Ejemplo n.º 1
0
        void add(HUDStandardItem element, LayoutOptions options)
        {
            if (element.IsVisible == false)
            {
                element.IsVisible = true;
            }

            IBoxModelElement elemBoxModel = element as IBoxModelElement;

            // for 2D view (but doesn't matter if we are doing a layout anyway!)
            Frame3f viewFrame = Cockpit.GetViewFrame2D();

            // with 3D view we should use this...
            //Frame3f viewFrame = Frame3f.Identity;

            element.SetObjectFrame(Frame3f.Identity);
            HUDUtil.PlaceInViewPlane(element, viewFrame);
            Cockpit.AddUIElement(element);

            Func <Vector2f> pinSourceF = options.PinSourcePoint2D;

            if (pinSourceF == null)
            {
                pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center);
            }

            Func <Vector2f> pinTargetF = options.PinTargetPoint2D;

            if (pinTargetF == null)
            {
                pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center);
            }

            Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift);

            // if we want to shift result in its layout frame, do that via a post-transform
            if (options.FrameAxesShift != Vector3f.Zero)
            {
                Solver.AddPostTransform(element, (e) => {
                    Frame3f f = (e as IElementFrame).GetObjectFrame();
                    f.Translate(options.FrameAxesShift.x * f.X + options.FrameAxesShift.y * f.Y + options.FrameAxesShift.z * f.Z);
                    (e as IElementFrame).SetObjectFrame(f);
                });
            }


            // auto-show
            if ((options.Flags & LayoutFlags.AnimatedShow) != 0)
            {
                HUDUtil.AnimatedShow(element);
            }
        }
Ejemplo n.º 2
0
        void add(HUDStandardItem element, LayoutOptions options)
        {
            if (element.IsVisible == false)
            {
                element.IsVisible = true;
            }

            IBoxModelElement elemBoxModel = element as IBoxModelElement;

            // for 2D view (but doesn't matter if we are doing a layout anyway!)
            Frame3f viewFrame = Cockpit.GetViewFrame2D();

            // with 3D view we should use this...
            //Frame3f viewFrame = Frame3f.Identity;

            element.SetObjectFrame(Frame3f.Identity);
            HUDUtil.PlaceInViewPlane(element, viewFrame);
            Cockpit.AddUIElement(element);

            Func <Vector2f> pinSourceF = options.PinSourcePoint2D;

            if (pinSourceF == null)
            {
                pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center);
            }

            Func <Vector2f> pinTargetF = options.PinTargetPoint2D;

            if (pinTargetF == null)
            {
                pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center);
            }

            Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift);

            // auto-show
            if ((options.Flags & LayoutFlags.AnimatedShow) != 0)
            {
                HUDUtil.AnimatedShow(element);
            }
        }