本文整理汇总了C++中app::DocumentObject::getPropertyList方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentObject::getPropertyList方法的具体用法?C++ DocumentObject::getPropertyList怎么用?C++ DocumentObject::getPropertyList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app::DocumentObject
的用法示例。
在下文中一共展示了DocumentObject::getPropertyList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotNewObject
void AutoSaveProperty::slotNewObject(const App::DocumentObject& obj)
{
std::vector<App::Property*> props;
obj.getPropertyList(props);
// if an object was deleted and then restored by an undo then add all properties
// because this might be the data files which we may want to re-write
for (std::vector<App::Property*>::iterator it = props.begin(); it != props.end(); ++it) {
slotChangePropertyData(*(*it));
}
}
示例2: makeCopy
App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::string sub, bool independent) {
App::DocumentObject* copy = nullptr;
// Check for null to avoid segfault
if (!obj)
return copy;
if( independent &&
(obj->isDerivedFrom(Sketcher::SketchObject::getClassTypeId()) ||
obj->isDerivedFrom(PartDesign::FeaturePrimitive::getClassTypeId()))) {
//we do know that the created instance is a document object, as obj is one. But we do not know which
//exact type
auto name = std::string("Copy") + std::string(obj->getNameInDocument());
copy = App::GetApplication().getActiveDocument()->addObject(obj->getTypeId().getName(), name.c_str());
//copy over all properties
std::vector<App::Property*> props;
std::vector<App::Property*> cprops;
obj->getPropertyList(props);
copy->getPropertyList(cprops);
auto it = cprops.begin();
for( App::Property* prop : props ) {
//independent copies don't have links and are not attached
if(independent && (
prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId()) ||
prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId()) ||
prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId()) ||
prop->getTypeId().isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())||
( prop->getGroup() && strcmp(prop->getGroup(),"Attachment")==0) )) {
++it;
continue;
}
App::Property* cprop = *it++;
if( strcmp(prop->getName(), "Label") == 0 ) {
static_cast<App::PropertyString*>(cprop)->setValue(name.c_str());
continue;
}
cprop->Paste(*prop);
//we are a independent copy, therefore no external geometry was copied. WE therefore can delete all
//constraints
if(obj->isDerivedFrom(Sketcher::SketchObject::getClassTypeId()))
static_cast<Sketcher::SketchObject*>(copy)->delConstraintsToExternal();
}
}
else {
std::string name;
if(!independent)
name = std::string("Reference");
else
name = std::string("Copy");
name += std::string(obj->getNameInDocument());
std::string entity;
if(!sub.empty())
entity = sub;
Part::PropertyPartShape* shapeProp = nullptr;
// TODO Replace it with commands (2015-09-11, Fat-Zer)
if(obj->isDerivedFrom(Part::Datum::getClassTypeId())) {
copy = App::GetApplication().getActiveDocument()->addObject(
obj->getClassTypeId().getName(), name.c_str() );
//we need to reference the individual datums and make again datums. This is important as
//datum adjust their size dependent on the part size, hence simply copying the shape is
//not enough
long int mode = mmDeactivated;
Part::Datum *datumCopy = static_cast<Part::Datum*>(copy);
if(obj->getTypeId() == PartDesign::Point::getClassTypeId()) {
mode = mm0Vertex;
}
else if(obj->getTypeId() == PartDesign::Line::getClassTypeId()) {
mode = mm1TwoPoints;
}
else if(obj->getTypeId() == PartDesign::Plane::getClassTypeId()) {
mode = mmFlatFace;
}
else
return copy;
// TODO Recheck this. This looks strange in case of independent copy (2015-10-31, Fat-Zer)
if(!independent) {
datumCopy->Support.setValue(obj, entity.c_str());
datumCopy->MapMode.setValue(mode);
}
else if(!entity.empty()) {
datumCopy->Shape.setValue(static_cast<Part::Datum*>(obj)->Shape.getShape().getSubShape(entity.c_str()));
} else {
datumCopy->Shape.setValue(static_cast<Part::Datum*>(obj)->Shape.getValue());
}
}
//.........这里部分代码省略.........