refactoring
This commit is contained in:
parent
d4ca18a8c7
commit
2029c55029
5 changed files with 983 additions and 978 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -65,6 +65,10 @@ namespace MatterHackers.Agg.UI
|
|||
/// </summary>
|
||||
public Type OperationType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if this operation should be visible when for a specific selected item. Usef for right click
|
||||
/// and context menu in properties panel.
|
||||
/// </summary>
|
||||
public Func<ISceneContext, bool> IsVisible { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ using MatterHackers.PolygonMesh;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public class CubeObject3D : PrimitiveObject3D, IObject3DControlsProvider
|
||||
public class CubeObject3D : PrimitiveObject3D, IObjectWithHeight
|
||||
{
|
||||
public CubeObject3D()
|
||||
{
|
||||
|
|
@ -50,21 +50,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public double Height { get; set; } = 20;
|
||||
|
||||
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||
{
|
||||
object3DControlsLayer.AddDefaultControls();
|
||||
object3DControlsLayer.AddWorldRotateControls();
|
||||
var object3DControls = object3DControlsLayer.Object3DControls;
|
||||
|
||||
object3DControls.Add(new ScaleMatrixTopControl(object3DControlsLayer));
|
||||
// object3DControls.Add(new ScaleHeightControl(object3DControlsLayer));
|
||||
|
||||
object3DControls.Add(new ScaleCornerControl(object3DControlsLayer, 0));
|
||||
object3DControls.Add(new ScaleCornerControl(object3DControlsLayer, 1));
|
||||
object3DControls.Add(new ScaleCornerControl(object3DControlsLayer, 2));
|
||||
object3DControls.Add(new ScaleCornerControl(object3DControlsLayer, 3));
|
||||
}
|
||||
|
||||
public static async Task<CubeObject3D> Create()
|
||||
{
|
||||
var item = new CubeObject3D();
|
||||
|
|
@ -114,4 +99,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IObjectWithHeight
|
||||
{
|
||||
double Height { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public void SetActiveItem(ISceneContext sceneContext)
|
||||
{
|
||||
var selectedItem = sceneContext.Scene.SelectedItem;
|
||||
var selectedItem = sceneContext?.Scene?.SelectedItem;
|
||||
if (this.item == selectedItem)
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private void Scene_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
var selectedItem = scene.SelectedItem;
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
DisposeCurrentSelectionObject3DControls();
|
||||
|
|
@ -155,14 +156,23 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
// On selection change, update state for mappings
|
||||
Object3DControls.Clear();
|
||||
|
||||
if (scene.SelectedItem is IObject3DControlsProvider provider)
|
||||
if (selectedItem is IObject3DControlsProvider provider)
|
||||
{
|
||||
provider.AddObject3DControls(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add default controls
|
||||
Object3DControls.Add(new ScaleMatrixTopControl(this));
|
||||
if (selectedItem is IObjectWithHeight heightObject)
|
||||
{
|
||||
// Object3DControls.Add(new ScaleHeightControl(this));
|
||||
Object3DControls.Add(new ScaleMatrixTopControl(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
Object3DControls.Add(new ScaleMatrixTopControl(this));
|
||||
}
|
||||
|
||||
Object3DControls.Add(new ScaleCornerControl(this, 0));
|
||||
Object3DControls.Add(new ScaleCornerControl(this, 1));
|
||||
Object3DControls.Add(new ScaleCornerControl(this, 2));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue