update earth plot 3D functions

This commit is contained in:
wyq 2021-12-22 00:22:25 +08:00
parent 834e8108b8
commit 8edb10231d
11 changed files with 183 additions and 34 deletions

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.formdev:flatlaf:1.6.5">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf/1.6.5/flatlaf-1.6.5.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf/1.6.5/flatlaf-1.6.5-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf/1.6.5/flatlaf-1.6.5-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.formdev:flatlaf-extras:1.6.5">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf-extras/1.6.5/flatlaf-extras-1.6.5.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf-extras/1.6.5/flatlaf-extras-1.6.5-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/formdev/flatlaf-extras/1.6.5/flatlaf-extras-1.6.5-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.locationtech.proj4j:proj4j:1.1.4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/locationtech/proj4j/proj4j/1.1.4/proj4j-1.1.4.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/locationtech/proj4j/proj4j/1.1.4/proj4j-1.1.4-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/locationtech/proj4j/proj4j/1.1.4/proj4j-1.1.4-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -100,6 +100,16 @@
<artifactId>freehep-graphicsio-ps</artifactId>
<version>2.4</version>
</dependency>
<!--<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
<version>2.3.2</version>
</dependency>-->
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>

View File

@ -35,8 +35,8 @@ public class EarthPlot3D extends Plot3DGL {
public EarthPlot3D() {
super();
this.angleY = 160;
earthSurface(50);
addGraphic(this.surface);
//earthSurface(50);
//addGraphic(this.surface);
}
// </editor-fold>
@ -81,7 +81,7 @@ public class EarthPlot3D extends Plot3DGL {
public SurfaceGraphics earthSurface(int n) {
Array lon = ArrayUtil.lineSpace(-180.f, 180.f, n + 1, true);
Array lat = ArrayUtil.lineSpace(-90.f, 90.f, n + 1, true);
lat = lat.flip(0);
lat = lat.flip(0).copy();
Array[] lonlat = ArrayUtil.meshgrid(lon, lat);
lon = lonlat[0];
lat = lonlat[1];
@ -102,9 +102,11 @@ public class EarthPlot3D extends Plot3DGL {
*/
public void earthImage(String imageFile) throws IOException, ImageReadException {
BufferedImage image = ImageUtil.imageLoad(imageFile);
if (this.surface != null) {
this.surface.setImage(image);
if (this.surface == null) {
this.earthSurface(50);
this.addGraphic(this.surface);
}
this.surface.setImage(image);
}
// </editor-fold>
}

View File

@ -1952,7 +1952,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
private void drawPoint(GL2 gl, Graphic graphic) {
if (extent.intersects(graphic.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(graphic.getExtent());
if (isDraw) {
PointZShape shape = (PointZShape) graphic.getShape();
PointBreak pb = (PointBreak) graphic.getLegend();
float[] rgba = pb.getColor().getRGBComponents(null);
@ -2112,7 +2116,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
private void drawLineString(GL2 gl, Graphic graphic) {
if (extent.intersects(graphic.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(graphic.getExtent());
if (isDraw) {
PolylineZShape shape = (PolylineZShape) graphic.getShape();
ColorBreak cb = graphic.getLegend();
if (cb.getBreakType() == BreakTypes.COLOR_BREAK_COLLECTION) {
@ -2150,7 +2158,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
private void drawPipe(GL2 gl, Graphic graphic) {
if (extent.intersects(graphic.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(graphic.getExtent());
if (isDraw) {
PipeShape shape = (PipeShape) graphic.getShape();
ColorBreak cb = graphic.getLegend();
shape.transform(transform);
@ -2203,7 +2215,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
private void drawStreamline(GL2 gl, Graphic graphic) {
if (extent.intersects(graphic.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(graphic.getExtent());
if (isDraw) {
PolylineZShape shape = (PolylineZShape) graphic.getShape();
ColorBreak cb = graphic.getLegend();
if (cb.getBreakType() == BreakTypes.COLOR_BREAK_COLLECTION) {
@ -2282,7 +2298,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
private void drawPipeStreamline(GL2 gl, Graphic graphic) {
if (extent.intersects(graphic.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(graphic.getExtent());
if (isDraw) {
PipeShape shape = (PipeShape) graphic.getShape();
ColorBreak cb = graphic.getLegend();
shape.transform(transform);
@ -2370,12 +2390,16 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
private void drawPolygonShape(GL2 gl, Graphic graphic) {
if (extent.intersects(graphic.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(graphic.getExtent());
if (isDraw) {
PolygonZShape shape = (PolygonZShape) graphic.getShape();
PolygonBreak pb = (PolygonBreak) graphic.getLegend();
List<PolygonZ> polygonZS = (List<PolygonZ>) shape.getPolygons();
for (int i = 0; i < polygonZS.size(); i++) {
PolygonZ polygonZ = (PolygonZ) shape.getPolygons().get(i);
PolygonZ polygonZ = polygonZS.get(i);
if (pb.isDrawFill()) {
if (polygonZ instanceof TessPolygon) {
drawTessPolygon(gl, (TessPolygon) polygonZ, pb);
@ -2600,7 +2624,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
PointZ p;
for (int i = 0; i < graphic.getNumGraphics(); i++) {
Graphic gg = graphic.getGraphicN(i);
if (extent.intersects(gg.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(gg.getExtent());
if (isDraw) {
PolygonZShape shape = (PolygonZShape) gg.getShape();
PolygonBreak pb = (PolygonBreak) gg.getLegend();
for (PolygonZ poly : (List<PolygonZ>) shape.getPolygons()) {
@ -2640,7 +2668,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
PointZ p;
for (int i = 0; i < graphic.getNumGraphics(); i++) {
Graphic gg = graphic.getGraphicN(i);
if (extent.intersects(gg.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(gg.getExtent());
if (isDraw) {
PolygonZShape shape = (PolygonZShape) gg.getShape();
PolygonBreak pb = (PolygonBreak) gg.getLegend();
for (PolygonZ poly : (List<PolygonZ>) shape.getPolygons()) {
@ -2843,12 +2875,12 @@ public class Plot3DGL extends Plot implements GLEventListener {
float float_x, float_y, float_xb, float_yb;
for (int i = 0; i < dim1 - 1; i++) {
for (int j = 0; j < dim2 - 1; j++) {
float_y = (float) (i) / dim1;
float_y = (float) (i) / (dim1 - 1);
//float_y = 1.0f - (float) (i) / dim1;
float_x = (float) (j) / dim2;
float_yb = (float) (i + 1) / dim1;
float_x = (float) (j) / (dim2 - 1);
float_yb = (float) (i + 1) / (dim1 - 1);
//float_yb = 1.0f - (float) (i + 1) / dim1;
float_xb = (float) (j + 1) / dim2;
float_xb = (float) (j + 1) / (dim2 - 1);
gl.glNormal3fv(JOGLUtil.toArray(surface.getNormal(i, j)), 0);
gl.glTexCoord2f(float_x, float_y);
gl.glVertex3fv(JOGLUtil.toArray(surface.getTVertex(i, j)), 0);
@ -3224,7 +3256,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
void drawWindArrow(GL2 gl, Graphic graphic) {
if (extent.intersects(graphic.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(graphic.getExtent());
if (isDraw) {
WindArrow3D shape = (WindArrow3D) graphic.getShape();
PointBreak pb = (PointBreak) graphic.getLegend();
PointZ sp = (PointZ) shape.getPoint();
@ -3398,7 +3434,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
void drawCubic(GL2 gl, Graphic graphic) {
if (extent.intersects(graphic.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(graphic.getExtent());
if (isDraw) {
CubicShape cubic = (CubicShape) graphic.getShape();
BarBreak bb = (BarBreak) graphic.getLegend();
List<PointZ> ps = cubic.getPoints();
@ -3441,7 +3481,11 @@ public class Plot3DGL extends Plot implements GLEventListener {
}
void drawCylinder(GL2 gl, Graphic graphic) {
if (extent.intersects(graphic.getExtent())) {
boolean isDraw = true;
if (this.clipPlane)
isDraw = extent.intersects(graphic.getExtent());
if (isDraw) {
CylinderShape cylinder = (CylinderShape) graphic.getShape();
BarBreak bb = (BarBreak) graphic.getLegend();
List<PointZ> ps = cylinder.getPoints();

View File

@ -1,8 +1,13 @@
package org.meteoinfo.chart.jogl;
import org.meteoinfo.chart.graphic.*;
import org.meteoinfo.chart.jogl.tessellator.Primitive;
import org.meteoinfo.chart.jogl.tessellator.TessPolygon;
import org.meteoinfo.geometry.graphic.Graphic;
import org.meteoinfo.geometry.legend.PolygonBreak;
import org.meteoinfo.geometry.shape.PointZ;
import org.meteoinfo.geometry.shape.PolygonZ;
import org.meteoinfo.geometry.shape.PolygonZShape;
import org.meteoinfo.geometry.shape.Shape;
import java.util.ArrayList;
@ -21,9 +26,9 @@ public class SphericalTransform {
public static float[] transform(float lon, float lat, float alt) {
double u = Math.toRadians(lon);
double v = Math.toRadians(lat);
float x = (float) (Math.cos(u) * Math.cos(v)) * radius;
float y = (float) (Math.sin(u) * Math.cos(v)) * radius;
float z = (float) Math.sin(v) * radius + alt;
float x = (float) (Math.cos(u) * Math.cos(v)) * (radius + alt);
float y = (float) (Math.sin(u) * Math.cos(v)) * (radius + alt);
float z = (float) Math.sin(v) * (radius + alt);
return new float[]{x, y, z};
}
@ -68,11 +73,34 @@ public class SphericalTransform {
for (int i = 0; i < graphics.getNumGraphics(); i++) {
Graphic gg = graphics.getGraphicN(i);
Shape shape = gg.getGraphicN(0).getShape();
boolean isTess = false;
if (shape instanceof PolygonZShape) {
PolygonBreak pb = (PolygonBreak) gg.getGraphicN(0).getLegend();
isTess = pb.isDrawFill();
}
if (isTess) {
PolygonZShape polygonZShape = (PolygonZShape) shape;
List<PolygonZ> polygonZS = (List<PolygonZ>) polygonZShape.getPolygons();
for (int j = 0; j < polygonZS.size(); j++) {
PolygonZ polygonZ = polygonZS.get(j);
TessPolygon tessPolygon = new TessPolygon(polygonZ);
for (Primitive primitive : tessPolygon.getPrimitives()) {
for (int k = 0; k < primitive.vertices.size(); k++) {
primitive.vertices.set(k, transform(primitive.vertices.get(k)));
}
}
polygonZS.set(j, tessPolygon);
}
} else {
List<PointZ> points = (List<PointZ>) shape.getPoints();
for (int j = 0; j < points.size(); j++) {
points.set(j, transform(points.get(j)));
}
if (shape instanceof PolygonZShape)
((PolygonZShape) shape).setPoints_keep(points);
else
shape.setPoints(points);
}
gg.setShape(shape);
graphics.setGraphicN(i, gg);
}

View File

@ -191,6 +191,16 @@ public class PolygonShape extends Shape implements Cloneable {
updatePolygons();
}
/**
* Set points and keep the polygons
* @param points The points
*/
public void setPoints_keep(List<? extends PointD> points){
_points = points;
this.setExtent(GeometryUtil.getPointsExtent(_points));
updatePolygons_keep();
}
/**
* Set points and keep the polygons
* @param points

View File

@ -1,6 +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\earth">
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\convolution"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
@ -14,19 +14,21 @@
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<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"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\earth"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
</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\jogl\surf_elev_texturemap.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\earth\contour.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\earth\geoshow_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\earth\contourf.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\jogl\surf_elev_texturemap.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\earth\contour.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\earth\geoshow_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\earth\contourf.py"/>
</RecentFiles>
</File>
<Font>
@ -34,5 +36,5 @@
</Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,0" MainFormSize="1280,715"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
</MeteoInfo>

View File

@ -1535,7 +1535,11 @@ class EarthAxes3D(Axes3DGL):
super(EarthAxes3D, self).__init__(*args, **kwargs)
image = kwargs.pop('image', 'world_topo.jpg')
self.axes.earthImage(os.path.join(migl.get_map_folder(), image))
if not image is None:
if not os.path.exists(image):
image = os.path.join(migl.get_map_folder(), image)
if os.path.exists(image):
self.axes.earthImage(image)
def _set_plot(self, plot):
"""
@ -1552,4 +1556,14 @@ class EarthAxes3D(Axes3DGL):
def axestype(self):
return '3d_Earth'
def earth_image(self, image):
"""
Set earth surface image.
:param image: (*str*) Earth image file path.
"""
if not os.path.exists(image):
image = os.path.join(migl.get_map_folder(), image)
if os.path.exists(image):
self.axes.earthImage(image)
####################################################