Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/Application/src/main.cpp
3203 views
1
/*****************************************************************************
2
* *
3
* Elmer, A Finite Element Software for Multiphysical Problems *
4
* *
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *
6
* *
7
* This program is free software; you can redistribute it and/or *
8
* modify it under the terms of the GNU General Public License *
9
* as published by the Free Software Foundation; either version 2 *
10
* of the License, or (at your option) any later version. *
11
* *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program (in file fem/GPL-2); if not, write to the *
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
20
* Boston, MA 02110-1301, USA. *
21
* *
22
*****************************************************************************/
23
24
/*****************************************************************************
25
* *
26
* ElmerGUI main *
27
* *
28
*****************************************************************************
29
* *
30
* Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback *
31
* Email: [email protected] *
32
* Web: http://www.csc.fi/elmer *
33
* Address: CSC - IT Center for Science Ltd. *
34
* Keilaranta 14 *
35
* 02101 Espoo, Finland *
36
* *
37
* Original Date: 15 Mar 2008 *
38
* *
39
*****************************************************************************/
40
#include "mainwindow.h"
41
#include <QApplication>
42
#include <iostream>
43
44
45
using namespace std;
46
47
#ifdef __APPLE__
48
#include <mach-o/dyld.h>
49
#include <stdlib.h>
50
#endif
51
52
int main(int argc, char *argv[]) {
53
54
#ifdef Q_OS_WINDOWS
55
#if WITH_QT6
56
qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
57
#endif
58
#endif
59
60
#ifdef __APPLE__
61
// we'll change ENVIRONMENT so that the Elmer binaries and libraries
62
// hidden within the application bundle will be correctly found
63
64
char executablePath[MAXPATHLENGTH] = {0};
65
uint32_t len = MAXPATHLENGTH;
66
67
if (!_NSGetExecutablePath((char *)executablePath, &len)) {
68
// remove executable name from path:
69
*(strrchr(executablePath, '/')) = '\0';
70
char *oldValue = 0, *newValue = 0;
71
72
oldValue = getenv("PATH");
73
asprintf(&newValue, "%s/../bin:%s", executablePath, oldValue);
74
setenv("PATH", newValue, 1);
75
free(newValue);
76
77
oldValue = getenv("DYLD_LIBRARY_PATH");
78
asprintf(&newValue, "%s/../lib:%s", executablePath, oldValue);
79
setenv("DYLD_LIBRARY_PATH", newValue, 0);
80
free(newValue);
81
82
asprintf(&newValue, "%s/..", executablePath);
83
setenv("ELMER_HOME", newValue, 0);
84
free(newValue);
85
86
asprintf(&newValue, "%s/../share/elmerpost", executablePath);
87
setenv("ELMER_POST_HOME", newValue, 0);
88
free(newValue);
89
90
#ifdef DEBUG
91
printf("PATH = %s\nDYLD_LIBRARY_PATH=%s\nELMER_HOME=%s\n", getenv("PATH"),
92
getenv("DYLD_LIBRARY_PATH"), getenv("ELMER_HOME"));
93
#endif
94
}
95
#endif
96
97
//========================================================================
98
99
QApplication app(argc, argv);
100
101
QStringList argList = QCoreApplication::arguments();
102
103
if (argList.contains("-h") || argList.contains("--help")) {
104
cout << "Usage:" << endl;
105
cout << " ElmerGUI [OPTION [FILE|DIR]]..." << endl;
106
cout << endl;
107
cout << "Graphical user interface and mesh generator for Elmer" << endl;
108
cout << endl;
109
cout << "Application options:" << endl;
110
cout << " -h, --help Show help options" << endl;
111
cout << " -i <string> Select input file" << endl;
112
cout << " -o <string> Select output dir" << endl;
113
cout << " -nogui Disable GUI" << endl;
114
cout << " -e Exit after saving" << endl;
115
cout << " -tq <value> Mesh quality (Tetgen only)" << endl;
116
cout << endl;
117
return 0;
118
}
119
120
// Borrow locale from C
121
QLocale::setDefault(QLocale::c());
122
123
MainWindow mainWindow;
124
mainWindow.parseCmdLine();
125
126
return app.exec();
127
}
128
129