X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_WorkshopListener.cpp;h=849466192813c7078634f398aa82845264f3d8b0;hb=176403004ff97696f3c0b5f8bdf48692177fb34a;hp=8db3733d20c00aa14a30175b32ea1c8500e71f39;hpb=4bd5b3938f3aba070cd4a79b8e6ffd625dcdbe81;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index 8db3733d2..849466192 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -11,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 @@ -27,11 +25,11 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -42,11 +40,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -63,13 +63,15 @@ //#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))); } //****************************************************** @@ -82,19 +84,18 @@ 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)); 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)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION)); } //****************************************************** @@ -110,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); @@ -138,7 +131,20 @@ 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)) { @@ -152,24 +158,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); @@ -187,40 +175,21 @@ 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 aObjects = 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 = aObjects.begin(); aIt != aObjects.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); - 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 } //****************************************************** @@ -228,14 +197,15 @@ void XGUI_WorkshopListener::onFeatureUpdatedMsg( const std::shared_ptr& theMsg) { #ifdef DEBUG_FEATURE_UPDATED - std::set aObjects = theMsg->objects(); + std::set anObjects = theMsg->objects(); std::set::const_iterator aIt; 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("onFeatureUpdatedMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str()); + qDebug(QString("onFeatureUpdatedMsg: %1, %2") + .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str()); #endif std::set aFeatures = theMsg->objects(); XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr(); @@ -261,24 +231,30 @@ void XGUI_WorkshopListener::onFeatureUpdatedMsg( } //****************************************************** -void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr& theMsg) +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(); + //bool aFirstVisualizedBody = false; + bool aDoFitAll = false; + int aNbOfShownObjects = workshop()->displayer()->objectsCount(); bool aRedisplayed = false; - for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { + //std::list aHiddenObjects; + for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) { ObjectPtr aObj = (*aIt); // Hide the object if it is invalid or concealed one @@ -287,26 +263,47 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr