Remove NozzleCalibrationWizard and supporting types
This commit is contained in:
parent
8627c96902
commit
3552c37b8c
6 changed files with 0 additions and 1111 deletions
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2019, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class NozzleCalibrationWizard : PrinterSetupWizard
|
||||
{
|
||||
public NozzleCalibrationWizard(PrinterConfig printer)
|
||||
: base(printer)
|
||||
{
|
||||
this.Title = "Nozzle Calibration".Localize();
|
||||
this.WindowSize = new Vector2(600 * GuiWidget.DeviceScale, 700 * GuiWidget.DeviceScale);
|
||||
}
|
||||
|
||||
public override bool Visible => printer.Settings.GetValue<int>(SettingsKey.extruder_count) > 1;
|
||||
|
||||
public override bool Enabled => true;
|
||||
|
||||
public override bool SetupRequired => NeedsToBeRun(printer);
|
||||
|
||||
public static bool NeedsToBeRun(PrinterConfig printer)
|
||||
{
|
||||
// we have a probe that we are using and we have not done leveling yet
|
||||
return UsingZProbe(printer) && !printer.Settings.GetValue<bool>(SettingsKey.probe_has_been_calibrated);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public static bool UsingZProbe(PrinterConfig printer)
|
||||
{
|
||||
var required = printer.Settings.GetValue<bool>(SettingsKey.print_leveling_required_to_print);
|
||||
|
||||
// we have a probe that we are using and we have not done leveling yet
|
||||
return (required || printer.Settings.GetValue<bool>(SettingsKey.print_leveling_enabled))
|
||||
&& printer.Settings.GetValue<bool>(SettingsKey.has_z_probe)
|
||||
&& printer.Settings.GetValue<bool>(SettingsKey.use_z_probe);
|
||||
}
|
||||
|
||||
protected override IEnumerator<WizardPage> GetPages()
|
||||
{
|
||||
yield return new WizardPage(
|
||||
this,
|
||||
"Nozzle Offset Calibration".Localize(),
|
||||
"Offset Calibration required. We'll now print a calibration guide on the printer to tune your nozzle offsets".Localize())
|
||||
{
|
||||
WindowTitle = Title
|
||||
};
|
||||
|
||||
var extruderCount = printer.Settings.GetValue<int>(SettingsKey.extruder_count);
|
||||
|
||||
var temps = new double[4];
|
||||
for (int i = 0; i < extruderCount; i++)
|
||||
{
|
||||
temps[i] = printer.Settings.Helpers.ExtruderTargetTemperature(i);
|
||||
}
|
||||
|
||||
bool hasHeatedBed = printer.Settings.GetValue<bool>(SettingsKey.has_heated_bed);
|
||||
double targetBedTemp = 0;
|
||||
if (hasHeatedBed)
|
||||
{
|
||||
targetBedTemp = printer.Settings.GetValue<double>(SettingsKey.bed_temperature);
|
||||
}
|
||||
|
||||
yield return new WaitForTempPage(
|
||||
this,
|
||||
"Waiting For Printer To Heat".Localize(),
|
||||
((extruderCount == 1) ? "Waiting for the hotend to heat to ".Localize() + temps[0] + "°C.\n" : "Waiting for the hotends to heat up.".Localize())
|
||||
+ "This will ensure that no filament is stuck to your nozzle.".Localize() + "\n"
|
||||
+ "\n"
|
||||
+ "Warning! The tip of the nozzle will be HOT!".Localize() + "\n"
|
||||
+ "Avoid contact with your skin.".Localize(),
|
||||
targetBedTemp,
|
||||
temps);
|
||||
|
||||
// add in the homing printer page
|
||||
yield return new HomePrinterPage(
|
||||
this,
|
||||
"Homing The Printer".Localize(),
|
||||
"Homing the printer, please wait".Localize() + "...",
|
||||
false);
|
||||
|
||||
|
||||
var calibrationPage = new NozzleOffsetCalibrationPrintPage(this, printer);
|
||||
yield return calibrationPage;
|
||||
|
||||
yield return new NozzleOffsetCalibrationResultsPage(this, printer, calibrationPage.XOffset, calibrationPage.YOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,214 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2019, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Transform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class CalibrationLine : GuiWidget
|
||||
{
|
||||
public static Dictionary<int, IVertexSource> Glyphs { get; private set; }
|
||||
private static int glyphSize = 10;
|
||||
|
||||
private bool mouseInBounds;
|
||||
private bool verticalLine;
|
||||
|
||||
private ThemeConfig theme;
|
||||
private IVertexSource glyph = null;
|
||||
private Stroke glyphStroke;
|
||||
private bool _isActive;
|
||||
|
||||
static CalibrationLine()
|
||||
{
|
||||
CalibrationLine.CreateGlyphs();
|
||||
}
|
||||
|
||||
public CalibrationLine(FlowDirection parentDirection, int glyphIndex, ThemeConfig theme)
|
||||
{
|
||||
if (parentDirection == FlowDirection.LeftToRight)
|
||||
{
|
||||
this.Width = glyphSize + 1;
|
||||
this.HAnchor = HAnchor.Absolute;
|
||||
this.VAnchor = VAnchor.Stretch;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Height = glyphSize + 1;
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
this.VAnchor = VAnchor.Absolute;
|
||||
}
|
||||
|
||||
verticalLine = parentDirection == FlowDirection.LeftToRight;
|
||||
|
||||
if (Glyphs.TryGetValue(glyphIndex, out IVertexSource glyph))
|
||||
{
|
||||
if (!verticalLine)
|
||||
{
|
||||
// Rotate glyph to match horizontal line
|
||||
glyph = new VertexSourceApplyTransform(glyph, Affine.NewRotation(MathHelper.DegreesToRadians(90)));
|
||||
}
|
||||
|
||||
this.glyph = glyph;
|
||||
this.glyphStroke = new Stroke(glyph.Scale(0.8));
|
||||
}
|
||||
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get => _isActive;
|
||||
set
|
||||
{
|
||||
if (_isActive != value)
|
||||
{
|
||||
_isActive = value;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNegative { get; set; }
|
||||
|
||||
public override void OnMouseEnterBounds(MouseEventArgs mouseEvent)
|
||||
{
|
||||
mouseInBounds = true;
|
||||
this.Invalidate();
|
||||
|
||||
base.OnMouseEnterBounds(mouseEvent);
|
||||
}
|
||||
|
||||
public override void OnMouseLeaveBounds(MouseEventArgs mouseEvent)
|
||||
{
|
||||
mouseInBounds = false;
|
||||
this.Invalidate();
|
||||
|
||||
base.OnMouseLeaveBounds(mouseEvent);
|
||||
}
|
||||
|
||||
public override Color BackgroundColor
|
||||
{
|
||||
get => mouseInBounds ? theme.AccentMimimalOverlay : base.BackgroundColor;
|
||||
set => base.BackgroundColor = value;
|
||||
}
|
||||
|
||||
public int OffsetIndex { get; set; }
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
Color lineColor = this.IsActive ? theme.PrimaryAccentColor : theme.TextColor;
|
||||
|
||||
var centerX = this.LocalBounds.XCenter;
|
||||
var centerY = this.LocalBounds.YCenter;
|
||||
|
||||
var start = new Vector2(centerX, (glyph == null) ? 20 : (this.IsNegative) ? 6 : 12);
|
||||
var end = new Vector2(centerX, this.LocalBounds.Height);
|
||||
|
||||
if (!verticalLine)
|
||||
{
|
||||
start = new Vector2(0, centerY);
|
||||
end = new Vector2(this.LocalBounds.Width - ((glyph == null) ? 20 : (this.IsNegative) ? 6 : 12), centerY);
|
||||
}
|
||||
|
||||
graphics2D.Line(start, end, lineColor, 1);
|
||||
|
||||
// Draw line end
|
||||
if (glyph != null)
|
||||
{
|
||||
int offset = IsNegative ? 17 : 11;
|
||||
|
||||
graphics2D.Render(
|
||||
glyphStroke,
|
||||
verticalLine ? new Vector2(centerX, offset) : new Vector2(this.Width - offset, centerY),
|
||||
lineColor);
|
||||
}
|
||||
|
||||
base.OnDraw(graphics2D);
|
||||
}
|
||||
|
||||
private static void CreateGlyphs()
|
||||
{
|
||||
Glyphs = new Dictionary<int, IVertexSource>();
|
||||
|
||||
var half = glyphSize / 2;
|
||||
|
||||
var triangle = new VertexStorage();
|
||||
triangle.MoveTo(half, glyphSize);
|
||||
triangle.LineTo(0, 0);
|
||||
triangle.LineTo(glyphSize, 0);
|
||||
triangle.LineTo(half, glyphSize);
|
||||
triangle.ClosePolygon();
|
||||
|
||||
var square = new VertexStorage();
|
||||
square.MoveTo(half, glyphSize);
|
||||
square.LineTo(0, glyphSize);
|
||||
square.LineTo(0, 0);
|
||||
square.LineTo(glyphSize, 0);
|
||||
square.LineTo(glyphSize, glyphSize);
|
||||
square.LineTo(half, glyphSize);
|
||||
square.ClosePolygon();
|
||||
|
||||
var diamond = new VertexStorage();
|
||||
diamond.MoveTo(half, glyphSize);
|
||||
diamond.LineTo(0, half);
|
||||
diamond.LineTo(half, 0);
|
||||
diamond.LineTo(glyphSize, half);
|
||||
diamond.LineTo(half, glyphSize);
|
||||
diamond.ClosePolygon();
|
||||
|
||||
var circle = new Ellipse(Vector2.Zero, half).Rotate(90, AngleType.Degrees).Translate(half, half);
|
||||
|
||||
var chevron = new VertexStorage();
|
||||
chevron.MoveTo(half, glyphSize);
|
||||
chevron.LineTo(0, 0);
|
||||
chevron.LineTo(half, glyphSize - 4);
|
||||
chevron.LineTo(glyphSize, 0);
|
||||
chevron.LineTo(half, glyphSize);
|
||||
chevron.ClosePolygon();
|
||||
|
||||
var transform = Affine.NewTranslation(-glyphSize / 2, -glyphSize);
|
||||
Glyphs.Add(0, new VertexSourceApplyTransform(triangle, transform));
|
||||
Glyphs.Add(5, new VertexSourceApplyTransform(diamond, transform));
|
||||
Glyphs.Add(10, new VertexSourceApplyTransform(square, transform));
|
||||
Glyphs.Add(15, new VertexSourceApplyTransform(chevron, transform));
|
||||
|
||||
Glyphs.Add(20, new VertexSourceApplyTransform(circle, transform));
|
||||
|
||||
Glyphs.Add(25, new VertexSourceApplyTransform(chevron, transform));
|
||||
Glyphs.Add(30, new VertexSourceApplyTransform(square, transform));
|
||||
Glyphs.Add(35, new VertexSourceApplyTransform(diamond, transform));
|
||||
Glyphs.Add(40, new VertexSourceApplyTransform(triangle, transform));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,221 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2019, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class NozzleOffsetCalibrationPrintPage : WizardPage
|
||||
{
|
||||
private NozzleOffsetTemplatePrinter templatePrinter;
|
||||
private NozzleOffsetTemplateWidget xOffsetWidget;
|
||||
private NozzleOffsetTemplateWidget yOffsetWidget;
|
||||
private TextWidget xOffsetText;
|
||||
private TextWidget yOffsetText;
|
||||
|
||||
public NozzleOffsetCalibrationPrintPage(ISetupWizard setupWizard, PrinterConfig printer)
|
||||
: base(setupWizard)
|
||||
{
|
||||
this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize();
|
||||
this.HeaderText = "Nozzle Offset Calibration".Localize() + ":";
|
||||
this.Name = "Nozzle Offset Calibration Wizard";
|
||||
|
||||
templatePrinter = new NozzleOffsetTemplatePrinter(printer);
|
||||
|
||||
contentRow.Padding = theme.DefaultContainerPadding;
|
||||
|
||||
contentRow.AddChild(xOffsetWidget = new NozzleOffsetTemplateWidget(templatePrinter.ActiveOffsets, FlowDirection.LeftToRight, theme)
|
||||
{
|
||||
Padding = new BorderDouble(left: 4),
|
||||
HAnchor = HAnchor.Absolute,
|
||||
VAnchor = VAnchor.Absolute,
|
||||
Height = 110,
|
||||
Width = 480
|
||||
});
|
||||
|
||||
xOffsetWidget.OffsetChanged += (s, e) =>
|
||||
{
|
||||
this.XOffset = xOffsetWidget.ActiveOffset;
|
||||
xOffsetText.Text = string.Format("{0}: {1:0.###}", "X Offset".Localize(), this.XOffset);
|
||||
|
||||
this.NextButton.Enabled = this.XOffset != double.MinValue && this.YOffset != double.MinValue;
|
||||
};
|
||||
|
||||
var container = new FlowLayoutWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Stretch
|
||||
};
|
||||
|
||||
contentRow.AddChild(container);
|
||||
|
||||
container.AddChild(yOffsetWidget = new NozzleOffsetTemplateWidget(templatePrinter.ActiveOffsets, FlowDirection.BottomToTop, theme)
|
||||
{
|
||||
Margin = new BorderDouble(top: 15),
|
||||
Padding = new BorderDouble(bottom: 4),
|
||||
VAnchor = VAnchor.Absolute,
|
||||
HAnchor = HAnchor.Absolute,
|
||||
Height = 480,
|
||||
Width = 110
|
||||
});
|
||||
|
||||
var verticalColumn = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Stretch,
|
||||
Margin = 40
|
||||
};
|
||||
container.AddChild(verticalColumn);
|
||||
|
||||
verticalColumn.AddChild(xOffsetText = new TextWidget("".Localize(), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
|
||||
{
|
||||
Width = 200,
|
||||
Margin = new BorderDouble(bottom: 10)
|
||||
});
|
||||
|
||||
verticalColumn.AddChild(yOffsetText = new TextWidget("".Localize(), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
|
||||
{
|
||||
Width = 200
|
||||
});
|
||||
|
||||
yOffsetWidget.OffsetChanged += (s, e) =>
|
||||
{
|
||||
this.YOffset = yOffsetWidget.ActiveOffset;
|
||||
yOffsetText.Text = string.Format("{0}: {1:0.###}", "Y Offset".Localize(), this.YOffset);
|
||||
|
||||
this.NextButton.Enabled = this.XOffset != double.MinValue && this.YOffset != double.MinValue;
|
||||
};
|
||||
|
||||
this.NextButton.Enabled = false;
|
||||
}
|
||||
|
||||
public double YOffset { get; set; } = double.MinValue;
|
||||
|
||||
public double XOffset { get; set; } = double.MinValue;
|
||||
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
base.OnLoad(args);
|
||||
|
||||
// Replace with calibration template code
|
||||
//await templatePrinter.PrintTemplate(verticalLayout: true);
|
||||
//await templatePrinter.PrintTemplate(verticalLayout: false);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var sketch1 = new GCodeSketch(printer)
|
||||
{
|
||||
Speed = (int)(printer.Settings.GetValue<double>(SettingsKey.first_layer_speed) * 60),
|
||||
RetractLength = printer.Settings.GetValue<double>(SettingsKey.retract_length),
|
||||
RetractSpeed = printer.Settings.GetValue<double>(SettingsKey.retract_speed) * 60,
|
||||
RetractLift = printer.Settings.GetValue<double>(SettingsKey.retract_lift),
|
||||
TravelSpeed = printer.Settings.GetValue<double>(SettingsKey.travel_speed) * 60,
|
||||
};
|
||||
|
||||
var sketch2 = new GCodeSketch(printer)
|
||||
{
|
||||
Speed = sketch1.Speed,
|
||||
RetractLength = sketch1.RetractLength,
|
||||
RetractSpeed = sketch1.RetractSpeed,
|
||||
RetractLift = sketch1.RetractLift,
|
||||
TravelSpeed = sketch1.TravelSpeed
|
||||
};
|
||||
|
||||
//gcodeSketch.WriteRaw("G92 E0");
|
||||
sketch1.WriteRaw("; LAYER: 0");
|
||||
sketch1.WriteRaw("; LAYER_HEIGHT: 0.2");
|
||||
|
||||
|
||||
sketch1.SetTool("T0");
|
||||
sketch2.SetTool("T1");
|
||||
sketch1.PenUp();
|
||||
|
||||
templatePrinter.BuildTemplate(sketch1, sketch2, verticalLayout: true);
|
||||
templatePrinter.BuildTemplate(sketch1, sketch2, verticalLayout: false);
|
||||
|
||||
|
||||
string outputPath = Path.Combine(
|
||||
ApplicationDataStorage.Instance.GCodeOutputPath,
|
||||
$"nozzle-offset-template-combined.gcode");
|
||||
|
||||
File.WriteAllText(outputPath, sketch1.ToGCode() + "\r\n" + sketch2.ToGCode());
|
||||
|
||||
// HACK: update state needed to be set before calling StartPrint
|
||||
printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
|
||||
await printer.Connection.StartPrint(outputPath, allowRecovery: false);
|
||||
|
||||
// Wait for print start
|
||||
while (!printer.Connection.PrintIsActive)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
// Wait for print finished
|
||||
while (printer.Connection.PrintIsActive)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
if (printer.Settings.GetValue<bool>(SettingsKey.z_homes_to_max))
|
||||
{
|
||||
printer.Connection.HomeAxis(PrinterConnection.Axis.Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
printer.Connection.MoveRelative(PrinterConnection.Axis.Z, 20, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
|
||||
printer.Connection.MoveAbsolute(PrinterConnection.Axis.Y,
|
||||
printer.Bed.Bounds.Top,
|
||||
printer.Settings.Helpers.ManualMovementSpeeds().Y);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
if (printer.Connection.CommunicationState == CommunicationStates.Printing ||
|
||||
printer.Connection.CommunicationState == CommunicationStates.Paused)
|
||||
{
|
||||
printer.CancelPrint();
|
||||
}
|
||||
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2019, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class NozzleOffsetCalibrationResultsPage : WizardPage
|
||||
{
|
||||
public NozzleOffsetCalibrationResultsPage(ISetupWizard setupWizard, PrinterConfig printer, double xOffset, double yOffset)
|
||||
: base(setupWizard)
|
||||
{
|
||||
this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize();
|
||||
this.HeaderText = "Nozzle Offset Calibration".Localize() + ":";
|
||||
this.Name = "Nozzle Offset Calibration Wizard";
|
||||
|
||||
this.CreateTextField("Congratulations, your nozzle offsets have been collected and are ready to be saved. Click next to save and finish the wizard".Localize());
|
||||
|
||||
var row = new SettingsRow(
|
||||
"X Offset".Localize(),
|
||||
null,
|
||||
theme,
|
||||
AggContext.StaticData.LoadIcon("probing_32x32.png", 16, 16, theme.InvertIcons));
|
||||
contentRow.AddChild(row);
|
||||
|
||||
row.AddChild(new TextWidget(xOffset.ToString("0.###") + "mm", pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
Margin = new BorderDouble(right: 10)
|
||||
});
|
||||
|
||||
row = new SettingsRow(
|
||||
"Y Offset".Localize(),
|
||||
null,
|
||||
theme,
|
||||
AggContext.StaticData.LoadIcon("probing_32x32.png", 16, 16, theme.InvertIcons));
|
||||
contentRow.AddChild(row);
|
||||
|
||||
row.AddChild(new TextWidget(yOffset.ToString("0.###") + "mm", pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
Margin = new BorderDouble(right: 10)
|
||||
});
|
||||
|
||||
this.NextButton.Visible = false;
|
||||
|
||||
var nextButton = theme.CreateDialogButton("Finish".Localize());
|
||||
nextButton.Name = "FinishCalibration";
|
||||
nextButton.Click += (s, e) =>
|
||||
{
|
||||
// TODO: removed fixed index
|
||||
var hotendOffset = printer.Settings.Helpers.ExtruderOffset(1);
|
||||
hotendOffset.X += xOffset;
|
||||
hotendOffset.Y += yOffset;
|
||||
|
||||
printer.Settings.Helpers.SetExtruderOffset(1, hotendOffset);
|
||||
|
||||
this.DialogWindow.CloseOnIdle();
|
||||
};
|
||||
|
||||
theme.ApplyPrimaryActionStyle(nextButton);
|
||||
|
||||
this.AddPageAction(nextButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,311 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2019, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Transform;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class NozzleOffsetTemplatePrinter
|
||||
{
|
||||
private PrinterConfig printer;
|
||||
private double[] activeOffsets;
|
||||
private double nozzleWidth;
|
||||
private int firstLayerSpeed;
|
||||
|
||||
public NozzleOffsetTemplatePrinter(PrinterConfig printer)
|
||||
{
|
||||
this.printer = printer;
|
||||
|
||||
// Build offsets
|
||||
activeOffsets = new double[41];
|
||||
activeOffsets[20] = 0;
|
||||
|
||||
var offsetStep = 1.2d / 20;
|
||||
|
||||
for (var i = 1; i <= 20; i++)
|
||||
{
|
||||
activeOffsets[20 - i] = i * offsetStep * -1;
|
||||
activeOffsets[20 + i] = i * offsetStep;
|
||||
}
|
||||
|
||||
nozzleWidth = printer.Settings.GetValue<double>(SettingsKey.nozzle_diameter);
|
||||
firstLayerSpeed = (int)(printer.Settings.GetValue<double>(SettingsKey.first_layer_speed) * 60);
|
||||
}
|
||||
|
||||
public double[] ActiveOffsets => activeOffsets;
|
||||
|
||||
public bool DebugMode { get; private set; } = false;
|
||||
|
||||
public void BuildTemplate(GCodeSketch gcodeSketch, GCodeSketch sketch2, bool verticalLayout)
|
||||
{
|
||||
if (verticalLayout)
|
||||
{
|
||||
gcodeSketch.Transform = Affine.NewRotation(MathHelper.DegreesToRadians(90)) * Affine.NewTranslation(120, 45);
|
||||
sketch2.Transform = gcodeSketch.Transform;
|
||||
}
|
||||
else
|
||||
{
|
||||
gcodeSketch.Transform = Affine.NewTranslation(90, 175);
|
||||
sketch2.Transform = gcodeSketch.Transform;
|
||||
}
|
||||
|
||||
var rect = new RectangleDouble(0, 0, 123, 30);
|
||||
|
||||
var originalRect = rect;
|
||||
|
||||
int towerSize = 10;
|
||||
|
||||
gcodeSketch.Speed = firstLayerSpeed;
|
||||
|
||||
double y1 = rect.Bottom;
|
||||
gcodeSketch.MoveTo(rect.Left, y1);
|
||||
|
||||
gcodeSketch.PenDown();
|
||||
|
||||
var towerRect = new RectangleDouble(0, 0, towerSize, towerSize);
|
||||
towerRect.Offset(originalRect.Left - towerSize, originalRect.Bottom);
|
||||
|
||||
// Prime
|
||||
if (verticalLayout)
|
||||
{
|
||||
this.PrimeHotend(gcodeSketch, towerRect);
|
||||
}
|
||||
|
||||
// Perimeters
|
||||
rect = this.CreatePerimeters(gcodeSketch, rect);
|
||||
|
||||
double x, y2, y3, y4;
|
||||
double sectionHeight = rect.Height / 2;
|
||||
bool up = true;
|
||||
var step = (rect.Width - 3) / 40;
|
||||
|
||||
if (!this.DebugMode)
|
||||
{
|
||||
y1 = rect.YCenter + (nozzleWidth / 2);
|
||||
|
||||
// Draw centerline
|
||||
gcodeSketch.MoveTo(rect.Left, y1);
|
||||
gcodeSketch.LineTo(rect.Right, y1);
|
||||
y1 += nozzleWidth;
|
||||
gcodeSketch.MoveTo(rect.Right, y1);
|
||||
gcodeSketch.LineTo(rect.Left, y1);
|
||||
|
||||
y1 -= nozzleWidth / 2;
|
||||
|
||||
x = rect.Left + 1.5;
|
||||
|
||||
y2 = y1 - sectionHeight - (nozzleWidth * 1.5);
|
||||
y3 = y2 - 2;
|
||||
y4 = y2 - 5;
|
||||
|
||||
bool drawGlyphs = true;
|
||||
|
||||
var inverseTransform = gcodeSketch.Transform;
|
||||
inverseTransform.invert();
|
||||
|
||||
// Draw calibration lines
|
||||
for (var i = 0; i <= 40; i++)
|
||||
{
|
||||
gcodeSketch.MoveTo(x, up ? y1 : y2);
|
||||
|
||||
if ((i % 5 == 0))
|
||||
{
|
||||
gcodeSketch.LineTo(x, y4);
|
||||
|
||||
if (i < 20)
|
||||
{
|
||||
gcodeSketch.MoveTo(x, y3);
|
||||
}
|
||||
|
||||
var currentPos = gcodeSketch.CurrentPosition;
|
||||
currentPos = inverseTransform.Transform(currentPos);
|
||||
|
||||
PrintLineEnd(gcodeSketch, drawGlyphs, i, currentPos);
|
||||
}
|
||||
|
||||
gcodeSketch.LineTo(x, up ? y2 : y1);
|
||||
|
||||
x = x + step;
|
||||
|
||||
up = !up;
|
||||
}
|
||||
}
|
||||
|
||||
gcodeSketch.PenUp();
|
||||
|
||||
x = rect.Left + 1.5;
|
||||
y1 = rect.Top + (nozzleWidth * .5);
|
||||
y2 = y1 - sectionHeight + (nozzleWidth * .5);
|
||||
|
||||
sketch2.PenUp();
|
||||
sketch2.MoveTo(rect.Left, rect.Top);
|
||||
sketch2.PenDown();
|
||||
|
||||
towerRect = new RectangleDouble(0, 0, towerSize, towerSize);
|
||||
towerRect.Offset(originalRect.Left - towerSize, originalRect.Top - towerSize);
|
||||
|
||||
// Prime
|
||||
if (verticalLayout)
|
||||
{
|
||||
this.PrimeHotend(sketch2, towerRect);
|
||||
}
|
||||
|
||||
if (this.DebugMode)
|
||||
{
|
||||
// Perimeters
|
||||
rect = this.CreatePerimeters(gcodeSketch, rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
up = true;
|
||||
|
||||
// Draw calibration lines
|
||||
for (var i = 0; i <= 40; i++)
|
||||
{
|
||||
sketch2.MoveTo(x + activeOffsets[i], up ? y1 : y2, retract: false);
|
||||
sketch2.LineTo(x + activeOffsets[i], up ? y2 : y1);
|
||||
|
||||
x = x + step;
|
||||
|
||||
up = !up;
|
||||
}
|
||||
}
|
||||
|
||||
sketch2.PenUp();
|
||||
}
|
||||
|
||||
private RectangleDouble CreatePerimeters(GCodeSketch gcodeSketch, RectangleDouble rect)
|
||||
{
|
||||
gcodeSketch.WriteRaw("; CreatePerimeters");
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
rect.Inflate(-nozzleWidth);
|
||||
gcodeSketch.DrawRectangle(rect);
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
private void PrimeHotend(GCodeSketch gcodeSketch, RectangleDouble towerRect)
|
||||
{
|
||||
gcodeSketch.WriteRaw("; Priming");
|
||||
|
||||
while (towerRect.Width > 4)
|
||||
{
|
||||
towerRect.Inflate(-nozzleWidth);
|
||||
gcodeSketch.DrawRectangle(towerRect);
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintLineEnd(GCodeSketch turtle, bool drawGlyphs, int i, Vector2 currentPos, bool lift = false)
|
||||
{
|
||||
var originalSpeed = turtle.Speed;
|
||||
turtle.Speed = Math.Min(700, turtle.Speed);
|
||||
|
||||
if (drawGlyphs && CalibrationLine.Glyphs.TryGetValue(i, out IVertexSource vertexSource))
|
||||
{
|
||||
turtle.WriteRaw("; LineEnd Marker");
|
||||
var flattened = new FlattenCurves(vertexSource);
|
||||
|
||||
var verticies = flattened.Vertices();
|
||||
var firstItem = verticies.First();
|
||||
var position = turtle.CurrentPosition;
|
||||
|
||||
var scale = 0.3;
|
||||
|
||||
if (firstItem.command != ShapePath.FlagsAndCommand.MoveTo)
|
||||
{
|
||||
if (lift)
|
||||
{
|
||||
turtle.PenUp();
|
||||
}
|
||||
|
||||
turtle.MoveTo((firstItem.position * scale) + currentPos);
|
||||
}
|
||||
|
||||
bool closed = false;
|
||||
|
||||
foreach (var item in verticies)
|
||||
{
|
||||
switch (item.command)
|
||||
{
|
||||
case ShapePath.FlagsAndCommand.MoveTo:
|
||||
if (lift)
|
||||
{
|
||||
turtle.PenUp();
|
||||
}
|
||||
|
||||
turtle.MoveTo((item.position * scale) + currentPos);
|
||||
|
||||
if (lift)
|
||||
{
|
||||
turtle.PenDown();
|
||||
}
|
||||
break;
|
||||
|
||||
case ShapePath.FlagsAndCommand.LineTo:
|
||||
turtle.LineTo((item.position * scale) + currentPos);
|
||||
break;
|
||||
|
||||
case ShapePath.FlagsAndCommand.FlagClose:
|
||||
turtle.LineTo((firstItem.position * scale) + currentPos);
|
||||
closed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool atStartingPosition = position.Equals(turtle.CurrentPosition, .1);
|
||||
|
||||
if (!closed
|
||||
&& !atStartingPosition)
|
||||
{
|
||||
turtle.LineTo((firstItem.position * scale) + currentPos);
|
||||
atStartingPosition = position.Equals(turtle.CurrentPosition, .1);
|
||||
}
|
||||
|
||||
// Restore original speed
|
||||
turtle.Speed = originalSpeed;
|
||||
|
||||
if (!atStartingPosition)
|
||||
{
|
||||
// Return to original position
|
||||
turtle.PenUp();
|
||||
turtle.MoveTo(currentPos);
|
||||
turtle.PenDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,146 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2019, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class NozzleOffsetTemplateWidget : FlowLayoutWidget
|
||||
{
|
||||
private double? _activeOffset = null;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public event EventHandler OffsetChanged;
|
||||
|
||||
public NozzleOffsetTemplateWidget(double[] activeOffsets, FlowDirection direction, ThemeConfig theme)
|
||||
: base(direction)
|
||||
{
|
||||
this.theme = theme;
|
||||
|
||||
if (direction == FlowDirection.LeftToRight)
|
||||
{
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
this.VAnchor = VAnchor.Absolute;
|
||||
this.Height = 110;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HAnchor = HAnchor.Absolute;
|
||||
this.VAnchor = VAnchor.Stretch;
|
||||
this.Width = 110;
|
||||
}
|
||||
|
||||
for (var i = 0; i <= 40; i++)
|
||||
{
|
||||
var calibrationLine = new CalibrationLine(direction, (i % 5 == 0) ? i : -1, theme)
|
||||
{
|
||||
// Margin = 1,
|
||||
IsNegative = i < 20,
|
||||
OffsetIndex = i,
|
||||
};
|
||||
calibrationLine.Click += (s, e) =>
|
||||
{
|
||||
if (activeLine != null)
|
||||
{
|
||||
activeLine.IsActive = false;
|
||||
}
|
||||
|
||||
calibrationLine.IsActive = true;
|
||||
activeLine = calibrationLine;
|
||||
this.ActiveOffset = activeOffsets[calibrationLine.OffsetIndex] * -1;
|
||||
};
|
||||
this.AddChild(calibrationLine);
|
||||
|
||||
// Add spacers to stretch to size
|
||||
if (i < 40)
|
||||
{
|
||||
if (this.FlowDirection == FlowDirection.LeftToRight)
|
||||
{
|
||||
this.AddChild(new HorizontalSpacer());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AddChild(new VerticalSpacer());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CalibrationLine activeLine;
|
||||
|
||||
public double ActiveOffset
|
||||
{
|
||||
get => _activeOffset ?? 0;
|
||||
set
|
||||
{
|
||||
if (value != _activeOffset)
|
||||
{
|
||||
_activeOffset = value;
|
||||
this.OffsetChanged?.Invoke(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
int strokeWidth = 3;
|
||||
|
||||
RectangleDouble rect;
|
||||
|
||||
if (this.FlowDirection == FlowDirection.LeftToRight)
|
||||
{
|
||||
rect = new RectangleDouble(0, 20, this.LocalBounds.Width, this.LocalBounds.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = new RectangleDouble(0, 0, this.LocalBounds.Width - 20, this.LocalBounds.Height);
|
||||
}
|
||||
|
||||
rect.Inflate(-1);
|
||||
|
||||
var center = rect.Center;
|
||||
|
||||
graphics2D.Rectangle(rect, theme.TextColor, strokeWidth);
|
||||
|
||||
if (this.FlowDirection == FlowDirection.LeftToRight)
|
||||
{
|
||||
graphics2D.Line(rect.Left, center.Y, rect.Right, center.Y, theme.TextColor, strokeWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics2D.Line(rect.XCenter, rect.Top, rect.XCenter, rect.Bottom, theme.TextColor, strokeWidth);
|
||||
}
|
||||
|
||||
base.OnDraw(graphics2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue