]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Initial implementation of the feature SHAPERtoSMESH
authorvsv <vsv@opencascade.com>
Mon, 9 Dec 2019 07:45:34 +0000 (10:45 +0300)
committervsv <vsv@opencascade.com>
Mon, 9 Dec 2019 07:45:34 +0000 (10:45 +0300)
src/ConnectorPlugin/CMakeLists.txt
src/ConnectorPlugin/ConnectorPlugin.py
src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py [new file with mode: 0644]
src/ConnectorPlugin/plugin-Connector.xml
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI.h
src/SHAPERGUI/SHAPERGUI_DataModel.cpp

index 17a885057e9dfb3f69597e62025ea52b74b426b0..ddf16fa67fa71de1c6e103337e4e0721596db723 100644 (file)
@@ -22,6 +22,7 @@ INCLUDE(Common)
 SET(PYTHON_FILES
     ConnectorPlugin.py
     ConnectorPlugin_ExportFeature.py
+    ConnectorPlugin_PublishToStudyFeature.py
 )
 
 SET(XML_RESOURCES
index f16adee55871b3ad29316e9a96c67ca254acbae3..3886c20e2240480dcaf114acadd4b2e92319e4d7 100644 (file)
@@ -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 (file)
index 0000000..76481bb
--- /dev/null
@@ -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
index d0eb76878874fbf3892dbfc29e1db9a65084dba7..0d30be9b41990a9b73efc0347b04b40122403995 100644 (file)
@@ -7,6 +7,10 @@
         tooltip="Export all results and groups into GEOM module"
         icon="icons/Connector/geom_export.png"
         helpfile="ConnectorPlugin/ConnectorPlugin.html"/>
+      <feature
+        id="PublishToStudy"
+        title="Pyblish to study"
+        internal="1"/>
     </group>
   </workbench>
 </plugin>
\ No newline at end of file
index bfac1ab628b70ac844930099f6fa4bddcbeaf581..36654dfb84ab737901d60b1386e90c68634e9f50 100644 (file)
@@ -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);
+}
index 1c52678385d50ea1ab3a12f52032bbd8579d5f45..8db934c1683e27f19b922bd1929c3c46954c0e9e 100644 (file)
@@ -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,
index efb30f936765a43c170cefea155ee697679e16a2..70cc7ed624d5581a46a263f741d435ed3ac84645 100644 (file)
@@ -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<std::string> 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<ModelAPI_Document> aDoc = ModelAPI_Session::get()->activeDocument();
   ModelAPI_Session::get()->startOperation(ExchangePlugin_Dump::ID());
   FeaturePtr aFeature = aDoc->addFeature(ExchangePlugin_Dump::ID());