pulsatingscience.cpp 5.96 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
47
48
49
50
51
	connect(ui.pulsarGlWidget, SIGNAL(pulsarSemiMajorAxisUpdated(double)),
				this, SLOT(updatePulsarSemiMajorAxisValue(double)));

	on_sliderPulsarSemiMajorAxis_valueChanged(ui.sliderPulsarSemiMajorAxis->value());

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

Oliver Bock's avatar
Oliver Bock committed
52
	on_sliderPulsarSpinFrequency_valueChanged(ui.sliderPulsarSpinFrequency->value());
53
54
	on_sliderPulsarSpinAxisInclination_valueChanged(ui.sliderPulsarSpinAxisInclination->value());
	on_sliderPulsarMagneticAxisInclination_valueChanged(ui.sliderPulsarMagneticAxisInclination->value());
Oliver Bock's avatar
Oliver Bock committed
55
56
57
58
59
60
}

PulsatingScience::~PulsatingScience()
{

}
61

Oliver Bock's avatar
Oliver Bock committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
120
void PulsatingScience::on_sliderPulsarSpinFrequency_valueChanged(int value)
121
{
Oliver Bock's avatar
Oliver Bock committed
122
123
	ui.pulsarGlWidget->setPulsarSpinFrequency(value * 0.1f);
	ui.lcdPulsarSpinFrequency->display(QString::number(value * 0.1f, 'f', 1));
Oliver Bock's avatar
Oliver Bock committed
124
125
}

126
127
128
129
130
131
void PulsatingScience::on_sliderPulsarSpinAxisInclination_valueChanged(int value)
{
	ui.pulsarGlWidget->setPulsarSpinAxisInclination(value);
	ui.lcdPulsarSpinAxisInclination->display(QString::number(value));
}

132
133
134
135
136
137
void PulsatingScience::on_sliderPulsarMagneticAxisInclination_valueChanged(int value)
{
	ui.pulsarGlWidget->setPulsarMagneticAxisInclination(value);
	ui.lcdPulsarMagneticAxisInclination->display(QString::number(value));
}

Oliver Bock's avatar
Oliver Bock committed
138
void PulsatingScience::on_sliderPulsarSemiMajorAxis_valueChanged(int value)
Oliver Bock's avatar
Oliver Bock committed
139
{
Oliver Bock's avatar
Oliver Bock committed
140
141
	ui.pulsarGlWidget->setPulsarSemiMajorAxis(value * 0.001f);
	ui.lcdPulsarSemiMajorAxis->display(QString::number(value * 0.001f, 'f', 1));
142
	ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: black");
143
}
Oliver Bock's avatar
Oliver Bock committed
144
145
146
147
148
149
150
151
152
153

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
154
155
156
157
158
159
160
161
162
163

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
164
165
166
167

void PulsatingScience::updatePulsarSemiMajorAxisValue(double value)
{
	ui.sliderPulsarSemiMajorAxis->setValue(value * 1000.0);
168
169
170
171
172

	if(value < 1.0 || value > 20.0) {
		ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: red");
		ui.lcdPulsarSemiMajorAxis->display(QString::number(value, 'f', 1));
	}
Oliver Bock's avatar
Oliver Bock committed
173
}