Put in undo redo buttons
Put in more undo
This commit is contained in:
parent
fa1125fbbf
commit
5197d1f62c
8 changed files with 96 additions and 51 deletions
|
|
@ -43,12 +43,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
public class UpArrow3D : InteractionVolume
|
||||
{
|
||||
private Mesh upArrow;
|
||||
private double zHitHeight;
|
||||
private Vector3 lastMoveDelta;
|
||||
private PlaneShape hitPlane;
|
||||
private View3DWidget view3DWidget;
|
||||
internal HeightValueDisplay heightDisplay;
|
||||
private PlaneShape hitPlane;
|
||||
private Vector3 lastMoveDelta;
|
||||
private Matrix4X4 transformOnMouseDown = Matrix4X4.Identity;
|
||||
private Mesh upArrow;
|
||||
private View3DWidget view3DWidget;
|
||||
private double zHitHeight;
|
||||
|
||||
public UpArrow3D(View3DWidget view3DWidget)
|
||||
: base(null, view3DWidget.meshViewerWidget)
|
||||
|
|
@ -78,6 +79,23 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
public override void DrawGlContent(EventArgs e)
|
||||
{
|
||||
if (MeshViewerToDrawWith.SelectedMeshGroup != null)
|
||||
{
|
||||
if (MouseOver)
|
||||
{
|
||||
RenderMeshToGl.Render(upArrow, RGBA_Bytes.Red, TotalTransform, RenderTypes.Shaded);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderMeshToGl.Render(upArrow, RGBA_Bytes.Black, TotalTransform, RenderTypes.Shaded);
|
||||
}
|
||||
}
|
||||
|
||||
base.DrawGlContent(e);
|
||||
}
|
||||
|
||||
public override void OnMouseDown(MouseEvent3DArgs mouseEvent3D)
|
||||
{
|
||||
zHitHeight = mouseEvent3D.info.hitPosition.z;
|
||||
|
|
@ -87,6 +105,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
IntersectInfo info = hitPlane.GetClosestIntersection(mouseEvent3D.MouseRay);
|
||||
zHitHeight = info.hitPosition.z;
|
||||
transformOnMouseDown = MeshViewerToDrawWith.SelectedMeshGroupTransform;
|
||||
|
||||
base.OnMouseDown(mouseEvent3D);
|
||||
}
|
||||
|
|
@ -126,6 +145,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
base.OnMouseMove(mouseEvent3D);
|
||||
}
|
||||
|
||||
public override void OnMouseUp(MouseEvent3DArgs mouseEvent3D)
|
||||
{
|
||||
view3DWidget.AddUndoForSelectedMeshGroupTransform(transformOnMouseDown);
|
||||
base.OnMouseUp(mouseEvent3D);
|
||||
}
|
||||
|
||||
public override void SetPosition()
|
||||
{
|
||||
heightDisplay.SetPosition();
|
||||
|
|
@ -152,22 +177,5 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
heightDisplay.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawGlContent(EventArgs e)
|
||||
{
|
||||
if (MeshViewerToDrawWith.SelectedMeshGroup != null)
|
||||
{
|
||||
if (MouseOver)
|
||||
{
|
||||
RenderMeshToGl.Render(upArrow, RGBA_Bytes.Red, TotalTransform, RenderTypes.Shaded);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderMeshToGl.Render(upArrow, RGBA_Bytes.Black, TotalTransform, RenderTypes.Shaded);
|
||||
}
|
||||
}
|
||||
|
||||
base.DrawGlContent(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
scaleControls.Add(scaleRatioControl);
|
||||
}
|
||||
|
||||
applyScaleButton = view3DWidget.whiteButtonFactory.Generate("Apply Scale".Localize(), centerText: true);
|
||||
applyScaleButton = view3DWidget.WhiteButtonFactory.Generate("Apply Scale".Localize(), centerText: true);
|
||||
applyScaleButton.Cursor = Cursors.Hand;
|
||||
buttonPanel.AddChild(applyScaleButton);
|
||||
|
||||
|
|
@ -148,6 +148,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
if (view3DWidget.HaveSelection)
|
||||
{
|
||||
Matrix4X4 startingTransform = view3DWidget.SelectedMeshGroupTransform;
|
||||
Vector3 currentScale = view3DWidget.MeshGroupExtraData[view3DWidget.SelectedMeshGroupIndex].currentScale;
|
||||
|
||||
double scale = scaleRatioControl.ActuallNumberEdit.Value;
|
||||
|
|
@ -162,6 +163,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
view3DWidget.MeshGroupExtraData[view3DWidget.SelectedMeshGroupIndex].currentScale.z = currentScale.z;
|
||||
ScaleAxis(scale, 2);
|
||||
}
|
||||
|
||||
view3DWidget.AddUndoForSelectedMeshGroupTransform(startingTransform);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,9 +182,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
if (view3DWidget.HaveSelection)
|
||||
{
|
||||
Matrix4X4 startingTransform = view3DWidget.SelectedMeshGroupTransform;
|
||||
SetNewModelSize(sizeDisplay[axisIndex].GetValue(), axisIndex);
|
||||
sizeDisplay[axisIndex].SetDisplayString("{0:0.00}".FormatWith(view3DWidget.SelectedMeshGroup.GetAxisAlignedBoundingBox().Size[axisIndex]));
|
||||
OnSelectedTransformChanged(null, null);
|
||||
view3DWidget.AddUndoForSelectedMeshGroupTransform(startingTransform);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -390,8 +390,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;
|
||||
AddChild(viewControls3D);
|
||||
|
||||
AddHandlers();
|
||||
|
||||
UiThread.RunOnIdle(AutoSpin);
|
||||
|
||||
if (printItemWrapper == null && windowType == WindowMode.Embeded)
|
||||
|
|
@ -971,16 +969,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
MeshViewerWidget.SetMaterialColor(1, ActiveTheme.Instance.PrimaryAccentColor);
|
||||
}
|
||||
|
||||
private void AddHandlers()
|
||||
{
|
||||
expandViewOptions.CheckedStateChanged += expandViewOptions_CheckedStateChanged;
|
||||
if (expandMaterialOptions != null)
|
||||
{
|
||||
expandMaterialOptions.CheckedStateChanged += expandMaterialOptions_CheckedStateChanged;
|
||||
}
|
||||
expandRotateOptions.CheckedStateChanged += expandRotateOptions_CheckedStateChanged;
|
||||
}
|
||||
|
||||
private void AddMaterialControls(FlowLayoutWidget buttonPanel)
|
||||
{
|
||||
extruderButtons.Clear();
|
||||
|
|
@ -1110,7 +1098,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
buttonPanel.AddChild(rotateButtonContainer);
|
||||
|
||||
Button layFlatButton = whiteButtonFactory.Generate("Align to Bed".Localize(), centerText: true);
|
||||
Button layFlatButton = WhiteButtonFactory.Generate("Align to Bed".Localize(), centerText: true);
|
||||
layFlatButton.Cursor = Cursors.Hand;
|
||||
buttonPanel.AddChild(layFlatButton);
|
||||
|
||||
|
|
@ -1311,12 +1299,48 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
FlowLayoutWidget buttonRightPanel = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
buttonRightPanel.Width = 200;
|
||||
|
||||
// put in undo redo
|
||||
{
|
||||
FlowLayoutWidget undoRedoButtons = new FlowLayoutWidget()
|
||||
{
|
||||
VAnchor = VAnchor.FitToChildren | VAnchor.ParentTop,
|
||||
HAnchor = HAnchor.FitToChildren | HAnchor.ParentCenter,
|
||||
};
|
||||
double oldWidth = WhiteButtonFactory.FixedWidth;
|
||||
WhiteButtonFactory.FixedWidth = WhiteButtonFactory.FixedWidth / 2;
|
||||
Button undoButton = WhiteButtonFactory.Generate("Undo".Localize(), centerText: true);
|
||||
undoButton.Enabled = false;
|
||||
undoButton.Click += (sender, e) =>
|
||||
{
|
||||
undoBuffer.Undo();
|
||||
};
|
||||
undoRedoButtons.AddChild(undoButton);
|
||||
|
||||
Button redoButton = WhiteButtonFactory.Generate("Redo".Localize(), centerText: true);
|
||||
redoButton.Enabled = false;
|
||||
redoButton.Click += (sender, e) =>
|
||||
{
|
||||
undoBuffer.Redo();
|
||||
};
|
||||
undoRedoButtons.AddChild(redoButton);
|
||||
buttonRightPanel.AddChild(undoRedoButtons);
|
||||
|
||||
undoBuffer.Changed += (sender, e) =>
|
||||
{
|
||||
undoButton.Enabled = undoBuffer.UndoCount > 0;
|
||||
redoButton.Enabled = undoBuffer.RedoCount > 0;
|
||||
};
|
||||
WhiteButtonFactory.FixedWidth = oldWidth;
|
||||
}
|
||||
|
||||
{
|
||||
BorderDouble buttonMargin = new BorderDouble(top: 3);
|
||||
|
||||
expandRotateOptions = ExpandMenuOptionFactory.GenerateCheckBoxButton("Rotate".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png");
|
||||
expandRotateOptions.Margin = new BorderDouble(bottom: 2);
|
||||
buttonRightPanel.AddChild(expandRotateOptions);
|
||||
expandRotateOptions.CheckedStateChanged += expandRotateOptions_CheckedStateChanged;
|
||||
|
||||
rotateOptionContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
rotateOptionContainer.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
|
@ -1332,6 +1356,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
expandMaterialOptions = ExpandMenuOptionFactory.GenerateCheckBoxButton("Materials".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png");
|
||||
expandMaterialOptions.Margin = new BorderDouble(bottom: 2);
|
||||
expandMaterialOptions.CheckedStateChanged += expandMaterialOptions_CheckedStateChanged;
|
||||
|
||||
if (numberOfExtruders > 1)
|
||||
{
|
||||
|
|
@ -1350,6 +1375,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
expandViewOptions = ExpandMenuOptionFactory.GenerateCheckBoxButton("Display".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png");
|
||||
expandViewOptions.Margin = new BorderDouble(bottom: 2);
|
||||
buttonRightPanel.AddChild(expandViewOptions);
|
||||
expandViewOptions.CheckedStateChanged += expandViewOptions_CheckedStateChanged;
|
||||
|
||||
viewOptionContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
viewOptionContainer.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue