From 861d505606d612bc328534dba3257e9ef9a1c269 Mon Sep 17 00:00:00 2001 From: ccolin Date: Sat, 2 Jan 2021 01:10:54 +0100 Subject: add basic collision detection --- src/settings_pane.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/settings_pane.cc (limited to 'src/settings_pane.cc') diff --git a/src/settings_pane.cc b/src/settings_pane.cc new file mode 100644 index 0000000..f37c14c --- /dev/null +++ b/src/settings_pane.cc @@ -0,0 +1,44 @@ +#include "settings_pane.hh" + +#include +#include +#include + + +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::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; + } +} -- cgit v1.2.3-70-g09d2