2017-06-28 18:39:46 -07:00
|
|
|
|
/*
|
2018-10-03 16:05:32 -07:00
|
|
|
|
Copyright (c) 2018, Lars Brubaker, John Lewin
|
2017-06-28 18:39:46 -07:00
|
|
|
|
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.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2018-02-18 10:58:47 -08:00
|
|
|
|
using System.Collections.ObjectModel;
|
2018-04-04 10:11:57 -07:00
|
|
|
|
using System.ComponentModel;
|
2018-04-06 14:41:49 -07:00
|
|
|
|
using System.Linq;
|
2017-06-28 18:39:46 -07:00
|
|
|
|
using MatterHackers.Agg;
|
2018-02-17 10:44:55 -08:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2017-06-28 18:39:46 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.Localizations;
|
2018-02-17 10:44:55 -08:00
|
|
|
|
using MatterHackers.MatterControl.ConfigurationPage;
|
2018-02-18 10:58:47 -08:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
2017-06-28 18:39:46 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.PartPreviewWindow
|
|
|
|
|
|
{
|
2018-02-17 10:44:55 -08:00
|
|
|
|
public class GCodeOptionsPanel : FlowLayoutWidget
|
|
|
|
|
|
{
|
2018-02-18 10:58:47 -08:00
|
|
|
|
private RadioIconButton speedsButton;
|
|
|
|
|
|
private RadioIconButton materialsButton;
|
|
|
|
|
|
private RadioIconButton noColorButton;
|
|
|
|
|
|
private View3DConfig gcodeOptions;
|
|
|
|
|
|
|
2019-02-01 16:12:12 -08:00
|
|
|
|
public GCodeOptionsPanel(ISceneContext sceneContext, PrinterConfig printer, ThemeConfig theme)
|
2018-02-17 10:44:55 -08:00
|
|
|
|
: base(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
2018-02-18 10:58:47 -08:00
|
|
|
|
gcodeOptions = sceneContext.RendererOptions;
|
|
|
|
|
|
|
|
|
|
|
|
var buttonPanel = new FlowLayoutWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
VAnchor = VAnchor.Fit
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var buttonGroup = new ObservableCollection<GuiWidget>();
|
|
|
|
|
|
|
2020-11-25 07:39:36 -08:00
|
|
|
|
speedsButton = new RadioIconButton(StaticData.Instance.LoadIcon("speeds.png", 16, 16, theme.InvertIcons), theme)
|
2018-02-18 10:58:47 -08:00
|
|
|
|
{
|
|
|
|
|
|
SiblingRadioButtonList = buttonGroup,
|
|
|
|
|
|
Name = "Speeds Button",
|
|
|
|
|
|
Checked = gcodeOptions.GCodeLineColorStyle == "Speeds",
|
|
|
|
|
|
ToolTipText = "Show Speeds".Localize(),
|
|
|
|
|
|
Margin = theme.ButtonSpacing
|
|
|
|
|
|
};
|
|
|
|
|
|
speedsButton.Click += SwitchColorModes_Click;
|
|
|
|
|
|
buttonGroup.Add(speedsButton);
|
|
|
|
|
|
|
|
|
|
|
|
buttonPanel.AddChild(speedsButton);
|
|
|
|
|
|
|
2020-11-25 07:39:36 -08:00
|
|
|
|
materialsButton = new RadioIconButton(StaticData.Instance.LoadIcon("materials.png", 16, 16, theme.InvertIcons), theme)
|
2018-02-18 10:58:47 -08:00
|
|
|
|
{
|
|
|
|
|
|
SiblingRadioButtonList = buttonGroup,
|
|
|
|
|
|
Name = "Materials Button",
|
|
|
|
|
|
Checked = gcodeOptions.GCodeLineColorStyle == "Materials",
|
|
|
|
|
|
ToolTipText = "Show Materials".Localize(),
|
|
|
|
|
|
Margin = theme.ButtonSpacing
|
|
|
|
|
|
};
|
|
|
|
|
|
materialsButton.Click += SwitchColorModes_Click;
|
|
|
|
|
|
buttonGroup.Add(materialsButton);
|
|
|
|
|
|
|
|
|
|
|
|
buttonPanel.AddChild(materialsButton);
|
|
|
|
|
|
|
2020-11-25 07:39:36 -08:00
|
|
|
|
noColorButton = new RadioIconButton(StaticData.Instance.LoadIcon("no-color.png", 16, 16, theme.InvertIcons), theme)
|
2018-02-18 10:58:47 -08:00
|
|
|
|
{
|
|
|
|
|
|
SiblingRadioButtonList = buttonGroup,
|
|
|
|
|
|
Name = "No Color Button",
|
|
|
|
|
|
Checked = gcodeOptions.GCodeLineColorStyle == "None",
|
|
|
|
|
|
ToolTipText = "No Color".Localize(),
|
|
|
|
|
|
Margin = theme.ButtonSpacing
|
|
|
|
|
|
};
|
|
|
|
|
|
noColorButton.Click += SwitchColorModes_Click;
|
|
|
|
|
|
buttonGroup.Add(noColorButton);
|
|
|
|
|
|
|
|
|
|
|
|
buttonPanel.AddChild(noColorButton);
|
|
|
|
|
|
|
|
|
|
|
|
this.AddChild(
|
|
|
|
|
|
new SettingsItem(
|
|
|
|
|
|
"Color View".Localize(),
|
2018-04-12 08:42:10 -07:00
|
|
|
|
theme,
|
|
|
|
|
|
optionalControls: buttonPanel,
|
2018-04-12 23:08:34 -07:00
|
|
|
|
enforceGutter: false));
|
2018-02-18 10:58:47 -08:00
|
|
|
|
|
2018-04-02 16:19:45 -07:00
|
|
|
|
gcodeOptions = sceneContext.RendererOptions;
|
2018-04-02 14:57:36 -07:00
|
|
|
|
|
2018-04-02 16:19:45 -07:00
|
|
|
|
var viewOptions = sceneContext.GetBaseViewOptions();
|
2018-04-02 14:57:36 -07:00
|
|
|
|
|
|
|
|
|
|
viewOptions.AddRange(new[]
|
|
|
|
|
|
{
|
2018-10-03 16:05:32 -07:00
|
|
|
|
new BoolOption(
|
|
|
|
|
|
"Model".Localize(),
|
2019-01-19 15:20:48 -08:00
|
|
|
|
() => gcodeOptions.GCodeModelView,
|
|
|
|
|
|
(value) => gcodeOptions.GCodeModelView = value),
|
2018-02-17 10:44:55 -08:00
|
|
|
|
new BoolOption(
|
|
|
|
|
|
"Moves".Localize(),
|
|
|
|
|
|
() => gcodeOptions.RenderMoves,
|
|
|
|
|
|
(value) => gcodeOptions.RenderMoves = value),
|
|
|
|
|
|
new BoolOption(
|
|
|
|
|
|
"Retractions".Localize(),
|
|
|
|
|
|
() => gcodeOptions.RenderRetractions,
|
|
|
|
|
|
(value) => gcodeOptions.RenderRetractions = value),
|
|
|
|
|
|
new BoolOption(
|
|
|
|
|
|
"Extrusion".Localize(),
|
|
|
|
|
|
() => gcodeOptions.SimulateExtrusion,
|
|
|
|
|
|
(value) => gcodeOptions.SimulateExtrusion = value),
|
|
|
|
|
|
new BoolOption(
|
|
|
|
|
|
"Transparent".Localize(),
|
|
|
|
|
|
() => gcodeOptions.TransparentExtrusion,
|
|
|
|
|
|
(value) => gcodeOptions.TransparentExtrusion = value),
|
|
|
|
|
|
new BoolOption(
|
|
|
|
|
|
"Sync To Print".Localize(),
|
|
|
|
|
|
() => gcodeOptions.SyncToPrint,
|
|
|
|
|
|
(value) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeOptions.SyncToPrint = value;
|
|
|
|
|
|
if (!gcodeOptions.SyncToPrint)
|
|
|
|
|
|
{
|
|
|
|
|
|
// If we are turning off sync to print, set the slider to full.
|
|
|
|
|
|
//layerRenderRatioSlider.SecondValue = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2018-04-02 14:57:36 -07:00
|
|
|
|
});
|
2018-02-17 10:44:55 -08:00
|
|
|
|
|
2018-04-04 10:11:57 -07:00
|
|
|
|
var optionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
2018-02-17 10:44:55 -08:00
|
|
|
|
{
|
2018-04-04 10:11:57 -07:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Fit
|
|
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(optionsContainer);
|
|
|
|
|
|
|
|
|
|
|
|
void BuildMenu()
|
|
|
|
|
|
{
|
2018-04-06 14:41:49 -07:00
|
|
|
|
foreach (var option in viewOptions.Where(option => option.IsVisible()))
|
2018-02-17 10:44:55 -08:00
|
|
|
|
{
|
2018-04-06 14:41:49 -07:00
|
|
|
|
var settingsItem = new SettingsItem(
|
|
|
|
|
|
option.Title,
|
2018-04-12 08:42:10 -07:00
|
|
|
|
theme,
|
2018-04-06 14:41:49 -07:00
|
|
|
|
new SettingsItem.ToggleSwitchConfig()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = option.Title + " Toggle",
|
|
|
|
|
|
Checked = option.IsChecked(),
|
|
|
|
|
|
ToggleAction = option.SetValue
|
|
|
|
|
|
},
|
|
|
|
|
|
enforceGutter: false);
|
|
|
|
|
|
|
|
|
|
|
|
settingsItem.Padding = settingsItem.Padding.Clone(right: 8);
|
|
|
|
|
|
|
|
|
|
|
|
optionsContainer.AddChild(settingsItem);
|
2018-02-17 10:44:55 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-04 10:11:57 -07:00
|
|
|
|
|
|
|
|
|
|
BuildMenu();
|
|
|
|
|
|
|
|
|
|
|
|
PropertyChangedEventHandler syncProperties = (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.PropertyName == nameof(gcodeOptions.RenderBed)
|
|
|
|
|
|
|| e.PropertyName == nameof(gcodeOptions.RenderBuildVolume))
|
|
|
|
|
|
{
|
|
|
|
|
|
optionsContainer.CloseAllChildren();
|
|
|
|
|
|
BuildMenu();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
gcodeOptions.PropertyChanged += syncProperties;
|
|
|
|
|
|
|
|
|
|
|
|
optionsContainer.Closed += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeOptions.PropertyChanged -= syncProperties;
|
|
|
|
|
|
};
|
2018-02-17 10:44:55 -08:00
|
|
|
|
}
|
2018-02-18 10:58:47 -08:00
|
|
|
|
|
|
|
|
|
|
private void SwitchColorModes_Click(object sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sender is GuiWidget widget)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (widget.Name == "Speeds Button")
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeOptions.GCodeLineColorStyle = "Speeds";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (widget.Name == "Materials Button")
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeOptions.GCodeLineColorStyle = "Materials";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeOptions.GCodeLineColorStyle = "None";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-17 10:44:55 -08:00
|
|
|
|
}
|
2017-06-28 18:39:46 -07:00
|
|
|
|
}
|