Remove sidebar, fix ViewControl buttons
This commit is contained in:
parent
aa3a48d90f
commit
bce4137069
5 changed files with 66 additions and 373 deletions
|
|
@ -233,7 +233,6 @@
|
|||
<Compile Include="PartPreviewWindow\View3D\View3DUngroup.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\SideBar\MirrorControls.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\IObject3DEditor.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\SideBar\View3DWidgetSidebar.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\View3DWidget.cs" />
|
||||
<Compile Include="PartPreviewWindow\SelectedObjectPanel.cs" />
|
||||
<Compile Include="PartPreviewWindow\ViewControls3D.cs" />
|
||||
|
|
|
|||
|
|
@ -42,22 +42,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
public SelectedObjectPanel() : base(FlowDirection.TopToBottom)
|
||||
{
|
||||
var buttonHeight = 40;
|
||||
|
||||
TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory()
|
||||
{
|
||||
normalTextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
hoverTextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
disabledTextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
pressedTextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
FixedHeight = buttonHeight,
|
||||
FixedWidth = buttonHeight,
|
||||
AllowThemeToAdjustImage = false,
|
||||
checkedBorderColor = RGBA_Bytes.White
|
||||
};
|
||||
|
||||
BackgroundColor = new RGBA_Bytes(0, 0, 0, 120);
|
||||
|
||||
HAnchor |= HAnchor.ParentRight;
|
||||
VAnchor = VAnchor.ParentTop | VAnchor.FitToChildren;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,179 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2016, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
public class View3DWidgetSidebar : FlowLayoutWidget
|
||||
{
|
||||
private View3DWidget view3DWidget;
|
||||
|
||||
// TODO: Remove debugging variables and draw functions once drag items are positioning correctly
|
||||
private Vector2 mouseMovePosition;
|
||||
private RectangleDouble meshViewerPosition;
|
||||
private FlowLayoutWidget buttonPanel;
|
||||
|
||||
public View3DWidgetSidebar(View3DWidget view3DWidget, double buildHeight)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
{
|
||||
this.view3DWidget = view3DWidget;
|
||||
this.Width = 200;
|
||||
|
||||
var ExpandMenuOptionFactory = view3DWidget.ExpandMenuOptionFactory;
|
||||
|
||||
buttonPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
VAnchor = VAnchor.FitToChildren
|
||||
};
|
||||
this.AddChild(buttonPanel);
|
||||
this.Padding = new BorderDouble(6, 6);
|
||||
this.Margin = new BorderDouble(0, 1);
|
||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
this.VAnchor = VAnchor.ParentBottomTop;
|
||||
}
|
||||
|
||||
// InitializeComponent is called after the Sidebar property has been assigned as SidebarPlugins
|
||||
// are passed an instance of the View3DWidget and expect to be able to access the Sidebar to
|
||||
// call create button methods
|
||||
public void InitializeComponents()
|
||||
{
|
||||
HashSet<IObject3DEditor> mappedEditors;
|
||||
|
||||
var objectEditorsByType = new Dictionary<Type, HashSet<IObject3DEditor>>();
|
||||
|
||||
// TODO: Consider only loading once into a static
|
||||
var objectEditors = new PluginFinder<IObject3DEditor>().Plugins;
|
||||
foreach (IObject3DEditor editor in objectEditors)
|
||||
{
|
||||
foreach (Type type in editor.SupportedTypes())
|
||||
{
|
||||
if (!objectEditorsByType.TryGetValue(type, out mappedEditors))
|
||||
{
|
||||
mappedEditors = new HashSet<IObject3DEditor>();
|
||||
objectEditorsByType.Add(type, mappedEditors);
|
||||
}
|
||||
|
||||
mappedEditors.Add(editor);
|
||||
}
|
||||
}
|
||||
|
||||
view3DWidget.objectEditors = objectEditors;
|
||||
view3DWidget.objectEditorsByType = objectEditorsByType;
|
||||
}
|
||||
|
||||
public GuiWidget CreateAddButton(string buttonLabel, Func<IObject3D> itemCreator)
|
||||
{
|
||||
GuiWidget addItemButton = CreateButtonState(
|
||||
buttonLabel,
|
||||
ImageBuffer.CreateScaledImage(StaticData.Instance.LoadImage(Path.Combine("Icons", "part_icon_transparent_40x40.png")), 64, 64),
|
||||
ActiveTheme.Instance.PrimaryBackgroundColor,
|
||||
ActiveTheme.Instance.PrimaryTextColor);
|
||||
addItemButton.Margin = new BorderDouble(3);
|
||||
|
||||
addItemButton.MouseDown += (sender, e) =>
|
||||
{
|
||||
view3DWidget.DragDropSource = itemCreator();
|
||||
};
|
||||
|
||||
addItemButton.MouseMove += (sender, mouseArgs) =>
|
||||
{
|
||||
var screenSpaceMousePosition = addItemButton.TransformToScreenSpace(mouseArgs.Position);
|
||||
view3DWidget.AltDragOver(screenSpaceMousePosition);
|
||||
};
|
||||
|
||||
addItemButton.MouseUp += (sender, mouseArgs) =>
|
||||
{
|
||||
if (addItemButton.LocalBounds.Contains(mouseArgs.Position) && view3DWidget.DragDropSource != null)
|
||||
{
|
||||
// Button click within the bounds of this control - Insert item at the best open position
|
||||
PlatingHelper.MoveToOpenPosition(view3DWidget.DragDropSource, view3DWidget.Scene);
|
||||
view3DWidget.InsertNewItem(view3DWidget.DragDropSource);
|
||||
}
|
||||
else if (view3DWidget.DragDropSource != null && view3DWidget.Scene.Children.Contains(view3DWidget.DragDropSource))
|
||||
{
|
||||
// Drag release outside the bounds of this control and not within the scene - Remove inserted item
|
||||
//
|
||||
// Mouse and widget positions
|
||||
var screenSpaceMousePosition = addItemButton.TransformToScreenSpace(mouseArgs.Position);
|
||||
meshViewerPosition = this.view3DWidget.meshViewerWidget.TransformToScreenSpace(view3DWidget.meshViewerWidget.LocalBounds);
|
||||
|
||||
// If the mouse is not within the meshViewer, remove the inserted drag item
|
||||
if (!meshViewerPosition.Contains(screenSpaceMousePosition))
|
||||
{
|
||||
view3DWidget.Scene.ModifyChildren(children => children.Remove(view3DWidget.DragDropSource));
|
||||
view3DWidget.Scene.ClearSelection();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create and push the undo operation
|
||||
view3DWidget.AddUndoOperation(
|
||||
new InsertCommand(view3DWidget, view3DWidget.DragDropSource));
|
||||
}
|
||||
}
|
||||
|
||||
view3DWidget.DragDropSource = null;
|
||||
};
|
||||
|
||||
return addItemButton;
|
||||
}
|
||||
|
||||
private static FlowLayoutWidget CreateButtonState(string buttonLabel, ImageBuffer buttonImage, RGBA_Bytes color, RGBA_Bytes textColor)
|
||||
{
|
||||
FlowLayoutWidget flowLayout = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
BackgroundColor = color,
|
||||
};
|
||||
flowLayout.AddChild(new ImageWidget(buttonImage)
|
||||
{
|
||||
Margin = new BorderDouble(0, 5, 0, 0),
|
||||
BackgroundColor = RGBA_Bytes.Gray,
|
||||
HAnchor = HAnchor.ParentCenter,
|
||||
Selectable = false,
|
||||
});
|
||||
flowLayout.AddChild(new TextWidget(buttonLabel, 0, 0, 9, Agg.Font.Justification.Center, textColor)
|
||||
{
|
||||
HAnchor = HAnchor.ParentCenter,
|
||||
Selectable = false,
|
||||
});
|
||||
return flowLayout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +182,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private Action afterSaveCallback = null;
|
||||
private bool editorThatRequestedSave = false;
|
||||
private FlowLayoutWidget enterEditButtonsContainer;
|
||||
private ExportPrintItemWindow exportingWindow = null;
|
||||
private ObservableCollection<GuiWidget> extruderButtons = new ObservableCollection<GuiWidget>();
|
||||
private bool hasDrawn = false;
|
||||
|
|
@ -205,7 +204,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
private bool wasInSelectMode = false;
|
||||
|
||||
public event EventHandler SelectedTransformChanged;
|
||||
public View3DWidgetSidebar Sidebar;
|
||||
|
||||
public static ImageBuffer ArrowRight
|
||||
{
|
||||
|
|
@ -252,6 +250,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground;
|
||||
|
||||
|
||||
viewControls3D.TransformStateChanged += ViewControls3D_TransformStateChanged;
|
||||
|
||||
FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
|
||||
mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
|
||||
|
|
@ -283,10 +284,24 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
buttonBottomPanel.Padding = new BorderDouble(3, 3);
|
||||
buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
Sidebar = new View3DWidgetSidebar(this, viewerVolume.y);
|
||||
Sidebar.Name = "buttonRightPanel";
|
||||
Sidebar.Visible = false;
|
||||
Sidebar.InitializeComponents();
|
||||
HashSet<IObject3DEditor> mappedEditors;
|
||||
objectEditorsByType = new Dictionary<Type, HashSet<IObject3DEditor>>();
|
||||
|
||||
// TODO: Consider only loading once into a static
|
||||
var objectEditors = new PluginFinder<IObject3DEditor>().Plugins;
|
||||
foreach (IObject3DEditor editor in objectEditors)
|
||||
{
|
||||
foreach (Type type in editor.SupportedTypes())
|
||||
{
|
||||
if (!objectEditorsByType.TryGetValue(type, out mappedEditors))
|
||||
{
|
||||
mappedEditors = new HashSet<IObject3DEditor>();
|
||||
objectEditorsByType.Add(type, mappedEditors);
|
||||
}
|
||||
|
||||
mappedEditors.Add(editor);
|
||||
}
|
||||
}
|
||||
|
||||
Scene.SelectionChanged += Scene_SelectionChanged;
|
||||
|
||||
|
|
@ -302,59 +317,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
editToolBar.AddChild(processingProgressControl);
|
||||
editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
|
||||
processingProgressControl.Visible = false;
|
||||
|
||||
// If the window is embedded (in the center panel) and there is no item loaded then don't show the add button
|
||||
enterEditButtonsContainer = new FlowLayoutWidget();
|
||||
{
|
||||
Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
|
||||
addButton.ToolTipText = "Insert an .stl, .amf or .zip file".Localize();
|
||||
addButton.Margin = new BorderDouble(right: 0);
|
||||
enterEditButtonsContainer.AddChild(addButton);
|
||||
addButton.Click += (sender, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
SwitchStateToEditing();
|
||||
});
|
||||
};
|
||||
if (printItemWrapper != null
|
||||
&& printItemWrapper.PrintItem.ReadOnly)
|
||||
{
|
||||
addButton.Enabled = false;
|
||||
}
|
||||
|
||||
ImageBuffer normalImage = StaticData.Instance.LoadIcon("icon_edit.png", 14, 14);
|
||||
|
||||
Button enterEdittingButton = textImageButtonFactory.Generate("Edit".Localize(), normalImage);
|
||||
enterEdittingButton.Name = "3D View Edit";
|
||||
enterEdittingButton.Margin = new BorderDouble(right: 4);
|
||||
enterEdittingButton.Click += (sender, e) =>
|
||||
{
|
||||
SwitchStateToEditing();
|
||||
};
|
||||
|
||||
if (printItemWrapper != null
|
||||
&& printItemWrapper.PrintItem.ReadOnly)
|
||||
{
|
||||
enterEdittingButton.Enabled = false;
|
||||
}
|
||||
|
||||
Button exportButton = textImageButtonFactory.Generate("Export".Localize() + "...");
|
||||
|
||||
exportButton.Margin = new BorderDouble(right: 10);
|
||||
exportButton.Click += (sender, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
OpenExportWindow();
|
||||
});
|
||||
};
|
||||
|
||||
enterEditButtonsContainer.AddChild(enterEdittingButton);
|
||||
enterEditButtonsContainer.AddChild(exportButton);
|
||||
}
|
||||
editToolBar.AddChild(enterEditButtonsContainer);
|
||||
|
||||
doEdittingButtonsContainer = new FlowLayoutWidget();
|
||||
doEdittingButtonsContainer.Visible = false;
|
||||
|
||||
|
|
@ -439,36 +401,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
separatorThree.VAnchor = VAnchor.ParentBottomTop;
|
||||
doEdittingButtonsContainer.AddChild(separatorThree);
|
||||
|
||||
Button cancelEditModeButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true);
|
||||
cancelEditModeButton.Name = "3D View Cancel";
|
||||
cancelEditModeButton.Click += (sender, e) =>
|
||||
Button exportButton = textImageButtonFactory.Generate("Export".Localize() + "...");
|
||||
|
||||
exportButton.Margin = new BorderDouble(right: 10);
|
||||
exportButton.Click += (sender, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
if (saveButtons.Visible)
|
||||
{
|
||||
StyledMessageBox.ShowMessageBox(
|
||||
ExitEditingAndSaveIfRequested,
|
||||
"Would you like to save your changes before exiting the editor?".Localize(),
|
||||
"Save Changes".Localize(),
|
||||
StyledMessageBox.MessageType.YES_NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (partHasBeenEdited)
|
||||
{
|
||||
ExitEditingAndSaveIfRequested(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchStateToNotEditing();
|
||||
}
|
||||
}
|
||||
OpenExportWindow();
|
||||
});
|
||||
};
|
||||
|
||||
doEdittingButtonsContainer.AddChild(cancelEditModeButton);
|
||||
|
||||
// put in the save button
|
||||
AddSaveAndSaveAs(doEdittingButtonsContainer);
|
||||
|
||||
|
|
@ -529,12 +472,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
};
|
||||
buttonRightPanelHolder.Name = "buttonRightPanelHolder";
|
||||
centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
|
||||
buttonRightPanelHolder.AddChild(Sidebar);
|
||||
Sidebar.VisibleChanged += (sender, e) =>
|
||||
{
|
||||
buttonRightPanelHolder.Visible = Sidebar.Visible;
|
||||
};
|
||||
|
||||
|
||||
buttonRightPanelDisabledCover = new GuiWidget()
|
||||
{
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
|
|
@ -579,18 +517,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
selectedObjectPanel = new SelectedObjectPanel()
|
||||
{
|
||||
Margin = new BorderDouble(0, 0, Sidebar.Width + 5, 5),
|
||||
Margin = 5,
|
||||
BackgroundColor = new RGBA_Bytes(0, 0, 0, ViewControls2D.overlayAlpha)
|
||||
};
|
||||
|
||||
AddChild(selectedObjectPanel);
|
||||
|
||||
UiThread.RunOnIdle(AutoSpin);
|
||||
|
||||
if (printItemWrapper == null && windowType == WindowMode.Embeded)
|
||||
{
|
||||
enterEditButtonsContainer.Visible = false;
|
||||
}
|
||||
|
||||
if (windowType == WindowMode.Embeded)
|
||||
{
|
||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetEditControlsBasedOnPrinterState, ref unregisterEvents);
|
||||
|
|
@ -637,6 +571,28 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
meshViewerWidget.TrackballTumbleWidget.DrawGlContent += TrackballTumbleWidget_DrawGlContent;
|
||||
}
|
||||
|
||||
private void ViewControls3D_TransformStateChanged(object sender, TransformStateChangedEventArgs e)
|
||||
{
|
||||
switch (e.TransformMode)
|
||||
{
|
||||
case ViewControls3DButtons.Rotate:
|
||||
meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;
|
||||
break;
|
||||
|
||||
case ViewControls3DButtons.Translate:
|
||||
meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Translation;
|
||||
break;
|
||||
|
||||
case ViewControls3DButtons.Scale:
|
||||
meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Scale;
|
||||
break;
|
||||
|
||||
case ViewControls3DButtons.PartSelect:
|
||||
meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectAll()
|
||||
{
|
||||
Scene.ClearSelection();
|
||||
|
|
@ -900,6 +856,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
// Not needed but safer than without
|
||||
viewControls3D.TransformStateChanged -= ViewControls3D_TransformStateChanged;
|
||||
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
|
@ -1400,12 +1359,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
if (partsToAdd.Length > 0)
|
||||
{
|
||||
bool enterEditModeBeforeAddingParts = enterEditButtonsContainer.Visible == true;
|
||||
if (enterEditModeBeforeAddingParts)
|
||||
{
|
||||
SwitchStateToEditing();
|
||||
}
|
||||
|
||||
loadAndAddPartsToPlate(partsToAdd);
|
||||
}
|
||||
}
|
||||
|
|
@ -1661,15 +1614,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
// Indicates if MatterControl is in a mode that allows DragDrop
|
||||
private bool AllowDragDrop()
|
||||
{
|
||||
if ((!enterEditButtonsContainer.Visible
|
||||
&& !doEdittingButtonsContainer.Visible)
|
||||
|| printItemWrapper != null && printItemWrapper.PrintItem.ReadOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
{
|
||||
return printItemWrapper?.PrintItem.ReadOnly != false;
|
||||
}
|
||||
|
||||
private void AutoSpin()
|
||||
|
|
@ -1719,14 +1665,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public async Task ClearBedAndLoadPrintItemWrapper(PrintItemWrapper newPrintItem, bool switchToEditingMode = false)
|
||||
{
|
||||
if(switchToEditingMode)
|
||||
{
|
||||
SwitchStateToEditing();
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchStateToNotEditing();
|
||||
}
|
||||
SwitchStateToEditing();
|
||||
|
||||
Scene.ModifyChildren(children => children.Clear());
|
||||
|
||||
|
|
@ -1799,14 +1738,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
VAnchor = VAnchor.FitToChildren
|
||||
VAnchor = VAnchor.FitToChildren,
|
||||
};
|
||||
|
||||
if (mappedEditors != null)
|
||||
{
|
||||
var dropDownList = new DropDownList("", maxHeight: 300)
|
||||
{
|
||||
Margin = new BorderDouble(0, 3)
|
||||
Margin = 3
|
||||
};
|
||||
|
||||
foreach (IObject3DEditor editor in mappedEditors)
|
||||
|
|
@ -1900,13 +1839,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
if (userResponseYesSave)
|
||||
{
|
||||
SaveChanges(null, SwitchStateToNotEditing);
|
||||
SaveChanges(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Discard changes in scene, revert back to original state
|
||||
SwitchStateToNotEditing();
|
||||
|
||||
// and reload the part
|
||||
ClearBedAndLoadPrintItemWrapper(printItemWrapper);
|
||||
}
|
||||
|
|
@ -2015,7 +1951,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
public void LockEditControls()
|
||||
{
|
||||
viewIsInEditModePreLock = doEdittingButtonsContainer.Visible;
|
||||
enterEditButtonsContainer.Visible = false;
|
||||
doEdittingButtonsContainer.Visible = false;
|
||||
buttonRightPanelDisabledCover.Visible = true;
|
||||
if (viewControls3D.PartSelectVisible == true)
|
||||
|
|
@ -2347,38 +2282,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
public override bool InEditMode
|
||||
{
|
||||
get { return Sidebar != null && Sidebar.Visible; }
|
||||
}
|
||||
|
||||
private void SwitchStateToNotEditing()
|
||||
{
|
||||
IsEditing = false;
|
||||
|
||||
if (!enterEditButtonsContainer.Visible)
|
||||
{
|
||||
enterEditButtonsContainer.Visible = true;
|
||||
processingProgressControl.Visible = false;
|
||||
Sidebar.Visible = false;
|
||||
doEdittingButtonsContainer.Visible = false;
|
||||
viewControls3D.PartSelectVisible = false;
|
||||
if (viewControls3D.ActiveButton == ViewControls3DButtons.PartSelect)
|
||||
{
|
||||
viewControls3D.ActiveButton = ViewControls3DButtons.Rotate;
|
||||
}
|
||||
|
||||
Scene.ModifyChildren(ClearSelectionApplyChanges);
|
||||
}
|
||||
}
|
||||
public override bool InEditMode => true;
|
||||
|
||||
internal async void SwitchStateToEditing()
|
||||
{
|
||||
if (enterEditButtonsContainer.Visible == true)
|
||||
{
|
||||
enterEditButtonsContainer.Visible = false;
|
||||
}
|
||||
|
||||
this.IsEditing = true;
|
||||
|
||||
viewControls3D.ActiveButton = ViewControls3DButtons.PartSelect;
|
||||
|
|
@ -2415,7 +2322,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Scene.SelectFirstChild();
|
||||
}
|
||||
|
||||
Sidebar.Visible = true;
|
||||
UnlockEditControls();
|
||||
viewControls3D.ActiveButton = ViewControls3DButtons.PartSelect;
|
||||
|
||||
|
|
@ -2429,15 +2335,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
if (viewIsInEditModePreLock)
|
||||
{
|
||||
if (!enterEditButtonsContainer.Visible)
|
||||
{
|
||||
viewControls3D.PartSelectVisible = true;
|
||||
doEdittingButtonsContainer.Visible = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
enterEditButtonsContainer.Visible = true;
|
||||
viewControls3D.PartSelectVisible = true;
|
||||
doEdittingButtonsContainer.Visible = true;
|
||||
}
|
||||
|
||||
if (wasInSelectMode)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
public class ViewControlsBase : FlowLayoutWidget
|
||||
{
|
||||
protected int buttonHeight = UserSettings.Instance.IsTouchScreen ? 40 : 20;
|
||||
protected const int overlayAlpha = 50;
|
||||
public const int overlayAlpha = 50;
|
||||
}
|
||||
|
||||
public class ViewControls2D : ViewControlsBase
|
||||
|
|
@ -109,18 +109,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
this.AddChild(threeDimensionButton);
|
||||
|
||||
if (UserSettings.Instance.get("LayerViewDefault") == "3D Layer"
|
||||
&&
|
||||
(UserSettings.Instance.Fields.StartCountDurringExit == UserSettings.Instance.Fields.StartCount - 1
|
||||
|| userChangedTo3DThisRun)
|
||||
)
|
||||
{
|
||||
threeDimensionButton.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
twoDimensionButton.Checked = true;
|
||||
}
|
||||
// Change to always start in 3D view
|
||||
threeDimensionButton.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue