Merge pull request #2865 from larsbrubaker/design_tools

Made subtract and replace and subtract editors always have a starting…
This commit is contained in:
Lars Brubaker 2018-01-10 14:39:59 -08:00 committed by GitHub
commit d2efc6f0f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 10 deletions

View file

@ -361,7 +361,7 @@ namespace MatterHackers.MatterControl
new SceneSelectionOperation() new SceneSelectionOperation()
{ {
TitleResolver = () => "Subtract & Replace".Localize(), TitleResolver = () => "Subtract & Replace".Localize(),
Action = (scene) => DoOpperation(scene, nameof(PaintMaterialEditor), "Subtract & Replace"), Action = (scene) => DoOpperation(scene, nameof(SubtractAndReplace), "Subtract & Replace"),
Icon = AggContext.StaticData.LoadIcon("paint.png").SetPreMultiply(), Icon = AggContext.StaticData.LoadIcon("paint.png").SetPreMultiply(),
}, },
new SceneSelectionOperation() new SceneSelectionOperation()

View file

@ -86,6 +86,7 @@
<Compile Include="ApplicationView\WindowsPlatformsFeatures.cs" /> <Compile Include="ApplicationView\WindowsPlatformsFeatures.cs" />
<Compile Include="PartPreviewWindow\LibraryBrowserPage.cs" /> <Compile Include="PartPreviewWindow\LibraryBrowserPage.cs" />
<Compile Include="PartPreviewWindow\MoveItemPage.cs" /> <Compile Include="PartPreviewWindow\MoveItemPage.cs" />
<Compile Include="PartPreviewWindow\View3D\Actions\SubtractAndReplace.cs" />
<Compile Include="PartPreviewWindow\View3D\PrinterBar\OverflowBar.cs" /> <Compile Include="PartPreviewWindow\View3D\PrinterBar\OverflowBar.cs" />
<Compile Include="PartPreviewWindow\View3D\PrinterBar\PrintPopupMenu.cs" /> <Compile Include="PartPreviewWindow\View3D\PrinterBar\PrintPopupMenu.cs" />
<Compile Include="PartPreviewWindow\View3D\PrinterBar\SliceButton.cs" /> <Compile Include="PartPreviewWindow\View3D\PrinterBar\SliceButton.cs" />
@ -140,7 +141,6 @@
<Compile Include="PartPreviewWindow\View3D\Actions\IntersectionEditor.cs" /> <Compile Include="PartPreviewWindow\View3D\Actions\IntersectionEditor.cs" />
<Compile Include="PartPreviewWindow\View3D\Actions\MeshWrapper.cs" /> <Compile Include="PartPreviewWindow\View3D\Actions\MeshWrapper.cs" />
<Compile Include="PartPreviewWindow\View3D\Actions\MeshWrapperOperation.cs" /> <Compile Include="PartPreviewWindow\View3D\Actions\MeshWrapperOperation.cs" />
<Compile Include="PartPreviewWindow\View3D\Actions\PaintMaterialEditor.cs" />
<Compile Include="PartPreviewWindow\View3D\Actions\SubtractEditor.cs" /> <Compile Include="PartPreviewWindow\View3D\Actions\SubtractEditor.cs" />
<Compile Include="PartPreviewWindow\View3D\LightingData.cs" /> <Compile Include="PartPreviewWindow\View3D\LightingData.cs" />
<Compile Include="PartPreviewWindow\View3D\PrinterBar\CancelButton.cs" /> <Compile Include="PartPreviewWindow\View3D\PrinterBar\CancelButton.cs" />

View file

@ -41,7 +41,7 @@ using MatterHackers.PolygonMesh;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{ {
#if DEBUG // keep this work in progress to the editor for now #if DEBUG // keep this work in progress to the editor for now
public class PaintMaterialEditor : IObject3DEditor public class SubtractAndReplace : IObject3DEditor
{ {
private MeshWrapperOperation group; private MeshWrapperOperation group;
private View3DWidget view3DWidget; private View3DWidget view3DWidget;
@ -93,7 +93,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{ {
var children = group.Children.ToList(); var children = group.Children.ToList();
tabContainer.AddChild(new TextWidget("Set as Paint") tabContainer.AddChild(new TextWidget("Set Replace")
{ {
TextColor = ActiveTheme.Instance.PrimaryTextColor, TextColor = ActiveTheme.Instance.PrimaryTextColor,
HAnchor = HAnchor.Left, HAnchor = HAnchor.Left,
@ -104,7 +104,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
var updateButton = theme.ButtonFactory.Generate("Update".Localize()); var updateButton = theme.ButtonFactory.Generate("Update".Localize());
updateButton.Margin = new BorderDouble(5); updateButton.Margin = new BorderDouble(5);
updateButton.HAnchor = HAnchor.Right; updateButton.HAnchor = HAnchor.Right;
updateButton.Enabled = false; // starts out disabled as there are no holes selected
updateButton.Click += (s, e) => updateButton.Click += (s, e) =>
{ {
// make sure the mesh on the group is not visible // make sure the mesh on the group is not visible
@ -112,6 +111,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
ProcessBooleans(group); ProcessBooleans(group);
}; };
int checkedCount = 0;
List<GuiWidget> radioSiblings = new List<GuiWidget>(); List<GuiWidget> radioSiblings = new List<GuiWidget>();
for (int i = 0; i < children.Count; i++) for (int i = 0; i < children.Count; i++)
{ {
@ -161,6 +161,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
}; };
tabContainer.AddChild(rowContainer); tabContainer.AddChild(rowContainer);
checkedCount += checkBox.Checked ? 1 : 0;
}
if(checkedCount == 0) // no items selected
{
// select the last item
if (tabContainer.Decendants().Where((d) => d is ICheckbox).Last() is ICheckbox firstCheckBox)
{
firstCheckBox.Checked = true;
}
} }
// add this last so it is at the bottom // add this last so it is at the bottom

View file

@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
if (group is MeshWrapperOperation) if (group is MeshWrapperOperation)
{ {
AddHoleSelector(view3DWidget, mainContainer, theme); AddSubtractSelector(view3DWidget, mainContainer, theme);
} }
return mainContainer; return mainContainer;
@ -69,11 +69,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
typeof(MeshWrapperOperation), typeof(MeshWrapperOperation),
}; };
private void AddHoleSelector(View3DWidget view3DWidget, FlowLayoutWidget tabContainer, ThemeConfig theme) private void AddSubtractSelector(View3DWidget view3DWidget, FlowLayoutWidget tabContainer, ThemeConfig theme)
{ {
var children = group.Children.ToList(); var children = group.Children.ToList();
tabContainer.AddChild(new TextWidget("Set as Hole") tabContainer.AddChild(new TextWidget("Set Subtract")
{ {
TextColor = ActiveTheme.Instance.PrimaryTextColor, TextColor = ActiveTheme.Instance.PrimaryTextColor,
HAnchor = HAnchor.Left, HAnchor = HAnchor.Left,
@ -84,7 +84,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
var updateButton = theme.ButtonFactory.Generate("Update".Localize()); var updateButton = theme.ButtonFactory.Generate("Update".Localize());
updateButton.Margin = new BorderDouble(5); updateButton.Margin = new BorderDouble(5);
updateButton.HAnchor = HAnchor.Right; updateButton.HAnchor = HAnchor.Right;
updateButton.Enabled = false; // starts out disabled as there are no holes selected
updateButton.Click += (s, e) => updateButton.Click += (s, e) =>
{ {
// make sure the mesh on the group is not visible // make sure the mesh on the group is not visible
@ -92,6 +91,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
ProcessBooleans(group); ProcessBooleans(group);
}; };
int checkedCount = 0;
List<GuiWidget> radioSiblings = new List<GuiWidget>(); List<GuiWidget> radioSiblings = new List<GuiWidget>();
for (int i = 0; i < children.Count; i++) for (int i = 0; i < children.Count; i++)
{ {
@ -141,6 +141,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
}; };
tabContainer.AddChild(rowContainer); tabContainer.AddChild(rowContainer);
checkedCount += checkBox.Checked ? 1 : 0;
}
if (checkedCount == 0) // no items selected
{
// select the last item
if (tabContainer.Decendants().Where((d) => d is ICheckbox).Last() is ICheckbox firstCheckBox)
{
firstCheckBox.Checked = true;
}
} }
// add this last so it is at the bottom // add this last so it is at the bottom

@ -1 +1 @@
Subproject commit 6151fbf50c3e657dc1e6c5059f8a9c12c1745d03 Subproject commit 65aa386c3cd4aef5531c4c362031c340942a8ccb