From: nds Date: Tue, 28 Oct 2014 07:53:26 +0000 (+0300) Subject: refs #176: The extrusion operation is available even if no part is active X-Git-Tag: V_0.5~69^2^2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8c77de0100ee460e3c091df5f0b4b59c40f86418;p=modules%2Fshaper.git refs #176: The extrusion operation is available even if no part is active The document kind is saved in the NewGeom module for each action. --- diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index dae250cc3..6bb769fda 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -342,6 +342,21 @@ QStringList NewGeom_Module::nestedActions(const QString& theId) const return QStringList(); } +//****************************************************** +void NewGeom_Module::setDocumentKind(const QString& theId, const QString& theKind) +{ + myDocumentType[theId] = theKind; +} + +//****************************************************** +QString NewGeom_Module::documentKind(const QString& theId) const +{ + if (myDocumentType.contains(theId)) + return myDocumentType[theId]; + return QString(); + +} + //****************************************************** void NewGeom_Module::selectionChanged() { diff --git a/src/NewGeom/NewGeom_Module.h b/src/NewGeom/NewGeom_Module.h index eab0275af..11a2e1035 100644 --- a/src/NewGeom/NewGeom_Module.h +++ b/src/NewGeom/NewGeom_Module.h @@ -58,6 +58,14 @@ Q_OBJECT //! Returns list of nested actions according to the given command ID virtual QStringList nestedActions(const QString& theId) const; + //! Set the document kind of the action by the given command Id + //! \param theId - the command ID + //! \param theKind - the document kind + virtual void setDocumentKind(const QString& theId, const QString& theKind); + + //! Returns the document kind of the action by the given command ID + virtual QString documentKind(const QString& theId) const; + //! Returns interface to Salome viewer virtual ModuleBase_IViewer* viewer() const { @@ -102,6 +110,7 @@ Q_OBJECT NewGeom_SalomeViewer* myProxyViewer; QMap myNestedActions; + QMap myDocumentType; bool myIsOpened; bool myIsStorePositions; diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index c3a35fe7c..081ab537f 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -129,14 +129,22 @@ void XGUI_ActionsMgr::updateByDocumentKind() { std::string aStdDocKind = ModelAPI_Session::get()->activeDocument()->kind(); QString aDocKind = QString::fromStdString(aStdDocKind); + XGUI_Workshop* aWorkshop = static_cast(parent()); foreach(QAction* eachAction, myActions.values()) { XGUI_Command* aCmd = dynamic_cast(eachAction); + QString aCmdDocKind; if(aCmd) { - QString aCmdDocKind = aCmd->documentKind(); - if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) { - eachAction->setEnabled(false); + aCmdDocKind = aCmd->documentKind(); + } + else { + QString aId = eachAction->data().toString(); + if (!aId.isEmpty()) { + aCmdDocKind = aWorkshop->salomeConnector()->documentKind(aId); } } + if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) { + eachAction->setEnabled(false); + } } } diff --git a/src/XGUI/XGUI_SalomeConnector.h b/src/XGUI/XGUI_SalomeConnector.h index e4a0276db..0c36dada2 100644 --- a/src/XGUI/XGUI_SalomeConnector.h +++ b/src/XGUI/XGUI_SalomeConnector.h @@ -67,6 +67,14 @@ class XGUI_EXPORT XGUI_SalomeConnector //! Returns list of nested actions according to the given command ID virtual QStringList nestedActions(const QString& theId) const = 0; + //! Set the document kind of the action by the given command Id + //! \param theId - the command ID + //! \param theKind - the document kind + virtual void setDocumentKind(const QString& theId, const QString& theKind) = 0; + + //! Returns the document kind of the action by the given command ID + virtual QString documentKind(const QString& theId) const = 0; + //! Returns interface to Salome viewer virtual ModuleBase_IViewer* viewer() const = 0; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 8a60b2e4a..6fd3bd0f3 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -585,6 +585,8 @@ void XGUI_Workshop::addFeature(const boost::shared_ptr& t QKeySequence(), isUsePropPanel); salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts)); + salomeConnector()->setDocumentKind(aFeatureId, QString::fromStdString(theMessage->documentKind())); + myActionsMgr->addCommand(aAction); myModule->featureCreated(aAction); } else {