-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasemodel.cpp
120 lines (95 loc) · 3.4 KB
/
basemodel.cpp
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright 2021 Jose Maria Castelo Ares
// This file is part of SIRview.
// SIRview is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// SIRview is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with SIRview. If not, see <https://www.gnu.org/licenses/>.
#include "basemodel.h"
BaseModel::BaseModel(
int index,
QString modelName,
std::list<QString> variableShortNamesList,
std::list<QString> variableLongNamesList,
std::list<QString> parameterNamesList,
std::list<double> parameterMinList,
std::list<double> parameterMaxList)
{
name = modelName;
modelIndex = index;
for (std::list<QString>::iterator it = variableShortNamesList.begin(); it != variableShortNamesList.end(); ++it)
{
variableShortNames.push_back(new QLabel(*it));
}
for (std::list<QString>::iterator it = variableLongNamesList.begin(); it != variableLongNamesList.end(); ++it)
{
variableLongNames.push_back(new QLabel(*it));
plotNames.push_back(*it);
}
for (std::list<QString>::iterator it = parameterNamesList.begin(); it != parameterNamesList.end(); ++it)
{
parameterNames.push_back(new QLabel(*it));
}
for (std::list<double>::iterator it = parameterMinList.begin(); it != parameterMinList.end(); ++it)
{
parameterMin.push_back(*it);
}
for (std::list<double>::iterator it = parameterMaxList.begin(); it != parameterMaxList.end(); ++it)
{
parameterMax.push_back(*it);
}
dimension = static_cast<int>(variableShortNames.size());
numParameters = static_cast<int>(parameterNames.size());
}
BaseModel::BaseModel(const BaseModel &bm)
{
name = bm.name;
dimension = bm.dimension;
numParameters = bm.numParameters;
for (size_t i = 0; i < bm.variableShortNames.size(); i++)
{
QLabel *label = new QLabel;
label->setText(bm.variableShortNames[i]->text());
variableShortNames.push_back(label);
}
for (size_t i = 0; i < bm.variableLongNames.size(); i++)
{
QLabel *label = new QLabel;
label->setText(bm.variableLongNames[i]->text());
variableLongNames.push_back(label);
}
for (size_t i = 0; i < bm.parameterNames.size(); i++)
{
QLabel *label = new QLabel;
label->setText(bm.parameterNames[i]->text());
parameterNames.push_back(label);
}
parameterMin = bm.parameterMin;
parameterMax = bm.parameterMax;
}
BaseModel::~BaseModel()
{
for (unsigned long i = 0; i < variableShortNames.size(); i++)
{
delete variableShortNames[i];
variableShortNames[i] = nullptr;
}
variableShortNames.clear();
for (unsigned long i = 0; i < variableLongNames.size(); i++)
{
delete variableLongNames[i];
variableLongNames[i] = nullptr;
}
variableLongNames.clear();
for (unsigned long i = 0; i < parameterNames.size(); i++)
{
delete parameterNames[i];
parameterNames[i] = nullptr;
}
parameterNames.clear();
}