private void panelForm_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         CurrentTool.OnMouseMove(e.X, e.Y);
     }
 }
Exemple #2
0
        void mPanel_MouseMove(object sender, MouseEventArgs e)
        {
            if (CurrentTool != null)
            {
                CurrentTool.OnMouseMove(e.X, e.Y);
            }
            RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(e.X, e.Y));

            Debug.Write(string.Format("X:{0}mm Y:{1}mm", pt.X * 25.4, pt.Y * 25.4));
        }
Exemple #3
0
        void mPanel_MouseMove(object sender, MouseEventArgs e)
        {
            // base.OnMouseMove(e);
            if (CurrentTool != null)
            {
                CurrentTool.OnMouseMove(e.X, e.Y);
            }
            RPoint pt = Transform.ToUnit(new PointF(e.X, e.Y), this);

            label1.Text = string.Format("X:{0}mm Y:{1}mm", pt.X * 25.4, pt.Y * 25.4);
        }
Exemple #4
0
        void mPanel_MouseMove(object sender, MouseEventArgs e)
        {
            ISnapPoint newsnap = null;
            Point      point   = this.PointToClient(Control.MousePosition);

            RgPoint mousepoint = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(point.X, point.Y));

            //获取捕捉点
            if (RunningSnapsEnabled)
            {
                newsnap = (mMap as Map).SnapPoint(mousepoint, m_runningSnapTypes, null);
            }
            //if (newsnap == null)
            //    newsnap = mMap.GridLayer.SnapPoint(m_canvaswrapper, mousepoint, null);
            if ((m_snappoint != null) && ((newsnap == null) || (newsnap.SnapPoint != m_snappoint.SnapPoint) || m_snappoint.GetType() != newsnap.GetType()))
            {
                PointF pt1 = mScreenDisplay.DisplayTransformation.ToScreen(m_snappoint.SnapPoint);

                Rectangle invalidaterect = new Rectangle((int)pt1.X - 2, (int)pt1.Y - 2, 4, 4);
                invalidaterect.Inflate(2, 2);
                //注意查看
                mScreenDisplay.RepaintStatic(invalidaterect); // remove old snappoint
                m_snappoint = newsnap;
            }

            if (m_snappoint == null)
            {
                m_snappoint = newsnap;
            }

            if (m_snappoint != null)
            {
                RepaintSnappoint(m_snappoint);
            }
            if (CurrentTool != null)
            {
                CurrentTool.OnMouseMove(e.X, e.Y);
            }
            RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(e.X, e.Y));
        }
Exemple #5
0
        void DrawingCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            Point loc = e.GetPosition(this);

            //CurrentUnityPosition = Container.ConvertToUnity(CurrentPosition);

            if (e.MiddleButton == MouseButtonState.Released && e.RightButton == MouseButtonState.Released)
            {
                if (CurrentRuler.IsSnapping)
                {
                    CurrentSnapPosition = new Point(-1, -1);

                    Point snap = new Point(loc.X, loc.Y);

                    if (CurrentRuler.GuideManager.Intersection_GetNearst(ref snap))
                    {
                        CurrentSnapPosition = snap;
                        CurrentPosition     = loc;
                        CurrentTool.OnMouseMove(this, CurrentSnapPosition, e.LeftButton, e.RightButton);
                        return;
                    }

                    Guideline gl = CurrentRuler.GuideManager.GetSnapGuide(loc);
                    if (gl != null)
                    {
                        gl.GetNearestPos(ref snap, CurrentRuler.dPicCapture);
                        CurrentSnapPosition = snap;
                        CurrentPosition     = loc;
                        CurrentTool.OnMouseMove(this, CurrentSnapPosition, e.LeftButton, e.RightButton);
                        return;
                    }
                }
                CurrentPosition = loc;
                CurrentTool.OnMouseMove(this, CurrentPosition, e.LeftButton, e.RightButton);
            }
            else
            {
                this.Cursor = Cursors.Arrow;
            }
        }
        //--------------------------------------------------------------------------------------------------

        public void MouseMove(Point pos, ViewportController viewportController)
        {
            _LastMouseMovePosition           = pos;
            _LastMouseMoveViewportController = viewportController;

            Selection.Update();

            if (pos.X < 0 || pos.Y < 0)
            {
                // Position is out of bounds, reset highlighting
                Workspace.AisContext.MoveTo(Int32.MinValue, Int32.MinValue, viewportController.Viewport.V3dView, false);;
                Invalidate(true);
                return;
            }

            var status = Workspace.AisContext.MoveTo(Convert.ToInt32(pos.X), Convert.ToInt32(pos.Y), viewportController.Viewport.V3dView, false);

            Invalidate(true);

            if (status != AIS_StatusOfDetection.AIS_SOD_Error)
            {
                Pnt rawPoint;
                if (!viewportController.Viewport.ScreenToPoint(Convert.ToInt32(pos.X), Convert.ToInt32(pos.Y), out rawPoint))
                {
                    IsMouseEventDataValid = false;
                    IsCursorPositionValid = false;
                    return;
                }

                Pnt planePoint;
                if (!viewportController.Viewport.ScreenToPoint(Workspace.WorkingPlane, Convert.ToInt32(pos.X), Convert.ToInt32(pos.Y), out planePoint))
                {
                    IsMouseEventDataValid = false;
                    IsCursorPositionValid = false;
                }

                _LastDetectedInteractive = null;
                _LastDetectedOwner       = null;
                InteractiveEntity detectedEntity = null;
                TopoDS_Shape      detectedShape  = null;
                if (Workspace.AisContext.HasDetected())
                {
                    _LastDetectedInteractive = Workspace.AisContext.DetectedInteractive();
                    _LastDetectedOwner       = Workspace.AisContext.DetectedOwner();
                    detectedEntity           = VisualShapes.GetVisibleEntity(_LastDetectedInteractive);
                    detectedShape            = Occt.Helper.Ais.GetDetectedShapeFromContext(Workspace.AisContext);
                }

                _MouseEventData.Set(viewportController.Viewport, pos, rawPoint, planePoint, detectedEntity, _LastDetectedInteractive, detectedShape);
                IsMouseEventDataValid = true;

                CursorPosition        = planePoint;
                CursorPosition2d      = Workspace.WorkingPlane.Parameters(planePoint);
                IsCursorPositionValid = true;
                bool handled = false;

                if (CurrentTool != null)
                {
                    handled = CurrentTool.OnMouseMove(_MouseEventData);
                }

                if (_ToolActions.Any() && !handled)
                {
                    foreach (var toolAction in _ToolActions)
                    {
                        if (toolAction.OnMouseMove(_MouseEventData))
                        {
                            break;
                        }
                    }
                }

                if (_MouseEventData.ForceReDetection)
                {
                    Workspace.AisContext.MoveTo(Convert.ToInt32(pos.X), Convert.ToInt32(pos.Y), viewportController.Viewport.V3dView, false);
                }

                return;
            }

            IsMouseEventDataValid = false;
            IsCursorPositionValid = false;
        }