X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_WorkshopListener.cpp;h=e420a5aec4814eb9666bf2eb4eb07e7780967bf5;hb=0596060c57c244e60b9f38b7b9f97da8af50bd5f;hp=e9e3e3601519ae9668cede5c3d8a43b225bd0668;hpb=1a59918751225b88769a5ed299dbfa76abb7697b;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp old mode 100755 new mode 100644 index e9e3e3601..e420a5aec --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -1,21 +1,35 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #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" -#include "XGUI_PropertyPanel.h" -#include "XGUI_ModuleConnector.h" -#include "XGUI_QtEvents.h" #ifndef HAVE_SALOME #include #endif -#include +#include +#include +#include + +#include +#include +#include #include #include @@ -23,33 +37,36 @@ #include #include #include -#include -#include -#include #include +#include -#include -#include -#include - +#include +#include +#include #include - #include #include #include #include -#include -#include +#include -#include -#include -#include -#include +#include "XGUI_ActionsMgr.h" +#include "XGUI_Displayer.h" +#include "XGUI_ErrorMgr.h" +#include "XGUI_FacesPanel.h" +#include "XGUI_OperationMgr.h" +#include "XGUI_ModuleConnector.h" +#include "XGUI_PropertyPanel.h" +#include "XGUI_QtEvents.h" +#include "XGUI_SalomeConnector.h" +#include "XGUI_SelectionMgr.h" +#include "XGUI_Workshop.h" + +#include #include #include #include -#include #ifdef _DEBUG #include @@ -65,7 +82,7 @@ const std::string DebugFeatureKind = "";//"Extrusion"; #endif -XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop) +XGUI_WorkshopListener::XGUI_WorkshopListener(XGUI_Workshop* theWorkshop) : myWorkshop(theWorkshop), myUpdatePrefs(false) { @@ -82,24 +99,29 @@ 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(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_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)); + + aLoop->registerListener(this, Events_Loop::eventByName("FinishOperation")); + aLoop->registerListener(this, Events_Loop::eventByName("AbortOperation")); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE)); } //****************************************************** void XGUI_WorkshopListener::processEvent(const std::shared_ptr& theMessage) { - if (QApplication::instance()->thread() != QThread::currentThread()) { + if (QApplication::instance() && + QApplication::instance()->thread() != QThread::currentThread()) { #ifdef _DEBUG std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl; #endif @@ -133,7 +155,18 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& 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) + workshop()->selector()->setSelected(aWidgetSelector->getAttributeSelection()); + } + } else if (theMessage->eventID() == Events_Loop::eventByName("FinishOperation")/* || + theMessage->eventID() == Events_Loop::eventByName("AbortOperation")*/) + workshop()->facesPanel()->reset(false); // do not flush redisplay, it is flushed after event + //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)) { @@ -146,37 +179,6 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& } else { 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()); - workshop()->propertyPanel()->createContentPanel(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); - if (aMsg) { - ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters(); - if (!aMsg->attributeId().empty()) { - aFactory->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId(), - aMsg->parameters()); - } - } } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)) { // the viewer's update context will not happens until viewer updated is emitted workshop()->displayer()->enableUpdateViewer(false); @@ -184,11 +186,17 @@ 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); + } else if ((theMessage->eventID() == + Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE)) || + (theMessage->eventID() == + Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE))) { + myWorkshop->updateAutoComputeState(); } 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; } @@ -212,7 +220,8 @@ void XGUI_WorkshopListener::onFeatureUpdatedMsg( anInfo.append(ModuleBase_Tools::objectInfo((*aIt))); } QString anInfoStr = anInfo.join(";\t"); - qDebug(QString("onFeatureUpdatedMsg: %1, %2").arg(anObjects.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(); @@ -238,7 +247,8 @@ void XGUI_WorkshopListener::onFeatureUpdatedMsg( } //****************************************************** -void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr& theMsg) +void XGUI_WorkshopListener:: + onFeatureRedisplayMsg(const std::shared_ptr& theMsg) { std::set anObjects = theMsg->objects(); std::set::const_iterator aIt; @@ -249,21 +259,21 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptrdisplayer(); - 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 - bool aHide = !aObj->data() || !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(); @@ -279,7 +289,8 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr(aRes); if (aCompSolidRes.get()) { - qDebug(QString("COMPSOLID, numberOfSubs = %1").arg(aCompSolidRes->numberOfSubs()).toStdString().c_str()); + qDebug(QString("COMPSOLID, numberOfSubs = %1") + .arg(aCompSolidRes->numberOfSubs()).toStdString().c_str()); } if (ModelAPI_Tools::compSolidOwner(aRes)) qDebug("COMPSOLID sub-object"); @@ -297,16 +308,16 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr