Exemplo n.º 1
0
        public override void doDrag(MEvent eventArg)
        {
            base.doDrag(eventArg);

            // If we are not in selecting mode (i.e. an object has been selected)
            // then do the translation.
            if (!_isSelecting())
            {
                eventArg.getPosition(ref endPos_x, ref endPos_y);
                MPoint  endW   = new MPoint();
                MPoint  startW = new MPoint();
                MVector vec    = new MVector();
                view.viewToWorld(startPos_x, startPos_y, startW, vec);
                view.viewToWorld(endPos_x, endPos_y, endW, vec);
                downButton = eventArg.mouseButton;

                // We reset the the move vector each time a drag event occurs
                // and then recalculate it based on the start position.
                cmd.undoIt();

                switch (currWin)
                {
                case 0:                         // TOP
                    switch (downButton)
                    {
                    case MEvent.MouseButtonType.kMiddleMouse:
                        cmd.setVector(endW.x - startW.x, 0.0, 0.0);
                        break;

                    case MEvent.MouseButtonType.kLeftMouse:
                    default:
                        cmd.setVector(endW.x - startW.x, 0.0, endW.z - startW.z);
                        break;
                    }
                    break;

                case 1:                         // FRONT
                    switch (downButton)
                    {
                    case MEvent.MouseButtonType.kMiddleMouse:
                        cmd.setVector(endW.x - startW.x, 0.0, 0.0);
                        break;

                    case MEvent.MouseButtonType.kLeftMouse:
                    default:
                        cmd.setVector(endW.x - startW.x, endW.y - startW.y, 0.0);
                        break;
                    }
                    break;

                case 2:                         //SIDE
                    switch (downButton)
                    {
                    case MEvent.MouseButtonType.kMiddleMouse:
                        cmd.setVector(0.0, 0.0, endW.z - startW.z);
                        break;

                    case MEvent.MouseButtonType.kLeftMouse:
                    default:
                        cmd.setVector(0.0, endW.y - startW.y, endW.z - startW.z);
                        break;
                    }
                    break;

                default:
                case 3:                         // PERSP
                    break;
                }

                cmd.redoIt();
                view.refresh(true, false);
            }
        }