pulsatingscience.cpp 4.84 KB
Newer Older
Oliver Bock's avatar
Oliver Bock committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/******************************************************************************
 *   Copyright (C) 2008 by Oliver Bock                                        *
 *   oliver.bock[AT]aei.mpg.de                                                *
 *                                                                            *
 *   This file is part of PulsatingScience.                                   *
 *                                                                            *
 *   PulsatingScience is free software: you can redistribute it and/or modify *
 *   it under the terms of the GNU General Public License as published        *
 *   by the Free Software Foundation, version 3 of the License.               *
 *                                                                            *
 *   PulsatingScience is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             *
 *   GNU General Public License for more details.                             *
 *                                                                            *
 *   You should have received a copy of the GNU General Public License        *
 *   along with PulsatingScience. If not, see <http://www.gnu.org/licenses/>. *
 *                                                                            *
 ******************************************************************************/

#include "pulsatingscience.h"

PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
{
	ui.setupUi(this);
26

Oliver Bock's avatar
Oliver Bock committed
27
28
29
30
	QAction* animControl = ui.dockAnimControl->toggleViewAction();
	animControl->setStatusTip("Toggle the animation control visibility");
	animControl->setShortcut(QKeySequence::fromString("Alt+A"));
	ui.menuView->addAction(animControl);
31
32
33
34
35
36
37
38
39
40

	connect(ui.actionRun, SIGNAL(activated()),
			ui.pulsarGlWidget, SLOT(runAnimation()));

	connect(ui.actionPause, SIGNAL(activated()),
				ui.pulsarGlWidget, SLOT(pauseAnimation()));

	connect(ui.actionStop, SIGNAL(activated()),
				ui.pulsarGlWidget, SLOT(stopAnimation()));

Oliver Bock's avatar
Oliver Bock committed
41
42
43
	connect(ui.actionRotationAxes, SIGNAL(toggled(bool)),
				ui.pulsarGlWidget, SLOT(showRotationAxes(bool)));

Oliver Bock's avatar
Oliver Bock committed
44
	on_sliderPulsarSpinFrequency_valueChanged(ui.sliderPulsarSpinFrequency->value());
45
46
	on_sliderPulsarSpinAxisInclination_valueChanged(ui.sliderPulsarSpinAxisInclination->value());
	on_sliderPulsarMagneticAxisInclination_valueChanged(ui.sliderPulsarMagneticAxisInclination->value());
Oliver Bock's avatar
Oliver Bock committed
47
48
	on_sliderOrbitRadius_valueChanged(ui.sliderOrbitRadius->value());
	on_sliderOrbitFrequency_valueChanged(ui.sliderOrbitFrequency->value());
Oliver Bock's avatar
Oliver Bock committed
49
50
51
52
53
54
}

PulsatingScience::~PulsatingScience()
{

}
55

Oliver Bock's avatar
Oliver Bock committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
void PulsatingScience::on_pushRun_clicked()
{
	if(ui.pushRun->isEnabled()) {
		ui.pushRun->setEnabled(false);
		ui.pushPause->setEnabled(true);
		ui.pushStop->setEnabled(true);
	}
	else {
		ui.pushRun->setEnabled(true);
		ui.pushPause->setEnabled(false);
		ui.pushStop->setEnabled(false);
	}
}

void PulsatingScience::on_pushPause_clicked()
{
	ui.pushRun->setEnabled(true);
	ui.pushPause->setEnabled(false);
	ui.pushStop->setEnabled(true);
}

void PulsatingScience::on_pushStop_clicked()
{
	ui.pushRun->setEnabled(true);
	ui.pushPause->setEnabled(false);
	ui.pushStop->setEnabled(false);
}

Oliver Bock's avatar
Oliver Bock committed
84
void PulsatingScience::on_sliderPulsarSpinFrequency_valueChanged(int value)
85
{
Oliver Bock's avatar
Oliver Bock committed
86
	ui.pulsarGlWidget->setPulsarRotationDelta(value / 10.0);
Oliver Bock's avatar
Oliver Bock committed
87
88
89
	ui.lcdPulsarSpinFrequency->display(QString::number(value / 10.0, 'f', 1));
}

90
91
92
93
94
95
void PulsatingScience::on_sliderPulsarSpinAxisInclination_valueChanged(int value)
{
	ui.pulsarGlWidget->setPulsarSpinAxisInclination(value);
	ui.lcdPulsarSpinAxisInclination->display(QString::number(value));
}

96
97
98
99
100
101
void PulsatingScience::on_sliderPulsarMagneticAxisInclination_valueChanged(int value)
{
	ui.pulsarGlWidget->setPulsarMagneticAxisInclination(value);
	ui.lcdPulsarMagneticAxisInclination->display(QString::number(value));
}

Oliver Bock's avatar
Oliver Bock committed
102
103
104
105
106
107
108
109
void PulsatingScience::on_sliderOrbitRadius_valueChanged(int value)
{
	ui.pulsarGlWidget->setOrbitRadius(value);
	ui.lcdOrbitRadius->display(QString::number(value, 'f', 1));
}

void PulsatingScience::on_sliderOrbitFrequency_valueChanged(int value)
{
Oliver Bock's avatar
Oliver Bock committed
110
	ui.pulsarGlWidget->setOrbitRotationDelta(value / 10.0);
Oliver Bock's avatar
Oliver Bock committed
111
	ui.lcdOrbitFrequency->display(QString::number(value / 10.0, 'f', 1));
112
}
Oliver Bock's avatar
Oliver Bock committed
113
114
115
116
117
118
119
120
121
122

void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
{
	checked ? ui.menuBar->show() : ui.menuBar->hide();
}

void PulsatingScience::on_actionStatus_bar_toggled(bool checked)
{
	checked ? ui.statusbar->show() : ui.statusbar->hide();
}
Oliver Bock's avatar
Oliver Bock committed
123
124
125
126
127
128
129
130
131
132

void PulsatingScience::on_actionAbout_activated()
{
	QMessageBox::about(this, "About",
			"<b>Pulsating Science</b><br>"
			"International Year of Astronomy 2009<br><br>"
			"Authors: Oliver Bock, Benjamin Knispel<br><br>"
			"Copyright &copy; 2009 "
			"<a href=\"http://www.aei.mpg.de\">Max-Planck-Institut f&uuml;r Gravitationsphysik</a>");
}