X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_WorkshopListener.cpp;h=dff5b6209b7d8ef933479c1796d8521c9d294fa0;hb=3a5afc79fc52a9ab688f830ab0d173e492b0ec7e;hp=fcc927c3edcc1d758fc18309c4a96de9a29d3993;hpb=f0f8fbdcadad2d5d42c443e70afc6251faea1469;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index fcc927c3e..dff5b6209 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,14 +11,12 @@ #include "XGUI_ModuleConnector.h" #include "XGUI_QtEvents.h" -#include -#include -#include +#ifndef HAVE_SALOME #include -#include -#include +#endif #include +#include #include #include @@ -26,11 +25,11 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -41,11 +40,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -59,15 +60,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(); - connect(anOperationMgr, SIGNAL(nestedStateChanged(const std::string&, const bool)), - this, SLOT(onNestedStateChanged(const std::string&, const bool))); } //****************************************************** @@ -80,9 +84,7 @@ void XGUI_WorkshopListener::initializeEventListening() { //Initialize event listening Events_Loop* aLoop = Events_Loop::loop(); - aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors. - aLoop->registerListener(this, Events_Loop::eventByName(Config_FeatureMessage::GUI_EVENT())); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED)); + aLoop->registerListener(this, Events_InfoMessage::errorID()); //!< Listening application errors. aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); @@ -92,6 +94,8 @@ void XGUI_WorkshopListener::initializeEventListening() aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION)); } //****************************************************** @@ -107,16 +111,8 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& return; } - //A message to start feature creation received. - if (theMessage->eventID() == Events_Loop::loop()->eventByName(Config_FeatureMessage::GUI_EVENT())) { - std::shared_ptr aFeatureMsg = - std::dynamic_pointer_cast(theMessage); - if (!aFeatureMsg->isInternal()) { - addFeature(aFeatureMsg); - } - } // Process creation of Part - else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { std::shared_ptr aUpdMsg = std::dynamic_pointer_cast(theMessage); onFeatureCreatedMsg(aUpdMsg); @@ -135,7 +131,19 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& std::shared_ptr aUpdMsg = std::dynamic_pointer_cast(theMessage); onFeatureRedisplayMsg(aUpdMsg); + } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)) { + std::shared_ptr aUpdMsg = + std::dynamic_pointer_cast(theMessage); + onFeatureEmptyPresentationMsg(aUpdMsg); + } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION)) { + ModuleBase_ModelWidget* aWidget = workshop()->propertyPanel()->activeWidget(); + if (aWidget) { + ModuleBase_WidgetSelector* aWidgetSelector = dynamic_cast(aWidget); + if (aWidgetSelector) + myWorkshop->setSelected(aWidgetSelector->getAttributeSelection()); + } } + //Update property panel on corresponding message. If there is no current operation (no //property panel), or received message has different feature to the current - do nothing. else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { @@ -149,24 +157,6 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& QApplication::restoreOverrideCursor(); } } - //An operation passed by message. Start it, process and commit. - else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) { - std::shared_ptr aPartSetMsg = - std::dynamic_pointer_cast(theMessage); - //myPropertyPanel->cleanContent(); - ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer(); - XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr(); - - if (anOperationMgr->startOperation(anOperation)) { - ModuleBase_OperationFeature* aFOperation = dynamic_cast(anOperation); - if (aFOperation) - workshop()->propertyPanel()->updateContentWidget(aFOperation->feature()); - if (!anOperation->getDescription()->hasXmlRepresentation()) { - if (anOperation->commit()) - workshop()->updateCommandStatus(); - } - } - } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SELFILTER_LOADED)) { std::shared_ptr aMsg = std::dynamic_pointer_cast(theMessage); @@ -184,27 +174,36 @@ 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 { //Show error dialog if error message received. - std::shared_ptr anAppError = std::dynamic_pointer_cast(theMessage); - if (anAppError) { - emit errorOccurred(QString::fromLatin1(anAppError->description())); + std::shared_ptr anIngfoMsg = std::dynamic_pointer_cast(theMessage); + if (anIngfoMsg) { + emit errorOccurred(anIngfoMsg); } 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) { +#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()) { @@ -222,7 +221,8 @@ void XGUI_WorkshopListener::onFeatureUpdatedMsg( } } } - anOperationMgr->onValidateOperation(); + //anOperationMgr->onValidateOperation(); + //if (myObjectBrowser) // myObjectBrowser->processEvent(theMsg); } @@ -230,21 +230,25 @@ void XGUI_WorkshopListener::onFeatureUpdatedMsg( //****************************************************** void XGUI_WorkshopListener::onFeatureRedisplayMsg(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 @@ -253,7 +257,13 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr