Putting in info for tool change timing
refactoring extruder index to tool index
This commit is contained in:
parent
0c6a0fe4be
commit
457e31ef10
8 changed files with 41 additions and 24 deletions
|
|
@ -128,15 +128,15 @@ namespace MatterHackers.GCodeVisualizer
|
|||
if (Math.Abs(eMovement) > 0)
|
||||
{
|
||||
// this is a retraction
|
||||
renderFeaturesForLayer.Add(new RenderFeatureRetract(currentInstruction.Position, eMovement, currentInstruction.ExtruderIndex, currentInstruction.FeedRate));
|
||||
renderFeaturesForLayer.Add(new RenderFeatureRetract(currentInstruction.Position, eMovement, currentInstruction.ToolIndex, currentInstruction.FeedRate));
|
||||
}
|
||||
if (currentInstruction.Line.StartsWith("G10"))
|
||||
{
|
||||
renderFeaturesForLayer.Add(new RenderFeatureRetract(currentInstruction.Position, -1, currentInstruction.ExtruderIndex, currentInstruction.FeedRate));
|
||||
renderFeaturesForLayer.Add(new RenderFeatureRetract(currentInstruction.Position, -1, currentInstruction.ToolIndex, currentInstruction.FeedRate));
|
||||
}
|
||||
else if (currentInstruction.Line.StartsWith("G11"))
|
||||
{
|
||||
renderFeaturesForLayer.Add(new RenderFeatureRetract(currentInstruction.Position, 1, currentInstruction.ExtruderIndex, currentInstruction.FeedRate));
|
||||
renderFeaturesForLayer.Add(new RenderFeatureRetract(currentInstruction.Position, 1, currentInstruction.ToolIndex, currentInstruction.FeedRate));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -150,7 +150,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
new RenderFeatureExtrusion(
|
||||
previousInstruction.Position,
|
||||
currentInstruction.Position,
|
||||
currentInstruction.ExtruderIndex,
|
||||
currentInstruction.ToolIndex,
|
||||
currentInstruction.FeedRate,
|
||||
currentInstruction.EPosition - previousInstruction.EPosition,
|
||||
gCodeFileToDraw.GetFilamentDiameter(),
|
||||
|
|
@ -164,7 +164,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
new RenderFeatureTravel(
|
||||
previousInstruction.Position,
|
||||
currentInstruction.Position,
|
||||
currentInstruction.ExtruderIndex,
|
||||
currentInstruction.ToolIndex,
|
||||
currentInstruction.FeedRate));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
{
|
||||
public abstract class RenderFeatureBase
|
||||
{
|
||||
protected int extruderIndex;
|
||||
protected int toolIndex;
|
||||
|
||||
public static Color HighlightColor { get; set; } = new Color("#D0F476");
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
|
||||
public RenderFeatureBase(int extruderIndex)
|
||||
{
|
||||
this.extruderIndex = extruderIndex;
|
||||
this.toolIndex = extruderIndex;
|
||||
}
|
||||
|
||||
static public void CreateCylinder(VectorPOD<ColorVertexData> colorVertexData, VectorPOD<int> indexData, Vector3 startPos, Vector3 endPos, double radius, int steps, Color color, double layerHeight)
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ namespace MatterHackers.GCodeVisualizer
|
|||
private Color color;
|
||||
private Color gray;
|
||||
|
||||
public RenderFeatureExtrusion(Vector3 start, Vector3 end, int extruderIndex, double travelSpeed, double totalExtrusionMm, double filamentDiameterMm, double layerHeight, Color color, Color gray)
|
||||
: base(start, end, extruderIndex, travelSpeed)
|
||||
public RenderFeatureExtrusion(Vector3 start, Vector3 end, int toolIndex, double travelSpeed, double totalExtrusionMm, double filamentDiameterMm, double layerHeight, Color color, Color gray)
|
||||
: base(start, end, toolIndex, travelSpeed)
|
||||
{
|
||||
this.color = color;
|
||||
this.gray = gray;
|
||||
|
|
@ -101,7 +101,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
}
|
||||
else
|
||||
{
|
||||
lineColor = renderInfo.GetMaterialColor(extruderIndex);
|
||||
lineColor = renderInfo.GetMaterialColor(toolIndex);
|
||||
}
|
||||
|
||||
CreateCylinder(colorVertexData, indexData, new Vector3(start), new Vector3(end), radius, 6, lineColor, layerHeight);
|
||||
|
|
@ -130,7 +130,7 @@ namespace MatterHackers.GCodeVisualizer
|
|||
}
|
||||
else
|
||||
{
|
||||
extrusionColor = renderInfo.GetMaterialColor(extruderIndex);
|
||||
extrusionColor = renderInfo.GetMaterialColor(toolIndex);
|
||||
}
|
||||
|
||||
if (renderInfo.CurrentRenderType.HasFlag(RenderType.TransparentExtrusion))
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ namespace MatterHackers.GCodeVisualizer
|
|||
var position = new Vector3(this.position);
|
||||
|
||||
// retract and unretract are the extruder color
|
||||
Color color = renderInfo.GetMaterialColor(extruderIndex);
|
||||
Color color = renderInfo.GetMaterialColor(toolIndex);
|
||||
// except for extruder 0 where they are the red and blue we are familiar with
|
||||
if (extruderIndex == 0)
|
||||
if (toolIndex == 0)
|
||||
{
|
||||
if (extrusionAmount > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ namespace MatterHackers.GCodeVisualizer
|
|||
|
||||
public Vector3Float End => end;
|
||||
|
||||
public RenderFeatureTravel(Vector3 start, Vector3 end, int extruderIndex, double travelSpeed)
|
||||
: base(extruderIndex)
|
||||
public RenderFeatureTravel(Vector3 start, Vector3 end, int toolIndex, double travelSpeed)
|
||||
: base(toolIndex)
|
||||
{
|
||||
this.extruderIndex = extruderIndex;
|
||||
this.toolIndex = toolIndex;
|
||||
this.start = new Vector3Float(start);
|
||||
this.end = new Vector3Float(end);
|
||||
this.travelSpeed = (float)travelSpeed;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ namespace MatterControl.Printing
|
|||
private double diameterOfFilamentUsedMmCache = 0;
|
||||
|
||||
private List<double> layerHeights = new List<double>();
|
||||
private List<int> toolChanges = new List<int>();
|
||||
private List<PrinterMachineInstruction> GCodeCommandQueue = new List<PrinterMachineInstruction>();
|
||||
|
||||
private bool foundFirstLayerMarker;
|
||||
|
|
@ -255,7 +256,7 @@ namespace MatterControl.Printing
|
|||
double extruderIndex = 0;
|
||||
if (GetFirstNumberAfter("T", lineString, ref extruderIndex))
|
||||
{
|
||||
machineInstructionForLine.ExtruderIndex = (int)extruderIndex;
|
||||
machineInstructionForLine.ToolIndex = (int)extruderIndex;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -349,6 +350,8 @@ namespace MatterControl.Printing
|
|||
Stopwatch maxProgressReport = new Stopwatch();
|
||||
maxProgressReport.Start();
|
||||
|
||||
int currentTool = 0;
|
||||
|
||||
for (int lineIndex = 0; lineIndex < GCodeCommandQueue.Count; lineIndex++)
|
||||
{
|
||||
PrinterMachineInstruction instruction = GCodeCommandQueue[lineIndex];
|
||||
|
|
@ -387,6 +390,12 @@ namespace MatterControl.Printing
|
|||
}
|
||||
}
|
||||
|
||||
if(instruction.ToolIndex != currentTool)
|
||||
{
|
||||
toolChanges.Add(lineIndex);
|
||||
currentTool = instruction.ToolIndex;
|
||||
}
|
||||
|
||||
if (feedRateMmPerMin > 0)
|
||||
{
|
||||
var timeForE = Estimator.GetSecondsForMovement(deltaEPositionThisLine,
|
||||
|
|
|
|||
|
|
@ -71,14 +71,14 @@ namespace MatterControl.Printing
|
|||
EPosition = copy.EPosition;
|
||||
MovementType = copy.MovementType;
|
||||
SecondsToEndFromHere = copy.SecondsToEndFromHere;
|
||||
ExtruderIndex = copy.ExtruderIndex;
|
||||
ToolIndex = copy.ToolIndex;
|
||||
}
|
||||
|
||||
public enum MovementTypes { Absolute, Relative };
|
||||
|
||||
public float EPosition { get; set; }
|
||||
|
||||
public int ExtruderIndex { get; set; }
|
||||
public int ToolIndex { get; set; }
|
||||
|
||||
public float FeedRate { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
private TextWidget lengthWidget;
|
||||
private TextWidget yInterceptWidget;
|
||||
private TextWidget xInterceptWidget;
|
||||
private TextWidget timeToToolChange;
|
||||
|
||||
public GCodeDebugView(PrinterTabPage printerTabPage, GCodeFile gCodeMemoryFile, ISceneContext sceneContext, ThemeConfig theme)
|
||||
: base(theme)
|
||||
|
|
@ -59,6 +60,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
slopeWidget = this.AddSetting("Slope".Localize(), "");
|
||||
yInterceptWidget = this.AddSetting("Y Intercept".Localize(), "");
|
||||
xInterceptWidget = this.AddSetting("X Intercept".Localize(), "");
|
||||
timeToToolChange = this.AddSetting("Tool Change".Localize(), "");
|
||||
|
||||
// Register listeners
|
||||
printerTabPage.LayerFeaturesScrollbar.SecondValueChanged += this.LayerFeaturesScrollbar_SecondValueChanged;
|
||||
|
|
@ -79,7 +81,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
int featuresOnLayer = sceneContext.GCodeRenderer.GetNumFeatures(layerIndex);
|
||||
int featureIndex = (int)(featuresOnLayer * renderInfo.FeatureToEndOnRatio0To1 + .5);
|
||||
|
||||
int activeFeatureIndex = Math.Max(0, Math.Min(featureIndex, featuresOnLayer - 1));
|
||||
int activeFeatureIndex = Math.Max(0, Math.Min(featureIndex, featuresOnLayer - 1) - 1);
|
||||
|
||||
if (sceneContext.GCodeRenderer[layerIndex, activeFeatureIndex] is RenderFeatureTravel line)
|
||||
{
|
||||
|
|
@ -90,7 +92,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
endPointWidget.Text = $"{end}";
|
||||
|
||||
var length = new Vector2(start).Distance(new Vector2(end));
|
||||
lengthWidget.Text = $"{length}";
|
||||
lengthWidget.Text = $"{length:0.###}";
|
||||
|
||||
// Slope
|
||||
// m = (y_2 - y_1) / (x_2 - x_1)
|
||||
|
|
@ -99,15 +101,21 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
// n = -x_1 * (y_2 - y_1) / (x_2 - x_1) + y_1
|
||||
|
||||
var slope = (end.Y - start.Y) / (end.X - start.X);
|
||||
slopeWidget.Text = $"{slope}";
|
||||
slopeWidget.Text = $"{slope:0.###}";
|
||||
|
||||
// -x_1 * (y_2 - y_1) / (x_2 - x_1) + y_1
|
||||
var yIntercept = -start.X * slope + start.Y;
|
||||
yInterceptWidget.Text = $"{yIntercept}";
|
||||
yInterceptWidget.Text = $"{yIntercept:0.###}";
|
||||
|
||||
// x_1 - y_1*(x_2-x_1)/(y_2-y_1)
|
||||
var xIntercept = start.X - start.Y * (end.X - start.X) / (end.Y - start.Y);
|
||||
xInterceptWidget.Text = $"{xIntercept}";
|
||||
xInterceptWidget.Text = $"{xIntercept:0.###}";
|
||||
|
||||
// put in the time until the next tool change
|
||||
if(timeToToolChange != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue