private bool TopicSelector_OnButtonClick(string topic)
        {
            Debug.Assert(GridView.Items != null, "GridView.Items != null");
            Debug.Assert(Pivot.Items != null, "Pivot.Items != null");

            if (Pivot.Items.Any(it => it is PivotItem x && (string)x.Header == topic))
            {
                return(false);
            }

            var graphic = new GraphicView();

            Memory[topic] = graphic.ViewModelContext;
            Pivot.Items.Add(new PivotItem {
                Header = topic, Content = graphic
            });
            GridView.Items.Insert(GridView.Items.Count - 1,
                                  new GridViewItem {
                Height  = 200,
                Width   = 200,
                Tag     = topic,
                Content = new TextBlock {
                    Text = topic, FontSize = 36
                }
            });
            return(true);
        }
Example #2
0
        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);
        }
Example #3
0
        /// <summary>
        /// Method to dispatch the MouseMove event from the ScenePanel and forward it to
        /// the current ViewCommand. It is responsible of updating the current view if
        /// necessary and of setting the new tracking point for the active TrackingService.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">MouseMove params</param>
        void scenePanel_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            System.Diagnostics.Debug.Assert(mainFrm != null);
            // Si el botón del mouse está apretado o es el SelectionCommand mandar evento
            // (La selección lo necesita aunque no esté apretado para poder manejar el Tracking)
            if ((viewCmd == SelectionCommand) || ((mainFrm.ScenePanel.Capture == true) && (viewCmd != null)))
            {
                GraphicViewManager gvm = GraphicViewManager.Instance;
                GraphicView        gv  = gvm.ActiveView;
                viewCmd.MouseMove(gv, e);

                if (viewCmd != SelectionCommand)
                {
                    gvm.UpdateView(gv);
                }
                else
                {
                    // Notify and Paint trackers
                    if (TrackingController.MouseMove(this, e, gv))
                    {
                        gvm.Presenter.TrackingPaint(this, e, gv, TrackingController);
                    }
                }
            }
        }
Example #4
0
        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);
        }
Example #5
0
        /// <summary>
        /// Method to dispatch the MouseUp event from the ScenePanel and forward it to
        /// the current ViewCommand. This method is responsible for releasing mouse
        /// capture, ending view commands and updating views accordingly.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">MouseUp params</param>
        void scenePanel_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            System.Diagnostics.Debug.Assert(mainFrm != null);
            if (viewCmd != null)
            {
                GraphicView gv = GraphicViewManager.Instance.ActiveView;
                bool        windowSelectionOn = SelectionCommand.WindowSelectionOn;

                viewCmd.ButtonUp(gv, e);
                mainFrm.ScenePanel.Capture = false;

                // Check if its time to end current ViewCommand
                if (e.Button == System.Windows.Forms.MouseButtons.Right || e.Button == MouseButtons.Middle)
                {
                    if ((viewCmd != SelectionCommand || gv.ModelRenderer.RenderOptions.ShowAnimated) && EndViewCommand != null)
                    {
                        EndViewCommand(this, new EndViewCommandArgs(viewCmd));
                    }
                    else if (!SelectionCommand.IsWorkingAsCommandService)
                    {
                        if (!windowSelectionOn)
                        {
                            Canguro.Model.Model.Instance.UnSelectAll();
                        }
                    }

                    viewCmd = SelectionCommand;

                    if (StartViewCommand != null)
                    {
                        StartViewCommand(this, EventArgs.Empty);
                    }
                    mainFrm.ScenePanel.Cursor = SelectionCommand.Cursor;
                }

                if (e.Button == MouseButtons.Middle && lastViewCmd != null)
                {
                    if (lastViewCmd == Commands.View.Trackball3D.Instance)
                    {
                        Execute("rotate");
                    }
                    else if (lastViewCmd == Commands.View.Pan.Instance)
                    {
                        Execute("pan");
                    }
                    else if (lastViewCmd == Commands.View.ZoomInteractive.Instance)
                    {
                        Execute("zoom");
                    }

                    lastViewCmd = null;
                }

                if (viewCmd == SelectionCommand)
                {
                    GraphicViewManager.Instance.UpdateView(gv);
                }
            }
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        public void PaintPointSymbol(Device device, GraphicView activeView, Vector3 magnet, PointMagnetType type, byte alpha)
        {
            // Must be called within a Begin-EndScene block
            Vector3 point2D = magnet;

            activeView.Project(ref point2D);

            drawPointSymbol(device, point2D.X, point2D.Y, type, alpha);
        }
Example #9
0
        public void PaintPointSymbol(Device device, GraphicView activeView, Vector3 magnet, PointMagnetType type, byte alpha)
        {
            // Must be called within a Begin-EndScene block
            Vector3 point2D = magnet;

            activeView.Project(ref point2D);

            drawPointSymbol(device, point2D.X, point2D.Y, type, alpha);
        }
 private void recalcPrimaryDependant(GraphicView activeView)
 {
     if (points.NeedRecalcPrimaryPointDependant)
     {
         lines.RecalcPrimaryDependant(activeView, points.PrimaryPoint);
         area.RecalcPrimaryDependant(activeView, points.PrimaryPoint, lines.GlobalAxes);
         points.RecalcPrimaryDependant(activeView);
     }
 }
 private void btnMakeViews_Click(object sender, System.EventArgs e)
 {
     myViewForm1         = new GraphicView();
     myViewForm2         = new TextView();
     myViewForm3         = new ReadOnlyView();
     myViewForm1.MyModel = theModel;
     myViewForm2.MyModel = theModel;
     myViewForm3.MyModel = theModel;
     theController.AddView(myViewForm1);
     theController.AddView(myViewForm2);
     theController.AddView(myViewForm3);
 }
        /// <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);
            }
        }
 //Open Graphic View Window
 private void graphicViewToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (graphicView == null || graphicView.IsDisposed)
     {
         graphicView = new GraphicView();
         graphicView.Show();
     }
     else
     {
         graphicView.Show();
         graphicView.BringToFront();
     }
 }
        /// <summary>
        /// Calculate the intersection point of two coplanar lines
        /// Source: http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline3d/
        /// </summary>
        /// <param name="l1">First LineMagnet</param>
        /// <param name="l2">Second LineMagnet</param>
        /// <returns>The intersection point magnet or null if none found</returns>
        private PointMagnet createIntersection(LineMagnet l1, LineMagnet l2, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            if (l1 != null && l2 != null)
            {
                float   numer, denom;
                float   d1, d2, d3, d4, d5;
                Vector3 p13 = l1.Position - l2.Position;
                Vector3 p21 = l1.Direction;
                Vector3 p43 = l2.Direction;

                d1 = p13.X * p43.X + p13.Y * p43.Y + p13.Z * p43.Z;
                d2 = p43.X * p21.X + p43.Y * p21.Y + p43.Z * p21.Z;
                d3 = p13.X * p21.X + p13.Y * p21.Y + p13.Z * p21.Z;
                d4 = p43.X * p43.X + p43.Y * p43.Y + p43.Z * p43.Z;
                d5 = p21.X * p21.X + p21.Y * p21.Y + p21.Z * p21.Z;

                denom = d5 * d4 - d2 * d2;
                if (Math.Abs(denom) < float.Epsilon)
                {
                    return(null);
                }
                numer = d1 * d2 - d3 * d4;

                float r = numer / denom;
                float s = (d1 + d2 * r) / d4;

                Vector3 pa = l1.Position + Vector3.Scale(p21, r);
                Vector3 pb = l2.Position + Vector3.Scale(p43, s);

                if ((pa - pb).Length() > 0.0001)
                {
                    return(null);
                }

                // Create magnet
                PointMagnet intPtMagnet = new PointMagnet(pa,
                                                          PointMagnetType.Intersection);

                if (intPtMagnet.Snap(activeView, e.Location) < SnapViewDistance)
                {
                    intPtMagnet.RelatedMagnets.Add(l1);
                    intPtMagnet.RelatedMagnets.Add(l2);
                    return(intPtMagnet);
                }
            }

            return(null);
        }
Example #15
0
        internal void Paint(Device device)
        {
            if (hoverItem != null)
            {
                // Glow item
                if (hoverItem is LineElement)
                {
                    LineElement line = hoverItem as LineElement;

                    Model.Model model      = Model.Model.Instance;
                    GraphicView activeView = GraphicViewManager.Instance.ActiveView;
                    View.Renderer.RenderOptions options = activeView.ModelRenderer.RenderOptions;

                    if (options.ShowDeformed && model.HasResults && curve != null)
                    {
                        for (int i = 0; i < curve.Length - 1; i++)
                        {
                            hoverPainter.PaintLine(device, curve[i], curve[i + 1]);
                        }
                    }
                    else
                    {
                        hoverPainter.PaintLine(device, line);
                    }
                }

                // Show hoverPos
                Vector3 hoverPos2D = hoverPos;
                GraphicViewManager.Instance.ActiveView.Project(ref hoverPos2D);
                hoverPainter.PaintPoint(device, hoverPos2D);

                if (showingTooltip && !string.IsNullOrEmpty(tooltipText))
                {
                    // Draw tooltip rectangle
                    rectHelper.Paint(device);

                    // Draw text
                    Rectangle rect = tooltipRectangle;
                    rect.X += 4;
                    rect.Y += 2;
                    hoverPainter.DrawText(tooltipText, rect, GraphicViewManager.Instance.PrintingHiResImage ? Color.Black : Color.White);
                }
            }
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     Debug.Assert(GridView.Items != null, "GridView.Items != null");
     Debug.Assert(Pivot.Items != null, "Pivot.Items != null");
     Memory["默认"] = new GraphicViewModel();
     foreach (var(topic, viewModel) in Memory)
     {
         var graphic = new GraphicView(viewModel);
         Pivot.Items.Add(new PivotItem {
             Header = topic, Content = graphic
         });
         GridView.Items.Insert(GridView.Items.Count - 1,
                               new GridViewItem {
             Height  = 200,
             Width   = 200,
             Tag     = topic,
             Content = new TextBlock {
                 Text = topic, FontSize = 36
             }
         });
     }
 }
        /// <summary>
        /// Gets an interesting point by following the line in reverse (as a mirror) and trying
        /// to find Joints at the same distance from the LineMagnet's position
        /// </summary>
        /// <param name="lm">The Line Magnet being followed</param>
        /// <param name="activeView">The view in which the snap is taking place</param>
        /// <param name="e">The MouseEventArgs of the last MouseMove event</param>
        /// <returns>A point magnet with the interesting point or null if none found</returns>
        private PointMagnet createInterestingDistance(LineMagnet lm, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            if (lm == null)
            {
                return(null);
            }

            Vector3 pos = lm.Position;

            activeView.Project(ref pos);
            Vector3 reversePickPos = pos + pos - new Vector3(e.X, e.Y, 0f);

            List <Item> pickedItems = Canguro.View.GraphicViewManager.Instance.PickItem((int)reversePickPos.X, (int)reversePickPos.Y);

            if (pickedItems == null)
            {
                return(null);
            }

            foreach (Item item in pickedItems)
            {
                Joint j;
                // Check if Joint si over line lm
                if ((j = item as Joint) != null)
                {
                    Vector3 ptInLine = Vector3.Cross(lm.Direction, j.Position - lm.Position);
                    if (Vector3.Dot(ptInLine, ptInLine) < float.Epsilon)
                    {
                        PointMagnet distMagnet = new PointMagnet(lm.Position + lm.Position - j.Position, PointMagnetType.SimplePoint);
                        distMagnet.RelatedMagnets.Add(new PointMagnet(j));
                        points.Add(distMagnet);
                        return(distMagnet);
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// Returns a perpendicular point magnet P if there's a point X and a line L which can be united
        /// by a perpendicular line:
        ///
        ///                      L
        ///                      |
        ///                      |
        ///    X - - - - - - - - P
        ///                      |
        ///                      |
        ///
        /// </summary>
        /// <param name="lm">The Line Magnet being followed</param>
        /// <param name="activeView">The view in which the snap is taking place</param>
        /// <param name="e">The MouseEventArgs of the last MouseMove event</param>
        /// <returns>The perpendicular point magnet or null if none found</returns>
        private PointMagnet createPerpendicularMagnet(LineMagnet lm, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            if (lm == null)
            {
                return(null);
            }
            float lmDot = Vector3.Dot(lm.Direction, lm.Direction);

            if (points.PrimaryPoint != null)
            {
                PointMagnet perp = addPerpendicularMagnet(lm, points.PrimaryPoint, lmDot, activeView, e);
                if (perp != null)
                {
                    return(perp);
                }
            }
            if (points.LastPoint != null)
            {
                return(addPerpendicularMagnet(lm, points.LastPoint, lmDot, activeView, e));
            }

            return(null);
        }
        /// <summary>method: completeSetUp
        /// make controller
        /// make model
        /// make views and
        /// show views
        /// </summary>
        private void completeSetUp()
        {
            // make controller
            theController = new CountryController();
            // make model
            theModel = new CountryModel(theController);
            // make views
            myViewForm1         = new GraphicView();
            myViewForm2         = new TextView();
            myViewForm3         = new ReadOnlyView();
            myViewForm1.MyModel = theModel;
            myViewForm2.MyModel = theModel;
            myViewForm3.MyModel = theModel;

            theController.AddView(myViewForm1);
            theController.AddView(myViewForm2);
            theController.AddView(myViewForm3);

            //show views
            myViewForm3.Show();
            myViewForm2.Show();
            myViewForm1.Show();
        }
        /// <summary>
        /// Method to try to create a midpoint magnet if the mouse is close to one
        /// </summary>
        /// <param name="lm">The Line Magnet being followed</param>
        /// <param name="activeView">The view in which the snap is taking place</param>
        /// <param name="e">The MouseEventArgs of the last MouseMove event</param>
        /// <returns>The MidPoint magnet or null if none found</returns>
        private PointMagnet createMidPoint(LineMagnet lm, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            if (lm == null)
            {
                return(null);
            }

            LineElement l;

            if ((l = lm.Line) != null)
            {
                PointMagnet midPtMagnet = new PointMagnet(Vector3.Scale(l.I.Position + l.J.Position, 0.5f),
                                                          PointMagnetType.MidPoint);
                if (midPtMagnet.Snap(activeView, e.Location) < SnapViewDistance)
                {
                    midPtMagnet.RelatedMagnets.Add(lm);
                    points.Add(midPtMagnet);
                    return(midPtMagnet);
                }
            }

            return(null);
        }
        /// <summary>
        /// Method to try to create a midpoint magnet if the mouse is close to one
        /// </summary>
        /// <param name="lm">The Line Magnet being followed</param>
        /// <param name="activeView">The view in which the snap is taking place</param>
        /// <param name="e">The MouseEventArgs of the last MouseMove event</param>
        /// <returns>The MidPoint magnet or null if none found</returns>
        private PointMagnet createMidPoint(LineMagnet lm, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            if (lm == null) return null;

            LineElement l;
            if ((l = lm.Line) != null)
            {
                PointMagnet midPtMagnet = new PointMagnet(Vector3.Scale(l.I.Position + l.J.Position, 0.5f),
                    PointMagnetType.MidPoint);
                if (midPtMagnet.Snap(activeView, e.Location) < SnapViewDistance)
                {
                    midPtMagnet.RelatedMagnets.Add(lm);
                    points.Add(midPtMagnet);
                    return midPtMagnet;
                }
            }

            return null;
        }
        /// <summary>
        /// Returns a perpendicular point magnet P if there's a point X and a line L which can be united
        /// by a perpendicular line:
        /// 
        ///                      L  
        ///                      |
        ///                      |
        ///    X - - - - - - - - P
        ///                      |
        ///                      |
        /// 
        /// </summary>
        /// <param name="lm">The Line Magnet being followed</param>
        /// <param name="activeView">The view in which the snap is taking place</param>
        /// <param name="e">The MouseEventArgs of the last MouseMove event</param>
        /// <returns>The perpendicular point magnet or null if none found</returns>
        private PointMagnet createPerpendicularMagnet(LineMagnet lm, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            if (lm == null) return null;
            float lmDot = Vector3.Dot(lm.Direction, lm.Direction);

            if (points.PrimaryPoint != null)
            {
                PointMagnet perp = addPerpendicularMagnet(lm, points.PrimaryPoint, lmDot, activeView, e);
                if (perp != null) return perp;
            }
            if (points.LastPoint != null)
                return addPerpendicularMagnet(lm, points.LastPoint, lmDot, activeView, e);

            return null;
        }
 private void recalcPrimaryDependant(GraphicView activeView)
 {
     if (points.NeedRecalcPrimaryPointDependant)
     {
         lines.RecalcPrimaryDependant(activeView, points.PrimaryPoint);
         area.RecalcPrimaryDependant(activeView, points.PrimaryPoint, lines.GlobalAxes);
         points.RecalcPrimaryDependant(activeView);
     }
 }
Example #24
0
 public void PaintLineSegment(Device device, GraphicView activeView, Point startPoint, Point endPoint, LineMagnetType type)
 {
     drawSegment(device, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y, type);
 }
        internal bool MouseMove(GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            bool needPaint = false;
            Item newHover = pickItem(e);
            if (hoverItem != newHover)
            {
                if (!showingTooltip)
                {
                    if (newHover != null)
                        timer.Change(TooltipDelay, System.Threading.Timeout.Infinite);
                    else
                        timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
                }
                else
                {
                    if (newHover == null)
                        timer.Change(TooltipDelay, System.Threading.Timeout.Infinite);
                    else
                        timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
                }
            }

            if (hoverItem != null || hoverItem != newHover)
                needPaint = true;

            hoverItem = newHover;

            Model.Model model = Model.Model.Instance;
            View.Renderer.RenderOptions options = activeView.ModelRenderer.RenderOptions;

            // Get position in the item's local coordinate system
            if (hoverItem is Joint)
                hoverPos = getHoverPos((Joint)hoverItem, model, options);
            else if (hoverItem is LineElement)
            {
                LineElement line = hoverItem as LineElement;

                if (options.ShowDeformed)
                    hoverPos = getHoverPos(line, activeView, e.Location, model, options);
                else
                {
                    Snap.LineMagnet lm = new Canguro.Controller.Snap.LineMagnet(line);
                    lm.Snap(activeView, e.Location);
                    hoverPos = lm.SnapPositionInt;
                    hoverXPos = (hoverPos - line.I.Position).Length() / line.LengthInt;
                }
            }

            // Get text to draw
            tooltipText = itemTextBuilder.GetItemText(hoverItem, hoverPos, hoverXPos);

            // Get Size of text
            if (!string.IsNullOrEmpty(tooltipText))
            {
                tooltipRectangle = hoverPainter.MeasureText(tooltipText);
            #if DEBUG
                if (tooltipRectangle.Width == 0 || tooltipRectangle.Height == 0)
                    throw new Exception("Measure String returned 0");
            #endif
                tooltipRectangle.Location += deltaRect;
                tooltipRectangle.X += e.X;
                tooltipRectangle.Y += e.Y;
                tooltipRectangle.Width += 8;
                tooltipRectangle.Height += 4;

                Viewport vp = activeView.Viewport;
                if (tooltipRectangle.Right > (vp.X + vp.Width))
                    tooltipRectangle.X -= (tooltipRectangle.Width + 2 * deltaRect.Width);

                rectHelper.MouseMove(activeView, tooltipRectangle.Location, tooltipRectangle.Location + tooltipRectangle.Size);
            }
            else if (!showingTooltip)
                timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

            return showingTooltip || needPaint;
        }
Example #26
0
 public void PaintLineSegment(Device device, GraphicView activeView, Point startPoint, Point endPoint, LineMagnetType type)
 {
     drawSegment(device, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y, type);
 }
        /// <summary>
        /// Gets an interesting point by following the line in reverse (as a mirror) and trying
        /// to find Joints at the same distance from the LineMagnet's position
        /// </summary>
        /// <param name="lm">The Line Magnet being followed</param>
        /// <param name="activeView">The view in which the snap is taking place</param>
        /// <param name="e">The MouseEventArgs of the last MouseMove event</param>
        /// <returns>A point magnet with the interesting point or null if none found</returns>
        private PointMagnet createInterestingDistance(LineMagnet lm, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            if (lm == null) return null;

            Vector3 pos = lm.Position;
            activeView.Project(ref pos);
            Vector3 reversePickPos = pos + pos - new Vector3(e.X, e.Y, 0f);

            List<Item> pickedItems = Canguro.View.GraphicViewManager.Instance.PickItem((int)reversePickPos.X, (int)reversePickPos.Y);
            if (pickedItems == null) return null;

            foreach (Item item in pickedItems)
            {
                Joint j;
                // Check if Joint si over line lm
                if ((j = item as Joint) != null)
                {
                    Vector3 ptInLine = Vector3.Cross(lm.Direction, j.Position - lm.Position);
                    if (Vector3.Dot(ptInLine, ptInLine) < float.Epsilon)
                    {
                        PointMagnet distMagnet = new PointMagnet(lm.Position + lm.Position - j.Position, PointMagnetType.SimplePoint);
                        distMagnet.RelatedMagnets.Add(new PointMagnet(j));
                        points.Add(distMagnet);
                        return distMagnet;
                    }
                }
            }

            return null;
        }
Example #28
0
        private Vector3 getHoverPos(LineElement line, GraphicView activeView, Point location, Model.Model model, View.Renderer.RenderOptions options)
        {
            Vector3 pos                   = Vector3.Empty;
            bool    lastUndoEnabled       = model.Undo.Enabled;
            bool    lastUnitSystemEnabled = Model.UnitSystem.UnitSystemsManager.Instance.Enabled;

            if (!model.HasResults || model.Results.ActiveCase == null)
            {
                return(pos);
            }

            try
            {
                if (model.IsLocked)
                {
                    model.Undo.Enabled = false;
                }

                Model.UnitSystem.UnitSystemsManager.Instance.Enabled = false;

                int numPoints = (int)options.LOD.GetLOD(line).LODSegments + 1;

                float[] xPos;
                Analysis.LineDeformationCalculator calc = new Analysis.LineDeformationCalculator();
                curve = calc.GetCurve(line, model.Results.ActiveCase.AbstractCase, numPoints, options.DeformationScale, model.Results.PaintScaleFactorTranslation, out xPos);

                int             iCurve = 0, numLines = curve.Length - 1;
                Snap.LineMagnet minLine = null, lm;
                float           minLineDist = float.MaxValue, lineDist;

                for (int i = 0; i < numLines; i++)
                {
                    lm = new Canguro.Controller.Snap.LineMagnet(curve[i], curve[i + 1] - curve[i], Canguro.Controller.Snap.LineMagnetType.FollowProjection);
                    if ((lineDist = lm.Snap(activeView, location)) < minLineDist)
                    {
                        if ((lm.SnapPositionInt - curve[i]).LengthSq() <= (curve[i + 1] - curve[i]).LengthSq())
                        {
                            minLineDist = lineDist;
                            minLine     = lm;
                            iCurve      = i;
                        }
                    }
                }

                if (minLine != null)
                {
                    pos = minLine.SnapPositionInt;
                    lm  = new Canguro.Controller.Snap.LineMagnet(curve[iCurve], curve[iCurve + 1] - curve[iCurve], Canguro.Controller.Snap.LineMagnetType.FollowProjection);

                    Vector3 tmp      = pos - curve[0];
                    Vector3 xPosUnit = curve[numLines] - curve[0];
                    xPosUnit  = Vector3.Scale(xPosUnit, 1.0f / xPosUnit.LengthSq());
                    hoverXPos = Vector3.Dot(tmp, xPosUnit);
                }
                else
                {
                    hoverItem = null;
                }
            }
            finally
            {
                Model.UnitSystem.UnitSystemsManager.Instance.Enabled = lastUnitSystemEnabled;
                model.Undo.Enabled = lastUndoEnabled;
            }

            return(pos);
        }
 public void ResetStatus(GraphicView activeView)
 {
     points.Clear();
     lines.Reset();
 }
 internal void Reset(GraphicView graphicView)
 {
 }
        /// <summary>
        /// Method to perform calculations based on the user interaction by
        /// moving the mouse
        /// </summary>
        /// <param name="sender">The object calling this method</param>
        /// <param name="e">The Mouse event args</param>
        /// <returns>A boolean indicating whether a repaint is necessary</returns>
        public bool MouseMove(GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            bool ret = true;

            paintMagnets.Clear();
            pickItems(e);
            recalcPrimaryDependant(activeView);

            // Check snap to acquired magnets
            points.Snap(activeView, e);
            lines.Snap(activeView, e);

            // Get max snap Magnet (the one closer to the mouse position)
            Magnet bestMagnet;
            float  snap, bestSnap, bestPointSnap = points.GetBestSnap(out bestMagnet);

            if (bestMagnet == null)
            {
                bestSnap = lines.GetBestSnap(out bestMagnet);
            }
            else
            {
                bestSnap = bestPointSnap;
            }

            // Update CurrentLine's positions if mouse moved over any of it's joints (if LineMagnet has a Line)
            if (lines.CurrentLine != null && bestMagnet != null && bestMagnet is PointMagnet &&
                lines.CurrentLine.Line != null && ((PointMagnet)bestMagnet).Joint != null)
            {
                Joint newJoint = ((PointMagnet)bestMagnet).Joint;

                if (newJoint == lines.CurrentLine.Line.I || newJoint == lines.CurrentLine.Line.J)
                {
                    lines.CurrentLine.Position = newJoint.Position;
                }
            }

            #region Intersection
            // Check intersections between LineMagnets. If any, create corresponding Magnet
            if (lines.CurrentLine != null && bestMagnet is LineMagnet && bestMagnet != lines.CurrentLine)
            {
                PointMagnet intersectionMagnet = createIntersection(lines.CurrentLine, bestMagnet as LineMagnet, activeView, e);
                if (intersectionMagnet != null)
                {
                    snap = intersectionMagnet.Snap(activeView, e.Location) + SnapEpsilon;
                    if (snap < SnapViewDistance)
                    {
                        // Paint helper line
                        paintMagnets.Add(bestMagnet);

                        // Paint intersection
                        paintMagnets.Add(intersectionMagnet);
                    }

                    if (snap < bestPointSnap && snap < EffectiveSnapDistance)
                    {
                        bestSnap   = snap;
                        bestMagnet = intersectionMagnet;
                    }
                }
            }
            #endregion

            #region Midpoint
            // Create midpoint magnet (if mouse is close to a Line)
            foreach (Magnet m in lines)
            {
                PointMagnet midMagnet = createMidPoint(m as LineMagnet, activeView, e);
                if (midMagnet != null)
                {
                    snap = midMagnet.Snap(activeView, e.Location) + SnapEpsilon;
                    if (snap < bestPointSnap && snap < EffectiveSnapDistance)
                    {
                        bestSnap   = snap;
                        bestMagnet = midMagnet;
                    }
                }
            }
            #endregion

            #region Perpendicular point
            // Create perpendicular magnets (if mouse is close to a line)
            PointMagnet perpMagnet = createPerpendicularMagnet(bestMagnet as LineMagnet, activeView, e);
            if (perpMagnet != null)
            {
                snap = perpMagnet.Snap(activeView, e.Location) + SnapEpsilon;
                if (snap < (bestPointSnap - SnapEpsilon) && snap < EffectiveSnapDistance)
                {
                    bestSnap   = snap;
                    bestMagnet = perpMagnet;
                }
            }
            #endregion

            #region Interesting Distance
            // If following a LineMagnet, then set next interesting distance as a PointMagnet
            PointMagnet distMagnet = createInterestingDistance(bestMagnet as LineMagnet, activeView, e);
            if (distMagnet != null)
            {
                snap = distMagnet.Snap(activeView, e.Location) + SnapEpsilon;
                if (snap < bestPointSnap)
                {
                    bestSnap   = snap;
                    bestMagnet = distMagnet;
                }
            }
            #endregion

            // Choose magnets to paint
            if ((bestMagnet is LineMagnet) && (lines.CurrentLine == null))
            {
                lines.CurrentLine = (LineMagnet)bestMagnet;
            }
            else if ((bestMagnet != null) && !bestMagnet.Equals(lines.CurrentLine))
            {
                paintMagnets.Add(bestMagnet);
            }

            // Set the Magnet to snap to if the user clicks the mouse
            snapMagnet = null;
            if (bestMagnet != null)
            {
                if (bestMagnet is PointMagnet && bestMagnet.LastSnapFitness < EffectiveSnapDistance)
                {
                    snapMagnet = bestMagnet;
                }
                else if (lines.CurrentLine != null)
                {
                    snapMagnet = lines.CurrentLine;
                }
                else if (bestMagnet is LineMagnet)
                {
                    snapMagnet = bestMagnet;
                }
            }
            else
            {
                area.Snap(activeView, e.Location);
                snapMagnet = (Magnet)area.Clone();
            }

            // TODO: Probably change the IsActive property to some enum, so as to activate snapping to
            // specific objects only (i.e. Joint snapping when CommandServices.GetJoint() is working)
            return(ret);
        }
        private Vector3 getHoverPos(LineElement line, GraphicView activeView, Point location, Model.Model model, View.Renderer.RenderOptions options)
        {
            Vector3 pos = Vector3.Empty;
            bool lastUndoEnabled = model.Undo.Enabled;
            bool lastUnitSystemEnabled = Model.UnitSystem.UnitSystemsManager.Instance.Enabled;

            if (!model.HasResults || model.Results.ActiveCase == null)
                return pos;

            try
            {
                if (model.IsLocked)
                    model.Undo.Enabled = false;

                Model.UnitSystem.UnitSystemsManager.Instance.Enabled = false;

                int numPoints = (int)options.LOD.GetLOD(line).LODSegments + 1;

                float[] xPos;
                Analysis.LineDeformationCalculator calc = new Analysis.LineDeformationCalculator();
                curve = calc.GetCurve(line, model.Results.ActiveCase.AbstractCase, numPoints, options.DeformationScale, model.Results.PaintScaleFactorTranslation, out xPos);

                int iCurve = 0, numLines = curve.Length - 1;
                Snap.LineMagnet minLine = null, lm;
                float minLineDist = float.MaxValue, lineDist;

                for (int i = 0; i < numLines; i++)
                {
                    lm = new Canguro.Controller.Snap.LineMagnet(curve[i], curve[i + 1] - curve[i], Canguro.Controller.Snap.LineMagnetType.FollowProjection);
                    if ((lineDist = lm.Snap(activeView, location)) < minLineDist)
                    {
                        if ((lm.SnapPositionInt - curve[i]).LengthSq() <= (curve[i + 1] - curve[i]).LengthSq())
                        {
                            minLineDist = lineDist;
                            minLine = lm;
                            iCurve = i;
                        }
                    }
                }

                if (minLine != null)
                {
                    pos = minLine.SnapPositionInt;
                    lm = new Canguro.Controller.Snap.LineMagnet(curve[iCurve], curve[iCurve + 1] - curve[iCurve], Canguro.Controller.Snap.LineMagnetType.FollowProjection);

                    Vector3 tmp = pos - curve[0];
                    Vector3 xPosUnit = curve[numLines] - curve[0];
                    xPosUnit = Vector3.Scale(xPosUnit, 1.0f / xPosUnit.LengthSq());
                    hoverXPos = Vector3.Dot(tmp, xPosUnit);
                }
                else
                    hoverItem = null;
            }
            finally
            {
                Model.UnitSystem.UnitSystemsManager.Instance.Enabled = lastUnitSystemEnabled;
                model.Undo.Enabled = lastUndoEnabled;
            }

            return pos;
        }
 public void ResetStatus(GraphicView activeView)
 {
     points.Clear();
     lines.Reset();
 }
Example #34
0
 public void PaintPointSymbol(Device device, GraphicView activeView, Point magnet, PointMagnetType type, byte alpha)
 {
     drawPointSymbol(device, magnet.X, magnet.Y, type, alpha);
 }
        /// <summary>
        /// Calculate the intersection point of two coplanar lines
        /// Source: http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline3d/
        /// </summary>
        /// <param name="l1">First LineMagnet</param>
        /// <param name="l2">Second LineMagnet</param>
        /// <returns>The intersection point magnet or null if none found</returns>
        private PointMagnet createIntersection(LineMagnet l1, LineMagnet l2, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            if (l1 != null && l2 != null)
            {
                float numer, denom;
                float d1, d2, d3, d4, d5;
                Vector3 p13 = l1.Position - l2.Position;
                Vector3 p21 = l1.Direction;
                Vector3 p43 = l2.Direction;

                d1 = p13.X * p43.X + p13.Y * p43.Y + p13.Z * p43.Z;
                d2 = p43.X * p21.X + p43.Y * p21.Y + p43.Z * p21.Z;
                d3 = p13.X * p21.X + p13.Y * p21.Y + p13.Z * p21.Z;
                d4 = p43.X * p43.X + p43.Y * p43.Y + p43.Z * p43.Z;
                d5 = p21.X * p21.X + p21.Y * p21.Y + p21.Z * p21.Z;

                denom = d5 * d4 - d2 * d2;
                if (Math.Abs(denom) < float.Epsilon)
                    return null;
                numer = d1 * d2 - d3 * d4;

                float r = numer / denom;
                float s = (d1 + d2 * r) / d4;

                Vector3 pa = l1.Position + Vector3.Scale(p21, r);
                Vector3 pb = l2.Position + Vector3.Scale(p43, s);

                if ((pa - pb).Length() > 0.0001)
                    return null;

                // Create magnet
                PointMagnet intPtMagnet = new PointMagnet(pa,
                    PointMagnetType.Intersection);

                if (intPtMagnet.Snap(activeView, e.Location) < SnapViewDistance)
                {
                    intPtMagnet.RelatedMagnets.Add(l1);
                    intPtMagnet.RelatedMagnets.Add(l2);
                    return intPtMagnet;
                }
            }

            return null;
        }
        /// <summary>
        /// Method to perform calculations based on the user interaction by
        /// moving the mouse
        /// </summary>
        /// <param name="sender">The object calling this method</param>
        /// <param name="e">The Mouse event args</param>
        /// <returns>A boolean indicating whether a repaint is necessary</returns>
        public bool MouseMove(GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            bool ret = true;

            paintMagnets.Clear();
            pickItems(e);
            recalcPrimaryDependant(activeView);

            // Check snap to acquired magnets
            points.Snap(activeView, e);
            lines.Snap(activeView, e);

            // Get max snap Magnet (the one closer to the mouse position)
            Magnet bestMagnet;
            float snap, bestSnap, bestPointSnap = points.GetBestSnap(out bestMagnet);
            if (bestMagnet == null)
                bestSnap = lines.GetBestSnap(out bestMagnet);
            else
                bestSnap = bestPointSnap;

            // Update CurrentLine's positions if mouse moved over any of it's joints (if LineMagnet has a Line)
            if (lines.CurrentLine != null && bestMagnet != null && bestMagnet is PointMagnet &&
                lines.CurrentLine.Line != null && ((PointMagnet)bestMagnet).Joint != null)
            {
                Joint newJoint = ((PointMagnet)bestMagnet).Joint;

                if (newJoint == lines.CurrentLine.Line.I || newJoint == lines.CurrentLine.Line.J)
                    lines.CurrentLine.Position = newJoint.Position;
            }

            #region Intersection
            // Check intersections between LineMagnets. If any, create corresponding Magnet
            if (lines.CurrentLine != null && bestMagnet is LineMagnet && bestMagnet != lines.CurrentLine)
            {
                PointMagnet intersectionMagnet = createIntersection(lines.CurrentLine, bestMagnet as LineMagnet, activeView, e);
                if (intersectionMagnet != null)
                {
                    snap = intersectionMagnet.Snap(activeView, e.Location) + SnapEpsilon;
                    if (snap < SnapViewDistance)
                    {
                        // Paint helper line
                        paintMagnets.Add(bestMagnet);

                        // Paint intersection
                        paintMagnets.Add(intersectionMagnet);
                    }

                    if (snap < bestPointSnap && snap < EffectiveSnapDistance)
                    {
                        bestSnap = snap;
                        bestMagnet = intersectionMagnet;
                    }
                }
            }
            #endregion

            #region Midpoint
            // Create midpoint magnet (if mouse is close to a Line)
            foreach (Magnet m in lines)
            {
                PointMagnet midMagnet = createMidPoint(m as LineMagnet, activeView, e);
                if (midMagnet != null)
                {
                    snap = midMagnet.Snap(activeView, e.Location) + SnapEpsilon;
                    if (snap < bestPointSnap && snap < EffectiveSnapDistance)
                    {
                        bestSnap = snap;
                        bestMagnet = midMagnet;
                    }
                }
            }
            #endregion

            #region Perpendicular point
            // Create perpendicular magnets (if mouse is close to a line)
            PointMagnet perpMagnet = createPerpendicularMagnet(bestMagnet as LineMagnet, activeView, e);
            if (perpMagnet != null)
            {
                snap = perpMagnet.Snap(activeView, e.Location) + SnapEpsilon;
                if (snap < (bestPointSnap - SnapEpsilon) && snap < EffectiveSnapDistance)
                {
                    bestSnap = snap;
                    bestMagnet = perpMagnet;
                }
            }
            #endregion

            #region Interesting Distance
            // If following a LineMagnet, then set next interesting distance as a PointMagnet
            PointMagnet distMagnet = createInterestingDistance(bestMagnet as LineMagnet, activeView, e);
            if (distMagnet != null)
            {
                snap = distMagnet.Snap(activeView, e.Location) + SnapEpsilon;
                if (snap < bestPointSnap)
                {
                    bestSnap = snap;
                    bestMagnet = distMagnet;
                }
            }
            #endregion

            // Choose magnets to paint
            if ((bestMagnet is LineMagnet) && (lines.CurrentLine == null))
                lines.CurrentLine = (LineMagnet)bestMagnet;
            else if ((bestMagnet != null) && !bestMagnet.Equals(lines.CurrentLine))
                paintMagnets.Add(bestMagnet);

            // Set the Magnet to snap to if the user clicks the mouse
            snapMagnet = null;
            if (bestMagnet != null)
            {
                if (bestMagnet is PointMagnet && bestMagnet.LastSnapFitness < EffectiveSnapDistance)
                    snapMagnet = bestMagnet;
                else if (lines.CurrentLine != null)
                    snapMagnet = lines.CurrentLine;
                else if (bestMagnet is LineMagnet)
                    snapMagnet = bestMagnet;
            }
            else
            {
                area.Snap(activeView, e.Location);
                snapMagnet = (Magnet)area.Clone();
            }

            // TODO: Probably change the IsActive property to some enum, so as to activate snapping to
            // specific objects only (i.e. Joint snapping when CommandServices.GetJoint() is working)
            return ret;
        }
        /// <summary>
        /// Method to add a perpendicular point magnet if the mouse is close to where it is
        /// </summary>
        private PointMagnet addPerpendicularMagnet(LineMagnet lm, PointMagnet pm, float lmDot, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            float r = Vector3.Dot(lm.Direction, pm.Position - lm.Position) / lmDot;
            PointMagnet perpPtMagnet = new PointMagnet(lm.Position + Vector3.Scale(lm.Direction, r),
                PointMagnetType.Perpendicular);
            if (perpPtMagnet.Snap(activeView, e.Location) < SnapViewDistance)
            {
                perpPtMagnet.RelatedMagnets.Add(pm);
                perpPtMagnet.RelatedMagnets.Add(lm);
                points.Add(perpPtMagnet);
                return perpPtMagnet;
            }

            return null;
        }
Example #38
0
        internal bool MouseMove(GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            bool needPaint = false;
            Item newHover  = pickItem(e);

            if (hoverItem != newHover)
            {
                if (!showingTooltip)
                {
                    if (newHover != null)
                    {
                        timer.Change(TooltipDelay, System.Threading.Timeout.Infinite);
                    }
                    else
                    {
                        timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
                    }
                }
                else
                {
                    if (newHover == null)
                    {
                        timer.Change(TooltipDelay, System.Threading.Timeout.Infinite);
                    }
                    else
                    {
                        timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
                    }
                }
            }

            if (hoverItem != null || hoverItem != newHover)
            {
                needPaint = true;
            }

            hoverItem = newHover;

            Model.Model model = Model.Model.Instance;
            View.Renderer.RenderOptions options = activeView.ModelRenderer.RenderOptions;

            // Get position in the item's local coordinate system
            if (hoverItem is Joint)
            {
                hoverPos = getHoverPos((Joint)hoverItem, model, options);
            }
            else if (hoverItem is LineElement)
            {
                LineElement line = hoverItem as LineElement;

                if (options.ShowDeformed)
                {
                    hoverPos = getHoverPos(line, activeView, e.Location, model, options);
                }
                else
                {
                    Snap.LineMagnet lm = new Canguro.Controller.Snap.LineMagnet(line);
                    lm.Snap(activeView, e.Location);
                    hoverPos  = lm.SnapPositionInt;
                    hoverXPos = (hoverPos - line.I.Position).Length() / line.LengthInt;
                }
            }

            // Get text to draw
            tooltipText = itemTextBuilder.GetItemText(hoverItem, hoverPos, hoverXPos);

            // Get Size of text
            if (!string.IsNullOrEmpty(tooltipText))
            {
                tooltipRectangle = hoverPainter.MeasureText(tooltipText);
#if DEBUG
                if (tooltipRectangle.Width == 0 || tooltipRectangle.Height == 0)
                {
                    throw new Exception("Measure String returned 0");
                }
#endif
                tooltipRectangle.Location += deltaRect;
                tooltipRectangle.X        += e.X;
                tooltipRectangle.Y        += e.Y;
                tooltipRectangle.Width    += 8;
                tooltipRectangle.Height   += 4;

                Viewport vp = activeView.Viewport;
                if (tooltipRectangle.Right > (vp.X + vp.Width))
                {
                    tooltipRectangle.X -= (tooltipRectangle.Width + 2 * deltaRect.Width);
                }

                rectHelper.MouseMove(activeView, tooltipRectangle.Location, tooltipRectangle.Location + tooltipRectangle.Size);
            }
            else if (!showingTooltip)
            {
                timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
            }

            return(showingTooltip || needPaint);
        }
Example #39
0
 internal void Reset(GraphicView graphicView)
 {
 }
        /// <summary>
        /// Method to add a perpendicular point magnet if the mouse is close to where it is
        /// </summary>
        private PointMagnet addPerpendicularMagnet(LineMagnet lm, PointMagnet pm, float lmDot, GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
        {
            float       r            = Vector3.Dot(lm.Direction, pm.Position - lm.Position) / lmDot;
            PointMagnet perpPtMagnet = new PointMagnet(lm.Position + Vector3.Scale(lm.Direction, r),
                                                       PointMagnetType.Perpendicular);

            if (perpPtMagnet.Snap(activeView, e.Location) < SnapViewDistance)
            {
                perpPtMagnet.RelatedMagnets.Add(pm);
                perpPtMagnet.RelatedMagnets.Add(lm);
                points.Add(perpPtMagnet);
                return(perpPtMagnet);
            }

            return(null);
        }
Example #41
0
 public void PaintPointSymbol(Device device, GraphicView activeView, Point magnet, PointMagnetType type, byte alpha)
 {
     drawPointSymbol(device, magnet.X, magnet.Y, type, alpha);
 }
        /// <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);
        }