Selection: add getAsPropertyLinkSubList method
Got tired of collecting selection into such properties over and over.
This commit is contained in:
parent
03e354f7ac
commit
5449001083
|
@ -394,6 +394,30 @@ std::vector<SelectionObject> SelectionSingleton::getSelectionEx(const char* pDoc
|
|||
return temp;
|
||||
}
|
||||
|
||||
int SelectionSingleton::getAsPropertyLinkSubList(App::PropertyLinkSubList &prop) const
|
||||
{
|
||||
std::vector<Gui::SelectionObject> sel = this->getSelectionEx();
|
||||
std::vector<App::DocumentObject*> objs; objs.reserve(sel.size()*2);
|
||||
std::vector<std::string> subs; subs.reserve(sel.size()*2);
|
||||
for( int iobj = 0 ; iobj < sel.size() ; iobj++ ){
|
||||
Gui::SelectionObject &selitem = sel[iobj];
|
||||
App::DocumentObject* obj = selitem.getObject();
|
||||
const std::vector<std::string> &subnames = selitem.getSubNames();
|
||||
if (subnames.size() == 0){//whole object is selected
|
||||
objs.push_back(obj);
|
||||
subs.push_back(std::string());
|
||||
} else {
|
||||
for( int isub = 0 ; isub < subnames.size() ; isub++ ){
|
||||
objs.push_back(obj);
|
||||
subs.push_back(subnames[isub]);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(objs.size()==subs.size());
|
||||
prop.setValues(objs, subs);
|
||||
return objs.size();
|
||||
}
|
||||
|
||||
vector<App::DocumentObject*> SelectionSingleton::getObjectsOfType(const Base::Type& typeId, const char* pDocName) const
|
||||
{
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
|
|
|
@ -287,6 +287,13 @@ public:
|
|||
*/
|
||||
std::vector<Gui::SelectionObject> getSelectionEx(const char* pDocName=0,Base::Type typeId=App::DocumentObject::getClassTypeId()) const;
|
||||
|
||||
/**
|
||||
* @brief getAsPropertyLinkSubList fills PropertyLinkSubList with current selection.
|
||||
* @param prop (output). The property object to recieve links
|
||||
* @return the number of items written to the link
|
||||
*/
|
||||
int getAsPropertyLinkSubList(App::PropertyLinkSubList &prop) const;
|
||||
|
||||
/** Returns a vector of all selection objects of all documents. */
|
||||
std::vector<SelObj> getCompleteSelection() const;
|
||||
bool hasSelection() const;
|
||||
|
|
Loading…
Reference in New Issue
Block a user