diff --git a/src/pulsaranimationwidget.cpp b/src/pulsaranimationwidget.cpp index 9351a8be1378ba39290099183d59d4ff1ffb4396..d6e4e2c819a1e936e11a2150080f261f01f5e0da 100644 --- a/src/pulsaranimationwidget.cpp +++ b/src/pulsaranimationwidget.cpp @@ -64,8 +64,10 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) : m_pulsarMass = 1.4f; m_companionMass = 1.4f; + m_showOrbits = false; m_showRotationAxes = false; m_cameraInteraction = false; + m_mouseLastX = 0; m_mouseLastY = 0; m_mouseAngleH = 90.0f; @@ -305,7 +307,7 @@ void PulsarAnimationWidget::paintGL() glPopMatrix(); // draw orbital planes - if(m_cameraInteraction) { + if(m_cameraInteraction || m_showOrbits) { glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent); static float sizeOffset = 0.25f; @@ -375,6 +377,13 @@ void PulsarAnimationWidget::updateFrame() emit pulsarAnimationStep(m_pulsarRotationDelta); } +void PulsarAnimationWidget::showOrbits(bool enabled) +{ + m_showOrbits = enabled; + + updateGL(); +} + void PulsarAnimationWidget::showRotationAxes(bool enabled) { m_showRotationAxes = enabled; diff --git a/src/pulsaranimationwidget.h b/src/pulsaranimationwidget.h index 88c95abcdeadf143eda8aa3f16617184f9fcb2d6..dd51e2e382700e48e8566af9d5c1f98534171baf 100644 --- a/src/pulsaranimationwidget.h +++ b/src/pulsaranimationwidget.h @@ -53,6 +53,7 @@ public slots: void updateFrame(); + void showOrbits(bool enabled); void showRotationAxes(bool enabled); signals: @@ -107,8 +108,10 @@ private: int m_pulsarSpinAxisInclination; int m_pulsarMagneticAxisInclination; + bool m_showOrbits; bool m_showRotationAxes; bool m_cameraInteraction; + int m_mouseLastX; int m_mouseLastY; int m_mouseAngleH; diff --git a/src/pulsatingscience.cpp b/src/pulsatingscience.cpp index fb024d0537db442356ebfa891227695d61286805..a4d0ed56cdb9f732ef935d47c2e953dcf3063de9 100644 --- a/src/pulsatingscience.cpp +++ b/src/pulsatingscience.cpp @@ -30,6 +30,7 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) ui.menuView->addAction(animControl); // inital status (based on GUI) + m_permanentOrbits = ui.actionPermanent_orbits->isChecked(); m_rotationAxesVisible = ui.actionRotationAxes->isChecked(); m_menuBarVisible = ui.actionMenu_bar->isChecked(); m_statusBarVisible = ui.actionStatus_bar->isChecked(); @@ -43,6 +44,8 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) m_pauseShortcut->setEnabled(false); m_stopShortcut = new QShortcut(ui.actionStop->shortcut(), this); m_stopShortcut->setEnabled(false); + m_permanentOrbitsShortcut = new QShortcut(ui.actionPermanent_orbits->shortcut(), this); + m_permanentOrbitsShortcut->setEnabled(false); m_rotationAxesShortcut = new QShortcut(ui.actionRotationAxes->shortcut(), this); m_rotationAxesShortcut->setEnabled(false); m_menuBarShortcut = new QShortcut(ui.actionMenu_bar->shortcut(), this); @@ -50,8 +53,7 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) m_fullscreenShortcut = new QShortcut(ui.actionFullscreen->shortcut(), this); m_fullscreenShortcut->setEnabled(false); - // TODO: register all remaining shortcuts, too (to use them while menu is hidden!) - + // establish object communications connect(ui.actionRun, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(runAnimation())); @@ -61,6 +63,9 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) connect(ui.actionStop, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(stopAnimation())); + connect(ui.actionPermanent_orbits, SIGNAL(toggled(bool)), + ui.pulsarGlWidget, SLOT(showOrbits(bool))); + connect(ui.actionRotationAxes, SIGNAL(toggled(bool)), ui.pulsarGlWidget, SLOT(showRotationAxes(bool))); @@ -76,7 +81,6 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<float>&)), ui.pulseScopeWidget, SLOT(drawCurve(const QVector<float>&))); - // initialize animation parameters (using GUI settings) on_sliderPulsarSemiMajorAxis_valueChanged(ui.sliderPulsarSemiMajorAxis->value()); @@ -105,6 +109,11 @@ PulsatingScience::~PulsatingScience() delete m_stopShortcut; } + if(m_permanentOrbitsShortcut) { + m_permanentOrbitsShortcut->disconnect(); + delete m_permanentOrbitsShortcut; + } + if(m_rotationAxesShortcut) { m_rotationAxesShortcut->disconnect(); delete m_rotationAxesShortcut; @@ -204,6 +213,21 @@ void PulsatingScience::on_sliderPulsarSemiMajorAxis_valueChanged(int value) ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: black"); } +void PulsatingScience::permanentOrbitsToggled() { + if(m_permanentOrbits) { + on_actionPermanent_orbits_toggled(false); + ui.actionPermanent_orbits->setChecked(false); + } + else { + on_actionPermanent_orbits_toggled(true); + ui.actionPermanent_orbits->setChecked(true); + } +} + +void PulsatingScience::on_actionPermanent_orbits_toggled(bool checked) { + m_permanentOrbits = checked; +} + void PulsatingScience::rotationAxesToggled() { if(m_rotationAxesVisible) { on_actionRotationAxes_toggled(false); @@ -245,6 +269,8 @@ void PulsatingScience::on_actionMenu_bar_toggled(bool checked) m_pauseShortcut->setEnabled(false); m_stopShortcut->disconnect(); m_stopShortcut->setEnabled(false); + m_permanentOrbitsShortcut->disconnect(); + m_permanentOrbitsShortcut->setEnabled(false); m_rotationAxesShortcut->disconnect(); m_rotationAxesShortcut->setEnabled(false); m_fullscreenShortcut->disconnect(); @@ -263,6 +289,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_permanentOrbitsShortcut->setEnabled(true); + connect(m_permanentOrbitsShortcut, SIGNAL(activated()), this, SLOT(permanentOrbitsToggled())); m_rotationAxesShortcut->setEnabled(true); connect(m_rotationAxesShortcut, SIGNAL(activated()), this, SLOT(rotationAxesToggled())); m_fullscreenShortcut->setEnabled(true); diff --git a/src/pulsatingscience.h b/src/pulsatingscience.h index 69002b2c34992eaefc964e1a291d2f422a314de8..9f42e33fadcb19bb616fb1ee94b6fc75d0082adb 100644 --- a/src/pulsatingscience.h +++ b/src/pulsatingscience.h @@ -49,6 +49,8 @@ public slots: void on_sliderPulsarMagneticAxisInclination_valueChanged(int value); void on_sliderPulsarSemiMajorAxis_valueChanged(int value); + void permanentOrbitsToggled(); + void on_actionPermanent_orbits_toggled(bool checked); void rotationAxesToggled(); void on_actionRotationAxes_toggled(bool checked); void fullscreenToggled(); @@ -69,10 +71,12 @@ private: QShortcut *m_runShortcut; QShortcut *m_pauseShortcut; QShortcut *m_stopShortcut; + QShortcut *m_permanentOrbitsShortcut; QShortcut *m_rotationAxesShortcut; QShortcut *m_menuBarShortcut; QShortcut *m_fullscreenShortcut; + bool m_permanentOrbits; bool m_rotationAxesVisible; bool m_menuBarVisible; bool m_statusBarVisible; diff --git a/src/pulsatingscience.ui b/src/pulsatingscience.ui index d8fab5d749674acde04f345b00c6b91357b9e795..7e910ded8f01986b62ae78f4be1ec78a27bd83f1 100644 --- a/src/pulsatingscience.ui +++ b/src/pulsatingscience.ui @@ -478,6 +478,7 @@ <property name="title" > <string>&View</string> </property> + <addaction name="actionPermanent_orbits" /> <addaction name="actionRotationAxes" /> <addaction name="separator" /> <addaction name="actionFullscreen" /> @@ -652,7 +653,7 @@ <bool>true</bool> </property> <property name="text" > - <string>Rotation Axes</string> + <string>Rotation axes</string> </property> <property name="shortcut" > <string>Alt+R</string> @@ -669,6 +670,17 @@ <string>Alt+F</string> </property> </action> + <action name="actionPermanent_orbits" > + <property name="checkable" > + <bool>true</bool> + </property> + <property name="text" > + <string>Orbital planes</string> + </property> + <property name="shortcut" > + <string>Alt+O</string> + </property> + </action> </widget> <customwidgets> <customwidget>