2017-09-15 15:17:56 -07:00
|
|
|
|
/*
|
|
|
|
|
|
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 System;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.MeshVisualizer;
|
|
|
|
|
|
using MatterHackers.VectorMath;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.PartPreviewWindow
|
|
|
|
|
|
{
|
2017-11-07 14:55:45 -08:00
|
|
|
|
public class PartTabPage : TabPage
|
2017-09-15 15:17:56 -07:00
|
|
|
|
{
|
2017-10-06 12:23:32 -07:00
|
|
|
|
internal View3DWidget view3DWidget;
|
2017-09-15 15:17:56 -07:00
|
|
|
|
|
|
|
|
|
|
protected ViewControls3D viewControls3D;
|
|
|
|
|
|
|
2017-11-07 14:55:45 -08:00
|
|
|
|
internal BedConfig sceneContext;
|
2017-09-15 15:17:56 -07:00
|
|
|
|
protected ThemeConfig theme;
|
|
|
|
|
|
|
|
|
|
|
|
protected GuiWidget view3DContainer;
|
|
|
|
|
|
protected FlowLayoutWidget topToBottom;
|
|
|
|
|
|
protected FlowLayoutWidget leftToRight;
|
|
|
|
|
|
|
2017-11-07 14:55:45 -08:00
|
|
|
|
public PartTabPage(PrinterConfig printer, BedConfig sceneContext, ThemeConfig theme, string tabTitle)
|
2017-09-15 15:17:56 -07:00
|
|
|
|
: base (tabTitle)
|
|
|
|
|
|
{
|
2017-09-15 16:49:21 -07:00
|
|
|
|
this.sceneContext = sceneContext;
|
2017-09-15 15:17:56 -07:00
|
|
|
|
this.theme = theme;
|
|
|
|
|
|
this.BackgroundColor = theme.TabBodyBackground;
|
|
|
|
|
|
this.Padding = 0;
|
|
|
|
|
|
|
2017-09-15 16:49:21 -07:00
|
|
|
|
viewControls3D = new ViewControls3D(theme, sceneContext.Scene.UndoBuffer)
|
2017-09-15 15:17:56 -07:00
|
|
|
|
{
|
2017-11-01 18:13:47 -07:00
|
|
|
|
//BackgroundColor = new Color(0, 0, 0, theme.OverlayAlpha),
|
2017-09-15 15:17:56 -07:00
|
|
|
|
PartSelectVisible = false,
|
2017-10-31 13:50:20 -07:00
|
|
|
|
VAnchor = VAnchor.Top | VAnchor.Fit,
|
|
|
|
|
|
HAnchor = HAnchor.Left | HAnchor.Stretch,
|
2017-09-15 15:17:56 -07:00
|
|
|
|
Visible = true,
|
|
|
|
|
|
};
|
|
|
|
|
|
viewControls3D.ResetView += (sender, e) =>
|
|
|
|
|
|
{
|
2017-10-06 12:23:32 -07:00
|
|
|
|
if (view3DWidget.Visible)
|
2017-09-15 15:17:56 -07:00
|
|
|
|
{
|
2017-10-06 12:23:32 -07:00
|
|
|
|
this.view3DWidget.ResetView();
|
2017-09-15 15:17:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2017-11-08 23:43:18 -08:00
|
|
|
|
viewControls3D.OverflowMenu.DynamicPopupContent = this.GetViewControls3DOverflowMenu;
|
|
|
|
|
|
|
2017-10-22 23:21:57 -07:00
|
|
|
|
bool isPrinterType = this is PrinterTabPage;
|
2017-09-15 15:17:56 -07:00
|
|
|
|
|
|
|
|
|
|
// The 3D model view
|
2017-10-06 12:23:32 -07:00
|
|
|
|
view3DWidget = new View3DWidget(
|
2017-09-17 01:11:18 -07:00
|
|
|
|
printer,
|
2017-09-15 16:49:21 -07:00
|
|
|
|
sceneContext,
|
2017-09-15 15:17:56 -07:00
|
|
|
|
View3DWidget.AutoRotate.Disabled,
|
|
|
|
|
|
viewControls3D,
|
|
|
|
|
|
theme,
|
2017-10-16 17:09:00 -07:00
|
|
|
|
this,
|
2017-09-15 15:17:56 -07:00
|
|
|
|
editorType: (isPrinterType) ? MeshViewerWidget.EditorType.Printer : MeshViewerWidget.EditorType.Part);
|
|
|
|
|
|
|
2017-11-09 00:02:21 -08:00
|
|
|
|
this.AddChild(topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch
|
|
|
|
|
|
});
|
2017-10-31 13:50:20 -07:00
|
|
|
|
|
2017-11-09 00:02:21 -08:00
|
|
|
|
topToBottom.AddChild(leftToRight = new FlowLayoutWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "View3DContainerParent",
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch
|
|
|
|
|
|
});
|
2017-09-15 15:17:56 -07:00
|
|
|
|
|
2017-11-09 00:02:21 -08:00
|
|
|
|
view3DContainer = new GuiWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch
|
|
|
|
|
|
};
|
2017-09-15 15:17:56 -07:00
|
|
|
|
|
2017-11-09 00:02:21 -08:00
|
|
|
|
var toolbarAndView3DWidget = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch
|
|
|
|
|
|
};
|
|
|
|
|
|
toolbarAndView3DWidget.AddChild(viewControls3D);
|
|
|
|
|
|
toolbarAndView3DWidget.AddChild(view3DWidget);
|
|
|
|
|
|
view3DContainer.AddChild(toolbarAndView3DWidget);
|
2017-10-21 12:05:44 -07:00
|
|
|
|
|
2017-09-15 15:17:56 -07:00
|
|
|
|
leftToRight.AddChild(view3DContainer);
|
|
|
|
|
|
|
2017-10-06 12:23:32 -07:00
|
|
|
|
view3DWidget.BackgroundColor = ActiveTheme.Instance.TertiaryBackgroundColor;
|
2017-09-15 15:17:56 -07:00
|
|
|
|
|
2017-09-16 01:28:05 -07:00
|
|
|
|
if (sceneContext.World.RotationMatrix == Matrix4X4.Identity)
|
2017-09-15 15:17:56 -07:00
|
|
|
|
{
|
2017-10-06 12:23:32 -07:00
|
|
|
|
this.view3DWidget.ResetView();
|
2017-09-15 15:17:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.AnchorAll();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual GuiWidget GetViewControls3DOverflowMenu()
|
|
|
|
|
|
{
|
2017-10-06 12:23:32 -07:00
|
|
|
|
return view3DWidget.ShowOverflowMenu();
|
2017-09-15 15:17:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnLoad(EventArgs args)
|
|
|
|
|
|
{
|
2017-10-06 12:23:32 -07:00
|
|
|
|
ApplicationController.Instance.ActiveView3DWidget = view3DWidget;
|
2017-09-15 15:17:56 -07:00
|
|
|
|
|
|
|
|
|
|
base.OnLoad(args);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|