void IRenderable.Render() { Trace.Assert(this.vStrandTop.HasBeenRendered && this.vStrandBottom.HasBeenRendered); // this.HasBeenRendered = true; this.CreatePathIfNecessary(); // // Create a polygon for the background shaded part // IList<Point> pTop = vStrandTop.Spline.PathPoints(this.iTopControlFirst, this.iTopControlLast); IList<Point> pBottom = vStrandBottom.Spline.PathPoints(this.iBottomControlFirst, this.iBottomControlLast); IList<Point> pBottomReversed = new List<Point>(pBottom.Reversed()); // List<Point> pathPoints = new List<Point>(pTop); pathPoints.AddRange(pBottom); // PathGeometry regionPathGeometry = PathGeometryFromPoints(pathPoints, true); this.path.Data = regionPathGeometry; // // Draw the lines that visualize the hydrogen bonds between the nucleotides // double[] topLengths = this.RunningLengths(pTop); double[] bottomLengths = this.RunningLengths(pBottomReversed); // for (int i = 1; i < this.cNt; i++) { double fraction = (double)i / (double)this.cNt; // Point ptTop = GetPointAtFractionLength(pTop, topLengths, fraction); Point ptBottom = GetPointAtFractionLength(pBottomReversed, bottomLengths,fraction); // LineGeometryD seg = new LineGeometryD(new PointD(ptBottom), new PointD(ptTop)); double spacing = (1.0 - Constants.DoubleStrandedHashFraction) * 0.5; PointD ptTopD = seg.PointOnLine(1.0 - spacing); PointD ptBottomD = seg.PointOnLine(spacing); // Line line = this.nucleotideLines[i-1]; line.X1 = ptTopD.X; line.Y1 = ptTopD.Y; line.X2 = ptBottomD.X; line.Y2 = ptBottomD.Y; } // this.path.Style = this.ThisStyle(this.path); foreach (Line l in this.nucleotideLines) { l.StrokeThickness = this.lineWidth; } }
void IRenderable.Render() { Trace.Assert(this.strand.HasBeenRendered); // NB: We currently *rely* on the fact that the spline is rendered before we are. We should fix that. // this.HasBeenRendered = true; this.CreateLineIfNecessary(); // this.line.Style = this.ThisStyle(this.line); this.line.StrokeThickness = this.GetLineWidth(this.line); // // NB: All these points are in canvas coordinates, since the spline control points and tangents are. // PointD ptControl = new PointD(this.strand.Spline.ControlPoints[this.iControlPoint]); VectorD vTangent = new VectorD(this.strand.Spline.TangentAtControlPoint(this.iControlPoint)); LineGeometryD lineTangent = new LineGeometryD(ptControl, ptControl + vTangent); LineGeometryD linePerp = lineTangent.Perpendicular(ptControl); PointD ptPerp = linePerp.PointOnLine(1.0); VectorD vPerp = (ptPerp - ptControl).Unit(); // PointD pt1 = ptControl - vPerp; PointD pt2 = ptControl + vPerp; // // Handle degenerate cases that arise // if (pt1.IsFinite() && pt2.IsFinite()) { // Now adjust for length. But that has to be done in the pre-transformed space // PointD pt1Pre = this.Canvas.XFormInverse.Apply(pt1); PointD pt2Pre = this.Canvas.XFormInverse.Apply(pt2); PointD ptControlPre = this.Canvas.XFormInverse.Apply(ptControl); // pt1Pre = ptControlPre + (pt1Pre - ptControlPre).Unit() * this.length; pt2Pre = ptControlPre + (pt2Pre - ptControlPre).Unit() * this.length; // pt1 = this.Canvas.XForm.Apply(pt1Pre); pt2 = this.Canvas.XForm.Apply(pt2Pre); } else { // Effectively, omit the tick mark pt1 = pt2 = ptControl; } // // Paranoia: if we don't have anywhere reasonable to put these guys, // then just leave them where they are. // if (pt1.IsFinite() && pt2.IsFinite()) { // Move our end points of our shape this.line.X1 = pt1.X; this.line.Y1 = pt1.Y; this.line.X2 = pt2.X; this.line.Y2 = pt2.Y; } }