App: fix trailing whitespace
This commit is contained in:
@@ -25,7 +25,7 @@ ENDIF(DOCDIR)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
#write relevant cmake variables to a file for later access with python. Exported are all variables
|
||||
#write relevant cmake variables to a file for later access with python. Exported are all variables
|
||||
#starting with BUILD. As the variable only exists if the user set it to ON a dict is useless, we
|
||||
#use a python list for export.
|
||||
set(_vars "const char CMakeVariables[] =\"cmake = [")
|
||||
|
||||
@@ -53,10 +53,10 @@ GeoFeatureGroupExtension::GeoFeatureGroupExtension()
|
||||
GeoFeatureGroupExtension::~GeoFeatureGroupExtension() = default;
|
||||
|
||||
void GeoFeatureGroupExtension::initExtension(ExtensionContainer* obj) {
|
||||
|
||||
|
||||
if(!obj->isDerivedFrom(App::GeoFeature::getClassTypeId()))
|
||||
throw Base::RuntimeError("GeoFeatureGroupExtension can only be applied to GeoFeatures");
|
||||
|
||||
|
||||
App::GroupExtension::initExtension(obj);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ PropertyPlacement& GeoFeatureGroupExtension::placement() {
|
||||
|
||||
if(!getExtendedContainer())
|
||||
throw Base::RuntimeError("GeoFeatureGroupExtension was not applied to GeoFeature");
|
||||
|
||||
|
||||
return static_cast<App::GeoFeature*>(getExtendedContainer())->Placement;
|
||||
}
|
||||
|
||||
@@ -81,19 +81,19 @@ DocumentObject* GeoFeatureGroupExtension::getGroupOfObject(const DocumentObject*
|
||||
{
|
||||
if(!obj)
|
||||
return nullptr;
|
||||
|
||||
|
||||
//we will find origins, but not origin features
|
||||
if(obj->isDerivedFrom(App::OriginFeature::getClassTypeId()))
|
||||
if(obj->isDerivedFrom(App::OriginFeature::getClassTypeId()))
|
||||
return OriginGroupExtension::getGroupOfObject(obj);
|
||||
|
||||
|
||||
//compared to GroupExtension we do return here all GeoFeatureGroups including all extensions derived from it
|
||||
//like OriginGroup. That is needed as we use this function to get all local coordinate systems. Also there
|
||||
//is no reason to distinguish between GeoFeatuerGroups, there is only between group/geofeaturegroup
|
||||
auto list = obj->getInList();
|
||||
for (auto inObj : list) {
|
||||
|
||||
//There is a chance that a derived geofeaturegroup links with a local link and hence is not
|
||||
//the parent group even though it links to the object. We use hasObject as one and only truth
|
||||
|
||||
//There is a chance that a derived geofeaturegroup links with a local link and hence is not
|
||||
//the parent group even though it links to the object. We use hasObject as one and only truth
|
||||
//if it has the object within the group
|
||||
auto group = inObj->getExtensionByType<GeoFeatureGroupExtension>(true);
|
||||
if(group && group->hasObject(obj))
|
||||
@@ -136,47 +136,47 @@ Base::Placement GeoFeatureGroupExtension::recursiveGroupPlacement(GeoFeatureGrou
|
||||
}
|
||||
|
||||
std::vector<DocumentObject*> GeoFeatureGroupExtension::addObjects(std::vector<App::DocumentObject*> objects) {
|
||||
|
||||
|
||||
std::vector<DocumentObject*> grp = Group.getValues();
|
||||
std::vector<DocumentObject*> ret;
|
||||
|
||||
|
||||
for(auto object : objects) {
|
||||
|
||||
|
||||
if(!allowObject(object))
|
||||
continue;
|
||||
|
||||
//cross CoordinateSystem links are not allowed, so we need to move the whole link group
|
||||
|
||||
//cross CoordinateSystem links are not allowed, so we need to move the whole link group
|
||||
std::vector<App::DocumentObject*> links = getCSRelevantLinks(object);
|
||||
links.push_back(object);
|
||||
|
||||
|
||||
for( auto obj : links) {
|
||||
//only one geofeaturegroup per object.
|
||||
//only one geofeaturegroup per object.
|
||||
auto *group = App::GeoFeatureGroupExtension::getGroupOfObject(obj);
|
||||
if(group && group != getExtendedObject())
|
||||
group->getExtensionByType<App::GroupExtension>()->removeObject(obj);
|
||||
|
||||
|
||||
if (!hasObject(obj)) {
|
||||
grp.push_back(obj);
|
||||
ret.push_back(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Group.setValues(grp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<DocumentObject*> GeoFeatureGroupExtension::removeObjects(std::vector<App::DocumentObject*> objects) {
|
||||
|
||||
|
||||
std::vector<DocumentObject*> removed;
|
||||
std::vector<DocumentObject*> grp = Group.getValues();
|
||||
|
||||
|
||||
for(auto object : objects) {
|
||||
//cross CoordinateSystem links are not allowed, so we need to remove the whole link group
|
||||
//cross CoordinateSystem links are not allowed, so we need to remove the whole link group
|
||||
std::vector< DocumentObject* > links = getCSRelevantLinks(object);
|
||||
links.push_back(object);
|
||||
|
||||
//remove all links out of group
|
||||
|
||||
//remove all links out of group
|
||||
for(auto link : links) {
|
||||
auto end = std::remove(grp.begin(), grp.end(), link);
|
||||
if(end != grp.end()) {
|
||||
@@ -185,10 +185,10 @@ std::vector<DocumentObject*> GeoFeatureGroupExtension::removeObjects(std::vector
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!removed.empty())
|
||||
Group.setValues(grp);
|
||||
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
@@ -196,11 +196,11 @@ void GeoFeatureGroupExtension::extensionOnChanged(const Property* p) {
|
||||
|
||||
//objects are only allowed in a single GeoFeatureGroup
|
||||
if(p == &Group && !Group.testStatus(Property::User3)) {
|
||||
|
||||
|
||||
if((!getExtendedObject()->isRestoring()
|
||||
|| getExtendedObject()->getDocument()->testStatus(Document::Importing))
|
||||
&& !getExtendedObject()->getDocument()->isPerformingTransaction()) {
|
||||
|
||||
|
||||
bool error = false;
|
||||
auto corrected = Group.getValues();
|
||||
for(auto obj : Group.getValues()) {
|
||||
@@ -279,7 +279,7 @@ void GeoFeatureGroupExtension::getCSOutList(const App::DocumentObject* obj,
|
||||
//we get all relevant linked objects. We can't use outList() as this includes the links from expressions,
|
||||
//also we only want links with scope Local
|
||||
auto result = getScopedObjectsFromLinks(obj, LinkScope::Local);
|
||||
|
||||
|
||||
//we remove all links to origin features and origins, they belong to a CS too and can't be moved
|
||||
result.erase(std::remove_if(result.begin(), result.end(), [](App::DocumentObject* obj)->bool {
|
||||
return (obj->isDerivedFrom(App::OriginFeature::getClassTypeId()) ||
|
||||
@@ -306,7 +306,7 @@ void GeoFeatureGroupExtension::getCSInList(const DocumentObject* obj,
|
||||
if(parent->hasExtension(App::GroupExtension::getExtensionClassTypeId()))
|
||||
continue;
|
||||
|
||||
//check if the link is real Local scope one or if it is a expression one (could also be both, so it is not
|
||||
//check if the link is real Local scope one or if it is a expression one (could also be both, so it is not
|
||||
//enough to check the expressions)
|
||||
auto res = getScopedObjectsFromLinks(parent, LinkScope::Local);
|
||||
if(std::find(res.begin(), res.end(), obj) != res.end())
|
||||
@@ -323,7 +323,7 @@ std::vector< DocumentObject* > GeoFeatureGroupExtension::getCSRelevantLinks(cons
|
||||
if(!obj)
|
||||
return std::vector< DocumentObject* >();
|
||||
|
||||
//get all out links
|
||||
//get all out links
|
||||
std::vector<DocumentObject*> vec;
|
||||
|
||||
recursiveCSRelevantLinks(obj, vec);
|
||||
@@ -336,7 +336,7 @@ std::vector< DocumentObject* > GeoFeatureGroupExtension::getCSRelevantLinks(cons
|
||||
return vec;
|
||||
}
|
||||
|
||||
void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* obj,
|
||||
void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* obj,
|
||||
std::vector< DocumentObject* >& vec) {
|
||||
|
||||
if(!obj)
|
||||
@@ -347,7 +347,7 @@ void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* ob
|
||||
getCSInList(obj, links);
|
||||
|
||||
//go on traversing the graph in all directions!
|
||||
for(auto o : links) {
|
||||
for(auto o : links) {
|
||||
if(!o || o == obj || std::find(vec.begin(), vec.end(), o) != vec.end())
|
||||
continue;
|
||||
|
||||
@@ -357,14 +357,14 @@ void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* ob
|
||||
}
|
||||
|
||||
bool GeoFeatureGroupExtension::extensionGetSubObject(DocumentObject *&ret, const char *subname,
|
||||
PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const
|
||||
PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const
|
||||
{
|
||||
ret = nullptr;
|
||||
const char *dot;
|
||||
if(!subname || *subname==0) {
|
||||
auto obj = dynamic_cast<const DocumentObject*>(getExtendedContainer());
|
||||
ret = const_cast<DocumentObject*>(obj);
|
||||
if(mat && transform)
|
||||
if(mat && transform)
|
||||
*mat *= const_cast<GeoFeatureGroupExtension*>(this)->placement().getValue().toMatrix();
|
||||
}else if((dot=strchr(subname,'.'))) {
|
||||
if(subname[0]!='$')
|
||||
@@ -380,9 +380,9 @@ bool GeoFeatureGroupExtension::extensionGetSubObject(DocumentObject *&ret, const
|
||||
}
|
||||
if(ret) {
|
||||
if(dot) ++dot;
|
||||
if(dot && *dot
|
||||
if(dot && *dot
|
||||
&& !ret->hasExtension(App::LinkBaseExtension::getExtensionClassTypeId())
|
||||
&& !ret->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId()))
|
||||
&& !ret->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId()))
|
||||
{
|
||||
// Consider this
|
||||
// Body
|
||||
@@ -405,7 +405,7 @@ bool GeoFeatureGroupExtension::extensionGetSubObject(DocumentObject *&ret, const
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mat && transform)
|
||||
if(mat && transform)
|
||||
*mat *= const_cast<GeoFeatureGroupExtension*>(this)->placement().getValue().toMatrix();
|
||||
ret = ret->getSubObject(dot?dot:"",pyObj,mat,true,depth+1);
|
||||
}
|
||||
@@ -446,7 +446,7 @@ bool GeoFeatureGroupExtension::isLinkValid(App::Property* prop) {
|
||||
auto result = getScopedObjectsFromLink(prop, LinkScope::Local);
|
||||
auto group = getGroupOfObject(obj);
|
||||
for(auto link : result) {
|
||||
if(getGroupOfObject(link) != group)
|
||||
if(getGroupOfObject(link) != group)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ bool GeoFeatureGroupExtension::isLinkValid(App::Property* prop) {
|
||||
result = getScopedObjectsFromLink(prop, LinkScope::Child);
|
||||
auto groupExt = obj->getExtensionByType<App::GeoFeatureGroupExtension>();
|
||||
for(auto link : result) {
|
||||
if(!groupExt->hasObject(link, true))
|
||||
if(!groupExt->hasObject(link, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -472,7 +472,7 @@ void GeoFeatureGroupExtension::getInvalidLinkObjects(const DocumentObject* obj,
|
||||
auto result = getScopedObjectsFromLinks(obj, LinkScope::Local);
|
||||
auto group = obj->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId()) ? obj : getGroupOfObject(obj);
|
||||
for(auto link : result) {
|
||||
if(getGroupOfObject(link) != group)
|
||||
if(getGroupOfObject(link) != group)
|
||||
vec.push_back(link);
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ void GeoFeatureGroupExtension::getInvalidLinkObjects(const DocumentObject* obj,
|
||||
result = getScopedObjectsFromLinks(obj, LinkScope::Child);
|
||||
auto groupExt = group->getExtensionByType<App::GeoFeatureGroupExtension>();
|
||||
for(auto link : result) {
|
||||
if(!groupExt->hasObject(link, true))
|
||||
if(!groupExt->hasObject(link, true))
|
||||
vec.push_back(link);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,16 +36,16 @@ namespace App
|
||||
|
||||
/**
|
||||
* @brief The base class for placeable group of DocumentObjects. It represents a local coordnate system
|
||||
*
|
||||
* This class is the FreeCAD way of representing local coordinate systems. It groups its children beneath
|
||||
*
|
||||
* This class is the FreeCAD way of representing local coordinate systems. It groups its children beneath
|
||||
* it and transforms them all with the GeoFeatureGroup placement. A few important properties:
|
||||
* - Every child that belongs to the CS must be in the Group property. Even if a sketch is part of a pad,
|
||||
* it must be in the Group property of the same GeoFeatureGroup as pad. This also holds for normal
|
||||
* GroupExtensions. They can be added to a GeoFeatureGroup, but all objects that the group holds must
|
||||
* it must be in the Group property of the same GeoFeatureGroup as pad. This also holds for normal
|
||||
* GroupExtensions. They can be added to a GeoFeatureGroup, but all objects that the group holds must
|
||||
* also be added to the GeoFeatureGroup
|
||||
* - Objects can be only in a single GeoFeatureGroup. It is not allowed to have a document object in
|
||||
* - Objects can be only in a single GeoFeatureGroup. It is not allowed to have a document object in
|
||||
* multiple GeoFeatureGroups
|
||||
* - PropertyLinks between different GeoFeatureGroups are forbidden. There are special link properties
|
||||
* - PropertyLinks between different GeoFeatureGroups are forbidden. There are special link properties
|
||||
* that allow such cross-CS links.
|
||||
* - Expressions can cross GeoFeatureGroup borders
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ class AppExport GeoFeatureGroupExtension : public App::GroupExtension
|
||||
|
||||
public:
|
||||
PropertyPlacement& placement();
|
||||
|
||||
|
||||
void initExtension(ExtensionContainer* obj) override;
|
||||
|
||||
/**
|
||||
@@ -66,11 +66,11 @@ public:
|
||||
* @param transform (input).
|
||||
*/
|
||||
virtual void transformPlacement(const Base::Placement &transform);
|
||||
|
||||
|
||||
/// Constructor
|
||||
GeoFeatureGroupExtension();
|
||||
~GeoFeatureGroupExtension() override;
|
||||
|
||||
|
||||
void extensionOnChanged(const Property* p) override;
|
||||
|
||||
/** Returns the geo feature group which contains this object.
|
||||
@@ -79,14 +79,14 @@ public:
|
||||
* @param obj the object to search for
|
||||
*/
|
||||
static DocumentObject* getGroupOfObject(const DocumentObject* obj);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculates the global placement of this group
|
||||
*
|
||||
* The returned placement describes the transformation from the global reference coordinate
|
||||
*
|
||||
* The returned placement describes the transformation from the global reference coordinate
|
||||
* system to the local coordinate system of this geo feature group. If this group has a no parent
|
||||
* GeoFeatureGroup the returned placement is the one of this group. For multiple stacked
|
||||
* GeoFeatureGroups the returned Placement is the combination of all parent placements including
|
||||
* GeoFeatureGroup the returned placement is the one of this group. For multiple stacked
|
||||
* GeoFeatureGroups the returned Placement is the combination of all parent placements including
|
||||
* the one of this group.
|
||||
* @return Base::Placement The transformation from global reference system to the groups local system
|
||||
*/
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
|
||||
/// Returns true if the given DocumentObject is DocumentObjectGroup but not GeoFeatureGroup
|
||||
static bool isNonGeoGroup(const DocumentObject* obj) {
|
||||
return obj->hasExtension(GroupExtension::getExtensionClassTypeId()) &&
|
||||
return obj->hasExtension(GroupExtension::getExtensionClassTypeId()) &&
|
||||
!obj->hasExtension(GeoFeatureGroupExtension::getExtensionClassTypeId());
|
||||
}
|
||||
|
||||
@@ -102,41 +102,41 @@ public:
|
||||
Base::Matrix4D *mat, bool transform, int depth) const override;
|
||||
|
||||
bool extensionGetSubObjects(std::vector<std::string> &ret, int reason) const override;
|
||||
|
||||
|
||||
std::vector< DocumentObject* > addObjects(std::vector< DocumentObject* > obj) override;
|
||||
std::vector< DocumentObject* > removeObjects(std::vector< DocumentObject* > obj) override;
|
||||
|
||||
/// Collects all links that are relevant for the coordinate system, meaning all recursive links to
|
||||
/// obj and from obj excluding expressions and stopping the recursion at other geofeaturegroups.
|
||||
|
||||
/// Collects all links that are relevant for the coordinate system, meaning all recursive links to
|
||||
/// obj and from obj excluding expressions and stopping the recursion at other geofeaturegroups.
|
||||
/// The result is the combination of CSOutList and CSInList.
|
||||
static std::vector<App::DocumentObject*> getCSRelevantLinks(const App::DocumentObject* obj);
|
||||
/// Checks if the links of the given object comply with all GeoFeatureGroup requirements, that means
|
||||
/// if normal links are only within the parent GeoFeatureGroup.
|
||||
/// if normal links are only within the parent GeoFeatureGroup.
|
||||
static bool areLinksValid(const App::DocumentObject* obj);
|
||||
/// Checks if the given link complies with all GeoFeatureGroup requirements, that means
|
||||
/// if normal links are only within the parent GeoFeatureGroup.
|
||||
/// if normal links are only within the parent GeoFeatureGroup.
|
||||
static bool isLinkValid(App::Property* link);
|
||||
//Returns all objects that are wrongly linked from this object, meaning which are out of scope of the
|
||||
//Returns all objects that are wrongly linked from this object, meaning which are out of scope of the
|
||||
//links of obj
|
||||
static void getInvalidLinkObjects(const App::DocumentObject* obj, std::vector<App::DocumentObject*>& vec);
|
||||
|
||||
|
||||
private:
|
||||
Base::Placement recursiveGroupPlacement(GeoFeatureGroupExtension* group, std::unordered_set<GeoFeatureGroupExtension*>& history);
|
||||
static std::vector<App::DocumentObject*> getScopedObjectsFromLinks(const App::DocumentObject*, LinkScope scope = LinkScope::Local);
|
||||
static std::vector<App::DocumentObject*> getScopedObjectsFromLink(App::Property*, LinkScope scope = LinkScope::Local);
|
||||
|
||||
/// Collects GeoFeatureGroup relevant objects that are linked from the given one. That means all linked objects
|
||||
/// except GeoFeatureGroups. Expressions links are ignored. Only local scope links are considered. There is no
|
||||
/// except GeoFeatureGroups. Expressions links are ignored. Only local scope links are considered. There is no
|
||||
/// recursion. An exception is thrown when there are dependency loops.
|
||||
static void getCSOutList(const App::DocumentObject* obj, std::vector<App::DocumentObject*>& vec);
|
||||
/// Collects GeoFeatureGroup relevant objects that link to the given one. That means all objects
|
||||
/// except GeoFeatureGroups. Expression links are ignored. Only local scope links are relevant, and
|
||||
/// except GeoFeatureGroups. Expression links are ignored. Only local scope links are relevant, and
|
||||
/// there is no recursion. An exception is thrown when there are dependency loops.
|
||||
static void getCSInList(const App::DocumentObject* obj, std::vector<App::DocumentObject*>& vec);
|
||||
|
||||
|
||||
static void recursiveCSRelevantLinks(const App::DocumentObject* obj,
|
||||
std::vector<App::DocumentObject*>& vec);
|
||||
|
||||
|
||||
};
|
||||
|
||||
using GeoFeatureGroupExtensionPython = ExtensionPythonT<GroupExtensionPythonT<GeoFeatureGroupExtension>>;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
Include="App/GeoFeatureGroupExtension.h"
|
||||
Namespace="App"
|
||||
FatherInclude="App/GroupExtensionPy.h"
|
||||
FatherNamespace="App">
|
||||
FatherNamespace="App">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
|
||||
<UserDocu>This class handles placeable group of document objects</UserDocu>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="DocumentObjectPy"
|
||||
Name="GeoFeaturePy"
|
||||
Twin="GeoFeature"
|
||||
TwinPointer="GeoFeature"
|
||||
Include="App/GeoFeature.h"
|
||||
Namespace="App"
|
||||
FatherInclude="App/DocumentObjectPy.h"
|
||||
<PythonExport
|
||||
Father="DocumentObjectPy"
|
||||
Name="GeoFeaturePy"
|
||||
Twin="GeoFeature"
|
||||
TwinPointer="GeoFeature"
|
||||
Include="App/GeoFeature.h"
|
||||
Namespace="App"
|
||||
FatherInclude="App/DocumentObjectPy.h"
|
||||
FatherNamespace="App">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Jürgen Riegel" EMail="FreeCAD@juergen-riegel.net" />
|
||||
|
||||
@@ -44,10 +44,10 @@ PyObject* GeoFeaturePy::getPaths(PyObject * /*args*/)
|
||||
}
|
||||
|
||||
PyObject* GeoFeaturePy::getGlobalPlacement(PyObject * args) {
|
||||
|
||||
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
|
||||
try {
|
||||
Base::Placement p = static_cast<GeoFeature*>(getDocumentObjectPtr())->globalPlacement();
|
||||
return new Base::PlacementPy(new Base::Placement(p));
|
||||
@@ -91,5 +91,5 @@ PyObject *GeoFeaturePy::getCustomAttributes(const char* /*attr*/) const
|
||||
|
||||
int GeoFeaturePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="DocumentObjectExtensionPy"
|
||||
Name="LinkBaseExtensionPy"
|
||||
TwinPointer="LinkBaseExtension"
|
||||
Twin="LinkBaseExtension"
|
||||
Include="App/Link.h"
|
||||
Namespace="App"
|
||||
FatherInclude="App/DocumentObjectExtensionPy.h"
|
||||
<PythonExport
|
||||
Father="DocumentObjectExtensionPy"
|
||||
Name="LinkBaseExtensionPy"
|
||||
TwinPointer="LinkBaseExtension"
|
||||
Twin="LinkBaseExtension"
|
||||
Include="App/Link.h"
|
||||
Namespace="App"
|
||||
FatherInclude="App/DocumentObjectExtensionPy.h"
|
||||
FatherNamespace="App">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Zheng, Lei" EMail="realthunder.dev@gmail.com" />
|
||||
@@ -23,7 +23,7 @@ This methode is here to implement what I called Property Design
|
||||
Pattern. The extension operates on a predefined set of properties,
|
||||
but it relies on the extended object to supply the actual property by
|
||||
calling this methode. You can choose a sub set of functionality of
|
||||
this extension by supplying only some of the supported properties.
|
||||
this extension by supplying only some of the supported properties.
|
||||
|
||||
The 'key' are names used to refer to properties supported by this
|
||||
extension, and 'val' is the actual name of the property of your
|
||||
@@ -72,7 +72,7 @@ setLink({index:(obj,subName,subElements),...}): set link element of a link group
|
||||
|
||||
obj (DocumentObject): the object to link to. If this is None, then the link is cleared
|
||||
|
||||
subName (String): Dot separated object path.
|
||||
subName (String): Dot separated object path.
|
||||
|
||||
subElements (String|tuple(String)): non-object sub-elements, e.g. Face1, Edge2.
|
||||
</UserDocu>
|
||||
|
||||
@@ -139,22 +139,22 @@ void MetadataPy::setVersion(Py::Object args)
|
||||
const char *name = nullptr;
|
||||
if (!PyArg_Parse(args.ptr(), "z", &name))
|
||||
throw Py::Exception();
|
||||
if (name && name[0] != '\0')
|
||||
if (name && name[0] != '\0')
|
||||
getMetadataPtr()->setVersion(App::Meta::Version(std::string(name)));
|
||||
else
|
||||
getMetadataPtr()->setVersion(App::Meta::Version());
|
||||
}
|
||||
|
||||
Py::Object MetadataPy::getDate() const
|
||||
{
|
||||
return Py::String(getMetadataPtr()->date());
|
||||
Py::Object MetadataPy::getDate() const
|
||||
{
|
||||
return Py::String(getMetadataPtr()->date());
|
||||
}
|
||||
|
||||
void MetadataPy::setDate(Py::Object args)
|
||||
{
|
||||
const char *date = nullptr;
|
||||
if (!PyArg_Parse(args.ptr(), "z", &date))
|
||||
throw Py::Exception();
|
||||
if (!PyArg_Parse(args.ptr(), "z", &date))
|
||||
throw Py::Exception();
|
||||
if (date) getMetadataPtr()->setDate(date);
|
||||
else
|
||||
getMetadataPtr()->setDate("");
|
||||
|
||||
@@ -1112,7 +1112,7 @@ void ObjectIdentifier::getDepLabels(
|
||||
}
|
||||
|
||||
ObjectIdentifier::Dependencies
|
||||
ObjectIdentifier::getDep(bool needProps, std::vector<std::string> *labels) const
|
||||
ObjectIdentifier::getDep(bool needProps, std::vector<std::string> *labels) const
|
||||
{
|
||||
Dependencies deps;
|
||||
getDep(deps,needProps,labels);
|
||||
@@ -1122,7 +1122,7 @@ ObjectIdentifier::getDep(bool needProps, std::vector<std::string> *labels) const
|
||||
void ObjectIdentifier::getDep(Dependencies &deps, bool needProps, std::vector<std::string> *labels) const
|
||||
{
|
||||
ResolveResults result(*this);
|
||||
if(labels)
|
||||
if(labels)
|
||||
getDepLabels(result,*labels);
|
||||
|
||||
if(!result.resolvedDocumentObject)
|
||||
@@ -1306,7 +1306,7 @@ Property *ObjectIdentifier::resolveProperty(const App::DocumentObject *obj,
|
||||
}
|
||||
return &const_cast<App::DocumentObject*>(obj)->Label; //fake the property
|
||||
}
|
||||
|
||||
|
||||
return obj->getPropertyByName(propertyName);
|
||||
}
|
||||
|
||||
@@ -1676,13 +1676,13 @@ Py::Object ObjectIdentifier::access(const ResolveResults &result,
|
||||
if(prop && prop->getContainer()!=obj) {
|
||||
auto linkTouched = Base::freecad_dynamic_cast<PropertyBool>(
|
||||
obj->getPropertyByName("_LinkTouched"));
|
||||
if(linkTouched)
|
||||
if(linkTouched)
|
||||
propName = linkTouched->getName();
|
||||
else {
|
||||
auto propOwner = Base::freecad_dynamic_cast<DocumentObject>(prop->getContainer());
|
||||
if(propOwner)
|
||||
if(propOwner)
|
||||
obj = propOwner;
|
||||
else
|
||||
else
|
||||
propName = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
<PythonExport
|
||||
Father="GeoFeaturePy"
|
||||
Name="PartPy"
|
||||
Twin="Part"
|
||||
TwinPointer="Part"
|
||||
Include="App/Part.h"
|
||||
Namespace="App"
|
||||
Name="PartPy"
|
||||
Twin="Part"
|
||||
TwinPointer="Part"
|
||||
Include="App/Part.h"
|
||||
Namespace="App"
|
||||
FatherInclude="App/GeoFeaturePy.h"
|
||||
FatherNamespace="App">
|
||||
<Documentation>
|
||||
|
||||
@@ -62,7 +62,7 @@ void PropertyExpressionContainer::slotRelabelDocument(const App::Document &doc)
|
||||
// For use a private _ExprContainers to track all living
|
||||
// PropertyExpressionContainer including those inside undo/redo stack,
|
||||
// because document relabel is not undoable/redoable.
|
||||
|
||||
|
||||
if(doc.getOldLabel() != doc.Label.getValue()) {
|
||||
for(auto prop : _ExprContainers)
|
||||
prop->onRelabeledDocument(doc);
|
||||
@@ -280,7 +280,7 @@ void PropertyExpressionEngine::Save(Base::Writer &writer) const
|
||||
<< Property::encodeAttribute(it->first.toString()) <<"\" expression=\""
|
||||
<< Property::encodeAttribute(expression) << "\"";
|
||||
if (!comment.empty())
|
||||
writer.Stream() << " comment=\""
|
||||
writer.Stream() << " comment=\""
|
||||
<< Property::encodeAttribute(comment) << "\"";
|
||||
writer.Stream() << "/>" << std::endl;
|
||||
}
|
||||
@@ -431,7 +431,7 @@ void PropertyExpressionEngine::onContainerRestored() {
|
||||
UpdateElementReferenceExpressionVisitor<PropertyExpressionEngine> v(*this);
|
||||
for(auto &e : expressions) {
|
||||
auto expr = e.second.expression;
|
||||
if(expr)
|
||||
if(expr)
|
||||
expr->visit(v);
|
||||
}
|
||||
}
|
||||
@@ -473,8 +473,8 @@ void PropertyExpressionEngine::setValue(const ObjectIdentifier & path, std::shar
|
||||
// Check if the current expression equals the new one and do nothing if so to reduce unneeded computations
|
||||
ExpressionMap::iterator it = expressions.find(usePath);
|
||||
if(it != expressions.end()
|
||||
&& (expr == it->second.expression ||
|
||||
(expr && it->second.expression
|
||||
&& (expr == it->second.expression ||
|
||||
(expr && it->second.expression
|
||||
&& expr->isSame(*it->second.expression))))
|
||||
{
|
||||
return;
|
||||
@@ -523,7 +523,7 @@ struct cycle_detector : public boost::dfs_visitor<> {
|
||||
*/
|
||||
|
||||
void PropertyExpressionEngine::buildGraph(const ExpressionMap & exprs,
|
||||
boost::unordered_map<int, ObjectIdentifier> & revNodes,
|
||||
boost::unordered_map<int, ObjectIdentifier> & revNodes,
|
||||
DiGraph & g, ExecuteOption option) const
|
||||
{
|
||||
boost::unordered_map<ObjectIdentifier, int> nodes;
|
||||
@@ -538,7 +538,7 @@ void PropertyExpressionEngine::buildGraph(const ExpressionMap & exprs,
|
||||
bool is_output = prop->testStatus(App::Property::Output)||(prop->getType()&App::Prop_Output);
|
||||
if((is_output && option==ExecuteNonOutput) || (!is_output && option==ExecuteOutput))
|
||||
continue;
|
||||
if(option == ExecuteOnRestore
|
||||
if(option == ExecuteOnRestore
|
||||
&& !prop->testStatus(Property::Transient)
|
||||
&& !(prop->getType() & Prop_Transient)
|
||||
&& !prop->testStatus(Property::EvalOnRestore))
|
||||
@@ -732,7 +732,7 @@ void PropertyExpressionEngine::getPathsToDocumentObject(DocumentObject* obj,
|
||||
auto it = deps.find(obj);
|
||||
if(it==deps.end())
|
||||
continue;
|
||||
for(auto &dep : it->second)
|
||||
for(auto &dep : it->second)
|
||||
paths.insert(paths.end(),dep.second.begin(),dep.second.end());
|
||||
}
|
||||
}
|
||||
@@ -927,7 +927,7 @@ bool PropertyExpressionEngine::adjustLink(const std::set<DocumentObject*> &inLis
|
||||
return true;
|
||||
}
|
||||
|
||||
void PropertyExpressionEngine::updateElementReference(DocumentObject *feature, bool reverse, bool notify)
|
||||
void PropertyExpressionEngine::updateElementReference(DocumentObject *feature, bool reverse, bool notify)
|
||||
{
|
||||
(void)notify;
|
||||
if(!feature)
|
||||
@@ -954,7 +954,7 @@ bool PropertyExpressionEngine::referenceChanged() const {
|
||||
}
|
||||
|
||||
Property *PropertyExpressionEngine::CopyOnImportExternal(
|
||||
const std::map<std::string,std::string> &nameMap) const
|
||||
const std::map<std::string,std::string> &nameMap) const
|
||||
{
|
||||
std::unique_ptr<PropertyExpressionEngine> engine;
|
||||
for(auto it=expressions.begin();it!=expressions.end();++it) {
|
||||
@@ -963,7 +963,7 @@ Property *PropertyExpressionEngine::CopyOnImportExternal(
|
||||
#else
|
||||
std::shared_ptr<Expression> expr(it->second.expression->importSubNames(nameMap));
|
||||
#endif
|
||||
if(!expr && !engine)
|
||||
if(!expr && !engine)
|
||||
continue;
|
||||
if(!engine) {
|
||||
engine.reset(new PropertyExpressionEngine);
|
||||
@@ -981,7 +981,7 @@ Property *PropertyExpressionEngine::CopyOnImportExternal(
|
||||
return engine.release();
|
||||
}
|
||||
|
||||
Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj,
|
||||
Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj,
|
||||
const std::string &ref, const char *newLabel) const
|
||||
{
|
||||
std::unique_ptr<PropertyExpressionEngine> engine;
|
||||
@@ -991,7 +991,7 @@ Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj,
|
||||
#else
|
||||
std::shared_ptr<Expression> expr(it->second.expression->updateLabelReference(obj,ref,newLabel));
|
||||
#endif
|
||||
if(!expr && !engine)
|
||||
if(!expr && !engine)
|
||||
continue;
|
||||
if(!engine) {
|
||||
engine.reset(new PropertyExpressionEngine);
|
||||
@@ -1011,7 +1011,7 @@ Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj,
|
||||
return engine.release();
|
||||
}
|
||||
|
||||
Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject *parent,
|
||||
Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject *parent,
|
||||
App::DocumentObject *oldObj, App::DocumentObject *newObj) const
|
||||
{
|
||||
std::unique_ptr<PropertyExpressionEngine> engine;
|
||||
@@ -1023,7 +1023,7 @@ Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject
|
||||
std::shared_ptr<Expression> expr(
|
||||
it->second.expression->replaceObject(parent,oldObj,newObj));
|
||||
#endif
|
||||
if(!expr && !engine)
|
||||
if(!expr && !engine)
|
||||
continue;
|
||||
if(!engine) {
|
||||
engine.reset(new PropertyExpressionEngine);
|
||||
@@ -1043,11 +1043,11 @@ Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject
|
||||
return engine.release();
|
||||
}
|
||||
|
||||
std::map<App::ObjectIdentifier, const App::Expression*>
|
||||
PropertyExpressionEngine::getExpressions() const
|
||||
std::map<App::ObjectIdentifier, const App::Expression*>
|
||||
PropertyExpressionEngine::getExpressions() const
|
||||
{
|
||||
std::map<App::ObjectIdentifier, const Expression*> res;
|
||||
for(auto &v : expressions)
|
||||
for(auto &v : expressions)
|
||||
res[v.first] = v.second.expression.get();
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
static void slotRelabelDocument(const App::Document &doc);
|
||||
};
|
||||
|
||||
class AppExport PropertyExpressionEngine : public App::PropertyExpressionContainer,
|
||||
class AppExport PropertyExpressionEngine : public App::PropertyExpressionContainer,
|
||||
private App::AtomicPropertyChangeInterface<PropertyExpressionEngine>
|
||||
{
|
||||
TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
ExecuteOnRestore,
|
||||
};
|
||||
/** Evaluate the expressions
|
||||
*
|
||||
*
|
||||
* @param option: execution option, see ExecuteOption.
|
||||
*/
|
||||
DocumentObjectExecReturn * execute(ExecuteOption option=ExecuteAll, bool *touched=nullptr);
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
|
||||
size_t numExpressions() const;
|
||||
|
||||
///signal called when an expression was changed
|
||||
///signal called when an expression was changed
|
||||
boost::signals2::signal<void (const App::ObjectIdentifier &)> expressionChanged;
|
||||
|
||||
void afterRestore() override;
|
||||
@@ -192,7 +192,7 @@ private:
|
||||
boost::unordered_map<int, App::ObjectIdentifier> &revNodes, std::vector<Edge> &edges) const;
|
||||
|
||||
void buildGraph(const ExpressionMap &exprs,
|
||||
boost::unordered_map<int, App::ObjectIdentifier> &revNodes,
|
||||
boost::unordered_map<int, App::ObjectIdentifier> &revNodes,
|
||||
DiGraph &g, ExecuteOption option=ExecuteAll) const;
|
||||
|
||||
void slotChangedObject(const App::DocumentObject &obj, const App::Property &prop);
|
||||
|
||||
@@ -50,7 +50,7 @@ struct AppExport CellAddress {
|
||||
};
|
||||
|
||||
explicit CellAddress(int row = -1, int col = -1, bool absRow=false, bool absCol=false)
|
||||
: _row(row), _col(col), _absRow(absRow), _absCol(absCol)
|
||||
: _row(row), _col(col), _absRow(absRow), _absCol(absCol)
|
||||
{ }
|
||||
|
||||
explicit CellAddress(const char * address) {
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
|
||||
CellAddress operator*() const { return CellAddress(row_curr, col_curr); }
|
||||
|
||||
inline bool operator<(const Range & other) const {
|
||||
inline bool operator<(const Range & other) const {
|
||||
if(from() < other.from())
|
||||
return true;
|
||||
if(from() > other.from())
|
||||
|
||||
Reference in New Issue
Block a user