public override void OnMouseUp(Mouse3DEventArgs mouseEvent3D)
        {
            if (hadClickOnControl)
            {
                if (getWidth() != scaleController.InitialState.Width ||
                    getDepth() != scaleController.InitialState.Depth)
                {
                    scaleController.EditComplete();
                    // make a new controller so we will have new undo data
                    scaleController = new ScaleController(Object3DControlContext, getWidth, setWidth, getDepth, setDepth, getHeight, setHeight);
                }
                Object3DControlContext.Scene.ShowSelectionShadow = true;
            }

            base.OnMouseUp(mouseEvent3D);
        }
Ejemplo n.º 2
0
        public override void OnMouseUp(Mouse3DEventArgs mouseEvent3D)
        {
            if (MouseDownOnControl)
            {
                scaleController.EditComplete();
                scaleController = new ScaleController(Object3DControlContext, getWidth, setWidth, getDepth, setDepth, getHeight, setHeight, getDiameters, setDiameters);

                Object3DControlContext.Scene.ShowSelectionShadow = true;
            }

            base.OnMouseUp(mouseEvent3D);
        }
Ejemplo n.º 3
0
        public override void OnMouseUp(Mouse3DEventArgs mouseEvent3D)
        {
            if (hadClickOnControl)
            {
                if (getDiameters[diameterIndex]() != scaleController.InitialState.Diameters[diameterIndex])
                {
                    scaleController.EditComplete();
                    scaleController = new ScaleController(Object3DControlContext, null, null, null, null, getHeight, setHeight, getDiameters, setDiameters);
                }
                Object3DControlContext.Scene.ShowSelectionShadow = true;
            }

            base.OnMouseUp(mouseEvent3D);
        }
Ejemplo n.º 4
0
        public ScaleHeightControl(IObject3DControlContext context,
                                  Func <double> getWidth,
                                  Action <double> setWidth,
                                  Func <double> getDepth,
                                  Action <double> setDepth,
                                  Func <double> getHeight,
                                  Action <double> setHeight,
                                  List <Func <double> > getDiameters   = null,
                                  List <Action <double> > setDiameters = null)
            : base(context)
        {
            theme = MatterControl.AppContext.Theme;

            this.getWidth     = getWidth;
            this.setWidth     = setWidth;
            this.getDepth     = getDepth;
            this.setDepth     = setDepth;
            this.getHeight    = getHeight;
            this.setHeight    = setHeight;
            this.getDiameters = getDiameters;
            this.setDiameters = setDiameters;

            scaleController = new ScaleController(Object3DControlContext, getWidth, setWidth, getDepth, setDepth, getHeight, setHeight, getDiameters, setDiameters);

            heightValueDisplayInfo = new InlineEditControl()
            {
                ForceHide = () =>
                {
                    // if the selection changes
                    if (RootSelection != activeSelectedItem)
                    {
                        return(true);
                    }

                    // if another control gets a hover
                    if (Object3DControlContext.HoveredObject3DControl != this &&
                        Object3DControlContext.HoveredObject3DControl != null)
                    {
                        return(true);
                    }

                    // if we clicked on the control
                    if (hadClickOnControl)
                    {
                        return(false);
                    }

                    return(false);
                },
                GetDisplayString = (value) => "{0:0.0}".FormatWith(value)
            };

            heightValueDisplayInfo.VisibleChanged += (s, e) =>
            {
                if (!heightValueDisplayInfo.Visible)
                {
                    hadClickOnControl = false;
                }
            };

            heightValueDisplayInfo.EditComplete += async(s, e) =>
            {
                if (heightValueDisplayInfo.Value == scaleController.FinalState.Height)
                {
                    return;
                }

                var selectedItem = activeSelectedItem;

                var bottom = GetBottomPosition(selectedItem);
                scaleController.ScaleHeight(heightValueDisplayInfo.Value);
                await selectedItem.Rebuild();

                var postScaleBottom = GetBottomPosition(selectedItem);
                selectedItem.Translate(bottom - postScaleBottom);

                scaleController.EditComplete();
                scaleController = new ScaleController(Object3DControlContext, getWidth, setWidth, getDepth, setDepth, getHeight, setHeight, getDiameters, setDiameters);
            };

            Object3DControlContext.GuiSurface.AddChild(heightValueDisplayInfo);

            DrawOnTop = true;

            topScaleMesh = PlatonicSolids.CreateCube(arrowSize, arrowSize, arrowSize);

            CollisionVolume = topScaleMesh.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }
Ejemplo n.º 5
0
        public ScaleDiameterControl(IObject3DControlContext context,
                                    Func <double> getHeight,
                                    Action <double> setHeight,
                                    List <Func <double> > getDiameters,
                                    List <Action <double> > setDiameters,
                                    int diameterIndex,
                                    ObjectSpace.Placement placement = ObjectSpace.Placement.Bottom,
                                    Func <bool> controlVisible      = null,
                                    double angleOffset = 0)
            : base(context)
        {
            this.getHeight      = getHeight;
            this.setHeight      = setHeight;
            this.getDiameters   = getDiameters;
            this.setDiameters   = setDiameters;
            this.controlVisible = controlVisible;
            this.placement      = placement;
            this.diameterIndex  = diameterIndex;
            this.angleOffset    = angleOffset;
            theme = MatterControl.AppContext.Theme;

            scaleController = new ScaleController(Object3DControlContext, null, null, null, null, getHeight, setHeight, getDiameters, setDiameters);

            diameterValueDisplayInfo = new InlineEditControl()
            {
                ForceHide        = ForceHideScale,
                GetDisplayString = (value) => "{0:0.0}".FormatWith(value),
            };

            diameterValueDisplayInfo.EditComplete += async(s, e) =>
            {
                var newDiameter = diameterValueDisplayInfo.Value != 0 ? diameterValueDisplayInfo.Value : getDiameters[diameterIndex]();

                if (newDiameter == scaleController.FinalState.Diameters[diameterIndex])
                {
                    return;
                }

                Vector3 lockedEdge = ObjectSpace.GetCenterPosition(ActiveSelectedItem, placement);
                scaleController.ScaleDiameter(newDiameter, diameterIndex);
                await ActiveSelectedItem.Rebuild();

                // and keep the locked edge in place
                Vector3 newLockedEdge = ObjectSpace.GetCenterPosition(ActiveSelectedItem, placement);
                ActiveSelectedItem.Translate(lockedEdge - newLockedEdge);

                scaleController.EditComplete();
                scaleController = new ScaleController(Object3DControlContext, null, null, null, null, getHeight, setHeight, getDiameters, setDiameters);
            };

            diameterValueDisplayInfo.VisibleChanged += (s, e) =>
            {
                if (!diameterValueDisplayInfo.Visible)
                {
                    hadClickOnControl = false;
                }
            };

            Object3DControlContext.GuiSurface.AddChild(diameterValueDisplayInfo);

            DrawOnTop = true;

            grabControlMesh = SphereObject3D.CreateSphere(grabControlSize, 15, 10);

            CollisionVolume = grabControlMesh.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }