Salome HOME
updated copyright message
[modules/shaper.git] / src / SHAPERGUI / shapergui_app.cpp
1 // Copyright (C) 2021-2023  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <QProcessEnvironment>
21 #include <QDir>
22 #include <QProcess>
23
24 #include <iostream>
25
26 int main(int argc, char *argv[])
27 {
28   constexpr char GUI_ROOT_DIR[]="GUI_ROOT_DIR";
29   constexpr char SHAPER_ROOT_DIR[]="SHAPER_ROOT_DIR";
30   constexpr char LIGHTAPPCONFIG[]="LightAppConfig";
31   QProcessEnvironment pe(QProcessEnvironment::systemEnvironment());
32   if(!pe.contains(SHAPER_ROOT_DIR))
33     {
34       std::cerr << SHAPER_ROOT_DIR << " is not defined in your environment !" << std::endl;
35       return 1;
36     }
37   if(!pe.contains(GUI_ROOT_DIR))
38     {
39       std::cerr << GUI_ROOT_DIR << " is not defined in your environment !" << std::endl;
40       return 1;
41     }
42   // fill LightAppConfig env var
43   QString gui_root_dir( QDir::fromNativeSeparators(pe.value(GUI_ROOT_DIR)) );
44   QString shaper_root_dir( QDir::fromNativeSeparators(pe.value(SHAPER_ROOT_DIR)) );
45   QString lightappconfig_val( QString("%1:%2")
46   .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/gui").arg(gui_root_dir) ) )
47   .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/shaper")
48         .arg(shaper_root_dir) ) ) );
49   pe.insert(LIGHTAPPCONFIG,lightappconfig_val);
50   //tells shutup to salome.salome_init invoked at shaper engine ignition
51   pe.insert("SALOME_EMB_SERVANT","1");
52   //
53   QProcess proc;
54   proc.setProcessEnvironment(pe);
55   proc.setProgram("suitexe");
56   proc.setArguments({"--modules=SHAPER"});
57   proc.setProcessChannelMode( QProcess::ForwardedErrorChannel );
58   proc.start();
59   proc.waitForFinished(-1);
60   return proc.exitCode();
61 }