From: vsv Date: Thu, 18 Oct 2018 16:37:37 +0000 (+0300) Subject: Auto-rebuild management X-Git-Tag: V9_2_0a2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=39bb14c5ae7df11b8c788ab0037ba5b893267204;p=modules%2Fshaper.git Auto-rebuild management --- diff --git a/src/ModuleBase/ModuleBase_Dialog.cpp b/src/ModuleBase/ModuleBase_Dialog.cpp index d07bebf0f..6c0cacd4f 100644 --- a/src/ModuleBase/ModuleBase_Dialog.cpp +++ b/src/ModuleBase/ModuleBase_Dialog.cpp @@ -75,7 +75,7 @@ ModuleBase_Dialog::ModuleBase_Dialog(ModuleBase_IWorkshop* theParent, const QStr aFrame->setFrameStyle(QFrame::WinPanel | QFrame::Raised); aLayout->addWidget(aFrame); - QVBoxLayout* aBtnLayout = new QVBoxLayout(aFrame); + QHBoxLayout* aBtnLayout = new QHBoxLayout(aFrame); ModuleBase_Tools::adjustMargins(aBtnLayout); myButtonsBox = new QDialogButtonBox( diff --git a/src/ModuleBase/ModuleBase_ModelDialogWidget.h b/src/ModuleBase/ModuleBase_ModelDialogWidget.h index d167da4a6..7ce788e86 100644 --- a/src/ModuleBase/ModuleBase_ModelDialogWidget.h +++ b/src/ModuleBase/ModuleBase_ModelDialogWidget.h @@ -42,7 +42,7 @@ public: /// Set general buttons from dialog /// \param theButtons the dialog buttons - void setDialogButtons(QDialogButtonBox* theButtons) { myOkCancelBtn = theButtons; } + virtual void setDialogButtons(QDialogButtonBox* theButtons) { myOkCancelBtn = theButtons; } protected: diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 67d2b349a..a60e3c2bb 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -182,28 +182,32 @@ QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon) { QImage anIcon = ModuleBase_IconFactory::loadImage(theIcon); QImage anAditional(theAdditionalIcon); + return composite(anAditional, anIcon); +} - if (anIcon.isNull()) +QPixmap composite(const QImage& theAdditionalIcon, QImage& theIcon) +{ + if (theIcon.isNull()) return QPixmap(); - int anAddWidth = anAditional.width(); - int anAddHeight = anAditional.height(); + int anAddWidth = theAdditionalIcon.width(); + int anAddHeight = theAdditionalIcon.height(); - int aWidth = anIcon.width(); - int aHeight = anIcon.height(); + int aWidth = theIcon.width(); + int aHeight = theIcon.height(); - int aStartWidthPos = aWidth - anAddWidth - 1; - int aStartHeightPos = aHeight - anAddHeight - 1; + int aStartWidthPos = aWidth - anAddWidth; + int aStartHeightPos = aHeight - anAddHeight; for (int i = 0; i < anAddWidth && i + aStartWidthPos < aWidth; i++) { for (int j = 0; j < anAddHeight && j + aStartHeightPos < aHeight; j++) { - if (qAlpha(anAditional.pixel(i, j)) > 0) - anIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, anAditional.pixel(i, j)); + if (qAlpha(theAdditionalIcon.pixel(i, j)) > 0) + theIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, theAdditionalIcon.pixel(i, j)); } } - return QPixmap::fromImage(anIcon); + return QPixmap::fromImage(theIcon); } QPixmap lighter(const QString& theIcon, const int theLighterValue) diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 6dd1e0985..b29434431 100755 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -96,6 +96,15 @@ MODULEBASE_EXPORT void setShadowEffect(QWidget* theWidget, const bool isSetEffec /// \return resulting pixmap MODULEBASE_EXPORT QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon); +/// Create composite pixmap. +/// Pixmap \a theAdditionalIcon is drawn over pixmap \a dest with coordinates +/// specified relatively to the upper left corner of \a theIcon. + +/// \param theAdditionalIcon additional pixmap +/// \param theIcon background pixmap +/// \return resulting pixmap +MODULEBASE_EXPORT QPixmap composite(const QImage& theAdditionalIcon, QImage& theIcon); + /// Generates the pixmap lighter than the resources pixmap. /// Pixmap \a theIcon is lighted according to the given value. /// If the lighter value is greater than 100, this functions returns a lighter pixmap. diff --git a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp index 96e10edb1..d31439d40 100644 --- a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp +++ b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp @@ -176,7 +176,8 @@ void ParametersPlugin_TreeWidget::closeEditor(QWidget* theEditor, ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData) - : ModuleBase_ModelDialogWidget(theParent, theData) + : ModuleBase_ModelDialogWidget(theParent, theData), + isUpplyBlocked(false) { QVBoxLayout* aLayout = new QVBoxLayout(this); @@ -248,6 +249,20 @@ ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theP onSelectionChanged(); } +void ParametersPlugin_WidgetParamsMgr::setDialogButtons(QDialogButtonBox* theButtons) +{ + ModuleBase_ModelDialogWidget::setDialogButtons(theButtons); + + QWidget* aBtnParentWgt = myOkCancelBtn->parentWidget(); + QHBoxLayout* aBtnParentLayout = dynamic_cast(aBtnParentWgt->layout()); + + QPushButton* aPreviewBtn = new QPushButton(tr("See preview"), aBtnParentWgt); + aBtnParentLayout->insertWidget(0, aPreviewBtn); + aBtnParentLayout->insertStretch(1, 1); + connect(aPreviewBtn, SIGNAL(clicked(bool)), SLOT(onShowPreview())); +} + + QList ParametersPlugin_WidgetParamsMgr::getControls() const { QList aList; @@ -783,3 +798,26 @@ bool ParametersPlugin_WidgetParamsMgr::isValid() return true; } +void ParametersPlugin_WidgetParamsMgr::showEvent(QShowEvent* theEvent) +{ + ModuleBase_ModelDialogWidget::showEvent(theEvent); + SessionPtr aMgr = ModelAPI_Session::get(); + isUpplyBlocked = aMgr->isAutoUpdateBlocked(); + aMgr->blockAutoUpdate(true); + Events_Loop* aLoop = Events_Loop::loop(); + aLoop->flush(aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE)); +} + +void ParametersPlugin_WidgetParamsMgr::hideEvent(QHideEvent* theEvent) +{ + ModuleBase_ModelDialogWidget::hideEvent(theEvent); + SessionPtr aMgr = ModelAPI_Session::get(); + aMgr->blockAutoUpdate(isUpplyBlocked); +} + +void ParametersPlugin_WidgetParamsMgr::onShowPreview() +{ + SessionPtr aMgr = ModelAPI_Session::get(); + aMgr->blockAutoUpdate(false); + aMgr->blockAutoUpdate(true); +} \ No newline at end of file diff --git a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h index 0e55044b3..98d0aefff 100644 --- a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h +++ b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h @@ -71,6 +71,10 @@ public: /// \return a control list virtual QList getControls() const; + /// Set general buttons from dialog + /// \param theButtons the dialog buttons + virtual void setDialogButtons(QDialogButtonBox* theButtons); + protected: /// Saves the internal parameters to the given feature /// \return True in success @@ -82,6 +86,10 @@ protected: /// The method called when widget is activated virtual void activateCustom(); + virtual void showEvent(QShowEvent* theEvent); + + virtual void hideEvent(QHideEvent* theEvent); + private slots: /// Slot for reaction on double click in the table (start editing) /// \param theIndex the clicked index @@ -113,6 +121,9 @@ private slots: /// Slot for reaction on selection in the table void onSelectionChanged(); + // A slot for show preview button + void onShowPreview(); + private: /// Creates a new parameter feature FeaturePtr createParameter() const; @@ -162,6 +173,8 @@ private: QPushButton* myRemoveBtn; QToolButton* myUpBtn; QToolButton* myDownBtn; + + bool isUpplyBlocked; }; diff --git a/src/PartSet/PartSet_IconFactory.cpp b/src/PartSet/PartSet_IconFactory.cpp index 42b3d4d62..da1c13a4a 100644 --- a/src/PartSet/PartSet_IconFactory.cpp +++ b/src/PartSet/PartSet_IconFactory.cpp @@ -64,11 +64,12 @@ QIcon PartSet_IconFactory::getIcon(ObjectPtr theObj) } break; case ModelAPI_StateMustBeUpdated: { - anIcon = ModuleBase_Tools::lighter(anIconString); + anIcon = ModuleBase_Tools::composite(":icons/toWork.png", anIconString); + //anIcon = ModuleBase_Tools::lighter(anIconString); } break; case ModelAPI_StateExecFailed: { - anIcon = ModuleBase_Tools::composite(":icons/exec_state_failed.png", anIconString); + anIcon = ModuleBase_Tools::composite(":icons/isFailed.png", anIconString); } break; case ModelAPI_StateInvalidArgument: { @@ -80,8 +81,8 @@ QIcon PartSet_IconFactory::getIcon(ObjectPtr theObj) } } - if (theObj->data() && theObj->data()->execState() == ModelAPI_StateMustBeUpdated) - return QIcon(":pictures/constr_object_modified.png"); + //if (theObj->data() && theObj->data()->execState() == ModelAPI_StateMustBeUpdated) + // return QIcon(":pictures/constr_object_modified.png"); std::string aGroup = theObj->groupName(); if (aGroup == ModelAPI_ResultPart::group()) diff --git a/src/PartSet/PartSet_TreeNodes.cpp b/src/PartSet/PartSet_TreeNodes.cpp index 92d25db69..08e9e3681 100644 --- a/src/PartSet/PartSet_TreeNodes.cpp +++ b/src/PartSet/PartSet_TreeNodes.cpp @@ -22,6 +22,7 @@ #include #include +#include #include @@ -1184,6 +1185,32 @@ void PartSet_ObjectFolderNode::getFirstAndLastIndex(int& theFirst, int& theLast) } +QVariant PartSet_ObjectFolderNode::data(int theColumn, int theRole) const +{ + const QImage anAditional(":icons/hasWarning.png"); + + if ((theRole == Qt::DecorationRole) && (theColumn == 1)) { + ObjectPtr aObject; + bool aHasWarning = false; + foreach(ModuleBase_ITreeNode* aNode, myChildren) { + aObject = aNode->object(); + if (aObject.get()) { + ModelAPI_ExecState aState = aObject->data()->execState(); + if ((aState == ModelAPI_StateExecFailed) || (aState == ModelAPI_StateMustBeUpdated)) { + aHasWarning = true; + break; + } + } + } + if (aHasWarning) { + return QIcon(ModuleBase_Tools::composite(":icons/hasWarning.png", + ":pictures/features_folder.png")); + } + } + return PartSet_ObjectNode::data(theColumn, theRole); +} + + ////////////////////////////////////////////////////////////////////////////////// QVariant PartSet_StepNode::data(int theColumn, int theRole) const { diff --git a/src/PartSet/PartSet_TreeNodes.h b/src/PartSet/PartSet_TreeNodes.h index 37e6d54db..4e37df89c 100644 --- a/src/PartSet/PartSet_TreeNodes.h +++ b/src/PartSet/PartSet_TreeNodes.h @@ -327,6 +327,9 @@ public: /// \param theGroup a name of group where objects were deleted virtual QTreeNodesList objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup); + /// Returns the node representation according to theRole. + virtual QVariant data(int theColumn, int theRole) const; + private: FeaturePtr getFeature(const std::string& theId) const; diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index 9b19b30a5..99819d90e 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -19,5 +19,8 @@ icons/group_face.png icons/group_solid.png icons/group_vertex.png + icons/toWork.png + icons/isFailed.png + icons/hasWarning.png diff --git a/src/PartSet/icons/hasWarning.png b/src/PartSet/icons/hasWarning.png new file mode 100644 index 000000000..535aef227 Binary files /dev/null and b/src/PartSet/icons/hasWarning.png differ diff --git a/src/PartSet/icons/isFailed.png b/src/PartSet/icons/isFailed.png new file mode 100644 index 000000000..2754e561f Binary files /dev/null and b/src/PartSet/icons/isFailed.png differ diff --git a/src/PartSet/icons/toWork.png b/src/PartSet/icons/toWork.png new file mode 100644 index 000000000..7d3dc1133 Binary files /dev/null and b/src/PartSet/icons/toWork.png differ diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 5418b3e25..4c93fca08 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -187,7 +187,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) myOperationMgr = new XGUI_OperationMgr(this, 0); ModuleBase_IWorkshop* aWorkshop = moduleConnector(); // Has to be defined first in order to get errors and messages from other components - myEventsListener = new XGUI_WorkshopListener(aWorkshop); + myEventsListener = new XGUI_WorkshopListener(this); mySelectionActivate = new XGUI_SelectionActivate(aWorkshop); SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr(); @@ -491,12 +491,11 @@ void XGUI_Workshop::initMenu() aCommand->connectTo(this, SLOT(onOpen())); - aCommand = aGroup->addFeature("AUTOCOMPUTE_CMD", tr("Block auto-apply"), + aCommand = aGroup->addFeature("AUTOCOMPUTE_CMD", tr("Auto rebuild"), tr("Blocks immediate apply of modifications"), - QIcon(":pictures/autoapply.png"), QString(), - QKeySequence(), true, true); - aCommand->setChecked(ModelAPI_Session::get()->isAutoUpdateBlocked()); - aCommand->connectTo(this, SLOT(onAutoApply(bool))); + QIcon(":pictures/autoapply_start.png"), QKeySequence()); + //aCommand->setChecked(ModelAPI_Session::get()->isAutoUpdateBlocked()); + aCommand->connectTo(this, SLOT(onAutoApply())); aCommand = aGroup->addFeature("PREF_CMD", tr("Preferences"), tr("Edit preferences"), QIcon(":pictures/preferences.png"), QKeySequence::Preferences); @@ -1327,7 +1326,10 @@ void XGUI_Workshop::updateCommandStatus() aCmd->setEnabled(myModule->canRedo()); } else if (aId == "AUTOCOMPUTE_CMD") { - aCmd->setChecked(aMgr->isAutoUpdateBlocked()); + //aCmd->setChecked(aMgr->isAutoUpdateBlocked()); + aCmd->setIcon(aMgr->isAutoUpdateBlocked() ? + QIcon(":pictures/autoapply_stop.png") : + QIcon(":pictures/autoapply_start.png")); } else // Enable all commands @@ -2824,8 +2826,32 @@ void XGUI_Workshop::moveOutFolder(bool isBefore) updateCommandStatus(); } -void XGUI_Workshop::onAutoApply(bool isToggle) +void XGUI_Workshop::onAutoApply() { SessionPtr aMgr = ModelAPI_Session::get(); - aMgr->blockAutoUpdate(isToggle); -} \ No newline at end of file + bool isBlocked = aMgr->isAutoUpdateBlocked(); + aMgr->blockAutoUpdate(!isBlocked); +} + +void XGUI_Workshop::updateAutoComputeState() +{ + SessionPtr aMgr = ModelAPI_Session::get(); + bool isComputeBlocked = aMgr->isAutoUpdateBlocked(); +#ifdef HAVE_SALOME + QAction* aUpdateCmd; + QList aCommands = workshop()->salomeConnector()->commandList(); + foreach(QAction* aCmd, aCommands) { + if (aCmd->data().toString() == "AUTOCOMPUTE_CMD") { + aUpdateCmd = aCmd; + break; + } + } + aUpdateCmd->setIcon(isComputeBlocked? QIcon(":pictures/autoapply_stop.png") : + QIcon(":pictures/autoapply_start.png")); +#else + AppElements_MainMenu* aMenuBar = myMainWindow->menuObject(); + AppElements_Command* aUpdateCmd = aMenuBar->feature("AUTOCOMPUTE_CMD"); + aUpdateCmd->button()->setIcon(isComputeBlocked? QIcon(":pictures/autoapply_stop.png") : + QIcon(":pictures/autoapply_start.png")); +#endif +} diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index b25938005..f9504dfee 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -320,6 +320,8 @@ Q_OBJECT /// \param theDirectory a path to directory void openDirectory(const QString& theDirectory); + void updateAutoComputeState(); + signals: /// Emitted when selection happens in Salome viewer void salomeViewerSelection(); @@ -396,7 +398,7 @@ signals: #endif /// A slot calleon toggle of auto-compute button - void onAutoApply(bool isToggle); + void onAutoApply(); /// Activates/deactivates the trihedron in the viewer AIS context void onTrihedronVisibilityChanged(bool theState); diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index f7720512d..7701c221b 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -82,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) { @@ -113,6 +113,8 @@ void XGUI_WorkshopListener::initializeEventListening() 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)); } //****************************************************** @@ -184,6 +186,11 @@ 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 = @@ -524,6 +531,5 @@ bool XGUI_WorkshopListener::customizeCurrentObject(const std::set& th XGUI_Workshop* XGUI_WorkshopListener::workshop() const { - XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); - return aConnector->workshop(); + return myWorkshop; } diff --git a/src/XGUI/XGUI_WorkshopListener.h b/src/XGUI/XGUI_WorkshopListener.h index c338535bd..cece7d965 100755 --- a/src/XGUI/XGUI_WorkshopListener.h +++ b/src/XGUI/XGUI_WorkshopListener.h @@ -50,7 +50,7 @@ class XGUI_EXPORT XGUI_WorkshopListener : public QObject, public Events_Listener public: /// Constructor. Used only if the workshop is launched in Salome environment /// \param theWorkshop a reference to workshop. - XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop); + XGUI_WorkshopListener(XGUI_Workshop* theWorkshop); virtual ~XGUI_WorkshopListener(); /// Register this class in the events loop for several types of events @@ -104,7 +104,7 @@ protected: XGUI_Workshop* workshop() const; private: - ModuleBase_IWorkshop* myWorkshop; // the current workshop + XGUI_Workshop* myWorkshop; // the current workshop bool myUpdatePrefs; }; diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 5de669be4..ea9614f94 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -74,7 +74,8 @@ pictures/move_out_after.png pictures/move_out_before.png pictures/selection.png - pictures/autoapply.png + pictures/autoapply_start.png + pictures/autoapply_stop.png pictures/whatis.png diff --git a/src/XGUI/pictures/autoapply.png b/src/XGUI/pictures/autoapply.png deleted file mode 100644 index 6298c41d5..000000000 Binary files a/src/XGUI/pictures/autoapply.png and /dev/null differ diff --git a/src/XGUI/pictures/autoapply_start.png b/src/XGUI/pictures/autoapply_start.png new file mode 100644 index 000000000..86453bb7b Binary files /dev/null and b/src/XGUI/pictures/autoapply_start.png differ diff --git a/src/XGUI/pictures/autoapply_stop.png b/src/XGUI/pictures/autoapply_stop.png new file mode 100644 index 000000000..5bde65bc8 Binary files /dev/null and b/src/XGUI/pictures/autoapply_stop.png differ