Example #1
0
        // version 2010-05-23: to solve the issue in Perspective View
        private void m_MouseEvents_OnMouseMove(Inventor.MouseButtonEnum Button, Inventor.ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
        {
            //if the interaction event is MyScreenshot, draw selecting rectangle.
            if (m_InteractionEvents.Name == "MyScreenshot" && m_flagMouseDown)
            {
                TransientGeometry tg = m_inventorApplication.TransientGeometry;

                Inventor.Point P1 = tg.CreatePoint(m_MouseStartViewPt.X, -m_MouseStartViewPt.Y, 0);
                Inventor.Point P3 = tg.CreatePoint(ViewPosition.X, -ViewPosition.Y, 0);
                Inventor.Point P4 = tg.CreatePoint(P1.X, P3.Y, 0);
                Inventor.Point P2 = tg.CreatePoint(P3.X, P1.Y, 0);

                //update coordinates

                oCoordSet[1] = P1;
                oCoordSet[2] = P2;
                oCoordSet[3] = P3;
                oCoordSet[4] = P4;
                oCoordSet[5] = P1;

                //add line strip
                if (oGiLineStripG != null)
                {
                    //SetTransformBehavior, default value for PixelScale is 1
                    oGiLineStripG.SetTransformBehavior(P1, DisplayTransformBehaviorEnum.kFrontFacingAndPixelScaling, 1);
                    oGiLineStripG.SetViewSpaceAnchor(P1, m_MouseStartViewPt, ViewLayoutEnum.kTopLeftViewCorner);
                }
                else if (oGiLineG != null)
                {
                    //SetTransformBehavior, default value for PixelScale is 1
                    oGiLineG.SetTransformBehavior(P1, DisplayTransformBehaviorEnum.kFrontFacingAndPixelScaling, 1);
                    oGiLineG.SetViewSpaceAnchor(P1, m_MouseStartViewPt, ViewLayoutEnum.kTopLeftViewCorner);
                }


                m_inventorApplication.ActiveView.Update();
            }
        }
Example #2
0
        private void m_MouseEvents_OnMouseUp(Inventor.MouseButtonEnum Button, Inventor.ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
        {
            //if the interaction event is MyScreenshot, create the image
            if (m_InteractionEvents.Name == "MyScreenshot")
            {
                m_InteractionEvents.InteractionGraphics.PreviewClientGraphics.Delete();
                m_inventorApplication.ActiveView.Update();

                if (oGiLineStripG != null)
                {
                    oGiLineStripG.Delete();
                    oGiLineStripG = null;
                }

                if (oGiLineG != null)
                {
                    oGiLineG.Delete();
                    oGiLineG = null;
                }

                //stop interaction event
                m_InteractionEvents.SetCursor(CursorTypeEnum.kCursorBuiltInArrow);
                m_flagMouseDown = false;
                if (m_MouseEvents != null)
                {
                    m_MouseEvents.OnMouseDown -= m_MouseEvents_OnMouseDown;
                    m_MouseEvents.OnMouseMove -= m_MouseEvents_OnMouseMove;
                    m_MouseEvents.OnMouseUp   -= m_MouseEvents_OnMouseUp;
                    m_MouseEvents              = null;
                }
                m_InteractionEvents.Stop();
                m_InteractionEvents = null;

                //prepare size of the image region, in pixel

                oSize = new Size(Convert.ToInt32(Math.Abs(ViewPosition.X - m_MouseStartViewPt.X)), Convert.ToInt32(Math.Abs(ViewPosition.Y - m_MouseStartViewPt.Y)));

                if (ViewPosition.X > m_MouseStartViewPt.X & ViewPosition.Y > m_MouseStartViewPt.Y)
                {
                    oCornerPt = m_MouseStartViewPt;
                }
                else if (ViewPosition.X > m_MouseStartViewPt.X & ViewPosition.Y < m_MouseStartViewPt.Y)
                {
                    oCornerPt.X = m_MouseStartViewPt.X;
                    oCornerPt.Y = ViewPosition.Y;
                }
                else if (ViewPosition.X <m_MouseStartViewPt.X& ViewPosition.Y> m_MouseStartViewPt.Y)
                {
                    oCornerPt.X = ViewPosition.X;
                    oCornerPt.Y = m_MouseStartViewPt.Y;
                }
                else
                {
                    oCornerPt = ViewPosition;
                }

                //take the view position in screen, calculate
                //the real pixel data of the corners

                oCornerPt.X = (int)View.Left + oCornerPt.X;
                oCornerPt.Y = (int)View.Top + oCornerPt.Y;
            }
        }
Example #3
0
        private void m_MouseEvents_OnMouseDown(Inventor.MouseButtonEnum Button, Inventor.ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
        {
            //if the interaction event is MyScreenshot,
            //then get the view position and model position

            if (m_InteractionEvents.Name == "MyScreenshot")
            {
                m_MouseStartViewPt = ViewPosition;
                m_StartModelPt     = ModelPosition;
                m_flagMouseDown    = true;

                //clean the last graphics
                m_InteractionEvents.InteractionGraphics.PreviewClientGraphics.Delete();
                m_inventorApplication.ActiveView.Update();

                //gi node
                oGiNode   = m_InteractionEvents.InteractionGraphics.PreviewClientGraphics.AddNode(1);
                oCoordSet = m_InteractionEvents.InteractionGraphics.GraphicsDataSets.CreateCoordinateSet(1);

                //color set
                oColorSet = m_InteractionEvents.InteractionGraphics.GraphicsDataSets.CreateColorSet(1);
                oColorSet.Add(1, 255, 0, 0);

                TransientGeometry tg    = m_inventorApplication.TransientGeometry;
                Inventor.Point    tempP = tg.CreatePoint(ViewPosition.X, ViewPosition.Y, 0);

                oCoordSet.Add(1, tempP);
                oCoordSet.Add(2, tempP);
                oCoordSet.Add(3, tempP);
                oCoordSet.Add(4, tempP);
                oCoordSet.Add(5, tempP);

                try
                {
                    if (oGiLineStripG != null)
                    {
                        oGiLineStripG.Delete();
                        oGiLineStripG = null;
                    }
                    oGiLineStripG = oGiNode.AddLineStripGraphics();
                    oGiLineStripG.CoordinateSet = oCoordSet;
                    oGiLineStripG.ColorSet      = oColorSet;
                    oGiLineStripG.BurnThrough   = true;
                }
                catch (Exception ex)
                {
                    //a problem in Inventor 2009( R13 ) with
                    //LineStripGraphics.BurnThrough. Use LineGraphics as workaround

                    if (oGiLineG != null)
                    {
                        oGiLineG.Delete();
                        oGiLineG = null;
                    }

                    oGiLineG = oGiNode.AddLineGraphics();
                    oGiLineG.CoordinateSet = oCoordSet;
                    oGiLineG.ColorSet      = oColorSet;
                    oGiLineG.BurnThrough   = true;
                }
            }
        }