public LineMagnet(Canguro.Model.LineElement line) : base(line.I.Position) { this.direction = line.J.Position - line.I.Position; this.type = LineMagnetType.FollowProjection; this.line = line; }
public void PaintLineSegment(Device device, GraphicView activeView, Vector3 startPos, Vector3 endPos, LineMagnetType type) { activeView.Project(ref startPos); activeView.Project(ref endPos); drawSegment(device, startPos.X, startPos.Y, endPos.X, endPos.Y, type); }
public LineMagnet(Vector3 position, Vector3 direction, LineMagnetType type) : base(position) { this.direction = direction; this.type = type; line = null; }
public void PaintLineSegment(Device device, GraphicView activeView, Vector3 startPos, Point endPoint, LineMagnetType type) { Vector3 pos2D = startPos; activeView.Project(ref pos2D); drawSegment(device, pos2D.X, pos2D.Y, endPoint.X, endPoint.Y, type); }
/// <summary> /// This method paints all the gadgets added by the Snaps /// (i.e. /// </summary> public void Paint(Device device, GraphicView activeView, System.Windows.Forms.MouseEventArgs e) { for (int i = 0; i < paintMagnets.Count; i++) { Magnet m = paintMagnets[i]; if (m != null) { if (m is PointMagnet) { byte alpha = 255; if (m.LastSnapFitness >= EffectiveSnapDistance) { alpha = (byte)((1f - (m.LastSnapFitness - EffectiveSnapDistance) / (SnapViewDistance - EffectiveSnapDistance)) * 128f + 64f); } switch (((PointMagnet)m).Type) { case PointMagnetType.Perpendicular: if (alpha == 255 && m.RelatedMagnets.Count > 0 && m.RelatedMagnets[0] is PointMagnet) { painter.PaintLineSegment(device, activeView, m.Position, m.RelatedMagnets[0].Position, LineMagnetType.FollowHelper); } break; case PointMagnetType.SimplePoint: if (alpha == 255 && m.RelatedMagnets.Count > 0 && m.RelatedMagnets[0] is PointMagnet) { painter.PaintPointSymbol(device, activeView, m.RelatedMagnets[0].Position, PointMagnetType.SimplePoint, 192); } break; } painter.PaintPointSymbol(device, activeView, m.Position, ((PointMagnet)m).Type, alpha); } else if (m is LineMagnet) { LineMagnetType lmt = ((LineMagnet)m).Type; if (lmt == LineMagnetType.FollowProjection && lines.CurrentLine != null) { lmt = LineMagnetType.FollowHelper; } painter.PaintLineSegment(device, activeView, m.Position, m.SnapPositionInt, lmt); } } } if (lines.CurrentLine != null) { painter.PaintLineSegment(device, activeView, lines.CurrentLine.Position, lines.CurrentLine.SnapPositionInt, lines.CurrentLine.Type); } }
private void drawSegment(Device device, float x0, float y0, float x1, float y1, LineMagnetType type) { int color = Color.FromArgb(128, Color.Gold).ToArgb(); uint stipplePattern = 0xffffffff; switch (type) { case LineMagnetType.FollowProjection: break; case LineMagnetType.FollowXAxis: color = Color.FromArgb(128, Color.Red).ToArgb(); break; case LineMagnetType.FollowYAxis: color = Color.FromArgb(128, Color.LightGreen).ToArgb(); break; case LineMagnetType.FollowZAxis: color = Color.FromArgb(128, Color.Blue).ToArgb(); break; case LineMagnetType.FollowHelper: color = Color.FromArgb(128, Color.SandyBrown).ToArgb(); break; } followAxis(device, x0, y0, x1, y1, color, (int)stipplePattern); }
public void PaintLineSegment(Device device, GraphicView activeView, Point startPoint, Point endPoint, LineMagnetType type) { drawSegment(device, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y, type); }