Skip to content

Commit

Permalink
Min-Max from config + negative offset
Browse files Browse the repository at this point in the history
  • Loading branch information
arkypita committed Nov 21, 2017
1 parent dd5409e commit 19e93d1
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 76 deletions.
4 changes: 2 additions & 2 deletions LaserGRBL/GrblCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,10 +1935,10 @@ public decimal ResolutionY
{ get { return ReadWithDefault(Version9 ? 101 : 1, 250); } }

public decimal TableWidth
{ get { return ReadWithDefault(Version9 ? 130 : -1, 200); } }
{ get { return ReadWithDefault(Version9 ? 130 : -1, 3000); } }

public decimal TableHeight
{ get { return ReadWithDefault(Version9 ? 131 : -1, 300); } }
{ get { return ReadWithDefault(Version9 ? 131 : -1, 2000); } }


private decimal ReadWithDefault(int number, decimal defval)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 41 additions & 22 deletions LaserGRBL/RasterConverter/ConvertSizeAndOptionForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,34 @@ namespace LaserGRBL.RasterConverter
/// </summary>
public partial class ConvertSizeAndOptionForm : Form
{
GrblCore mCore;
bool supportPWM = (bool)Settings.GetObject("Support Hardware PWM", true);

public ConvertSizeAndOptionForm()
public ConvertSizeAndOptionForm(GrblCore core)
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
mCore = core;

BackColor = ColorScheme.FormBackColor;
GbLaser.ForeColor = GbSize.ForeColor = GbSpeed.ForeColor = ForeColor = ColorScheme.FormForeColor;
BtnCancel.BackColor = BtnCreate.BackColor = ColorScheme.FormButtonsColor;

LblSmin.Visible = LblSmax.Visible = IIMaxPower.Visible = IIMinPower.Visible = BtnModulationInfo.Visible = supportPWM;
AssignMinMaxLimit();
}

private void AssignMinMaxLimit()
{
IISizeW.MaxValue = (int)mCore.Configuration.TableWidth;
IISizeH.MaxValue = (int)mCore.Configuration.TableHeight;

IIOffsetX.MaxValue = (int)mCore.Configuration.TableWidth;
IIOffsetY.MaxValue = (int)mCore.Configuration.TableHeight;
IIOffsetX.MinValue = -(int)mCore.Configuration.TableWidth;
IIOffsetY.MinValue = -(int)mCore.Configuration.TableHeight;

IIBorderTracing.MaxValue = IILinearFilling.MaxValue = IITravelSpeed.MaxValue = (int)mCore.Configuration.MaxRateX;
IIMaxPower.MaxValue = (int)mCore.Configuration.MaxPWM;
}

ImageProcessor IP;
Expand Down Expand Up @@ -82,50 +96,44 @@ public void ShowDialog(ImageProcessor processor)

ShowDialog();
}
private void IISizeW_CurrentValueChanged(object sender, int NewValue, bool ByUser)


private void IISizeW_CurrentValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
if (ByUser)
IISizeH.CurrentValue = IP.WidthToHeight(NewValue);

IP.TargetSize = new Size(IISizeW.CurrentValue, IISizeH.CurrentValue);
}

private void IISizeH_CurrentValueChanged(object sender, int NewValue, bool ByUser)
private void IISizeH_CurrentValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
if (ByUser)
IISizeW.CurrentValue = IP.HeightToWidht(NewValue);

IP.TargetSize = new Size(IISizeW.CurrentValue, IISizeH.CurrentValue);
}

void IIOffsetXYCurrentValueChanged(object sender, int NewValue, bool ByUser)
void IIOffsetXYCurrentValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
IP.TargetOffset = new Point(IIOffsetX.CurrentValue, IIOffsetY.CurrentValue);
}
void IIBorderTracingCurrentValueChanged(object sender, int NewValue, bool ByUser)

void IIBorderTracingCurrentValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
IP.BorderSpeed = NewValue;
}
void IIMarkSpeedCurrentValueChanged(object sender, int NewValue, bool ByUser)

void IIMarkSpeedCurrentValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
IP.MarkSpeed = NewValue;
}
void IITravelSpeedCurrentValueChanged(object sender, int NewValue, bool ByUser)
void IITravelSpeedCurrentValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
IP.TravelSpeed = NewValue;
}
void IIMinPowerCurrentValueChanged(object sender, int NewValue, bool ByUser)
void IIMinPowerCurrentValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
if (ByUser && IIMaxPower.CurrentValue <= NewValue)
IIMaxPower.CurrentValue = NewValue + 1;

IP.MinPower = NewValue;
}
void IIMaxPowerCurrentValueChanged(object sender, int NewValue, bool ByUser)
void IIMaxPowerCurrentValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
if (ByUser && IIMinPower.CurrentValue >= NewValue)
IIMinPower.CurrentValue = NewValue - 1;
Expand All @@ -152,6 +160,17 @@ private void CBLaserOFF_SelectedIndexChanged(object sender, EventArgs e)
{
IP.LaserOff = (string)CBLaserOFF.SelectedItem;
}

private void IISizeW_OnTheFlyValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
if (ByUser)
IISizeH.CurrentValue = IP.WidthToHeight(NewValue);
}

private void IISizeH_OnTheFlyValueChanged(object sender, int OldValue, int NewValue, bool ByUser)
{
if (ByUser) IISizeW.CurrentValue = IP.HeightToWidht(NewValue);
}

}
}
22 changes: 11 additions & 11 deletions LaserGRBL/RasterConverter/ConvertSizeAndOptionForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
<value>IIOffsetX</value>
</data>
<data name="&gt;&gt;IIOffsetX.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;IIOffsetX.Parent" xml:space="preserve">
<value>tableLayoutPanel3</value>
Expand All @@ -253,7 +253,7 @@
<value>IIOffsetY</value>
</data>
<data name="&gt;&gt;IIOffsetY.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;IIOffsetY.Parent" xml:space="preserve">
<value>tableLayoutPanel3</value>
Expand All @@ -277,7 +277,7 @@
<value>IISizeH</value>
</data>
<data name="&gt;&gt;IISizeH.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;IISizeH.Parent" xml:space="preserve">
<value>tableLayoutPanel3</value>
Expand All @@ -301,7 +301,7 @@
<value>IISizeW</value>
</data>
<data name="&gt;&gt;IISizeW.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;IISizeW.Parent" xml:space="preserve">
<value>tableLayoutPanel3</value>
Expand Down Expand Up @@ -622,7 +622,7 @@
<value>IIBorderTracing</value>
</data>
<data name="&gt;&gt;IIBorderTracing.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;IIBorderTracing.Parent" xml:space="preserve">
<value>tableLayoutPanel6</value>
Expand Down Expand Up @@ -715,7 +715,7 @@
<value>IILinearFilling</value>
</data>
<data name="&gt;&gt;IILinearFilling.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;IILinearFilling.Parent" xml:space="preserve">
<value>tableLayoutPanel6</value>
Expand All @@ -742,7 +742,7 @@
<value>IITravelSpeed</value>
</data>
<data name="&gt;&gt;IITravelSpeed.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;IITravelSpeed.Parent" xml:space="preserve">
<value>tableLayoutPanel6</value>
Expand Down Expand Up @@ -928,7 +928,7 @@ Click for more information...</value>
<value>BtnModulationInfo</value>
</data>
<data name="&gt;&gt;BtnModulationInfo.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.ImageButton, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.ImageButton, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;BtnModulationInfo.Parent" xml:space="preserve">
<value>tableLayoutPanel7</value>
Expand Down Expand Up @@ -1018,7 +1018,7 @@ Click for more information...</value>
<value>IIMinPower</value>
</data>
<data name="&gt;&gt;IIMinPower.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;IIMinPower.Parent" xml:space="preserve">
<value>tableLayoutPanel7</value>
Expand Down Expand Up @@ -1075,7 +1075,7 @@ Click for more information...</value>
<value>IIMaxPower</value>
</data>
<data name="&gt;&gt;IIMaxPower.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.IntegerInput.IntegerInputRanged, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;IIMaxPower.Parent" xml:space="preserve">
<value>tableLayoutPanel7</value>
Expand Down Expand Up @@ -1154,7 +1154,7 @@ Click for more information...</value>
<value>BtnOnOffInfo</value>
</data>
<data name="&gt;&gt;BtnOnOffInfo.Type" xml:space="preserve">
<value>LaserGRBL.UserControls.ImageButton, LaserGRBL, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null</value>
<value>LaserGRBL.UserControls.ImageButton, LaserGRBL, Version=2.8.19.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;BtnOnOffInfo.Parent" xml:space="preserve">
<value>tableLayoutPanel7</value>
Expand Down
9 changes: 5 additions & 4 deletions LaserGRBL/RasterConverter/RasterToLaserForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ namespace LaserGRBL.RasterConverter
{
public partial class RasterToLaserForm : Form
{
GrblCore mCore;
ImageProcessor IP;
bool preventClose;

bool supportPWM = (bool)Settings.GetObject("Support Hardware PWM", true);

private RasterToLaserForm(GrblCore core, string filename)
{
InitializeComponent();
mCore = core;

BackColor = ColorScheme.FormBackColor;
GbConversionTool.ForeColor = GbLineToLineOptions.ForeColor = GbParameters.ForeColor = GbVectorizeOptions.ForeColor = ForeColor = ColorScheme.FormForeColor;
Expand Down Expand Up @@ -141,7 +142,7 @@ void GoodInput(object sender, KeyPressEventArgs e)

void BtnCreateClick(object sender, EventArgs e)
{
using (ConvertSizeAndOptionForm f = new ConvertSizeAndOptionForm())
using (ConvertSizeAndOptionForm f = new ConvertSizeAndOptionForm(mCore))
{
f.ShowDialog(IP);
if (f.DialogResult == DialogResult.OK)
Expand Down Expand Up @@ -596,13 +597,13 @@ private void CbDither_SelectedIndexChanged(object sender, EventArgs e)

private void BtnQualityInfo_Click(object sender, EventArgs e)
{
UDQuality.Value = (decimal)ResolutionHelperForm.CreateAndShowDialog((double)UDQuality.Value);
UDQuality.Value = (decimal)ResolutionHelperForm.CreateAndShowDialog(mCore, (double)UDQuality.Value);
//System.Diagnostics.Process.Start(@"http://lasergrbl.com/usage/raster-image-import/setting-reliable-resolution/");
}

private void BtnFillingQualityInfo_Click(object sender, EventArgs e)
{
UDFillingQuality.Value = (decimal)ResolutionHelperForm.CreateAndShowDialog((double)UDFillingQuality.Value);
UDFillingQuality.Value = (decimal)ResolutionHelperForm.CreateAndShowDialog(mCore, (double)UDFillingQuality.Value);
//System.Diagnostics.Process.Start(@"http://lasergrbl.com/usage/raster-image-import/setting-reliable-resolution/");
}

Expand Down
4 changes: 2 additions & 2 deletions LaserGRBL/RasterConverter/ResolutionHelperForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public ResolutionHelperForm()
BtnCancel.BackColor = BtnCreate.BackColor = ColorScheme.FormButtonsColor;
}

public static double CreateAndShowDialog(double oldval)
public static double CreateAndShowDialog(GrblCore Core, double oldval)
{
double rv = oldval;

using (ResolutionHelperForm f = new ResolutionHelperForm())
{
f.UDDesired.Value = (decimal)oldval;
f.UDHardware.Value = (decimal)Settings.GetObject("Hardware Resolution", 100.0m);
f.UDHardware.Value = Core.Configuration.ResolutionX;
f.Compute(null, null);

if (f.ShowDialog() == DialogResult.OK)
Expand Down
Loading

0 comments on commit 19e93d1

Please sign in to comment.