Skip to content
Snippets Groups Projects
Commit cc486b69 authored by Oliver Bock's avatar Oliver Bock
Browse files

Added button/action to reset camera position (in line with observer's line of sight)

parent 57b7c9b8
No related branches found
No related tags found
No related merge requests found
......@@ -508,6 +508,15 @@ void PulsarAnimationWidget::stopAnimation()
updateGL();
}
void PulsarAnimationWidget::resetViewpoint()
{
m_mouseAngleH = 0.0;
m_mouseAngleV = 0.0;
m_cameraZoom = 30.0;
updateCameraPosition(m_mouseAngleH, m_mouseAngleV, m_cameraZoom);
}
void PulsarAnimationWidget::updateFrame()
{
m_pulsarRotationAngle += m_pulsarRotationDelta;
......
......@@ -49,6 +49,7 @@ public slots:
void runAnimation();
void pauseAnimation();
void stopAnimation();
void resetViewpoint();
void updateFrame();
......
......@@ -52,6 +52,8 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
m_pauseShortcut->setEnabled(false);
m_stopShortcut = new QShortcut(ui.actionStop->shortcut(), this);
m_stopShortcut->setEnabled(false);
m_resetShortcut = new QShortcut(ui.actionReset->shortcut(), this);
m_resetShortcut->setEnabled(false);
m_rotationAxesShortcut = new QShortcut(ui.actionRotationAxes->shortcut(), this);
m_rotationAxesShortcut->setEnabled(false);
m_menuBarShortcut = new QShortcut(ui.actionMenu_bar->shortcut(), this);
......@@ -90,6 +92,12 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
connect(ui.actionStop, SIGNAL(triggered()),
this, SLOT(on_pushStop_clicked()));
connect(ui.pushReset, SIGNAL(clicked()),
ui.pulsarGlWidget, SLOT(resetViewpoint()));
connect(ui.actionReset, SIGNAL(triggered()),
ui.pulsarGlWidget, SLOT(resetViewpoint()));
connect(ui.actionRotationAxes, SIGNAL(toggled(bool)),
ui.pulsarGlWidget, SLOT(showRotationAxes(bool)));
......@@ -120,6 +128,11 @@ PulsatingScience::~PulsatingScience()
delete m_stopShortcut;
}
if(m_resetShortcut) {
m_resetShortcut->disconnect();
delete m_resetShortcut;
}
if(m_rotationAxesShortcut) {
m_rotationAxesShortcut->disconnect();
delete m_rotationAxesShortcut;
......@@ -244,6 +257,8 @@ void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
m_pauseShortcut->setEnabled(false);
m_stopShortcut->disconnect();
m_stopShortcut->setEnabled(false);
m_resetShortcut->disconnect();
m_resetShortcut->setEnabled(false);
m_rotationAxesShortcut->disconnect();
m_rotationAxesShortcut->setEnabled(false);
m_fullscreenShortcut->disconnect();
......@@ -262,6 +277,8 @@ void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
connect(m_pauseShortcut, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(pauseAnimation()));
m_stopShortcut->setEnabled(true);
connect(m_stopShortcut, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(stopAnimation()));
m_resetShortcut->setEnabled(true);
connect(m_resetShortcut, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(resetViewpoint()));
m_rotationAxesShortcut->setEnabled(true);
connect(m_rotationAxesShortcut, SIGNAL(activated()), this, SLOT(rotationAxesToggled()));
m_fullscreenShortcut->setEnabled(true);
......
......@@ -74,6 +74,7 @@ private:
QShortcut *m_runShortcut;
QShortcut *m_pauseShortcut;
QShortcut *m_stopShortcut;
QShortcut *m_resetShortcut;
QShortcut *m_permanentOrbitsShortcut;
QShortcut *m_rotationAxesShortcut;
QShortcut *m_menuBarShortcut;
......
<RCC>
<qresource prefix="icons" >
<qresource prefix="/icons">
<file>resources/control-pause.png</file>
<file>resources/control-quit.png</file>
<file>resources/control-run.png</file>
......@@ -8,11 +8,12 @@
<file>resources/help-help.png</file>
<file>resources/help-website.png</file>
<file>resources/aei-icon48.png</file>
<file>resources/control-reset.png</file>
</qresource>
<qresource prefix="i18ns" >
<qresource prefix="/i18ns">
<file>resources/pulsatingscience_de.qm</file>
</qresource>
<qresource prefix="textures" >
<qresource prefix="/textures">
<file>resources/texture_background_carina.png</file>
<file>resources/texture_pulsar.png</file>
</qresource>
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>745</width>
<height>600</height>
<width>787</width>
<height>684</height>
</rect>
</property>
<property name="windowTitle">
......@@ -336,6 +336,26 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushReset">
<property name="statusTip">
<string>Reset view to observer's line of sight</string>
</property>
<property name="text">
<string>Reset</string>
</property>
<property name="icon">
<iconset resource="pulsatingscience.qrc">
<normaloff>:/icons/resources/control-reset.png</normaloff>:/icons/resources/control-reset.png</iconset>
</property>
<property name="iconSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......@@ -394,7 +414,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>745</width>
<width>787</width>
<height>22</height>
</rect>
</property>
......@@ -426,6 +446,8 @@
<addaction name="actionPause"/>
<addaction name="actionStop"/>
<addaction name="separator"/>
<addaction name="actionReset"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
<addaction name="menuControl"/>
......@@ -619,6 +641,21 @@
<string>Alt+O</string>
</property>
</action>
<action name="actionReset">
<property name="icon">
<iconset resource="pulsatingscience.qrc">
<normaloff>:/icons/resources/control-reset.png</normaloff>:/icons/resources/control-reset.png</iconset>
</property>
<property name="text">
<string>Reset</string>
</property>
<property name="toolTip">
<string>Reset view</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment