pulsatingscience.cpp 6.45 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
45
46
	connect(ui.pulsarGlWidget, SIGNAL(pulsarSemiMajorAxisUpdated(double)),
				this, SLOT(updatePulsarSemiMajorAxisValue(double)));

Oliver Bock's avatar
Oliver Bock committed
47
48
49
50
51
52
53
54
55
	connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationStep(float)),
				ui.pulseScopeWidget, SLOT(markerStep(float)));

	connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationReset()),
				ui.pulseScopeWidget, SLOT(markerReset()));

	connect(ui.pulsarGlWidget, SIGNAL(pulsarViewDataUpdated(const QVector<float>&)),
				ui.pulseScopeWidget, SLOT(drawCurve(const QVector<float>&)));

Oliver Bock's avatar
Oliver Bock committed
56
57
58
59
60
	on_sliderPulsarSemiMajorAxis_valueChanged(ui.sliderPulsarSemiMajorAxis->value());

	on_radioCompanionNS_toggled(true);
	on_sliderPulsarMass_valueChanged(ui.sliderPulsarMass->value());

Oliver Bock's avatar
Oliver Bock committed
61
	on_sliderPulsarSpinFrequency_valueChanged(ui.sliderPulsarSpinFrequency->value());
62
63
	on_sliderPulsarSpinAxisInclination_valueChanged(ui.sliderPulsarSpinAxisInclination->value());
	on_sliderPulsarMagneticAxisInclination_valueChanged(ui.sliderPulsarMagneticAxisInclination->value());
Oliver Bock's avatar
Oliver Bock committed
64
65
66
67
68
69
}

PulsatingScience::~PulsatingScience()
{

}
70

Oliver Bock's avatar
Oliver Bock committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
void PulsatingScience::on_radioCompanionWD_toggled(bool checked)
{
	if(checked) {
		ui.pulsarGlWidget->setCompanionMass(0.6f);
		ui.lcdCompanionMass->display(QString::number(0.6f, 'f', 1));
	}
}

void PulsatingScience::on_radioCompanionSun_toggled(bool checked)
{
	if(checked) {
		ui.pulsarGlWidget->setCompanionMass(1.0f);
		ui.lcdCompanionMass->display(QString::number(1.0f, 'f', 1));
	}
}

void PulsatingScience::on_radioCompanionNS_toggled(bool checked)
{
	if(checked) {
		ui.pulsarGlWidget->setCompanionMass(1.4f);
		ui.lcdCompanionMass->display(QString::number(1.4f, 'f', 1));
	}
}

void PulsatingScience::on_sliderPulsarMass_valueChanged(int value)
{
	ui.pulsarGlWidget->setPulsarMass(value * 0.1f);
	ui.lcdPulsarMass->display(QString::number(value * 0.1f, 'f', 1));
}

Oliver Bock's avatar
Oliver Bock committed
129
void PulsatingScience::on_sliderPulsarSpinFrequency_valueChanged(int value)
130
{
Oliver Bock's avatar
Oliver Bock committed
131
132
	ui.pulsarGlWidget->setPulsarSpinFrequency(value * 0.1f);
	ui.lcdPulsarSpinFrequency->display(QString::number(value * 0.1f, 'f', 1));
Oliver Bock's avatar
Oliver Bock committed
133
134
}

135
136
137
138
139
140
void PulsatingScience::on_sliderPulsarSpinAxisInclination_valueChanged(int value)
{
	ui.pulsarGlWidget->setPulsarSpinAxisInclination(value);
	ui.lcdPulsarSpinAxisInclination->display(QString::number(value));
}

141
142
143
144
145
146
void PulsatingScience::on_sliderPulsarMagneticAxisInclination_valueChanged(int value)
{
	ui.pulsarGlWidget->setPulsarMagneticAxisInclination(value);
	ui.lcdPulsarMagneticAxisInclination->display(QString::number(value));
}

Oliver Bock's avatar
Oliver Bock committed
147
void PulsatingScience::on_sliderPulsarSemiMajorAxis_valueChanged(int value)
Oliver Bock's avatar
Oliver Bock committed
148
{
Oliver Bock's avatar
Oliver Bock committed
149
150
	ui.pulsarGlWidget->setPulsarSemiMajorAxis(value * 0.001f);
	ui.lcdPulsarSemiMajorAxis->display(QString::number(value * 0.001f, 'f', 1));
151
	ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: black");
152
}
Oliver Bock's avatar
Oliver Bock committed
153
154
155
156
157
158
159
160
161
162

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
163
164
165
166
167
168
169
170
171
172

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>");
}
Oliver Bock's avatar
Oliver Bock committed
173
174
175
176

void PulsatingScience::updatePulsarSemiMajorAxisValue(double value)
{
	ui.sliderPulsarSemiMajorAxis->setValue(value * 1000.0);
177

178
179
180
181
182
183
184
	if((int)value <= 1 || (int)value >= 20) {
		if((int)value < 1 || (int)value > 20) {
			ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: red");
		}
		else {
			ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: black");
		}
185
186
		ui.lcdPulsarSemiMajorAxis->display(QString::number(value, 'f', 1));
	}
Oliver Bock's avatar
Oliver Bock committed
187
}