]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Test
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 11 Feb 2021 22:09:53 +0000 (23:09 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 11 Feb 2021 22:09:53 +0000 (23:09 +0100)
CMakeLists.txt
src/SHAPERGUI/CMakeLists.txt
src/SHAPERGUI/shapergui.cpp [new file with mode: 0644]

index 2d8fef60ec80470adc09fe7f626e3e74aadf22a2..d335e299187c34cf5ed7031269a76dfb6dfe473d 100644 (file)
@@ -101,6 +101,7 @@ SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packag
 SET(SHAPER_INSTALL_PYTHON_API ${_pydir}/salome/shaper CACHE INTERNAL "" FORCE)
 SET(SHAPER_INSTALL_SWIG ${_pydir} CACHE INTERNAL "" FORCE)
 IF(${HAVE_SALOME})
+    SET(SHAPER_INSTALL_EXE bin/salome CACHE INTERNAL "" FORCE)
     SET(SHAPER_INSTALL_ADDONS bin/salome CACHE INTERNAL "" FORCE)
     SET(SHAPER_INSTALL_BIN lib/salome CACHE INTERNAL "" FORCE)
     SET(SHAPER_INSTALL_PLUGIN_FILES lib/salome CACHE INTERNAL "" FORCE)
@@ -115,6 +116,7 @@ IF(${HAVE_SALOME})
 
     SALOME_INSTALL_SCRIPTS("shaper_test.py" ${SHAPER_INSTALL_PYTHON_FILES})
 ELSE(${HAVE_SALOME})
+    SET(SHAPER_INSTALL_EXE bin CACHE INTERNAL "" FORCE)
     SET(SHAPER_INSTALL_ADDONS addons CACHE INTERNAL "" FORCE)
     SET(SHAPER_INSTALL_BIN bin CACHE INTERNAL "" FORCE)
     SET(SHAPER_INSTALL_HEADERS include CACHE INTERNAL "" FORCE)
index a3f1c93ee8a78b13fc4f960872ea3461570bdd6d..0211a295d41eda667ef6b5f03cee1c995534860c 100644 (file)
@@ -126,12 +126,17 @@ ADD_DEPENDENCIES(SHAPER XGUI)
 # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
 TARGET_LINK_LIBRARIES(SHAPER ${PROJECT_LIBRARIES})
 
+#
+add_executable(shapergui shapergui.cpp)
+target_link_libraries(shapergui ${QT_LIBRARIES})
+
 # configuration
 CONFIGURE_FILE(
   "${CMAKE_CURRENT_SOURCE_DIR}/resources/LightApp.xml.in"
   "${CMAKE_CURRENT_BINARY_DIR}/LightApp.xml"
   )
 
+install(TARGETS shapergui DESTINATION ${SHAPER_INSTALL_EXE})
 INSTALL(TARGETS SHAPER DESTINATION ${SHAPER_INSTALL_BIN})
 INSTALL(FILES ${PROJECT_RESOURCES} DESTINATION ${SHAPER_INSTALL_RESOURCES})
 INSTALL(FILES ${QM_RESOURCES} DESTINATION ${SHAPER_INSTALL_QM_RESOURCES})
diff --git a/src/SHAPERGUI/shapergui.cpp b/src/SHAPERGUI/shapergui.cpp
new file mode 100644 (file)
index 0000000..b0ba67c
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2021  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
+//
+
+#include <QProcessEnvironment>
+#include <QDir>
+#include <QProcess>
+
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+  constexpr char GUI_ROOT_DIR[]="GUI_ROOT_DIR";
+  constexpr char SHAPER_ROOT_DIR[]="SHAPER_ROOT_DIR";
+  constexpr char LIGHTAPPCONFIG[]="LightAppConfig";
+  QProcessEnvironment pe(QProcessEnvironment::systemEnvironment());
+  if(!pe.contains(SHAPER_ROOT_DIR))
+    {
+      std::cerr << SHAPER_ROOT_DIR << " is not defined in your environment !" << std::endl;
+      return 1;
+    }
+  if(!pe.contains(GUI_ROOT_DIR))
+    {
+      std::cerr << GUI_ROOT_DIR << " is not defined in your environment !" << std::endl;
+      return 1;
+    }
+  // fill LightAppConfig env var
+  QString gui_root_dir( QDir::fromNativeSeparators(pe.value(GUI_ROOT_DIR)) );
+  QString shaper_root_dir( QDir::fromNativeSeparators(pe.value(SHAPER_ROOT_DIR)) );
+  QString lightappconfig_val( QString("%1:%2")
+  .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/gui").arg(gui_root_dir) ) )
+  .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/shaper").arg(shaper_root_dir) ) ) );
+  pe.insert(LIGHTAPPCONFIG,lightappconfig_val);
+  //tells shutup to salome.salome_init invoked at shaper engine ignition
+  pe.insert("SALOME_EMB_SERVANT","1");
+  //
+  QProcess proc;
+  proc.setProcessEnvironment(pe);
+  proc.setProgram("suitexe");
+  proc.setArguments({"--modules=SHAPER"});
+  proc.setProcessChannelMode( QProcess::ForwardedErrorChannel );
+  proc.start();
+  proc.waitForFinished();
+  return proc.exitCode();
+}