Skip to content

Commit

Permalink
PartDesign: improve SubShapeBinder make command
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder authored and wwmayer committed Mar 20, 2020
1 parent b3835cd commit 3366a24
Showing 1 changed file with 18 additions and 28 deletions.
46 changes: 18 additions & 28 deletions src/Mod/PartDesign/Gui/Command.cpp
Expand Up @@ -383,36 +383,26 @@ void CmdPartDesignSubShapeBinder::activated(int iMsg)
pcActiveBody = PartDesignGui::getBody(false,true,true,&binderParent,&binderSub);
FeatName = getUniqueObjectName("Binder",pcActiveBody);
}
Base::Matrix4D mat;
if(values.size()==1 && binderParent && binderParent!=binder) {
App::DocumentObject *obj = values.begin()->first;
auto subs = values.begin()->second;
App::DocumentObject *sobj = 0;
App::DocumentObject *parent = 0;
std::string parentSub = binderSub;
for(auto &sub : subs) {
auto link = obj;
auto linkSub = binderSub;
auto res = binderParent->resolveRelativeLink(linkSub,link,sub);
if(!sobj) {
sobj = link;
parent = res;
parentSub = linkSub;
}else if(sobj!=link || parent!=res) {
QMessageBox::critical(Gui::getMainWindow(), QObject::tr("SubShapeBinder"),
QObject::tr("Cannot link to more than one object"));
return;
if(binderParent && binderParent!=binder) {
decltype(values) links;
for(auto &v : values) {
App::DocumentObject *obj = v.first;
if(obj == pcActiveBody)
continue;
if(obj != binderParent) {
auto &subs = links[obj];
subs.insert(subs.end(),v.second.begin(),v.second.end());
continue;
}
for(auto &sub : v.second) {
auto link = obj;
auto linkSub = binderSub;
binderParent->resolveRelativeLink(linkSub,link,sub);
if(link && link != pcActiveBody)
links[link].push_back(sub);
}
}
if(sobj) {
values.clear();
values[sobj] = std::move(subs);
}
if(parent) {
binderParent = parent;
binderSub = parentSub;
binderParent->getSubObject(binderSub.c_str(),0,&mat);
}
values = std::move(links);
}

try {
Expand Down

0 comments on commit 3366a24

Please sign in to comment.