Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path optimization #2070

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
501 changes: 501 additions & 0 deletions LaserGRBL/Core/GCodeSegment.cs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions LaserGRBL/Core/GrblCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,11 @@ public void OpenFile(System.Windows.Forms.Form parent, string filename = null, b
}
}

public void OptimizeCommands()
{
file.OptimizeCommands(Settings.GetObject<string>("Core.LastOpenFile", null));
}

private ImageCodecInfo GetEncoder(ImageFormat format)
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
Expand Down
25 changes: 25 additions & 0 deletions LaserGRBL/GrblFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,31 @@ public void LoadImportedSVG(string filename, bool append, GrblCore core)
RiseOnFileLoaded(filename, elapsed);
}

public void OptimizeCommands(string filename)
{
RiseOnFileLoading(filename);

long start = Tools.HiResTimer.TotalMilliseconds;

string[] lines = GCodeSegment.CleanGCode(list);
list.Clear();
foreach (string l in lines)
{
string line = l;
if ((line = line.Trim()).Length > 0)
{
GrblCommand cmd = new GrblCommand(line);
if (!cmd.IsEmpty)
list.Add(cmd);
}
}

Analyze();
long elapsed = Tools.HiResTimer.TotalMilliseconds - start;

RiseOnFileLoaded(filename, elapsed);
}


private abstract class ColorSegment
{
Expand Down
1 change: 1 addition & 0 deletions LaserGRBL/LaserGRBL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
<Compile Include="ComWrapper\MySerial\StopBits.cs" />
<Compile Include="ComWrapper\MySerial\WinSerialStream.cs" />
<Compile Include="ComWrapper\UsbSerial2.cs" />
<Compile Include="Core\GCodeSegment.cs" />
<Compile Include="Tools\Project.cs" />
<Compile Include="Core\VigoCore.cs" />
<Compile Include="CsPotrace\PotraceClipper.cs" />
Expand Down
1,661 changes: 840 additions & 821 deletions LaserGRBL/MainForm.Designer.cs

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions LaserGRBL/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private void TimerUpdate()
TTLEstimated.Text = Strings.MainFormEstimatedTime;

MnFileOpen.Enabled = Core.CanLoadNewFile;
MnSaveProject.Enabled = MnAdvancedSave.Enabled = MnSaveProgram.Enabled = Core.HasProgram;
MnSaveProject.Enabled = MnAdvancedSave.Enabled = MnSaveProgram.Enabled = MnOptimizePath.Enabled = Core.HasProgram;
MnFileSend.Enabled = Core.CanSendFile;
MnStartFromPosition.Enabled = Core.CanSendFile;
MnRunMulti.Enabled = Core.CanSendFile || Core.CanResumeHold || Core.CanFeedHold;
Expand Down Expand Up @@ -445,8 +445,6 @@ void TTOvClick(object sender, EventArgs e)
GetOvMenu().Show(Cursor.Position, ToolStripDropDownDirection.AboveLeft);
}



internal virtual System.Windows.Forms.ContextMenuStrip GetOvMenu()
{
System.Windows.Forms.ContextMenuStrip CM = new System.Windows.Forms.ContextMenuStrip();
Expand Down Expand Up @@ -506,6 +504,11 @@ private void MnSaveProject_Click(object sender, EventArgs e)
Core.SaveProject(this);
}

private void MnOptimizePath_Click(object sender, EventArgs e)
{
Core.OptimizeCommands();
}

private void MNEnglish_Click(object sender, EventArgs e)
{
SetLanguage(new System.Globalization.CultureInfo("en"));
Expand Down Expand Up @@ -993,10 +996,12 @@ private void MnConfigureOrturWiFi_Click(object sender, EventArgs e)
{
ShowWiFiConfig();
}
}


}


public class MMnRenderer : ToolStripProfessionalRenderer
public class MMnRenderer : ToolStripProfessionalRenderer
{
public MMnRenderer() : base(new CustomMenuColor()) { }

Expand Down
1,175 changes: 1,018 additions & 157 deletions LaserGRBL/MainForm.fr.resx

Large diffs are not rendered by default.

3,900 changes: 1,962 additions & 1,938 deletions LaserGRBL/MainForm.resx

Large diffs are not rendered by default.