]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
DPI scaling for vtkView 49/4549/2
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 21 Oct 2020 08:34:53 +0000 (11:34 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 21 Oct 2020 08:35:33 +0000 (11:35 +0300)
gitlab #143

Change-Id: I09408079abaaa66675bfa2397f6c795f5d5f0408

org.simantics.g3d.vtk/META-INF/MANIFEST.MF
org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/InteractiveVtkPanel.java
org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VtkView.java
org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/InteractiveVtkComposite.java

index 1ba1aaf62e4cc3e07c7ce0c8ab934df446ec188b..81a1ae204719ddd2da155f3c6d011a5c35f10a03 100644 (file)
@@ -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,
index d697070cfbae165dfb49ff7cf3efe5a3dd28c738..761309e2697b18e0d9cdcbdfd68fada219ba9cc9 100644 (file)
@@ -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);
+       }
+       
        
        
 }
index 5bbd9c9eb8ee837453079fc539287cff875ab98f..dd6b98cde837f53d33ff0bb0a658cc0c348d630e 100644 (file)
@@ -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);
 
 }
index da984c086650c2c4578b7593175e44a4c5a9cfb1..406c713d4cb64ba63e85f21e5975de01e09c31db 100644 (file)
@@ -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);
+       }
+       
        
        
 }