From: Marko Luukkainen Date: Wed, 21 Oct 2020 08:34:53 +0000 (+0300) Subject: DPI scaling for vtkView X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=283135023599b52fdb3b1455553e5f8434d25eff;p=simantics%2F3d.git DPI scaling for vtkView gitlab #143 Change-Id: I09408079abaaa66675bfa2397f6c795f5d5f0408 --- diff --git a/org.simantics.g3d.vtk/META-INF/MANIFEST.MF b/org.simantics.g3d.vtk/META-INF/MANIFEST.MF index 1ba1aaf6..81a1ae20 100644 --- a/org.simantics.g3d.vtk/META-INF/MANIFEST.MF +++ b/org.simantics.g3d.vtk/META-INF/MANIFEST.MF @@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.core.runtime, org.simantics.ui;bundle-version="1.0.0", vtk.rendering;bundle-version="8.2.0", org.simantics.utils.thread.swt;bundle-version="1.1.0", - org.slf4j.api + org.slf4j.api, + org.simantics.scenegraph;bundle-version="1.1.1" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Export-Package: org.simantics.g3d.vtk.action, diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/InteractiveVtkPanel.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/InteractiveVtkPanel.java index d697070c..761309e2 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/InteractiveVtkPanel.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/InteractiveVtkPanel.java @@ -20,6 +20,7 @@ import org.eclipse.core.runtime.Platform; import org.simantics.g3d.scenegraph.RenderListener; import org.simantics.g3d.vtk.action.vtkAction; import org.simantics.g3d.vtk.common.VtkView; +import org.simantics.scenegraph.utils.DPIUtil; import org.simantics.utils.threads.AWTThread; import org.simantics.utils.threads.IThreadWorkQueue; @@ -127,14 +128,29 @@ public class InteractiveVtkPanel extends vtkPanel implements VtkView { } public void setSize(int x, int y) { + super.setSize(x, y); + } + + public void _setSize(int x, int y) { + System.out.println(this.getClass().getSimpleName() + " " + windowset + " setSize " +x + " " + y); if (windowset == 1) { + Lock(); rw.SetSize(x, y); iren.SetSize(x, y); iren.ConfigureEvent(); UnLock(); + } else { + if (x > 1000) + System.out.println(); } } + + @Override + public void setBounds(int x, int y, int width, int height) { + super.setBounds(x, y, width, height); + _setSize(width, height); + } private vtkScenePicker scenePicker; @@ -440,6 +456,16 @@ public class InteractiveVtkPanel extends vtkPanel implements VtkView { repaint(); } + @Override + public double upscale(double d) { + return DPIUtil.upscale(d); + } + + @Override + public int upscale(int i) { + return DPIUtil.upscale(i); + } + } diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VtkView.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VtkView.java index 5bbd9c9e..dd6b98cd 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VtkView.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VtkView.java @@ -28,5 +28,8 @@ public interface VtkView { public void addDeletable(vtkObjectBase o); public void removeDeletable (vtkObjectBase o); + + public int upscale(int i); + public double upscale(double d); } diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/InteractiveVtkComposite.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/InteractiveVtkComposite.java index da984c08..406c713d 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/InteractiveVtkComposite.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/InteractiveVtkComposite.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.Platform; +import org.eclipse.swt.internal.DPIUtil; import org.eclipse.swt.widgets.Composite; import org.simantics.g3d.scenegraph.RenderListener; import org.simantics.g3d.vtk.action.vtkAction; @@ -415,6 +416,16 @@ public class InteractiveVtkComposite extends vtkSwtComponent implements VtkView{ return null; } + @Override + public int upscale(int i) { + return DPIUtil.autoScaleUp(i); + } + + @Override + public double upscale(double d) { + return (double)DPIUtil.autoScaleUp((float)d); + } + }