mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add fill function
This commit is contained in:
parent
b4b6a7ffd2
commit
0365238698
@ -1613,35 +1613,57 @@ public class GraphicFactory {
|
||||
* @return Graphics
|
||||
*/
|
||||
public static GraphicCollection createPolygons(Array xa, Array ya, PolygonBreak pgb) {
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
|
||||
GraphicCollection graphics = new GraphicCollection();
|
||||
double x, y;
|
||||
int n = (int) xa.getSize();
|
||||
PolygonShape pgs;
|
||||
PointD p;
|
||||
List<PointD> points = new ArrayList<>();
|
||||
IndexIterator xIter = xa.getIndexIterator();
|
||||
IndexIterator yIter = ya.getIndexIterator();
|
||||
while (xIter.hasNext()){
|
||||
x = xIter.getDoubleNext();
|
||||
y = yIter.getDoubleNext();
|
||||
if (Double.isNaN(x)) {
|
||||
if (points.size() > 2) {
|
||||
pgs = new PolygonShape();
|
||||
pgs.setPoints(points);
|
||||
Graphic aGraphic = new Graphic(pgs, pgb);
|
||||
graphics.add(aGraphic);
|
||||
if (xa.getRank() == 1) {
|
||||
IndexIterator xIter = xa.getIndexIterator();
|
||||
IndexIterator yIter = ya.getIndexIterator();
|
||||
while (xIter.hasNext()) {
|
||||
x = xIter.getDoubleNext();
|
||||
y = yIter.getDoubleNext();
|
||||
if (Double.isNaN(x)) {
|
||||
if (points.size() > 2) {
|
||||
pgs = new PolygonShape();
|
||||
pgs.setPoints(points);
|
||||
Graphic aGraphic = new Graphic(pgs, pgb);
|
||||
graphics.add(aGraphic);
|
||||
}
|
||||
points = new ArrayList<>();
|
||||
} else {
|
||||
p = new PointD(x, y);
|
||||
points.add(p);
|
||||
}
|
||||
points = new ArrayList<>();
|
||||
} else {
|
||||
p = new PointD(x, y);
|
||||
points.add(p);
|
||||
}
|
||||
}
|
||||
if (points.size() > 2) {
|
||||
pgs = new PolygonShape();
|
||||
pgs.setPoints(points);
|
||||
Graphic aGraphic = new Graphic(pgs, pgb);
|
||||
graphics.add(aGraphic);
|
||||
if (points.size() > 2) {
|
||||
pgs = new PolygonShape();
|
||||
pgs.setPoints(points);
|
||||
Graphic aGraphic = new Graphic(pgs, pgb);
|
||||
graphics.add(aGraphic);
|
||||
}
|
||||
} else {
|
||||
int[] shape = xa.getShape();
|
||||
int nRow = shape[0];
|
||||
int nCol = shape[1];
|
||||
int idx;
|
||||
for (int i = 0; i < nCol; i++) {
|
||||
points = new ArrayList<>();
|
||||
for (int j = 0; j < nRow; j++) {
|
||||
idx = j * nCol + i;
|
||||
x = xa.getDouble(idx);
|
||||
y = ya.getDouble(idx);
|
||||
points.add(new PointD(x, y));
|
||||
}
|
||||
pgs = new PolygonShape();
|
||||
pgs.setPoints(points);
|
||||
graphics.add(new Graphic(pgs, pgb));
|
||||
}
|
||||
}
|
||||
return graphics;
|
||||
}
|
||||
|
||||
@ -2675,7 +2675,7 @@ public class GLPlot extends Plot {
|
||||
break;
|
||||
case POLYLINE:
|
||||
case POLYLINE_Z:
|
||||
ColorBreak cb = graphic.getLegend();
|
||||
/*ColorBreak cb = graphic.getLegend();
|
||||
if (cb instanceof StreamlineBreak) {
|
||||
if (shape instanceof PipeShape) {
|
||||
this.drawPipeStreamline(gl, graphic);
|
||||
@ -2702,14 +2702,14 @@ public class GLPlot extends Plot {
|
||||
} else {
|
||||
this.drawLineString(gl, graphic);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
break;
|
||||
case POLYGON:
|
||||
case POLYGON_Z:
|
||||
this.drawPolygonShape(gl, graphic);
|
||||
break;
|
||||
case WIND_ARROW:
|
||||
this.drawWindArrow(gl, graphic);
|
||||
//this.drawWindArrow(gl, graphic);
|
||||
break;
|
||||
case CUBIC:
|
||||
this.drawCubic(gl, graphic);
|
||||
@ -3039,181 +3039,6 @@ public class GLPlot extends Plot {
|
||||
}
|
||||
}
|
||||
|
||||
private void drawStreamline(GL2 gl, Graphic graphic) {
|
||||
boolean isDraw = true;
|
||||
if (this.clipPlane)
|
||||
isDraw = drawExtent.intersects(graphic.getExtent());
|
||||
|
||||
if (isDraw) {
|
||||
PolylineZShape shape = (PolylineZShape) graphic.getShape();
|
||||
ColorBreak cb = graphic.getLegend();
|
||||
if (cb.getBreakType() == BreakTypes.COLOR_BREAK_COLLECTION) {
|
||||
ColorBreakCollection cbc = (ColorBreakCollection) cb;
|
||||
Polyline line = shape.getPolylines().get(0);
|
||||
java.util.List<PointZ> ps = (java.util.List<PointZ>) line.getPointList();
|
||||
float[] rgba;
|
||||
PointZ p;
|
||||
gl.glLineWidth(((PolylineBreak) cbc.get(0)).getWidth() * this.dpiScale);
|
||||
gl.glBegin(GL2.GL_LINE_STRIP);
|
||||
for (int i = 0; i < ps.size(); i++) {
|
||||
PolylineBreak plb = (PolylineBreak) cbc.get(i);
|
||||
rgba = plb.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
gl.glLineWidth(plb.getWidth() * this.dpiScale);
|
||||
p = ps.get(i);
|
||||
gl.glVertex3fv(transform.transformArray((float) p.X, (float) p.Y, (float) p.Z), 0);
|
||||
}
|
||||
gl.glEnd();
|
||||
|
||||
//Draw arrow
|
||||
StreamlineBreak slb = (StreamlineBreak) cbc.get(0);
|
||||
int interval = slb.getInterval();
|
||||
if (slb.getArrowHeadLength() > 0 || slb.getArrowHeadWidth() > 0) {
|
||||
float[] p2, p1;
|
||||
PointZ pp;
|
||||
for (int i = 0; i < ps.size(); i++) {
|
||||
slb = (StreamlineBreak) cbc.get(i);
|
||||
pp = ps.get(i);
|
||||
p2 = transform.transformArray((float) pp.X, (float) pp.Y, (float) pp.Z);
|
||||
if (i > 0 && i % interval == 0) {
|
||||
pp = ps.get(i - 1);
|
||||
p1 = transform.transformArray((float) pp.X, (float) pp.Y, (float) pp.Z);
|
||||
drawArrow(gl, p2, p1, slb);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
StreamlineBreak slb = (StreamlineBreak) cb;
|
||||
int interval = slb.getInterval();
|
||||
float[] rgba = slb.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
gl.glLineWidth(slb.getWidth() * this.dpiScale);
|
||||
gl.glBegin(GL2.GL_LINE_STRIP);
|
||||
for (Polyline line : shape.getPolylines()) {
|
||||
java.util.List<PointZ> ps = (java.util.List<PointZ>) line.getPointList();
|
||||
float[] p;
|
||||
PointZ pp;
|
||||
for (int i = 0; i < ps.size(); i++) {
|
||||
pp = ps.get(i);
|
||||
p = transform.transformArray((float) pp.X, (float) pp.Y, (float) pp.Z);
|
||||
gl.glVertex3f(p[0], p[1], p[2]);
|
||||
}
|
||||
}
|
||||
gl.glEnd();
|
||||
|
||||
//Draw arrow
|
||||
if (slb.getArrowHeadLength() > 0 || slb.getArrowHeadWidth() > 0) {
|
||||
for (Polyline line : shape.getPolylines()) {
|
||||
java.util.List<PointZ> ps = (java.util.List<PointZ>) line.getPointList();
|
||||
float[] p, p1;
|
||||
PointZ pp;
|
||||
for (int i = 0; i < ps.size(); i++) {
|
||||
pp = ps.get(i);
|
||||
p = transform.transformArray((float) pp.X, (float) pp.Y, (float) pp.Z);
|
||||
if (i > 0 && i % interval == 0) {
|
||||
pp = ps.get(i - 1);
|
||||
p1 = transform.transformArray((float) pp.X, (float) pp.Y, (float) pp.Z);
|
||||
drawArrow(gl, p, p1, slb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawPipeStreamline(GL2 gl, Graphic graphic) {
|
||||
boolean isDraw = true;
|
||||
if (this.clipPlane)
|
||||
isDraw = drawExtent.intersects(graphic.getExtent());
|
||||
|
||||
if (isDraw) {
|
||||
PipeShape shape = (PipeShape) graphic.getShape();
|
||||
ColorBreak cb = graphic.getLegend();
|
||||
shape.transform(transform);
|
||||
Pipe pipe = shape.getPipe();
|
||||
int count = pipe.getContourCount();
|
||||
if (cb.getBreakType() == BreakTypes.COLOR_BREAK_COLLECTION) {
|
||||
ColorBreakCollection cbc = (ColorBreakCollection) cb;
|
||||
float[] rgba;
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
StreamlineBreak plb = (StreamlineBreak) cbc.get(i);
|
||||
rgba = plb.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
List<Vector3f> c1 = pipe.getContour(i);
|
||||
List<Vector3f> c2 = pipe.getContour(i+1);
|
||||
List<Vector3f> n1 = pipe.getNormal(i);
|
||||
List<Vector3f> n2 = pipe.getNormal(i+1);
|
||||
gl.glBegin(GL_TRIANGLE_STRIP);
|
||||
for(int j = 0; j < (int)c2.size(); ++j)
|
||||
{
|
||||
gl.glNormal3fv(JOGLUtil.toArray(n2.get(j)), 0);
|
||||
gl.glVertex3fv(JOGLUtil.toArray(c2.get(j)), 0);
|
||||
gl.glNormal3fv(JOGLUtil.toArray(n1.get(j)), 0);
|
||||
gl.glVertex3fv(JOGLUtil.toArray(c1.get(j)), 0);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
|
||||
//Draw arrow
|
||||
List<Vector3f> path = pipe.getPath();
|
||||
StreamlineBreak slb = (StreamlineBreak) cbc.get(0);
|
||||
int interval = slb.getInterval();
|
||||
if (slb.getArrowHeadLength() > 0 || slb.getArrowHeadWidth() > 0) {
|
||||
float[] p2, p1;
|
||||
Vector3f pp;
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
slb = (StreamlineBreak) cbc.get(i);
|
||||
pp = path.get(i);
|
||||
p2 = new float[]{pp.x, pp.y, pp.z};
|
||||
if (i > 0 && i % interval == 0) {
|
||||
pp = path.get(i - 1);
|
||||
p1 = new float[]{pp.x, pp.y, pp.z};
|
||||
drawArrow(gl, p2, p1, slb);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
StreamlineBreak slb = (StreamlineBreak) cb;
|
||||
int interval = slb.getInterval() * 3;
|
||||
float[] rgba = slb.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
for(int i = 0; i < count - 1; i++)
|
||||
{
|
||||
List<Vector3f> c1 = pipe.getContour(i);
|
||||
List<Vector3f> c2 = pipe.getContour(i+1);
|
||||
List<Vector3f> n1 = pipe.getNormal(i);
|
||||
List<Vector3f> n2 = pipe.getNormal(i+1);
|
||||
gl.glBegin(GL_TRIANGLE_STRIP);
|
||||
for(int j = 0; j < (int)c2.size(); ++j)
|
||||
{
|
||||
gl.glNormal3fv(JOGLUtil.toArray(n2.get(j)), 0);
|
||||
gl.glVertex3fv(JOGLUtil.toArray(c2.get(j)), 0);
|
||||
gl.glNormal3fv(JOGLUtil.toArray(n1.get(j)), 0);
|
||||
gl.glVertex3fv(JOGLUtil.toArray(c1.get(j)), 0);
|
||||
}
|
||||
gl.glEnd();
|
||||
}
|
||||
|
||||
//Draw arrow
|
||||
List<Vector3f> path = pipe.getPath();
|
||||
if (slb.getArrowHeadLength() > 0 || slb.getArrowHeadWidth() > 0) {
|
||||
float[] p2, p1;
|
||||
Vector3f pp;
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
pp = path.get(i);
|
||||
p2 = new float[]{pp.x, pp.y, pp.z};
|
||||
if (i > 0 && i % interval == 0) {
|
||||
pp = path.get(i - 1);
|
||||
p1 = new float[]{pp.x, pp.y, pp.z};
|
||||
drawArrow(gl, p2, p1, slb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawPolygonShape(GL2 gl, Graphic graphic) {
|
||||
boolean isDraw = true;
|
||||
if (this.clipPlane)
|
||||
@ -3692,241 +3517,6 @@ public class GLPlot extends Plot {
|
||||
gl.glDisable(GL2.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void drawArrow(GL2 gl, float[] p1, float[] p2, StreamlineBreak slb) {
|
||||
// Calculate vector along direction of line
|
||||
float[] v = {p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]};
|
||||
float norm_of_v = (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
|
||||
// Size of cone in arrow:
|
||||
//float coneFractionAxially = 0.025f; // radius at thickest part
|
||||
//float coneFractionRadially = 0.12f; // length of arrow
|
||||
|
||||
//float coneHgt = coneFractionAxially;
|
||||
//float coneRadius = coneFractionRadially;
|
||||
float coneRadius = slb.getArrowHeadLength() * 0.02f;
|
||||
float coneHgt = slb.getArrowHeadWidth() * 0.02f;
|
||||
|
||||
// Set location of arrowhead to be at the startpoint of the line
|
||||
float[] vConeLocation = p2;
|
||||
|
||||
// Initialize transformation matrix
|
||||
float[] mat44
|
||||
= {1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1};
|
||||
|
||||
// The direction of the arrowhead is the line vector
|
||||
float[] dVec = {v[0], v[1], v[2]};
|
||||
|
||||
// Normalize dVec to get Unit Vector norm_startVec
|
||||
float[] norm_startVec = VectorUtil.normalizeVec3(dVec);
|
||||
|
||||
// Normalize zaxis to get Unit Vector norm_endVec
|
||||
float[] zaxis = {0.0f, 0.0f, 1.0f};
|
||||
float[] norm_endVec = VectorUtil.normalizeVec3(zaxis);
|
||||
|
||||
if (Float.isNaN(norm_endVec[0]) || Float.isNaN(norm_endVec[1]) || Float.isNaN(norm_endVec[2])) {
|
||||
norm_endVec[0] = 0.0f;
|
||||
norm_endVec[1] = 0.0f;
|
||||
norm_endVec[2] = 0.0f;
|
||||
}
|
||||
|
||||
// If vectors are identical, set transformation matrix to identity
|
||||
if (((norm_startVec[0] - norm_endVec[0]) > 1e-14) && ((norm_startVec[1] - norm_endVec[1]) > 1e-14) && ((norm_startVec[2] - norm_endVec[2]) > 1e-14)) {
|
||||
mat44[0] = 1.0f;
|
||||
mat44[5] = 1.0f;
|
||||
mat44[10] = 1.0f;
|
||||
mat44[15] = 1.0f;
|
||||
} // otherwise create the matrix
|
||||
else {
|
||||
// Vector cross-product, result = axb
|
||||
float[] axb = new float[3];
|
||||
VectorUtil.crossVec3(axb, norm_startVec, norm_endVec);
|
||||
|
||||
// Normalize axb to get Unit Vector norm_axb
|
||||
float[] norm_axb = VectorUtil.normalizeVec3(axb);
|
||||
|
||||
if (Float.isNaN(norm_axb[0]) || Float.isNaN(norm_axb[1]) || Float.isNaN(norm_axb[2])) {
|
||||
norm_axb[0] = 0.0f;
|
||||
norm_axb[1] = 0.0f;
|
||||
norm_axb[2] = 0.0f;
|
||||
}
|
||||
|
||||
// Build the rotation matrix
|
||||
float ac = (float) Math.acos(VectorUtil.dotVec3(norm_startVec, norm_endVec));
|
||||
|
||||
float s = (float) Math.sin(ac);
|
||||
float c = (float) Math.cos(ac);
|
||||
float t = 1 - c;
|
||||
|
||||
float x = norm_axb[0];
|
||||
float y = norm_axb[1];
|
||||
float z = norm_axb[2];
|
||||
|
||||
// Fill top-left 3x3
|
||||
mat44[0] = t * x * x + c;
|
||||
mat44[1] = t * x * y - s * z;
|
||||
mat44[2] = t * x * z + s * y;
|
||||
|
||||
mat44[4] = t * x * y + s * z;
|
||||
mat44[5] = t * y * y + c;
|
||||
mat44[6] = t * y * z - s * x;
|
||||
|
||||
mat44[8] = t * x * z - s * y;
|
||||
mat44[9] = t * y * z + s * x;
|
||||
mat44[10] = t * z * z + c;
|
||||
|
||||
mat44[15] = 1.0f;
|
||||
}
|
||||
|
||||
gl.glPushMatrix();
|
||||
gl.glPushAttrib(GL2.GL_POLYGON_BIT); // includes GL_CULL_FACE
|
||||
gl.glDisable(GL2.GL_CULL_FACE); // draw from all sides
|
||||
|
||||
// Translate and rotate arrowhead to correct position
|
||||
gl.glTranslatef(vConeLocation[0], vConeLocation[1], vConeLocation[2]);
|
||||
gl.glMultMatrixf(mat44, 0);
|
||||
|
||||
float[] rgba = slb.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
GLUquadric cone_obj = glu.gluNewQuadric();
|
||||
glu.gluCylinder(cone_obj, 0, coneHgt, coneRadius, 8, 1);
|
||||
|
||||
gl.glPopAttrib(); // GL_CULL_FACE
|
||||
gl.glPopMatrix();
|
||||
}
|
||||
|
||||
void drawWindArrow(GL2 gl, Graphic graphic) {
|
||||
boolean isDraw = true;
|
||||
if (this.clipPlane)
|
||||
isDraw = drawExtent.intersects(graphic.getExtent());
|
||||
|
||||
if (isDraw) {
|
||||
WindArrow3D shape = (WindArrow3D) graphic.getShape();
|
||||
PointBreak pb = (PointBreak) graphic.getLegend();
|
||||
PointZ sp = (PointZ) shape.getPoint();
|
||||
PointZ ep = (PointZ) shape.getEndPoint();
|
||||
Vector3f xyz = transform.transform((float) sp.X, (float) sp.Y, (float) sp.Z);
|
||||
float x1 = xyz.x;
|
||||
float y1 = xyz.y;
|
||||
float z1 = xyz.z;
|
||||
xyz = transform.transform((float) ep.X, (float) ep.Y, (float) ep.Z);
|
||||
float x2 = xyz.x;
|
||||
float y2 = xyz.y;
|
||||
float z2 = xyz.z;
|
||||
|
||||
gl.glPushMatrix();
|
||||
gl.glPushAttrib(GL2.GL_POLYGON_BIT); // includes GL_CULL_FACE
|
||||
gl.glDisable(GL2.GL_CULL_FACE); // draw from all sides
|
||||
|
||||
float[] rgba = pb.getColor().getRGBComponents(null);
|
||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
gl.glLineWidth(pb.getOutlineSize() * this.dpiScale);
|
||||
gl.glBegin(GL2.GL_LINES);
|
||||
gl.glVertex3f(x1, y1, z1);
|
||||
gl.glVertex3f(x2, y2, z2);
|
||||
gl.glEnd();
|
||||
|
||||
// Calculate vector along direction of line
|
||||
float[] v = {x1 - x2, y1 - y2, z1 - z2};
|
||||
float norm_of_v = (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
|
||||
// Size of cone in arrow:
|
||||
//float coneFractionAxially = 0.025f; // radius at thickest part
|
||||
//float coneFractionRadially = 0.12f; // length of arrow
|
||||
|
||||
//float coneHgt = coneFractionAxially * norm_of_v;
|
||||
//float coneRadius = coneFractionRadially * norm_of_v;
|
||||
float coneRadius = shape.getHeadLength() * 0.02f;
|
||||
float coneHgt = shape.getHeadWidth() * 0.02f;
|
||||
|
||||
// Set location of arrowhead to be at the startpoint of the line
|
||||
float[] vConeLocation = {x2, y2, z2};
|
||||
|
||||
// Initialize transformation matrix
|
||||
float[] mat44
|
||||
= {1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1};
|
||||
|
||||
// The direction of the arrowhead is the line vector
|
||||
float[] dVec = {v[0], v[1], v[2]};
|
||||
|
||||
// Normalize dVec to get Unit Vector norm_startVec
|
||||
float[] norm_startVec = VectorUtil.normalizeVec3(dVec);
|
||||
|
||||
// Normalize zaxis to get Unit Vector norm_endVec
|
||||
float[] zaxis = {0.0f, 0.0f, 1.0f};
|
||||
float[] norm_endVec = VectorUtil.normalizeVec3(zaxis);
|
||||
|
||||
if (Float.isNaN(norm_endVec[0]) || Float.isNaN(norm_endVec[1]) || Float.isNaN(norm_endVec[2])) {
|
||||
norm_endVec[0] = 0.0f;
|
||||
norm_endVec[1] = 0.0f;
|
||||
norm_endVec[2] = 0.0f;
|
||||
}
|
||||
|
||||
// If vectors are identical, set transformation matrix to identity
|
||||
if (((norm_startVec[0] - norm_endVec[0]) > 1e-14) && ((norm_startVec[1] - norm_endVec[1]) > 1e-14) && ((norm_startVec[2] - norm_endVec[2]) > 1e-14)) {
|
||||
mat44[0] = 1.0f;
|
||||
mat44[5] = 1.0f;
|
||||
mat44[10] = 1.0f;
|
||||
mat44[15] = 1.0f;
|
||||
} // otherwise create the matrix
|
||||
else {
|
||||
// Vector cross-product, result = axb
|
||||
float[] axb = new float[3];
|
||||
VectorUtil.crossVec3(axb, norm_startVec, norm_endVec);
|
||||
|
||||
// Normalize axb to get Unit Vector norm_axb
|
||||
float[] norm_axb = VectorUtil.normalizeVec3(axb);
|
||||
|
||||
if (Float.isNaN(norm_axb[0]) || Float.isNaN(norm_axb[1]) || Float.isNaN(norm_axb[2])) {
|
||||
norm_axb[0] = 0.0f;
|
||||
norm_axb[1] = 0.0f;
|
||||
norm_axb[2] = 0.0f;
|
||||
}
|
||||
|
||||
// Build the rotation matrix
|
||||
float ac = (float) Math.acos(VectorUtil.dotVec3(norm_startVec, norm_endVec));
|
||||
|
||||
float s = (float) Math.sin(ac);
|
||||
float c = (float) Math.cos(ac);
|
||||
float t = 1 - c;
|
||||
|
||||
float x = norm_axb[0];
|
||||
float y = norm_axb[1];
|
||||
float z = norm_axb[2];
|
||||
|
||||
// Fill top-left 3x3
|
||||
mat44[0] = t * x * x + c;
|
||||
mat44[1] = t * x * y - s * z;
|
||||
mat44[2] = t * x * z + s * y;
|
||||
|
||||
mat44[4] = t * x * y + s * z;
|
||||
mat44[5] = t * y * y + c;
|
||||
mat44[6] = t * y * z - s * x;
|
||||
|
||||
mat44[8] = t * x * z - s * y;
|
||||
mat44[9] = t * y * z + s * x;
|
||||
mat44[10] = t * z * z + c;
|
||||
|
||||
mat44[15] = 1.0f;
|
||||
}
|
||||
|
||||
// Translate and rotate arrowhead to correct position
|
||||
gl.glTranslatef(vConeLocation[0], vConeLocation[1], vConeLocation[2]);
|
||||
gl.glMultMatrixf(mat44, 0);
|
||||
|
||||
GLUquadric cone_obj = glu.gluNewQuadric();
|
||||
glu.gluCylinder(cone_obj, 0, coneHgt, coneRadius, 8, 1);
|
||||
|
||||
gl.glPopAttrib(); // GL_CULL_FACE
|
||||
gl.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
void drawCircle(GL2 gl, float z, float radius, PolygonBreak bb) {
|
||||
drawCircle(gl, z, radius, bb, false);
|
||||
}
|
||||
|
||||
@ -2565,7 +2565,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
case POLYLINE:
|
||||
case POLYLINE_Z:
|
||||
ColorBreak cb = graphic.getLegend();
|
||||
if (cb instanceof StreamlineBreak) {
|
||||
/*if (cb instanceof StreamlineBreak) {
|
||||
if (shape instanceof PipeShape) {
|
||||
this.drawPipeStreamline(gl, graphic);
|
||||
} else {
|
||||
@ -2591,14 +2591,14 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
} else {
|
||||
this.drawLineString(gl, graphic);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
break;
|
||||
case POLYGON:
|
||||
case POLYGON_Z:
|
||||
this.drawPolygonShape(gl, graphic);
|
||||
break;
|
||||
case WIND_ARROW:
|
||||
this.drawWindArrow(gl, graphic);
|
||||
//this.drawWindArrow(gl, graphic);
|
||||
break;
|
||||
case CUBIC:
|
||||
this.drawCubic(gl, graphic);
|
||||
@ -2927,7 +2927,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void drawStreamline(GL2 gl, Graphic graphic) {
|
||||
/*private void drawStreamline(GL2 gl, Graphic graphic) {
|
||||
boolean isDraw = true;
|
||||
if (this.clipPlane)
|
||||
isDraw = drawExtent.intersects(graphic.getExtent());
|
||||
@ -3100,7 +3100,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
protected void drawPolygonShape(GL2 gl, Graphic graphic) {
|
||||
boolean isDraw = true;
|
||||
@ -3580,7 +3580,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
gl.glDisable(GL2.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void drawArrow(GL2 gl, float[] p1, float[] p2, StreamlineBreak slb) {
|
||||
/*void drawArrow(GL2 gl, float[] p1, float[] p2, StreamlineBreak slb) {
|
||||
// Calculate vector along direction of line
|
||||
float[] v = {p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]};
|
||||
float norm_of_v = (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
@ -3683,9 +3683,9 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
|
||||
gl.glPopAttrib(); // GL_CULL_FACE
|
||||
gl.glPopMatrix();
|
||||
}
|
||||
}*/
|
||||
|
||||
void drawWindArrow(GL2 gl, Graphic graphic) {
|
||||
/*void drawWindArrow(GL2 gl, Graphic graphic) {
|
||||
boolean isDraw = true;
|
||||
if (this.clipPlane)
|
||||
isDraw = drawExtent.intersects(graphic.getExtent());
|
||||
@ -3813,7 +3813,7 @@ public class Plot3DGL extends Plot implements GLEventListener {
|
||||
gl.glPopAttrib(); // GL_CULL_FACE
|
||||
gl.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
void drawCircle(GL2 gl, float z, float radius, PolygonBreak bb) {
|
||||
drawCircle(gl, z, radius, bb, false);
|
||||
|
||||
@ -1,34 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\LaSW">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\ascii"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\pie"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\patch"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\patch">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\maskout"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\bar"/>
|
||||
<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\isosurface"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamplot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\emips"/>
|
||||
<RecentFolder Folder="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW\airship"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\patch"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\reindex_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\heart_cdata.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_isosurface_ws.py"/>
|
||||
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
|
||||
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\patch\fill_2.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\reindex_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\heart_cdata.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_isosurface_ws.py"/>
|
||||
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
|
||||
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\patch\fill_2.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -36,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="1354,809"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Binary file not shown.
@ -2844,6 +2844,33 @@ class Axes(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
def fill(self, x, y, color=None, **kwargs):
|
||||
"""
|
||||
Plot filled polygons.
|
||||
|
||||
- To plot one region, specify x and y as vectors.
|
||||
- To plot multiple regions, specify x and y as matrices where each column corresponds to a polygon.
|
||||
|
||||
:param x: (*array_like*) X coordinates for each vertex.
|
||||
:param y: (*array_like*) Y coordinates for each vertex.
|
||||
:param color: (*Color*) Fill color.
|
||||
"""
|
||||
if color is not None:
|
||||
kwargs['facecolor'] = color
|
||||
lbreak, isunique = plotutil.getlegendbreak('polygon', **kwargs)
|
||||
|
||||
if y is None:
|
||||
graphics = Graphic(x, lbreak)
|
||||
else:
|
||||
x = plotutil.getplotdata(x)
|
||||
y = plotutil.getplotdata(y)
|
||||
graphics = GraphicFactory.createPolygons(x, y, lbreak)
|
||||
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
self.add_graphic(graphics, zorder=zorder)
|
||||
self._axes.setAutoExtent()
|
||||
return graphics
|
||||
|
||||
def patch(self, x, y=None, **kwargs):
|
||||
"""
|
||||
Create one or more filled polygons.
|
||||
|
||||
Binary file not shown.
@ -431,8 +431,8 @@ def annotate(s, xy, *args, **kwargs):
|
||||
return r
|
||||
|
||||
|
||||
@_copy_docstring_and_deprecators(Axes.patch)
|
||||
def fill(x, y=None, **kwargs):
|
||||
@_copy_docstring_and_deprecators(Axes.fill)
|
||||
def fill(x, y, color=None, **kwargs):
|
||||
global g_axes
|
||||
if g_figure is None:
|
||||
figure()
|
||||
@ -440,7 +440,7 @@ def fill(x, y=None, **kwargs):
|
||||
if g_axes is None:
|
||||
g_axes = axes()
|
||||
|
||||
r = g_axes.patch(x, y, **kwargs)
|
||||
r = g_axes.fill(x, y, color, **kwargs)
|
||||
if r is not None:
|
||||
draw_if_interactive()
|
||||
return r
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user