Gui: fix view object global coordinate space showable checking
This commit is contained in:
@@ -288,6 +288,9 @@ public:
|
||||
std::set<App::DocumentObject *> newSet;
|
||||
bool updated = false;
|
||||
for (auto child : newChildren) {
|
||||
auto childVp = docItem->getViewProvider(child);
|
||||
if (!childVp)
|
||||
continue;
|
||||
if(child && child->getNameInDocument()) {
|
||||
if(!newSet.insert(child).second) {
|
||||
TREE_WARN("duplicate child item " << obj->getFullName()
|
||||
@@ -309,18 +312,21 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!showable)
|
||||
child->Visibility.setValue(false);
|
||||
childVp->setShowable(showable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto child : childSet) {
|
||||
if(newSet.find(child) == newSet.end()) {
|
||||
if (newSet.find(child) == newSet.end()) {
|
||||
// this means old child removed
|
||||
updated = true;
|
||||
docItem->_ParentMap[child].erase(obj);
|
||||
|
||||
auto childVp = docItem->getViewProvider(child);
|
||||
if (childVp && child->getDocument() == obj->getDocument())
|
||||
childVp->setShowable(docItem->isObjectShowable(child));
|
||||
}
|
||||
}
|
||||
// We still need to check the order of the children
|
||||
@@ -330,10 +336,9 @@ public:
|
||||
|
||||
if(updated && checkVisibility) {
|
||||
for(auto child : children) {
|
||||
if(!child || !child->getNameInDocument() || !child->Visibility.getValue())
|
||||
continue;
|
||||
if(child->getDocument()==obj->getDocument() && !docItem->isObjectShowable(child))
|
||||
child->Visibility.setValue(false);
|
||||
auto childVp = docItem->getViewProvider(child);
|
||||
if (childVp && child->getDocument() == obj->getDocument())
|
||||
childVp->setShowable(docItem->isObjectShowable(child));
|
||||
}
|
||||
}
|
||||
return updated;
|
||||
@@ -3240,24 +3245,23 @@ void TreeWidget::_slotDeleteObject(const Gui::ViewProviderDocumentObject& view,
|
||||
// Check for any child of the deleted object that is not in the tree, and put it
|
||||
// under document item.
|
||||
for(auto child : data->children) {
|
||||
if(!child || !child->getNameInDocument() || child->getDocument()!=doc)
|
||||
auto childVp = docItem->getViewProvider(child);
|
||||
if (!childVp || child->getDocument() != doc)
|
||||
continue;
|
||||
docItem->_ParentMap[child].erase(obj);
|
||||
auto cit = docItem->ObjectMap.find(child);
|
||||
if(cit==docItem->ObjectMap.end() || cit->second->items.empty()) {
|
||||
auto vpd = docItem->getViewProvider(child);
|
||||
if(!vpd) continue;
|
||||
if(docItem->createNewItem(*vpd))
|
||||
if (cit==docItem->ObjectMap.end() || cit->second->items.empty()) {
|
||||
if (docItem->createNewItem(*childVp))
|
||||
needUpdate = true;
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
auto childItem = *cit->second->items.begin();
|
||||
if(childItem->requiredAtRoot(false)) {
|
||||
if(docItem->createNewItem(*childItem->object(),docItem,-1,childItem->myData))
|
||||
if (childItem->requiredAtRoot(false)) {
|
||||
if (docItem->createNewItem(*childItem->object(),docItem,-1,childItem->myData))
|
||||
needUpdate = true;
|
||||
}
|
||||
}
|
||||
if(child->Visibility.getValue() && !docItem->isObjectShowable(child))
|
||||
child->Visibility.setValue(false);
|
||||
childVp->setShowable(docItem->isObjectShowable(child));
|
||||
}
|
||||
docItem->ObjectMap.erase(obj);
|
||||
}
|
||||
@@ -4126,7 +4130,7 @@ DocumentObjectItem *DocumentItem::findItem(
|
||||
auto subObj = obj->getSubObject(name.c_str());
|
||||
if(!subObj || subObj==obj) {
|
||||
if(!subObj && !getTree()->searchDoc)
|
||||
TREE_WARN("sub object not found " << item->getName() << '.' << name.c_str());
|
||||
TREE_LOG("sub object not found " << item->getName() << '.' << name.c_str());
|
||||
if(select) {
|
||||
item->selected += 2;
|
||||
if(std::find(item->mySubs.begin(),item->mySubs.end(),subname)==item->mySubs.end())
|
||||
|
||||
@@ -534,6 +534,9 @@ protected:
|
||||
*/
|
||||
virtual QIcon mergeOverlayIcons (const QIcon & orig) const;
|
||||
|
||||
/// Turn on mode switch
|
||||
virtual void setModeSwitch();
|
||||
|
||||
protected:
|
||||
/// The root Separator of the ViewProvider
|
||||
SoSeparator *pcRoot;
|
||||
@@ -549,7 +552,6 @@ protected:
|
||||
std::bitset<32> StatusBits;
|
||||
|
||||
private:
|
||||
void setModeSwitch();
|
||||
int _iActualMode;
|
||||
int _iEditMode;
|
||||
int viewOverrideMode;
|
||||
|
||||
@@ -71,10 +71,9 @@ PROPERTY_SOURCE(Gui::ViewProviderDocumentObject, Gui::ViewProvider)
|
||||
ViewProviderDocumentObject::ViewProviderDocumentObject()
|
||||
: pcObject(nullptr)
|
||||
, pcDocument(nullptr)
|
||||
, _UpdatingView(false)
|
||||
{
|
||||
static const char *dogroup = "Display Options";
|
||||
static const char *sgroup = "Selection";
|
||||
static const char *dogroup = "Display Options";
|
||||
static const char *sgroup = "Selection";
|
||||
|
||||
ADD_PROPERTY_TYPE(DisplayMode, ((long)0), dogroup, App::Prop_None, "Set the display mode");
|
||||
ADD_PROPERTY_TYPE(Visibility, (true), dogroup, App::Prop_None, "Show the object in the 3d view");
|
||||
@@ -236,6 +235,32 @@ void ViewProviderDocumentObject::hide(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderDocumentObject::isShowable() const
|
||||
{
|
||||
return _Showable;
|
||||
}
|
||||
|
||||
void ViewProviderDocumentObject::setShowable(bool enable)
|
||||
{
|
||||
if (_Showable == enable)
|
||||
return;
|
||||
|
||||
_Showable = enable;
|
||||
int which = getModeSwitch()->whichChild.getValue();
|
||||
if (_Showable && which == -1 && Visibility.getValue()) {
|
||||
setModeSwitch();
|
||||
}
|
||||
else if (!_Showable) {
|
||||
if (which >= 0)
|
||||
ViewProvider::hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderDocumentObject::setModeSwitch() {
|
||||
if(isShowable())
|
||||
ViewProvider::setModeSwitch();
|
||||
}
|
||||
|
||||
void ViewProviderDocumentObject::show(void)
|
||||
{
|
||||
if(TreeWidget::isObjectShowable(getObject()))
|
||||
|
||||
@@ -148,6 +148,9 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void setShowable(bool enable);
|
||||
bool isShowable() const;
|
||||
|
||||
protected:
|
||||
/*! Get the active mdi view of the document this view provider is part of.
|
||||
@note The returned mdi view doesn't need to be a 3d view but can be e.g.
|
||||
@@ -194,14 +197,17 @@ protected:
|
||||
|
||||
//@}
|
||||
|
||||
virtual void setModeSwitch() override;
|
||||
|
||||
protected:
|
||||
App::DocumentObject *pcObject;
|
||||
Gui::Document* pcDocument;
|
||||
|
||||
private:
|
||||
bool _Showable = true;
|
||||
|
||||
std::vector<const char*> aDisplayEnumsArray;
|
||||
std::vector<std::string> aDisplayModesArray;
|
||||
bool _UpdatingView;
|
||||
|
||||
friend class Document;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user