Exemplo n.º 1
0
        public ScaleController(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)
        {
            this.context = context;

            this.getWidth = getWidth;
            this.setWidth = setWidth;

            this.getDepth = getDepth;
            this.setDepth = setDepth;

            this.getHeight = getHeight;
            this.setHeight = setHeight;

            this.getDiameters = getDiameters;
            this.setDiameters = setDiameters;

            if (getDiameters != null)
            {
                for (int i = 0; i < getDiameters.Count; i++)
                {
                    InitialState.Diameters.Add(0);
                }
            }

            SetInitialState(context);
        }
Exemplo n.º 2
0
        public PathControl(IObject3DControlContext context)
        {
            this.context = context;
            theme        = MatterControl.AppContext.Theme;

            world = context.World;
        }
Exemplo n.º 3
0
        private void SetInitialState(IObject3DControlContext context)
        {
            if (getWidth != null)
            {
                InitialState.Width = getWidth();
            }

            if (getDepth != null)
            {
                InitialState.Depth = getDepth.Invoke();
            }

            if (getHeight != null)
            {
                InitialState.Height = getHeight();
            }

            if (getDiameters != null)
            {
                for (int i = 0; i < getDiameters.Count; i++)
                {
                    InitialState.Diameters[i] = getDiameters[i]();
                }
            }

            if (selectedItem != null)
            {
                InitialState.Matrix = selectedItem.Matrix;
            }

            FinalState = new ScaleStates(InitialState);
        }
Exemplo n.º 4
0
        public ScaleMatrixEdgeControl(IObject3DControlContext context, int edgeIndex)
            : base(context)
        {
            theme = MatterControl.AppContext.Theme;

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

            xValueDisplayInfo.EditComplete += EditComplete;

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

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

            yValueDisplayInfo.EditComplete += EditComplete;

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

            if (edgeIndex % 2 == 1)
            {
                Object3DControlContext.GuiSurface.AddChild(xValueDisplayInfo);
            }
            else
            {
                Object3DControlContext.GuiSurface.AddChild(yValueDisplayInfo);
            }

            this.edgeIndex = edgeIndex;

            DrawOnTop = true;

            minXminYMesh = PlatonicSolids.CreateCube(selectCubeSize, selectCubeSize, selectCubeSize);

            CollisionVolume = minXminYMesh.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }
 public TracedPositionObject3DControl(IObject3DControlContext context, IObject3D owner, Func <Vector3> getPosition, Action <Vector3> setPosition)
 {
     this.theme       = ApplicationController.Instance.Theme;
     this.context     = context;
     this.getPosition = getPosition;
     this.setPosition = setPosition;
     this.shape       = PlatonicSolids.CreateCube();
     this.shape       = SphereObject3D.CreateSphere(1, 15, 10);
     collisionVolume  = shape.CreateBVHData();
     this.owner       = owner;
 }
Exemplo n.º 6
0
        public RotateCornerControl(IObject3DControlContext context, int axisIndex)
            : base(context)
        {
            theme = MatterControl.AppContext.Theme;

            angleTextControl = new InlineEditControl()
            {
                ForceHide        = ForceHideAngle,
                GetDisplayString = (value) => "{0:0.0#}°".FormatWith(value),
                Visible          = false
            };

            angleTextControl.VisibleChanged += (s, e) =>
            {
                mouseDownInfo = null;
                Invalidate();
            };

            Object3DControlContext.GuiSurface.AddChild(angleTextControl);

            angleTextControl.EditComplete += (s, e) =>
            {
                var selectedItem = RootSelection;

                if (selectedItem != null &&
                    mouseDownInfo != null)
                {
                    if (mouseMoveInfo != null)
                    {
                        SnappedRotationAngle = MathHelper.DegreesToRadians(angleTextControl.Value);

                        mouseMoveInfo.AngleOfHit = mouseDownInfo.AngleOfHit + SnappedRotationAngle;

                        RotatingCW = DeltaAngle(0, SnappedRotationAngle) < 0;

                        // undo the last rotation
                        RotateAroundAxis(selectedItem, -lastSnappedRotation);

                        // rotate it
                        RotateAroundAxis(selectedItem, SnappedRotationAngle);

                        Invalidate();

                        lastSnappedRotation = SnappedRotationAngle;
                    }

                    Object3DControlContext.Scene.AddTransformSnapshot(mouseDownInfo.SelectedObjectTransform);
                }
            };

            this.RotationAxis = axisIndex;

            DrawOnTop = true;

            rotationHandle = PlatonicSolids.CreateCube(selectCubeSize);

            RectangleDouble bounds = Arrows.GetBounds();

            if (rotationImageWhite == null)
            {
                rotationImageWhite = new ImageBuffer(64, 64, 32, new BlenderBGRA());
            }

            var arrows2 = new VertexSourceApplyTransform(Arrows, Affine.NewTranslation(-bounds.Center)
                                                         * Affine.NewScaling(rotationImageWhite.Width / bounds.Width, rotationImageWhite.Height / bounds.Height)
                                                         * Affine.NewTranslation(rotationImageWhite.Width / 2, rotationImageWhite.Height / 2));

            Graphics2D imageGraphics = rotationImageWhite.NewGraphics2D();

            imageGraphics.Clear(new Color(Color.White, 0));
            imageGraphics.Render(new FlattenCurves(arrows2), Color.White);

            var clearImage = new ImageBuffer(2, 2, 32, new BlenderBGRA());

            for (int i = 0; i < rotationHandle.Faces.Count; i++)
            {
                if (i == 0 || i == 1)
                {
                    rotationHandle.PlaceTextureOnFace(i, rotationImageWhite);
                }
                else
                {
                    rotationHandle.PlaceTextureOnFace(i, clearImage);
                }
            }

            CollisionVolume = rotationHandle.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }
Exemplo n.º 7
0
        public MoveInZControl(IObject3DControlContext context)
            : base(context)
        {
            theme = AppContext.Theme;
            Name  = "MoveInZControl";
            zHeightDisplayInfo = new InlineEditControl()
            {
                ForceHide = () =>
                {
                    var selectedItem = RootSelection;
                    // if the selection changes
                    if (selectedItem != 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)
            };

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

            zHeightDisplayInfo.EditComplete += (s, e) =>
            {
                var selectedItem = RootSelection;

                Matrix4X4 startingTransform = selectedItem.Matrix;

                var newZPosition = zHeightDisplayInfo.Value;

                if (Object3DControlContext.SnapGridDistance > 0)
                {
                    // snap this position to the grid
                    double snapGridDistance = Object3DControlContext.SnapGridDistance;

                    // snap this position to the grid
                    newZPosition = ((int)((newZPosition / snapGridDistance) + .5)) * snapGridDistance;
                }

                AxisAlignedBoundingBox originalSelectedBounds = selectedItem.GetAxisAlignedBoundingBox();
                var moveAmount = newZPosition - originalSelectedBounds.MinXYZ.Z;

                if (moveAmount != 0)
                {
                    selectedItem.Matrix *= Matrix4X4.CreateTranslation(0, 0, moveAmount);
                    Invalidate();
                }

                context.Scene.AddTransformSnapshot(startingTransform);
            };

            Object3DControlContext.GuiSurface.AddChild(zHeightDisplayInfo);

            DrawOnTop = true;

            using (Stream arrowStream = AggContext.StaticData.OpenStream(Path.Combine("Stls", "up_pointer.stl")))
            {
                upArrowMesh = StlProcessing.Load(arrowStream, CancellationToken.None);
            }

            CollisionVolume = upArrowMesh.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }
        public ScaleMatrixTopControl(IObject3DControlContext context)
            : base(context)
        {
            theme = AppContext.Theme;

            zValueDisplayInfo = 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)
            };

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

            zValueDisplayInfo.EditComplete += (s, e) =>
            {
                var selectedItem = activeSelectedItem;

                Matrix4X4 startingTransform      = selectedItem.Matrix;
                var       originalSelectedBounds = selectedItem.GetAxisAlignedBoundingBox();
                Vector3   topPosition            = GetTopPosition(selectedItem);
                var       lockedBottom           = new Vector3(topPosition.X, topPosition.Y, originalSelectedBounds.MinXYZ.Z);

                Vector3 newSize = Vector3.Zero;
                newSize.Z = zValueDisplayInfo.Value;
                Vector3 scaleAmount = ScaleMatrixCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys);

                var scale = Matrix4X4.CreateScale(scaleAmount);

                selectedItem.Matrix = selectedItem.ApplyAtBoundsCenter(scale);

                // and keep the locked edge in place
                AxisAlignedBoundingBox scaledSelectedBounds = selectedItem.GetAxisAlignedBoundingBox();
                var newLockedBottom = new Vector3(topPosition.X, topPosition.Y, scaledSelectedBounds.MinXYZ.Z);

                selectedItem.Matrix *= Matrix4X4.CreateTranslation(lockedBottom - newLockedBottom);

                Invalidate();

                Object3DControlContext.Scene.AddTransformSnapshot(startingTransform);
            };

            Object3DControlContext.GuiSurface.AddChild(zValueDisplayInfo);

            DrawOnTop = true;

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

            CollisionVolume = topScaleMesh.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }
Exemplo n.º 9
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;
        }
Exemplo n.º 10
0
 public ScaleMatrixTopControl(IObject3DControlContext context)
     : base(context)
 {
 }
        public ScaleHeightControl(IObject3DControlContext context)
            : base(context)
        {
            theme = AppContext.Theme;

            zValueDisplayInfo = 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)
            };

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

            zValueDisplayInfo.EditComplete += (s, e) =>
            {
                var selectedItem = activeSelectedItem;

                if (selectedItem is IObjectWithHeight heightObject)
                {
                    var     startingHeight         = heightObject.Height;
                    var     originalSelectedBounds = selectedItem.GetAxisAlignedBoundingBox();
                    Vector3 topPosition            = GetTopPosition(selectedItem);
                    var     lockedBottom           = GetBottomPosition(selectedItem);

                    Vector3 newSize = Vector3.Zero;
                    newSize.Z = zValueDisplayInfo.Value;
                    Vector3 scaleAmount = ScaleCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys);

                    heightObject.Height *= scaleAmount.Z;

                    var scale = Matrix4X4.CreateScale(scaleAmount);

                    Invalidate();

                    SetHeightUndo(startingHeight);
                }
            };

            Object3DControlContext.GuiSurface.AddChild(zValueDisplayInfo);

            DrawOnTop = true;

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

            CollisionVolume = topScaleMesh.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }
Exemplo n.º 12
0
 public Object3DControl(IObject3DControlContext object3DControlContext)
 {
     this.Object3DControlContext = object3DControlContext;
 }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
0
 public ScaleHeightControl(IObject3DControlContext context)
     : base(context)
 {
 }
Exemplo n.º 15
0
 public SnappingIndicators(IObject3DControlContext context)
     : base(context)
 {
     this.DrawOnTop = true;
     Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
 }
        public ScaleWidthDepthCornerControl(IObject3DControlContext object3DControlContext,
                                            Func <double> getWidth,
                                            Action <double> setWidth,
                                            Func <double> getDepth,
                                            Action <double> setDepth,
                                            Func <double> getHeight,
                                            Action <double> setHeight,
                                            int quadrant)
            : base(object3DControlContext)
        {
            theme           = MatterControl.AppContext.Theme;
            this.getWidth   = getWidth;
            this.setWidth   = setWidth;
            this.getDepth   = getDepth;
            this.setDepth   = setDepth;
            this.getHeight  = getHeight;
            this.setHeight  = setHeight;
            scaleController = new ScaleController(object3DControlContext, getWidth, setWidth, getDepth, setDepth, getHeight, setHeight);

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

            xValueDisplayInfo.EditComplete += EditComplete;

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

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

            yValueDisplayInfo.EditComplete += EditComplete;

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

            Object3DControlContext.GuiSurface.AddChild(xValueDisplayInfo);
            Object3DControlContext.GuiSurface.AddChild(yValueDisplayInfo);

            this.quadrantIndex = quadrant;

            DrawOnTop = true;

            minXminYMesh = PlatonicSolids.CreateCube(selectCubeSize, selectCubeSize, selectCubeSize);

            CollisionVolume = minXminYMesh.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }
Exemplo n.º 17
0
        public ScaleHeightControl(IObject3DControlContext context)
            : base(context)
        {
            theme = AppContext.Theme;

            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) =>
            {
                var selectedItem = activeSelectedItem;

                if (selectedItem is IObjectWithHeight heightObject &&
                    heightValueDisplayInfo.Value != heightObject.Height)
                {
                    await selectedItem.Rebuild();

                    Invalidate();

                    SetHeightUndo(heightValueDisplayInfo.Value, heightObject.Height);
                }
            };

            Object3DControlContext.GuiSurface.AddChild(heightValueDisplayInfo);

            DrawOnTop = true;

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

            CollisionVolume = topScaleMesh.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }
Exemplo n.º 18
0
 public SelectionShadow(IObject3DControlContext context)
     : base(context)
 {
     theme       = AppContext.Theme;
     shadowColor = theme.ResolveColor(theme.BackgroundColor, Color.Black.WithAlpha(80)).WithAlpha(110);
 }
        public ScaleWidthDepthEdgeControl(IObject3DControlContext context,
                                          Func <double> getWidth,
                                          Action <double> setWidth,
                                          Func <double> getDepth,
                                          Action <double> setDepth,
                                          Func <double> getHeight,
                                          Action <double> setHeight,
                                          int edgeIndex)
            : base(context)
        {
            theme = MatterControl.AppContext.Theme;

            switch (edgeIndex)
            {
            case 0:
                Name = "ScaleDepthBack";
                break;

            case 1:
                Name = "ScaleWidthLeft";
                break;

            case 2:
                Name = "ScaleDepthFront";
                break;

            case 3:
                Name = "ScaleWidthRight";
                break;
            }

            this.getWidth   = getWidth;
            this.setWidth   = setWidth;
            this.getDepth   = getDepth;
            this.setDepth   = setDepth;
            this.getHeight  = getHeight;
            this.setHeight  = setHeight;
            scaleController = new ScaleController(Object3DControlContext, getWidth, setWidth, getDepth, setDepth, getHeight, setHeight);

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

            xValueDisplayInfo.EditComplete += EditComplete;

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

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

            yValueDisplayInfo.EditComplete += EditComplete;

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

            if (edgeIndex % 2 == 1)
            {
                Object3DControlContext.GuiSurface.AddChild(xValueDisplayInfo);
            }
            else
            {
                Object3DControlContext.GuiSurface.AddChild(yValueDisplayInfo);
            }

            this.edgeIndex = edgeIndex;

            DrawOnTop = true;

            minXminYMesh = PlatonicSolids.CreateCube(selectCubeSize, selectCubeSize, selectCubeSize);

            CollisionVolume = minXminYMesh.CreateBVHData();

            Object3DControlContext.GuiSurface.BeforeDraw += Object3DControl_BeforeDraw;
        }