X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_WorkshopListener.cpp;h=03aaf4fa1f10e729201c7bcaafa8a27d82a62145;hb=220bd2b37119be1c65abf88a88792445cb9d99f8;hp=2e22c49eda0c6e4b103b2dbe5b41d85c9cd4425f;hpb=bb76c80f7e5115754ce5898c51d80cb8f2dfdfe4;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index 2e22c49ed..03aaf4fa1 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -3,6 +3,7 @@ #include "XGUI_WorkshopListener.h" #include "XGUI_Workshop.h" #include "XGUI_Displayer.h" +#include "XGUI_ErrorMgr.h" #include "XGUI_OperationMgr.h" #include "XGUI_SalomeConnector.h" #include "XGUI_ActionsMgr.h" @@ -10,12 +11,14 @@ #include "XGUI_ModuleConnector.h" #include "XGUI_QtEvents.h" +#ifndef HAVE_SALOME #include #include #include #include #include #include +#endif #include @@ -26,6 +29,7 @@ #include #include #include +#include #include #include @@ -37,6 +41,7 @@ #include #include +#include #include #include #include @@ -44,6 +49,7 @@ #include #include #include +#include #include #include @@ -57,12 +63,18 @@ //#define DEBUG_FEATURE_CREATED //#define DEBUG_FEATURE_REDISPLAY +//#define DEBUG_FEATURE_UPDATED //#define DEBUG_RESULT_COMPSOLID +#ifdef DEBUG_FEATURE_REDISPLAY +const std::string DebugFeatureKind = "Extrusion"; +#endif + XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop) : myWorkshop(theWorkshop), myUpdatePrefs(false) { + XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr(); } //****************************************************** @@ -84,6 +96,7 @@ void XGUI_WorkshopListener::initializeEventListening() aLoop->registerListener(this, Events_LongOp::eventID()); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)); @@ -153,7 +166,9 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr(); if (anOperationMgr->startOperation(anOperation)) { - workshop()->propertyPanel()->updateContentWidget(anOperation->feature()); + ModuleBase_OperationFeature* aFOperation = dynamic_cast(anOperation); + if (aFOperation) + workshop()->propertyPanel()->updateContentWidget(aFOperation->feature()); if (!anOperation->getDescription()->hasXmlRepresentation()) { if (anOperation->commit()) workshop()->updateCommandStatus(); @@ -177,7 +192,25 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& // the viewer's update context is unblocked, the viewer's update works XGUI_Displayer* aDisplayer = workshop()->displayer(); aDisplayer->enableUpdateViewer(true); - aDisplayer->updateViewer(); + } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)) { + std::shared_ptr aUpdMsg = + std::dynamic_pointer_cast(theMessage); + std::set anObjects = aUpdMsg->objects(); + + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (workshop()->operationMgr()->currentOperation()); + bool aFeatureChanged = false; + if(aFOperation ) { + FeaturePtr aFeature = aFOperation->feature(); + if (aFeature.get()) { + std::set::const_iterator aIt; + for (aIt = anObjects.begin(); aIt != anObjects.end() && !aFeatureChanged; ++aIt) { + aFeatureChanged = ModelAPI_Feature::feature(*aIt) == aFeature; + } + } + if (aFeatureChanged) + workshop()->operationMgr()->onValidateOperation(); + } } else { //Show error dialog if error message received. std::shared_ptr anAppError = std::dynamic_pointer_cast(theMessage); @@ -186,31 +219,47 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& } return; } - if (!workshop()->isSalomeMode()) { +#ifndef HAVE_SALOME SessionPtr aMgr = ModelAPI_Session::get(); AppElements_MainWindow* aMainWindow = workshop()->mainWindow(); if (aMgr->isModified() != aMainWindow->isModifiedState()) aMainWindow->setModifiedState(aMgr->isModified()); - } +#endif } //****************************************************** -void XGUI_WorkshopListener::onFeatureUpdatedMsg(const std::shared_ptr& theMsg) +void XGUI_WorkshopListener::onFeatureUpdatedMsg( + const std::shared_ptr& theMsg) { +#ifdef DEBUG_FEATURE_UPDATED + std::set anObjects = theMsg->objects(); + std::set::const_iterator aIt; + QStringList anInfo; + for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) { + anInfo.append(ModuleBase_Tools::objectInfo((*aIt))); + } + QString anInfoStr = anInfo.join(";\t"); + qDebug(QString("onFeatureUpdatedMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str()); +#endif std::set aFeatures = theMsg->objects(); XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr(); if (anOperationMgr->hasOperation()) { - FeaturePtr aCurrentFeature = anOperationMgr->currentOperation()->feature(); - std::set::const_iterator aIt; - for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) { - ObjectPtr aNewFeature = (*aIt); - if (aNewFeature == aCurrentFeature) { - workshop()->propertyPanel()->updateContentWidget(aCurrentFeature); - break; + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (anOperationMgr->currentOperation()); + if (aFOperation) { + FeaturePtr aCurrentFeature = aFOperation->feature(); + std::set::const_iterator aIt; + for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) { + ObjectPtr aNewFeature = (*aIt); + if (aNewFeature == aCurrentFeature) { + workshop()->propertyPanel()->updateContentWidget(aCurrentFeature); + break; + } } } } - anOperationMgr->onValidateOperation(); + //anOperationMgr->onValidateOperation(); + //if (myObjectBrowser) // myObjectBrowser->processEvent(theMsg); } @@ -218,21 +267,25 @@ void XGUI_WorkshopListener::onFeatureUpdatedMsg(const std::shared_ptr& theMsg) { - std::set aObjects = theMsg->objects(); + std::set anObjects = theMsg->objects(); std::set::const_iterator aIt; #ifdef DEBUG_FEATURE_REDISPLAY QStringList anInfo; - for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { + for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) { anInfo.append(ModuleBase_Tools::objectInfo((*aIt))); } QString anInfoStr = anInfo.join(";\t"); - qDebug(QString("onFeatureRedisplayMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str()); + qDebug(QString("onFeatureRedisplayMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str()); #endif XGUI_Workshop* aWorkshop = workshop(); XGUI_Displayer* aDisplayer = aWorkshop->displayer(); - for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { + bool aFirstVisualizedBody = false; + + bool aRedisplayed = false; + //std::list aHiddenObjects; + for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) { ObjectPtr aObj = (*aIt); // Hide the object if it is invalid or concealed one @@ -241,7 +294,13 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr