Пример #1
0
        private void AddMirrorControls(FlowLayoutWidget buttonPanel)
        {
            List <GuiWidget> mirrorControls = new List <GuiWidget>();

            double oldFixedWidth = view3DWidget.textImageButtonFactory.FixedWidth;

            view3DWidget.textImageButtonFactory.FixedWidth = view3DWidget.EditButtonHeight;

            FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonContainer.HAnchor = HAnchor.ParentLeftRight;

            Button mirrorXButton = view3DWidget.textImageButtonFactory.Generate("X", centerText: true);

            buttonContainer.AddChild(mirrorXButton);
            mirrorControls.Add(mirrorXButton);
            mirrorXButton.Click += (object sender, EventArgs mouseEvent) =>
            {
                if (view3DWidget.SelectedMeshGroupIndex != -1)
                {
                    view3DWidget.SelectedMeshGroup.ReverseFaceEdges();
                    view3DWidget.SelectedMeshGroupTransform = PlatingHelper.ApplyAtCenter(view3DWidget.SelectedMeshGroup, view3DWidget.SelectedMeshGroupTransform, Matrix4X4.CreateScale(-1, 1, 1));
                    view3DWidget.PartHasBeenChanged();
                    Invalidate();
                }
            };

            Button mirrorYButton = view3DWidget.textImageButtonFactory.Generate("Y", centerText: true);

            buttonContainer.AddChild(mirrorYButton);
            mirrorControls.Add(mirrorYButton);
            mirrorYButton.Click += (object sender, EventArgs mouseEvent) =>
            {
                if (view3DWidget.SelectedMeshGroupIndex != -1)
                {
                    view3DWidget.SelectedMeshGroup.ReverseFaceEdges();
                    view3DWidget.SelectedMeshGroupTransform = PlatingHelper.ApplyAtCenter(view3DWidget.SelectedMeshGroup, view3DWidget.SelectedMeshGroupTransform, Matrix4X4.CreateScale(1, -1, 1));
                    view3DWidget.PartHasBeenChanged();
                    Invalidate();
                }
            };

            Button mirrorZButton = view3DWidget.textImageButtonFactory.Generate("Z", centerText: true);

            buttonContainer.AddChild(mirrorZButton);
            mirrorControls.Add(mirrorZButton);
            mirrorZButton.Click += (object sender, EventArgs mouseEvent) =>
            {
                if (view3DWidget.SelectedMeshGroupIndex != -1)
                {
                    view3DWidget.SelectedMeshGroup.ReverseFaceEdges();
                    view3DWidget.SelectedMeshGroupTransform = PlatingHelper.ApplyAtCenter(view3DWidget.SelectedMeshGroup, view3DWidget.SelectedMeshGroupTransform, Matrix4X4.CreateScale(1, 1, -1));
                    view3DWidget.PartHasBeenChanged();
                    Invalidate();
                }
            };
            buttonPanel.AddChild(buttonContainer);
            buttonPanel.AddChild(view3DWidget.GenerateHorizontalRule());
            view3DWidget.textImageButtonFactory.FixedWidth = oldFixedWidth;
        }
Пример #2
0
        public override void OnMouseMove(MouseEvent3DArgs mouseEvent3D)
        {
            IntersectInfo info = hitPlane.GetClosestIntersection(mouseEvent3D.MouseRay);

            if (info != null && MeshViewerToDrawWith.SelectedMeshGroupIndex != -1)
            {
                Vector3 delta = new Vector3(0, 0, info.hitPosition.z - zHitHeight);

                // move it back to where it started
                MeshViewerToDrawWith.SelectedMeshGroupTransform *= Matrix4X4.CreateTranslation(new Vector3(-lastMoveDelta));

                if (MeshViewerToDrawWith.SnapGridDistance > 0)
                {
                    // snap this position to the grid
                    double snapGridDistance = MeshViewerToDrawWith.SnapGridDistance;
                    AxisAlignedBoundingBox selectedBounds = MeshViewerToDrawWith.GetBoundsForSelection();

                    // snap the z position
                    double bottom        = selectedBounds.minXYZ.z + delta.z;
                    double snappedBottom = (Math.Round((bottom / snapGridDistance))) * snapGridDistance;
                    delta.z = snappedBottom - selectedBounds.minXYZ.z;
                }

                // and move it from there to where we are now
                MeshViewerToDrawWith.SelectedMeshGroupTransform *= Matrix4X4.CreateTranslation(new Vector3(delta));

                lastMoveDelta = delta;

                view3DWidget.PartHasBeenChanged();
                Invalidate();
            }

            base.OnMouseMove(mouseEvent3D);
        }
Пример #3
0
        private void MirrorOnAxis(int axisIndex)
        {
            view3DWidget.SelectedMeshGroup.ReverseFaceEdges();
            Vector3 mirorAxis = Vector3.One;

            mirorAxis[axisIndex] = -1;
            view3DWidget.SelectedMeshGroupTransform = PlatingHelper.ApplyAtCenter(view3DWidget.SelectedMeshGroup, view3DWidget.SelectedMeshGroupTransform, Matrix4X4.CreateScale(mirorAxis));
            view3DWidget.PartHasBeenChanged();
            Invalidate();
        }
Пример #4
0
 public void Undo()
 {
     view3DWidget.MeshGroups.RemoveAt(newItemIndex);
     view3DWidget.MeshGroupExtraData.RemoveAt(newItemIndex);
     view3DWidget.MeshGroupTransforms.RemoveAt(newItemIndex);
     if (view3DWidget.SelectedMeshGroupIndex >= view3DWidget.MeshGroups.Count)
     {
         view3DWidget.SelectedMeshGroupIndex = view3DWidget.MeshGroups.Count - 1;
     }
     view3DWidget.PartHasBeenChanged();
 }
Пример #5
0
        private void ScaleAxis(double scaleIn, int axis)
        {
            AxisAlignedBoundingBox originalMeshBounds = view3DWidget.SelectedMeshGroup.GetAxisAlignedBoundingBox();

            Vector3 newScale = Vector3.One;

            newScale[axis] = scaleIn;
            Matrix4X4 totalScale = Matrix4X4.CreateScale(newScale);

            view3DWidget.SelectedMeshGroupTransform = PlatingHelper.ApplyAtCenter(view3DWidget.SelectedMeshGroup, view3DWidget.SelectedMeshGroupTransform, totalScale);

            // keep the bottom where it was
            AxisAlignedBoundingBox scaledBounds = view3DWidget.SelectedMeshGroup.GetAxisAlignedBoundingBox(view3DWidget.SelectedMeshGroupTransform);

            PlatingHelper.PlaceMeshAtHeight(view3DWidget.MeshGroups, view3DWidget.MeshGroupTransforms, view3DWidget.SelectedMeshGroupIndex, scaledBounds.minXYZ.z);

            view3DWidget.PartHasBeenChanged();
            Invalidate();
            OnSelectedTransformChanged(this, null);
        }
Пример #6
0
        private void ScaleAxis(double scaleIn, int axis)
        {
            AxisAlignedBoundingBox originalMeshBounds = view3DWidget.SelectedMeshGroup.GetAxisAlignedBoundingBox();

            AxisAlignedBoundingBox scaledBounds = view3DWidget.SelectedMeshGroup.GetAxisAlignedBoundingBox(view3DWidget.SelectedMeshGroupTransform);

            // first we remove any scale we have applied and then scale to the new value
            Vector3 axisRemoveScalings = Vector3.One;

            if (originalMeshBounds.XSize > 0 && scaledBounds.XSize > 0)
            {
                axisRemoveScalings.x = originalMeshBounds.XSize / scaledBounds.XSize;
            }
            if (originalMeshBounds.YSize > 0 && scaledBounds.YSize > 0)
            {
                axisRemoveScalings.y = originalMeshBounds.YSize / scaledBounds.YSize;
            }
            if (originalMeshBounds.ZSize > 0 && scaledBounds.ZSize > 0)
            {
                axisRemoveScalings.z = originalMeshBounds.ZSize / scaledBounds.ZSize;
            }

            Matrix4X4 removeScaleMatrix = Matrix4X4.CreateScale(axisRemoveScalings);

            Vector3 newScale = view3DWidget.MeshGroupExtraData[view3DWidget.SelectedMeshGroupIndex].currentScale;

            newScale[axis] = scaleIn;
            Matrix4X4 totalScale = removeScaleMatrix * Matrix4X4.CreateScale(newScale);

            view3DWidget.SelectedMeshGroupTransform = PlatingHelper.ApplyAtCenter(view3DWidget.SelectedMeshGroup, view3DWidget.SelectedMeshGroupTransform, totalScale);

            // keep the bottom where it was
            PlatingHelper.PlaceMeshAtHeight(view3DWidget.MeshGroups, view3DWidget.MeshGroupTransforms, view3DWidget.SelectedMeshGroupIndex, scaledBounds.minXYZ.z);

            view3DWidget.PartHasBeenChanged();
            Invalidate();
            view3DWidget.MeshGroupExtraData[view3DWidget.SelectedMeshGroupIndex].currentScale[axis] = scaleIn;
            OnSelectedTransformChanged(this, null);
        }