// Every click adds a Quad protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e) { if (ActionMode == actionType.None && !GetToolBar().Contains(RenderContextUtility.ConvertPoint(GetMousePosition(e))) && e.ChangedButton == System.Windows.Input.MouseButton.Left) { if (firstClick == false) { ScreenToPlane(RenderContextUtility.ConvertPoint(GetMousePosition(e)), plane, out start); SnapToGrid(ref start); firstClick = true; } else { ScreenToPlane(RenderContextUtility.ConvertPoint(GetMousePosition(e)), plane, out end); SnapToGrid(ref end); Line l = new Line(start, end); Entities.Add(new Quad( l.StartPoint, l.EndPoint, new Point3D(l.EndPoint.X, l.EndPoint.Y, l.EndPoint.Z + wallHeight), new Point3D(l.StartPoint.X, l.StartPoint.Y, l.StartPoint.Z + wallHeight)), wallColor); start = end; Invalidate(); } } base.OnMouseUp(e); }
private void model1_MouseMove(object sender, MouseEventArgs e) { if (cameraIsMoving) { return; } int index = model1.GetEntityUnderMouseCursor(RenderContextUtility.ConvertPoint(model1.GetMousePosition(e))); if (index != -1 && index != lastIndex) { //hide the tooltip tip.IsOpen = false; //get the entity Entity ent = model1.Entities[index]; //get the entity type string entType = ent.GetType().ToString().Split('.').LastOrDefault(); //show the tooltip with the entity info tip.Content = entType + " ID: " + index; ToolTipService.SetToolTip(model1, tip); tip.IsOpen = true; lastIndex = index; } }
private void viewport_dragDrop(object sender, DragEventArgs e) { if (isDragging) { //shows default cursor e.Effects = DragDropEffects.None; if (_selBlockName != null) { // gets current mouse position System.Drawing.Point mouseLocation = RenderContextUtility.ConvertPoint(model1.GetMousePosition(e)); // current 3D point Point3D dragTo; model1.ScreenToPlane(mouseLocation, Plane.XY, out dragTo); Vector3D delta = (Vector3D)tempEntity.EntityData; // translates entity to the temp entity current position currentRef.Transformation = new Translation(delta); // adds the entity to the viewport model1.Entities.Add(currentRef); // refresh the entities treeView PopulateTree(treeView1, new List <Entity>() { currentRef }, model1.Blocks); } FinishDraggingOperation(); } }
void eyeshot_PreviewMouseDown(object sender, MouseButtonEventArgs e) { // gets the entity index int entityIndex = eyeshot.GetEntityUnderMouseCursor(RenderContextUtility.ConvertPoint(e.GetPosition(eyeshot))); // if we found an entity and the left mouse button is down if (entityIndex != -1 && e.LeftButton == MouseButtonState.Pressed) { try { // gets the entity reference Entity entity = eyeshot.Entities[entityIndex] as Entity; if (entity is Joint) { var joint = entity as Joint; BaseIO(joint.Position); } } catch { return; } //Debugger.Break(); } }
protected void OnMouseMove_Picking(MouseEventArgs e) { if (buttonPressed) { System.Drawing.Point location = RenderContextUtility.ConvertPoint(GetMousePosition(e)); int diffX = location.X - initialLocation.X; if (diffX > 10) { CurrentPickState = Common.ViewportPickState.Enclosed; } else if (diffX < -10) { CurrentPickState = Common.ViewportPickState.Crossing; } else { CurrentPickState = Common.ViewportPickState.Pick; } currentLocation = location; _SwapBufferRequired = true; } }
private void model1_MouseMove(object sender, MouseEventArgs e) { // if moving action is enabled, then draws temporary arrows when the mouse is hover an entity if (move && e.LeftButton == MouseButtonState.Released && e.RightButton == MouseButtonState.Released && e.MiddleButton == MouseButtonState.Released) { TranslateAndShowArrows(RenderContextUtility.ConvertPoint(model1.GetMousePosition(e))); } if (!move || e.LeftButton != MouseButtonState.Pressed || model1.ActionMode != actionType.None || model1.GetToolBar().Contains(RenderContextUtility.ConvertPoint(model1.GetMousePosition(e)))) { return; } if (moveFrom == null) { return; } // if we found an entity and the left mouse button is down if (entityIndex != -1 && e.LeftButton == MouseButtonState.Pressed) { // removes temp arrows during translation, if present model1.TempEntities.Remove(tempArrows[0]); model1.TempEntities.Remove(tempArrows[1]); model1.TempEntities.Remove(tempArrows[2]); model1.TempEntities.Remove(tempArrows[3]); // gets the entity reference Entity entity = model1.Entities[entityIndex] as Entity; // current 3D point Point3D moveTo; model1.ScreenToPlane(RenderContextUtility.ConvertPoint(model1.GetMousePosition(e)), xyzPlane, out moveTo); Vector3D delta = Vector3D.Subtract(moveTo, moveFrom); // sets start as current moveFrom = moveTo; // applies the translation entity.Translate(delta); // regens entities that need it model1.Entities.Regen(); // refresh the screen model1.Invalidate(); // sets start as current moveFrom = moveTo; //updates blinked entity if present if (entity.EntityData != null) { ((Entity)entity.EntityData).Translate(delta); ((Entity)entity.EntityData).Regen(0.01); } } }
protected override void OnMouseMove(MouseEventArgs e) { CurrentLocation = RenderContextUtility.ConvertPoint(e.GetPosition(this)); CurrentIndex = GetEntityUnderMouseCursor(CurrentLocation); this.SetCurrentPoint(); if (_isPickingEnable) { OnMouseMove_Picking(e); } if (_isSnapEnable) { OnMouseMove_Snapping(e); } if (_isDrawingEnable) { OnMouseMove_Drawing(e); } if (_SwapBufferRequired) { PaintBackBuffer(); SwapBuffers(); } _SwapBufferRequired = false; base.OnMouseMove(e); }
void viewport_dragDrop(object sender, DragEventArgs e) { if (Dragging) { e.Effects = DragDropEffects.None; if (_selMaterial != "") { // gets target entity int selectedIndex = model1.GetEntityUnderMouseCursor(RenderContextUtility.ConvertPoint((model1.GetMousePosition(e)))); if (selectedIndex != -1) { Entity selEntity = model1.Entities[selectedIndex]; if (selEntity != null) { // gets scale u,v value double u, v; Double.TryParse(this.textBoxU.Text, out u); Double.TryParse(this.textBoxV.Text, out v); // assigns the material to all triangles and maps the material texture with specific mapping ((Mesh)selEntity).ApplyMaterial(_selMaterial, SelMapping, u, v); model1.Entities.Regen(); } } } Dragging = false; model1.Invalidate(); } }
private void seatColor_Click(object sender, RoutedEventArgs e) { ToggleButton rb = (ToggleButton)sender; model1.Layers[plasticMatName].Color = RenderContextUtility.ConvertColor(rb.Background); // affects edges color model1.Materials[plasticMatName].Diffuse = RenderContextUtility.ConvertColor(rb.Background); // affects faces color model1.Invalidate(); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); mousePos = RenderContextUtility.ConvertPoint(GetMousePosition(e)); PaintBackBuffer(); SwapBuffers(); }
protected override void OnMouseUp(MouseButtonEventArgs e) { Point location = RenderContextUtility.ConvertPoint(GetMousePosition(e)); if (GetToolBar().Contains(location)) { base.OnMouseUp(e); return; } if (_measuring) { if (e.ChangedButton == MouseButton.Left) { if (_firstClick == false) { _points.Clear(); _firstClick = true; } if (FindClosestPoint(location) == -1) { StopMeasuring(false); } else { _points.Add(_measureEndPoint); if (_points.Count > 1) { _line = new Line(_points[0], _points[1]) { LineWeightMethod = colorMethodType.byEntity, LineWeight = 1 }; string text = String.Format("{0} mm", Math.Round(_line.Length(), 2)); var to = new TextOnly((_line.StartPoint + _line.EndPoint) / 2, text, new Font("Tahoma", 8.25f), Color.Black, ContentAlignment.BottomLeft); Entities.Add(_line, Color.Black); Labels.Add(to); Invalidate(); StopMeasuring(false); } } } else if (e.ChangedButton == MouseButton.Right) { ResetMeasuring(); } } base.OnMouseUp(e); }
protected override void OnMouseMove(MouseEventArgs e) { _mouseLocation = RenderContextUtility.ConvertPoint(GetMousePosition(e)); _current = ScreenToWorld(RenderContextUtility.ConvertPoint(GetMousePosition(e))); // paint the viewport surface PaintBackBuffer(); // consolidates the drawing SwapBuffers(); base.OnMouseMove(e); }
protected void OnMouseDown_Picking(MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left && ActionMode == devDept.Eyeshot.actionType.None) { if (!GetViewCubeIcon().Contains(RenderContextUtility.ConvertPoint(GetMousePosition(e)))) { buttonPressed = true; initialLocation = currentLocation = RenderContextUtility.ConvertPoint(GetMousePosition(e)); CurrentPickState = Common.ViewportPickState.Pick; } } }
public MyViewModel() { // Initializes the Coordinate System Icon for the data binding. MyCoordinateSystemIcon = new CoordinateSystemIcon(); // Initializes the Origin Symbol for the data binding. MyOriginSymbol = OriginSymbol.GetDefaultOriginSymbol(); OsStyleType = originSymbolStyleType.Ball; // Initializes the Grids collection for the data binding. Grid grid = new Grid() { Step = 10, MajorLinesEvery = 4 }; MyGrids = new ObservableCollection <Grid> { grid }; // Initializes the ToolBar for the data binding. MyToolBars = new ObservableCollection <ToolBar>(new List <ToolBar>() { ToolBar.GetDefaultToolBar() }); MyToolBar.Position = ToolBar.positionType.HorizontalTopCenter; // Uses toolbar buttons count info to enable/disable the Add/Remove buttons _buttonsCount = MyToolBar.Buttons.Count; // Creates the command for the the Add/Remove buttons CreateAddToolbarButtonCommand(); CreateRemoveToolbarButtonCommand(); // Initializes the BackgroundSettings for the the data binding. MyBackgroundSettings = new BackgroundSettings(backgroundStyleType.Solid, Helper.ConvertColor("#FF434752"), System.Drawing.Color.White, Helper.ConvertColor("#FFEDEDED"), .75, null); // Sets the ViewModel's BackgroundStyle: in this way the "Background" comboboxes will be updated too. BackgroundStyle = MyBackgroundSettings.StyleMode; // Initializes the Background images. MyBackgroundSettings.Image = Image1 = RenderContextUtility.ConvertImage(new Bitmap(Pictures + "background1.jpg")); Image2 = RenderContextUtility.ConvertImage(new Bitmap(Pictures + "background2.jpg")); Image3 = RenderContextUtility.ConvertImage(new Bitmap(Pictures + "background3.jpg")); // Initializes the Images for the ViewCube buttons. VcResetImages = ViewCubeIcon.GetDefaultViewCubeIcon().FrontImage; VcImage1 = RenderContextUtility.ConvertImage(new Bitmap(Pictures + "Spongebob_Front.jpg")); VcImage2 = RenderContextUtility.ConvertImage(new Bitmap(Pictures + "Noel_Front.jpg")); // Initializes the EntitiList collection for the the data binding. _entityList = new MyEntityList(); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (leftButtonDown) { stroke.Add(RenderContextUtility.ConvertPoint(GetMousePosition(e))); // Repaints the scene and draws the strokes in the DrawOverlay PaintBackBuffer(); SwapBuffers(); //Invalidate(); } }
private void BtnVcImage1_OnChecked(object sender, RoutedEventArgs e) { if (_myViewModel != null) { _myViewModel.VcFaceImages = new ImageSource[] { RenderContextUtility.ConvertImage(new Bitmap(Pictures + "Spongebob_Front.jpg")), RenderContextUtility.ConvertImage(new Bitmap(Pictures + "Spongebob_Back.jpg")), RenderContextUtility.ConvertImage(new Bitmap(Pictures + "Spongebob_Top.jpg")), RenderContextUtility.ConvertImage(new Bitmap(Pictures + "Spongebob_Bottom.jpg")), RenderContextUtility.ConvertImage(new Bitmap(Pictures + "Spongebob_Left.jpg")), RenderContextUtility.ConvertImage(new Bitmap(Pictures + "Spongebob_Right.jpg")) } } ; }
protected override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); if (GetToolBar().Contains(RenderContextUtility.ConvertPoint(GetMousePosition(e))) || ActionMode != actionType.None) { return; } stroke.Clear(); Invalidate(); if (e.LeftButton == MouseButtonState.Pressed) { leftButtonDown = true; } }
private void Model1_OnMouseDown(object sender, MouseButtonEventArgs e) { // Checks that we are not using left mouse button for ZPR if (model1.ActionMode == actionType.None && e.ChangedButton != System.Windows.Input.MouseButton.Middle) { Point3D closest; if (inspectVertex) { if (model1.FindClosestVertex(RenderContextUtility.ConvertPoint(model1.GetMousePosition(e)), 50, out closest) != -1) { model1.Labels.Add(new devDept.Eyeshot.Labels.LeaderAndText(closest, closest.ToString(), new System.Drawing.Font("Tahoma", 8.25f), MyModel.DrawingColor, new Vector2D(0, 50))); } } model1.Invalidate(); } }
private void viewport_dragOver(object sender, DragEventArgs e) { // gets current mouse position System.Drawing.Point mouseLocation = RenderContextUtility.ConvertPoint(model1.GetMousePosition(e)); if (model1.ActionMode != actionType.None || model1.GetToolBar().Contains(mouseLocation)) { return; } if (isDragging && tempEntity != null) { // current 3D point Point3D dragTo; model1.ScreenToPlane(mouseLocation, Plane.XY, out dragTo); Vector3D delta = Vector3D.Subtract(dragTo, dragFrom); // applies the translation to the temp entity tempEntity.Translate(delta); tempEntity.Regen(0.1); // saves translations applied if (tempEntity.EntityData == null) { tempEntity.EntityData = delta; } else { tempEntity.EntityData = ((Vector3D)tempEntity.EntityData) + delta; } // updates camera Near and Far planes to avoid clipping temp entity on the scene during translation model1.TempEntities.UpdateBoundingBox(); // refresh the screen model1.Invalidate(); // sets start as current dragFrom = dragTo; } }
private void model1_MouseDown(object sender, MouseButtonEventArgs e) { Point mousePos = RenderContextUtility.ConvertPoint(model1.GetMousePosition(e)); if (!move || e.LeftButton != MouseButtonState.Pressed || model1.ActionMode != actionType.None || model1.GetToolBar().Contains(mousePos)) { return; } // gets the entity index entityIndex = model1.GetEntityUnderMouseCursor(mousePos); if (entityIndex < 0) { return; } // gets 3D start point model1.ScreenToPlane(mousePos, xyzPlane, out moveFrom); }
// Every click adds a line protected override void OnMouseUp(MouseButtonEventArgs e) { if (GetToolBar().Contains(RenderContextUtility.ConvertPoint(GetMousePosition(e)))) { base.OnMouseUp(e); return; } if (ActionMode == actionType.None && e.ChangedButton == System.Windows.Input.MouseButton.Left) { if (firstClick == false) { points.Clear(); firstClick = true; } ScreenToPlane(RenderContextUtility.ConvertPoint(GetMousePosition(e)), plane, out current); points.Add(current); } else if (e.ChangedButton == System.Windows.Input.MouseButton.Right) { ScreenToPlane(RenderContextUtility.ConvertPoint(GetMousePosition(e)), plane, out current); points.Add(current); lp = new LinearPath(points); lp.LineWeightMethod = colorMethodType.byEntity; lp.LineWeight = 2; Entities.Add(lp, System.Drawing.Color.ForestGreen); points.Clear(); current = null; Invalidate(); } base.OnMouseUp(e); }
protected override void OnMouseMove(MouseEventArgs e) { if (DrawingLinearDim && ActionMode == actionType.None) { // saves the current mouse position _mouseLocation = RenderContextUtility.ConvertPoint(GetMousePosition(e)); _snappedPoint = null; int index = GetEntityUnderMouseCursor(_mouseLocation); if (index != -1 && !(Entities[index] is RasterView)) { FindClosestVertex(_mouseLocation, 50, out _snappedPoint); // returns the closest snapped point to the cursor } // paints the viewport surface PaintBackBuffer(); // consolidates the drawing SwapBuffers(); } base.OnMouseMove(e); }
protected override void OnMouseMove(MouseEventArgs e) { // save the current mouse position mouseLocation = RenderContextUtility.ConvertPoint(GetMousePosition(e)); // if start is valid and actionMode is None and it's not in the toolbar area if (current == null || ActionMode != actionType.None || GetToolBar().Contains(RenderContextUtility.ConvertPoint(GetMousePosition(e)))) { base.OnMouseMove(e); return; } // paint the viewport surface PaintBackBuffer(); // consolidates the drawing SwapBuffers(); base.OnMouseMove(e); }
private void DrawTooltip(MouseEventArgs e) { if (model1.ObjectManipulator.Visible) { return; } int entId = model1.GetEntityUnderMouseCursor(RenderContextUtility.ConvertPoint(model1.GetMousePosition(e))); string newString = string.Empty; if (entId >= 0) { newString = textSelectEntity; } else { newString = textResetCurrent; } SetToolTipText(newString); }
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); }
protected override void OnMouseDown(MouseButtonEventArgs e) { var mousePosition = RenderContextUtility.ConvertPoint(GetMousePosition(e)); if (DrawingLinearDim && ActionMode == actionType.None) { if (GetToolBar().Contains(mousePosition)) { base.OnMouseDown(e); return; } if (e.ChangedButton == MouseButton.Left) { if (_numPoints < 2) { if (_snappedPoint != null) { _points[_numPoints++] = _snappedPoint; // adds the snapped point to the list of points } if (_numPoints == 1) { int index = GetEntityUnderMouseCursor(_mouseLocation); if (index != -1) { var view = Entities[index] as devDept.Eyeshot.Entities.View; if (view != null) { _viewScale = view.Scale; } else { _viewScale = 1; } } } } else { // the following lines need to add LinearDim to Drawings ScreenToPlane(mousePosition, _plane, out _current); double unitsConversionFactor = GetUnitsConversionFactor(); var linearDim = new LinearDim(_drawingPlane, _points[0] / unitsConversionFactor, _points[1] / unitsConversionFactor, _current / unitsConversionFactor, DimTextHeight); linearDim.Scale(unitsConversionFactor); linearDim.LayerName = WiresLayerName; linearDim.LinearScale = 1 / _viewScale; Entities.Add(linearDim); Invalidate(); DisableDimensioning(); } } else if (e.RightButton == MouseButtonState.Pressed) // restarts dimensioning { _points = new Point3D[3]; _numPoints = 0; _viewScale = 1; } } base.OnMouseDown(e); }
private void model1_MouseDownItem(object sender, MouseButtonEventArgs e) { // add item(vertex, Edge or Face) under mouse cursor as Temporary Entity on the screen if (e.LeftButton == MouseButtonState.Pressed && model1.ActionMode == actionType.None && !model1.GetToolBar().Contains(RenderContextUtility.ConvertPoint(model1.GetMousePosition(e)))) { AddEntityItem(model1.GetMousePosition(e)); } }
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); }
public ListViewModelItem(Layer layer) { Layer = layer; IsChecked = layer.Visible; ForeColor = RenderContextUtility.ConvertColor(Layer.Color); }
protected override void OnMouseMove(MouseEventArgs e) { // save the current mouse position mouseLocation = RenderContextUtility.ConvertPoint(GetMousePosition(e)); // If ObjectSnap is ON, we need to find closest vertex (if any) if (objectSnapEnabled) { this.snapPoint = null; snapPoints = GetSnapPoints(mouseLocation); } // if start is valid and actionMode is None and it's not in the toolbar area if (current == null || ActionMode != actionType.None || GetToolBar().Contains(mouseLocation)) { base.OnMouseMove(e); return; } // paint the viewport surface PaintBackBuffer(); // consolidates the drawing SwapBuffers(); if (drawingPoints) { activeOperationLabel = "Points: "; } else if (drawingText) { activeOperationLabel = "Text: "; } else if (drawingLeader) { activeOperationLabel = "Leader: "; } else if (drawingLine) { activeOperationLabel = "Line: "; } else if (drawingEllipse) { activeOperationLabel = "Ellipse: "; } else if (drawingEllipticalArc) { activeOperationLabel = "EllipticalArc: "; } else if (drawingCircle) { activeOperationLabel = "Circle: "; } else if (drawingArc) { activeOperationLabel = "Arc: "; } else if (drawingPolyLine) { activeOperationLabel = "Polyline: "; } else if (drawingCurve) { activeOperationLabel = "Spline: "; } else if (doingMirror) { activeOperationLabel = "Mirror: "; } else if (doingOffset) { activeOperationLabel = "Offset: "; } else if (doingTrim) { activeOperationLabel = "Trim: "; } else if (doingExtend) { activeOperationLabel = "Extend: "; } else if (doingFillet) { activeOperationLabel = "Fillet: "; } else if (doingChamfer) { activeOperationLabel = "Chamfer: "; } else if (doingMove) { activeOperationLabel = "Move: "; } else if (doingRotate) { activeOperationLabel = "Rotate: "; } else if (doingScale) { activeOperationLabel = "Scale: "; } else if (doingTangents) { activeOperationLabel = "Tangents: "; } else { activeOperationLabel = ""; } base.OnMouseMove(e); }