Exact PrinterTabPage to new file
This commit is contained in:
parent
aa3baf069a
commit
34a377ede2
6 changed files with 217 additions and 187 deletions
|
|
@ -211,6 +211,7 @@
|
|||
<Compile Include="PartPreviewWindow\GCodeDetailsView.cs" />
|
||||
<Compile Include="PartPreviewWindow\LayerNavigationWidget.cs" />
|
||||
<Compile Include="PartPreviewWindow\OverflowDropdown.cs" />
|
||||
<Compile Include="PartPreviewWindow\PrinterTabPage.cs" />
|
||||
<Compile Include="PartPreviewWindow\SetLayerWidget.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\GridOptionsPanel.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\InteractionVolume.cs" />
|
||||
|
|
|
|||
|
|
@ -27,21 +27,12 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrintQueue;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.MeshVisualizer;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.IO;
|
||||
using static MatterHackers.MatterControl.PartPreviewWindow.View3DWidget;
|
||||
using MatterHackers.MatterControl.PrinterControls;
|
||||
using MatterHackers.MatterControl.ActionBar;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
|
|
@ -49,7 +40,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
private TabControl tabControl;
|
||||
private View3DWidget.AutoRotate autoRotate3DView;
|
||||
private View3DWidget.OpenMode openMode;
|
||||
private View3DWidget.WindowMode windowMode;
|
||||
|
|
@ -68,7 +58,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
// LoadPrintItem {{
|
||||
var activeSettings = ActiveSliceSettings.Instance;
|
||||
|
||||
tabControl = ApplicationController.Instance.Theme.CreateTabControl();
|
||||
var tabControl = ApplicationController.Instance.Theme.CreateTabControl();
|
||||
|
||||
string tabTitle = !activeSettings.PrinterSelected ? "Printer".Localize() : activeSettings.GetValue(SettingsKey.printer_name);
|
||||
|
||||
|
|
@ -106,177 +96,5 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
//this.LoadPrintItem(printItem);
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
|
||||
public class PrinterTabPage : GuiWidget
|
||||
{
|
||||
private View3DWidget modelViewer;
|
||||
internal ViewGcodeBasic gcodeViewer;
|
||||
private PrintItemWrapper printItem;
|
||||
private ViewControls3D viewControls3D;
|
||||
|
||||
public PrinterTabPage(PrinterSettings activeSettings, PrintItemWrapper printItem)
|
||||
{
|
||||
this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground;
|
||||
this.Padding = new BorderDouble(top: 3);
|
||||
|
||||
double buildHeight = activeSettings.GetValue<double>(SettingsKey.build_height);
|
||||
|
||||
viewControls3D = new ViewControls3D(ApplicationController.Instance.Theme.ViewControlsButtonFactory)
|
||||
{
|
||||
PartSelectVisible = false,
|
||||
VAnchor = VAnchor.ParentTop | VAnchor.FitToChildren | VAnchor.AbsolutePosition,
|
||||
HAnchor = HAnchor.ParentLeft | HAnchor.FitToChildren,
|
||||
Visible = true,
|
||||
Margin = new BorderDouble(11, 0, 0, 50)
|
||||
};
|
||||
viewControls3D.ResetView += (sender, e) =>
|
||||
{
|
||||
modelViewer.meshViewerWidget.ResetView();
|
||||
};
|
||||
viewControls3D.OverflowButton.DynamicPopupContent = () =>
|
||||
{
|
||||
if (gcodeViewer.Visible)
|
||||
{
|
||||
return gcodeViewer.ShowOverflowMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
return modelViewer.ShowOverflowMenu();
|
||||
}
|
||||
};
|
||||
|
||||
// The 3D model view
|
||||
modelViewer = new View3DWidget(printItem,
|
||||
new Vector3(activeSettings.GetValue<Vector2>(SettingsKey.bed_size), buildHeight),
|
||||
activeSettings.GetValue<Vector2>(SettingsKey.print_center),
|
||||
activeSettings.GetValue<BedShape>(SettingsKey.bed_shape),
|
||||
View3DWidget.WindowMode.Embeded,
|
||||
View3DWidget.AutoRotate.Disabled,
|
||||
viewControls3D,
|
||||
ApplicationController.Instance.Theme,
|
||||
View3DWidget.OpenMode.Editing);
|
||||
|
||||
var topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
topToBottom.AnchorAll();
|
||||
this.AddChild(topToBottom);
|
||||
|
||||
// Must come after we have an instance of View3DWidget an its undo buffer
|
||||
topToBottom.AddChild(new PrinterActionsBar(modelViewer, this)
|
||||
{
|
||||
Padding = new BorderDouble(bottom: 2)
|
||||
});
|
||||
|
||||
var leftToRight = new FlowLayoutWidget();
|
||||
leftToRight.AnchorAll();
|
||||
topToBottom.AddChild(leftToRight);
|
||||
|
||||
var container = new GuiWidget();
|
||||
container.AnchorAll();
|
||||
container.AddChild(modelViewer);
|
||||
|
||||
leftToRight.AddChild(container);
|
||||
|
||||
// The slice layers view
|
||||
gcodeViewer = new ViewGcodeBasic(
|
||||
new Vector3(activeSettings.GetValue<Vector2>(SettingsKey.bed_size), buildHeight),
|
||||
activeSettings.GetValue<Vector2>(SettingsKey.print_center),
|
||||
activeSettings.GetValue<BedShape>(SettingsKey.bed_shape),
|
||||
ViewGcodeBasic.WindowMode.Embeded,
|
||||
viewControls3D,
|
||||
ApplicationController.Instance.Theme,
|
||||
modelViewer.meshViewerWidget);
|
||||
gcodeViewer.AnchorAll();
|
||||
this.gcodeViewer.Visible = false;
|
||||
|
||||
container.AddChild(gcodeViewer);
|
||||
|
||||
AddSettingsTabBar(leftToRight, modelViewer);
|
||||
|
||||
modelViewer.BackgroundColor = ActiveTheme.Instance.TertiaryBackgroundColor;
|
||||
|
||||
if (ApplicationController.Instance.PartPreviewState.RotationMatrix == Matrix4X4.Identity)
|
||||
{
|
||||
modelViewer.meshViewerWidget.ResetView();
|
||||
|
||||
ApplicationController.Instance.PartPreviewState.RotationMatrix = modelViewer.meshViewerWidget.World.RotationMatrix;
|
||||
ApplicationController.Instance.PartPreviewState.TranslationMatrix = modelViewer.meshViewerWidget.World.TranslationMatrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
modelViewer.meshViewerWidget.World.RotationMatrix = ApplicationController.Instance.PartPreviewState.RotationMatrix;
|
||||
modelViewer.meshViewerWidget.World.TranslationMatrix = ApplicationController.Instance.PartPreviewState.TranslationMatrix;
|
||||
}
|
||||
|
||||
this.printItem = printItem;
|
||||
|
||||
this.AddChild(viewControls3D);
|
||||
|
||||
this.AnchorAll();
|
||||
}
|
||||
|
||||
private void AddSettingsTabBar(GuiWidget parent, GuiWidget widgetTodockTo)
|
||||
{
|
||||
var sideBar = new DockingTabControl(widgetTodockTo, DockSide.Right)
|
||||
{
|
||||
ControlIsPinned = ApplicationController.Instance.PrintSettingsPinned
|
||||
};
|
||||
sideBar.PinStatusChanged += (s, e) =>
|
||||
{
|
||||
ApplicationController.Instance.PrintSettingsPinned = sideBar.ControlIsPinned;
|
||||
};
|
||||
parent.AddChild(sideBar);
|
||||
|
||||
if (ActiveSliceSettings.Instance.PrinterSelected)
|
||||
{
|
||||
sideBar.AddPage("Slice Settings".Localize(), new SliceSettingsWidget());
|
||||
}
|
||||
else
|
||||
{
|
||||
sideBar.AddPage("Slice Settings".Localize(), new NoSettingsWidget());
|
||||
}
|
||||
|
||||
sideBar.AddPage("Controls".Localize(), new ManualPrinterControls());
|
||||
|
||||
var terminalControls = new TerminalControls();
|
||||
terminalControls.VAnchor |= VAnchor.ParentBottomTop;
|
||||
sideBar.AddPage("Terminal".Localize(), terminalControls);
|
||||
}
|
||||
|
||||
public void SwitchToLayerView()
|
||||
{
|
||||
gcodeViewer.Visible = true;
|
||||
modelViewer.ShowSliceLayers = true;
|
||||
}
|
||||
|
||||
public void ToggleView()
|
||||
{
|
||||
gcodeViewer.Visible = !gcodeViewer.Visible;
|
||||
modelViewer.ShowSliceLayers = gcodeViewer.Visible;
|
||||
}
|
||||
|
||||
private async void LoadActivePrintItem()
|
||||
{
|
||||
await modelViewer.ClearBedAndLoadPrintItemWrapper(printItem);
|
||||
}
|
||||
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
ApplicationController.Instance.ActiveView3DWidget = modelViewer;
|
||||
LoadActivePrintItem();
|
||||
base.OnLoad(args);
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
var visibleWidget = modelViewer.meshViewerWidget;
|
||||
|
||||
ApplicationController.Instance.PartPreviewState.RotationMatrix = visibleWidget.World.RotationMatrix;
|
||||
ApplicationController.Instance.PartPreviewState.TranslationMatrix = visibleWidget.World.TranslationMatrix;
|
||||
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
212
PartPreviewWindow/PrinterTabPage.cs
Normal file
212
PartPreviewWindow/PrinterTabPage.cs
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
Copyright (c) 2017, 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 MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.PrintQueue;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.MeshVisualizer;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using MatterHackers.MatterControl.PrinterControls;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
public class PrinterTabPage : GuiWidget
|
||||
{
|
||||
private View3DWidget modelViewer;
|
||||
internal ViewGcodeBasic gcodeViewer;
|
||||
private PrintItemWrapper printItem;
|
||||
private ViewControls3D viewControls3D;
|
||||
|
||||
public PrinterTabPage(PrinterSettings activeSettings, PrintItemWrapper printItem)
|
||||
{
|
||||
this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground;
|
||||
this.Padding = new BorderDouble(top: 3);
|
||||
|
||||
double buildHeight = activeSettings.GetValue<double>(SettingsKey.build_height);
|
||||
|
||||
viewControls3D = new ViewControls3D(ApplicationController.Instance.Theme.ViewControlsButtonFactory)
|
||||
{
|
||||
PartSelectVisible = false,
|
||||
VAnchor = VAnchor.ParentTop | VAnchor.FitToChildren | VAnchor.AbsolutePosition,
|
||||
HAnchor = HAnchor.ParentLeft | HAnchor.FitToChildren,
|
||||
Visible = true,
|
||||
Margin = new BorderDouble(11, 0, 0, 50)
|
||||
};
|
||||
viewControls3D.ResetView += (sender, e) =>
|
||||
{
|
||||
modelViewer.meshViewerWidget.ResetView();
|
||||
};
|
||||
viewControls3D.OverflowButton.DynamicPopupContent = () =>
|
||||
{
|
||||
if (gcodeViewer.Visible)
|
||||
{
|
||||
return gcodeViewer.ShowOverflowMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
return modelViewer.ShowOverflowMenu();
|
||||
}
|
||||
};
|
||||
|
||||
// The 3D model view
|
||||
modelViewer = new View3DWidget(printItem,
|
||||
new Vector3(activeSettings.GetValue<Vector2>(SettingsKey.bed_size), buildHeight),
|
||||
activeSettings.GetValue<Vector2>(SettingsKey.print_center),
|
||||
activeSettings.GetValue<BedShape>(SettingsKey.bed_shape),
|
||||
View3DWidget.WindowMode.Embeded,
|
||||
View3DWidget.AutoRotate.Disabled,
|
||||
viewControls3D,
|
||||
ApplicationController.Instance.Theme,
|
||||
View3DWidget.OpenMode.Editing);
|
||||
|
||||
var topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
topToBottom.AnchorAll();
|
||||
this.AddChild(topToBottom);
|
||||
|
||||
// Must come after we have an instance of View3DWidget an its undo buffer
|
||||
topToBottom.AddChild(new PrinterActionsBar(modelViewer, this)
|
||||
{
|
||||
Padding = new BorderDouble(bottom: 2)
|
||||
});
|
||||
|
||||
var leftToRight = new FlowLayoutWidget();
|
||||
leftToRight.AnchorAll();
|
||||
topToBottom.AddChild(leftToRight);
|
||||
|
||||
var container = new GuiWidget();
|
||||
container.AnchorAll();
|
||||
container.AddChild(modelViewer);
|
||||
|
||||
leftToRight.AddChild(container);
|
||||
|
||||
// The slice layers view
|
||||
gcodeViewer = new ViewGcodeBasic(
|
||||
new Vector3(activeSettings.GetValue<Vector2>(SettingsKey.bed_size), buildHeight),
|
||||
activeSettings.GetValue<Vector2>(SettingsKey.print_center),
|
||||
activeSettings.GetValue<BedShape>(SettingsKey.bed_shape),
|
||||
ViewGcodeBasic.WindowMode.Embeded,
|
||||
viewControls3D,
|
||||
ApplicationController.Instance.Theme,
|
||||
modelViewer.meshViewerWidget);
|
||||
gcodeViewer.AnchorAll();
|
||||
this.gcodeViewer.Visible = false;
|
||||
|
||||
container.AddChild(gcodeViewer);
|
||||
|
||||
AddSettingsTabBar(leftToRight, modelViewer);
|
||||
|
||||
modelViewer.BackgroundColor = ActiveTheme.Instance.TertiaryBackgroundColor;
|
||||
|
||||
if (ApplicationController.Instance.PartPreviewState.RotationMatrix == Matrix4X4.Identity)
|
||||
{
|
||||
modelViewer.meshViewerWidget.ResetView();
|
||||
|
||||
ApplicationController.Instance.PartPreviewState.RotationMatrix = modelViewer.meshViewerWidget.World.RotationMatrix;
|
||||
ApplicationController.Instance.PartPreviewState.TranslationMatrix = modelViewer.meshViewerWidget.World.TranslationMatrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
modelViewer.meshViewerWidget.World.RotationMatrix = ApplicationController.Instance.PartPreviewState.RotationMatrix;
|
||||
modelViewer.meshViewerWidget.World.TranslationMatrix = ApplicationController.Instance.PartPreviewState.TranslationMatrix;
|
||||
}
|
||||
|
||||
this.printItem = printItem;
|
||||
|
||||
this.AddChild(viewControls3D);
|
||||
|
||||
this.AnchorAll();
|
||||
}
|
||||
|
||||
private void AddSettingsTabBar(GuiWidget parent, GuiWidget widgetTodockTo)
|
||||
{
|
||||
var sideBar = new DockingTabControl(widgetTodockTo, DockSide.Right)
|
||||
{
|
||||
ControlIsPinned = ApplicationController.Instance.PrintSettingsPinned
|
||||
};
|
||||
sideBar.PinStatusChanged += (s, e) =>
|
||||
{
|
||||
ApplicationController.Instance.PrintSettingsPinned = sideBar.ControlIsPinned;
|
||||
};
|
||||
parent.AddChild(sideBar);
|
||||
|
||||
if (ActiveSliceSettings.Instance.PrinterSelected)
|
||||
{
|
||||
sideBar.AddPage("Slice Settings".Localize(), new SliceSettingsWidget());
|
||||
}
|
||||
else
|
||||
{
|
||||
sideBar.AddPage("Slice Settings".Localize(), new NoSettingsWidget());
|
||||
}
|
||||
|
||||
sideBar.AddPage("Controls".Localize(), new ManualPrinterControls());
|
||||
|
||||
var terminalControls = new TerminalControls();
|
||||
terminalControls.VAnchor |= VAnchor.ParentBottomTop;
|
||||
sideBar.AddPage("Terminal".Localize(), terminalControls);
|
||||
}
|
||||
|
||||
public void SwitchToLayerView()
|
||||
{
|
||||
gcodeViewer.Visible = true;
|
||||
modelViewer.ShowSliceLayers = true;
|
||||
}
|
||||
|
||||
public void ToggleView()
|
||||
{
|
||||
gcodeViewer.Visible = !gcodeViewer.Visible;
|
||||
modelViewer.ShowSliceLayers = gcodeViewer.Visible;
|
||||
}
|
||||
|
||||
private async void LoadActivePrintItem()
|
||||
{
|
||||
await modelViewer.ClearBedAndLoadPrintItemWrapper(printItem);
|
||||
}
|
||||
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
ApplicationController.Instance.ActiveView3DWidget = modelViewer;
|
||||
LoadActivePrintItem();
|
||||
base.OnLoad(args);
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
var visibleWidget = modelViewer.meshViewerWidget;
|
||||
|
||||
ApplicationController.Instance.PartPreviewState.RotationMatrix = visibleWidget.World.RotationMatrix;
|
||||
ApplicationController.Instance.PartPreviewState.TranslationMatrix = visibleWidget.World.TranslationMatrix;
|
||||
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
public PrinterActionsBar(View3DWidget modelViewer, PartPreviewContent.PrinterTabPage printerTabPage)
|
||||
public PrinterActionsBar(View3DWidget modelViewer, PrinterTabPage printerTabPage)
|
||||
{
|
||||
UndoBuffer undoBuffer = modelViewer.UndoBuffer;
|
||||
|
||||
|
|
|
|||
|
|
@ -231,7 +231,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
protected FlowLayoutWidget editPlateButtonsContainer;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public View3DWidget(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, Vector2 bedCenter, BedShape bedShape, WindowMode windowType, AutoRotate autoRotate, ViewControls3D viewControls3D, ThemeConfig theme, OpenMode openMode = OpenMode.Viewing)
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
layersButton.Margin = 3;
|
||||
layersButton.Click += (s, e) =>
|
||||
{
|
||||
var parentTabPage = this.Parents<PartPreviewContent.PrinterTabPage>().First();
|
||||
var parentTabPage = this.Parents<PrinterTabPage>().First();
|
||||
parentTabPage.ToggleView();
|
||||
};
|
||||
AddChild(layersButton);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue