-
Notifications
You must be signed in to change notification settings - Fork 1
/
positiondialog.cpp
61 lines (51 loc) · 1.82 KB
/
positiondialog.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
/*!
* \file positiondialog.cpp
* \author Simon Coakley
* \date 2012
* \copyright Copyright (c) 2012 University of Sheffield
* \brief Implementation of position dialog
*/
#include <QtGui>
#include <QHBoxLayout>
#include "./positiondialog.h"
PositionDialog::PositionDialog(QList<AgentType> *ats,
VisualSettingsModel * model, int r, QWidget *parent)
: QDialog(parent) {
setupUi(this);
vsm = model;
agentTypes = ats;
row = r;
for (int i = 0; i < agentTypes->count(); i++) {
if (QString::compare(agentTypes->at(i).name,
vsm->getRule(row)->agentType()) == 0) {
for (int j = 0; j < agentTypes->at(i).variables.count(); j++) {
variableComboBox->insertItem(j,
agentTypes->at(i).variables.at(j));
}
}
}
valueSpinBox->setMaximum(9999.99);
valueSpinBox->setMinimum(-9999.99);
connect(checkBox_Variable, SIGNAL(clicked(bool)),
variableComboBox, SLOT(setEnabled(bool)));
connect(buttonBox, SIGNAL(accepted()), this, SIGNAL(okButton()));
connect(buttonBox, SIGNAL(rejected()), this, SIGNAL(cancelButton()));
}
void PositionDialog::setPosition(Position p) {
position = p;
int index = 0;
for (int i = 0; i < variableComboBox->count(); i++) {
if (variableComboBox->itemText(i) == position.positionVariable)
index = i;
}
variableComboBox->setCurrentIndex(index);
valueSpinBox->setValue(position.opValue);
checkBox_Variable->setChecked(position.useVariable);
variableComboBox->setEnabled(position.useVariable);
}
Position PositionDialog::getPosition() {
position.positionVariable = variableComboBox->currentText();
position.opValue = valueSpinBox->value();
position.useVariable = checkBox_Variable->checkState();
return position;
}