Skip to content

Commit

Permalink
PathGui: shorten preselect GCode display length
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder authored and wwmayer committed Mar 19, 2017
1 parent 2f1880c commit b6b678b
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 91 deletions.
11 changes: 5 additions & 6 deletions src/Mod/Path/App/Command.cpp
Expand Up @@ -96,16 +96,15 @@ bool Command::has(const std::string& attr) const
return Parameters.count(a) > 0;
}

std::string Command::toGCode (void) const
std::string Command::toGCode (int precision, bool padzero) const
{
std::stringstream str;
str.precision(5);
if(padzero) str.setf(std::ios::fixed);
str.precision(precision);
str << Name;
for(std::map<std::string,double>::const_iterator i = Parameters.begin(); i != Parameters.end(); ++i) {
std::string k = i->first;
if(k == "N") continue;
std::string v = std::to_string(i->second);
str << " " << k << v;
if(i->first == "N") continue;
str << " " << i->first << i->second;
}
return str.str();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/App/Command.h
Expand Up @@ -52,7 +52,7 @@ namespace Path
Base::Placement getPlacement (void) const; // returns a placement from the x,y,z,a,b,c parameters
Base::Vector3d getCenter (void) const; // returns a 3d vector from the i,j,k parameters
void setCenter(const Base::Vector3d&, bool clockwise=true); // sets the center coordinates and the command name
std::string toGCode (void) const; // returns a GCode string representation of the command
std::string toGCode (int precision=5, bool padzero=true) const; // returns a GCode string representation of the command
void setFromGCode (const std::string&); // sets the parameters from the contents of the given GCode string
void setFromPlacement (const Base::Placement&); // sets the parameters from the contents of the given placement
bool has(const std::string&) const; // returns true if the given string exists in the parameters
Expand Down

0 comments on commit b6b678b

Please sign in to comment.