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
|
#include "settings_pane.hh"
#include <QCheckBox>
#include <QDoubleSpinBox>
#include <QFormLayout>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QTabWidget>
SettingsPane::SettingsPane(QWidget *parent)
:QWidget(parent) {
QDoubleSpinBox *sphere_radius = new QDoubleSpinBox();
sphere_radius->setSingleStep(.1);
QCheckBox *show_trajectories = new QCheckBox();
QCheckBox *show_guides = new QCheckBox();
collisions = new QListWidget();
speeding_violations = new QListWidget();
connect(sphere_radius, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &SettingsPane::sphereRadiusChanged);
connect(show_trajectories, &QCheckBox::stateChanged,
this, &SettingsPane::toggledTrajectories);
connect(show_guides, &QCheckBox::stateChanged,
this, &SettingsPane::toggledGuides);
connect(collisions, &QListWidget::itemClicked,
[&](QListWidgetItem *item) { emit bookmarkClicked(((BookmarkItem *) item)->getFrame()); });
connect(speeding_violations, &QListWidget::itemClicked,
[&](QListWidgetItem *item) { emit bookmarkClicked(((BookmarkItem *) item)->getFrame()); });
QTabWidget *tabs = new QTabWidget();
QFormLayout *layout = new QFormLayout;
layout->addRow("Taille de la sphère de collision", sphere_radius);
layout->addRow("Afficher les trajectoires", show_trajectories);
layout->addRow("Afficher les guides", show_guides);
tabs->addTab(collisions, "Collisions");
tabs->addTab(speeding_violations, "Excès de vitesse");
layout->addRow(tabs);
setLayout(layout);
}
void SettingsPane::addCollision(int idA, int idB, int frame) {
BookmarkItem *item = new BookmarkItem("Frame " + QString::number(frame) + ": #"
+ QString::number(idA) + " et #" + QString::number(idB),
frame);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
collisions->addItem(item);
}
void SettingsPane::addSpeedingViolation(int id, int frame, double speed) {
BookmarkItem *item = new BookmarkItem("Frame " + QString::number(frame) + ": #"
+ QString::number(id) + " (" + QString::number(speed) + ")",
frame);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
speeding_violations->addItem(item);
}
void SettingsPane::clearCollisions() {
QListWidgetItem *item;
while ((item = collisions->takeItem(0)) != nullptr) {
delete item;
}
}
void SettingsPane::clearSpeedingViolations() {
QListWidgetItem *item;
while ((item = speeding_violations->takeItem(0)) != nullptr) {
delete item;
}
}
|