Example #1
0
        public PtView(OpenGLSheet PicBox)
        {
            m_PictureBox = PicBox;

            // Add observers.
            m_ViewObserverList = new FRList<ViewPaintObserver>();
            m_ViewObserverList.Add(new NotesObserver());
            m_ViewObserverList.Add(new SelectionObserver());
            m_ViewObserverList.Add(new PreviewObserver());
            m_TransientObjObserver = new TransientObjectObserver();
            m_ViewObserverList.Add(m_TransientObjObserver);

            // Initialize the transform matrix.
            m_DeviceToWorld = Matrix44.Identity;
            m_DeviceToWorld.SetTranslation(GePoint.kOrigin - new GePoint(10, 10));

            // Hook up the events.
            m_PictureBox.MouseDown += new MouseEventHandler(OnMouseDown);
            m_PictureBox.MouseUp += new MouseEventHandler(OnMouseUp);
            m_PictureBox.MouseMove += new MouseEventHandler(OnMouseMove);
            m_PictureBox.MouseDoubleClick += new MouseEventHandler(OnMouseDoubleClick);
            m_PictureBox.MouseClick += new MouseEventHandler(OnMouseClick);
            m_PictureBox.MouseWheel += new MouseEventHandler(OnMouseWheel);

            m_PictureBox.DrawingRender += new System.Windows.Forms.PaintEventHandler(DrawingRender);
            m_PictureBox.DeviceType = OpenGLSheet.GraphicDeviceType.OPENGL;

            m_SelectionManager = new SelectionManager();
        }
Example #2
0
        public void RightMutiplyTest()
        {
            Matrix44 target = Matrix44.Identity;
            target.SetTranslation(new Vector(10, -2.5, 3));

            GePoint point = new GePoint(0, 0, 0);
            GePoint to = new GePoint(1, 2, 3);

            Matrix44 A = new Matrix44();
            A.SetTranslation(to - point);

            Matrix44 expected = target * A;
            Matrix44 actual = A.Clone();
            actual.LeftMultiply(target);

            Assert.AreEqual(expected, actual, "FR.Math.Matrix44.RightMutiply did not return the expected value.");
        }
Example #3
0
        public void MultiplyTest()
        {
            GePoint point = new GePoint(0,0,0);
            GePoint to = new GePoint(1,2,3);

            Matrix44 trans = new Matrix44();
            trans.SetTranslation(to - point);

            GePoint expected = to;
            GePoint actual = trans * point;

            Assert.AreEqual(expected, actual, "FR.Math.Matrix44.operator * did not return the expected value.");
        }
        public override void GenerateGraphics(DisplayItemList DLList)
        {
            Debug.Assert(DLList != null);
             if (null == DLList) return;

             // It must exist two point at least.
             if (m_AttachPoint == null) return;
             if (m_InternalPoints.Empty()) return;

             // Attach point to the first internal point
             GePoint p1 = m_AttachPoint;
             GePoint p2 = m_InternalPoints[0];
             // If the first two points are equal, we needn't continue to calculate.
             if (p1.IsEqualTo(p2)) return;

             Matrix44 trans = new Matrix44();
             trans.SetTranslation(p1 - GePoint.kOrigin);
             //trans.SetRotate(MathFactory.Math.PI, UnitVector.kZAxis, GePoint.kOrigin);
             Vector direction = p2 - p1;
             trans.SetRotate(UnitVector.kXAxis, direction.UnitVector, GePoint.kOrigin);
             //trans.SetRotate(UnitVector.kXAxis, UnitVector.kYAxis, p2);

             // Arrowhead
             BFxSolidArrowHead arrow = new BFxSolidArrowHead();
             arrow.GetDisplayList(DLList, trans);

             DisplayItemBuilder.GenDisplayItemLine(DLList, p1, p2);

             DisplayItemBuilder.GenDisplayItemPoint(DLList, p1);

             DisplayItemBuilder.GenDisplayItemLines(DLList, m_InternalPoints);
             DisplayItemBuilder.GenDisplayItemPoints(DLList, m_InternalPoints);

             // Text
             if (!m_Text.Empty)
             {
                 GeRectangle rec = PtApp.ActiveView.GetRichStringRange(m_Text);

                 if (rec != null)
                 {
                     Vector offset = new Vector(0, -rec.Height / 2, 0);
                     GePoint basePoint = m_InternalPoints[m_InternalPoints.Count - 1] + offset;
                     DisplayItemText DLText = new DisplayItemText(m_Text.GetString(), basePoint, PtApp.ActiveDocument.GetFontManager().GetFont(m_Text.FontID));
                     DLList.AddItem(DLText);

                     rec.MoveTo(basePoint);

                     DisplayItemBuilder.GenDisplayItemLines(DLList, rec);
                 }
             }
        }