Stefan Schuermans commited on 2013-04-22 19:37:21
Showing 6 changed files, with 72 additions and 2 deletions.
... | ... |
@@ -365,6 +365,46 @@ bool CmdParser::procCmd_set_move_z(std::istream &strm) |
365 | 365 |
return true; |
366 | 366 |
} |
367 | 367 |
|
368 |
+/** |
|
369 |
+ * @brief process set_offset_x command |
|
370 |
+ * @param[in] strm stream to read command arguments from |
|
371 |
+ * @return if processing command was successful |
|
372 |
+ */ |
|
373 |
+bool CmdParser::procCmd_set_offset_x(std::istream &strm) |
|
374 |
+{ |
|
375 |
+ // get arguments |
|
376 |
+ double x; |
|
377 |
+ strm >> x; |
|
378 |
+ if (strm.fail()) { |
|
379 |
+ std::cerr << "missing x coordinate" << std::endl; |
|
380 |
+ return false; |
|
381 |
+ } |
|
382 |
+ |
|
383 |
+ // update settings |
|
384 |
+ mSettings.offset_x = x; |
|
385 |
+ return true; |
|
386 |
+} |
|
387 |
+ |
|
388 |
+/** |
|
389 |
+ * @brief process set_offset_y command |
|
390 |
+ * @param[in] strm stream to read command arguments from |
|
391 |
+ * @return if processing command was successful |
|
392 |
+ */ |
|
393 |
+bool CmdParser::procCmd_set_offset_y(std::istream &strm) |
|
394 |
+{ |
|
395 |
+ // get arguments |
|
396 |
+ double y; |
|
397 |
+ strm >> y; |
|
398 |
+ if (strm.fail()) { |
|
399 |
+ std::cerr << "missing y coordinate" << std::endl; |
|
400 |
+ return false; |
|
401 |
+ } |
|
402 |
+ |
|
403 |
+ // update settings |
|
404 |
+ mSettings.offset_y = y; |
|
405 |
+ return true; |
|
406 |
+} |
|
407 |
+ |
|
368 | 408 |
/** |
369 | 409 |
* @brief process set_precision command |
370 | 410 |
* @param[in] strm stream to read command arguments from |
... | ... |
@@ -484,6 +524,10 @@ bool CmdParser::procLine(const std::string &strLine) |
484 | 524 |
return procCmd_set_feed_mill(strm); |
485 | 525 |
else if (cmd == "set_move_z") |
486 | 526 |
return procCmd_set_move_z(strm); |
527 |
+ else if (cmd == "set_offset_x") |
|
528 |
+ return procCmd_set_offset_x(strm); |
|
529 |
+ else if (cmd == "set_offset_y") |
|
530 |
+ return procCmd_set_offset_y(strm); |
|
487 | 531 |
else if (cmd == "set_precision") |
488 | 532 |
return procCmd_set_precision(strm); |
489 | 533 |
else if (cmd == "set_tool_diameter") |
... | ... |
@@ -123,6 +123,20 @@ public: |
123 | 123 |
*/ |
124 | 124 |
bool procCmd_set_move_z(std::istream &strm); |
125 | 125 |
|
126 |
+ /** |
|
127 |
+ * @brief process set_offset_x command |
|
128 |
+ * @param[in] strm stream to read command arguments from |
|
129 |
+ * @return if processing command was successful |
|
130 |
+ */ |
|
131 |
+ bool procCmd_set_offset_x(std::istream &strm); |
|
132 |
+ |
|
133 |
+ /** |
|
134 |
+ * @brief process set_offset_y command |
|
135 |
+ * @param[in] strm stream to read command arguments from |
|
136 |
+ * @return if processing command was successful |
|
137 |
+ */ |
|
138 |
+ bool procCmd_set_offset_y(std::istream &strm); |
|
139 |
+ |
|
126 | 140 |
/** |
127 | 141 |
* @brief process set_precision command |
128 | 142 |
* @param[in] strm stream to read command arguments from |
... | ... |
@@ -93,6 +93,8 @@ void Path::removeEqPoints(double eqDist) |
93 | 93 |
*/ |
94 | 94 |
void Path::toGCode(const Settings &settings, double z, GCode &gcode) const |
95 | 95 |
{ |
96 |
+ Point offset(settings.offset_x, settings.offset_y); |
|
97 |
+ |
|
96 | 98 |
// leave if no points |
97 | 99 |
if (mPoints.empty()) |
98 | 100 |
return; |
... | ... |
@@ -101,7 +103,7 @@ void Path::toGCode(const Settings &settings, double z, GCode &gcode) const |
101 | 103 |
gcode.appendUp(settings.move_z); |
102 | 104 |
|
103 | 105 |
// move to start |
104 |
- gcode.appendFast(mPoints.front()); |
|
106 |
+ gcode.appendFast(mPoints.front() + offset); |
|
105 | 107 |
|
106 | 108 |
// cut down |
107 | 109 |
gcode.appendFeed(settings.feed_drill); |
... | ... |
@@ -111,7 +113,7 @@ void Path::toGCode(const Settings &settings, double z, GCode &gcode) const |
111 | 113 |
gcode.appendFeed(settings.feed_mill); |
112 | 114 |
Points::const_iterator pt = mPoints.begin(); |
113 | 115 |
for (++pt; pt != mPoints.end(); ++pt) |
114 |
- gcode.appendLinear(*pt); |
|
116 |
+ gcode.appendLinear(*pt + offset); |
|
115 | 117 |
|
116 | 118 |
// move up |
117 | 119 |
gcode.appendUp(settings.move_z); |
... | ... |
@@ -18,6 +18,8 @@ public: |
18 | 18 |
double feed_drill; ///< feed rate for drilling |
19 | 19 |
double feed_mill; ///< feed rate for milling |
20 | 20 |
double move_z; ///< z coordinate for moving |
21 |
+ double offset_x; ///< offset to add to X coordinate |
|
22 |
+ double offset_y; ///< offset to add to Y coordinate |
|
21 | 23 |
double precision; ///< precision, >= 1.0e-8 , <= 1.0 |
22 | 24 |
double tool_diameter; ///< diameter of cutting tool, >= 0.0 |
23 | 25 |
}; |
24 | 26 |