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

Added menu bar option to toggle flash visibility

parent 2e189760
Branches
Tags
No related merge requests found
......@@ -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"
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;
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PulsatingScienceClass</class>
<widget class="QMainWindow" name="PulsatingScienceClass">
......@@ -5,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>704</width>
<width>743</width>
<height>600</height>
</rect>
</property>
......@@ -26,7 +27,7 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="PulsarAnimationWidget" native="1" name="pulsarGlWidget" />
<widget class="PulsarAnimationWidget" name="pulsarGlWidget" native="true"/>
<widget class="PulseScopeWidget" name="pulseScopeWidget">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
......@@ -292,7 +293,7 @@
<item>
<widget class="QRadioButton" name="radioCompanionWD">
<property name="statusTip">
<string>Set companion class to "White Dwarf" (0.6 solar masses)</string>
<string>Set companion class to &quot;White Dwarf&quot; (0.6 solar masses)</string>
</property>
<property name="text">
<string>White Dwarf</string>
......@@ -302,7 +303,7 @@
<item>
<widget class="QRadioButton" name="radioCompanionSun">
<property name="statusTip">
<string>Set companion class to "Sun" (1.0 solar masses)</string>
<string>Set companion class to &quot;Sun&quot; (1.0 solar masses)</string>
</property>
<property name="text">
<string>Sun</string>
......@@ -315,7 +316,7 @@
<item>
<widget class="QRadioButton" name="radioCompanionNS">
<property name="statusTip">
<string>Set companion class to "Neutron Star" (1.4 solar masses)</string>
<string>Set companion class to &quot;Neutron Star&quot; (1.4 solar masses)</string>
</property>
<property name="text">
<string>Neutron Star</string>
......@@ -343,7 +344,7 @@
<item row="0" column="3">
<widget class="QLabel" name="label_11">
<property name="text">
<string>M&lt;sub>0&lt;/sub></string>
<string>M&lt;sub&gt;0&lt;/sub&gt;</string>
</property>
</widget>
</item>
......@@ -392,7 +393,7 @@
<item row="1" column="3">
<widget class="QLabel" name="label_13">
<property name="text">
<string>M&lt;sub>0&lt;/sub></string>
<string>M&lt;sub&gt;0&lt;/sub&gt;</string>
</property>
</widget>
</item>
......@@ -478,7 +479,7 @@
<item>
<widget class="QPushButton" name="pushAbout">
<property name="statusTip">
<string>About "Pulsating Science"</string>
<string>About &quot;Pulsating Science&quot;</string>
</property>
<property name="text">
<string>About</string>
......@@ -506,8 +507,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>704</width>
<height>31</height>
<width>743</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuView">
......@@ -516,6 +517,7 @@
</property>
<addaction name="actionPermanent_orbits"/>
<addaction name="actionRotationAxes"/>
<addaction name="actionPulseFlashes"/>
<addaction name="separator"/>
<addaction name="actionFullscreen"/>
<addaction name="separator"/>
......@@ -569,7 +571,7 @@
<string>About</string>
</property>
<property name="statusTip">
<string>About "Pulsating Science"</string>
<string>About &quot;Pulsating Science&quot;</string>
</property>
<property name="shortcut">
<string>Ctrl+A</string>
......@@ -732,6 +734,23 @@
<string>Alt+O</string>
</property>
</action>
<action name="actionPulseFlashes">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Pulse flashes</string>
</property>
<property name="statusTip">
<string>Toggle the pulse flash visibility</string>
</property>
<property name="shortcut">
<string>Alt+P</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