/*****************************************************************************1* *2* Elmer, A Finite Element Software for Multiphysical Problems *3* *4* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *5* *6* This program is free software; you can redistribute it and/or *7* modify it under the terms of the GNU General Public License *8* as published by the Free Software Foundation; either version 2 *9* of the License, or (at your option) any later version. *10* *11* This program is distributed in the hope that it will be useful, *12* but WITHOUT ANY WARRANTY; without even the implied warranty of *13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *14* GNU General Public License for more details. *15* *16* You should have received a copy of the GNU General Public License *17* along with this program (in file fem/GPL-2); if not, write to the *18* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *19* Boston, MA 02110-1301, USA. *20* *21*****************************************************************************/2223/*****************************************************************************24* *25* ElmerGUI main *26* *27*****************************************************************************28* *29* Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback *30* Email: [email protected] *31* Web: http://www.csc.fi/elmer *32* Address: CSC - IT Center for Science Ltd. *33* Keilaranta 14 *34* 02101 Espoo, Finland *35* *36* Original Date: 15 Mar 2008 *37* *38*****************************************************************************/39#include "mainwindow.h"40#include <QApplication>41#include <iostream>424344using namespace std;4546#ifdef __APPLE__47#include <mach-o/dyld.h>48#include <stdlib.h>49#endif5051int main(int argc, char *argv[]) {5253#ifdef Q_OS_WINDOWS54#if WITH_QT655qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");56#endif57#endif5859#ifdef __APPLE__60// we'll change ENVIRONMENT so that the Elmer binaries and libraries61// hidden within the application bundle will be correctly found6263char executablePath[MAXPATHLENGTH] = {0};64uint32_t len = MAXPATHLENGTH;6566if (!_NSGetExecutablePath((char *)executablePath, &len)) {67// remove executable name from path:68*(strrchr(executablePath, '/')) = '\0';69char *oldValue = 0, *newValue = 0;7071oldValue = getenv("PATH");72asprintf(&newValue, "%s/../bin:%s", executablePath, oldValue);73setenv("PATH", newValue, 1);74free(newValue);7576oldValue = getenv("DYLD_LIBRARY_PATH");77asprintf(&newValue, "%s/../lib:%s", executablePath, oldValue);78setenv("DYLD_LIBRARY_PATH", newValue, 0);79free(newValue);8081asprintf(&newValue, "%s/..", executablePath);82setenv("ELMER_HOME", newValue, 0);83free(newValue);8485asprintf(&newValue, "%s/../share/elmerpost", executablePath);86setenv("ELMER_POST_HOME", newValue, 0);87free(newValue);8889#ifdef DEBUG90printf("PATH = %s\nDYLD_LIBRARY_PATH=%s\nELMER_HOME=%s\n", getenv("PATH"),91getenv("DYLD_LIBRARY_PATH"), getenv("ELMER_HOME"));92#endif93}94#endif9596//========================================================================9798QApplication app(argc, argv);99100QStringList argList = QCoreApplication::arguments();101102if (argList.contains("-h") || argList.contains("--help")) {103cout << "Usage:" << endl;104cout << " ElmerGUI [OPTION [FILE|DIR]]..." << endl;105cout << endl;106cout << "Graphical user interface and mesh generator for Elmer" << endl;107cout << endl;108cout << "Application options:" << endl;109cout << " -h, --help Show help options" << endl;110cout << " -i <string> Select input file" << endl;111cout << " -o <string> Select output dir" << endl;112cout << " -nogui Disable GUI" << endl;113cout << " -e Exit after saving" << endl;114cout << " -tq <value> Mesh quality (Tetgen only)" << endl;115cout << endl;116return 0;117}118119// Borrow locale from C120QLocale::setDefault(QLocale::c());121122MainWindow mainWindow;123mainWindow.parseCmdLine();124125return app.exec();126}127128129