Fix crossreference handling

This commit is contained in:
Stefan Tröger 2015-08-08 10:36:03 +02:00
parent 83eedba043
commit 2ff2d29f02
2 changed files with 52 additions and 14 deletions

View File

@ -263,7 +263,7 @@ void CmdPartDesignShapeBinder::activated(int iMsg)
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true);
if (pcActiveBody == 0)
return;
std::string FeatName = getUniqueObjectName("ShapeBinder");
std::string tmp = std::string("Create ShapeBinder");
@ -409,14 +409,21 @@ void CmdPartDesignNewSketch::activated(int iMsg)
if(result == QDialog::DialogCode::Rejected)
return;
else if(!dlg.radioXRef->isChecked()) {
// TODO This fails if we had match PlainFilter2 (2015-10-31, Fat-Zer)
const std::vector<std::string> &sub = FaceFilter.Result[0][0].getSubNames();
auto copy = PartDesignGui::TaskFeaturePick::makeCopy(obj, sub[0], dlg.radioIndependent->isChecked());
auto oBody = PartDesignGui::getBodyFor(obj, false);
if(oBody)
std::string sub;
if(FaceFilter.match())
sub = FaceFilter.Result[0][0].getSubNames()[0];
auto copy = PartDesignGui::TaskFeaturePick::makeCopy(obj, sub, dlg.radioIndependent->isChecked());
if(pcActiveBody)
pcActiveBody->addFeature(copy);
else
else if (pcActivePart)
pcActivePart->addObject(copy);
if(PlaneFilter.match())
supportString = std::string("(App.activeDocument().") + copy->getNameInDocument() + ", '')";
else
supportString = std::string("(App.activeDocument().") + copy->getNameInDocument() + ", '" + sub +"')";
}
}
}
@ -788,6 +795,30 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which,
}
}
if(!bNoSketchWasSelected && ext) {
auto* pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false);
QDialog* dia = new QDialog;
Ui_Dialog dlg;
dlg.setupUi(dia);
dia->setModal(true);
int result = dia->exec();
if(result == QDialog::DialogCode::Rejected)
return;
else if(!dlg.radioXRef->isChecked()) {
auto copy = PartDesignGui::TaskFeaturePick::makeCopy(sketches[0], "", dlg.radioIndependent->isChecked());
auto oBody = PartDesignGui::getBodyFor(sketches[0], false);
if(oBody)
pcActiveBody->addFeature(copy);
else
pcActivePart->addObject(copy);
sketches[0] = copy;
}
}
// If there is more than one selection/possibility, show dialog and let user pick sketch
if ((bNoSketchWasSelected && validSketches > 1) ||
(!bNoSketchWasSelected && sketches.size() > 1)) {

View File

@ -321,9 +321,9 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st
else {
auto name = std::string("Reference") + std::string(obj->getNameInDocument());
const char* entity = std::string("").c_str();
std::string entity;
if(!sub.empty())
entity = sub.c_str();
entity = sub;
Part::PropertyPartShape* shapeProp = nullptr;
@ -352,11 +352,11 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st
// TODO Recheck this. This looks strange in case of independent copy (2015-10-31, Fat-Zer)
if(!independent) {
datumCopy->Support.setValue(obj, entity);
datumCopy->Support.setValue(obj, entity.c_str());
datumCopy->MapMode.setValue(mode);
}
else if(strcmp(entity,"") != 0) {
datumCopy->Shape.setValue(static_cast<Part::Datum*>(obj)->Shape.getShape().getSubShape(entity));
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());
}
@ -366,7 +366,7 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st
copy = App::GetApplication().getActiveDocument()->addObject("PartDesign::ShapeBinder2D", name.c_str());
if(!independent)
static_cast<PartDesign::ShapeBinder2D*>(copy)->Support.setValue(obj, entity);
static_cast<PartDesign::ShapeBinder2D*>(copy)->Support.setValue(obj, entity.c_str());
else
shapeProp = &static_cast<PartDesign::ShapeBinder*>(copy)->Shape;
}
@ -376,10 +376,17 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st
copy = App::GetApplication().getActiveDocument()->addObject("PartDesign::ShapeBinder", name.c_str());
if(!independent)
static_cast<PartDesign::ShapeBinder*>(copy)->Support.setValue(obj, entity);
static_cast<PartDesign::ShapeBinder*>(copy)->Support.setValue(obj, entity.c_str());
else
shapeProp = &static_cast<PartDesign::ShapeBinder*>(copy)->Shape;
}
if(independent && shapeProp) {
if(entity.empty())
shapeProp->setValue(static_cast<Part::Feature*>(obj)->Shape.getValue());
else
shapeProp->setValue(static_cast<Part::Feature*>(obj)->Shape.getShape().getSubShape(entity.c_str()));
}
}
return copy;