PartDesign changes

* Mostly for supporting in-place editing

* Add new SubShapeBinder that support cross coordinate system,
  external, and sub-object binding
This commit is contained in:
Zheng, Lei
2019-07-13 18:13:21 +08:00
committed by wmayer
parent 11321bb996
commit cd2b7e297c
55 changed files with 1944 additions and 755 deletions

View File

@@ -116,21 +116,6 @@ short Body::mustExecute() const
return Part::BodyBase::mustExecute();
}
App::DocumentObject* Body::getPrevFeature(App::DocumentObject *start) const
{
std::vector<App::DocumentObject*> features = Group.getValues();
if (features.empty()) return NULL;
App::DocumentObject* st = (start == NULL ? Tip.getValue() : start);
if (st == NULL)
return st; // Tip is NULL
std::vector<App::DocumentObject*>::iterator it = std::find(features.begin(), features.end(), st);
if (it == features.end()) return NULL; // Invalid start object
it--;
return *it;
}
App::DocumentObject* Body::getPrevSolidFeature(App::DocumentObject *start)
{
if (!start) { // default to tip
@@ -246,7 +231,8 @@ bool Body::isAllowed(const App::DocumentObject* f)
f->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()) ||
// TODO Shouldn't we replace it with Sketcher::SketchObject? (2015-08-13, Fat-Zer)
f->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()) ||
f->getTypeId().isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId())
f->getTypeId().isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) ||
f->getTypeId().isDerivedFrom(PartDesign::SubShapeBinder::getClassTypeId())
// TODO Why this lines was here? why should we allow anything of those? (2015-08-13, Fat-Zer)
//f->getTypeId().isDerivedFrom(Part::FeaturePython::getClassTypeId()) // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython...
//f->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())
@@ -281,6 +267,17 @@ std::vector<App::DocumentObject*> Body::addObject(App::DocumentObject *feature)
if (isSolidFeature(feature)) {
Tip.setValue (feature);
}
if(feature->Visibility.getValue()
&& feature->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
{
for(auto obj : Group.getValues()) {
if(obj->Visibility.getValue()
&& obj!=feature
&& obj->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
obj->Visibility.setValue(false);
}
}
std::vector<App::DocumentObject*> result = {feature};
return result;
@@ -330,6 +327,9 @@ void Body::insertObject(App::DocumentObject* feature, App::DocumentObject* targe
Group.setValues (model);
if(feature->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
static_cast<PartDesign::Feature*>(feature)->_Body.setValue(this);
// Set the BaseFeature property
setBaseProperty(feature);
}
@@ -445,7 +445,9 @@ void Body::onSettingDocument() {
void Body::onChanged (const App::Property* prop) {
// we neither load a project nor perform undo/redo
if (!this->isRestoring() && !this->getDocument()->isPerformingTransaction()) {
if (!this->isRestoring()
&& this->getDocument()
&& !this->getDocument()->isPerformingTransaction()) {
if (prop == &BaseFeature) {
FeatureBase* bf = nullptr;
auto first = Group.getValues().empty() ? nullptr : Group.getValues().front();
@@ -523,3 +525,12 @@ App::DocumentObject *Body::getSubObject(const char *subname,
*pmat *= Placement.getValue().toMatrix();
return const_cast<Body*>(this);
}
void Body::onDocumentRestored()
{
for(auto obj : Group.getValues()) {
if(obj->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
static_cast<PartDesign::Feature*>(obj)->_Body.setValue(this);
}
DocumentObject::onDocumentRestored();
}