add clicking to a collision to seek to it
This commit is contained in:
parent
bb0da810d9
commit
a23067c181
@ -29,6 +29,7 @@ Drone::Drone(const QJsonObject &json)
|
|||||||
for (const QJsonValue &o : ja) {
|
for (const QJsonValue &o : ja) {
|
||||||
waypoints.append(Waypoint(o.toObject()));
|
waypoints.append(Waypoint(o.toObject()));
|
||||||
}
|
}
|
||||||
|
setTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent) {
|
|||||||
QDockWidget *dock = new QDockWidget("Outils", this);
|
QDockWidget *dock = new QDockWidget("Outils", this);
|
||||||
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||||
settings_pane = new SettingsPane();
|
settings_pane = new SettingsPane();
|
||||||
|
settings_pane->setEnabled(false);
|
||||||
dock->setWidget(settings_pane);
|
dock->setWidget(settings_pane);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, dock);
|
addDockWidget(Qt::RightDockWidgetArea, dock);
|
||||||
}
|
}
|
||||||
@ -62,9 +63,13 @@ void MainWindow::open(const QString &path) {
|
|||||||
if (dc) delete dc;
|
if (dc) delete dc;
|
||||||
glw.meshes.clear();
|
glw.meshes.clear();
|
||||||
dc = new DroneController(json_doc.object());
|
dc = new DroneController(json_doc.object());
|
||||||
playpause_action->setEnabled(true);
|
|
||||||
|
// Play/Pause button
|
||||||
connect(dc, &DroneController::playing, this, &MainWindow::play);
|
connect(dc, &DroneController::playing, this, &MainWindow::play);
|
||||||
connect(dc, &DroneController::pausing, this, &MainWindow::pause);
|
connect(dc, &DroneController::pausing, this, &MainWindow::pause);
|
||||||
|
playpause_action->setEnabled(true);
|
||||||
|
|
||||||
|
// Seekbar slider
|
||||||
slider->setMinimum(0);
|
slider->setMinimum(0);
|
||||||
slider->setMaximum(dc->getDuration());
|
slider->setMaximum(dc->getDuration());
|
||||||
slider->setValue(0);
|
slider->setValue(0);
|
||||||
@ -72,10 +77,19 @@ void MainWindow::open(const QString &path) {
|
|||||||
connect(slider, &QSlider::sliderReleased, dc, &DroneController::resume);
|
connect(slider, &QSlider::sliderReleased, dc, &DroneController::resume);
|
||||||
connect(slider, &QSlider::valueChanged, dc, &DroneController::seek);
|
connect(slider, &QSlider::valueChanged, dc, &DroneController::seek);
|
||||||
connect(dc, &DroneController::frameChanged, slider, &QSlider::setValue);
|
connect(dc, &DroneController::frameChanged, slider, &QSlider::setValue);
|
||||||
connect(dc, &DroneController::collision, settings_pane, &SettingsPane::addCollision);
|
connect(settings_pane, &SettingsPane::collisionClicked,
|
||||||
dc->computeCollisions(10);
|
slider, &QSlider::setValue);
|
||||||
pause();
|
|
||||||
slider->setEnabled(true);
|
slider->setEnabled(true);
|
||||||
|
|
||||||
|
connect(dc, &DroneController::collision, settings_pane, &SettingsPane::addCollision);
|
||||||
|
connect(settings_pane, &SettingsPane::sphereRadiusChanged,
|
||||||
|
[&](double _) { settings_pane->clearCollisions(); });
|
||||||
|
connect(settings_pane, &SettingsPane::sphereRadiusChanged,
|
||||||
|
dc, &DroneController::computeCollisions);
|
||||||
|
settings_pane->setEnabled(true);
|
||||||
|
|
||||||
|
dc->computeCollisions(.1);
|
||||||
|
pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ SettingsPane::SettingsPane(QWidget *parent)
|
|||||||
this, &SettingsPane::toggledTrajectories);
|
this, &SettingsPane::toggledTrajectories);
|
||||||
connect(show_support_lines, &QCheckBox::stateChanged,
|
connect(show_support_lines, &QCheckBox::stateChanged,
|
||||||
this, &SettingsPane::toggledSupportLines);
|
this, &SettingsPane::toggledSupportLines);
|
||||||
|
connect(collisions, &QListWidget::itemClicked,
|
||||||
|
[&](QListWidgetItem *item) { emit collisionClicked(((CollisionItem *) item)->getFrame()); });
|
||||||
|
|
||||||
QFormLayout *layout = new QFormLayout;
|
QFormLayout *layout = new QFormLayout;
|
||||||
layout->addRow("Taille de la sphère de collision", sphere_radius);
|
layout->addRow("Taille de la sphère de collision", sphere_radius);
|
||||||
@ -29,8 +31,9 @@ SettingsPane::SettingsPane(QWidget *parent)
|
|||||||
|
|
||||||
|
|
||||||
void SettingsPane::addCollision(int idA, int idB, int frame) {
|
void SettingsPane::addCollision(int idA, int idB, int frame) {
|
||||||
QListWidgetItem *item = new QListWidgetItem(QString::number(frame) + ": "
|
CollisionItem *item = new CollisionItem(QString::number(frame) + ": "
|
||||||
+ QString::number(idA) + " / " + QString::number(idB));
|
+ QString::number(idA) + " / " + QString::number(idB),
|
||||||
|
frame);
|
||||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
|
item->setFlags(Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
|
||||||
collisions->addItem(item);
|
collisions->addItem(item);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,18 @@
|
|||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
|
|
||||||
|
|
||||||
|
class CollisionItem : public QListWidgetItem {
|
||||||
|
const int frame;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CollisionItem(QString text, int frame)
|
||||||
|
:QListWidgetItem(text),
|
||||||
|
frame(frame) {}
|
||||||
|
|
||||||
|
int getFrame() const { return frame; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class SettingsPane : public QWidget {
|
class SettingsPane : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -21,6 +33,7 @@ signals:
|
|||||||
void sphereRadiusChanged(double sqRadius);
|
void sphereRadiusChanged(double sqRadius);
|
||||||
void toggledTrajectories(int shown);
|
void toggledTrajectories(int shown);
|
||||||
void toggledSupportLines(int shown);
|
void toggledSupportLines(int shown);
|
||||||
|
void collisionClicked(int frame);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user