X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_WorkshopListener.cpp;h=6ec62aba90d20ed11338b7a168406cf857fea6d3;hb=eb860f799eab680975365d8ce18cec6e04a6f391;hp=dff5b6209b7d8ef933479c1796d8521c9d294fa0;hpb=1a9c873645580822c23f4abcd374b6c639d5b9cf;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 dff5b6209..6ec62aba9 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -1,22 +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 #include @@ -24,34 +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 @@ -67,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) { @@ -88,20 +103,26 @@ void XGUI_WorkshopListener::initializeEventListening() 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_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES)); 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 @@ -129,8 +150,32 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& // Redisplay feature else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) { std::shared_ptr aUpdMsg = - std::dynamic_pointer_cast(theMessage); + std::dynamic_pointer_cast(theMessage); onFeatureRedisplayMsg(aUpdMsg); + } + else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_VISUAL_ATTRIBUTES)) { + std::shared_ptr aUpdMsg = + std::dynamic_pointer_cast(theMessage); + std::set aObjList = aUpdMsg->objects(); + std::set::const_iterator aIt; + std::list::const_iterator aResIt; + XGUI_Displayer* aDisplayer = workshop()->displayer(); + AISObjectPtr aAIS; + for (aIt = aObjList.begin(); aIt != aObjList.end(); ++aIt) { + FeaturePtr aFeature = std::dynamic_pointer_cast(*aIt); + if (aFeature) { + aAIS = aDisplayer->getAISObject(aFeature); + if (aAIS.get()) + workshop()->module()->customizePresentation(aFeature, aAIS); + + std::list aResults = aFeature->results(); + for (aResIt = aResults.begin(); aResIt != aResults.end(); ++aResIt) { + aAIS = aDisplayer->getAISObject(*aResIt); + if (aAIS.get()) + workshop()->module()->customizePresentation(*aResIt, aAIS); + } + } + } } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)) { std::shared_ptr aUpdMsg = std::dynamic_pointer_cast(theMessage); @@ -138,11 +183,14 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& } 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); + ModuleBase_WidgetSelector* aWidgetSelector = + dynamic_cast(aWidget); if (aWidgetSelector) - myWorkshop->setSelected(aWidgetSelector->getAttributeSelection()); + 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. @@ -156,17 +204,6 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& } else { QApplication::restoreOverrideCursor(); } - } - 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); @@ -174,9 +211,15 @@ 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 anIngfoMsg = std::dynamic_pointer_cast(theMessage); + std::shared_ptr anIngfoMsg = + std::dynamic_pointer_cast(theMessage); if (anIngfoMsg) { emit errorOccurred(anIngfoMsg); } @@ -202,7 +245,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(); @@ -228,7 +272,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; @@ -239,21 +284,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(); @@ -269,7 +314,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"); @@ -287,16 +333,16 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr