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

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;
......
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PulsatingScienceClass</class>
<widget class="QMainWindow" name="PulsatingScienceClass" >
<property name="geometry" >
<widget class="QMainWindow" name="PulsatingScienceClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>704</width>
<width>743</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Pulsating Science - Max-Planck-Institut für Gravitationsphysik Hannover</string>
</property>
<property name="windowIcon" >
<iconset resource="pulsatingscience.qrc" >
<property name="windowIcon">
<iconset resource="pulsatingscience.qrc">
<normaloff>:/icons/resources/aei-icon48.png</normaloff>:/icons/resources/aei-icon48.png</iconset>
</property>
<property name="autoFillBackground" >
<property name="autoFillBackground">
<bool>true</bool>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="PulsarAnimationWidget" native="1" name="pulsarGlWidget" />
<widget class="PulseScopeWidget" name="pulseScopeWidget" >
<property name="frameShape" >
<widget class="PulsarAnimationWidget" name="pulsarGlWidget" native="true"/>
<widget class="PulseScopeWidget" name="pulseScopeWidget">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy" >
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy" >
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="backgroundBrush" >
<brush brushstyle="SolidPattern" >
<color alpha="255" >
<property name="backgroundBrush">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</property>
<property name="interactive" >
<property name="interactive">
<bool>false</bool>
</property>
<property name="renderHints" >
<property name="renderHints">
<set>QPainter::HighQualityAntialiasing</set>
</property>
</widget>
......@@ -57,403 +58,403 @@
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar" />
<widget class="QDockWidget" name="dockAnimControl" >
<property name="features" >
<widget class="QStatusBar" name="statusbar"/>
<widget class="QDockWidget" name="dockAnimControl">
<property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Animation Control</string>
</property>
<attribute name="dockWidgetArea" >
<attribute name="dockWidgetArea">
<number>8</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents" >
<layout class="QGridLayout" name="gridLayout_3" >
<item row="1" column="2" >
<layout class="QGridLayout" name="gridLayout_2" >
<item row="2" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="2">
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Pulsar Spin Frequency:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QSlider" name="sliderPulsarSpinFrequency" >
<property name="statusTip" >
<item row="2" column="1">
<widget class="QSlider" name="sliderPulsarSpinFrequency">
<property name="statusTip">
<string>Use this slider to adjust the spin frequency</string>
</property>
<property name="minimum" >
<property name="minimum">
<number>0</number>
</property>
<property name="maximum" >
<property name="maximum">
<number>20</number>
</property>
<property name="pageStep" >
<property name="pageStep">
<number>5</number>
</property>
<property name="value" >
<property name="value">
<number>5</number>
</property>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance" >
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls" >
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition" >
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval" >
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QLCDNumber" name="lcdPulsarSpinFrequency" >
<property name="numDigits" >
<item row="2" column="2">
<widget class="QLCDNumber" name="lcdPulsarSpinFrequency">
<property name="numDigits">
<number>6</number>
</property>
<property name="segmentStyle" >
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
<property name="value" stdset="0" >
<property name="value" stdset="0">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Pulsar Orbit Semi Major Axis:</string>
</property>
</widget>
</item>
<item row="5" column="2" >
<widget class="QLCDNumber" name="lcdPulsarSemiMajorAxis" >
<property name="numDigits" >
<item row="5" column="2">
<widget class="QLCDNumber" name="lcdPulsarSemiMajorAxis">
<property name="numDigits">
<number>6</number>
</property>
<property name="segmentStyle" >
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
<property name="value" stdset="0" >
<property name="value" stdset="0">
<double>5.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QSlider" name="sliderPulsarSemiMajorAxis" >
<property name="statusTip" >
<item row="5" column="1">
<widget class="QSlider" name="sliderPulsarSemiMajorAxis">
<property name="statusTip">
<string>Use this slider to adjust the length of the semi major axis of the pulsar's elliptical orbit</string>
</property>
<property name="minimum" >
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum" >
<property name="maximum">
<number>20000</number>
</property>
<property name="value" >
<property name="value">
<number>5000</number>
</property>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition" >
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval" >
<property name="tickInterval">
<number>1000</number>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Pulsar Spin Axis Inclination:</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Pulsar Magn. Axis Inclination:</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QSlider" name="sliderPulsarSpinAxisInclination" >
<property name="statusTip" >
<item row="3" column="1">
<widget class="QSlider" name="sliderPulsarSpinAxisInclination">
<property name="statusTip">
<string>Use this slider to adjust the inclination of the spin axis with respect to the orbit axis</string>
</property>
<property name="maximum" >
<property name="maximum">
<number>180</number>
</property>
<property name="value" >
<property name="value">
<number>0</number>
</property>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition" >
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
<item row="3" column="2" >
<widget class="QLCDNumber" name="lcdPulsarSpinAxisInclination" >
<property name="numDigits" >
<item row="3" column="2">
<widget class="QLCDNumber" name="lcdPulsarSpinAxisInclination">
<property name="numDigits">
<number>6</number>
</property>
<property name="segmentStyle" >
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
<property name="intValue" stdset="0" >
<property name="intValue" stdset="0">
<number>0</number>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QSlider" name="sliderPulsarMagneticAxisInclination" >
<property name="statusTip" >
<item row="4" column="1">
<widget class="QSlider" name="sliderPulsarMagneticAxisInclination">
<property name="statusTip">
<string>Use this slider to adjust the inclination of the magnetic pole axis with respect to the spin axis</string>
</property>
<property name="maximum" >
<property name="maximum">
<number>180</number>
</property>
<property name="value" >
<property name="value">
<number>60</number>
</property>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition" >
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="QLCDNumber" name="lcdPulsarMagneticAxisInclination" >
<property name="numDigits" >
<item row="4" column="2">
<widget class="QLCDNumber" name="lcdPulsarMagneticAxisInclination">
<property name="numDigits">
<number>6</number>
</property>
<property name="segmentStyle" >
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
<property name="value" stdset="0" >
<property name="value" stdset="0">
<double>60.000000000000000</double>
</property>
<property name="intValue" stdset="0" >
<property name="intValue" stdset="0">
<number>60</number>
</property>
</widget>
</item>
<item row="3" column="3" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<item row="3" column="3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>deg</string>
</property>
</widget>
</item>
<item row="4" column="3" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<item row="4" column="3">
<widget class="QLabel" name="label_7">
<property name="text">
<string>deg</string>
</property>
</widget>
</item>
<item row="2" column="3" >
<widget class="QLabel" name="label_8" >
<property name="text" >
<item row="2" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Hz</string>
</property>
</widget>
</item>
<item row="5" column="3" >
<widget class="QLabel" name="label_9" >
<property name="text" >
<item row="5" column="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>AU</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_10" >
<property name="text" >
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Companion Class:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radioCompanionWD" >
<property name="statusTip" >
<string>Set companion class to "White Dwarf" (0.6 solar masses)</string>
<widget class="QRadioButton" name="radioCompanionWD">
<property name="statusTip">
<string>Set companion class to &quot;White Dwarf&quot; (0.6 solar masses)</string>
</property>
<property name="text" >
<property name="text">
<string>White Dwarf</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioCompanionSun" >
<property name="statusTip" >
<string>Set companion class to "Sun" (1.0 solar masses)</string>
<widget class="QRadioButton" name="radioCompanionSun">
<property name="statusTip">
<string>Set companion class to &quot;Sun&quot; (1.0 solar masses)</string>
</property>
<property name="text" >
<property name="text">
<string>Sun</string>
</property>
<property name="checked" >
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioCompanionNS" >
<property name="statusTip" >
<string>Set companion class to "Neutron Star" (1.4 solar masses)</string>
<widget class="QRadioButton" name="radioCompanionNS">
<property name="statusTip">
<string>Set companion class to &quot;Neutron Star&quot; (1.4 solar masses)</string>
</property>
<property name="text" >
<property name="text">
<string>Neutron Star</string>
</property>
<property name="checked" >
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>