Beispiel #1
0
        /// <summary>
        /// identify snapPoints of the entity under mouse cursor in that moment, using PickBoxSize as tolerance
        /// </summary>
        public SnapPoint[] GetSnapPoints(System.Drawing.Point mouseLocation)
        {
            //changed PickBoxSize to define a range for display snapPoints
            int oldSize = PickBoxSize;

            PickBoxSize = 10;

            //select the entity under mouse cursor
            Transformation accumulatedParentTransform = new Identity();
            Entity         ent = GetNestedEntity(mouseLocation, Entities, ref accumulatedParentTransform);

            PickBoxSize = oldSize;
            SnapPoint[] snapPoints = new SnapPoint[0];

            if (ent != null)
            {
                //extract the entity selected with GetEntityUnderMouseCursor


                //check which type of entity is it and then,identify snap points
                if (ent is devDept.Eyeshot.Entities.Point)
                {
                    devDept.Eyeshot.Entities.Point point = (devDept.Eyeshot.Entities.Point)ent;

                    switch (activeObjectSnap)
                    {
                    case objectSnapType.Point:
                        Point3D point3d = point.Vertices[0];
                        snapPoints = new SnapPoint[] { new SnapPoint(point3d, objectSnapType.Point) };
                        break;
                    }
                }
                else if (ent is Line) //line
                {
                    Line line = (Line)ent;

                    switch (activeObjectSnap)
                    {
                    case objectSnapType.End:
                        snapPoints = new SnapPoint[] { new SnapPoint(line.StartPoint, objectSnapType.End),
                                                       new SnapPoint(line.EndPoint, objectSnapType.End) };
                        break;

                    case objectSnapType.Mid:
                        snapPoints = new SnapPoint[] { new SnapPoint(line.MidPoint, objectSnapType.Mid) };
                        break;
                    }
                }
                else if (ent is LinearPath)//polyline
                {
                    LinearPath       polyline           = (LinearPath)ent;
                    List <SnapPoint> polyLineSnapPoints = new List <SnapPoint>();

                    switch (activeObjectSnap)
                    {
                    case objectSnapType.End:
                        foreach (Point3D point in polyline.Vertices)
                        {
                            polyLineSnapPoints.Add(new SnapPoint(point, objectSnapType.End));
                        }
                        snapPoints = polyLineSnapPoints.ToArray();
                        break;
                    }
                }
                else if (ent is CompositeCurve)//composite
                {
                    CompositeCurve   composite          = (CompositeCurve)ent;
                    List <SnapPoint> polyLineSnapPoints = new List <SnapPoint>();

                    switch (activeObjectSnap)
                    {
                    case objectSnapType.End:
                        foreach (ICurve curveSeg in composite.CurveList)
                        {
                            polyLineSnapPoints.Add(new SnapPoint(curveSeg.EndPoint, objectSnapType.End));
                        }
                        polyLineSnapPoints.Add(new SnapPoint(composite.CurveList[0].StartPoint, objectSnapType.End));
                        snapPoints = polyLineSnapPoints.ToArray();
                        break;
                    }
                }
                else if (ent is Arc) //Arc
                {
                    Arc arc = (Arc)ent;

                    switch (activeObjectSnap)
                    {
                    case objectSnapType.End:
                        snapPoints = new SnapPoint[] { new SnapPoint(arc.StartPoint, objectSnapType.End),
                                                       new SnapPoint(arc.EndPoint, objectSnapType.End) };
                        break;

                    case objectSnapType.Mid:
                        snapPoints = new SnapPoint[] { new SnapPoint(arc.MidPoint, objectSnapType.Mid) };
                        break;

                    case objectSnapType.Center:
                        snapPoints = new SnapPoint[] { new SnapPoint(arc.Center, objectSnapType.Center) };
                        break;
                    }
                }
                else if (ent is Circle) //Circle
                {
                    Circle circle = (Circle)ent;

                    switch (activeObjectSnap)
                    {
                    case objectSnapType.End:
                        snapPoints = new SnapPoint[] { new SnapPoint(circle.EndPoint, objectSnapType.End) };
                        break;

                    case objectSnapType.Mid:
                        snapPoints = new SnapPoint[] { new SnapPoint(circle.PointAt(circle.Domain.Mid), objectSnapType.Mid) };
                        break;

                    case objectSnapType.Center:
                        snapPoints = new SnapPoint[] { new SnapPoint(circle.Center, objectSnapType.Center) };
                        break;

                    case objectSnapType.Quad:
                        Point3D quad1 = new Point3D(circle.Center.X, circle.Center.Y + circle.Radius);
                        Point3D quad2 = new Point3D(circle.Center.X + circle.Radius, circle.Center.Y);
                        Point3D quad3 = new Point3D(circle.Center.X, circle.Center.Y - circle.Radius);
                        Point3D quad4 = new Point3D(circle.Center.X - circle.Radius, circle.Center.Y);

                        snapPoints = new SnapPoint[] { new SnapPoint(quad1, objectSnapType.Quad),
                                                       new SnapPoint(quad2, objectSnapType.Quad),
                                                       new SnapPoint(quad3, objectSnapType.Quad),
                                                       new SnapPoint(quad4, objectSnapType.Quad) };
                        break;
                    }
                }
#if NURBS
                else if (ent is Curve) // Spline
                {
                    Curve curve = (Curve)ent;

                    switch (activeObjectSnap)
                    {
                    case objectSnapType.End:
                        snapPoints = new SnapPoint[] { new SnapPoint(curve.StartPoint, objectSnapType.End),
                                                       new SnapPoint(curve.EndPoint, objectSnapType.End) };
                        break;

                    case objectSnapType.Mid:
                        snapPoints = new SnapPoint[] { new SnapPoint(curve.PointAt(0.5), objectSnapType.Mid) };
                        break;
                    }
                }
#endif
                else if (ent is EllipticalArc) //Elliptical Arc
                {
                    EllipticalArc elArc = (EllipticalArc)ent;

                    switch (activeObjectSnap)
                    {
                    case objectSnapType.End:
                        snapPoints = new SnapPoint[] { new SnapPoint(elArc.StartPoint, objectSnapType.End),
                                                       new SnapPoint(elArc.EndPoint, objectSnapType.End) };
                        break;

                    case objectSnapType.Center:
                        snapPoints = new SnapPoint[] { new SnapPoint(elArc.Center, objectSnapType.Center) };
                        break;
                    }
                }
                else if (ent is Ellipse) //Ellipse
                {
                    Ellipse ellipse = (Ellipse)ent;
                    switch (activeObjectSnap)
                    {
                    case objectSnapType.End:
                        snapPoints = new SnapPoint[] { new SnapPoint(ellipse.EndPoint, objectSnapType.End) };
                        break;

                    case objectSnapType.Mid:
                        snapPoints = new SnapPoint[] { new SnapPoint(ellipse.PointAt(ellipse.Domain.Mid), objectSnapType.Mid) };
                        break;

                    case objectSnapType.Center:
                        snapPoints = new SnapPoint[] { new SnapPoint(ellipse.Center, objectSnapType.Center) };
                        break;
                    }
                }
                else if (ent is Mesh) //Mesh
                {
                    Mesh mesh = (Mesh)ent;

                    switch (activeObjectSnap)
                    {
                    case objectSnapType.End:

                        snapPoints = new SnapPoint[mesh.Vertices.Length];

                        for (int i = 0; i < mesh.Vertices.Length; i++)
                        {
                            Point3D pt = mesh.Vertices[i];
                            snapPoints[i] = new SnapPoint(pt, objectSnapType.End);
                        }
                        break;
                    }
                }
            }

            if (accumulatedParentTransform != new Identity())
            {
                Point3D p_tmp;
                foreach (SnapPoint sp in snapPoints)
                {
                    p_tmp = accumulatedParentTransform * sp;
                    sp.X  = p_tmp.X;
                    sp.Y  = p_tmp.Y;
                    sp.Z  = p_tmp.Z;
                }
            }

            return(snapPoints);
        }
Beispiel #2
0
        public bool AreEqual(Entity ent1, Entity ent2)
        {
            if (ent1 is CompositeCurve)
            {
                CompositeCurve cc1 = (CompositeCurve)ent1;
                CompositeCurve cc2 = (CompositeCurve)ent2;

                if (cc1.CurveList.Count == cc2.CurveList.Count)
                {
                    int equalCurvesInListCount = 0;

                    foreach (Entity entC in cc1.CurveList)
                    {
                        foreach (Entity entC2 in cc2.CurveList)
                        {
                            if (entC.GetType() == entC2.GetType())
                            {
                                if (CompareIfEqual(entC, entC2))
                                {
                                    equalCurvesInListCount++;
                                    break;
                                }
                            }
                        }
                    }

                    if (cc1.CurveList.Count == equalCurvesInListCount)
                    {
                        return(true);
                    }
                }
            }

            else if (ent1 is LinearPath)
            {
                LinearPath lp1 = (LinearPath)ent1;
                LinearPath lp2 = (LinearPath)ent2;

                if (lp1.Vertices.Length == lp2.Vertices.Length)
                {
                    for (int i = 0; i < lp1.Vertices.Length; i++)
                    {
                        if (!(lp1.Vertices[i] == lp2.Vertices[i]))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }

            else if (ent1 is PlanarEntity)
            {
                PlanarEntity pe1 = (PlanarEntity)ent1;
                PlanarEntity pe2 = (PlanarEntity)ent2;
                if (
                    pe1.Plane.AxisZ == pe2.Plane.AxisZ &&
                    pe1.Plane.AxisX == pe2.Plane.AxisX
                    )
                {
                    if (ent1 is Arc)
                    {
                        Arc arc1 = (Arc)ent1;
                        Arc arc2 = (Arc)ent2;

                        if (
                            arc1.Center == arc2.Center &&
                            arc1.Radius == arc2.Radius &&
                            arc1.Domain.Min == arc2.Domain.Min &&
                            arc1.Domain.Max == arc2.Domain.Max
                            )
                        {
                            return(true);
                        }
                    }
                    else if (ent1 is Circle)
                    {
                        Circle c1 = (Circle)ent1;
                        Circle c2 = (Circle)ent2;

                        if (
                            c1.Center == c2.Center &&
                            c1.Radius == c2.Radius
                            )
                        {
                            return(true);
                        }
                    }
                    else if (ent1 is EllipticalArc)
                    {
                        EllipticalArc e1 = (EllipticalArc)ent1;
                        EllipticalArc e2 = (EllipticalArc)ent2;

                        if (
                            e1.Center == e2.Center &&
                            e1.RadiusX == e2.RadiusX &&
                            e1.RadiusY == e2.RadiusY &&
                            e1.Domain.Low == e2.Domain.Low &&
                            e1.Domain.High == e2.Domain.High
                            )
                        {
                            return(true);
                        }
                    }
                    else if (ent1 is Ellipse)
                    {
                        Ellipse e1 = (Ellipse)ent1;
                        Ellipse e2 = (Ellipse)ent2;

                        if (
                            e1.Center == e2.Center &&
                            e1.RadiusX == e2.RadiusX &&
                            e1.RadiusY == e2.RadiusY
                            )
                        {
                            return(true);
                        }
                    }

                    else if (ent1 is Text)
                    {
                        if (ent1 is Dimension)
                        {
                            Dimension dim1 = (Dimension)ent1;
                            Dimension dim2 = (Dimension)ent2;

                            if (
                                dim1.InsertionPoint == dim2.InsertionPoint &&
                                dim1.DimLinePosition == dim2.DimLinePosition
                                )
                            {
                                if (ent1 is AngularDim)
                                {
                                    AngularDim ad1 = (AngularDim)ent1;
                                    AngularDim ad2 = (AngularDim)ent2;

                                    if (
                                        ad1.ExtLine1 == ad2.ExtLine1 &&
                                        ad1.ExtLine2 == ad2.ExtLine2 &&
                                        ad1.StartAngle == ad2.StartAngle &&
                                        ad1.EndAngle == ad2.EndAngle &&
                                        ad1.Radius == ad2.Radius
                                        )
                                    {
                                        return(true);
                                    }
                                }
                                else if (ent1 is LinearDim)
                                {
                                    LinearDim ld1 = (LinearDim)ent1;
                                    LinearDim ld2 = (LinearDim)ent2;

                                    if (
                                        ld1.ExtLine1 == ld2.ExtLine1 &&
                                        ld1.ExtLine2 == ld2.ExtLine2
                                        )
                                    {
                                        return(true);
                                    }
                                }
                                else if (ent1 is DiametricDim)
                                {
                                    DiametricDim dd1 = (DiametricDim)ent1;
                                    DiametricDim dd2 = (DiametricDim)ent2;

                                    if (
                                        dd1.Distance == dd2.Distance &&
                                        dd1.Radius == dd2.Radius &&
                                        dd1.CenterMarkSize == dd2.CenterMarkSize
                                        )
                                    {
                                        return(true);
                                    }
                                }
                                else if (ent1 is RadialDim)
                                {
                                    RadialDim rd1 = (RadialDim)ent1;
                                    RadialDim rd2 = (RadialDim)ent2;

                                    if (
                                        rd1.Radius == rd2.Radius &&
                                        rd1.CenterMarkSize == rd2.CenterMarkSize
                                        )
                                    {
                                        return(true);
                                    }
                                }
                                else if (ent1 is OrdinateDim)
                                {
                                    OrdinateDim od1 = (OrdinateDim)ent1;
                                    OrdinateDim od2 = (OrdinateDim)ent2;

                                    if (
                                        od1.DefiningPoint == od2.DefiningPoint &&
                                        od1.Origin == od2.Origin &&
                                        od1.LeaderEndPoint == od2.LeaderEndPoint
                                        )
                                    {
                                        return(true);
                                    }
                                }
                                else
                                {
                                    Console.Write("Type " + ent1.GetType() + " not implemented.");
                                    return(true);
                                }
                            }
                        }

                        else if (ent1 is devDept.Eyeshot.Entities.Attribute)
                        {
                            devDept.Eyeshot.Entities.Attribute att1 = (devDept.Eyeshot.Entities.Attribute)ent1;
                            devDept.Eyeshot.Entities.Attribute att2 = (devDept.Eyeshot.Entities.Attribute)ent2;

                            if (
                                att1.Value == att2.Value &&
                                att1.InsertionPoint == att2.InsertionPoint
                                )
                            {
                                return(true);
                            }
                        }

                        else
                        {
                            Text tx1 = (Text)ent1;
                            Text tx2 = (Text)ent2;

                            if (
                                tx1.InsertionPoint == tx2.InsertionPoint &&
                                tx1.TextString == tx2.TextString &&
                                tx1.StyleName == tx2.StyleName &&
                                tx1.WidthFactor == tx2.WidthFactor &&
                                tx1.Height == tx2.Height
                                )
                            {
                                return(true);
                            }
                        }
                    }

                    else
                    {
                        Console.Write("Type " + ent1.GetType() + " not implemented.");
                        return(true);
                    }
                }
            }

            else if (ent1 is Line)
            {
                Line line1 = (Line)ent1;
                Line line2 = (Line)ent2;

                if (
                    line1.StartPoint == line2.StartPoint &&
                    line1.EndPoint == line2.EndPoint
                    )
                {
                    return(true);
                }
            }

            else if (ent1 is devDept.Eyeshot.Entities.Point)
            {
                devDept.Eyeshot.Entities.Point point1 = (devDept.Eyeshot.Entities.Point)ent1;
                devDept.Eyeshot.Entities.Point point2 = (devDept.Eyeshot.Entities.Point)ent2;

                if (
                    point1.Position == point2.Position
                    )
                {
                    return(true);
                }
            }

#if NURBS
            else if (ent1 is Curve)
            {
                Curve cu1 = (Curve)ent1;
                Curve cu2 = (Curve)ent2;

                if (
                    cu1.ControlPoints.Length == cu2.ControlPoints.Length &&
                    cu1.KnotVector.Length == cu2.KnotVector.Length &&
                    cu1.Degree == cu2.Degree
                    )
                {
                    for (int k = 0; k < cu1.ControlPoints.Length; k++)
                    {
                        if (cu1.ControlPoints[k] != cu2.ControlPoints[k])
                        {
                            return(false);
                        }
                    }

                    for (int k = 0; k < cu1.KnotVector.Length; k++)
                    {
                        if (cu1.KnotVector[k] != cu2.KnotVector[k])
                        {
                            return(false);
                        }
                    }

                    return(true);
                }
            }
#endif

            else
            {
                Console.Write("Type " + ent1.GetType() + " not implemented.");
                return(true);
            }
            return(false);
        }
        private void AddEntityItem(System.Windows.Point mousePosition)
        {
            if (itemMode == itemType.None)
            {
                return;
            }

            // the tranformation of the parent BlockReference
            Transformation trans = new Identity();

            // the item under mouse cursor to be added into TempEntities list
            Entity tempItem = null;

            // gets the vertex under mouse cursor
            devDept.Eyeshot.Environment.SelectedSubItem selItem = (devDept.Eyeshot.Environment.SelectedSubItem)model1.GetItemUnderMouseCursor(RenderContextUtility.ConvertPoint(mousePosition));

            if (selItem == null)
            {
                return;
            }

            //the Brep entity under mouse cursor
            Brep brep = (Brep)selItem.Item;

            // gets transformation of the parent BlockReference (there is only one level of hierarchy)
            trans = selItem.Parents.First().Transformation;

            switch (itemMode)
            {
            case itemType.Vertex:
                // creates a Point as temp entity that represent the vertex item
                tempItem       = new devDept.Eyeshot.Entities.Point(brep.Vertices[selItem.Index], 15);
                tempItem.Color = Color.FromArgb(150, Color.Blue);
                break;

            case itemType.Edge:
                // creates an ICurve as temp entity that represent the edge item
                tempItem            = (Entity)((Entity)brep.Edges[selItem.Index].Curve).Clone();
                tempItem.LineWeight = 10;
                tempItem.Color      = Color.FromArgb(150, Color.Purple);
                break;

            case itemType.Face:
                // creates a Mesh as temp entity that represent the face item
                tempItem       = brep.Faces[selItem.Index].ConvertToMesh(skipEdges: true);
                tempItem.Color = Color.FromArgb(150, Color.DeepSkyBlue);
                break;
            }
            // transform the temp entity onto the represented item
            tempItem.TransformBy(trans);

            // regens it before to add into TempEntity list
            if (tempItem is ICurve)
            {
                tempItem.Regen(0.01);
            }

            // adds it to the TempEntities list
            model1.TempEntities.Add(tempItem);

            //stores it into tempItems list
            tempItems.Add(tempItem);
        }
Beispiel #4
0
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            var mousePos = RenderContextUtility.ConvertPoint(GetMousePosition(e));

            this.selEntityIndex = GetEntityUnderMouseCursor(mousePos);

            if (waitingForSelection)
            {
                if (this.selEntityIndex != -1)
                {
                    if (selEntity == null || drawingAngularDim)
                    {
                        this.selEntity = this.Entities[selEntityIndex];
                        if (activeOperationLabel != "")
                        {
                            this.selEntity.Selected = true;
                        }
                    }

                    // drawingAngularDim from lines needs more than one selection
                    if (!drawingAngularDim || this.Entities[selEntityIndex] is Arc)
                    {
                        waitingForSelection = false;
                    }
                }
            }

            if (GetToolBar().Contains(mousePos))
            {
                base.OnMouseDown(e);

                return;
            }

            #region Handle LMB Clicks
            if (ActionMode == actionType.None && e.ChangedButton == MouseButton.Left)
            {
                // we need to skip adding points for entity selection click
                editingMode = doingOffset || doingMirror || doingExtend || doingTrim || doingFillet || doingChamfer || doingTangents;

                ScreenToPlane(mousePos, plane, out current);

                if (objectSnapEnabled && snapPoint != null)
                {
                    if (!(editingMode && firstClick))
                    {
                        points.Add(snapPoint);
                    }
                }
                else if (IsPolygonClosed())//control needed to close curve and polyline when cursor is near the starting point of polyline or curve
                {
                    //if the distance from current point and first point stored is less than given threshold
                    points.Add((Point3D)points[0].Clone()); //the point to add to points is the first point stored.
                    current = (Point3D)points[0].Clone();
                }
                else if (gridSnapEnabled)
                {
                    if (!(editingMode && firstClick))
                    {
                        SnapToGrid(ref current);
                        points.Add(current);
                    }
                }
                else
                {
                    if (!(editingMode && firstClick))
                    {
                        points.Add(current);
                    }
                }
                firstClick = false;

                // If drawing points, create and add new point entity on each LMB click
                if (drawingPoints)
                {
                    devDept.Eyeshot.Entities.Point point;

                    if (objectSnapEnabled && snapPoint != null)
                    {
                        point = new devDept.Eyeshot.Entities.Point(snap);
                    }
                    else
                    {
                        point = new devDept.Eyeshot.Entities.Point(current);
                    }

                    AddAndRefresh(point, ActiveLayerName);
                }
                else if (drawingText)
                {
                    devDept.Eyeshot.Entities.Text text = new Text(current, "Sample Text", 5);
                    AddAndRefresh(text, ActiveLayerName);
                }
                else if (drawingLeader)
                {
                    if (points.Count == 3)
                    {
                        Leader leader = new Leader(Plane.XY, points);
                        leader.ArrowheadSize = 3;
                        AddAndRefresh(leader, ActiveLayerName);
                        devDept.Eyeshot.Entities.Text text = new Text((Point3D)current.Clone(), "Sample Text", leader.ArrowheadSize);
                        AddAndRefresh(text, ActiveLayerName);

                        drawingLeader = false;
                    }
                }
                // If LINE drawing is finished, create and add line entity to model
                else if (drawingLine && points.Count == 2)
                {
                    Line line = new Line(points[0], points[1]);
                    AddAndRefresh(line, ActiveLayerName);
                    drawingLine = false;
                }
                // If CIRCLE drawing is finished, create and add a circle entity to model
                else if (drawingCircle && points.Count == 2)
                {
                    Circle circle = new Circle(drawingPlane, drawingPlane.Origin, radius);
                    AddAndRefresh(circle, ActiveLayerName);

                    drawingCircle = false;
                }
                // If ARC drawing is finished, create and add an arc entity to model
                // Input - Center and two end points
                else if (drawingArc && points.Count == 3)
                {
                    Arc arc = new Arc(drawingPlane, drawingPlane.Origin, radius, 0, arcSpanAngle);
                    AddAndRefresh(arc, ActiveLayerName);

                    drawingArc = false;
                }
                // If drawing ellipse, create and add ellipse entity to model
                // Inputs - Ellipse center, End of first axis, End of second axis
                else if (drawingEllipse && points.Count == 3)
                {
                    Ellipse ellipse = new Ellipse(drawingPlane, drawingPlane.Origin, radius, radiusY);
                    AddAndRefresh(ellipse, ActiveLayerName);

                    drawingEllipse = false;
                }
                // If EllipticalArc drawing is finished, create and add EllipticalArc entity to model
                // Input - Ellipse center, End of first axis, End of second axis, end point
                else if (drawingEllipticalArc && points.Count == 4)
                {
                    EllipticalArc ellipticalArc = new EllipticalArc(drawingPlane, drawingPlane.Origin, radius, radiusY, 0, arcSpanAngle, true);
                    AddAndRefresh(ellipticalArc, ActiveLayerName);

                    drawingEllipticalArc = false;
                }
                else if (drawingLinearDim && points.Count == 3)
                {
                    LinearDim linearDim = new LinearDim(drawingPlane, points[0], points[1], current, dimTextHeight);
                    AddAndRefresh(linearDim, ActiveLayerName);

                    drawingLinearDim = false;
                }
                else if (drawingAlignedDim && points.Count == 3)
                {
                    LinearDim alignedDim = new LinearDim(drawingPlane, points[0], points[1], current, dimTextHeight);
                    AddAndRefresh(alignedDim, ActiveLayerName);

                    drawingAlignedDim = false;
                }
                else if (drawingOrdinateDim && points.Count == 2)
                {
                    OrdinateDim ordinateDim = new OrdinateDim(Plane.XY, points[0], points[1], drawingOrdinateDimVertical, dimTextHeight);
                    AddAndRefresh(ordinateDim, ActiveLayerName);

                    drawingOrdinateDim = false;
                }
                else if ((drawingRadialDim || drawingDiametricDim) && points.Count == 2)
                {
                    if (selEntity is Circle)
                    {
                        Circle circle = selEntity as Circle;

                        // ensures that radialDim plane has always the correct normal
                        Circle orientedCircle = new Circle(Plane.XY, circle.Center, circle.Radius);

                        if (drawingRadialDim)
                        {
                            RadialDim radialDim = new RadialDim(orientedCircle, points[points.Count - 1], dimTextHeight);
                            AddAndRefresh(radialDim, ActiveLayerName);
                            drawingRadialDim = false;
                        }
                        else
                        {
                            DiametricDim diametricDim = new DiametricDim(orientedCircle, points[points.Count - 1], dimTextHeight);
                            AddAndRefresh(diametricDim, ActiveLayerName);
                            drawingDiametricDim = false;
                        }
                    }
                }
                else if (drawingAngularDim)
                {
                    if (!drawingAngularDimFromLines)
                    {
                        if (selEntity is Arc && points.Count == 2 && !drawingQuadrantPoint)
                        {
                            Arc     arc        = selEntity as Arc;
                            Plane   myPlane    = (Plane)arc.Plane.Clone();
                            Point3D startPoint = arc.StartPoint;
                            Point3D endPoint   = arc.EndPoint;

                            // checks if the Arc is clockwise
                            if (Utility.IsOrientedClockwise(arc.Vertices))
                            {
                                myPlane.Flip();
                                startPoint = arc.EndPoint;
                                endPoint   = arc.StartPoint;
                            }

                            AngularDim angularDim = new AngularDim(myPlane, startPoint, endPoint, points[points.Count - 1], dimTextHeight);

                            angularDim.TextSuffix = "°";

                            AddAndRefresh(angularDim, ActiveLayerName);
                            drawingAngularDim = false;
                        }
                    }

                    // If it's not time to set quadrantPoint, adds the lines for angular dim
                    if (selEntity is Line && !drawingQuadrantPoint && quadrantPoint == null)
                    {
                        Line selectedLine = (Line)selEntity;

                        if (firstLine == null)
                        {
                            firstLine = selectedLine;
                        }
                        else if (secondLine == null && !ReferenceEquals(firstLine, selectedLine))
                        {
                            secondLine           = selectedLine;
                            drawingQuadrantPoint = true;
                            // resets points to get only the quadrant point and text position point
                            points.Clear();
                        }

                        drawingAngularDimFromLines = true;
                    }
                    else if (drawingQuadrantPoint)
                    {
                        ScreenToPlane(mousePos, plane, out quadrantPoint);
                        drawingQuadrantPoint = false;
                    }
                    //if all parameters are present, gets angular dim
                    else if (points.Count == 2 && quadrantPoint != null)
                    {
                        AngularDim angularDim = new AngularDim(plane, (Line)firstLine.Clone(), (Line)secondLine.Clone(), quadrantPoint, points[points.Count - 1], dimTextHeight);

                        angularDim.TextSuffix = "°";

                        AddAndRefresh(angularDim, ActiveLayerName);

                        drawingAngularDim          = false;
                        drawingAngularDimFromLines = false;
                    }
                }
                else if (doingOffset && points.Count == 1)
                {
                    CreateOffsetEntity();
                    ClearAllPreviousCommandData();
                }
                else if (doingMirror && points.Count == 2 && selEntity != null)
                {
                    CreateMirrorEntity();
                    ClearAllPreviousCommandData();
                }
                else if (doingExtend && firstSelectedEntity != null && secondSelectedEntity != null)
                {
                    ExtendEntity();
                    ClearAllPreviousCommandData();
                }
                else if (doingTrim && firstSelectedEntity != null && secondSelectedEntity != null)
                {
                    TrimEntity();
                    ClearAllPreviousCommandData();
                }
                else if (doingFillet && firstSelectedEntity != null && secondSelectedEntity != null)
                {
                    CreateFilletEntity();
                    ClearAllPreviousCommandData();
                }
                else if (doingChamfer && firstSelectedEntity != null && secondSelectedEntity != null)
                {
                    CreateChamferEntity();
                    ClearAllPreviousCommandData();
                }
                else if (doingTangents && firstSelectedEntity != null && secondSelectedEntity != null)
                {
                    CreateTangentEntity();
                    ClearAllPreviousCommandData();
                }
                else if (doingMove && points.Count == 2)
                {
                    if (points.Count == 2)
                    {
                        foreach (Entity ent in this.selEntities)
                        {
                            Vector3D movement = new Vector3D(points[0], points[1]);
                            ent.Translate(movement);
                        }

                        Entities.Regen();
                        ClearAllPreviousCommandData();
                    }
                }
                else if (doingRotate)
                {
                    if (points.Count == 3)
                    {
                        foreach (Entity ent in this.selEntities)
                        {
                            ent.Rotate(arcSpanAngle, Vector3D.AxisZ, points[0]);
                        }

                        Entities.Regen();
                        ClearAllPreviousCommandData();
                    }
                }
                else if (doingScale)
                {
                    if (points.Count == 3)
                    {
                        foreach (Entity ent in this.selEntities)
                        {
                            ent.Scale(points[0], scaleFactor);
                        }

                        Entities.Regen();
                        ClearAllPreviousCommandData();
                    }
                }
            }
            #endregion

            #region Handle RMB Clicks
            else if (e.ChangedButton == MouseButton.Right)
            {
                ScreenToPlane(mousePos, plane, out current);

                if (drawingPoints)
                {
                    points.Clear();
                    drawingPoints = false;
                }
                else if (drawingText)
                {
                    drawingText = false;
                }
                else if (drawingLeader)
                {
                    drawingLeader = false;
                }

                // If drawing polyline, create and add LinearPath entity to model
                else if (drawingPolyLine)
                {
                    LinearPath lp = new LinearPath(points);
                    AddAndRefresh(lp, ActiveLayerName);

                    drawingPolyLine = false;
                }
                // If drawing spline, create and add curve entity to model
                else if (drawingCurve)
                {
#if NURBS
                    Curve curve = Curve.CubicSplineInterpolation(points);
                    AddAndRefresh(curve, ActiveLayerName);
#endif
                    drawingCurve = false;
                }
                else
                {
                    ClearAllPreviousCommandData();
                }
            }
            #endregion

            base.OnMouseDown(e);
        }