-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathmain.cpp
More file actions
91 lines (84 loc) · 3.06 KB
/
Copy pathmain.cpp
File metadata and controls
91 lines (84 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL
* VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the OSMC (Open Source Modelica Consortium)
* Public License (OSMC-PL) are obtained from OSMC, either from the above
* address, from the URLs:
* http://www.openmodelica.org or
* https://github.com/OpenModelica/ or
* http://www.ida.liu.se/projects/OpenModelica,
* and in the OpenModelica distribution.
*
* GNU AGPL version 3 is obtained from:
* https://www.gnu.org/licenses/licenses.html#GPL
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
#include "OMSensDialog.h"
#include "omedit_plugin/model.h"
#include <QApplication>
#include <QTemporaryDir>
// Model example to be used when OMSens is used as standalone
// (main function below example)
Model modelExample()
{
// Define model data
const QList<QString> inputVariables;
const QList<QString> parameters( QList<QString>()
<< "realParam1"
<< "realParam2"
<< "realParam3");
const QList<QString> outputVariables( QList<QString>()
<< "outvar1"
<< "outvar2"
<< "outvar3");
const QList<QString> auxVariables;
// Model name
QString modelName = "ModelWithVariousParams";
// Model path in Qt resources
QString fileResourcePath = ":/OMSens/ModelWithVariousParams.mo";
// Model file name to be used when written to disk
QString tempModelName = "ModelWithVariousParams.mo";
// Temp dir where to write Model
QTemporaryDir tempDir;
// Disable auto remove so the user can check the model
tempDir.setAutoRemove(false);
QString filePath= QDir::cleanPath(tempDir.path() + QDir::separator() + tempModelName);
if (tempDir.isValid()) {
QFile::copy(fileResourcePath, filePath);
}
// Initialize model
Model model(inputVariables, outputVariables, auxVariables, parameters, filePath, modelName);
return model;
}
int main(int argc, char *argv[])
{
// Initialize Qt Application
QApplication a(argc, argv);
// Model information for testing:
Model model = modelExample();
// Initialize OMSens Dialog
OMSensDialog dialog(model);
// Show OMSens Dialog
dialog.show();
// Run and end Qt Application
return a.exec();
}