From a45e84a2ff7ac307ebe9af1ef6648a377399305c Mon Sep 17 00:00:00 2001 From: MX_Master Date: Wed, 13 Oct 2021 23:16:55 +0600 Subject: [PATCH] + safe height gcode parameter --- src/confscreen.cpp | 10 ++++++++++ src/exportvector.cpp | 6 +++--- src/solvespace.cpp | 3 ++- src/solvespace.h | 1 + src/ui.h | 15 ++++++++------- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/confscreen.cpp b/src/confscreen.cpp index 2eb9534..1e2e82a 100644 --- a/src/confscreen.cpp +++ b/src/confscreen.cpp @@ -161,6 +161,11 @@ void TextWindow::ScreenChangeGCodeParameter(int link, uint32_t v) { buf += SS.MmToString(SS.gCode.depth, true); break; + case 'h': + SS.TW.edit.meaning = Edit::G_CODE_SAFE_HEIGHT; + buf += SS.MmToString(SS.gCode.safeHeight, true); + break; + case 's': SS.TW.edit.meaning = Edit::G_CODE_PASSES; buf += std::to_string(SS.gCode.passes); @@ -492,6 +497,11 @@ bool TextWindow::EditControlDoneForConfiguration(const std::string &s) { if(e) SS.gCode.depth = (float)SS.ExprToMm(e); break; } + case Edit::G_CODE_SAFE_HEIGHT: { + Expr *e = Expr::From(s, /*popUpError=*/true); + if(e) SS.gCode.safeHeight = (float)SS.ExprToMm(e); + break; + } case Edit::G_CODE_PASSES: { Expr *e = Expr::From(s, /*popUpError=*/true); if(e) SS.gCode.passes = (int)(e->Eval()); diff --git a/src/exportvector.cpp b/src/exportvector.cpp index 5a3c5d3..55abac6 100644 --- a/src/exportvector.cpp +++ b/src/exportvector.cpp @@ -1102,7 +1102,7 @@ void SvgFileWriter::StartFile() { fprintf(f, "stroke-dasharray:%s;\r\n", patternStr.c_str()); } if(s->filled) { - fprintf(f, "fill:#%02x%02x%02x;\r\n", fillRgb.red, fillRgb.green, fillRgb.blue); + fprintf(f, "fill:#%02x%02x%02x;\r\n", fillRgb.red, fillRgb.green, fillRgb.blue); } else { fprintf(f, "fill:none;\r\n"); @@ -1308,9 +1308,9 @@ void GCodeFileWriter::FinishAndCloseFile() { SS.MmToString(pt->p.x).c_str(), SS.MmToString(pt->p.y).c_str(), SS.MmToString(SS.gCode.feed).c_str()); } - // Move up to a clearance plane 5mm above the work. + // Move up to a clearance plane above the work. fprintf(f, "G00 Z%s\r\n", - SS.MmToString(SS.gCode.depth < 0 ? +5 : -5).c_str()); + SS.MmToString(SS.gCode.safeHeight).c_str()); } } diff --git a/src/solvespace.cpp b/src/solvespace.cpp index 5d6d7b2..7876887 100644 --- a/src/solvespace.cpp +++ b/src/solvespace.cpp @@ -105,6 +105,7 @@ void SolveSpaceUI::Init() { exportCanvas.dy = settings->ThawFloat("ExportCanvas_Dy", 5.0); // Extra parameters when exporting G code gCode.depth = settings->ThawFloat("GCode_Depth", 10.0); + gCode.safeHeight = settings->ThawFloat("GCode_SafeHeight", 5.0); gCode.passes = settings->ThawInt("GCode_Passes", 1); gCode.feed = settings->ThawFloat("GCode_Feed", 10.0); gCode.plungeFeed = settings->ThawFloat("GCode_PlungeFeed", 10.0); @@ -413,7 +414,7 @@ static std::pair SelectSIPrefixMm(int ord, int dim) { default: dbp ("dimensions over 3 not supported"); break; - } + } return {0, "m"}; } static std::pair SelectSIPrefixInch(int deg) { diff --git a/src/solvespace.h b/src/solvespace.h index 348a8e6..8a92216 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -598,6 +598,7 @@ public: } exportCanvas; struct { double depth; + double safeHeight; int passes; double feed; double plungeFeed; diff --git a/src/ui.h b/src/ui.h index 0700653..21b00cd 100644 --- a/src/ui.h +++ b/src/ui.h @@ -314,13 +314,14 @@ public: EXPORT_OFFSET = 110, CANVAS_SIZE = 111, G_CODE_DEPTH = 112, - G_CODE_PASSES = 113, - G_CODE_FEED = 114, - G_CODE_PLUNGE_FEED = 115, - AUTOSAVE_INTERVAL = 116, - LIGHT_AMBIENT = 117, - FIND_CONSTRAINT_TIMEOUT = 118, - EXPLODE_DISTANCE = 119, + G_CODE_SAFE_HEIGHT = 113, + G_CODE_PASSES = 114, + G_CODE_FEED = 115, + G_CODE_PLUNGE_FEED = 116, + AUTOSAVE_INTERVAL = 117, + LIGHT_AMBIENT = 118, + FIND_CONSTRAINT_TIMEOUT = 119, + EXPLODE_DISTANCE = 120, // For TTF text TTF_TEXT = 300, // For the step dimension screen