Improving ungroup
issue: MatterHackers/MCCentral#4129 Content moves when ungrouped
This commit is contained in:
parent
52d22d32f0
commit
30cef6ef5a
5 changed files with 15 additions and 31 deletions
|
|
@ -423,7 +423,17 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
TitleResolver = () => "Ungroup".Localize(),
|
||||
Action = (scene) => scene.UngroupSelection(),
|
||||
IsEnabled = (scene) => scene.SelectedItem != null,
|
||||
IsEnabled = (scene) =>
|
||||
{
|
||||
var selectedItem = scene.SelectedItem;
|
||||
if(selectedItem != null)
|
||||
{
|
||||
var hasSingleMesh = selectedItem.Mesh != null && selectedItem.Children.Count == 0;
|
||||
return hasSingleMesh || selectedItem is GroupObject3D;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
Icon = AggContext.StaticData.LoadIcon("ungroup.png", 16, 16).SetPreMultiply(),
|
||||
},
|
||||
new SceneSelectionSeparator(),
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
{
|
||||
public class GroupObject3D : Object3D
|
||||
{
|
||||
public override bool CanApply => true;
|
||||
|
||||
public GroupObject3D()
|
||||
{
|
||||
Name = "Group".Localize();
|
||||
|
|
|
|||
|
|
@ -108,34 +108,6 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
}
|
||||
}
|
||||
|
||||
public static void CopyProperties(this IObject3D copyTo, IObject3D copyFrom, Object3DPropertyFlags flags)
|
||||
{
|
||||
if (flags.HasFlag(Object3DPropertyFlags.Matrix))
|
||||
{
|
||||
copyTo.Matrix = copyFrom.Matrix;
|
||||
}
|
||||
if (flags.HasFlag(Object3DPropertyFlags.Color))
|
||||
{
|
||||
copyTo.Color = copyFrom.Color;
|
||||
}
|
||||
if (flags.HasFlag(Object3DPropertyFlags.MaterialIndex))
|
||||
{
|
||||
copyTo.MaterialIndex = copyFrom.MaterialIndex;
|
||||
}
|
||||
if (flags.HasFlag(Object3DPropertyFlags.Name))
|
||||
{
|
||||
copyTo.Name = copyFrom.Name;
|
||||
}
|
||||
if (flags.HasFlag(Object3DPropertyFlags.OutputType))
|
||||
{
|
||||
copyTo.OutputType = copyFrom.OutputType;
|
||||
}
|
||||
if (flags.HasFlag(Object3DPropertyFlags.Visible))
|
||||
{
|
||||
copyTo.Visible = copyFrom.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
public static IObject3D Translate(this IObject3D objectToTranslate, double x = 0, double y = 0, double z = 0, string name = "")
|
||||
{
|
||||
return objectToTranslate.Translate(new Vector3(x, y, z), name);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
public override void Apply(UndoBuffer undoBuffer)
|
||||
{
|
||||
// change this from a text object to a group
|
||||
var newContainer = new Object3D();
|
||||
var newContainer = new GroupObject3D();
|
||||
newContainer.CopyProperties(this, Object3DPropertyFlags.All);
|
||||
foreach (var child in this.Children)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 53d38d57d01d8bf08a8e79a8313a4137293c628e
|
||||
Subproject commit c5fc89ec56e43e7e01ce1458364e400b678e5073
|
||||
Loading…
Add table
Add a link
Reference in a new issue