Improved subtract selection rendering
does not modify the part colors only the rendering colors Refactoring
This commit is contained in:
parent
1b20984dd1
commit
201c9d1d65
8 changed files with 71 additions and 25 deletions
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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.DataConverters3D;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public interface ISelectableChildContainer
|
||||
{
|
||||
SelectedChildren SelectedChildren
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
|
||||
[ShowAsList]
|
||||
[DisplayName("Anchor")]
|
||||
public ChildrenSelector AnchorObjectSelector { get; set; } = new ChildrenSelector();
|
||||
public SelectedChildren AnchorObjectSelector { get; set; } = new SelectedChildren();
|
||||
|
||||
public bool Advanced { get; set; } = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
typeof(Color),
|
||||
typeof(Vector2), typeof(Vector3),
|
||||
typeof(DirectionVector), typeof(DirectionAxis),
|
||||
typeof(ChildrenSelector),
|
||||
typeof(SelectedChildren),
|
||||
typeof(ImageBuffer),
|
||||
typeof(List<string>)
|
||||
};
|
||||
|
|
@ -435,7 +435,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
rowContainer.AddChild(row2);
|
||||
}
|
||||
else if (propertyValue is ChildrenSelector childSelector)
|
||||
else if (propertyValue is SelectedChildren childSelector)
|
||||
{
|
||||
var showAsList = property.PropertyInfo.GetCustomAttributes(true).OfType<ShowAsListAttribute>().FirstOrDefault() != null;
|
||||
if (showAsList)
|
||||
|
|
@ -446,7 +446,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
RegisterValueChanged(field,
|
||||
(valueString) =>
|
||||
{
|
||||
var childrenSelector = new ChildrenSelector();
|
||||
var childrenSelector = new SelectedChildren();
|
||||
foreach (var child in valueString.Split(','))
|
||||
{
|
||||
childrenSelector.Add(child);
|
||||
|
|
@ -608,7 +608,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return new ImageWidget(imageBuffer);
|
||||
}
|
||||
|
||||
private static GuiWidget CreateSelector(ChildrenSelector childSelector, IObject3D parent, ThemeConfig theme)
|
||||
private static GuiWidget CreateSelector(SelectedChildren childSelector, IObject3D parent, ThemeConfig theme)
|
||||
{
|
||||
GuiWidget tabContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
|
||||
|
|
@ -618,16 +618,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
using (child.RebuildLock())
|
||||
{
|
||||
if (!childSelector.Contains(child.ID)
|
||||
|| tabContainer.HasBeenClosed)
|
||||
{
|
||||
child.Color = new Color(child.WorldColor(), 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
child.Color = new Color(child.WorldColor(), 200);
|
||||
}
|
||||
|
||||
if (selectionChanged)
|
||||
{
|
||||
child.Visible = true;
|
||||
|
|
|
|||
|
|
@ -44,14 +44,16 @@ using MatterHackers.VectorMath;
|
|||
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||
{
|
||||
[ShowUpdateButton]
|
||||
public class SubtractAndReplaceObject3D : MeshWrapperObject3D
|
||||
public class SubtractAndReplaceObject3D : MeshWrapperObject3D, ISelectableChildContainer
|
||||
{
|
||||
public SubtractAndReplaceObject3D()
|
||||
{
|
||||
Name = "Subtract and Replace";
|
||||
}
|
||||
|
||||
public ChildrenSelector ItemsToSubtract { get; set; } = new ChildrenSelector();
|
||||
public SelectedChildren ItemsToSubtract { get; set; } = new SelectedChildren();
|
||||
|
||||
public SelectedChildren SelectedChildren => ItemsToSubtract;
|
||||
|
||||
public override void OnInvalidate(InvalidateArgs invalidateType)
|
||||
{
|
||||
|
|
@ -81,7 +83,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
|||
ResetMeshWrapperMeshes(Object3DPropertyFlags.All, CancellationToken.None);
|
||||
|
||||
// spin up a task to calculate the paint
|
||||
ApplicationController.Instance.Tasks.Execute("Subtract".Localize(), null, (reporter, cancellationToken) =>
|
||||
ApplicationController.Instance.Tasks.Execute("Replacing".Localize(), null, (reporter, cancellationToken) =>
|
||||
{
|
||||
var progressStatus = new ProgressStatus();
|
||||
|
||||
|
|
|
|||
|
|
@ -160,14 +160,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
|||
}
|
||||
|
||||
[ShowUpdateButton]
|
||||
public class SubtractObject3D : MeshWrapperObject3D
|
||||
public class SubtractObject3D : MeshWrapperObject3D, ISelectableChildContainer
|
||||
{
|
||||
public SubtractObject3D()
|
||||
{
|
||||
Name = "Subtract";
|
||||
}
|
||||
|
||||
public ChildrenSelector ItemsToSubtract { get; set; } = new ChildrenSelector();
|
||||
public SelectedChildren ItemsToSubtract { get; set; } = new SelectedChildren();
|
||||
|
||||
public SelectedChildren SelectedChildren => ItemsToSubtract;
|
||||
|
||||
public void Subtract()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ using MatterHackers.Agg.UI;
|
|||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
using MatterHackers.MatterControl.DesignTools.EditableTypes;
|
||||
using MatterHackers.MatterControl.DesignTools.Operations;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
|
|
@ -453,8 +454,10 @@ namespace MatterHackers.MeshVisualizer
|
|||
|
||||
public bool SuppressUiVolumes { get; set; } = false;
|
||||
|
||||
private void DrawObject(IObject3D object3D, List<Object3DView> transparentMeshes, bool parentSelected, DrawEventArgs e)
|
||||
private void DrawObject(IObject3D object3D, List<Object3DView> transparentMeshes, DrawEventArgs e)
|
||||
{
|
||||
var selectedItem = scene.SelectedItem;
|
||||
|
||||
foreach (var item in object3D.VisibleMeshes())
|
||||
{
|
||||
// check for correct persistable rendering
|
||||
|
|
@ -488,6 +491,14 @@ namespace MatterHackers.MeshVisualizer
|
|||
|
||||
Color drawColor = GetItemColor(item);
|
||||
|
||||
if(selectedItem is ISelectableChildContainer selectableChildContainer)
|
||||
{
|
||||
if(selectableChildContainer.SelectedChildren.Contains(item.ID))
|
||||
{
|
||||
drawColor = new Color(drawColor, 200);
|
||||
}
|
||||
}
|
||||
|
||||
bool isDebugItem = (item == scene.DebugItem);
|
||||
|
||||
if (!sceneContext.ViewState.ModelView)
|
||||
|
|
@ -524,7 +535,6 @@ namespace MatterHackers.MeshVisualizer
|
|||
transparentMeshes.Add(new Object3DView(item, drawColor));
|
||||
}
|
||||
|
||||
var selectedItem = scene.SelectedItem;
|
||||
bool isSelected = selectedItem != null
|
||||
&& (selectedItem.DescendantsAndSelf().Any((i) => i == item)
|
||||
|| selectedItem.Parents<ModifiedMeshObject3D>().Any((mw) => mw == item));
|
||||
|
|
@ -721,7 +731,7 @@ namespace MatterHackers.MeshVisualizer
|
|||
{
|
||||
if (object3D.Visible)
|
||||
{
|
||||
DrawObject(object3D, transparentMeshes, false, e);
|
||||
DrawObject(object3D, transparentMeshes, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue