PartDesign: Port body to be a origin group
This commit is contained in:
parent
47ed29fffd
commit
9a3b952fb9
|
@ -49,20 +49,20 @@ public:
|
|||
/** Adds an object of \a sType with \a pObjectName to the document this group belongs to and
|
||||
* append it to this group as well.
|
||||
*/
|
||||
DocumentObject *addObject(const char* sType, const char* pObjectName);
|
||||
virtual DocumentObject *addObject(const char* sType, const char* pObjectName);
|
||||
/* Adds the object \a obj to this group.
|
||||
*/
|
||||
void addObject(DocumentObject* obj);
|
||||
virtual void addObject(DocumentObject* obj);
|
||||
/*override this function if you want only special objects
|
||||
*/
|
||||
virtual bool allowObject(DocumentObject* ) {return true;};
|
||||
|
||||
/** Removes an object from this group.
|
||||
*/
|
||||
void removeObject(DocumentObject* obj);
|
||||
virtual void removeObject(DocumentObject* obj);
|
||||
/** Removes all children objects from this group and the document.
|
||||
*/
|
||||
void removeObjectsFromDocument();
|
||||
virtual void removeObjectsFromDocument();
|
||||
/** Returns the object of this group with \a Name. If the group doesn't have such an object 0 is returned.
|
||||
* @note This method might return 0 even if the document this group belongs to contains an object with this name.
|
||||
*/
|
||||
|
|
|
@ -35,21 +35,14 @@
|
|||
namespace Part {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(Part::BodyBase, Part::Feature)
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(Part::BodyBase, Part::Feature)
|
||||
|
||||
BodyBase::BodyBase()
|
||||
{
|
||||
ADD_PROPERTY(Model , (0) );
|
||||
ADD_PROPERTY(Tip , (0) );
|
||||
ADD_PROPERTY(BaseFeature , (0) );
|
||||
}
|
||||
|
||||
bool BodyBase::hasFeature(const App::DocumentObject* f) const
|
||||
{
|
||||
const std::vector<App::DocumentObject*> &features = Model.getValues();
|
||||
return f == BaseFeature.getValue() || std::find(features.begin(), features.end(), f) != features.end();
|
||||
}
|
||||
|
||||
BodyBase* BodyBase::findBodyOf(const App::DocumentObject* f)
|
||||
{
|
||||
App::Document* doc = f->getDocument();
|
||||
|
@ -57,7 +50,7 @@ BodyBase* BodyBase::findBodyOf(const App::DocumentObject* f)
|
|||
std::vector<App::DocumentObject*> bodies = doc->getObjectsOfType(BodyBase::getClassTypeId());
|
||||
for (std::vector<App::DocumentObject*>::const_iterator b = bodies.begin(); b != bodies.end(); b++) {
|
||||
BodyBase* body = static_cast<BodyBase*>(*b);
|
||||
if (body->hasFeature(f))
|
||||
if (body->hasObject(f))
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
@ -73,10 +66,10 @@ bool BodyBase::isAfter(const App::DocumentObject *feature, const App::DocumentOb
|
|||
}
|
||||
|
||||
if (!target || target == BaseFeature.getValue() ) {
|
||||
return hasFeature (feature);
|
||||
return hasObject (feature);
|
||||
}
|
||||
|
||||
const std::vector<App::DocumentObject *> & features = Model.getValues();
|
||||
const std::vector<App::DocumentObject *> & features = Group.getValues();
|
||||
auto featureIt = std::find(features.begin(), features.end(), feature);
|
||||
auto targetIt = std::find(features.begin(), features.end(), target);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define PART_BodyBase_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/OriginGroupExtension.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
|
||||
|
@ -36,19 +37,16 @@ namespace Part
|
|||
* in edit or active on a workbench, the body shows only the
|
||||
* resulting shape to the outside (Tip link).
|
||||
*/
|
||||
class PartExport BodyBase : public Part::Feature
|
||||
class PartExport BodyBase : public Part::Feature, public App::OriginGroupExtension
|
||||
{
|
||||
PROPERTY_HEADER(Part::BodyBase);
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(Part::BodyBase);
|
||||
|
||||
public:
|
||||
BodyBase();
|
||||
|
||||
/// The list of features
|
||||
App::PropertyLinkList Model;
|
||||
|
||||
/**
|
||||
* The final feature of the body it is associated with.
|
||||
* Note: tip may either point to the BaseFeature or to some feature inside the Model list.
|
||||
* Note: tip may either point to the BaseFeature or to some feature inside the Group list.
|
||||
* in case it points to the model the PartDesign::Body guaranties that it is a solid.
|
||||
*/
|
||||
App::PropertyLink Tip;
|
||||
|
@ -59,23 +57,16 @@ public:
|
|||
*/
|
||||
App::PropertyLink BaseFeature;
|
||||
|
||||
/// Returns all Model objects prepanded by BaseFeature (if any)
|
||||
/// Returns all Group objects prepanded by BaseFeature (if any)
|
||||
std::vector<App::DocumentObject *> getFullModel () {
|
||||
std::vector<App::DocumentObject *> rv;
|
||||
if ( BaseFeature.getValue () ) {
|
||||
rv.push_back ( BaseFeature.getValue () );
|
||||
}
|
||||
std::copy ( Model.getValues ().begin (), Model.getValues ().end (), std::back_inserter (rv) );
|
||||
std::copy ( Group.getValues ().begin (), Group.getValues ().end (), std::back_inserter (rv) );
|
||||
return rv;
|
||||
}
|
||||
|
||||
// These methods are located here to avoid a dependency of ViewProviderSketchObject on PartDesign
|
||||
/// Remove the feature from the body
|
||||
virtual void removeFeature(App::DocumentObject*){}
|
||||
|
||||
/// Return true if the feature belongs to this body or either the body is based on the feature
|
||||
bool hasFeature(const App::DocumentObject *f) const;
|
||||
|
||||
/// Return true if the feature belongs to the body and is located after the target
|
||||
bool isAfter(const App::DocumentObject *feature, const App::DocumentObject *target) const;
|
||||
|
||||
|
|
|
@ -60,15 +60,15 @@ Body::Body() {
|
|||
|
||||
/*
|
||||
// Note: The following code will catch Python Document::removeObject() modifications. If the object removed is
|
||||
// a member of the Body::Model, then it will be automatically removed from the Model property which triggers the
|
||||
// a member of the Body::Group, then it will be automatically removed from the Group property which triggers the
|
||||
// following two methods
|
||||
// But since we require the Python user to call both Document::addObject() and Body::addFeature(), we should
|
||||
// also require calling both Document::removeObject and Body::removeFeature() in order to be consistent
|
||||
void Body::onBeforeChange(const App::Property *prop)
|
||||
{
|
||||
// Remember the feature before the current Tip. If the Tip is already at the first feature, remember the next feature
|
||||
if (prop == &Model) {
|
||||
std::vector<App::DocumentObject*> features = Model.getValues();
|
||||
if (prop == &Group) {
|
||||
std::vector<App::DocumentObject*> features = Group.getValues();
|
||||
if (features.empty()) {
|
||||
rememberTip = NULL;
|
||||
} else {
|
||||
|
@ -91,8 +91,8 @@ void Body::onBeforeChange(const App::Property *prop)
|
|||
|
||||
void Body::onChanged(const App::Property *prop)
|
||||
{
|
||||
if (prop == &Model) {
|
||||
std::vector<App::DocumentObject*> features = Model.getValues();
|
||||
if (prop == &Group) {
|
||||
std::vector<App::DocumentObject*> features = Group.getValues();
|
||||
if (features.empty()) {
|
||||
Tip.setValue(NULL);
|
||||
} else {
|
||||
|
@ -119,7 +119,7 @@ short Body::mustExecute() const
|
|||
|
||||
App::DocumentObject* Body::getPrevFeature(App::DocumentObject *start) const
|
||||
{
|
||||
std::vector<App::DocumentObject*> features = Model.getValues();
|
||||
std::vector<App::DocumentObject*> features = Group.getValues();
|
||||
if (features.empty()) return NULL;
|
||||
App::DocumentObject* st = (start == NULL ? Tip.getValue() : start);
|
||||
if (st == NULL)
|
||||
|
@ -146,9 +146,9 @@ App::DocumentObject* Body::getPrevSolidFeature(App::DocumentObject *start)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
assert ( hasFeature ( start ) );
|
||||
assert ( hasObject ( start ) );
|
||||
|
||||
const std::vector<App::DocumentObject*> & features = Model.getValues();
|
||||
const std::vector<App::DocumentObject*> & features = Group.getValues();
|
||||
|
||||
auto startIt = std::find ( features.rbegin(), features.rend(), start );
|
||||
assert ( startIt != features.rend() );
|
||||
|
@ -173,9 +173,9 @@ App::DocumentObject* Body::getNextSolidFeature(App::DocumentObject *start)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
assert ( hasFeature ( start ) );
|
||||
assert ( hasObject ( start ) );
|
||||
|
||||
const std::vector<App::DocumentObject*> & features = Model.getValues();
|
||||
const std::vector<App::DocumentObject*> & features = Group.getValues();
|
||||
std::vector<App::DocumentObject*>::const_iterator startIt;
|
||||
|
||||
if ( start == baseFeature ) {
|
||||
|
@ -264,9 +264,12 @@ Body* Body::findBodyOf(const App::DocumentObject* feature)
|
|||
}
|
||||
|
||||
|
||||
void Body::addFeature(App::DocumentObject *feature)
|
||||
void Body::addObject(App::DocumentObject *feature)
|
||||
{
|
||||
insertFeature (feature, getNextSolidFeature (), /*after = */ false);
|
||||
if(!isAllowed(feature))
|
||||
throw Base::Exception("Body: object is not allowed");
|
||||
|
||||
insertObject (feature, getNextSolidFeature (), /*after = */ false);
|
||||
// Move the Tip if we added a solid
|
||||
if (isSolidFeature(feature)) {
|
||||
Tip.setValue (feature);
|
||||
|
@ -274,7 +277,7 @@ void Body::addFeature(App::DocumentObject *feature)
|
|||
}
|
||||
|
||||
|
||||
void Body::insertFeature(App::DocumentObject* feature, App::DocumentObject* target, bool after)
|
||||
void Body::insertObject(App::DocumentObject* feature, App::DocumentObject* target, bool after)
|
||||
{
|
||||
if (target) {
|
||||
if (target == BaseFeature.getValue()) {
|
||||
|
@ -284,13 +287,13 @@ void Body::insertFeature(App::DocumentObject* feature, App::DocumentObject* targ
|
|||
} else {
|
||||
throw Base::Exception("Body: impossible to insert before the base object");
|
||||
}
|
||||
} else if (!hasFeature (target)) {
|
||||
} else if (!hasObject (target)) {
|
||||
// Check if the target feature belongs to the body
|
||||
throw Base::Exception("Body: the feature we should insert relative to is not part of that body");
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> model = Model.getValues();
|
||||
std::vector<App::DocumentObject*> model = Group.getValues();
|
||||
std::vector<App::DocumentObject*>::iterator insertInto;
|
||||
|
||||
// Find out the position there to insert the feature
|
||||
|
@ -313,7 +316,7 @@ void Body::insertFeature(App::DocumentObject* feature, App::DocumentObject* targ
|
|||
// Insert the new feature after the given
|
||||
model.insert (insertInto, feature);
|
||||
|
||||
Model.setValues (model);
|
||||
Group.setValues (model);
|
||||
|
||||
// Set the BaseFeature property
|
||||
if (Body::isSolidFeature(feature)) {
|
||||
|
@ -333,7 +336,7 @@ void Body::insertFeature(App::DocumentObject* feature, App::DocumentObject* targ
|
|||
}
|
||||
|
||||
|
||||
void Body::removeFeature(App::DocumentObject* feature)
|
||||
void Body::removeObject(App::DocumentObject* feature)
|
||||
{
|
||||
App::DocumentObject* nextSolidFeature = getNextSolidFeature(feature);
|
||||
App::DocumentObject* prevSolidFeature = getPrevSolidFeature(feature);
|
||||
|
@ -348,7 +351,7 @@ void Body::removeFeature(App::DocumentObject* feature)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> model = Model.getValues();
|
||||
std::vector<App::DocumentObject*> model = Group.getValues();
|
||||
std::vector<App::DocumentObject*>::iterator it = std::find(model.begin(), model.end(), feature);
|
||||
|
||||
// Adjust Tip feature if it is pointing to the deleted object
|
||||
|
@ -360,9 +363,9 @@ void Body::removeFeature(App::DocumentObject* feature)
|
|||
}
|
||||
}
|
||||
|
||||
// Erase feature from Model
|
||||
// Erase feature from Group
|
||||
model.erase(it);
|
||||
Model.setValues(model);
|
||||
Group.setValues(model);
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,8 +375,8 @@ App::DocumentObjectExecReturn *Body::execute(void)
|
|||
Base::Console().Error("Body '%s':\n", getNameInDocument());
|
||||
App::DocumentObject* tip = Tip.getValue();
|
||||
Base::Console().Error(" Tip: %s\n", (tip == NULL) ? "None" : tip->getNameInDocument());
|
||||
std::vector<App::DocumentObject*> model = Model.getValues();
|
||||
Base::Console().Error(" Model:\n");
|
||||
std::vector<App::DocumentObject*> model = Group.getValues();
|
||||
Base::Console().Error(" Group:\n");
|
||||
for (std::vector<App::DocumentObject*>::const_iterator m = model.begin(); m != model.end(); m++) {
|
||||
if (*m == NULL) continue;
|
||||
Base::Console().Error(" %s", (*m)->getNameInDocument());
|
||||
|
@ -422,14 +425,6 @@ void Body::onSettingDocument() {
|
|||
Part::BodyBase::onSettingDocument();
|
||||
}
|
||||
|
||||
void Body::removeModelFromDocument() {
|
||||
//delete all child objects if needed
|
||||
std::set<DocumentObject*> grp ( Model.getValues().begin (), Model.getValues().end() );
|
||||
for (auto obj : grp) {
|
||||
this->getDocument()->remObject(obj->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
void Body::onChanged (const App::Property* prop) {
|
||||
if ( prop == &BaseFeature ) {
|
||||
App::DocumentObject *baseFeature = BaseFeature.getValue();
|
||||
|
@ -443,24 +438,6 @@ void Body::onChanged (const App::Property* prop) {
|
|||
Part::BodyBase::onChanged ( prop );
|
||||
}
|
||||
|
||||
App::Origin *Body::getOrigin () const {
|
||||
App::DocumentObject *originObj = Origin.getValue ();
|
||||
|
||||
if ( !originObj ) {
|
||||
std::stringstream err;
|
||||
err << "Can't find Origin for \"" << getNameInDocument () << "\"";
|
||||
throw Base::Exception ( err.str().c_str () );
|
||||
|
||||
} else if (! originObj->isDerivedFrom ( App::Origin::getClassTypeId() ) ) {
|
||||
std::stringstream err;
|
||||
err << "Bad object \"" << originObj->getNameInDocument () << "\"(" << originObj->getTypeId().getName()
|
||||
<< ") linked to the Origin of \"" << getNameInDocument () << "\"";
|
||||
throw Base::Exception ( err.str().c_str () );
|
||||
} else {
|
||||
return static_cast<App::Origin *> ( originObj );
|
||||
}
|
||||
}
|
||||
|
||||
void Body::setupObject () {
|
||||
// NOTE: the code shared with App::OriginGroup
|
||||
App::Document *doc = getDocument ();
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
* Add the feature into the body at the current insert point.
|
||||
* The insertion poin is the before next solid after the Tip feature
|
||||
*/
|
||||
void addFeature(App::DocumentObject* feature);
|
||||
virtual void addObject(App::DocumentObject*) override;
|
||||
|
||||
/**
|
||||
* Insert the feature into the body after the given feature.
|
||||
|
@ -81,13 +81,10 @@ public:
|
|||
*
|
||||
* @note the methode doesn't modifies the Tip unlike addFeature()
|
||||
*/
|
||||
void insertFeature(App::DocumentObject* feature, App::DocumentObject* target, bool after=false);
|
||||
void insertObject(App::DocumentObject* feature, App::DocumentObject* target, bool after=false);
|
||||
|
||||
/// Remove the feature from the body
|
||||
void removeFeature(App::DocumentObject* feature);
|
||||
|
||||
/// Delets all the objects linked to the model.
|
||||
void removeModelFromDocument();
|
||||
virtual void removeObject(DocumentObject* obj) override;
|
||||
|
||||
/**
|
||||
* Checks if the given document object lays after the current insert point
|
||||
|
@ -110,6 +107,7 @@ public:
|
|||
* all features derived from PartDesign::Feature and Part::Datum and sketches
|
||||
*/
|
||||
static bool isAllowed(const App::DocumentObject* f);
|
||||
virtual bool allowObject(DocumentObject* f) {return isAllowed(f);};
|
||||
|
||||
/**
|
||||
* Return the body which this feature belongs too, or NULL
|
||||
|
@ -117,13 +115,8 @@ public:
|
|||
*/
|
||||
static Body *findBodyOf(const App::DocumentObject* feature);
|
||||
|
||||
/// Returns the origin link or throws an exception
|
||||
App::Origin *getOrigin () const;
|
||||
|
||||
PyObject *getPyObject(void);
|
||||
|
||||
/// Origin linked to the property, please use getOrigin () to access it
|
||||
App::PropertyLink Origin;
|
||||
|
||||
protected:
|
||||
virtual void onSettingDocument();
|
||||
|
|
|
@ -68,7 +68,7 @@ PyObject* BodyPy::addFeature(PyObject *args)
|
|||
Body* body = this->getBodyPtr();
|
||||
|
||||
try {
|
||||
body->addFeature(feature);
|
||||
body->addObject(feature);
|
||||
} catch (Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_SystemError, e.what());
|
||||
return 0;
|
||||
|
@ -107,7 +107,7 @@ PyObject* BodyPy::insertFeature(PyObject *args)
|
|||
Body* body = this->getBodyPtr();
|
||||
|
||||
try {
|
||||
body->insertFeature(feature, target, after);
|
||||
body->insertObject(feature, target, after);
|
||||
} catch (Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_SystemError, e.what());
|
||||
return 0;
|
||||
|
@ -126,7 +126,7 @@ PyObject* BodyPy::removeFeature(PyObject *args)
|
|||
Body* body = this->getBodyPtr();
|
||||
|
||||
try {
|
||||
body->removeFeature(feature);
|
||||
body->removeObject(feature);
|
||||
} catch (Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_SystemError, e.what());
|
||||
return 0;
|
||||
|
@ -140,7 +140,7 @@ PyObject* BodyPy::removeModelFromDocument(PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
|
||||
getBodyPtr()->removeModelFromDocument();
|
||||
getBodyPtr()->removeObjectsFromDocument();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
supportString = std::string("(App.activeDocument().") + obj->getNameInDocument() + ", '')";
|
||||
}
|
||||
|
||||
if (!pcActiveBody->hasFeature(obj)) {
|
||||
if (!pcActiveBody->hasObject(obj)) {
|
||||
if ( !obj->isDerivedFrom ( App::Plane::getClassTypeId() ) ) {
|
||||
// TODO check here if the plane associated with right part/body (2015-09-01, Fat-Zer)
|
||||
|
||||
|
@ -409,7 +409,7 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
auto copy = PartDesignGui::TaskFeaturePick::makeCopy(obj, sub, dlg.radioIndependent->isChecked());
|
||||
|
||||
if(pcActiveBody)
|
||||
pcActiveBody->addFeature(copy);
|
||||
pcActiveBody->addObject(copy);
|
||||
else if (pcActivePart)
|
||||
pcActivePart->addObject(copy);
|
||||
|
||||
|
@ -466,7 +466,7 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
for (auto plane: datumPlanes) {
|
||||
planes.push_back ( plane );
|
||||
// Check whether this plane belongs to the active body
|
||||
if ( pcActiveBody && pcActiveBody->hasFeature(plane) ) {
|
||||
if ( pcActiveBody && pcActiveBody->hasObject(plane) ) {
|
||||
if ( !pcActiveBody->isAfterInsertPoint ( plane ) ) {
|
||||
validPlanes++;
|
||||
status.push_back(PartDesignGui::TaskFeaturePick::validFeature);
|
||||
|
@ -640,7 +640,7 @@ unsigned validateSketches(std::vector<App::DocumentObject*>& sketches,
|
|||
status.push_back(PartDesignGui::TaskFeaturePick::otherPart);
|
||||
continue;
|
||||
}
|
||||
} else if (!pcActiveBody->hasFeature(*s)) {
|
||||
} else if (!pcActiveBody->hasObject(*s)) {
|
||||
// Check whether this plane belongs to a body of the same part
|
||||
PartDesign::Body* b = PartDesign::Body::findBodyOf(*s);
|
||||
if(!b)
|
||||
|
@ -807,7 +807,7 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which,
|
|||
auto copy = PartDesignGui::TaskFeaturePick::makeCopy(sketches[0], "", dlg.radioIndependent->isChecked());
|
||||
auto oBody = PartDesignGui::getBodyFor(sketches[0], false);
|
||||
if(oBody)
|
||||
pcActiveBody->addFeature(copy);
|
||||
pcActiveBody->addObject(copy);
|
||||
else
|
||||
pcActivePart->addObject(copy);
|
||||
|
||||
|
|
|
@ -742,7 +742,7 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg)
|
|||
if ( body ) {
|
||||
bodyBase= body->BaseFeature.getValue();
|
||||
for ( auto feat: features ) {
|
||||
if ( !body->hasFeature ( feat ) ) {
|
||||
if ( !body->hasObject ( feat ) ) {
|
||||
allFeaturesFromSameBody = false;
|
||||
break;
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg)
|
|||
}
|
||||
|
||||
// Create a list of all features in this body
|
||||
const std::vector<App::DocumentObject*> & model = body->Model.getValues();
|
||||
const std::vector<App::DocumentObject*> & model = body->Group.getValues();
|
||||
|
||||
// Ask user to select the target feature
|
||||
bool ok;
|
||||
|
|
|
@ -115,7 +115,7 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c
|
|||
|
||||
if (!body) { // Allow selecting Part::Datum features from the active Body
|
||||
return false;
|
||||
} else if (!allowOtherBody && !body->hasFeature(pObj)) {
|
||||
} else if (!allowOtherBody && !body->hasObject(pObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ void getReferencedSelection(const App::DocumentObject* thisObj, const Gui::Selec
|
|||
|
||||
auto copy = PartDesignGui::TaskFeaturePick::makeCopy(selObj, subname, dlg.radioIndependent->isChecked());
|
||||
if(selBody)
|
||||
body->addFeature(copy);
|
||||
body->addObject(copy);
|
||||
else
|
||||
pcActivePart->addObject(copy);
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ bool TaskDlgDatumParameters::accept() {
|
|||
//the user has to decide which option we should take if external references are used
|
||||
bool ext = false;
|
||||
for(App::DocumentObject* obj : pcDatum->Support.getValues()) {
|
||||
if(!pcActiveBody->hasFeature(obj) && !pcActiveBody->getOrigin()->hasObject(obj))
|
||||
if(!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj))
|
||||
ext = true;
|
||||
}
|
||||
if(ext) {
|
||||
|
@ -155,7 +155,7 @@ bool TaskDlgDatumParameters::accept() {
|
|||
int index = 0;
|
||||
for(App::DocumentObject* obj : pcDatum->Support.getValues()) {
|
||||
|
||||
if(!pcActiveBody->hasFeature(obj) && !pcActiveBody->getOrigin()->hasObject(obj)) {
|
||||
if(!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj)) {
|
||||
objs.push_back(PartDesignGui::TaskFeaturePick::makeCopy(obj, subs[index], dlg.radioIndependent->isChecked()));
|
||||
copies.push_back(objs.back());
|
||||
subs[index] = "";
|
||||
|
@ -176,7 +176,7 @@ bool TaskDlgDatumParameters::accept() {
|
|||
//we need to add the copied features to the body after the command action, as otherwise freecad crashs unexplainable
|
||||
for(auto obj : copies) {
|
||||
if(pcActiveBody)
|
||||
pcActiveBody->addFeature(obj);
|
||||
pcActiveBody->addObject(obj);
|
||||
else if (pcActivePart)
|
||||
pcActivePart->addObject(obj);
|
||||
}
|
||||
|
|
|
@ -235,17 +235,17 @@ std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures()
|
|||
auto copy = makeCopy(obj, "", ui->radioIndependent->isChecked());
|
||||
|
||||
if (*st == otherBody) {
|
||||
activeBody->addFeature(copy);
|
||||
activeBody->addObject(copy);
|
||||
}
|
||||
else if (*st == otherPart) {
|
||||
auto oBody = PartDesignGui::getBodyFor(obj, false);
|
||||
if (!oBody)
|
||||
activePart->addObject(copy);
|
||||
else
|
||||
activeBody->addFeature(copy);
|
||||
activeBody->addObject(copy);
|
||||
}
|
||||
else if (*st == notInBody) {
|
||||
activeBody->addFeature(copy);
|
||||
activeBody->addObject(copy);
|
||||
// doesn't supposed to get here anything but sketch but to be on the safe side better to check
|
||||
if (copy->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) {
|
||||
Sketcher::SketchObject *sketch = static_cast<Sketcher::SketchObject*>(copy);
|
||||
|
|
|
@ -720,13 +720,13 @@ bool TaskDlgPipeParameters::accept()
|
|||
std::vector<App::DocumentObject*> copies;
|
||||
|
||||
bool ext = false;
|
||||
if(!pcActiveBody->hasFeature(pcPipe->Spine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->Spine.getValue()))
|
||||
if(!pcActiveBody->hasObject(pcPipe->Spine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->Spine.getValue()))
|
||||
ext = true;
|
||||
else if(!pcActiveBody->hasFeature(pcPipe->AuxillerySpine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->AuxillerySpine.getValue()))
|
||||
else if(!pcActiveBody->hasObject(pcPipe->AuxillerySpine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->AuxillerySpine.getValue()))
|
||||
ext = true;
|
||||
else {
|
||||
for(App::DocumentObject* obj : pcPipe->Sections.getValues()) {
|
||||
if(!pcActiveBody->hasFeature(obj) && !pcActiveBody->getOrigin()->hasObject(obj))
|
||||
if(!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj))
|
||||
ext = true;
|
||||
}
|
||||
}
|
||||
|
@ -741,12 +741,12 @@ bool TaskDlgPipeParameters::accept()
|
|||
return false;
|
||||
else if(!dlg.radioXRef->isChecked()) {
|
||||
|
||||
if(!pcActiveBody->hasFeature(pcPipe->Spine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->Spine.getValue())) {
|
||||
if(!pcActiveBody->hasObject(pcPipe->Spine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->Spine.getValue())) {
|
||||
pcPipe->Spine.setValue(PartDesignGui::TaskFeaturePick::makeCopy(pcPipe->Spine.getValue(), "", dlg.radioIndependent->isChecked()),
|
||||
pcPipe->Spine.getSubValues());
|
||||
copies.push_back(pcPipe->Spine.getValue());
|
||||
}
|
||||
else if(!pcActiveBody->hasFeature(pcPipe->AuxillerySpine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->AuxillerySpine.getValue())){
|
||||
else if(!pcActiveBody->hasObject(pcPipe->AuxillerySpine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->AuxillerySpine.getValue())){
|
||||
pcPipe->AuxillerySpine.setValue(PartDesignGui::TaskFeaturePick::makeCopy(pcPipe->AuxillerySpine.getValue(), "", dlg.radioIndependent->isChecked()),
|
||||
pcPipe->AuxillerySpine.getSubValues());
|
||||
copies.push_back(pcPipe->AuxillerySpine.getValue());
|
||||
|
@ -756,7 +756,7 @@ bool TaskDlgPipeParameters::accept()
|
|||
int index = 0;
|
||||
for(App::DocumentObject* obj : pcPipe->Sections.getValues()) {
|
||||
|
||||
if(!pcActiveBody->hasFeature(obj) && !pcActiveBody->getOrigin()->hasObject(obj)) {
|
||||
if(!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj)) {
|
||||
objs.push_back(PartDesignGui::TaskFeaturePick::makeCopy(obj, "", dlg.radioIndependent->isChecked()));
|
||||
copies.push_back(objs.back());
|
||||
}
|
||||
|
@ -781,7 +781,7 @@ bool TaskDlgPipeParameters::accept()
|
|||
for(auto obj : copies) {
|
||||
//Dead code: pcActiveBody was previously used without checking for null, so it won't be null here either.
|
||||
//if(pcActiveBody)
|
||||
pcActiveBody->addFeature(obj);
|
||||
pcActiveBody->addObject(obj);
|
||||
//else if (pcActivePart)
|
||||
// pcActivePart->addObject(obj);
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ const QByteArray TaskSketchBasedParameters::onFaceName(const QString& text)
|
|||
// everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree)
|
||||
return QByteArray();
|
||||
} else if (obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) {
|
||||
if (!activeBody->hasFeature(obj))
|
||||
if (!activeBody->hasObject(obj))
|
||||
return QByteArray();
|
||||
return QByteArray();
|
||||
} else {
|
||||
|
|
|
@ -88,7 +88,7 @@ PartDesign::Body *getBodyFor(const App::DocumentObject* obj, bool messageIfNot)
|
|||
return nullptr;
|
||||
|
||||
PartDesign::Body * rv = getBody( /*messageIfNot =*/ false);
|
||||
if(rv && rv->hasFeature(obj))
|
||||
if(rv && rv->hasObject(obj))
|
||||
return rv;
|
||||
|
||||
rv = PartDesign::Body::findBodyOf(obj);
|
||||
|
|
|
@ -179,7 +179,7 @@ void ViewProvider::onChanged(const App::Property* prop) {
|
|||
if(body) {
|
||||
|
||||
//hide all features in the body other than this object
|
||||
for(App::DocumentObject* obj : body->Model.getValues()) {
|
||||
for(App::DocumentObject* obj : body->Group.getValues()) {
|
||||
|
||||
if(obj->isDerivedFrom(PartDesign::Feature::getClassTypeId()) && obj != getObject()) {
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->activeDocument()->getViewProvider(obj);
|
||||
|
|
|
@ -183,7 +183,7 @@ bool ViewProviderBody::doubleClicked(void)
|
|||
std::vector<App::DocumentObject*> ViewProviderBody::claimChildren(void)const
|
||||
{
|
||||
PartDesign::Body* body= static_cast<PartDesign::Body*> ( getObject () );
|
||||
const std::vector<App::DocumentObject*> &model = body->Model.getValues ();
|
||||
const std::vector<App::DocumentObject*> &model = body->Group.getValues ();
|
||||
std::set<App::DocumentObject*> outSet; //< set of objects not to claim (childrens of childrens)
|
||||
|
||||
// search for objects handled (claimed) by the features
|
||||
|
@ -220,7 +220,7 @@ std::vector<App::DocumentObject*> ViewProviderBody::claimChildren3D(void)const
|
|||
{
|
||||
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
|
||||
|
||||
const std::vector<App::DocumentObject*> & features = body->Model.getValues();
|
||||
const std::vector<App::DocumentObject*> & features = body->Group.getValues();
|
||||
|
||||
std::vector<App::DocumentObject*> rv;
|
||||
|
||||
|
@ -248,7 +248,7 @@ std::vector<App::DocumentObject*> ViewProviderBody::claimChildren3D(void)const
|
|||
// bool active = body->IsActive.getValue();
|
||||
// //Base::Console().Error("Body is %s\n", active ? "active" : "inactive");
|
||||
// ActiveGuiDoc->signalHighlightObject(*this, Gui::Blue, active);
|
||||
// std::vector<App::DocumentObject*> features = body->Model.getValues();
|
||||
// std::vector<App::DocumentObject*> features = body->Group.getValues();
|
||||
// bool highlight = true;
|
||||
// App::DocumentObject* tip = body->Tip.getValue();
|
||||
// for (std::vector<App::DocumentObject*>::const_iterator f = features.begin(); f != features.end(); f++) {
|
||||
|
@ -264,7 +264,7 @@ std::vector<App::DocumentObject*> ViewProviderBody::claimChildren3D(void)const
|
|||
bool ViewProviderBody::onDelete ( const std::vector<std::string> &) {
|
||||
// TODO May be do it conditionally? (2015-09-05, Fat-Zer)
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.getDocument(\"%s\").getObject(\"%s\").removeModelFromDocument()"
|
||||
"App.getDocument(\"%s\").getObject(\"%s\").removeGroupFromDocument()"
|
||||
,getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
return true;
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ void ViewProviderBody::updateData(const App::Property* prop)
|
|||
{
|
||||
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
|
||||
|
||||
if (prop == &body->Model || prop == &body->BaseFeature) {
|
||||
if (prop == &body->Group || prop == &body->BaseFeature) {
|
||||
// update sizes of origins and datums
|
||||
updateOriginDatumSize ();
|
||||
//ensure all model features are in visual body mode
|
||||
|
@ -298,7 +298,7 @@ void ViewProviderBody::slotChangedObjectApp ( const App::DocumentObject& obj, co
|
|||
}
|
||||
|
||||
PartDesign::Body *body = static_cast<PartDesign::Body*> ( getObject() );
|
||||
if ( body && body->hasFeature (&obj ) ) {
|
||||
if ( body && body->hasObject (&obj ) ) {
|
||||
updateOriginDatumSize ();
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ void ViewProviderBody::slotChangedObjectGui (
|
|||
PartDesign::Body *body = static_cast<PartDesign::Body*> ( getObject() );
|
||||
App::DocumentObject *obj = vp.getObject ();
|
||||
|
||||
if ( body && obj && body->hasFeature ( obj ) ) {
|
||||
if ( body && obj && body->hasObject ( obj ) ) {
|
||||
updateOriginDatumSize ();
|
||||
}
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ void ViewProviderBody::unifyVisualProperty(const App::Property* prop) {
|
|||
Gui::Document *gdoc = Gui::Application::Instance->getDocument ( pcObject->getDocument() ) ;
|
||||
|
||||
PartDesign::Body *body = static_cast<PartDesign::Body *> ( getObject() );
|
||||
auto features = body->Model.getValues();
|
||||
auto features = body->Group.getValues();
|
||||
for(auto feature : features) {
|
||||
|
||||
if(!feature->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
|
||||
|
@ -453,7 +453,7 @@ void ViewProviderBody::setVisualBodyMode(bool bodymode) {
|
|||
Gui::Document *gdoc = Gui::Application::Instance->getDocument ( pcObject->getDocument() ) ;
|
||||
|
||||
PartDesign::Body *body = static_cast<PartDesign::Body *> ( getObject() );
|
||||
auto features = body->Model.getValues();
|
||||
auto features = body->Group.getValues();
|
||||
for(auto feature : features) {
|
||||
|
||||
if(!feature->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
|
||||
|
|
|
@ -193,7 +193,7 @@ void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) con
|
|||
}
|
||||
// if all at lest one selected feature doesn't belongs to the same body
|
||||
// disable the menu entry
|
||||
if ( addMoveFeatureInTree && !body->hasFeature ( sel.pObject ) ) {
|
||||
if ( addMoveFeatureInTree && !body->hasObject ( sel.pObject ) ) {
|
||||
addMoveFeatureInTree = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user