Ejemplo n.º 1
0
 protected override void DrawOverlay(Model.DrawSceneParams myParams)
 {
     // text drawing
     if (_current != null)
     {
         DrawText(_mouseLocation.X, Size.Height - _mouseLocation.Y + 10, "Point Coord: " + _current, new System.Drawing.Font("Tahoma", 8.25f), System.Drawing.Color.Black, System.Drawing.ContentAlignment.BottomLeft);
     }
     else
     {
         DrawText(_mouseLocation.X, Size.Height - _mouseLocation.Y + 10, "Depth for Transparency", new System.Drawing.Font("Tahoma", 8.25f), System.Drawing.Color.Black, System.Drawing.ContentAlignment.BottomLeft);
     }
     base.DrawOverlay(myParams);
 }
Ejemplo n.º 2
0
        protected override void DrawOverlay(Model.DrawSceneParams myParams)
        {
            ScreenToPlane(mouseLocation, plane, out current);

            currentlySnapping = false;

            // If ObjectSnap is ON, we need to find closest vertex (if any)
            if (objectSnapEnabled && snapPoints != null && snapPoints.Length > 0)
            {
                snap              = FindClosestPoint(snapPoints);
                current           = snap;
                currentlySnapping = true;
            }

            // set GL for interactive draw or elastic line
            renderContext.SetLineSize(1);

            renderContext.EnableXOR(true);

            renderContext.SetState(depthStencilStateType.DepthTestOff);

            if (!(currentlySnapping) && !(waitingForSelection) && ActionMode == actionType.None &&
                !(doingExtend || doingTrim || doingFillet || doingChamfer || doingTangents || drawingOrdinateDim) && !ObjectManipulator.Visible)
            {
                if (!cursorOutside)
                {
                    DrawPositionMark(current);
                }
            }

            if (drawingLine || drawingPolyLine)
            {
                DrawInteractiveLines();
            }
            else if (drawingCircle && points.Count > 0)
            {
                if (ActionMode == actionType.None && !GetToolBar().Contains(mouseLocation))
                {
                    DrawInteractiveCircle();
                }
            }
            else if (drawingArc && points.Count > 0)
            {
                if (ActionMode == actionType.None && !GetToolBar().Contains(mouseLocation))
                {
                    DrawInteractiveArc();
                }
            }
            else if (drawingEllipse && points.Count > 0)
            {
                DrawInteractiveEllipse();
            }
            else if (drawingEllipticalArc && points.Count > 0)
            {
                DrawInteractiveEllipticalArc();
            }
            else if (drawingCurve)
            {
                DrawInteractiveCurve();
            }
            else if (drawingLeader)
            {
                DrawInteractiveLeader();
            }
            else if (drawingLinearDim || drawingAlignedDim)
            {
                if (points.Count < 2)
                {
                    if (!cursorOutside)
                    {
                        DrawSelectionMark(mouseLocation);

                        renderContext.EnableXOR(false);
                        string text = "Select the first point";
                        if (!firstClick)
                        {
                            text = "Select the second point";
                        }

                        DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                                 text, new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                        renderContext.EnableXOR(true);
                    }
                }
                else
                {
                    if (drawingLinearDim)
                    {
                        DrawInteractiveLinearDim();
                    }
                    else if (drawingAlignedDim)
                    {
                        DrawInteractiveAlignedDim();
                    }
                }
            }
            else if (drawingOrdinateDim)
            {
                if (!cursorOutside)
                {
                    if (points.Count == 1)
                    {
                        DrawPositionMark(current, 5);
                        DrawInteractiveOrdinateDim();
                    }
                    else
                    {
                        DrawPositionMark(current);
                        renderContext.EnableXOR(false);
                        string text = "Select the definition point";
                        if (!firstClick)
                        {
                            text = "Select the leader end point";
                        }

                        DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                                 text, new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                        renderContext.EnableXOR(true);
                    }
                }
            }
            else if (drawingRadialDim || drawingDiametricDim)
            {
                if (waitingForSelection)
                {
                    DrawSelectionMark(mouseLocation);

                    renderContext.EnableXOR(false);

                    DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                             "Select Arc or Circle", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                    renderContext.EnableXOR(true);
                }
                DrawInteractiveDiametricDim();
            }
            else if (drawingAngularDim)
            {
                if (waitingForSelection)
                {
                    if (!drawingAngularDimFromLines)
                    {
                        DrawSelectionMark(mouseLocation);

                        renderContext.EnableXOR(false);

                        DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                                 "Select Arc or Line", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                        renderContext.EnableXOR(true);
                    }
                    else if (quadrantPoint == null && !drawingQuadrantPoint)
                    {
                        DrawSelectionMark(mouseLocation);

                        renderContext.EnableXOR(false);

                        DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                                 "Select second Line", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                        renderContext.EnableXOR(true);
                    }
                    else if (drawingQuadrantPoint)
                    {
                        DrawSelectionMark(mouseLocation);

                        renderContext.EnableXOR(false);

                        DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                                 "Select a quadrant", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                        renderContext.EnableXOR(true);
                    }
                    else if (quadrantPoint != null)
                    {
                        DrawSelectionMark(mouseLocation);

                        renderContext.EnableXOR(false);

                        DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                                 "Select text position", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                        renderContext.EnableXOR(true);
                    }
                }
                DrawInteractiveAngularDim();
            }
            else if (doingMirror)
            {
                if (waitingForSelection)
                {
                    DrawSelectionMark(mouseLocation);

                    renderContext.EnableXOR(false);

                    DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                             "Select entity to mirror", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                    renderContext.EnableXOR(true);
                }

                CreateMirrorEntity();
            }
            else if (doingOffset)
            {
                if (waitingForSelection)
                {
                    DrawSelectionMark(mouseLocation);

                    renderContext.EnableXOR(false);

                    DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                             "Select entity to offset", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                    renderContext.EnableXOR(true);
                }
                CreateOffsetEntity();
            }
            else if (doingMove)
            {
                MoveEntity();
            }
            else if (doingScale)
            {
                ScaleEntity();
            }
            else if (doingRotate)
            {
                RotateEntity();
            }
            else if (doingFillet)
            {
                if (waitingForSelection)
                {
                    DrawSelectionMark(mouseLocation);

                    renderContext.EnableXOR(false);

                    DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                             "Select first curve", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                    renderContext.EnableXOR(true);
                }
                CreateFilletEntity();
            }

            else if (doingTangents)
            {
                if (waitingForSelection)
                {
                    {
                        DrawSelectionMark(mouseLocation);

                        renderContext.EnableXOR(false);

                        DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                                 "Select first circle", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                        renderContext.EnableXOR(true);
                    }
                }
                CreateTangentEntity();
            }
            else if (doingChamfer)
            {
                if (waitingForSelection)
                {
                    DrawSelectionMark(mouseLocation);
                    renderContext.EnableXOR(false);

                    DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                             "Select first curve", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                    renderContext.EnableXOR(true);
                }
                CreateChamferEntity();
            }
            else if (doingExtend)
            {
                if (waitingForSelection)
                {
                    DrawSelectionMark(mouseLocation);
                    renderContext.EnableXOR(false);

                    DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                             "Select boundary entity", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);

                    renderContext.EnableXOR(true);
                }
                ExtendEntity();
            }
            else if (doingTrim)
            {
                if (waitingForSelection)
                {
                    DrawSelectionMark(mouseLocation);
                    renderContext.EnableXOR(false);

                    DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                             "Select trimming entity", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft);
                    renderContext.EnableXOR(true);
                }
                TrimEntity();
            }

            // disables draw inverted
            renderContext.EnableXOR(false);


            // text drawing
            if (!(drawingDiametricDim || drawingAlignedDim || drawingLinearDim || drawingOrdinateDim || drawingLeader || drawingRadialDim || drawingAngularDim ||
                  doingMirror || doingOffset || doingTangents || doingExtend || doingTrim || doingFillet || doingChamfer || doingMove || doingScale || doingRotate) && ActionMode == actionType.None)
            {
                if (!(drawingEllipticalArc && points.Count >= 3) && !cursorOutside)
                {
                    //label on mouse
                    string exitCommand = "";
                    if (drawingCurve || drawingPolyLine || drawingPoints)
                    {
                        exitCommand = rmb;
                    }
                    else
                    {
                        exitCommand = "";
                    }

                    DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10,
                             activeOperationLabel +
                             "X = " + current.X.ToString("f2") + ", " +
                             "Y = " + current.Y.ToString("f2") +
                             exitCommand,
                             new Font("Tahoma", 8.25f),
                             DrawingColor, ContentAlignment.BottomLeft);
                }
            }

            base.DrawOverlay(myParams);
        }