From 08e450fc490505eb80a146826c6438fc6a305ca1 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 11 Feb 2021 23:09:53 +0100 Subject: [PATCH] Test --- CMakeLists.txt | 2 ++ src/SHAPERGUI/CMakeLists.txt | 5 +++ src/SHAPERGUI/shapergui.cpp | 60 ++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 src/SHAPERGUI/shapergui.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d8fef60e..d335e2991 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/SHAPERGUI/CMakeLists.txt b/src/SHAPERGUI/CMakeLists.txt index a3f1c93ee..0211a295d 100644 --- a/src/SHAPERGUI/CMakeLists.txt +++ b/src/SHAPERGUI/CMakeLists.txt @@ -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 index 000000000..b0ba67c83 --- /dev/null +++ b/src/SHAPERGUI/shapergui.cpp @@ -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 +#include +#include + +#include + +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(); +} -- 2.39.2