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(); } }
private void OnMouseClick3dAction(Mouse3dPosition point) { if (point.IsMouseDown) { // Check if a shape dragging is currently executing if (_selectedShape.IsDragging) { _selectedShape.MouseDrag(point.Point.X(), point.Point.Y()); _selectedShape.Display(true); } else if (_selectedShape.CanDrag(point.Point.X(), point.Point.Y())) { // Launch the dragging operation _selectedShape.StartDragging(point.Point.X(), point.Point.Y()); } } else { if (_selectedShape.IsDragging) { _selectedShape.EndDragging(); Inputs[ActionNames.EditDetectionPipe].OnNotification(PipeConstants.RegenerateSolver); } } }
private void OnMouseMove3dAction(Mouse3dPosition point) { if (rectangle != null) { rectangle.SetEndpoints(_xMin, _yMin, point.Point.X() - _xMin, point.Point.Y() - _yMin, 0); rectangle.Display(true); } }
private void OnMouseMove3dAction(Mouse3dPosition point) { // Drawing an ellipse realtime needs one point in the list if (_points.Count != 1) { return; } Double xMin = _points[0].X(); Double yMin = _points[0].Y(); double majorRadius = Math.Abs(point.Point.X() - xMin); double minorRadius = Math.Abs(point.Point.Y() - yMin); // The OCC requires the minor radius to be higher than 0 if ((majorRadius < 0.01) || (minorRadius < 0.01)) { 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; } try { // Build/regenerate the ellipse with the new coordinates if (_ellipse == null) { _ellipse = new Ellipse2D(Context2d, xMin, yMin, majorRadius, minorRadius, 0); } else { _ellipse.SetProperties(xMin, yMin, majorRadius, minorRadius, 0); } _ellipse.Display(true); } catch (Exception ex) { string message = "Exception on creating eclipse (logged): " + ex.Message; MessageBox.Show(message); log.Debug(message); } }
/// <summary> /// Register additional inputs to the ones inherited from the base class. /// </summary> /// <param name="inputName"></param> /// <param name="data"></param> protected override void OnReceiveInputData(string inputName, object data) { switch (inputName) { case ActionNames.Document: _document = data as Document; break; case ActionNames.SolverDrawerPipe: _occMousePosition = data as Mouse3dPosition; break; case ActionNames.Context2d: Context2d = data as OCAIS2D_InteractiveContext; break; default: base.OnReceiveInputData(inputName, data); break; } }
private void OnMouseMove3dAction(Mouse3dPosition point) { if (_points.Count != 1) { return; } Double xMin = _points[0].X(); Double yMin = _points[0].Y(); // Build/regenerate the rectangle with the new coordinates if (_rectangle == null) { _rectangle = new Rectangle2D(Context2d, xMin, yMin, point.Point.X() - xMin, point.Point.Y() - yMin, 0); } else { _rectangle.SetEndpoints(xMin, yMin, point.Point.X() - xMin, point.Point.Y() - yMin, 0); } _rectangle.Display(true); }
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(); } }
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(); } }
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); } }