QSS Solver GUI  4.5.3
modeleditor.hpp
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  This file is part of QSS Solver.
4 
5  QSS Solver is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  QSS Solver is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
17 
18  ******************************************************************************/
19 
20 #pragma once
21 
22 #include <QTabWidget>
23 #include <QTextCursor>
24 #include <ui/ui_modeleditor.h>
25 
26 #include <utils.hpp>
27 
28 class ModelInfo;
29 class MmoHighlighter;
30 
31 class ModelEditor : public QDialog, public Ui::ModelEditorForm {
32  Q_OBJECT
33  public:
34  ModelEditor(QWidget *parent = NULL, QString name = QString());
35  ~ModelEditor();
36  inline QString absTolerance() { return getAnnotations("AbsTolerance"); };
37  QString activeBaseFileName();
38  bool activeDirty();
39  QString activeFileName();
40  inline int activeFileIndex() { return _model_editor_tab->currentIndex(); };
41  QString activeFullFileName();
42  QString baseFileName(int idx);
43  inline bool checkModel() { return checkToken("model "); };
44  inline bool checkPackage() { return checkToken("package "); };
45  void closeFiles();
46  inline int count() { return _model_editor_tab->count(); };
47  inline QString derDelta() { return getAnnotations("MMO_DerDelta"); };
48  inline QString description() { return getAnnotations("MMO_Description").remove('"'); };
49  void editModel(QString name = QString());
50  QString fileName(int idx);
51  QStringList fileNames();
52  QString fullFileName(int idx);
53  inline QString minStep() { return getAnnotations("MMO_MinStep"); };
54  QString modelName();
55  QString newFileName();
56  inline QString output() { return getAnnotations("MMO_Output"); };
57  inline QString outputType() { return getAnnotations("MMO_OutputType"); };
58  inline QString period() { return getAnnotations("MMO_Period"); };
59  inline QString scheduler() { return getAnnotations("MMO_Scheduler"); };
60  inline QString solver() { return getAnnotations("MMO_Solver"); };
61  inline QString startTime() { return getAnnotations("StartTime"); };
62  inline QString stopTime() { return getAnnotations("StopTime"); };
63  inline QString symDiff() { return getAnnotations("MMO_SymDiff"); };
64  inline QString parallel() { return getAnnotations("MMO_Parallel"); };
65  inline QString partitionMethod() { return getAnnotations("MMO_PartitionMethod"); };
66  inline QString DT() { return getAnnotations("MMO_DT_Min"); };
67  inline QString tolerance() { return getAnnotations("Tolerance"); };
68  inline void setAbsTolerance(QString str) { _absTolerance = str; };
69  inline void setDerDelta(QString str) { _derdelta = findValue("MMO_DerDelta", str); };
70  inline void setDescription(QString str)
71  {
72  _description.clear();
73  _description.append("\"").append(str).append("\"");
74  };
75  inline void setMinStep(QString str) { _minstep = findValue("MMO_MinStep", str); };
76  inline void setOutput(QString str) { _output = str; };
77  inline void setOutputType(QString str) { _outputType = findValue("MMO_OutputType", str); };
78  inline void setPeriod(QString str) { _period = findValue("MMO_Period", str); };
79  inline void setScheduler(QString str) { _scheduler = findValue("MMO_Scheduler", str); };
80  inline void setSolver(QString str) { _solver = str; };
81  inline void setStartTime(QString str) { _startTime = str; };
82  inline void setStopTime(QString str) { _stopTime = str; };
83  inline void setSymDiff(QString str) { _symdiff = findValue("MMO_SymDiff", str); };
84  inline void setTolerance(QString str) { _tolerance = str; };
85  inline void setZcHyst(QString str) { _zchyst = findValue("MMO_ZCHyst", str); };
86  inline void setLPS(QString str) { _lps = findValue("MMO_LPS", str); };
87  void writeAnnotations();
88  inline QString zcHyst() { return getAnnotations("MMO_ZCHyst"); };
89  inline QString LPS() { return getAnnotations("MMO_LPS"); };
90  inline void setParallel(QString str) { _parallel = findValue("MMO_Parallel", str); };
91  inline bool isParallel() { return _parallel.compare("true") == 0; };
92  inline void setPartitionMethod(QString str) { _partitionMethod = findValue("MMO_PartitionMethod", str); };
93  inline void setJacobian(QString str) { _jacobian = findValue("Jacobian", str); };
94  inline QString jacobian() { return _jacobian; };
95  inline void setDT(QString str) { _dt = findValue("MMO_DT_Min", str); };
96  inline void setDtSynch(QString str) { _dtSynch = findValue("MMO_DT_Synch", str); };
97  inline QString dtSynch() { return getAnnotations("MMO_DT_Synch"); };
98  inline void setDtPeriod(QString str) { _dtPeriod = findValue("MMO_DT_SynchPeriod", str); };
99  inline QString dtPeriod() { return getAnnotations("MMO_DT_SynchPeriod"); };
100  inline void setDtStepLog(QString str) { _dtStepLog = findValue("MMO_DT_StepLog", str); };
101  inline QString dtStepLog() { return getAnnotations("MMO_DT_StepLog"); };
102  inline void setPatohSettings(QString str) { _patohSettings = str; };
103  inline void setScotchSettings(QString str) { _scotchSettings = str; };
104  inline void setMetisSettings(QString str) { _metisSettings = str; };
105  inline QString patohSettings() { return getAnnotations("MMO_PatohSettings"); };
106  inline QString scotchSettings() { return getAnnotations("MMO_ScotchSettings"); };
107  inline QString metisSettings() { return getAnnotations("MMO_MetisSettings"); };
108  inline void setSemiStaticPartitioning(bool st) { _semiStaticPartitioning = st; };
110  inline void setImbalance(QString str) { _imbalance = findValue("MMO_Imbalance", str); };
111  inline QString imbalance() { return getAnnotations("MMO_Imbalance"); };
112  inline void setReorderPartition(QString str) { _reorderPartition = findValue("MMO_ReorderPartition", str); };
113  inline QString reorderPartition() { return getAnnotations("MMO_ReorderPartition"); };
114  inline void setDebugGraph(QString str) { _debugGraph = findValue("MMO_DebugGraph", str); };
115  inline QString debugGraph() { return getAnnotations("MMO_DebugGraph"); };
116  inline void setGenerateArch(QString str) { _generateArch = findValue("MMO_GenerateArch", str); };
117  inline QString generateArch() { return getAnnotations("MMO_GenerateArch"); };
118  inline QString BDFPart() { return getAnnotations("MMO_BDF_Part"); };
119  inline void setBDFPart(QString str) { _BDFPart = str; };
120  inline QString BDFPartitionDepth() { return getAnnotations("MMO_BDF_PDepth"); };
121  inline void setBDFPartitionDepth(QString str) { _BDFPartitionDepth = str; };
122  inline QString BDFMaxStep() { return getAnnotations("MMO_BDF_Max_Step"); };
123  inline void setBDFMaxStep(QString str) { _BDFMaxStep = str; };
124 
125  void keyReleaseEvent(QKeyEvent *event);
126  void save(void);
127  void saveAll(void);
128  void saveAs(QString name = QString());
129 
130  protected:
131  void reject(){};
132 
133  void currentChanged(int index);
134  void tabCloseRequested(int index);
135  void textChanged();
136 
137  signals:
138  void clean(int);
139  void done(QString name, QString ext);
140 
141  private:
142  inline void addLine(QString str) { _annotations << str; };
143  inline int beginModel() { return tokenPosition("model "); };
144  inline int endModel() { return tokenPosition("end " + modelName()); };
145  int controlEmptyLines(int position);
146  bool checkToken(QString str);
147  bool checkAnnotations();
148  int checkFunctions(int modelInit, int modelEnd);
149  void remove(int tab);
150  void deleteAnnotations();
151  void deletePackageFiles(int idx);
152  QString findValue(QString token, QString str);
153  QString getAnnotations(QString str);
154  QString getAnnotationValue(QString value, QString token);
155  bool lineEmpty();
156  void setAnnotations(QString str, QString value, bool separator);
157  void save(int tab);
158  int tokenPosition(QString token);
161  void searchFixedAnnot(QStringList annotations);
162  void addFixedAnnot();
163 
164  QStringList _annotations;
165  QMap<QString, QString> _defaultValues;
166  QString _startTime;
167  QString _stopTime;
168  QString _tolerance;
169  QString _absTolerance;
170  QString _solver;
171  QString _output;
172  QString _outputType;
173  QString _period;
174  QString _lps;
175  QString _description;
176  QString _minstep;
177  QString _zchyst;
178  QString _derdelta;
179  QString _scheduler;
180  QString _symdiff;
181  QString _dtSynch;
182  QString _dtPeriod;
183  QString _dtStepLog;
184  QString _dt;
185  QString _parallel;
187  QString _jacobian;
188  QString _patohSettings;
190  QString _metisSettings;
191  QString _generateArch;
192  QString _debugGraph;
194  QString _imbalance;
195  QString _BDFPart;
197  QString _BDFMaxStep;
199  QMap<QString, QString> _fixed_annotations;
200  QTabWidget *_model_editor_tab;
201  QList<ModelInfo> *_models;
204 };
ModelEditor::checkPackage
bool checkPackage()
Definition: modeleditor.hpp:44
ModelEditor::_parallel
QString _parallel
Definition: modeleditor.hpp:185
ModelEditor::_reorderPartition
QString _reorderPartition
Definition: modeleditor.hpp:193
ModelEditor::activeDirty
bool activeDirty()
Definition: modeleditor.cpp:167
ModelEditor::setLPS
void setLPS(QString str)
Definition: modeleditor.hpp:86
ModelEditor::setOutput
void setOutput(QString str)
Definition: modeleditor.hpp:76
ModelEditor::_metisSettings
QString _metisSettings
Definition: modeleditor.hpp:190
ModelEditor::BDFPart
QString BDFPart()
Definition: modeleditor.hpp:118
ModelEditor::checkAnnotations
bool checkAnnotations()
Definition: modeleditor.cpp:444
ModelEditor::_generateArch
QString _generateArch
Definition: modeleditor.hpp:191
ModelEditor::_imbalance
QString _imbalance
Definition: modeleditor.hpp:194
utils.hpp
ModelEditor::currentChanged
void currentChanged(int index)
Definition: modeleditor.cpp:228
ModelInfo
Definition: modelinfo.hpp:24
ModelEditor::checkModel
bool checkModel()
Definition: modeleditor.hpp:43
ModelEditor::_scheduler
QString _scheduler
Definition: modeleditor.hpp:179
ModelEditor::setScheduler
void setScheduler(QString str)
Definition: modeleditor.hpp:79
ModelEditor::partitionMethod
QString partitionMethod()
Definition: modeleditor.hpp:65
ModelEditor::setImbalance
void setImbalance(QString str)
Definition: modeleditor.hpp:110
ModelEditor::absTolerance
QString absTolerance()
Definition: modeleditor.hpp:36
ModelEditor::done
void done(QString name, QString ext)
ModelEditor::LPS
QString LPS()
Definition: modeleditor.hpp:89
ModelEditor::_annotations
QStringList _annotations
Definition: modeleditor.hpp:164
ModelEditor::addLine
void addLine(QString str)
Definition: modeleditor.hpp:142
ModelEditor::derDelta
QString derDelta()
Definition: modeleditor.hpp:47
ModelEditor::symDiff
QString symDiff()
Definition: modeleditor.hpp:63
ModelEditor::scotchSettings
QString scotchSettings()
Definition: modeleditor.hpp:106
ModelEditor::keyReleaseEvent
void keyReleaseEvent(QKeyEvent *event)
Definition: modeleditor.cpp:149
ModelEditor::setMetisSettings
void setMetisSettings(QString str)
Definition: modeleditor.hpp:104
ModelEditor::startTime
QString startTime()
Definition: modeleditor.hpp:61
ModelEditor::BDFMaxStep
QString BDFMaxStep()
Definition: modeleditor.hpp:122
ModelEditor::outputType
QString outputType()
Definition: modeleditor.hpp:57
ModelEditor::_BDFMaxStep
QString _BDFMaxStep
Definition: modeleditor.hpp:197
ModelEditor::activeFileName
QString activeFileName()
Definition: modeleditor.cpp:161
ModelEditor::setAbsTolerance
void setAbsTolerance(QString str)
Definition: modeleditor.hpp:68
ModelEditor::_patohSettings
QString _patohSettings
Definition: modeleditor.hpp:188
ModelEditor::_dt
QString _dt
Definition: modeleditor.hpp:184
ModelEditor::description
QString description()
Definition: modeleditor.hpp:48
ModelEditor::tabCloseRequested
void tabCloseRequested(int index)
Definition: modeleditor.cpp:236
ModelEditor::period
QString period()
Definition: modeleditor.hpp:58
MmoHighlighter
Definition: mmohighlight.hpp:27
ModelEditor::_outputType
QString _outputType
Definition: modeleditor.hpp:172
ModelEditor::setPartitionMethod
void setPartitionMethod(QString str)
Definition: modeleditor.hpp:92
ModelEditor::_dtPeriod
QString _dtPeriod
Definition: modeleditor.hpp:182
ModelEditor::debugGraph
QString debugGraph()
Definition: modeleditor.hpp:115
ModelEditor::activeFileIndex
int activeFileIndex()
Definition: modeleditor.hpp:40
ModelEditor::fileName
QString fileName(int idx)
Definition: modeleditor.cpp:176
ModelEditor::setParallel
void setParallel(QString str)
Definition: modeleditor.hpp:90
ModelEditor::_hl
MmoHighlighter * _hl
Definition: modeleditor.hpp:203
ModelEditor::checkFunctions
int checkFunctions(int modelInit, int modelEnd)
Definition: modeleditor.cpp:582
ModelEditor::setScotchSettings
void setScotchSettings(QString str)
Definition: modeleditor.hpp:103
ModelEditor::setSolver
void setSolver(QString str)
Definition: modeleditor.hpp:80
Utils
Definition: utils.hpp:60
ModelEditor::setSymDiff
void setSymDiff(QString str)
Definition: modeleditor.hpp:83
ModelEditor::setZcHyst
void setZcHyst(QString str)
Definition: modeleditor.hpp:85
ModelEditor::_solver
QString _solver
Definition: modeleditor.hpp:170
ModelEditor::_fixed_annotations
QMap< QString, QString > _fixed_annotations
Definition: modeleditor.hpp:199
ModelEditor::setDebugGraph
void setDebugGraph(QString str)
Definition: modeleditor.hpp:114
ModelEditor::_absTolerance
QString _absTolerance
Definition: modeleditor.hpp:169
ModelEditor::setAnnotations
void setAnnotations(QString str, QString value, bool separator)
Definition: modeleditor.cpp:419
ModelEditor::generateArch
QString generateArch()
Definition: modeleditor.hpp:117
ModelEditor::baseFileName
QString baseFileName(int idx)
Definition: modeleditor.cpp:190
ModelEditor::remove
void remove(int tab)
Definition: modeleditor.cpp:265
ModelEditor::dtSynch
QString dtSynch()
Definition: modeleditor.hpp:97
ModelEditor::setPeriod
void setPeriod(QString str)
Definition: modeleditor.hpp:78
ModelEditor::_jacobian
QString _jacobian
Definition: modeleditor.hpp:187
ModelEditor::_lps
QString _lps
Definition: modeleditor.hpp:174
ModelEditor::modelName
QString modelName()
Definition: modeleditor.cpp:715
ModelEditor::_scotchSettings
QString _scotchSettings
Definition: modeleditor.hpp:189
ModelEditor::_output
QString _output
Definition: modeleditor.hpp:171
ModelEditor::semiStaticPartitioning
bool semiStaticPartitioning()
Definition: modeleditor.hpp:109
ModelEditor::metisSettings
QString metisSettings()
Definition: modeleditor.hpp:107
ModelEditor::setDerDelta
void setDerDelta(QString str)
Definition: modeleditor.hpp:69
ModelEditor::_BDFPartitionDepth
QString _BDFPartitionDepth
Definition: modeleditor.hpp:196
ModelEditor::setStopTime
void setStopTime(QString str)
Definition: modeleditor.hpp:82
ModelEditor::getAnnotations
QString getAnnotations(QString str)
Definition: modeleditor.cpp:502
ModelEditor::setTolerance
void setTolerance(QString str)
Definition: modeleditor.hpp:84
ModelEditor::_partitionMethod
QString _partitionMethod
Definition: modeleditor.hpp:186
ModelEditor::setDtPeriod
void setDtPeriod(QString str)
Definition: modeleditor.hpp:98
ModelEditor::reject
void reject()
Definition: modeleditor.hpp:131
ModelEditor::setBDFPartitionDepth
void setBDFPartitionDepth(QString str)
Definition: modeleditor.hpp:121
ModelEditor::tolerance
QString tolerance()
Definition: modeleditor.hpp:67
ModelEditor::findValue
QString findValue(QString token, QString str)
Definition: modeleditor.cpp:572
ModelEditor::checkToken
bool checkToken(QString str)
Definition: modeleditor.cpp:434
ModelEditor::setDT
void setDT(QString str)
Definition: modeleditor.hpp:95
ModelEditor::setSemiStaticPartitioning
void setSemiStaticPartitioning(bool st)
Definition: modeleditor.hpp:108
ModelEditor::_utils
Utils * _utils
Definition: modeleditor.hpp:202
ModelEditor::addFixedAnnot
void addFixedAnnot()
Definition: modeleditor.cpp:742
ModelEditor::_period
QString _period
Definition: modeleditor.hpp:173
ModelEditor::textChanged
void textChanged()
Definition: modeleditor.cpp:210
ModelEditor::closeFiles
void closeFiles()
Definition: modeleditor.cpp:258
ModelEditor::patohSettings
QString patohSettings()
Definition: modeleditor.hpp:105
ModelEditor::lineEmpty
bool lineEmpty()
Definition: modeleditor.cpp:409
ModelEditor
Definition: modeleditor.hpp:31
ModelEditor::save
void save(void)
Definition: modeleditor.cpp:276
ModelEditor::controlEmptyLines
int controlEmptyLines(int position)
Definition: modeleditor.cpp:617
ModelEditor::deleteAnnotations
void deleteAnnotations()
Definition: modeleditor.cpp:637
ModelEditor::parallel
QString parallel()
Definition: modeleditor.hpp:64
ModelEditor::_description
QString _description
Definition: modeleditor.hpp:175
ModelEditor::isParallel
bool isParallel()
Definition: modeleditor.hpp:91
ModelEditor::_BDFPart
QString _BDFPart
Definition: modeleditor.hpp:195
ModelEditor::setBDFPart
void setBDFPart(QString str)
Definition: modeleditor.hpp:119
ModelEditor::_debugGraph
QString _debugGraph
Definition: modeleditor.hpp:192
ModelEditor::dtPeriod
QString dtPeriod()
Definition: modeleditor.hpp:99
ModelEditor::_models
QList< ModelInfo > * _models
Definition: modeleditor.hpp:201
ModelEditor::saveAll
void saveAll(void)
Definition: modeleditor.cpp:307
ModelEditor::setPatohSettings
void setPatohSettings(QString str)
Definition: modeleditor.hpp:102
ModelEditor::_dtStepLog
QString _dtStepLog
Definition: modeleditor.hpp:183
ModelEditor::beginModel
int beginModel()
Definition: modeleditor.hpp:143
ModelEditor::setDtSynch
void setDtSynch(QString str)
Definition: modeleditor.hpp:96
ModelEditor::zcHyst
QString zcHyst()
Definition: modeleditor.hpp:88
ModelEditor::stopTime
QString stopTime()
Definition: modeleditor.hpp:62
ModelEditor::endModel
int endModel()
Definition: modeleditor.hpp:144
ModelEditor::deletePackageFiles
void deletePackageFiles(int idx)
Definition: modeleditor.cpp:706
ModelEditor::_stopTime
QString _stopTime
Definition: modeleditor.hpp:167
ModelEditor::activeBaseFileName
QString activeBaseFileName()
Definition: modeleditor.cpp:184
ModelEditor::getAnnotationValue
QString getAnnotationValue(QString value, QString token)
Definition: modeleditor.cpp:365
ModelEditor::setJacobian
void setJacobian(QString str)
Definition: modeleditor.hpp:93
ModelEditor::_minstep
QString _minstep
Definition: modeleditor.hpp:176
ModelEditor::setDtStepLog
void setDtStepLog(QString str)
Definition: modeleditor.hpp:100
ModelEditor::solver
QString solver()
Definition: modeleditor.hpp:60
ModelEditor::~ModelEditor
~ModelEditor()
Definition: modeleditor.cpp:107
ModelEditor::BDFPartitionDepth
QString BDFPartitionDepth()
Definition: modeleditor.hpp:120
ModelEditor::ModelEditor
ModelEditor(QWidget *parent=NULL, QString name=QString())
Definition: modeleditor.cpp:29
ModelEditor::reorderPartition
QString reorderPartition()
Definition: modeleditor.hpp:113
ModelEditor::writeAnnotations
void writeAnnotations()
Definition: modeleditor.cpp:749
ModelEditor::minStep
QString minStep()
Definition: modeleditor.hpp:53
ModelEditor::_dtSynch
QString _dtSynch
Definition: modeleditor.hpp:181
ModelEditor::fullFileName
QString fullFileName(int idx)
Definition: modeleditor.cpp:204
ModelEditor::activeFullFileName
QString activeFullFileName()
Definition: modeleditor.cpp:198
ModelEditor::dtStepLog
QString dtStepLog()
Definition: modeleditor.hpp:101
ModelEditor::imbalance
QString imbalance()
Definition: modeleditor.hpp:111
ModelEditor::DT
QString DT()
Definition: modeleditor.hpp:66
ModelEditor::setMinStep
void setMinStep(QString str)
Definition: modeleditor.hpp:75
ModelEditor::_zchyst
QString _zchyst
Definition: modeleditor.hpp:177
ModelEditor::setDescription
void setDescription(QString str)
Definition: modeleditor.hpp:70
ModelEditor::_defaultValues
QMap< QString, QString > _defaultValues
Definition: modeleditor.hpp:165
ModelEditor::_symdiff
QString _symdiff
Definition: modeleditor.hpp:180
ModelEditor::jacobian
QString jacobian()
Definition: modeleditor.hpp:94
ModelEditor::fileNames
QStringList fileNames()
Definition: modeleditor.cpp:400
ModelEditor::setReorderPartition
void setReorderPartition(QString str)
Definition: modeleditor.hpp:112
ModelEditor::_model_editor_tab
QTabWidget * _model_editor_tab
Definition: modeleditor.hpp:200
ModelEditor::_startTime
QString _startTime
Definition: modeleditor.hpp:166
ModelEditor::_derdelta
QString _derdelta
Definition: modeleditor.hpp:178
ModelEditor::output
QString output()
Definition: modeleditor.hpp:56
ModelEditor::setStartTime
void setStartTime(QString str)
Definition: modeleditor.hpp:81
ModelEditor::_semiStaticPartitioning
bool _semiStaticPartitioning
Definition: modeleditor.hpp:198
ModelEditor::_tolerance
QString _tolerance
Definition: modeleditor.hpp:168
ModelEditor::searchFixedAnnot
void searchFixedAnnot(QStringList annotations)
Definition: modeleditor.cpp:732
ModelEditor::clean
void clean(int)
ModelEditor::editModel
void editModel(QString name=QString())
Definition: modeleditor.cpp:114
ModelEditor::tokenPosition
int tokenPosition(QString token)
Definition: modeleditor.cpp:387
ModelEditor::saveAs
void saveAs(QString name=QString())
Definition: modeleditor.cpp:287
ModelEditor::setGenerateArch
void setGenerateArch(QString str)
Definition: modeleditor.hpp:116
ModelEditor::count
int count()
Definition: modeleditor.hpp:46
ModelEditor::newFileName
QString newFileName()
Definition: modeleditor.cpp:318
ModelEditor::scheduler
QString scheduler()
Definition: modeleditor.hpp:59
ModelEditor::setBDFMaxStep
void setBDFMaxStep(QString str)
Definition: modeleditor.hpp:123
ModelEditor::setOutputType
void setOutputType(QString str)
Definition: modeleditor.hpp:77