private void OnMouseClick3dAction(Mouse3dPosition point)
        {
            if (point.IsMouseDown)
            {
                _xMin = point.Point.X();
                _yMin = point.Point.Y();

                // Build the selection rectangle
                rectangle = new Rectangle2D(Context2d, _xMin, _yMin, 1, 1, 0);
                // Set the line type to selection
                rectangle.SetAspect(DrawingUtils.GetSelectionAspectLine());
            }
            else
            {
                _xMax = point.Point.X();
                _yMax = point.Point.Y();

                // Remove the selection rectangle from the view and release it
                Context2d.Erase(rectangle, true, false);
                rectangle = null;

                // Test if the zoom window is greater than a minimal window
                if ((Math.Abs(_xMin - _xMax) > 1) || (Math.Abs(_yMin - _yMax) > 1))
                {
                    // Do the zoom window between Pmin and Pmax
                    int xMin = 0, yMin = 0, xMax = 0, yMax = 0;
                    GeomUtils.TranslateCoordinatesFromOCC(View2d, _xMin, _yMin, ref xMin, ref yMin);
                    GeomUtils.TranslateCoordinatesFromOCC(View2d, _xMax, _yMax, ref xMax, ref yMax);
                    View2d.WindowFit(xMin, yMin, xMax, yMax);
                }

                View2d.Update();
            }
        }
Пример #2
0
        public override void OnDeactivate()
        {
            base.OnDeactivate();

            // Remove the realtime drawn line
            if (_ellipse != null)
            {
                Context2d.Erase(_ellipse, true, false);
            }

            _points.Clear();
        }
Пример #3
0
        private void OnMouseClick3dAction(Mouse3dPosition point)
        {
            if (point.IsMouseDown == false)
            {
                AddToPointList(point.Point);
            }
            _label = null;

            // Finished building the line
            if (_points.Count >= 2)
            {
                // Remove the realtime drawn line
                Context2d.Erase(_line, true, false);

                // Build the final line translated to the drawing plane
                var line = new Line2D(Context2d, _points[0].X(), _points[0].Y(), _points[1].X(), _points[1].Y());

                // Add the line to the OCAF data hierarchy and also display it
                _document.Transact();

                // Save the new shape into the Ocaf data structure
                int result = AddToOcaf(line, Ax2);

                // Attach an integer attribute to L to memorize it's not displayed
                _label.Update <IntegerInterpreter>().Value = (int)OcafObjectVisibility.ToBeDisplayed;

                _document.Commit("Draw line");
                line.Display(true);

                // Inform the listeners that a new shape was generated
                Inputs[ActionNames.SolverDrawerPipe].OnNotification("Draw Line", line);
                Inputs[ActionNames.EditDetectionPipe].OnNotification("Draw Line", line);

                // Clear the list and get ready for drawing a new line
                _points.Clear();
            }
        }
Пример #4
0
        private void OnMouseClick3dAction(Mouse3dPosition point)
        {
            if (point.IsMouseDown == false)
            {
                AddToPointList(point.Point);
            }

            // Finished building the rectangle
            if (_points.Count >= 2)
            {
                // Remove the realtime drawn rectangle
                Context2d.Erase(_rectangle, true, false);

                // Build the final rectangle from the two coordinates
                var rectangle = new Rectangle2D(Context2d, _points[0].X(), _points[0].Y(), _points[1].X() - _points[0].X(), _points[1].Y() - _points[0].Y(), 0);

                // Add the rectangle to the OCAF data hierarchy and also display it
                _document.Transact();

                // Save the new shape into the Ocaf data structure
                L = AddToOcaf(rectangle, Ax2);

                // Attach an integer attribute to L to memorize it's not displayed
                L.Update <IntegerInterpreter>().Value = (int)OcafObjectVisibility.ToBeDisplayed;

                _document.Commit("Draw rectangle");
                rectangle.Display(true);

                // Inform the listeners that a new shape was generated
                Inputs[ActionNames.SolverDrawerPipe].OnNotification("Draw Rectangle", rectangle);
                Inputs[ActionNames.EditDetectionPipe].OnNotification("Draw Rectangle", rectangle);

                // Clear the list and get ready for drawing a new rectangle
                _points.Clear();
            }
        }
Пример #5
0
        private void OnMouseClick3dAction(Mouse3dPosition point)
        {
            if (point.IsMouseDown == false)
            {
                AddToPointList(point.Point);
            }

            // Finished building the ellipse
            if (_points.Count < 2)
            {
                return;
            }

            try
            {
                double majorRadius = Math.Abs(_points[1].X() - _points[0].X());
                double minorRadius = Math.Abs(_points[1].Y() - _points[0].Y());

                // The OCC requires the minor radius to be higher than 0
                if ((majorRadius < 0.01) || (minorRadius < 0.01))
                {
                    _points.Clear();
                    return;
                }

                // The OCC ellipse requires the minor radius to be smaller than the major radius
                if (minorRadius > majorRadius)
                {
                    double aux = majorRadius;
                    majorRadius = minorRadius;
                    minorRadius = aux;
                }

                // Remove the realtime drawn ellipse
                Context2d.Erase(_ellipse, true, false);

                // Build the shape translated to the drawing plane
                var ellipse = new Ellipse2D(Context2d, _points[0].X(), _points[0].Y(), majorRadius, minorRadius, 0);

                // Add the ellipse to the OCAF data hierarchy and also display it
                _document.Transact();

                // Save the new shape into the Ocaf data structure
                int result = AddToOcaf(ellipse, Ax2);

                // Attach an integer attribute to L to memorize it's not displayed
                label.Update <IntegerInterpreter>().Value = (int)OcafObjectVisibility.ToBeDisplayed;

                _document.Commit("Draw circle");
                ellipse.Display(true);

                // Inform the listeners that a new shape was generated
                Inputs[ActionNames.SolverDrawerPipe].OnNotification("Draw Ellipse", ellipse);
                Inputs[ActionNames.EditDetectionPipe].OnNotification("Draw Ellipse", ellipse);

                // Clear the list and get ready for drawing a new ellipse
                _points.Clear();
            }
            catch (Exception ex)
            {
                string message = "Logged exception on creating ellipse: " + ex.Message;
                MessageBox.Show(message);
                log.Debug(message);
            }
        }