本文整理汇总了C++中app::DocumentObject::getPropertyMap方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentObject::getPropertyMap方法的具体用法?C++ DocumentObject::getPropertyMap怎么用?C++ DocumentObject::getPropertyMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app::DocumentObject
的用法示例。
在下文中一共展示了DocumentObject::getPropertyMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activated
void StdCmdDuplicateSelection::activated(int iMsg)
{
App::Document* act = App::GetApplication().getActiveDocument();
if (!act)
return; // no active document found
Gui::Document* doc = Gui::Application::Instance->getDocument(act);
std::vector<Gui::SelectionSingleton::SelObj> sel = Gui::Selection().getCompleteSelection();
for (std::vector<SelectionSingleton::SelObj>::iterator it = sel.begin(); it != sel.end(); ++it) {
if (!it->pObject)
continue; // should actually not happen
// create a copy of the object
App::DocumentObject* copy = act->copyObject(it->pObject, false);
if (!copy) // continue if no copy could be created
continue;
// mark all properties of the copy as "touched" which are touched in the original object
std::map<std::string,App::Property*> props;
it->pObject->getPropertyMap(props);
std::map<std::string,App::Property*> copy_props;
copy->getPropertyMap(copy_props);
for (std::map<std::string,App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) {
if (jt->second->isTouched()) {
std::map<std::string,App::Property*>::iterator kt;
kt = copy_props.find(jt->first);
if (kt != copy_props.end()) {
kt->second->touch();
}
}
}
Gui::Document* parent = Gui::Application::Instance->getDocument(it->pObject->getDocument());
if (!parent || !doc)
continue; // should not happen
// copy the properties of the associated view providers
Gui::ViewProvider* view = parent->getViewProvider(it->pObject);
Gui::ViewProvider* copy_view = doc->getViewProvider(copy);
copy_view->addDynamicProperties(view);
if (!view || !copy_view)
continue; // should not happen
// get the properties of the view provider
props.clear();
view->getPropertyMap(props);
copy_props.clear();
copy_view->getPropertyMap(copy_props);
for (std::map<std::string,App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) {
std::map<std::string,App::Property*>::iterator kt;
kt = copy_props.find(jt->first);
if (kt != copy_props.end()) {
std::auto_ptr<App::Property> data(jt->second->Copy());
if (data.get()) {
kt->second->Paste(*data);
}
}
}
}
}