Exemplo n.º 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();
        }
Exemplo n.º 2
0
        public override void GetDisplayList(DisplayItemList DLList
            , Matrix44 trans)
        {
            Debug.Assert(DLList != null && trans != null);
            if (null == DLList || null == trans) return;

            GePoint Base = new GePoint(0, 0, 0);
            GePoint End = new GePoint(m_Width, 0, 0);
            GePoint Top = new GePoint(m_Width, m_Height / 2, 0);
            GePoint Bottom = new GePoint(m_Width, -m_Height / 2, 0);
            Base.Transform(trans);
            End.Transform(trans);
            Top.Transform(trans);
            Bottom.Transform(trans);

            FRList<GePoint> PointList = new FRList<GePoint>();
            PointList.Add(Base);
            PointList.Add(Top);
            PointList.Add(Bottom);
            PointList.Add(Base);

            DisplayItemBuilder.GenDisplayItemLines(DLList, PointList);
            DisplayItemBuilder.GenDisplayItemPoint(DLList, Base);
            DisplayItemBuilder.GenDisplayItemPoint(DLList, End);
        }
Exemplo n.º 3
0
        public GraphicDeviceProxy(GraphicContext GpCtx)
        {
            m_GraphicContext = GpCtx;
            m_Device = GpCtx.GetGraphicDevice();

            m_WorldToDevice = GpCtx.WorldToDevice;
        }
Exemplo n.º 4
0
        protected override bool OnQualify(SelectContext selectCtx, Matrix44 parentTrans)
        {
            foreach (DisplayItem item in m_ItemList)
                item.Qualify(selectCtx, GetChildrenTransformation(parentTrans));

            return false;
        }
        public ViewTransformManipulator(Matrix44 DeviceToWorld)
        {
            Debug.Assert(DeviceToWorld != null);

            m_DeviceToWorld = DeviceToWorld;

            m_LastPoint = GePoint.kOrigin;
            m_CursorShape = "Translation.cur";
        }
Exemplo n.º 6
0
        public void Draw(GraphicContext gpCtx, Matrix44 parentTrans)
        {
            ApplyAttributes(gpCtx.GetGraphicDevice());

            if (gpCtx != null)
                OnDraw(gpCtx, parentTrans);

            UnApplyAttributes(gpCtx.GetGraphicDevice());
        }
Exemplo n.º 7
0
        // DP: Template Method
        public void Qualify(SelectContext selectCtx, Matrix44 parentTrans)
        {
            //if (null == selectCtx || selectCtx.IsHitted) return;
            if (null == selectCtx) return;

            if(OnQualify(selectCtx, parentTrans))
            {

            }
        }
Exemplo n.º 8
0
        public void GetAllScalingTest()
        {
            Matrix44 target = new Matrix44();
            target[3, 3] = 10;

            double expected = 0.1;
            double actual = target.GetAllScaling();

            Assert.AreEqual(expected, actual, "FR.Math.Matrix44.GetAllScaling did not return the expected value.");
        }
Exemplo n.º 9
0
        // The old point can't be null, the trans can be null.
        public static GePoint GetTransformedPoint(GePoint oldPoint, Matrix44 trans)
        {
            Debug.Assert(oldPoint != null);
            GePoint newPoint = null;
            if (oldPoint != null && trans != null)
                newPoint = trans * oldPoint;
            else // either of them is null.
                newPoint = oldPoint;

            return newPoint;
        }
Exemplo n.º 10
0
        public void EqualsTest()
        {
            Matrix44 target = new Matrix44();

            object obj = new Matrix44();

            bool expected = true;
            bool actual = target.Equals(obj);

            Assert.AreEqual(expected, actual, "FR.Math.Matrix44.Equals did not return the expected value.");
        }
Exemplo n.º 11
0
        protected override void OnDraw(GraphicContext gpCtx, Matrix44 parentTrans)
        {
            if (gpCtx != null)
            {
                GePoint worldPosition = MathUtil.GetTransformedPoint(m_Position, parentTrans);

                GraphicDeviceProxy Device =
                    gpCtx.CreateGraphicDeviceProxy();
                Device.DrawText(m_String, worldPosition, m_Font);
            }
        }
Exemplo n.º 12
0
        protected override void OnDraw(GraphicContext gpCtx, Matrix44 parentTrans)
        {
            if (gpCtx != null)
            {
                GePoint worldCenterPoint = MathUtil.GetTransformedPoint(m_CenterPoint, parentTrans);

                GraphicDeviceProxy Device =
                    gpCtx.CreateGraphicDeviceProxy();
                Device.DrawCircle(worldCenterPoint, Convert.ToSingle(m_dRadius));
            }
        }
Exemplo n.º 13
0
        // The old oldLineSeg can't be null, the trans can be null.
        public static GeLineSeg GetTransformedLineSeg(GeLineSeg oldLineSeg, Matrix44 trans)
        {
            Debug.Assert(oldLineSeg != null);
            GeLineSeg newLineSeg = null;
            if (oldLineSeg != null && trans != null)
            {
                newLineSeg = new GeLineSeg(
                    trans * oldLineSeg.StartPoint,
                    trans * oldLineSeg.EndPoint);
            }
            else // either of them is null.
                newLineSeg = oldLineSeg;

            return newLineSeg;
        }
Exemplo n.º 14
0
        protected override bool OnQualify(SelectContext selectCtx, Matrix44 parentTrans)
        {
            if (selectCtx == null) return false;

            GePoint worldPoint = MathUtil.GetTransformedPoint(m_Point, parentTrans);

            double dDiff = worldPoint.DistanceTo(selectCtx.WorldPoint);

            if (dDiff < selectCtx.SelectTolerance)
            {
                selectCtx.AddItem(dDiff, this);
                return true;
            }

            return false;
        }
Exemplo n.º 15
0
        // The old oldPoints can't be null, the trans can be null.
        public static FRList<GePoint> GetTransformedPoints(FRList<GePoint> oldPoints, Matrix44 trans)
        {
            Debug.Assert(oldPoints != null);
            FRList<GePoint> newPoints = null;
            if (oldPoints != null && trans != null)
            {
                newPoints = new FRList<GePoint>();
                for (int i = 0; i < oldPoints.Count; i++)
                {
                    newPoints.Add(trans * oldPoints[i]);
                }
            }
            else // either of them is null.
                newPoints = oldPoints;

            return newPoints;
        }
Exemplo n.º 16
0
        private Matrix44 GetChildrenTransformation(Matrix44 parentTrans)
        {
            Matrix44 childTrans = null;
            if (parentTrans != null && m_Transformation != null)
            {
                childTrans = m_Transformation * parentTrans;
            }
            else if (parentTrans != null) // m_Transformation == null
            {
                childTrans = parentTrans;
            }
            else // trans == null
            {
                childTrans = m_Transformation;
            }

            return childTrans;
        }
Exemplo n.º 17
0
        public override void GetDisplayList(DisplayItemList DLList
            , Matrix44 trans)
        {
            Debug.Assert(DLList != null && trans != null);
            if (null == DLList || null == trans) return;

            GePoint Base = new GePoint(0, 0, 0);
            GePoint End = new GePoint(m_Width, 0, 0);
            GePoint Top = new GePoint(m_Width, m_Height / 2, 0);
            GePoint Bottom = new GePoint(m_Width, -m_Height / 2, 0);
            Base.Transform(trans);
            End.Transform(trans);
            Top.Transform(trans);
            Bottom.Transform(trans);

            FRList<GePoint> PointList = new FRList<GePoint>();
            PointList.Add(Base);
            PointList.Add(Top);
            PointList.Add(Bottom);
            PointList.Add(Base);

            FRList<GePoint> meshPoints = new FRList<GePoint>();
            meshPoints.Add(Base);
            meshPoints.Add(End);
            meshPoints.Add(Top);
            meshPoints.Add(Bottom);

            // Use two triangles
            FRList<int> connectivity = new FRList<int>();
            connectivity.Add(0);
            connectivity.Add(1);
            connectivity.Add(2);

            connectivity.Add(0);
            connectivity.Add(1);
            connectivity.Add(3);

            DisplayItemBuilder.GenDisplayItemLines(DLList, PointList);
            DisplayItemBuilder.GenDisplayItemMesh(DLList
                , connectivity, meshPoints, null, null);
            DisplayItemBuilder.GenDisplayItemPoint(DLList, Base);
            DisplayItemBuilder.GenDisplayItemPoint(DLList, End);
        }
Exemplo n.º 18
0
        protected override bool OnQualify(SelectContext selectCtx, Matrix44 parentTrans)
        {
            if (selectCtx == null) return false;

            GePoint worldCenterPoint = MathUtil.GetTransformedPoint(m_CenterPoint, parentTrans);

            double dist = worldCenterPoint.DistanceTo(selectCtx.WorldPoint);

            // Get the plus distance
            double dDiff = dist - m_dRadius;
            if (dDiff < 0) dDiff = -dDiff;

            if (dDiff < selectCtx.SelectTolerance)
            {
                selectCtx.AddItem(dDiff, this);
                return true;
            }

            return false;
        }
Exemplo n.º 19
0
        protected override bool OnQualify(SelectContext selectCtx, Matrix44 parentTrans)
        {
            if (selectCtx == null) return false;

            GeRectangle Rec = Range;

            GePoint worldPosition = MathUtil.GetTransformedPoint(m_Position, parentTrans);

            Rec.MoveTo(worldPosition);

            if (selectCtx.WorldPoint.X > (Rec.MinPoint.X - selectCtx.SelectTolerance)
                && selectCtx.WorldPoint.X < (Rec.MaxPoint.X + selectCtx.SelectTolerance)
                && selectCtx.WorldPoint.Y > (Rec.MinPoint.Y - selectCtx.SelectTolerance)
                && selectCtx.WorldPoint.Y < (Rec.MaxPoint.Y + selectCtx.SelectTolerance))
            {
                selectCtx.AddItem(0, this);
                return true;
            }

            return false;
        }
Exemplo n.º 20
0
        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);
                 }
             }
        }
Exemplo n.º 21
0
 public DisplayItemList()
 {
     m_ItemList = new FRList<DisplayItem>();
     m_Transformation = null;
 }
Exemplo n.º 22
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.");
        }
Exemplo n.º 23
0
 protected abstract bool OnQualify(SelectContext selectCtx, Matrix44 parentTrans);
Exemplo n.º 24
0
        public void InverseTest()
        {
            Matrix44 expected = new Matrix44();

            Matrix44 actual = expected.Inverse;

            Assert.AreEqual(expected, actual, "FR.Math.Matrix44.Inverse was not set correctly.");
        }
Exemplo n.º 25
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.");
        }
Exemplo n.º 26
0
 public void LeftMultiply(Matrix44 rhs)
 {
     if (null == rhs) return;
     Matrix44 newMatrix = rhs * this;
     m_Proxy = newMatrix._Proxy;
 }
Exemplo n.º 27
0
 protected override void OnDraw(GraphicContext gpCtx, Matrix44 parentTrans)
 {
     for (int i = 0; i < m_ItemList.Count; i++)
         m_ItemList[i].Draw(gpCtx, GetChildrenTransformation(parentTrans));
 }
Exemplo n.º 28
0
 protected abstract void OnDraw(GraphicContext gpCtx, Matrix44 parentTrans);
Exemplo n.º 29
0
        public GePoint Transform(Matrix44 trans)
        {
            Debug.Assert(trans != null);
            if (null == trans) return this;

            _Proxy.Transform(trans._Proxy);

            return this;
        }
Exemplo n.º 30
0
 public abstract void GetDisplayList(DisplayItemList DLList, Matrix44 trans);