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

Added option to show orbital planes permanently (not only during interaction)

parent 06da55db
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -478,6 +478,7 @@
<property name="title" >
<string>&amp;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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment