Refactoring to build a Height scaling top control
This commit is contained in:
parent
5c2308a134
commit
8511191abb
8 changed files with 74 additions and 52 deletions
|
|
@ -296,7 +296,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IObject3DControl> GetObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ using MatterHackers.VectorMath;
|
||||||
|
|
||||||
namespace MatterHackers.Plugins.EditorTools
|
namespace MatterHackers.Plugins.EditorTools
|
||||||
{
|
{
|
||||||
public class ScaleTopControl : Object3DControl
|
public abstract class ScaleTopControl : Object3DControl
|
||||||
{
|
{
|
||||||
private IObject3D activeSelectedItem;
|
private IObject3D activeSelectedItem;
|
||||||
private PlaneShape hitPlane;
|
private PlaneShape hitPlane;
|
||||||
|
|
@ -66,7 +66,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
public ScaleTopControl(IObject3DControlContext context)
|
public ScaleTopControl(IObject3DControlContext context)
|
||||||
: base(context)
|
: base(context)
|
||||||
{
|
{
|
||||||
theme = MatterControl.AppContext.Theme;
|
theme = AppContext.Theme;
|
||||||
|
|
||||||
zValueDisplayInfo = new InlineEditControl()
|
zValueDisplayInfo = new InlineEditControl()
|
||||||
{
|
{
|
||||||
|
|
@ -372,4 +372,20 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
Object3DControlContext.GuiSurface.BeforeDraw -= Object3DControl_BeforeDraw;
|
Object3DControlContext.GuiSurface.BeforeDraw -= Object3DControl_BeforeDraw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ScaleMatrixTopControl : ScaleTopControl
|
||||||
|
{
|
||||||
|
public ScaleMatrixTopControl(IObject3DControlContext context)
|
||||||
|
: base(context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ScaleHeightControl : ScaleTopControl
|
||||||
|
{
|
||||||
|
public ScaleHeightControl(IObject3DControlContext context)
|
||||||
|
: base(context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,14 +28,15 @@ either expressed or implied, of the FreeBSD Project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MatterHackers.Agg;
|
|
||||||
using MatterHackers.DataConverters3D;
|
using MatterHackers.DataConverters3D;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||||
|
using MatterHackers.Plugins.EditorTools;
|
||||||
using MatterHackers.PolygonMesh;
|
using MatterHackers.PolygonMesh;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.DesignTools
|
namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
public class CubeObject3D : PrimitiveObject3D
|
public class CubeObject3D : PrimitiveObject3D, IObject3DControlsProvider
|
||||||
{
|
{
|
||||||
public CubeObject3D()
|
public CubeObject3D()
|
||||||
{
|
{
|
||||||
|
|
@ -49,6 +50,21 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
public double Height { get; set; } = 20;
|
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()
|
public static async Task<CubeObject3D> Create()
|
||||||
{
|
{
|
||||||
var item = new CubeObject3D();
|
var item = new CubeObject3D();
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
public interface IObject3DControlsProvider
|
public interface IObject3DControlsProvider
|
||||||
{
|
{
|
||||||
List<IObject3DControl> GetObject3DControls(Object3DControlsLayer object3DControlsLayer);
|
void AddObject3DControls(Object3DControlsLayer object3DControlsLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -129,14 +129,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IObject3DControl> GetObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||||
{
|
{
|
||||||
return new List<IObject3DControl>
|
object3DControlsLayer.AddDefaultControls();
|
||||||
{
|
|
||||||
new MoveInZControl(object3DControlsLayer),
|
|
||||||
new SelectionShadow(object3DControlsLayer),
|
|
||||||
new SnappingIndicators(object3DControlsLayer),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageBuffer LoadImage()
|
private ImageBuffer LoadImage()
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
public class MeasureToolObject3D : Object3D, IObject3DControlsProvider, IEditorDraw
|
public class MeasureToolObject3D : Object3D, IObject3DControlsProvider, IEditorDraw
|
||||||
{
|
{
|
||||||
private static Mesh shape = null;
|
private static Mesh shape = null;
|
||||||
private List<IObject3DControl> editorControls;
|
private List<IObject3DControl> editorControls = null;
|
||||||
|
|
||||||
public MeasureToolObject3D()
|
public MeasureToolObject3D()
|
||||||
{
|
{
|
||||||
|
|
@ -88,7 +88,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
public override bool Persistable => false;
|
public override bool Persistable => false;
|
||||||
|
|
||||||
public List<IObject3DControl> GetObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||||
{
|
{
|
||||||
if (editorControls == null)
|
if (editorControls == null)
|
||||||
{
|
{
|
||||||
|
|
@ -133,7 +133,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return editorControls;
|
object3DControlsLayer.Object3DControls.AddRange(editorControls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async void OnInvalidate(InvalidateArgs invalidateType)
|
public override async void OnInvalidate(InvalidateArgs invalidateType)
|
||||||
|
|
|
||||||
|
|
@ -59,22 +59,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
|
|
||||||
public bool DrawOpenGLContent { get; set; } = true;
|
public bool DrawOpenGLContent { get; set; } = true;
|
||||||
|
|
||||||
private List<IObject3DControl> CurrentObject3DControls { get; set; } = new List<IObject3DControl>();
|
public List<IObject3DControl> Object3DControls { get; set; } = new List<IObject3DControl>();
|
||||||
|
|
||||||
public IEnumerable<IObject3DControl> Object3DControls
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (CurrentObject3DControls == null)
|
|
||||||
{
|
|
||||||
return Enumerable.Empty<IObject3DControl>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return CurrentObject3DControls;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly LightingData lighting = new LightingData();
|
private readonly LightingData lighting = new LightingData();
|
||||||
private GuiWidget renderSource;
|
private GuiWidget renderSource;
|
||||||
|
|
@ -168,33 +153,44 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
DisposeCurrentSelectionObject3DControls();
|
DisposeCurrentSelectionObject3DControls();
|
||||||
|
|
||||||
// On selection change, update state for mappings
|
// On selection change, update state for mappings
|
||||||
CurrentObject3DControls = null;
|
Object3DControls.Clear();
|
||||||
|
|
||||||
if (scene.SelectedItem is IObject3DControlsProvider provider)
|
if (scene.SelectedItem is IObject3DControlsProvider provider)
|
||||||
{
|
{
|
||||||
CurrentObject3DControls = provider.GetObject3DControls(this);
|
provider.AddObject3DControls(this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CurrentObject3DControls = new List<IObject3DControl>(new IObject3DControl[]
|
// add default controls
|
||||||
{
|
Object3DControls.Add(new ScaleMatrixTopControl(this));
|
||||||
// add default controls
|
Object3DControls.Add(new ScaleCornerControl(this, 0));
|
||||||
new RotateCornerControl(this, 0),
|
Object3DControls.Add(new ScaleCornerControl(this, 1));
|
||||||
new RotateCornerControl(this, 1),
|
Object3DControls.Add(new ScaleCornerControl(this, 2));
|
||||||
new RotateCornerControl(this, 2),
|
Object3DControls.Add(new ScaleCornerControl(this, 3));
|
||||||
new MoveInZControl(this),
|
|
||||||
new ScaleTopControl(this),
|
AddWorldRotateControls();
|
||||||
new ScaleCornerControl(this, 0),
|
AddDefaultControls();
|
||||||
new ScaleCornerControl(this, 1),
|
|
||||||
new ScaleCornerControl(this, 2),
|
|
||||||
new ScaleCornerControl(this, 3),
|
|
||||||
new SelectionShadow(this),
|
|
||||||
new SnappingIndicators(this),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add in MoveInZ, SelectionShadow & SnappingIndicators
|
||||||
|
/// </summary>
|
||||||
|
public void AddDefaultControls()
|
||||||
|
{
|
||||||
|
Object3DControls.Add(new MoveInZControl(this));
|
||||||
|
Object3DControls.Add(new SelectionShadow(this));
|
||||||
|
Object3DControls.Add(new SnappingIndicators(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddWorldRotateControls()
|
||||||
|
{
|
||||||
|
Object3DControls.Add(new RotateCornerControl(this, 0));
|
||||||
|
Object3DControls.Add(new RotateCornerControl(this, 1));
|
||||||
|
Object3DControls.Add(new RotateCornerControl(this, 2));
|
||||||
|
}
|
||||||
|
|
||||||
private void DisposeCurrentSelectionObject3DControls()
|
private void DisposeCurrentSelectionObject3DControls()
|
||||||
{
|
{
|
||||||
foreach (var item in this.Object3DControls)
|
foreach (var item in this.Object3DControls)
|
||||||
|
|
@ -202,7 +198,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
item.Dispose();
|
item.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.CurrentObject3DControls = null;
|
this.Object3DControls.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RenderBounds(DrawEventArgs e, WorldView world, IEnumerable<BvhIterator> allResults)
|
public static void RenderBounds(DrawEventArgs e, WorldView world, IEnumerable<BvhIterator> allResults)
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||||
var deltaRatio = sensorDelta / stepperDelta;
|
var deltaRatio = sensorDelta / stepperDelta;
|
||||||
if (deltaRatio < .5 || deltaRatio > 2)
|
if (deltaRatio < .5 || deltaRatio > 2)
|
||||||
{
|
{
|
||||||
|
printer.Connection.TerminalLog.WriteLine($"RUNNOUT ({positionSensorData.ExtrusionDiscrepency}): Sensor ({sensorDelta:#.0}) / Stepper ({stepperDelta:#.0}) = {deltaRatio:#.00}");
|
||||||
// we have a discrepancy set a runout state
|
// we have a discrepancy set a runout state
|
||||||
positionSensorData.ExtrusionDiscrepency++;
|
positionSensorData.ExtrusionDiscrepency++;
|
||||||
if (positionSensorData.ExtrusionDiscrepency > 2)
|
if (positionSensorData.ExtrusionDiscrepency > 2)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue