improve primary operations
This commit is contained in:
parent
3f8eeda65b
commit
0416a941d7
14 changed files with 83 additions and 121 deletions
|
|
@ -68,8 +68,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private static Dictionary<string, SceneOperation> OperationsById { get; } = new Dictionary<string, SceneOperation>();
|
||||
|
||||
private static Dictionary<Type, List<SceneOperation>> PrimaryOperations { get; } = new Dictionary<Type, List<SceneOperation>>();
|
||||
|
||||
public static SceneOperation AddBaseOperation()
|
||||
{
|
||||
return new SceneOperation("AddBase")
|
||||
|
|
@ -264,16 +262,6 @@ namespace MatterHackers.MatterControl
|
|||
return null;
|
||||
}
|
||||
|
||||
public static IEnumerable<SceneOperation> GetPrimaryOperations(Type type)
|
||||
{
|
||||
if (PrimaryOperations.ContainsKey(type))
|
||||
{
|
||||
return PrimaryOperations[type];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PopupMenu GetToolbarOverflowMenu(ThemeConfig theme, ISceneContext sceneContext, Func<SceneOperation, bool> includeInToolbarOverflow = null)
|
||||
{
|
||||
var popupMenu = new PopupMenu(theme);
|
||||
|
|
@ -712,7 +700,6 @@ namespace MatterHackers.MatterControl
|
|||
return true;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
// path items
|
||||
if (includePaths
|
||||
&& selectedItem.VisiblePaths().Count() > 1
|
||||
|
|
@ -720,7 +707,6 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -742,9 +728,7 @@ namespace MatterHackers.MatterControl
|
|||
ArrangeAllPartsOperation(),
|
||||
new SceneSelectionSeparator(),
|
||||
LayFlatOperation(),
|
||||
#if DEBUG
|
||||
RebuildOperation(),
|
||||
#endif
|
||||
GroupOperation(),
|
||||
UngroupOperation(),
|
||||
new SceneSelectionSeparator(),
|
||||
|
|
@ -886,42 +870,6 @@ namespace MatterHackers.MatterControl
|
|||
// register legacy types so they still show, they don't have ui to create so they don't have icons set dynamically
|
||||
Icons.Add(typeof(AlignObject3D), (theme) => StaticData.Instance.LoadIcon("align_left_dark.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply());
|
||||
|
||||
// image operations
|
||||
PrimaryOperations.Add(typeof(ImageObject3D), new List<SceneOperation> { SceneOperations.ById("ImageConverter"), SceneOperations.ById("ImageToPath"), });
|
||||
|
||||
// path operations
|
||||
PrimaryOperations.Add(typeof(ImageToPathObject3D_2), new List<SceneOperation>
|
||||
{
|
||||
SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("SmoothPath")
|
||||
});
|
||||
PrimaryOperations.Add(typeof(SmoothPathObject3D), new List<SceneOperation>
|
||||
{
|
||||
SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("InflatePath"), SceneOperations.ById("OutlinePath")
|
||||
});
|
||||
PrimaryOperations.Add(typeof(TextObject3D), new List<SceneOperation>
|
||||
{
|
||||
SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("InflatePath"), SceneOperations.ById("OutlinePath")
|
||||
});
|
||||
PrimaryOperations.Add(typeof(BoxPathObject3D), new List<SceneOperation>
|
||||
{
|
||||
SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("InflatePath"), SceneOperations.ById("OutlinePath")
|
||||
});
|
||||
PrimaryOperations.Add(typeof(InflatePathObject3D), new List<SceneOperation>
|
||||
{
|
||||
SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("OutlinePath")
|
||||
});
|
||||
PrimaryOperations.Add(typeof(OutlinePathObject3D), new List<SceneOperation>
|
||||
{
|
||||
SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("InflatePath")
|
||||
});
|
||||
PrimaryOperations.Add(typeof(LinearExtrudeObject3D), new List<SceneOperation>
|
||||
{
|
||||
SceneOperations.ById("AddBase")
|
||||
});
|
||||
|
||||
// default operations
|
||||
PrimaryOperations.Add(typeof(Object3D), new List<SceneOperation> { SceneOperations.ById("Scale") });
|
||||
|
||||
Icons.Add(typeof(ImageObject3D), (theme) => StaticData.Instance.LoadIcon("image_converter.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply());
|
||||
}
|
||||
|
||||
|
|
@ -933,13 +881,11 @@ namespace MatterHackers.MatterControl
|
|||
TitleGetter = () => "Combine".Localize(),
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
#if DEBUG
|
||||
if (sceneContext.Scene.SelectedItem.VisiblePaths().Count() > 1)
|
||||
{
|
||||
new MergePathObject3D("Combine".Localize(), ClipperLib.ClipType.ctUnion).WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
new CombineObject3D_2().WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||
}
|
||||
|
|
@ -1102,13 +1048,11 @@ namespace MatterHackers.MatterControl
|
|||
TitleGetter = () => "Intersect".Localize(),
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
#if DEBUG
|
||||
if (sceneContext.Scene.SelectedItem.VisiblePaths().Count() > 1)
|
||||
{
|
||||
new MergePathObject3D("Intersect".Localize(), ClipperLib.ClipType.ctIntersection).WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
new IntersectionObject3D_2().WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||
}
|
||||
|
|
@ -1382,13 +1326,11 @@ namespace MatterHackers.MatterControl
|
|||
TitleGetter = () => "Subtract".Localize(),
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
#if DEBUG
|
||||
if (sceneContext.Scene.SelectedItem.VisiblePaths().Count() > 1)
|
||||
{
|
||||
new SubtractPathObject3D().WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
var subtractItem = new SubtractObject3D_2();
|
||||
subtractItem.WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||
|
|
@ -1539,5 +1481,4 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
IEnumerable<SceneOperation> GetOperations();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
if (plugin is IExportWithOptions pluginWithOptions)
|
||||
{
|
||||
var optionPanel = pluginWithOptions.GetOptionsPanel(libraryItems);
|
||||
var optionPanel = pluginWithOptions.GetOptionsPanel(libraryItems, pluginButton);
|
||||
if (optionPanel != null)
|
||||
{
|
||||
optionPanel.HAnchor = HAnchor.Stretch;
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
|
|||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[HideMeterialAndColor]
|
||||
public class ImageToPathObject3D_2 : Object3D, IImageProvider, IEditorDraw, IObject3DControlsProvider, IPropertyGridModifier, IEditorWidgetModifier
|
||||
{
|
||||
public class ImageToPathObject3D_2 : PathObject3D, IImageProvider, IEditorDraw, IObject3DControlsProvider, IPropertyGridModifier, IEditorWidgetModifier
|
||||
{
|
||||
public ImageToPathObject3D_2()
|
||||
{
|
||||
Name = "Image to Path".Localize();
|
||||
|
|
@ -178,16 +178,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
object3DControlsLayer.AddControls(ControlTypes.Standard2D);
|
||||
}
|
||||
|
||||
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
||||
{
|
||||
this.DrawPath();
|
||||
}
|
||||
|
||||
public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
||||
{
|
||||
return this.GetWorldspaceAabbOfDrawPath();
|
||||
}
|
||||
|
||||
public override bool CanApply => true;
|
||||
|
||||
[HideFromEditor]
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
Sharp,
|
||||
}
|
||||
|
||||
public class InflatePathObject3D : Object3D, IEditorDraw, IObject3DControlsProvider
|
||||
{
|
||||
public class InflatePathObject3D : PathObject3D, IEditorDraw, IObject3DControlsProvider
|
||||
{
|
||||
public InflatePathObject3D()
|
||||
{
|
||||
Name = "Inflate Path".Localize();
|
||||
|
|
@ -135,15 +135,5 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
|
||||
return joinType;
|
||||
}
|
||||
|
||||
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
||||
{
|
||||
this.DrawPath();
|
||||
}
|
||||
|
||||
public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
||||
{
|
||||
return this.GetWorldspaceAabbOfDrawPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -45,8 +45,8 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
public class OutlinePathObject3D : Object3D, IEditorDraw, IObject3DControlsProvider
|
||||
{
|
||||
public class OutlinePathObject3D : PathObject3D, IEditorDraw, IObject3DControlsProvider
|
||||
{
|
||||
public OutlinePathObject3D()
|
||||
{
|
||||
Name = "Outline Path".Localize();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
public class SmoothPathObject3D : Object3D, IEditorDraw, IObject3DControlsProvider
|
||||
public class SmoothPathObject3D : PathObject3D, IEditorDraw, IObject3DControlsProvider
|
||||
{
|
||||
public SmoothPathObject3D()
|
||||
{
|
||||
|
|
@ -178,15 +178,5 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
|
||||
VertexStorage = outputPolygons.CreateVertexStorage();
|
||||
}
|
||||
|
||||
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
||||
{
|
||||
this.DrawPath();
|
||||
}
|
||||
|
||||
public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
||||
{
|
||||
return this.GetWorldspaceAabbOfDrawPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ namespace MatterHackers.MatterControl.DesignTools.Primitives
|
|||
public BoxPathObject3D()
|
||||
{
|
||||
Name = "Box".Localize();
|
||||
Color = MatterHackers.MatterControl.DesignTools.Operations.Object3DExtensions.PrimitiveColors["Cube"];
|
||||
Color = Operations.Object3DExtensions.PrimitiveColors["Cube"];
|
||||
}
|
||||
|
||||
public static double MinEdgeSize = .001;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
|
@ -48,8 +49,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
|
||||
[HideMeterialAndColor]
|
||||
public class ImageObject3D : AssetObject3D, IImageProvider, IObject3DControlsProvider, IEditorWidgetModifier
|
||||
{
|
||||
public class ImageObject3D : AssetObject3D, IImageProvider, IObject3DControlsProvider, IEditorWidgetModifier, IPrimaryOperationsSpecifier
|
||||
{
|
||||
private const double DefaultSizeMm = 60;
|
||||
|
||||
private string _assetPath;
|
||||
|
|
@ -400,5 +401,11 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<SceneOperation> GetOperations()
|
||||
{
|
||||
yield return SceneOperations.ById("ImageConverter");
|
||||
yield return SceneOperations.ById("ImageToPath");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -60,8 +61,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
|
||||
[HideChildrenFromTreeView]
|
||||
public class TextObject3D : Object3D, IPropertyGridModifier, IEditorDraw
|
||||
{
|
||||
public class TextObject3D : Object3D, IPropertyGridModifier, IEditorDraw, IPrimaryOperationsSpecifier
|
||||
{
|
||||
private bool refreshToolBar;
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
|
|
@ -367,5 +368,16 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
return this.GetWorldspaceAabbOfDrawPath();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<SceneOperation> GetOperations()
|
||||
{
|
||||
if (Output == OutputDimensions.Output2D)
|
||||
{
|
||||
return PathObject3D.GetOperations(this.GetType());
|
||||
}
|
||||
|
||||
// return no enumerations
|
||||
return Enumerable.Empty<SceneOperation>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
|
||||
public virtual bool ExportPossible(ILibraryAsset libraryItem) => true;
|
||||
|
||||
public GuiWidget GetOptionsPanel(IEnumerable<ILibraryItem> libraryItems)
|
||||
public GuiWidget GetOptionsPanel(IEnumerable<ILibraryItem> libraryItems, RadioButton radioButton)
|
||||
{
|
||||
var container = new FlowLayoutWidget()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,6 +62,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public interface IExportWithOptions : IExportPlugin
|
||||
{
|
||||
GuiWidget GetOptionsPanel(IEnumerable<ILibraryItem> libraryItems);
|
||||
}
|
||||
GuiWidget GetOptionsPanel(IEnumerable<ILibraryItem> libraryItems, RadioButton radioButton);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
{
|
||||
private bool mergeMeshes = true;
|
||||
|
||||
public int Priority => 2;
|
||||
private bool saveMultipleStls = false;
|
||||
|
||||
public int Priority => 2;
|
||||
|
||||
public string ButtonText => "STL File".Localize();
|
||||
|
||||
|
|
@ -82,8 +84,8 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
first = false;
|
||||
}
|
||||
|
||||
if (!await MeshExport.ExportMesh(item, filename, mergeMeshes, progress))
|
||||
{
|
||||
if (!await MeshExport.ExportMesh(item, filename, mergeMeshes, progress, saveMultipleStls))
|
||||
{
|
||||
badExports.Add(item.Name);
|
||||
}
|
||||
}
|
||||
|
|
@ -103,8 +105,8 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
};
|
||||
}
|
||||
|
||||
public GuiWidget GetOptionsPanel(IEnumerable<ILibraryItem> libraryItems)
|
||||
{
|
||||
public GuiWidget GetOptionsPanel(IEnumerable<ILibraryItem> libraryItems, RadioButton radioButton)
|
||||
{
|
||||
var exportMeshCount = 0;
|
||||
foreach (var item in libraryItems.OfType<ILibraryAsset>())
|
||||
{
|
||||
|
|
@ -119,19 +121,21 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var container = new FlowLayoutWidget()
|
||||
{
|
||||
|
||||
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
Margin = new BorderDouble(left: 40, bottom: 10),
|
||||
};
|
||||
|
||||
var theme = AppContext.Theme;
|
||||
|
||||
var unionAllPartsCheckbox = new CheckBox("Merge faces into single mesh".Localize(), theme.TextColor, 10)
|
||||
{
|
||||
// add union checkbox
|
||||
var unionAllPartsCheckbox = new CheckBox("Performe Union".Localize(), theme.TextColor, 10)
|
||||
{
|
||||
Checked = true,
|
||||
Cursor = Cursors.Hand,
|
||||
ToolTipText = "Disable to expart all faces without merging".Localize()
|
||||
ToolTipText = "Performe a union before exporting. Might be slower but can clean up some models.".Localize(),
|
||||
Margin = new BorderDouble(0, 3)
|
||||
};
|
||||
unionAllPartsCheckbox.CheckedStateChanged += (s, e) =>
|
||||
{
|
||||
|
|
@ -139,7 +143,22 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
};
|
||||
container.AddChild(unionAllPartsCheckbox);
|
||||
|
||||
return container;
|
||||
}
|
||||
// add separate checkbox
|
||||
var saveAsSeparateSTLsCheckbox = new CheckBox("Save Each Separately".Localize(), theme.TextColor, 10)
|
||||
{
|
||||
Checked = false,
|
||||
Cursor = Cursors.Hand,
|
||||
ToolTipText = "Save every object as a separate STL using its name. The save filename will be used if no name can be found.".Localize(),
|
||||
Margin = new BorderDouble(0, 3)
|
||||
};
|
||||
saveAsSeparateSTLsCheckbox.CheckedStateChanged += (s, e) =>
|
||||
{
|
||||
radioButton.InvokeClick();
|
||||
saveMultipleStls = saveAsSeparateSTLsCheckbox.Checked;
|
||||
};
|
||||
container.AddChild(saveAsSeparateSTLsCheckbox);
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private void TaskDetails_ProgressChanged(object sender, (double progress0To1, string status) e)
|
||||
{
|
||||
if (e.status.StartsWith("[[send to terminal]]"))
|
||||
if (e.status != null
|
||||
&& e.status.StartsWith("[[send to terminal]]"))
|
||||
{
|
||||
// strip of the prefix
|
||||
e.status = e.status.Substring("[[send to terminal]]".Length);
|
||||
|
|
|
|||
|
|
@ -3514,6 +3514,12 @@ Translated:PEI Bed Temperature
|
|||
English:Percentage of
|
||||
Translated:Percentage of
|
||||
|
||||
English:Performe a union before exporting. Might be slower but can clean up some models.
|
||||
Translated:Performe a union before exporting. Might be slower but can clean up some models.
|
||||
|
||||
English:Performe Union
|
||||
Translated:Performe Union
|
||||
|
||||
English:Perimeter Acceleration
|
||||
Translated:Perimeter Acceleration
|
||||
|
||||
|
|
@ -4363,6 +4369,12 @@ Translated:Save changes ?
|
|||
English:Save Changes?
|
||||
Translated:Save Changes?
|
||||
|
||||
English:Save Each Separately
|
||||
Translated:Save Each Separately
|
||||
|
||||
English:Save every object as a separate STL using its name. The save filename will be used if no name can be found.
|
||||
Translated:Save every object as a separate STL using its name. The save filename will be used if no name can be found.
|
||||
|
||||
English:Save file:
|
||||
Translated:Save file:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue