update surf plot function

This commit is contained in:
wyq 2023-06-05 16:00:00 +08:00
parent 77660473f9
commit f50beb48ea
12 changed files with 1562 additions and 52 deletions

View File

@ -8033,16 +8033,31 @@ public class GraphicFactory {
float[] vertexColor = new float[rowNum * colNum * 4]; float[] vertexColor = new float[rowNum * colNum * 4];
Color color; Color color;
Index index = va.getIndex(); Index index = va.getIndex();
for (int i = 0; i < rowNum; i++) { if (va.getDataType() == DataType.INT) {
for (int j = 0; j < colNum; j++) { for (int i = 0; i < rowNum; i++) {
idx = i * colNum + j; for (int j = 0; j < colNum; j++) {
vertexPosition[idx * 3] = xa.getFloat(idx); idx = i * colNum + j;
vertexPosition[idx * 3 + 1] = ya.getFloat(idx); vertexPosition[idx * 3] = xa.getFloat(idx);
vertexPosition[idx * 3 + 2] = za.getFloat(idx); vertexPosition[idx * 3 + 1] = ya.getFloat(idx);
index.set0(i); vertexPosition[idx * 3 + 2] = za.getFloat(idx);
index.set1(j); index.set0(i);
color = new Color(va.getInt(index.set2(0)), va.getInt(index.set2(1)), va.getInt(index.set2(2))); index.set1(j);
System.arraycopy(color.getRGBComponents(null), 0, vertexColor, idx * 4, 4); color = new Color(va.getInt(index.set2(0)), va.getInt(index.set2(1)), va.getInt(index.set2(2)));
System.arraycopy(color.getRGBComponents(null), 0, vertexColor, idx * 4, 4);
}
}
} else {
for (int i = 0; i < rowNum; i++) {
for (int j = 0; j < colNum; j++) {
idx = i * colNum + j;
vertexPosition[idx * 3] = xa.getFloat(idx);
vertexPosition[idx * 3 + 1] = ya.getFloat(idx);
vertexPosition[idx * 3 + 2] = za.getFloat(idx);
index.set0(i);
index.set1(j);
color = new Color(va.getFloat(index.set2(0)), va.getFloat(index.set2(1)), va.getFloat(index.set2(2)));
System.arraycopy(color.getRGBComponents(null), 0, vertexColor, idx * 4, 4);
}
} }
} }
surfaceGraphic.setVertexPosition(vertexPosition, rowNum); surfaceGraphic.setVertexPosition(vertexPosition, rowNum);

View File

@ -1433,7 +1433,7 @@ public class GLPlot extends Plot {
yMax = this.transform.transform_y((float) axesExtent.maxY); yMax = this.transform.transform_y((float) axesExtent.maxY);
zMin = this.transform.transform_z((float) axesExtent.minZ);*/ zMin = this.transform.transform_z((float) axesExtent.minZ);*/
float[] rgba = this.boxColor.getRGBComponents(null); float[] rgba = this.gridLine.getColor().getRGBComponents(null);
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]); gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
gl.glLineWidth(this.gridLine.getSize() * this.dpiScale); gl.glLineWidth(this.gridLine.getSize() * this.dpiScale);
gl.glBegin(GL2.GL_LINE_STRIP); gl.glBegin(GL2.GL_LINE_STRIP);
@ -1590,14 +1590,8 @@ public class GLPlot extends Plot {
yMax = (float) axesExtent.maxY; yMax = (float) axesExtent.maxY;
zMin = (float) axesExtent.minZ; zMin = (float) axesExtent.minZ;
zMax = (float) axesExtent.maxZ; zMax = (float) axesExtent.maxZ;
/*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);*/
float[] rgba = this.boxColor.getRGBComponents(null); float[] rgba = this.gridLine.getColor().getRGBComponents(null);
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]); gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
gl.glLineWidth(this.gridLine.getSize() * this.dpiScale); gl.glLineWidth(this.gridLine.getSize() * this.dpiScale);
if (this.angleY >= 180 && this.angleY < 360) { if (this.angleY >= 180 && this.angleY < 360) {
@ -1644,14 +1638,8 @@ public class GLPlot extends Plot {
yMax = (float) axesExtent.maxY; yMax = (float) axesExtent.maxY;
zMin = (float) axesExtent.minZ; zMin = (float) axesExtent.minZ;
zMax = (float) axesExtent.maxZ; zMax = (float) axesExtent.maxZ;
/*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);*/
float[] rgba = this.boxColor.getRGBComponents(null); float[] rgba = this.gridLine.getColor().getRGBComponents(null);
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]); gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
gl.glLineWidth(this.gridLine.getSize() * this.dpiScale); gl.glLineWidth(this.gridLine.getSize() * this.dpiScale);
if (this.angleY >= 180 && this.angleY < 360) { if (this.angleY >= 180 && this.angleY < 360) {

View File

@ -5,6 +5,7 @@
*/ */
package org.meteoinfo.chart.plot; package org.meteoinfo.chart.plot;
import org.meteoinfo.common.colors.ColorUtil;
import org.meteoinfo.geometry.legend.LineStyles; import org.meteoinfo.geometry.legend.LineStyles;
import org.meteoinfo.geometry.legend.PolylineBreak; import org.meteoinfo.geometry.legend.PolylineBreak;
@ -36,7 +37,7 @@ public class GridLine {
*/ */
public GridLine(boolean visible) { public GridLine(boolean visible) {
this.lineBreak = new PolylineBreak(); this.lineBreak = new PolylineBreak();
this.lineBreak.setColor(Color.LIGHT_GRAY); this.lineBreak.setColor(new Color(0.15f, 0.15f, 0.15f, 0.15f));
this.lineBreak.setStyle(LineStyles.DASH); this.lineBreak.setStyle(LineStyles.DASH);
this.top = false; this.top = false;
this.drawXLine = visible; this.drawXLine = visible;
@ -58,8 +59,36 @@ public class GridLine {
* @param value Color * @param value Color
*/ */
public void setColor(Color value){ public void setColor(Color value){
int alpha = this.getColor().getAlpha();
Color color = ColorUtil.getColor(value, alpha);
this.lineBreak.setColor(color);
}
/**
* Set color
* @param value Color
*/
public void setColorAndAlpha(Color value){
this.lineBreak.setColor(value); this.lineBreak.setColor(value);
} }
/**
* Set alpha
* @param value Alpha
*/
public void setAlpha(int value) {
Color color = ColorUtil.getColor(this.getColor(), value);
this.lineBreak.setColor(color);
}
/**
* Set alpha
* @param value Alpha
*/
public void setAlpha(float value) {
Color color = ColorUtil.getColor(this.getColor(), value);
this.lineBreak.setColor(color);
}
/** /**
* Get size * Get size

View File

@ -70,6 +70,27 @@ public class ColorUtil {
// </editor-fold> // </editor-fold>
// <editor-fold desc="Get Set Methods"> // <editor-fold desc="Get Set Methods">
/**
* Get new color from existing color and alpha
* @param color Existing color
* @param alpha Alpha
* @return
*/
public static Color getColor(Color color, int alpha) {
return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
}
/**
* Get new color from existing color and alpha
* @param color Existing color
* @param alpha Alpha
* @return
*/
public static Color getColor(Color color, float alpha) {
float[] rgba = color.getRGBColorComponents(null);
return new Color(rgba[0], rgba[1], rgba[2], alpha);
}
/** /**
* Get common color * Get common color
* *

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile"> <MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\map"> <Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\FY"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\awx"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\awx"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\contour"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\contour"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\fill"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\fill"/>
<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"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\dataconvert"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
</Path> </Path>
<File> <File>
<OpenedFiles> <OpenedFiles>
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/> <OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/> <OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surfc_1.py"/> <OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_color_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh\meshc_peaks.py"/> <OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_alpha_1.py"/>
</OpenedFiles> </OpenedFiles>
<RecentFiles> <RecentFiles>
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/> <RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/> <RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surfc_1.py"/> <RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_color_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh\meshc_peaks.py"/> <RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_alpha_1.py"/>
</RecentFiles> </RecentFiles>
</File> </File>
<Font> <Font>
@ -36,5 +38,5 @@
</Font> </Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/> <LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/> <Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,0" MainFormSize="1383,767"/> <Startup MainFormLocation="-7,0" MainFormSize="1419,836"/>
</MeteoInfo> </MeteoInfo>

View File

@ -606,7 +606,7 @@ class Axes3D(Axes):
axis.setTickLabelColor(ticklabelcolor) axis.setTickLabelColor(ticklabelcolor)
axis.setTickLabelFont(font) axis.setTickLabelFont(font)
def grid(self, b, **kwargs): def grid(self, b=None, **kwargs):
""" """
Turn the axes grids on or off. Turn the axes grids on or off.
@ -615,23 +615,29 @@ class Axes3D(Axes):
:param kwargs: *kwargs* are used to set the grid line properties. :param kwargs: *kwargs* are used to set the grid line properties.
""" """
gridline = self._axes.getGridLine() gridline = self._axes.getGridLine()
if b is None: if b is None and len(kwargs) == 0:
b = not gridline.isDrawZLine() b = not gridline.isDrawZLine()
axis = kwargs.pop('axis', 'all') axis = kwargs.pop('axis', 'all')
if axis == 'all': if b is not None:
gridline.setDrawXLine(b) if axis == 'all':
gridline.setDrawYLine(b) gridline.setDrawXLine(b)
gridline.setDrawZLine(b) gridline.setDrawYLine(b)
elif axis == 'x': gridline.setDrawZLine(b)
gridline.setDrawXLine(b) elif axis == 'x':
elif axis == 'y': gridline.setDrawXLine(b)
gridline.setDrawYLine(b) elif axis == 'y':
elif axis == 'z': gridline.setDrawYLine(b)
gridline.setDrawZLine(b) elif axis == 'z':
gridline.setDrawZLine(b)
color = kwargs.pop('color', None) color = kwargs.pop('color', None)
if not color is None: if not color is None:
c = plotutil.getcolor(color) c = plotutil.getcolor(color)
gridline.setColor(c) gridline.setColor(c)
alpha = kwargs.pop('alpha', None)
if alpha is not None:
gridline.setAlpha(float(alpha))
linewidth = kwargs.pop('linewidth', None) linewidth = kwargs.pop('linewidth', None)
if not linewidth is None: if not linewidth is None:
gridline.setSize(linewidth) gridline.setSize(linewidth)

View File

@ -8,8 +8,7 @@
from org.meteoinfo.chart.graphic import GraphicFactory from org.meteoinfo.chart.graphic import GraphicFactory
from org.meteoinfo.chart import AspectType from org.meteoinfo.chart import AspectType
from org.meteoinfo.geometry.legend import BreakTypes, BarBreak from org.meteoinfo.geometry.legend import BreakTypes, BarBreak, LegendManage
from org.meteoinfo.geo.legend import LegendManage
from org.meteoinfo.geo.layer import LayerTypes from org.meteoinfo.geo.layer import LayerTypes
from org.meteoinfo.geometry.shape import ShapeTypes from org.meteoinfo.geometry.shape import ShapeTypes
from org.meteoinfo.geometry.graphic import Graphic, GraphicCollection from org.meteoinfo.geometry.graphic import Graphic, GraphicCollection

View File

@ -210,7 +210,7 @@ def getcolormap(**kwargs):
cs.append(c) cs.append(c)
cmap = ColorMap(cs) cmap = ColorMap(cs)
else: else:
cmapstr = kwargs.pop('cmap', 'matlab_jet') cmapstr = kwargs.pop('cmap', 'parula')
if len(cmapstr) > 2 and cmapstr[-2:] == '_r': if len(cmapstr) > 2 and cmapstr[-2:] == '_r':
cmapstr = cmapstr[:-2] cmapstr = cmapstr[:-2]
reverse = True reverse = True
@ -843,7 +843,9 @@ def setlegendscheme_polygon(ls, **kwargs):
edge = kwargs.pop('edge', edge) edge = kwargs.pop('edge', edge)
edgesize = kwargs.pop('edgesize', None) edgesize = kwargs.pop('edgesize', None)
fill = kwargs.pop('fill', fill) fill = kwargs.pop('fill', fill)
alpha = kwargs.pop('alpha', None) alpha = kwargs.pop('facealpha', None)
if alpha is None:
alpha = kwargs.pop('alpha', None)
hatch = kwargs.pop('hatch', None) hatch = kwargs.pop('hatch', None)
hatch = gethatch(hatch) hatch = gethatch(hatch)
hatchsize = kwargs.pop('hatchsize', None) hatchsize = kwargs.pop('hatchsize', None)