Path::Command Class Reference

The representation of a cnc command in a path. More...

#include <Command.h>

Public Member Functions

 Command ()
 
 Command (const char *name, const std::map< std::string, double > &parameters)
 
Base::Vector3d getCenter (void) const
 
virtual unsigned int getMemSize (void) const
 This method is used to get the size of objects It is not meant to have the exact size, it is more or less an estimation which runs fast! Is it two bytes or a GB? More...
 
double getParam (const std::string &name, double fallback=0.0) const
 
Base::Placement getPlacement (const Base::Vector3d pos=Base::Vector3d()) const
 
double getValue (const std::string &name) const
 
bool has (const std::string &) const
 
virtual void Restore (Base::XMLReader &)
 This method is used to restore properties from an XML document. More...
 
virtual void Save (Base::Writer &) const
 This method is used to save properties to an XML document. More...
 
void scaleBy (double factor)
 
void setCenter (const Base::Vector3d &, bool clockwise=true)
 
void setFromGCode (const std::string &)
 
void setFromPlacement (const Base::Placement &)
 
std::string toGCode (int precision=6, bool padzero=true) const
 
Command transform (const Base::Placement &)
 
 ~Command ()
 
- Public Member Functions inherited from Base::Persistence
void dumpToStream (std::ostream &stream, int compression)
 
virtual unsigned int getMemSize () const =0
 This method is used to get the size of objects It is not meant to have the exact size, it is more or less an estimation which runs fast! Is it two bytes or a GB? More...
 
virtual Base::Type getTypeId (void) const
 
virtual void Restore (XMLReader &)=0
 This method is used to restore properties from an XML document. More...
 
virtual void RestoreDocFile (Reader &)
 This method is used to restore large amounts of data from a file In this method you simply stream in your SaveDocFile() saved data. More...
 
void restoreFromStream (std::istream &stream)
 
virtual void Save (Writer &) const =0
 This method is used to save properties to an XML document. More...
 
virtual void SaveDocFile (Writer &) const
 This method is used to save large amounts of data to a binary file. More...
 
- Public Member Functions inherited from Base::BaseClass
 BaseClass ()
 Construction. More...
 
 BaseClass (const BaseClass &)=default
 
virtual PyObjectgetPyObject ()
 This method returns the Python wrapper for a C++ object. More...
 
virtual Type getTypeId () const
 
bool isDerivedFrom (const Type type) const
 
BaseClassoperator= (const BaseClass &)=default
 
virtual void setPyObject (PyObject *)
 
virtual ~BaseClass ()
 Destruction. More...
 

Public Attributes

std::string Name
 
std::map< std::string, double > Parameters
 

Additional Inherited Members

- Static Public Member Functions inherited from Base::Persistence
static void * create (void)
 
static std::string encodeAttribute (const std::string &)
 Encodes an attribute upon saving. More...
 
static Base::Type getClassTypeId (void)
 
static void init (void)
 
- Static Public Member Functions inherited from Base::BaseClass
static void * create ()
 
static Type getClassTypeId ()
 
static void init ()
 
- Static Protected Member Functions inherited from Base::BaseClass
static void initSubclass (Base::Type &toInit, const char *ClassName, const char *ParentName, Type::instantiationMethod method=nullptr)
 

Detailed Description

The representation of a cnc command in a path.

Constructor & Destructor Documentation

◆ Command() [1/2]

Command::Command ( )

Referenced by transform().

◆ Command() [2/2]

Command::Command ( const char *  name,
const std::map< std::string, double > &  parameters 
)

◆ ~Command()

Command::~Command ( )

Member Function Documentation

◆ getCenter()

Vector3d Command::getCenter ( void  ) const

◆ getMemSize()

unsigned int Command::getMemSize ( void  ) const
virtual

This method is used to get the size of objects It is not meant to have the exact size, it is more or less an estimation which runs fast! Is it two bytes or a GB?

Implements Base::Persistence.

References toGCode().

◆ getParam()

double Path::Command::getParam ( const std::string &  name,
double  fallback = 0.0 
) const

Referenced by getCenter(), getPlacement(), and getValue().

◆ getPlacement()

◆ getValue()

double Command::getValue ( const std::string &  name) const

References getParam().

Referenced by Path::PathSegmentWalker::walk().

◆ has()

bool Command::has ( const std::string &  attr) const

◆ Restore()

void Command::Restore ( Base::XMLReader )
virtual

This method is used to restore properties from an XML document.

It uses the XMLReader class, which bases on SAX, to read the in Save() written information. Again the Vector as an example:

void PropertyVector::Restore(Base::XMLReader &reader)
{
// read my Element
reader.readElement("PropertyVector");
// get the value of my Attribute
_cVec.x = reader.getAttributeAsFloat("valueX");
_cVec.y = reader.getAttributeAsFloat("valueY");
_cVec.z = reader.getAttributeAsFloat("valueZ");
}

Implements Base::Persistence.

References Base::XMLReader::getAttribute(), Base::XMLReader::readElement(), and setFromGCode().

◆ Save()

void Command::Save ( Base::Writer ) const
virtual

This method is used to save properties to an XML document.

A good example you'll find in PropertyStandard.cpp, e.g. the vector:

void PropertyVector::Save (Writer &writer) const
{
writer << writer.ind() << "<PropertyVector valueX=\"" << _cVec.x <<
"\" valueY=\"" << _cVec.y <<
"\" valueZ=\"" << _cVec.z <<"\"/>" << endl;
}

The writer.ind() expression writes the indentation, just for pretty printing of the XML. As you see, the writing of the XML document is not done with a DOM implementation because of performance reasons. Therefore the programmer has to take care that a valid XML document is written. This means closing tags and writing UTF-8.

See also
Base::Writer

Implements Base::Persistence.

References Base::Writer::ind(), Base::Writer::Stream(), and toGCode().

◆ scaleBy()

void Command::scaleBy ( double  factor)

References Parameters.

◆ setCenter()

void Command::setCenter ( const Base::Vector3d pos,
bool  clockwise = true 
)

◆ setFromGCode()

void Command::setFromGCode ( const std::string &  str)

References Name, and Parameters.

Referenced by Restore().

◆ setFromPlacement()

◆ toGCode()

std::string Command::toGCode ( int  precision = 6,
bool  padzero = true 
) const

◆ transform()

Member Data Documentation

◆ Name

◆ Parameters

std::map<std::string,double> Path::Command::Parameters

The documentation for this class was generated from the following files: