update mouse dragging function for 3D axes

This commit is contained in:
wyq 2021-12-29 23:45:06 +08:00
parent 73eb8aaf8d
commit 3bcca6808d
5 changed files with 21 additions and 17 deletions

View File

@ -234,8 +234,5 @@ public class EarthPlot3D extends Plot3DGL {
}
}
private float getScale() {
return (float) (this.extent.getWidth() / this.drawExtent.getWidth());
}
// </editor-fold>
}

View File

@ -319,13 +319,13 @@ public class GLChartPanel extends GLJPanel implements IChartPanel {
} else {
size = e.getComponent().getSize();
float thetaY = 180.0f * ((float) (x - this.mouseLastPos.x) / size.width);
float thetaY = 360.0f * ((float) (x - this.mouseLastPos.x) / size.width);
float thetaX = 180.0f * ((float) (this.mouseLastPos.y - y) / size.height);
if (this.plot3DGL instanceof EarthPlot3D) {
float ratio = (float) (this.plot3DGL.getDrawExtent().getWidth() / this.plot3DGL.getExtent().getWidth());
thetaY *= ratio;
thetaX *= ratio;
float scale = this.plot3DGL.getScale();
thetaY /= scale;
thetaX /= scale;
}
float elevation = this.plot3DGL.getAngleX() - thetaX;
@ -349,11 +349,12 @@ public class GLChartPanel extends GLJPanel implements IChartPanel {
this.repaint();
} else if (SwingUtilities.isRightMouseButton(e)) {
size = e.getComponent().getSize();
float shift = 180.0f * ((float) (this.mouseLastPos.x - x) / size.width);
if (!(this.plot3DGL instanceof EarthPlot3D)) {
shift = -shift;
float shift = 360.0f * ((float) (this.mouseLastPos.x - x) / size.width);
if (this.plot3DGL instanceof EarthPlot3D) {
float scale = this.plot3DGL.getScale();
shift /= -scale;
}
float head = this.plot3DGL.getHeadAngle() + shift;
float head = this.plot3DGL.getHeadAngle() - shift;
if (head >= 360) {
head -= 360;
} else if (head < 0) {

View File

@ -3868,6 +3868,14 @@ public class Plot3DGL extends Plot implements GLEventListener {
return ls;
}
/**
* Get extent scale - extent / draw extent
* @return Extent scale
*/
public float getScale() {
return (float) (this.extent.getWidth() / this.drawExtent.getWidth());
}
@Override
public void dispose(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();

View File

@ -19,16 +19,14 @@
</Path>
<File>
<OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\classification\saturn.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d_earth\isosurface_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d_earth\streamslice_pitch.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d_earth\CALIPSO_L1_3d.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar_1.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\classification\saturn.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d_earth\isosurface_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d_earth\streamslice_pitch.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d_earth\CALIPSO_L1_3d.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar_1.py"/>
</RecentFiles>
</File>
<Font>
@ -36,5 +34,5 @@
</Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,0" MainFormSize="1441,807"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
</MeteoInfo>

View File

@ -8,5 +8,5 @@
<ScriptLanguage Language="Jython"/>
<LookFeel LafDecorated="true" Name="FlatLightLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-6,0" MainFormSize="1293,685" ShowMeteoDataDlg="false"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685" ShowMeteoDataDlg="true"/>
</MeteoInfo>