X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Workshop.cpp;h=646a41bfa8c070f70a6f183e566d8db0c59b2cb1;hb=9d2e6d9c21e4f16817ca5b572847fe323f6ef32a;hp=d726e86b220ba6a26c634fe7ab7998c000228c46;hpb=03421c138afb385f1bb8d11f290ccb1663f3fbb8;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index d726e86b2..646a41bfa 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -165,8 +165,6 @@ void XGUI_Workshop::startApplication() aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); aLoop->registerListener(this, Events_LongOp::eventID()); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOSHOW)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOHIDE)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)); @@ -348,24 +346,6 @@ void XGUI_Workshop::processEvent(const std::shared_ptr& theMessa } else { QApplication::restoreOverrideCursor(); } - } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TOSHOW)) { - std::shared_ptr anUpdateMsg = - std::dynamic_pointer_cast(theMessage); - const std::set& aObjList = anUpdateMsg->objects(); - QObjectPtrList aList; - std::set::const_iterator aIt; - for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt) - aList.append(*aIt); - showObjects(aList, true); - } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TOHIDE)) { - std::shared_ptr anUpdateMsg = - std::dynamic_pointer_cast(theMessage); - const std::set& aObjList = anUpdateMsg->objects(); - QObjectPtrList aList; - std::set::const_iterator aIt; - for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt) - aList.append(*aIt); - showObjects(aList, false); } //An operation passed by message. Start it, process and commit. else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) { @@ -466,7 +446,8 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptrdata() || !aObj->data()->isValid(); + bool aHide = !aObj->data() || !aObj->data()->isValid() || + aObj->isDisabled() || (!aObj->isDisplayed()); if (!aHide) { // check that this is not hidden result ResultPtr aRes = std::dynamic_pointer_cast(aObj); aHide = aRes && aRes->isConcealed(); @@ -487,21 +468,23 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptrredisplay(aObj, false); - if (myOperationMgr->hasOperation()) { - ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - if (!aOperation->isEditOperation() && - aOperation->hasObject(aObj) && myDisplayer->isActive(aObj)) + //if (myOperationMgr->hasOperation()) { + // ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); + // if (!aOperation->isEditOperation() && + // aOperation->hasObject(aObj) && myDisplayer->isActive(aObj)) + if (!myModule->canActivateSelection(aObj)) { + if (myDisplayer->isActive(aObj)) myDisplayer->deactivate(aObj); } } else { // display object if the current operation has it - ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - if (aOperation && aOperation->hasObject(aObj)) { - ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - #ifdef DEBUG_FEATURE_REDISPLAY - QString anObjInfo = ModuleBase_Tools::objectInfo((aObj)); - qDebug(QString(" display object = %1").arg(anObjInfo).toStdString().c_str()); - #endif - if (displayObject(aObj)) { + if (displayObject(aObj)) { + //ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); + //if (aOperation && aOperation->hasObject(aObj)) { + if (!myModule->canActivateSelection(aObj)) { + #ifdef DEBUG_FEATURE_REDISPLAY + QString anObjInfo = ModuleBase_Tools::objectInfo((aObj)); + qDebug(QString(" display object = %1").arg(anObjInfo).toStdString().c_str()); + #endif // Deactivate object of current operation from selection if (myDisplayer->isActive(aObj)) myDisplayer->deactivate(aObj); @@ -533,16 +516,18 @@ void XGUI_Workshop::onFeatureCreatedMsg(const std::shared_ptrdata() || !anObject->data()->isValid()) - continue; - //ResultPartPtr aPart = std::dynamic_pointer_cast(*aIt); - //if (aPart) { - //aHasPart = true; - // If a feature is created from the aplication's python console - // it doesn't stored in the operation mgr and doesn't displayed - //} else { - isDisplayed = displayObject(*aIt); - //} + // we should not display disabled objects + bool aHide = !anObject->data() || !anObject->data()->isValid() || + anObject->isDisabled() || (!anObject->isDisplayed()); + if (!aHide) { + // setDisplayed has to be called in order to synchronize internal state of the object + // with list of displayed objects + if (myModule->canDisplayObject(anObject)) { + anObject->setDisplayed(true); + isDisplayed = displayObject(*aIt); + } else + anObject->setDisplayed(false); + } } //if (myObjectBrowser) // myObjectBrowser->processEvent(theMsg); @@ -847,7 +832,6 @@ void XGUI_Workshop::onOpen() } else if (anAnswer == QMessageBox::Cancel) { return; } - aSession->closeAll(); myCurrentDir = ""; } @@ -863,9 +847,10 @@ void XGUI_Workshop::onOpen() } QApplication::setOverrideCursor(Qt::WaitCursor); myIsLoadingData = true; + aSession->closeAll(); aSession->load(myCurrentDir.toLatin1().constData()); myObjectBrowser->rebuildDataTree(); - displayAllResults(); + //displayAllResults(); updateCommandStatus(); myIsLoadingData = false; QApplication::restoreOverrideCursor(); @@ -1252,8 +1237,12 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) setDisplayMode(aObjects, XGUI_Displayer::Shading); else if (theId == "WIREFRAME_CMD") setDisplayMode(aObjects, XGUI_Displayer::Wireframe); - else if (theId == "HIDEALL_CMD") - myDisplayer->eraseAll(); + else if (theId == "HIDEALL_CMD") { + QObjectPtrList aList = myDisplayer->displayedObjects(); + foreach (ObjectPtr aObj, aList) + aObj->setDisplayed(false); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + } } //************************************************************** @@ -1281,7 +1270,7 @@ void XGUI_Workshop::deleteObjects() aDescription += tr(" %1"); QStringList aObjectNames; foreach (ObjectPtr aObj, anObjects) { - if (!aObj->data().get()) + if (!aObj->data()->isValid()) continue; aObjectNames << QString::fromStdString(aObj->data()->name()); } @@ -1507,21 +1496,29 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) //************************************************************** void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible) { - foreach (ObjectPtr aObj, theList) - { + foreach (ObjectPtr aObj, theList) { if (isVisible) { - displayObject(aObj); + aObj->setDisplayed(true); + //displayObject(aObj); } else { - myDisplayer->erase(aObj, false); + aObj->setDisplayed(false); + //myDisplayer->erase(aObj, false); } } - myDisplayer->updateViewer(); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + //myDisplayer->updateViewer(); } //************************************************************** void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList) { - myDisplayer->showOnly(theList); + QObjectPtrList aList = myDisplayer->displayedObjects(); + foreach (ObjectPtr aObj, aList) + aObj->setDisplayed(false); + foreach (ObjectPtr aObj, theList) + aObj->setDisplayed(true); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + } @@ -1558,8 +1555,10 @@ void XGUI_Workshop::displayDocumentResults(DocumentPtr theDoc) //************************************************************** void XGUI_Workshop::displayGroupResults(DocumentPtr theDoc, std::string theGroup) { - for (int i = 0; i < theDoc->size(theGroup); i++) - displayObject(theDoc->object(theGroup, i)); + for (int i = 0; i < theDoc->size(theGroup); i++) + theDoc->object(theGroup, i)->setDisplayed(true); + //displayObject(theDoc->object(theGroup, i)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } //************************************************************** @@ -1586,7 +1585,6 @@ void XGUI_Workshop::closeDocument() SessionPtr aMgr = ModelAPI_Session::get(); aMgr->closeAll(); - objectBrowser()->clearContent(); } //**************************************************************