Fixed camera reverting in 3d explorer not reverting fov slider

This commit is contained in:
Michaël Lemaire 2014-01-04 11:43:40 +01:00
parent ec71b09f2e
commit 98646efb99
3 changed files with 18 additions and 7 deletions

View file

@ -34,18 +34,17 @@ DialogExplorer::DialogExplorer(QWidget* parent, CameraDefinition* camera, bool c
label = new QLabel(tr("Field of vision"), panel); label = new QLabel(tr("Field of vision"), panel);
label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
panel->layout()->addWidget(label); panel->layout()->addWidget(label);
QSlider* slider = new QSlider(Qt::Horizontal, panel); _fov = new QSlider(Qt::Horizontal, panel);
slider->setRange(0, 1000); _fov->setRange(0, 1000);
slider->setValue((int)(1000.0 * (camera->getPerspective().yfov - 0.7) / 1.0)); _fov->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
slider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); connect(_fov, SIGNAL(valueChanged(int)), this, SLOT(fovChanged(int)));
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(fovChanged(int))); panel->layout()->addWidget(_fov);
panel->layout()->addWidget(slider);
panel->layout()->addWidget(new QLabel(tr("COMMANDS\n\nLeft click : Look around\nRight click : Pan (adjust framing)\nWheel : Move forward/backward\nHold SHIFT : Faster\nHold CTRL : Slower"), panel)); panel->layout()->addWidget(new QLabel(tr("COMMANDS\n\nLeft click : Look around\nRight click : Pan (adjust framing)\nWheel : Move forward/backward\nHold SHIFT : Faster\nHold CTRL : Slower"), panel));
button = new QPushButton(tr("Reset camera"), panel); button = new QPushButton(tr("Reset camera"), panel);
panel->layout()->addWidget(button); panel->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), _wanderer, SLOT(resetCamera())); QObject::connect(button, SIGNAL(clicked()), this, SLOT(resetCamera()));
if (camera_validable) if (camera_validable)
{ {
@ -61,6 +60,7 @@ DialogExplorer::DialogExplorer(QWidget* parent, CameraDefinition* camera, bool c
layout()->addWidget(panel); layout()->addWidget(panel);
resize(900, 600); resize(900, 600);
resetCamera();
} }
DialogExplorer::~DialogExplorer() DialogExplorer::~DialogExplorer()
@ -73,6 +73,12 @@ void DialogExplorer::validateCamera()
accept(); accept();
} }
void DialogExplorer::resetCamera()
{
_wanderer->resetCamera();
_fov->setValue((int)(1000.0 * (_wanderer->getCurrentCamera()->getPerspective().yfov - 0.7) / 1.0));
}
void DialogExplorer::fovChanged(int value) void DialogExplorer::fovChanged(int value)
{ {
_wanderer->setCameraFov(0.7 + 1.0 * ((double)value) / 1000.0); _wanderer->setCameraFov(0.7 + 1.0 * ((double)value) / 1000.0);

View file

@ -5,6 +5,8 @@
#include <QDialog> #include <QDialog>
class QSlider;
class DialogExplorer : public QDialog class DialogExplorer : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -14,10 +16,12 @@ public:
protected slots: protected slots:
void validateCamera(); void validateCamera();
void resetCamera();
void fovChanged(int value); void fovChanged(int value);
private: private:
WidgetExplorer* _wanderer; WidgetExplorer* _wanderer;
QSlider* _fov;
}; };
#endif #endif

View file

@ -16,6 +16,7 @@ public:
~WidgetExplorer(); ~WidgetExplorer();
void setCameraFov(double fov); void setCameraFov(double fov);
inline const CameraDefinition* getCurrentCamera() const {return _current_camera;}
public slots: public slots:
void resetCamera(); void resetCamera();