From: vsv Date: Mon, 9 Dec 2019 07:45:34 +0000 (+0300) Subject: Initial implementation of the feature X-Git-Tag: V9_5_0a1~17^2~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8ca73a3fe1753842a2081735e942780d5415c6b2;p=modules%2Fshaper.git Initial implementation of the feature --- diff --git a/src/ConnectorPlugin/CMakeLists.txt b/src/ConnectorPlugin/CMakeLists.txt index 17a885057..ddf16fa67 100644 --- a/src/ConnectorPlugin/CMakeLists.txt +++ b/src/ConnectorPlugin/CMakeLists.txt @@ -22,6 +22,7 @@ INCLUDE(Common) SET(PYTHON_FILES ConnectorPlugin.py ConnectorPlugin_ExportFeature.py + ConnectorPlugin_PublishToStudyFeature.py ) SET(XML_RESOURCES diff --git a/src/ConnectorPlugin/ConnectorPlugin.py b/src/ConnectorPlugin/ConnectorPlugin.py index f16adee55..3886c20e2 100644 --- a/src/ConnectorPlugin/ConnectorPlugin.py +++ b/src/ConnectorPlugin/ConnectorPlugin.py @@ -23,6 +23,7 @@ import ModelAPI from ConnectorPlugin_ExportFeature import ExportFeature +from ConnectorPlugin_PublishToStudyFeature import PublishToStudyFeature ## @ingroup Plugins # The main class for management the construction features as plugin. @@ -37,6 +38,8 @@ class ConnectorPlugin(ModelAPI.ModelAPI_Plugin): def createFeature(self, theFeatureID): if theFeatureID == ExportFeature.ID(): return ExportFeature().__disown__() + elif theFeatureID == PublishToStudyFeature.ID(): + return PublishToStudyFeature().__disown__() else: print("ConnectorPlugin: No such feature %s" % theFeatureID) diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py new file mode 100644 index 000000000..76481bb56 --- /dev/null +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -0,0 +1,67 @@ +# 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 +# + +## @package Plugins +# ExportFeature class definition + +import ModelAPI +import ExchangeAPI +import EventsAPI + +import salome +from salome.shaper import model + +import os + + +## @ingroup Plugins +# Feature to export all shapes and groups into the GEOM module +class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): + + ## The constructor. + def __init__(self): + ModelAPI.ModelAPI_Feature.__init__(self) + pass + + @staticmethod + ## Export kind. Static. + def ID(): + return "PublishToStudy" + + ## Returns the kind of a feature. + def getKind(self): + return PublishToStudyFeature.ID() + + ## This feature is action: has no property panel and executes immediately. + def isAction(self): + return True + + ## This feature has no attributes, as it is action. + def initAttributes(self): + pass + + ## Exports all shapes and groups into the GEOM module. + def execute(self): + aSession = ModelAPI.ModelAPI_Session.get() + ## Get active document + self.Part = aSession.activeDocument() + salome.salome_init(1) + + print("### Excutation of PublishToStudy") + pass diff --git a/src/ConnectorPlugin/plugin-Connector.xml b/src/ConnectorPlugin/plugin-Connector.xml index d0eb76878..0d30be9b4 100644 --- a/src/ConnectorPlugin/plugin-Connector.xml +++ b/src/ConnectorPlugin/plugin-Connector.xml @@ -7,6 +7,10 @@ tooltip="Export all results and groups into GEOM module" icon="icons/Connector/geom_export.png" helpfile="ConnectorPlugin/ConnectorPlugin.html"/> + \ No newline at end of file diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index bfac1ab62..36654dfb8 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -442,6 +442,8 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy) connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)), getApp(), SLOT(onSaveAsDoc())); + publishToStudy(); + return LightApp_Module::deactivateModule(theStudy); } @@ -1176,3 +1178,8 @@ void SHAPERGUI::resetToolbars() SUIT_ResourceMgr* aResMgr = application()->resourceMgr(); aResMgr->remove(ToolbarsSection); } + +void SHAPERGUI::publishToStudy() +{ + myWorkshop->module()->launchOperation("PublishToStudy", false); +} diff --git a/src/SHAPERGUI/SHAPERGUI.h b/src/SHAPERGUI/SHAPERGUI.h index 1c5267838..8db934c16 100644 --- a/src/SHAPERGUI/SHAPERGUI.h +++ b/src/SHAPERGUI/SHAPERGUI.h @@ -170,6 +170,8 @@ Q_OBJECT void resetToolbars(); + void publishToStudy(); + public slots: /// \brief The method is redefined to connect to the study viewer before the data /// model is filled by opened file. This file open will flush redisplay signals for, diff --git a/src/SHAPERGUI/SHAPERGUI_DataModel.cpp b/src/SHAPERGUI/SHAPERGUI_DataModel.cpp index efb30f936..70cc7ed62 100644 --- a/src/SHAPERGUI/SHAPERGUI_DataModel.cpp +++ b/src/SHAPERGUI/SHAPERGUI_DataModel.cpp @@ -85,6 +85,9 @@ bool SHAPERGUI_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStr bool SHAPERGUI_DataModel::save(QStringList& theFiles) { + // Pyblish to study before saving of the data model + myModule->publishToStudy(); + LightApp_DataModel::save( theFiles ); XGUI_Workshop* aWorkShop = myModule->workshop(); std::list aFileNames; @@ -125,6 +128,7 @@ bool SHAPERGUI_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QS bool SHAPERGUI_DataModel::close() { + myModule->publishToStudy(); myModule->workshop()->closeDocument(); return LightApp_DataModel::close(); } @@ -175,6 +179,8 @@ bool SHAPERGUI_DataModel::dumpPython(const QString& thePath, CAM_Study* theStudy if (!aStudy) return false; + myModule->publishToStudy(); + std::shared_ptr aDoc = ModelAPI_Session::get()->activeDocument(); ModelAPI_Session::get()->startOperation(ExchangePlugin_Dump::ID()); FeaturePtr aFeature = aDoc->addFeature(ExchangePlugin_Dump::ID());