add updateProjections function

This commit is contained in:
wyq 2022-08-10 11:09:32 +08:00
parent 622d88d3ea
commit 7ee744f212
3 changed files with 74 additions and 8 deletions

View File

@ -815,6 +815,13 @@ public class GLChartPanel extends GLJPanel implements IChartPanel {
//this.display();
}
/**
* Driven reshape method of the 3D plot
*/
public void reshape() {
this.plot3DGL.reshape(this, 0, 0, plot3DGL.width, plot3DGL.height);
}
/**
* Start animator
*/

View File

@ -10,6 +10,7 @@ import com.jogamp.opengl.*;
import com.jogamp.opengl.glu.GLU;
import com.jogamp.opengl.glu.GLUquadric;
import com.jogamp.opengl.glu.GLUtessellator;
import com.jogamp.opengl.glu.gl2.GLUgl2;
import com.jogamp.opengl.math.VectorUtil;
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
import com.jogamp.opengl.util.awt.TextRenderer;
@ -355,6 +356,22 @@ public class Plot3DGL extends Plot implements GLEventListener {
this.fixExtent = value;
}
/**
* Get width
* @return Width
*/
public int getWidth() {
return this.width;
}
/**
* Get height
* @return Height
*/
public int getHeight() {
return this.height;
}
/**
* Get if clip plane
* @return Boolean
@ -957,6 +974,9 @@ public class Plot3DGL extends Plot implements GLEventListener {
*/
public void setOrthographic(boolean value) {
this.orthographic = value;
/*if (this.drawable != null)
this.updateProjections(this.drawable);*/
}
/**
@ -4309,6 +4329,43 @@ public class Plot3DGL extends Plot implements GLEventListener {
gl.glLoadIdentity();
}
/**
* Update projections
*/
public void updateProjections(GLAutoDrawable drawable) {
final GL2 gl = drawable.getGL().getGL2();
final float h = (float) width / (float) height;
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
if (this.orthographic) {
float v = 2.0f;
switch (this.aspectType) {
case EQUAL:
gl.glOrthof(-v * h, v * h, -v, v, -distance, distance);
break;
default:
gl.glOrthof(-v, v, -v, v, -distance, distance);
break;
}
} else {
float near = 0.1f;
float far = 1000.0f;
switch (this.aspectType) {
case EQUAL:
glu.gluPerspective(45.0f, h, near, far);
break;
default:
glu.gluPerspective(45.0f, 1.0f, near, far);
break;
}
glu.gluLookAt(0.0f, 0.0f, distance, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
}
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
/**
* Get tight inset area
*

View File

@ -1,32 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\common_math\stats">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\random"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\signal"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\spatial"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\optimize"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\fitting"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\special"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\polar"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar"/>
</Path>
<File>
<OpenedFiles>
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\optimize\curve_fit_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\stats\beta_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar\bar_1.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\optimize\curve_fit_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\stats\beta_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar\bar_1.py"/>
</RecentFiles>
</File>
<Font>
@ -34,5 +36,5 @@
</Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
<Startup MainFormLocation="-7,0" MainFormSize="1457,797"/>
</MeteoInfo>