Commit 1251c71c authored by Oliver Bock's avatar Oliver Bock

Added menu bar option to toggle flash visibility

parent 2e189760
......@@ -96,6 +96,7 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
// initial view features
m_showOrbits = false;
m_showRotationAxes = false;
m_showPulseFlashes = true;
m_cameraInteraction = false;
// initial view settings
......@@ -555,12 +556,14 @@ void PulsarAnimationWidget::paintGL()
renderText(10, 10, -100, QString::fromLocal8Bit("Max-Planck-Insitut für Gravitationsphysik"), font);
// render pulse "flash"
int profileIndex = (int) round(m_pulsarRotationAngle);
profileIndex = profileIndex == 360 ? 0 : profileIndex;
GLfloat flashAlpha = m_pulseProfile[profileIndex];
glColor4f(1.0, 1.0, 0.0, 0.75 * flashAlpha);
glTranslatef(0.0, 0.0, -1.0);
glRectf(0.0, 0.0, width(), height());
if(m_showPulseFlashes) {
int profileIndex = (int) round(m_pulsarRotationAngle);
profileIndex = profileIndex == 360 ? 0 : profileIndex;
GLfloat flashAlpha = m_pulseProfile[profileIndex];
glColor4f(1.0, 1.0, 0.0, 0.75 * flashAlpha);
glTranslatef(0.0, 0.0, -1.0);
glRectf(0.0, 0.0, width(), height());
}
// restore original state
glMatrixMode(GL_PROJECTION);
......@@ -621,6 +624,13 @@ void PulsarAnimationWidget::showRotationAxes(bool enabled)
updateGL();
}
void PulsarAnimationWidget::showPulseFlashes(bool enabled)
{
m_showPulseFlashes = enabled;
updateGL();
}
void PulsarAnimationWidget::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
......
......@@ -57,6 +57,7 @@ public slots:
void showOrbits(bool enabled);
void showRotationAxes(bool enabled);
void showPulseFlashes(bool enabled);
signals:
void pulsarSemiMajorAxisUpdated(double value);
......@@ -117,6 +118,7 @@ private:
bool m_showOrbits;
bool m_showRotationAxes;
bool m_showPulseFlashes;
bool m_cameraInteraction;
int m_mouseLastX;
......
......@@ -42,6 +42,7 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
// inital status (based on GUI)
m_permanentOrbits = ui.actionPermanent_orbits->isChecked();
m_rotationAxesVisible = ui.actionRotationAxes->isChecked();
m_pulseFlashesVisible = ui.actionPulseFlashes->isChecked();
m_menuBarVisible = ui.actionMenu_bar->isChecked();
m_statusBarVisible = ui.actionStatus_bar->isChecked();
m_animControlVisible = true;
......@@ -59,6 +60,8 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
m_permanentOrbitsShortcut->setEnabled(false);
m_rotationAxesShortcut = new QShortcut(ui.actionRotationAxes->shortcut(), this);
m_rotationAxesShortcut->setEnabled(false);
m_pulseFlashesShortcut = new QShortcut(ui.actionPulseFlashes->shortcut(), this);
m_pulseFlashesShortcut->setEnabled(false);
m_menuBarShortcut = new QShortcut(ui.actionMenu_bar->shortcut(), this);
m_menuBarShortcut->setEnabled(false);
m_fullscreenShortcut = new QShortcut(ui.actionFullscreen->shortcut(), this);
......@@ -103,6 +106,9 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
connect(ui.actionRotationAxes, SIGNAL(toggled(bool)),
ui.pulsarGlWidget, SLOT(showRotationAxes(bool)));
connect(ui.actionPulseFlashes, SIGNAL(toggled(bool)),
ui.pulsarGlWidget, SLOT(showPulseFlashes(bool)));
connect(ui.pulsarGlWidget, SIGNAL(pulsarSemiMajorAxisUpdated(double)),
this, SLOT(updatePulsarSemiMajorAxisValue(double)));
......@@ -153,6 +159,11 @@ PulsatingScience::~PulsatingScience()
delete m_rotationAxesShortcut;
}
if(m_pulseFlashesShortcut) {
m_pulseFlashesShortcut->disconnect();
delete m_pulseFlashesShortcut;
}
if(m_menuBarShortcut) {
m_menuBarShortcut->disconnect();
delete m_menuBarShortcut;
......@@ -303,6 +314,21 @@ void PulsatingScience::on_actionRotationAxes_toggled(bool checked) {
m_rotationAxesVisible = checked;
}
void PulsatingScience::pulseFlashesToggled() {
if(m_pulseFlashesVisible) {
on_actionPulseFlashes_toggled(false);
ui.actionPulseFlashes->setChecked(false);
}
else {
on_actionPulseFlashes_toggled(true);
ui.actionPulseFlashes->setChecked(true);
}
}
void PulsatingScience::on_actionPulseFlashes_toggled(bool checked) {
m_pulseFlashesVisible = checked;
}
void PulsatingScience::menuBarToggled()
{
if(ui.menuBar->isVisible()) {
......@@ -333,6 +359,8 @@ void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
m_permanentOrbitsShortcut->setEnabled(false);
m_rotationAxesShortcut->disconnect();
m_rotationAxesShortcut->setEnabled(false);
m_pulseFlashesShortcut->disconnect();
m_pulseFlashesShortcut->setEnabled(false);
m_fullscreenShortcut->disconnect();
m_fullscreenShortcut->setEnabled(false);
m_menuBarShortcut->disconnect();
......@@ -353,6 +381,8 @@ void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
connect(m_permanentOrbitsShortcut, SIGNAL(activated()), this, SLOT(permanentOrbitsToggled()));
m_rotationAxesShortcut->setEnabled(true);
connect(m_rotationAxesShortcut, SIGNAL(activated()), this, SLOT(rotationAxesToggled()));
m_pulseFlashesShortcut->setEnabled(true);
connect(m_pulseFlashesShortcut, SIGNAL(activated()), this, SLOT(pulseFlashesToggled()));
m_fullscreenShortcut->setEnabled(true);
connect(m_fullscreenShortcut, SIGNAL(activated()), this, SLOT(fullscreenToggled()));
m_menuBarShortcut->setEnabled(true);
......
......@@ -60,6 +60,8 @@ public slots:
void on_actionPermanent_orbits_toggled(bool checked);
void rotationAxesToggled();
void on_actionRotationAxes_toggled(bool checked);
void pulseFlashesToggled();
void on_actionPulseFlashes_toggled(bool checked);
void fullscreenToggled();
void on_actionFullscreen_toggled(bool checked);
void menuBarToggled();
......@@ -83,6 +85,7 @@ private:
QShortcut *m_stopShortcut;
QShortcut *m_permanentOrbitsShortcut;
QShortcut *m_rotationAxesShortcut;
QShortcut *m_pulseFlashesShortcut;
QShortcut *m_menuBarShortcut;
QShortcut *m_fullscreenShortcut;
QShortcut *m_fullscreenESCShortcut;
......@@ -90,6 +93,7 @@ private:
bool m_permanentOrbits;
bool m_rotationAxesVisible;
bool m_pulseFlashesVisible;
bool m_menuBarVisible;
bool m_statusBarVisible;
bool m_animControlVisible;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment