protected override Vector3f layout_item(SceneUIElement e)
        {
            AxisAlignedBox2f box = Container.Bounds2D;

            Vector3f vNewPos3 = Vector3f.Zero;   // 2.5d center coordinate

            IBoxModelElement boxElem = e as IBoxModelElement;

            if (PinConstraints.ContainsKey(e))
            {
                Pin pin = PinConstraints[e];

                Vector2f SourcePos = pin.FromF();
                Vector2f PinToPos  = pin.ToF();
                vNewPos3 = BoxModel.SetObjectPosition(boxElem, SourcePos, PinToPos, pin.fZ);
            }
            else if (boxElem != null)
            {
                vNewPos3 = BoxModel.SetObjectPosition(boxElem, BoxPosition.Center, box.Center, 0);
            }
            else
            {
                // do nothing?
            }

            return(vNewPos3);
        }
Beispiel #2
0
        protected override void layout_item(SceneUIElement e)
        {
            AxisAlignedBox2f box = Container.Bounds2D;

            IBoxModelElement boxElem = e as IBoxModelElement;
            IElementFrame    eFramed = e as IElementFrame;

            if (PinConstraints.ContainsKey(e))
            {
                Pin pin = PinConstraints[e];

                // evaluate pin constraints in 2D box space
                Vector2f SourcePos = pin.FromF();
                Vector2f PinToPos  = pin.ToF();

                // map center of object into box space
                //  note: ignores orientation!
                Frame3f  objF    = eFramed.GetObjectFrame();
                Vector2f center2 = Region.To2DCoords(objF.Origin);

                // construct new 2D position
                Vector2f vOffset = SourcePos - center2;
                Vector2f vNewPos = PinToPos - vOffset;

                // map 2D position back to 3D surface and orient object
                Frame3f frame = Region.From2DCoords(vNewPos, pin.fZ);
                eFramed.SetObjectFrame(frame);
            }
            else if (boxElem != null)
            {
                // position object at center of box region
                Frame3f frame = Region.From2DCoords(Vector2f.Zero, 0);
                eFramed.SetObjectFrame(frame);
            }
            else
            {
                // do nothing?
            }
        }
Beispiel #3
0
        protected override void layout_item(SceneUIElement e)
        {
            AxisAlignedBox2f box = Container.Bounds2D;

            IBoxModelElement boxElem = e as IBoxModelElement;

            if (PinConstraints.ContainsKey(e))
            {
                Pin pin = PinConstraints[e];

                Vector2f SourcePos = pin.FromF();
                Vector2f PinToPos  = pin.ToF();
                BoxModel.SetObjectPosition(boxElem, SourcePos, PinToPos, pin.fZ);
            }
            else if (boxElem != null)
            {
                BoxModel.SetObjectPosition(boxElem, BoxPosition.Center, box.Center, 0);
            }
            else
            {
                // do nothing?
            }
        }
        protected override Vector3f layout_item(SceneUIElement e)
        {
            AxisAlignedBox2f box = Container.Bounds2D;

            IBoxModelElement boxElem = e as IBoxModelElement;
            IElementFrame    eFramed = e as IElementFrame;

            Vector3f vNewPos3 = Vector3f.Zero;   // 2.5d center coordinate

            if (PinConstraints.ContainsKey(e))
            {
                Pin pin = PinConstraints[e];

                // [TODO] We have to xform the center of the object. But if we pin
                //   a corner, we want to enforce the corner position in 3D (eg on curved surf).
                //   Currently we pin the corner in 2D, but then conver that to a 2D-center
                //   and then use that position. So on curved surf, things overlap, etc

                // evaluate pin constraints in 2D box space
                Vector2f SourcePos = pin.FromF();
                Vector2f PinToPos  = pin.ToF();

                // map center of object into box space
                //  note: ignores orientation!
                //Frame3f objF = eFramed.GetObjectFrame();
                //Vector2f center2 = Region.To2DCoords(objF.Origin);
                Vector2f center2 = Vector2f.Zero;

                // construct new 2D position
                Vector2f vOffset = SourcePos - center2;
                Vector2f vNewPos = PinToPos - vOffset;
                vNewPos3 = new Vector3f(vNewPos.x, vNewPos.y, pin.fZ);

                // map 2D position back to 3D surface and orient object
                Frame3f frame = Region.From2DCoords(vNewPos, pin.fZ);
                eFramed.SetObjectFrame(frame);
            }
            else if (boxElem != null)
            {
                Vector2f vNewPos = Vector2f.Zero;
                vNewPos3 = new Vector3f(vNewPos.x, vNewPos.y, 0);

                // position object at center of box region
                Frame3f frame = Region.From2DCoords(vNewPos, 0);
                eFramed.SetObjectFrame(frame);
            }
            else
            {
                // do nothing?
            }

            if (PostTransforms.ContainsKey(e))
            {
                foreach (var xform in PostTransforms[e])
                {
                    xform(e);
                }
            }

            return(vNewPos3);
        }