예제 #1
0
        protected void ResetRectangle()
        {
            if (_mouseEvents != null)
            {
                _mouseEvents.OnMouseMove  -= _onMouseMove_Delegate;
                _onMouseMove_Delegate      = null;
                _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                _onMouseClick_Delegate     = null;
                _mouseEvents = null;
            }

            _rectangleLines                        = null;
            _horizontalMidPointAlign               = null;
            _verticalMidPointAlign                 = null;
            _userInputEvents.OnContextMenu        -= _userInputEvents_OnContextMenuDelegate;
            _userInputEvents_OnContextMenuDelegate = null;
            _planarSketch  = null;
            _drawingSketch = null;
            _secondSelectedSketchEntity = null;
            _inferredOriginPoint        = null;
            _inferredFinalPositionPoint = null;
            _firstSelectedSketchEntity  = null;
            _pickedPoint2d                  = null;
            _pickedSketchPoint              = null;
            _rectangleOriginSketchPoint     = null;
            _rectangleCoordSet              = null;
            _rectanglePointCoords           = null;
            _rectangleInteractionGraphics   = null;
            _rectangleGraphicsColorSet      = null;
            _interactionEvents.OnTerminate -= _onTerminate_Delegate;
            _interactionEvents.Stop();
            _interactionEvents = null;
        }
예제 #2
0
        /// <summary>
        /// When the appropriate rectangle button is clicked the button's OnExecute event handler
        /// calls this method to hook up the mouse click event which will wait for the user to select
        /// a point from which to start the drawing of the rectangle
        /// </summary>
        public virtual void StartRectangleInteraction()
        {
            _interactionEvents = _inventorApplication.CommandManager.CreateInteractionEvents();

            _rectangleInteractionGraphics = _interactionEvents.InteractionGraphics;
            _rectangleClientGraphics      = _rectangleInteractionGraphics.OverlayClientGraphics;
            _rectangleLineNode            = _rectangleClientGraphics.AddNode(1);
            _rectangleGraphicsDataSets    = _rectangleInteractionGraphics.GraphicsDataSets;
            _rectangleCoordSet            = _rectangleGraphicsDataSets.CreateCoordinateSet(1);
            _rectangleIndexSet            = _rectangleGraphicsDataSets.CreateIndexSet(1);

            _onTerminate_Delegate           = new InteractionEventsSink_OnTerminateEventHandler(StopInteraction);
            _interactionEvents.OnTerminate += _onTerminate_Delegate;

            _userInputEvents = _inventorApplication.CommandManager.UserInputEvents;
            _userInputEvents_OnContextMenuDelegate = new UserInputEventsSink_OnContextMenuEventHandler(UserInputEvents_OnContextMenu);
            _userInputEvents.OnContextMenu        += _userInputEvents_OnContextMenuDelegate;

            _mouseEvents = _interactionEvents.MouseEvents;
            _mouseEvents.PointInferenceEnabled = true;
            _onMouseClick_Delegate             = new MouseEventsSink_OnMouseClickEventHandler(OnMouseClick_CreateRectangle);
            _mouseEvents.OnMouseClick         += _onMouseClick_Delegate;

            _interactionEvents.StatusBarText = "Select a Point from which to start the rectangle";

            _interactionEvents.AllowCommandAliases = true;

            _interactionEvents.Start();
        }
예제 #3
0
        //-----------------------------------------------------------------------------
        //----------------- MoveCmd implement ----------------------------------------
        //-----------------------------------------------------------------------------
        public void InitializePreviewGraphics()
        {
            m_interactionEvents = m_inventorApplication.CommandManager.CreateInteractionEvents();

            InteractionGraphics interactionGraphics = m_interactionEvents.InteractionGraphics;

            ClientGraphics previewClientGraphics = interactionGraphics.PreviewClientGraphics;

            m_previewClientGraphicsNode = previewClientGraphics.AddNode(1);

            m_pointGraphics = m_previewClientGraphicsNode.AddPointGraphics();

            GraphicsDataSets graphicsDateSets = interactionGraphics.GraphicsDataSets;

            m_graphicsCoordinateSet = graphicsDateSets.CreateCoordinateSet(1);

            m_graphicsColorSet = graphicsDateSets.CreateColorSet(1);

            m_graphicsColorSet.Add(1, 255, 0, 0);

            m_graphicsColorIndexSet = graphicsDateSets.CreateIndexSet(1);

            m_pointGraphics.CoordinateSet = m_graphicsCoordinateSet;
            m_pointGraphics.BurnThrough   = true;
        }
예제 #4
0
        public void InitializePreviewGraphics()
        {
            m_interactionEvents = m_inventorApplication.CommandManager.CreateInteractionEvents();

            InteractionGraphics interactionGraphics = m_interactionEvents.InteractionGraphics;

            ClientGraphics previewClientGraphics = interactionGraphics.PreviewClientGraphics;

            m_previewClientGraphicsNode = previewClientGraphics.AddNode(1);

            m_triangleStripGraphics = m_previewClientGraphicsNode.AddTriangleStripGraphics();

            GraphicsDataSets graphicsDataSets = interactionGraphics.GraphicsDataSets;

            m_graphicsCoordinateSet = graphicsDataSets.CreateCoordinateSet(1);

            m_graphicsColorSet = graphicsDataSets.CreateColorSet(1);

            m_graphicsColorSet.Add(1, 100, 100, 200);
            m_graphicsColorSet.Add(2, 150, 150, 250);

            m_graphicsColorIndexSet = graphicsDataSets.CreateIndexSet(1);

            m_triangleStripGraphics.CoordinateSet = m_graphicsCoordinateSet;
            m_triangleStripGraphics.ColorSet      = m_graphicsColorSet;
            m_triangleStripGraphics.ColorIndexSet = m_graphicsColorIndexSet;

            m_triangleStripGraphics.ColorBinding = ColorBindingEnum.kPerItemColors;
            m_triangleStripGraphics.BurnThrough  = true;
        }
예제 #5
0
        public DragPointCmd()
        {
            m_userInputEvents = null;

            m_interactionGrapgics = null;

            m_workPoint = null;
        }
예제 #6
0
        private void Render(int renderLayer, Renderer renderer)
        {
            ResolveDockingCoordinates(Dock, WorldWidth, WorldHeight, out float x, out float y);

            InteractionGraphics.Render(renderLayer, renderer, x, y, WorldWidth, WorldHeight, InteractionState);

            AdditionalRender(renderLayer, renderer);
            //renderer.FillCircle(renderLayer - 1, Color.Red, 0, 0, 1);
            //renderer.DrawRectangle(renderLayer - 1, Color.Green, 0.5f, /*Bounds.X - Transform.Position.X, Bounds.Y - Transform.Position.Y*/0, 0, bounds.Width, bounds.Height);
        }
예제 #7
0
        void DoDemo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            //Create new interaction event
            _interactionEvents = InvApp.CommandManager.CreateInteractionEvents();

            //Store mouse events
            _mouseEvents = _interactionEvents.MouseEvents;

            //Enable mouse move. This is disabled by default for performance reasons
            _mouseEvents.MouseMoveEnabled = true;

            //Listen to OnMouseMove event
            _mouseEvents.OnMouseMove +=
                new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove);

            _interactionEvents.StatusBarText = "Select triangle vertex: ";

            //Retrieve InteractionGraphics
            InteractionGraphics ig = _interactionEvents.InteractionGraphics;

            //Create new node
            GraphicsNode node = ig.OverlayClientGraphics.AddNode(1);

            //Add Triangle primitive
            _triangleGraph = node.AddTriangleGraphics();

            //Set up coordinates
            GraphicsCoordinateSet coordSet = ig.GraphicsDataSets.CreateCoordinateSet(1);

            double[] coords = new double[]
            {
                0.0, 0.0, 0.0, //vertex 1
                5.0, 0.0, 0.0, //vertex 2
                2.5, 5.0, 0.0  //vertex 3
            };

            coordSet.PutCoordinates(ref coords);

            _triangleGraph.CoordinateSet = coordSet;

            _interactionEvents.Start();
        }
예제 #8
0
        public override void OnDrag(DragStateEnum DragState, ShiftStateEnum ShiftKeys, Point ModelPosition, Point2d ViewPosition, View View, NameValueMap AdditionalInfo, out HandlingCodeEnum HandlingCode)
        {
            SelectSet oSelectSet;

            oSelectSet = m_inventorApplication.ActiveDocument.SelectSet;

            if (DragState == DragStateEnum.kDragStateDragHandlerSelection)
            {
                if (oSelectSet.Count == 1 && oSelectSet[1].Type == (int)ObjectTypeEnum.kWorkPointObject)
                {
                    m_workPoint = oSelectSet[1];

                    if (m_workPoint.DefinitionType == WorkPointDefinitionEnum.kFixedWorkPoint)
                    {
                        HandlingCode = HandlingCodeEnum.kEventCanceled;

                        this.StartInteraction();

                        m_interactionEvents.MouseEvents.MouseMoveEnabled = true;

                        m_interactionGrapgics = m_interactionEvents.InteractionGraphics;
                        m_interactionEvents.SetCursor(CursorTypeEnum.kCursorBuiltInCommonSketchDrag);
                        m_interactionEvents.Start();
                    }
                    else
                    {
                        base.OnDrag(DragState, ShiftKeys, ModelPosition, ViewPosition, View, AdditionalInfo, out HandlingCode);
                    }
                }
                else
                {
                    base.OnDrag(DragState, ShiftKeys, ModelPosition, ViewPosition, View, AdditionalInfo, out HandlingCode);
                }
            }
            else
            {
                base.OnDrag(DragState, ShiftKeys, ModelPosition, ViewPosition, View, AdditionalInfo, out HandlingCode);
            }
        }
예제 #9
0
        public void UpdatePreviewGraphics()
        {
            m_graphicsCoordinateSet = null;

            InteractionGraphics interactionGraphics = m_interactionEvents.InteractionGraphics;
            GraphicsDataSets    graphicsDataSets    = interactionGraphics.GraphicsDataSets;

            if (graphicsDataSets.Count != 0)
            {
                graphicsDataSets[1].Delete();
            }

            //  m_graphicsCoordinateSet = graphicsDataSets.CreateCoordinateSet(1);

            //m_pointGraphics.CoordinateSet = m_graphicsCoordinateSet;

            //TransientGeometry transientGeometry = m_inventorApplication.TransientGeometry;

            PartDocument oPartDoc;

            oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument;

            PartComponentDefinition oPartCompDef;

            oPartCompDef = oPartDoc.ComponentDefinition;

            WorkAxis workAxis;

            workAxis = oPartCompDef.WorkAxes.AddByRevolvedFace(m_selectFace, true);

            if (m_UCS == null)
            {
                return;
            }

            WorkPoint workPoint;

            workPoint = oPartCompDef.WorkPoints.AddByCurveAndEntity(workAxis, m_UCS.XYPlane);
            Point transPoint = workPoint.Point;

            UnitVector xUnitVector = m_UCS.XAxis.Line.Direction;
            UnitVector yUnitVector = m_UCS.YAxis.Line.Direction;

            Double[] xCoords = new Double[3];
            xUnitVector.GetUnitVectorData(ref xCoords);
            Double[] yCoords = new Double[3];
            yUnitVector.GetUnitVectorData(ref yCoords);

            double xOffset = this.GetValueFromExpression(m_moveCmdDlg.xOffsetText.Text);
            double yOffset = this.GetValueFromExpression(m_moveCmdDlg.yOffsetText.Text);

            Double[] transCoords = new Double[3];
            transCoords[0] = xOffset * xCoords[0] + yOffset * yCoords[0];
            transCoords[1] = xOffset * xCoords[1] + yOffset * yCoords[1];
            transCoords[2] = xOffset * xCoords[2] + yOffset * yCoords[2];

            Vector transVector = m_inventorApplication.TransientGeometry.CreateVector();

            transVector.PutVectorData(transCoords);

            transPoint.TranslateBy(transVector);

            Double[] oPointCoords = new Double[3];
            oPointCoords[0] = transPoint.X;
            oPointCoords[1] = transPoint.Y;
            oPointCoords[2] = transPoint.Z;

            m_graphicsCoordinateSet = graphicsDataSets.CreateCoordinateSet(1);

            m_graphicsCoordinateSet.PutCoordinates(oPointCoords);

            m_pointGraphics.CoordinateSet = m_graphicsCoordinateSet;

            TransientGeometry transientGeometry = m_inventorApplication.TransientGeometry;

            // m_graphicsCoordinateSet.Add(1, transPoint);

            m_inventorApplication.ActiveView.Update();
        }
예제 #10
0
        public void UpdatePreviewGraphics()
        {
            //remove the existing co-ordinates
            m_graphicsCoordinateSet = null;

            InteractionGraphics interactionGraphics = m_interactionEvents.InteractionGraphics;
            GraphicsDataSets    graphicsDataSets    = interactionGraphics.GraphicsDataSets;

            m_graphicsCoordinateSet = graphicsDataSets.CreateCoordinateSet(1);

            //remove the existing color indices
            m_graphicsColorIndexSet = null;

            m_graphicsColorIndexSet = graphicsDataSets.CreateIndexSet(1);
            m_triangleStripGraphics.CoordinateSet = m_graphicsCoordinateSet;
            m_triangleStripGraphics.ColorIndexSet = m_graphicsColorIndexSet;

            TransientGeometry transientGeometry = m_inventorApplication.TransientGeometry;

            Point point1 = transientGeometry.CreatePoint(0, 0, 0);
            Point point2 = transientGeometry.CreatePoint(m_length, 0, 0);
            Point point3 = transientGeometry.CreatePoint(m_length, m_width, 0);
            Point point4 = transientGeometry.CreatePoint(0, m_width, 0);
            Point point5 = transientGeometry.CreatePoint(0, 0, m_height);
            Point point6 = transientGeometry.CreatePoint(m_length, 0, m_height);
            Point point7 = transientGeometry.CreatePoint(m_length, m_width, m_height);
            Point point8 = transientGeometry.CreatePoint(0, m_width, m_height);

            AddGraphicsPoints(point1);
            AddColorIndex(1);
            AddGraphicsPoints(point6);
            AddColorIndex(1);
            AddGraphicsPoints(point2);
            AddColorIndex(1);
            AddGraphicsPoints(point3);
            AddColorIndex(1);
            AddGraphicsPoints(point1);
            AddColorIndex(2);
            AddGraphicsPoints(point4);
            AddColorIndex(2);
            AddGraphicsPoints(point8);
            AddColorIndex(1);
            AddGraphicsPoints(point3);
            AddColorIndex(1);
            AddGraphicsPoints(point7);
            AddColorIndex(2);
            AddGraphicsPoints(point6);
            AddColorIndex(2);
            AddGraphicsPoints(point8);
            AddColorIndex(1);
            AddGraphicsPoints(point5);
            AddColorIndex(1);
            AddGraphicsPoints(point1);
            AddColorIndex(2);
            AddGraphicsPoints(point6);
            AddColorIndex(2);

            m_inventorApplication.ActiveView.Update();

            //Get the CommandManager object
            CommandManager oCommandManager;

            oCommandManager = m_inventorApplication.CommandManager;

            //Get control definition for the homeview command
            ControlDefinition oControlDef;

            oControlDef = oCommandManager.ControlDefinitions["AppIsometricViewCmd"];

            //Excute the command
            oControlDef.Execute();
        }
        protected void ResetRectangle()
        {
            if (_mouseEvents != null)
            {
                _mouseEvents.OnMouseMove -= _onMouseMove_Delegate;
                _onMouseMove_Delegate = null;
                _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                _onMouseClick_Delegate = null;
                _mouseEvents = null;
            }

            _rectangleLines = null;
            _horizontalMidPointAlign = null;
            _verticalMidPointAlign = null;
            _userInputEvents.OnContextMenu -= _userInputEvents_OnContextMenuDelegate;
            _userInputEvents_OnContextMenuDelegate = null;
            _planarSketch = null;
            _drawingSketch = null;
            _secondSelectedSketchEntity = null;
            _inferredOriginPoint = null;
            _inferredFinalPositionPoint = null;
            _firstSelectedSketchEntity = null;
            _pickedPoint2d = null;
            _pickedSketchPoint = null;
            _rectangleOriginSketchPoint = null;
            _rectangleCoordSet = null;
            _rectanglePointCoords = null;
            _rectangleInteractionGraphics = null;
            _rectangleGraphicsColorSet = null;
            _interactionEvents.OnTerminate -= _onTerminate_Delegate;
            _interactionEvents.Stop();
            _interactionEvents = null;
        }
        /// <summary>
        /// When the appropriate rectangle button is clicked the button's OnExecute event handler
        /// calls this method to hook up the mouse click event which will wait for the user to select 
        /// a point from which to start the drawing of the rectangle
        /// </summary>
        public virtual void StartRectangleInteraction()
        {
            _interactionEvents = _inventorApplication.CommandManager.CreateInteractionEvents();

            _rectangleInteractionGraphics = _interactionEvents.InteractionGraphics;
            _rectangleClientGraphics = _rectangleInteractionGraphics.OverlayClientGraphics;
            _rectangleLineNode = _rectangleClientGraphics.AddNode(1);
            _rectangleGraphicsDataSets = _rectangleInteractionGraphics.GraphicsDataSets;
            _rectangleCoordSet = _rectangleGraphicsDataSets.CreateCoordinateSet(1);
            _rectangleIndexSet = _rectangleGraphicsDataSets.CreateIndexSet(1);

            _onTerminate_Delegate = new InteractionEventsSink_OnTerminateEventHandler(StopInteraction);
            _interactionEvents.OnTerminate += _onTerminate_Delegate;

            _userInputEvents = _inventorApplication.CommandManager.UserInputEvents;
            _userInputEvents_OnContextMenuDelegate = new UserInputEventsSink_OnContextMenuEventHandler(UserInputEvents_OnContextMenu);
            _userInputEvents.OnContextMenu += _userInputEvents_OnContextMenuDelegate;

            _mouseEvents = _interactionEvents.MouseEvents;
            _mouseEvents.PointInferenceEnabled = true;
            _onMouseClick_Delegate = new MouseEventsSink_OnMouseClickEventHandler(OnMouseClick_CreateRectangle);
            _mouseEvents.OnMouseClick += _onMouseClick_Delegate;

            _interactionEvents.StatusBarText = "Select a Point from which to start the rectangle";

            _interactionEvents.AllowCommandAliases = true;

            _interactionEvents.Start();
        }