Sketcher::Constraint Class Reference

#include <Constraint.h>

Public Member Functions

Constraintclone (void) const
 
 Constraint ()
 
 Constraint (Constraint &&)=delete
 
Constraintcopy (void) const
 
virtual unsigned int getMemSize (void) const override
 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...
 
Base::Quantity getPresentationValue () const
 
virtual PyObjectgetPyObject (void) override
 This method returns the Python wrapper for a C++ object. More...
 
double getValue () const
 
std::string internalAlignmentTypeToString () const
 
bool isDimensional () const
 
Constraintoperator= (const Constraint &a)=delete
 
Constraintoperator= (Constraint &&)=delete
 
virtual void Restore (Base::XMLReader &) override
 This method is used to restore properties from an XML document. More...
 
virtual void Save (Base::Writer &) const override
 This method is used to save properties to an XML document. More...
 
void setValue (double newValue)
 
void substituteIndex (int fromGeoId, int toGeoId)
 utility function to swap the index in First/Second/Third of the provided constraint from the fromGeoId GeoId to toGeoId More...
 
std::string typeToString () const
 
virtual ~Constraint ()=default
 
- 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...
 

Static Public Member Functions

static std::string internalAlignmentTypeToString (InternalAlignmentType alignment)
 
static std::string typeToString (ConstraintType type)
 
- 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 ()
 

Public Attributes

InternalAlignmentType AlignmentType
 
int First
 
PointPos FirstPos
 
int InternalAlignmentIndex
 
bool isActive
 
bool isDriving
 
bool isInVirtualSpace
 
float LabelDistance
 
float LabelPosition
 
std::string Name
 
int Second
 
PointPos SecondPos
 
int Third
 
PointPos ThirdPos
 
ConstraintType Type
 

Protected Attributes

boost::uuids::uuid tag
 

Friends

class PropertyConstraintList
 

Additional Inherited Members

- Static Protected Member Functions inherited from Base::BaseClass
static void initSubclass (Base::Type &toInit, const char *ClassName, const char *ParentName, Type::instantiationMethod method=nullptr)
 

Constructor & Destructor Documentation

◆ Constraint() [1/2]

Constraint::Constraint ( )

Referenced by clone(), copy(), and getPyObject().

◆ Constraint() [2/2]

Sketcher::Constraint::Constraint ( Constraint &&  )
delete

◆ ~Constraint()

virtual Sketcher::Constraint::~Constraint ( )
virtualdefault

Member Function Documentation

◆ clone()

◆ copy()

◆ getMemSize()

unsigned int Constraint::getMemSize ( void  ) const
overridevirtual

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.

◆ getPresentationValue()

◆ getPyObject()

PyObject * Constraint::getPyObject ( void  )
overridevirtual

This method returns the Python wrapper for a C++ object.

It's in the responsibility of the programmer to do the correct reference counting. Basically there are two ways how to implement that: Either always return a new Python object then reference counting is not a matter or return always the same Python object then the reference counter must be incremented by one. However, it's absolutely forbidden to return always the same Python object without incrementing the reference counter.

The default implementation returns 'None'.

Reimplemented from Base::BaseClass.

References Constraint().

◆ getValue()

◆ internalAlignmentTypeToString() [1/2]

std::string Sketcher::Constraint::internalAlignmentTypeToString ( ) const

◆ internalAlignmentTypeToString() [2/2]

std::string Constraint::internalAlignmentTypeToString ( InternalAlignmentType  alignment)
static

◆ isDimensional()

◆ operator=() [1/2]

Constraint & Sketcher::Constraint::operator= ( const Constraint a)
delete

◆ operator=() [2/2]

Constraint & Sketcher::Constraint::operator= ( Constraint &&  )
delete

◆ Restore()

void Constraint::Restore ( Base::XMLReader )
overridevirtual

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 AlignmentType, First, FirstPos, Base::XMLReader::getAttribute(), Base::XMLReader::getAttributeAsFloat(), Base::XMLReader::getAttributeAsInteger(), Base::XMLReader::hasAttribute(), Sketcher::InternalAlignment, InternalAlignmentIndex, isActive, isDriving, isInVirtualSpace, LabelDistance, LabelPosition, Name, Base::XMLReader::readElement(), Second, SecondPos, Third, ThirdPos, and Sketcher::Undef.

Referenced by Sketcher::PropertyConstraintList::Restore().

◆ Save()

void Constraint::Save ( Base::Writer ) const
overridevirtual

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 AlignmentType, Base::Persistence::encodeAttribute(), First, FirstPos, Base::Writer::ind(), Sketcher::InternalAlignment, InternalAlignmentIndex, isActive, isDriving, isInVirtualSpace, LabelDistance, LabelPosition, Name, Second, SecondPos, Base::Writer::Stream(), Third, and ThirdPos.

◆ setValue()

void Sketcher::Constraint::setValue ( double  newValue)

◆ substituteIndex()

void Constraint::substituteIndex ( int  fromGeoId,
int  toGeoId 
)

utility function to swap the index in First/Second/Third of the provided constraint from the fromGeoId GeoId to toGeoId

References First, Second, and Third.

Referenced by Sketcher::SketchObject::split().

◆ typeToString() [1/2]

std::string Sketcher::Constraint::typeToString ( ) const

References typeToString().

Referenced by typeToString().

◆ typeToString() [2/2]

std::string Constraint::typeToString ( ConstraintType  type)
static

Friends And Related Function Documentation

◆ PropertyConstraintList

Member Data Documentation

◆ AlignmentType

◆ First

◆ FirstPos

◆ InternalAlignmentIndex

◆ isActive

◆ isDriving

◆ isInVirtualSpace

◆ LabelDistance

float Sketcher::Constraint::LabelDistance

◆ LabelPosition

float Sketcher::Constraint::LabelPosition

◆ Name

◆ Second

◆ SecondPos

◆ tag

◆ Third

◆ ThirdPos

◆ Type


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