Property: * Extended property status bitset. Mirror most of PropertyType and allow dynamic change property type. * Cache property name and type to improve performance * Centralize property status change signalling * Change aboutToSetValue()/hasSetValue() to virtual * Add new API getFullName() to obtain full quanlified name of the property AtomicPropertyChangeInterface: * Allow calling aboutToSetValue()/hasSetValue() when actually changed PropertyLists: * Refactor implementation by an abstract class PropertyListBase and a template class PropertyListsT, to allow better code reuse. PropertyListT is derived from AtomicPropertyChangeInterface to allow more efficient change on individual elements. * All list type property now accept setting python value as a dictionary with index as key to set individual element of a list. * Add touch list for more efficient handling of value changes. The list contains the index of changed value. And empty touch list should be treated as the entire list is changed. PropertyContainerPy expose this functionality with getPropertyTouchList(). PropertyPersistentObject: * New property to allow dynamic creation of any FreeCAD object derived from Base::Persistence, and use it as a property. DynamicProperty: * Use boost multi_index_container for efficient property lookup while keeping order. * Modify to be allowed to use in PropertyContainer directly PropertyContainer: * Use boost multi_index_container for efficient property lookup while keeping order. * Allow adding/removing dynamic property on all property container * Modify Save/Restore() to persist property status, and better handle transient property which can now be dynamically enabled/disabled per object. * Add new API getFullName() to obtain full quanlified name of the property. Implemented by Document, DocumentObject, and also ViewProviderDocumentObject if future patch DocumentObject and FeaturePython are modified to accommondate the dynamic property changes. Removed get/setCustomAttribute() implementation from DocumentObjectPy, and rely on PropertyContainerPy for the implementation, because of the additional dynamic property support in property container. Gui::ViewProviderDocumentObject, which is derived from PropertyContainer, is also modified accordingly
439 lines
12 KiB
C++
439 lines
12 KiB
C++
/***************************************************************************
|
|
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
|
|
* *
|
|
* This file is part of the FreeCAD CAx development system. *
|
|
* *
|
|
* This library is free software; you can redistribute it and/or *
|
|
* modify it under the terms of the GNU Library General Public *
|
|
* License as published by the Free Software Foundation; either *
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
* *
|
|
* This library is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU Library General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU Library General Public *
|
|
* License along with this library; see the file COPYING.LIB. If not, *
|
|
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
|
* Suite 330, Boston, MA 02111-1307, USA *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
|
|
#ifndef APP_PROPERTYGEO_H
|
|
#define APP_PROPERTYGEO_H
|
|
|
|
// Std. configurations
|
|
|
|
#include <Base/Vector3D.h>
|
|
#include <Base/Matrix.h>
|
|
#include <Base/BoundBox.h>
|
|
#include <Base/Placement.h>
|
|
|
|
#include "Property.h"
|
|
#include "PropertyLinks.h"
|
|
#include "ComplexGeoData.h"
|
|
|
|
namespace Base {
|
|
class Writer;
|
|
}
|
|
|
|
namespace Data {
|
|
class ComplexGeoData;
|
|
}
|
|
|
|
namespace App
|
|
{
|
|
class Feature;
|
|
class Placement;
|
|
|
|
|
|
|
|
/** Vector properties
|
|
* This is the father of all properties handling Integers.
|
|
*/
|
|
class AppExport PropertyVector: public Property
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
/**
|
|
* A constructor.
|
|
* A more elaborate description of the constructor.
|
|
*/
|
|
PropertyVector();
|
|
|
|
/**
|
|
* A destructor.
|
|
* A more elaborate description of the destructor.
|
|
*/
|
|
virtual ~PropertyVector();
|
|
|
|
/** Sets the property
|
|
*/
|
|
void setValue(const Base::Vector3d &vec);
|
|
void setValue(double x, double y, double z);
|
|
|
|
/// Get valid paths for this property; used by auto completer
|
|
void getPaths(std::vector<ObjectIdentifier> &paths) const;
|
|
|
|
/** This method returns a string representation of the property
|
|
*/
|
|
const Base::Vector3d &getValue(void) const;
|
|
const char* getEditorName(void) const {
|
|
return "Gui::PropertyEditor::PropertyVectorItem";
|
|
}
|
|
|
|
virtual PyObject *getPyObject(void);
|
|
virtual void setPyObject(PyObject *);
|
|
|
|
virtual void Save (Base::Writer &writer) const;
|
|
virtual void Restore(Base::XMLReader &reader);
|
|
|
|
virtual Property *Copy(void) const;
|
|
virtual void Paste(const Property &from);
|
|
|
|
virtual unsigned int getMemSize (void) const {
|
|
return sizeof(Base::Vector3d);
|
|
}
|
|
|
|
private:
|
|
Base::Vector3d _cVec;
|
|
};
|
|
|
|
|
|
class AppExport PropertyVectorDistance: public PropertyVector
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
/**
|
|
* A constructor.
|
|
* A more elaborate description of the constructor.
|
|
*/
|
|
PropertyVectorDistance();
|
|
|
|
/**
|
|
* A destructor.
|
|
* A more elaborate description of the destructor.
|
|
*/
|
|
virtual ~PropertyVectorDistance();
|
|
|
|
const boost::any getPathValue(const ObjectIdentifier &path) const;
|
|
|
|
const char* getEditorName(void) const {
|
|
return "Gui::PropertyEditor::PropertyVectorDistanceItem";
|
|
}
|
|
};
|
|
|
|
class AppExport PropertyPosition: public PropertyVector
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
/**
|
|
* A constructor.
|
|
* A more elaborate description of the constructor.
|
|
*/
|
|
PropertyPosition();
|
|
|
|
/**
|
|
* A destructor.
|
|
* A more elaborate description of the destructor.
|
|
*/
|
|
virtual ~PropertyPosition();
|
|
|
|
const boost::any getPathValue(const ObjectIdentifier &path) const;
|
|
|
|
const char* getEditorName(void) const {
|
|
return "Gui::PropertyEditor::PropertyPositionItem";
|
|
}
|
|
};
|
|
|
|
class AppExport PropertyDirection: public PropertyVector
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
/**
|
|
* A constructor.
|
|
* A more elaborate description of the constructor.
|
|
*/
|
|
PropertyDirection();
|
|
|
|
/**
|
|
* A destructor.
|
|
* A more elaborate description of the destructor.
|
|
*/
|
|
virtual ~PropertyDirection();
|
|
|
|
const boost::any getPathValue(const ObjectIdentifier &path) const;
|
|
|
|
const char* getEditorName(void) const {
|
|
return "Gui::PropertyEditor::PropertyDirectionItem";
|
|
}
|
|
};
|
|
|
|
class AppExport PropertyVectorList: public PropertyListsT<Base::Vector3d>
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
typedef PropertyListsT<Base::Vector3d> inherited;
|
|
|
|
public:
|
|
/**
|
|
* A constructor.
|
|
* A more elaborate description of the constructor.
|
|
*/
|
|
PropertyVectorList();
|
|
|
|
/**
|
|
* A destructor.
|
|
* A more elaborate description of the destructor.
|
|
*/
|
|
virtual ~PropertyVectorList();
|
|
|
|
void setValue(double x, double y, double z);
|
|
using inherited::setValue;
|
|
|
|
virtual PyObject *getPyObject(void);
|
|
|
|
virtual void Save (Base::Writer &writer) const;
|
|
virtual void Restore(Base::XMLReader &reader);
|
|
|
|
virtual void SaveDocFile (Base::Writer &writer) const;
|
|
virtual void RestoreDocFile(Base::Reader &reader);
|
|
|
|
virtual Property *Copy(void) const;
|
|
virtual void Paste(const Property &from);
|
|
|
|
virtual unsigned int getMemSize (void) const;
|
|
|
|
protected:
|
|
Base::Vector3d getPyValue(PyObject *) const override;
|
|
};
|
|
|
|
/// Property representing a 4x4 matrix
|
|
/*!
|
|
* Encapsulates a Base::Matrix4D in a Property
|
|
*/
|
|
class AppExport PropertyMatrix: public Property
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
/**
|
|
* A constructor.
|
|
* Intitialises to an identity matrix
|
|
*/
|
|
PropertyMatrix();
|
|
|
|
/**
|
|
* A destructor.
|
|
* A more elaborate description of the destructor.
|
|
*/
|
|
virtual ~PropertyMatrix();
|
|
|
|
/** Sets the property
|
|
*/
|
|
void setValue(const Base::Matrix4D &mat);
|
|
|
|
/** This method returns a string representation of the property
|
|
*/
|
|
const Base::Matrix4D &getValue(void) const;
|
|
const char* getEditorName(void) const {
|
|
return "Gui::PropertyEditor::PropertyMatrixItem";
|
|
}
|
|
|
|
virtual PyObject *getPyObject(void);
|
|
virtual void setPyObject(PyObject *);
|
|
|
|
virtual void Save (Base::Writer &writer) const;
|
|
virtual void Restore(Base::XMLReader &reader);
|
|
|
|
virtual Property *Copy(void) const;
|
|
virtual void Paste(const Property &from);
|
|
|
|
virtual unsigned int getMemSize (void) const {
|
|
return sizeof(Base::Matrix4D);
|
|
}
|
|
|
|
private:
|
|
Base::Matrix4D _cMat;
|
|
};
|
|
|
|
/** Vector properties
|
|
* This is the father of all properties handling Integers.
|
|
*/
|
|
class AppExport PropertyPlacement: public Property
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
/**
|
|
* A constructor.
|
|
* A more elaborate description of the constructor.
|
|
*/
|
|
PropertyPlacement();
|
|
|
|
/**
|
|
* A destructor.
|
|
* A more elaborate description of the destructor.
|
|
*/
|
|
virtual ~PropertyPlacement();
|
|
|
|
/** Sets the property
|
|
*/
|
|
void setValue(const Base::Placement &pos);
|
|
|
|
/** Sets property only if changed
|
|
* @param pos: input placement
|
|
* @param tol: position tolerance
|
|
* @param atol: angular tolerance
|
|
*/
|
|
bool setValueIfChanged(const Base::Placement &pos,
|
|
double tol=1e-7, double atol=1e-12);
|
|
|
|
/** This method returns a string representation of the property
|
|
*/
|
|
const Base::Placement &getValue(void) const;
|
|
|
|
/// Get valid paths for this property; used by auto completer
|
|
void getPaths(std::vector<ObjectIdentifier> &paths) const;
|
|
|
|
void setPathValue(const ObjectIdentifier &path, const boost::any &value);
|
|
|
|
const boost::any getPathValue(const ObjectIdentifier &path) const;
|
|
|
|
const char* getEditorName(void) const {
|
|
return "Gui::PropertyEditor::PropertyPlacementItem";
|
|
}
|
|
|
|
virtual PyObject *getPyObject(void);
|
|
virtual void setPyObject(PyObject *);
|
|
|
|
virtual void Save (Base::Writer &writer) const;
|
|
virtual void Restore(Base::XMLReader &reader);
|
|
|
|
virtual Property *Copy(void) const;
|
|
virtual void Paste(const Property &from);
|
|
|
|
virtual unsigned int getMemSize (void) const {
|
|
return sizeof(Base::Placement);
|
|
}
|
|
|
|
static const Placement Null;
|
|
|
|
private:
|
|
Base::Placement _cPos;
|
|
};
|
|
|
|
/** the general Link Property
|
|
* Main Purpose of this property is to Link Objects and Features in a document.
|
|
*/
|
|
class AppExport PropertyPlacementLink : public PropertyLink
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
/**
|
|
* A constructor.
|
|
* A more elaborate description of the constructor.
|
|
*/
|
|
PropertyPlacementLink();
|
|
|
|
/**
|
|
* A destructor.
|
|
* A more elaborate description of the destructor.
|
|
*/
|
|
virtual ~PropertyPlacementLink();
|
|
|
|
/** This method returns the linked DocumentObject
|
|
*/
|
|
App::Placement * getPlacementObject(void) const;
|
|
|
|
virtual Property *Copy(void) const;
|
|
virtual void Paste(const Property &from);
|
|
};
|
|
|
|
|
|
class AppExport PropertyPlacementList: public PropertyListsT<Base::Placement>
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
/**
|
|
* A property that stores a list of placements
|
|
*/
|
|
PropertyPlacementList();
|
|
|
|
virtual ~PropertyPlacementList();
|
|
|
|
virtual PyObject *getPyObject(void);
|
|
|
|
virtual void Save (Base::Writer &writer) const;
|
|
virtual void Restore(Base::XMLReader &reader);
|
|
|
|
virtual void SaveDocFile (Base::Writer &writer) const;
|
|
virtual void RestoreDocFile(Base::Reader &reader);
|
|
|
|
virtual Property *Copy(void) const;
|
|
virtual void Paste(const Property &from);
|
|
|
|
virtual unsigned int getMemSize (void) const;
|
|
|
|
protected:
|
|
Base::Placement getPyValue(PyObject *) const override;
|
|
};
|
|
|
|
|
|
/** The base class for all basic geometry properties.
|
|
* @author Werner Mayer
|
|
*/
|
|
class AppExport PropertyGeometry : public App::Property
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
PropertyGeometry();
|
|
virtual ~PropertyGeometry();
|
|
|
|
/** @name Modification */
|
|
//@{
|
|
/// Applies a transformation on the real geometric data type
|
|
virtual void transformGeometry(const Base::Matrix4D &rclMat) = 0;
|
|
/// Retrieve bounding box information
|
|
virtual Base::BoundBox3d getBoundingBox() const = 0;
|
|
//@}
|
|
};
|
|
|
|
/** The base class for all complex data properties.
|
|
* @author Werner Mayer
|
|
*/
|
|
class AppExport PropertyComplexGeoData : public App::PropertyGeometry
|
|
{
|
|
TYPESYSTEM_HEADER();
|
|
|
|
public:
|
|
PropertyComplexGeoData();
|
|
virtual ~PropertyComplexGeoData();
|
|
|
|
/** @name Modification */
|
|
//@{
|
|
/// Applies a transformation on the real geometric data type
|
|
virtual void transformGeometry(const Base::Matrix4D &rclMat) = 0;
|
|
//@}
|
|
|
|
/** @name Getting basic geometric entities */
|
|
//@{
|
|
virtual const Data::ComplexGeoData* getComplexData() const = 0;
|
|
virtual Base::BoundBox3d getBoundingBox() const = 0;
|
|
//@}
|
|
};
|
|
|
|
} // namespace App
|
|
|
|
|
|
#endif // APP_PROPERTYGEO_H
|