Remove xmin, xmax, ymin, ymax, zmin, zmax variables in Plot3DGL.

This commit is contained in:
wyq 2022-06-10 20:28:35 +08:00
parent 20e9848b27
commit 567bb029ac
4 changed files with 62 additions and 86 deletions

View File

@ -99,15 +99,9 @@ public class EarthPlot3D extends Plot3DGL {
// <editor-fold desc="Method">
void updateDataExtent() {
xmin = (float) dataExtent.minX;
xmax = (float) dataExtent.maxX;
ymin = (float) dataExtent.minY;
ymax = (float) dataExtent.maxY;
zmin = (float) dataExtent.minZ;
zmax = (float) dataExtent.maxZ;
xAxis.setMinMaxValue(xmin, xmax);
yAxis.setMinMaxValue(ymin, ymax);
zAxis.setMinMaxValue(zmin, zmax);
xAxis.setMinMaxValue(dataExtent.minX, dataExtent.maxX);
yAxis.setMinMaxValue(dataExtent.minY, dataExtent.maxY);
zAxis.setMinMaxValue(dataExtent.minZ, dataExtent.maxZ);
}
/**
@ -314,12 +308,12 @@ public class EarthPlot3D extends Plot3DGL {
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
gl.glLineWidth(this.zAxis.getLineWidth() * this.dpiScale);
gl.glBegin(GL2.GL_LINES);
Vector3f xyz = SphericalTransform.transform(loc.X, loc.Y, this.zmin);
Vector3f xyz = SphericalTransform.transform(loc.X, loc.Y, (float) this.dataExtent.minZ);
x = this.transform.transform_x(xyz.x);
y = this.transform.transform_y(xyz.y);
z = this.transform.transform_z(xyz.z);
gl.glVertex3f(x, y, z);
xyz = SphericalTransform.transform(loc.X, loc.Y, this.zmax);
xyz = SphericalTransform.transform(loc.X, loc.Y, (float) this.dataExtent.maxZ);
x = this.transform.transform_x(xyz.x);
y = this.transform.transform_y(xyz.y);
z = this.transform.transform_z(xyz.z);
@ -339,7 +333,7 @@ public class EarthPlot3D extends Plot3DGL {
strWidth = 0.0f;
for (int i = 0; i < this.zAxis.getTickValues().length; i += skip) {
v = (float) this.zAxis.getTickValues()[i];
if (v < zmin || v > zmax) {
if (v < dataExtent.minZ || v > dataExtent.maxZ) {
continue;
}
@ -385,7 +379,7 @@ public class EarthPlot3D extends Plot3DGL {
//Draw z axis label
ChartText label = this.zAxis.getLabel();
if (label != null) {
v = (zmin + zmax) / 2;
v = (float) (dataExtent.minZ + dataExtent.maxZ) / 2;
xyz = SphericalTransform.transform(loc.X, loc.Y, v);
x = this.transform.transform_x(xyz.x);
y = this.transform.transform_y(xyz.y);
@ -430,10 +424,10 @@ public class EarthPlot3D extends Plot3DGL {
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
gl.glLineWidth(this.zAxis.getLineWidth() * this.dpiScale);
gl.glBegin(GL2.GL_LINES);
Vector3f xyz = SphericalTransform.transform(loc.X, loc.Y, this.zmin);
Vector3f xyz = SphericalTransform.transform(loc.X, loc.Y, (float) this.dataExtent.minZ);
xyz = this.transform.transform(xyz);
gl.glVertex3f(xyz.x, xyz.y, xyz.z);
Vector3f xyz1 = SphericalTransform.transform(loc.X, loc.Y, this.zmax);
Vector3f xyz1 = SphericalTransform.transform(loc.X, loc.Y, (float) this.dataExtent.maxZ);
xyz1 = this.transform.transform(xyz1);
gl.glVertex3f(xyz1.x, xyz1.y, xyz1.z);
gl.glEnd();
@ -451,7 +445,7 @@ public class EarthPlot3D extends Plot3DGL {
strWidth = 0.0f;
for (int i = 0; i < this.zAxis.getTickValues().length; i += skip) {
v = (float) this.zAxis.getTickValues()[i];
if (v < zmin || v > zmax) {
if (v < dataExtent.minZ || v > dataExtent.maxZ) {
continue;
}
@ -492,7 +486,7 @@ public class EarthPlot3D extends Plot3DGL {
//Draw z axis label
ChartText label = this.zAxis.getLabel();
if (label != null) {
v = (zmin + zmax) / 2;
v = (float) (dataExtent.minZ + dataExtent.maxZ) / 2;
xyz = SphericalTransform.transform(loc.X, loc.Y, v);
xyz = this.transform.transform(xyz);
mvMatrix.transformPosition(xyz);

View File

@ -109,12 +109,13 @@ public class MapPlot3D extends Plot3DGL {
@Override
protected void drawAxis(GL2 gl) {
float xMin = this.transform.transform_x(this.xmin);
float xMax = this.transform.transform_x(this.xmax);
float yMin = this.transform.transform_y(this.ymin);
float yMax = this.transform.transform_y(this.ymax);
float zMin = this.transform.transform_z(this.zmin);
float zMax = this.transform.transform_z(this.zmax);
float xMin, xMax, yMin, yMax, zMin, zMax;
xMin = this.transform.transform_x((float) axesExtent.minX);
xMax = this.transform.transform_x((float) axesExtent.maxX);
yMin = this.transform.transform_y((float) axesExtent.minY);
yMax = this.transform.transform_y((float) axesExtent.maxY);
zMin = this.transform.transform_z((float) axesExtent.minZ);
zMax = this.transform.transform_z((float) axesExtent.maxZ);
gl.glDepthFunc(GL.GL_ALWAYS);
@ -164,7 +165,7 @@ public class MapPlot3D extends Plot3DGL {
GridLabel gridLabel = lonLabels.get(i);
PointD point = gridLabel.getCoord();
x = (float) point.X;
if (x < xmin || x > xmax) {
if (x < axesExtent.minX || x > axesExtent.maxX) {
continue;
}
x = this.transform.transform_x(x);
@ -238,7 +239,7 @@ public class MapPlot3D extends Plot3DGL {
GridLabel gridLabel = latLabels.get(i);
PointD point = gridLabel.getCoord();
y = (float) point.Y;
if (y < ymin || y > ymax) {
if (y < axesExtent.minY || y > axesExtent.maxY) {
continue;
}
y = this.transform.transform_y(y);
@ -328,7 +329,7 @@ public class MapPlot3D extends Plot3DGL {
float v;
for (int i = 0; i < this.zAxis.getTickValues().length; i += skip) {
v = (float) this.zAxis.getTickValues()[i];
if (v < zmin || v > zmax) {
if (v < axesExtent.minZ || v > axesExtent.maxZ) {
continue;
}
v = this.transform.transform_z(v);

View File

@ -93,8 +93,8 @@ public class Plot3DGL extends Plot implements GLEventListener {
protected final Axis yAxis;
protected final Axis zAxis;
protected List<ZAxisOption> zAxisLocations;
protected float xmin, xmax = 1.0f, ymin;
protected float ymax = 1.0f, zmin, zmax = 1.0f;
//protected float xmin, xmax = 1.0f, ymin;
//protected float ymax = 1.0f, zmin, zmax = 1.0f;
protected Transform transform = new Transform();
protected boolean clipPlane = true;
protected boolean axesZoom = false;
@ -146,9 +146,6 @@ public class Plot3DGL extends Plot implements GLEventListener {
this.zAxis = new Axis();
this.zAxis.setTickLength(8);
this.zAxisLocations = new ArrayList<>();
this.graphicExtent = new Extent3D();
Extent3D extent3D = new Extent3D(-1, 1, -1, 1, -1, 1);
this.setDrawExtent((Extent3D) extent3D.clone());
this.fixExtent = false;
this.graphics = new GraphicCollection3D();
this.hideOnDrag = false;
@ -163,6 +160,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
this.orthographic = true;
this.distance = 5.f;
this.initAngles();
this.graphicExtent = new Extent3D();
Extent3D extent3D = new Extent3D(-1, 1, -1, 1, -1, 1);
this.drawExtent = (Extent3D) extent3D.clone();
this.transform.setExtent(this.drawExtent);
this.axesExtent = (Extent3D) this.drawExtent.clone();
}
/**
@ -312,27 +314,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param value Extent
*/
public void setDrawExtent(Extent3D extent) {
xmin = (float) extent.minX;
xmax = (float) extent.maxX;
ymin = (float) extent.minY;
ymax = (float) extent.maxY;
zmin = (float) extent.minZ;
zmax = (float) extent.maxZ;
if (xmin == xmax) {
xmin -= 1;
xmax += 1;
}
if (ymin == ymax) {
ymin -= 1;
ymax += 1;
}
if (zmin == zmax) {
zmin -= 1;
zmax += 1;
}
this.drawExtent = new Extent3D(xmin, xmax, ymin, ymax, zmin, zmax);
this.drawExtent = (Extent3D) extent;
this.transform.setExtent(this.drawExtent);
if (!this.axesZoom) {
@ -745,7 +727,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @return X minimum
*/
public float getXMin() {
return this.xmin;
return (float) this.drawExtent.minX;
}
/**
@ -754,9 +736,9 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param value Minimum x
*/
public void setXMin(float value) {
this.xmin = value;
this.drawExtent.minX = value;
updateExtent();
this.xAxis.setMinMaxValue(xmin, xmax);
this.xAxis.setMinMaxValue(drawExtent.minX, drawExtent.maxX);
}
/**
@ -765,7 +747,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @return X maximum
*/
public float getXMax() {
return this.xmax;
return (float) this.drawExtent.maxX;
}
/**
@ -774,9 +756,9 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param value Maximum x
*/
public void setXMax(float value) {
this.xmax = value;
this.drawExtent.maxX = value;
updateExtent();
this.xAxis.setMinMaxValue(xmin, xmax);
this.xAxis.setMinMaxValue(drawExtent.minX, drawExtent.maxX);
}
/**
@ -786,8 +768,8 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param max Maximum value
*/
public void setXMinMax(float min, float max) {
this.xmin = min;
this.xmax = max;
this.drawExtent.minX = min;
this.drawExtent.maxX = max;
updateExtent();
this.xAxis.setMinMaxValue(min, max);
this.fixExtent = true;
@ -799,7 +781,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @return Y minimum
*/
public float getYMin() {
return this.ymin;
return (float) this.drawExtent.minY;
}
/**
@ -808,9 +790,9 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param value Minimum y
*/
public void setYMin(float value) {
this.ymin = value;
this.drawExtent.minY = value;
updateExtent();
this.yAxis.setMinMaxValue(ymin, ymax);
this.yAxis.setMinMaxValue(drawExtent.minY, drawExtent.maxY);
}
/**
@ -819,7 +801,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @return Y maximum
*/
public float getYMax() {
return this.ymax;
return (float) this.drawExtent.maxY;
}
/**
@ -828,9 +810,9 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param value Maximum y
*/
public void setYMax(float value) {
this.ymax = value;
this.drawExtent.maxY = value;
updateExtent();
this.yAxis.setMinMaxValue(ymin, ymax);
this.yAxis.setMinMaxValue(drawExtent.minY, drawExtent.maxY);
}
/**
@ -840,8 +822,8 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param max Maximum value
*/
public void setYMinMax(float min, float max) {
this.ymin = min;
this.ymax = max;
this.drawExtent.minY = min;
this.drawExtent.maxY = max;
updateExtent();
this.yAxis.setMinMaxValue(min, max);
this.fixExtent = true;
@ -853,7 +835,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @return Z minimum
*/
public float getZMin() {
return this.zmin;
return (float) this.drawExtent.minZ;
}
/**
@ -862,9 +844,9 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param value Minimum z
*/
public void setZMin(float value) {
this.zmin = value;
this.drawExtent.minZ = value;
updateExtent();
this.zAxis.setMinMaxValue(zmin, zmax);
this.zAxis.setMinMaxValue(drawExtent.minZ, drawExtent.maxZ);
}
/**
@ -873,7 +855,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @return Z maximum
*/
public float getZMax() {
return this.zmax;
return (float) this.drawExtent.maxZ;
}
/**
@ -882,9 +864,9 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param value Maximum z
*/
public void setZMax(float value) {
this.zmax = value;
this.drawExtent.maxZ = value;
updateExtent();
this.zAxis.setMinMaxValue(zmin, zmax);
this.zAxis.setMinMaxValue(drawExtent.minZ, drawExtent.maxZ);
}
/**
@ -894,8 +876,8 @@ public class Plot3DGL extends Plot implements GLEventListener {
* @param max Maximum value
*/
public void setZMinMax(float min, float max) {
this.zmin = min;
this.zmax = max;
this.drawExtent.minZ = min;
this.drawExtent.maxZ = max;
updateExtent();
this.zAxis.setMinMaxValue(min, max);
this.fixExtent = true;
@ -1046,7 +1028,6 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
protected void updateExtent() {
this.drawExtent = new Extent3D(xmin, xmax, ymin, ymax, zmin, zmax);
this.transform.setExtent(this.drawExtent);
this.setAxesExtent((Extent3D) this.drawExtent.clone());
}

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\plot"/>
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
@ -10,25 +9,26 @@
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\calipso"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
</Path>
<File>
<OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\isosurface_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume_specular.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_proj.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\CALIPSO_L1_3d_axis.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\isosurface_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\volumeplot_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume_specular.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_proj.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\CALIPSO_L1_3d_axis.py"/>
</RecentFiles>
</File>
<Font>
@ -36,5 +36,5 @@
</Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,0" MainFormSize="1409,776"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
</MeteoInfo>