SET(PYTHON_FILES
ConnectorPlugin.py
ConnectorPlugin_ExportFeature.py
+ ConnectorPlugin_PublishToStudyFeature.py
)
SET(XML_RESOURCES
import ModelAPI
from ConnectorPlugin_ExportFeature import ExportFeature
+from ConnectorPlugin_PublishToStudyFeature import PublishToStudyFeature
## @ingroup Plugins
# The main class for management the construction features as 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)
--- /dev/null
+# 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
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
connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
getApp(), SLOT(onSaveAsDoc()));
+ publishToStudy();
+
return LightApp_Module::deactivateModule(theStudy);
}
SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
aResMgr->remove(ToolbarsSection);
}
+
+void SHAPERGUI::publishToStudy()
+{
+ myWorkshop->module()->launchOperation("PublishToStudy", false);
+}
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,
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;
bool SHAPERGUI_DataModel::close()
{
+ myModule->publishToStudy();
myModule->workshop()->closeDocument();
return LightApp_DataModel::close();
}
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());