Sketcher: when refusing to link external, print why (in statusbar)
This commit is contained in:
parent
cc89deccbf
commit
e2f70e5e5b
|
@ -1702,13 +1702,26 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
|||
return -1;
|
||||
}
|
||||
|
||||
bool SketchObject::isExternalAllowed(App::Document *pDoc, App::DocumentObject *pObj) const
|
||||
bool SketchObject::isExternalAllowed(App::Document *pDoc, App::DocumentObject *pObj, eReasonList* rsn) const
|
||||
{
|
||||
if (rsn)
|
||||
*rsn = rlAllowed;
|
||||
|
||||
// Externals outside of the Document are NOT allowed
|
||||
if (this->getDocument() != pDoc)
|
||||
if (this->getDocument() != pDoc){
|
||||
if (rsn)
|
||||
*rsn = rlOtherDoc;
|
||||
return false;
|
||||
}
|
||||
|
||||
//circular reference prevention
|
||||
try {
|
||||
return this->testIfLinkDAGCompatible(pObj);
|
||||
if (!(this->testIfLinkDAGCompatible(pObj))){
|
||||
if (rsn)
|
||||
*rsn = rlCircularReference;
|
||||
return false
|
||||
;
|
||||
}
|
||||
} catch (Base::Exception &e) {
|
||||
Base::Console().Warning("Probably, there is a circular reference in the document. Error: %s\n", e.what());
|
||||
return true; //prohibiting this reference won't remove the problem anyway...
|
||||
|
@ -1721,6 +1734,8 @@ bool SketchObject::isExternalAllowed(App::Document *pDoc, App::DocumentObject *p
|
|||
if (body != NULL) {
|
||||
if ( ! body->hasFeature (pObj) && !this->allowOtherBody ) {
|
||||
// Selection outside of body not allowed if flag is not set
|
||||
if (rsn)
|
||||
*rsn = rlOtherPart;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -261,8 +261,16 @@ public:
|
|||
|
||||
/// Flag to allow external geometry from other bodies than the one this sketch belongs to
|
||||
bool allowOtherBody;
|
||||
/// Return true if this object is allowed as external geometry for the sketch
|
||||
bool isExternalAllowed(App::Document *pDoc, App::DocumentObject *pObj) const;
|
||||
|
||||
enum eReasonList{
|
||||
rlAllowed,
|
||||
rlOtherDoc,
|
||||
rlCircularReference,
|
||||
rlOtherPart,
|
||||
};
|
||||
/// Return true if this object is allowed as external geometry for the
|
||||
/// sketch. rsn argument recieves the reason for disallowing.
|
||||
bool isExternalAllowed(App::Document *pDoc, App::DocumentObject *pObj, eReasonList* rsn = 0) const;
|
||||
|
||||
protected:
|
||||
/// get called by the container when a property has changed
|
||||
|
|
|
@ -4475,8 +4475,21 @@ namespace SketcherGui {
|
|||
bool allow(App::Document *pDoc, App::DocumentObject *pObj, const char *sSubName)
|
||||
{
|
||||
Sketcher::SketchObject *sketch = static_cast<Sketcher::SketchObject*>(object);
|
||||
if (!sketch->isExternalAllowed(pDoc, pObj))
|
||||
Sketcher::SketchObject::eReasonList msg;
|
||||
if (!sketch->isExternalAllowed(pDoc, pObj, &msg)){
|
||||
switch(msg){
|
||||
case Sketcher::SketchObject::rlCircularReference:
|
||||
this->notAllowedReason = QT_TR_NOOP("Linking this will cause circular dependency.");
|
||||
break;
|
||||
case Sketcher::SketchObject::rlOtherDoc:
|
||||
this->notAllowedReason = QT_TR_NOOP("This object is in another document.");
|
||||
break;
|
||||
case Sketcher::SketchObject::rlOtherPart:
|
||||
this->notAllowedReason = QT_TR_NOOP("This object belongs to another part, can't link.");
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Note: its better to search the support of the sketch in case the sketch support is a base plane
|
||||
//Part::BodyBase* body = Part::BodyBase::findBodyOf(sketch);
|
||||
|
|
Loading…
Reference in New Issue
Block a user