aboutsummaryrefslogtreecommitdiff
path: root/src/settings_pane.cc
blob: f37c14cba7a08a2165c5911d9790f38408586c6e (plain)
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
#include "settings_pane.hh"

#include <QCheckBox>
#include <QDoubleSpinBox>
#include <QFormLayout>


SettingsPane::SettingsPane(QWidget *parent)
	:QWidget(parent) {
	QDoubleSpinBox *sphere_radius = new QDoubleSpinBox();
	QCheckBox *show_trajectories = new QCheckBox();
	QCheckBox *show_support_lines = new QCheckBox();
	collisions = new QListWidget();

	connect(sphere_radius, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
			this, &SettingsPane::sphereRadiusChanged);
	connect(show_trajectories, &QCheckBox::stateChanged,
			this, &SettingsPane::toggledTrajectories);
	connect(show_support_lines, &QCheckBox::stateChanged,
			this, &SettingsPane::toggledSupportLines);

	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 lignes de support", show_support_lines);
	layout->addRow(collisions);
	setLayout(layout);
}


void SettingsPane::addCollision(int idA, int idB, int frame) {
	QListWidgetItem *item = new QListWidgetItem(QString::number(frame) + ": "
							   + QString::number(idA) + " / " + QString::number(idB));
	item->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
	collisions->addItem(item);
}


void SettingsPane::clearCollisions() {
	QListWidgetItem *item;
	while ((item = collisions->takeItem(0)) != nullptr) {
		delete item;
	}
}