Bläddra i källkod

Added setting of glLineWidth form the GUI

Andreas Völker 5 år sedan
förälder
incheckning
d71cb512d9

+ 4 - 0
src/de/andreasvoelker/BlochFrame.java

@@ -16,6 +16,10 @@ public class BlochFrame extends GLCanvas {
         renderer.setNonlinearity(v);
     }
 
+    public void setLineWidth(float value) {
+        renderer.setLineWidth(value);
+    }
+
 
     class MyMouseMotionListener implements MouseMotionListener {
         int prevX, prevY;

+ 11 - 0
src/de/andreasvoelker/BlochRenderer.java

@@ -20,6 +20,9 @@ public class BlochRenderer implements GLEventListener {
     private float pitch = 0;
     private float yaw = 0;
 
+    private float lineWidth = 1.0f;
+
+
     public float getNonlinearity() {
         return nonlinearity;
     }
@@ -93,6 +96,7 @@ public class BlochRenderer implements GLEventListener {
         setupViewMatrix(gl);
         gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
         gl.glEnable(gl.GL_DEPTH_TEST);
+        gl.glLineWidth(lineWidth);
         if (blochSphere != null) {
             if (colormap != null){
                 colormap.enable(gl);
@@ -138,4 +142,11 @@ public class BlochRenderer implements GLEventListener {
         this.blochSphere = blochSphere;
     }
 
+    public float getLineWidth() {
+        return lineWidth;
+    }
+
+    public void setLineWidth(float lineWidth) {
+        this.lineWidth = lineWidth;
+    }
 }

+ 15 - 2
src/de/andreasvoelker/MainWindows.java

@@ -9,6 +9,7 @@ public class MainWindows extends JFrame {
     final JButton button;
     final BlochFrame blochFrame;
     final JSlider nonlinearRemapping;
+    final JSlider lineWidth;
 
     MainWindows(){
         super("BlochRender");
@@ -29,14 +30,26 @@ public class MainWindows extends JFrame {
         setLayout(new MigLayout("fill"));
         nonlinearRemapping = new JSlider();
         nonlinearRemapping.setMinimum(0);
-        nonlinearRemapping.setMajorTickSpacing(200);
+        nonlinearRemapping.setMaximum(200);
         nonlinearRemapping.setValue(20);
         nonlinearRemapping.addChangeListener(e -> blochFrame.setNonlinearity((float)(nonlinearRemapping.getValue())/20.0f));
 
-        add(blochFrame, "grow, span 1 3");
+        setLayout(new MigLayout("fill"));
+        lineWidth = new JSlider();
+        lineWidth.setMinimum(1);
+        lineWidth.setMaximum(200);
+        lineWidth.setValue(1);
+        lineWidth.addChangeListener(e -> blochFrame.setLineWidth((float)(lineWidth.getValue())/10.0f));
+
+        add(blochFrame, "grow, span 1 4");
+
         add(button, "wrap, span 2");
+
         add(new JLabel("Nonlinear remapping"));
         add(nonlinearRemapping, "wrap");
+        add(new JLabel("Linewidth"));
+        add(lineWidth, "wrap");
+
         add(label, "span 2");
         this.pack();