57 lines
1.8 KiB
C++
57 lines
1.8 KiB
C++
#include "settings_pane.hh"
|
|
|
|
#include <QCheckBox>
|
|
#include <QDoubleSpinBox>
|
|
#include <QFormLayout>
|
|
#include <QGroupBox>
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
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);
|
|
connect(collisions, &QListWidget::itemClicked,
|
|
[&](QListWidgetItem *item) { emit collisionClicked(((CollisionItem *) item)->getFrame()); });
|
|
|
|
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);
|
|
QGroupBox *box = new QGroupBox();
|
|
box->setTitle("Collisions");
|
|
box->setFlat(true);
|
|
box->setAlignment(Qt::AlignHCenter);
|
|
QVBoxLayout *box_layout = new QVBoxLayout();
|
|
box_layout->addWidget(collisions);
|
|
box->setLayout(box_layout);
|
|
layout->addRow(box);
|
|
setLayout(layout);
|
|
}
|
|
|
|
|
|
void SettingsPane::addCollision(int idA, int idB, int frame) {
|
|
CollisionItem *item = new CollisionItem("Frame " + QString::number(frame) + ": #"
|
|
+ QString::number(idA) + " et #" + QString::number(idB),
|
|
frame);
|
|
item->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
|
|
collisions->addItem(item);
|
|
}
|
|
|
|
|
|
void SettingsPane::clearCollisions() {
|
|
QListWidgetItem *item;
|
|
while ((item = collisions->takeItem(0)) != nullptr) {
|
|
delete item;
|
|
}
|
|
}
|