public virtual void renderAngle(Atom atomA, Atom atomB, Atom atomC, short colix, bool renderArcs) { /* * if (! (atomA.isVisible() && atomB.isVisible() && atomC.isVisible())) * return; */ if (displayModelIndex >= 0 && (displayModelIndex != atomA.modelIndex || displayModelIndex != atomB.modelIndex || displayModelIndex != atomC.modelIndex)) { return; } //g3d.setColix(colix); int zA = atomA.ScreenZ - atomA.ScreenD - 10; int zB = atomB.ScreenZ - atomB.ScreenD - 10; int zC = atomC.ScreenZ - atomC.ScreenD - 10; int zOffset = (zA + zB + zC) / 3; int radius = drawSegment(atomA.ScreenX, atomA.ScreenY, zA, atomB.ScreenX, atomB.ScreenY, zB, colix); radius += drawSegment(atomB.ScreenX, atomB.ScreenY, zB, atomC.ScreenX, atomC.ScreenY, zC, colix); radius = (radius + 1) / 2; if (!renderArcs) { return; } // FIXME mth -- this really should be a function of pixelsPerAngstrom // in addition, the location of the arc is not correct // should probably be some percentage of the smaller distance AxisAngle4f aa = measurement.aa; if (aa == null) { // 180 degrees paintMeasurementString(atomB.ScreenX + 5, atomB.ScreenY - 5, zB, radius, colix); return; } int dotCount = (int)((aa.angle / (2 * System.Math.PI)) * 64); float stepAngle = aa.angle / dotCount; aaT.set_Renamed(aa); int iMid = dotCount / 2; for (int i = dotCount; --i >= 0;) { aaT.angle = i * stepAngle; matrixT.set_Renamed(aaT); pointT.set_Renamed(measurement.pointArc); matrixT.transform(pointT); pointT.add(atomB.point3f); //Point3i screenArc = viewer.transformPoint(pointT); //int zArc = screenArc.z - zOffset; //if (zArc < 0) // zArc = 0; //g3d.drawPixel(screenArc.x, screenArc.y, zArc); //if (i == iMid) //{ // pointT.set_Renamed(measurement.pointArc); // pointT.scale(1.1f); // matrixT.transform(pointT); // pointT.add(atomB.point3f); // Point3i screenLabel = viewer.transformPoint(pointT); // int zLabel = screenLabel.z - zOffset; // paintMeasurementString(screenLabel.x, screenLabel.y, zLabel, radius, colix); //} } }
public virtual void formatMeasurement() { for (int i = count; --i >= 0;) { if (countPlusIndices[i + 1] < 0) { strMeasurement = null; return; } } if (count < 2) { return; } switch (count) { case 2: float distance = frame.getDistance(countPlusIndices[1], countPlusIndices[2]); strMeasurement = formatDistance(distance); break; case 3: float degrees = frame.getAngle(countPlusIndices[1], countPlusIndices[2], countPlusIndices[3]); strMeasurement = formatAngle(degrees); if (degrees == 180) { aa = null; pointArc = null; } else { Point3f pointA = getAtomPoint3f(1); Point3f pointB = getAtomPoint3f(2); Point3f pointC = getAtomPoint3f(3); Vector3f vectorBA = new Vector3f(); Vector3f vectorBC = new Vector3f(); vectorBA.sub(pointA, pointB); vectorBC.sub(pointC, pointB); float radians = vectorBA.angle(vectorBC); Vector3f vectorAxis = new Vector3f(); vectorAxis.cross(vectorBA, vectorBC); aa = new AxisAngle4f(vectorAxis.x, vectorAxis.y, vectorAxis.z, radians); vectorBA.normalize(); vectorBA.scale(0.5f); pointArc = new Point3f(vectorBA); } break; case 4: float torsion = frame.getTorsion(countPlusIndices[1], countPlusIndices[2], countPlusIndices[3], countPlusIndices[4]); strMeasurement = formatAngle(torsion); break; default: System.Console.Out.WriteLine("Invalid count to measurement shape:" + count); throw new System.IndexOutOfRangeException(); } }