Commit 6b75f14b authored by Oliver Bock's avatar Oliver Bock

Added beam angle setting

* Interactive control via GUI (initial setting 20 degrees)
* Also: variable for beam length/height
* Also: variable for beam rim size (thickness)
parent bc7e81e6
......@@ -56,8 +56,8 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
// initialize quadric pointers
m_quadricPulsar = NULL;
m_quadricPulsarSpinAxis = NULL;
m_quadricPulsarSpinAxisTop1 = NULL;
m_quadricPulsarSpinAxisTop2 = NULL;
m_quadricPulsarSpinAxisTop1 = NULL;
m_quadricPulsarSpinAxisTop2 = NULL;
m_quadricPulsarMagneticAxis = NULL;
m_quadricPulsarConeRim1 = NULL;
m_quadricPulsarConeRim2 = NULL;
......@@ -72,10 +72,13 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_pulsarRotationAngle = 0.0;
m_pulsarSpinAxisInclination = 0.0;
m_pulsarMagneticAxisInclination = 5.0;
m_pulsarBeamInnerRadius = 0.4f;
m_pulsarBeamOuterRadius = 0.5f;
// initial spin frequency of 0.5 Hz
m_pulsarMagneticAxisInclination = 5.0;
m_pulsarBeamLength = 3.0f;
m_pulsarBeamRimSize = 0.1f;
setPulsarBeamAngle(20);
// initial spin frequency of 0.5 Hz
m_pulsarRotationDelta = (360.0 * 0.5) / m_framesPerSecond;
// initial view features
......@@ -83,9 +86,9 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_cameraInteraction = false;
// initial view settings
m_mouseAngleH = 0.0;
m_mouseAngleV = 0.0;
m_cameraZoom = 30.0;
m_mouseAngleH = 0.0;
m_mouseAngleV = 0.0;
m_cameraZoom = 30.0;
m_cameraZoomLBound = 10.0;
m_cameraZoomUBound = 4500.0;
m_mouseLastX = 0;
......@@ -335,7 +338,7 @@ void PulsarAnimationWidget::paintGL()
// Pinnacle of cone is shared vertex for fan, moved up z-axis
// to produce a cone instead of a circle
glColor3f(1.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 3.0f);
glVertex3f(0.0f, 0.0f, m_pulsarBeamLength);
// Loop around in a circle and specify even points along the circle
// as the vertices of the triangle fan (32 sections)
......@@ -354,7 +357,7 @@ void PulsarAnimationWidget::paintGL()
// draw first cone's inner layer (do we need/want this?)
glBegin(GL_TRIANGLE_FAN);
glColor3f(0.66f, 0.66f, 0.0f);
glVertex3f(0.0f, 0.0f, 3.0f);
glVertex3f(0.0f, 0.0f, m_pulsarBeamLength);
for(angle = 0.0f; angle < (2.0f*GL_PI); angle += (GL_PI/32.0f)) {
x = m_pulsarBeamInnerRadius * sin(angle);
y = m_pulsarBeamInnerRadius * cos(angle);
......@@ -544,15 +547,15 @@ void PulsarAnimationWidget::showEvent(QShowEvent *event)
void PulsarAnimationWidget::updateCameraPosition(const double angleH, const double angleV, const double zoom)
{
m_cameraPosX = sin(angleH * deg2rad) * cos(angleV * deg2rad) * zoom;
m_cameraPosY = sin(angleV * deg2rad) * zoom;
m_cameraPosX = sin(angleH * deg2rad) * cos(angleV * deg2rad) * zoom;
m_cameraPosY = sin(angleV * deg2rad) * zoom;
m_cameraPosZ = cos(angleH * deg2rad) * cos(angleV * deg2rad) * zoom;
updatePulseProfile();
updateGL();
// qDebug("Camera (x,y,z,+,h,v): %f, %f, %f, %f, %f, %f", m_cameraPosX, m_cameraPosY, m_cameraPosZ, zoom, angleH, angleV);
// qDebug("Camera (x,y,z,+,h,v): %f, %f, %f, %f, %f, %f", m_cameraPosX, m_cameraPosY, m_cameraPosZ, zoom, angleH, angleV);
}
void PulsarAnimationWidget::setFramePerSecond(const unsigned int fps)
......@@ -582,6 +585,15 @@ void PulsarAnimationWidget::setPulsarMagneticAxisInclination(const int degrees)
updateGL();
}
void PulsarAnimationWidget::setPulsarBeamAngle(const int degrees)
{
m_pulsarBeamOuterRadius = tan(deg2rad * degrees * 0.5f) * m_pulsarBeamLength;
m_pulsarBeamInnerRadius = m_pulsarBeamOuterRadius - m_pulsarBeamRimSize;
updatePulseProfile();
updateGL();
}
void PulsarAnimationWidget::resetParameters()
{
m_pulsarRotationAngle = 0.0;
......
......@@ -43,6 +43,7 @@ public:
void setPulsarSpinFrequency(const double frequency);
void setPulsarSpinAxisInclination(const int degrees);
void setPulsarMagneticAxisInclination(const int degrees);
void setPulsarBeamAngle(const int degrees);
public slots:
void runAnimation();
......@@ -91,8 +92,10 @@ private:
double m_pulsarSpinAxisInclination;
double m_pulsarMagneticAxisInclination;
double m_pulsarBeamInnerRadius;
double m_pulsarBeamOuterRadius;
double m_pulsarBeamLength;
double m_pulsarBeamInnerRadius;
double m_pulsarBeamOuterRadius;
double m_pulsarBeamRimSize;
bool m_showRotationAxes;
bool m_cameraInteraction;
......
......@@ -197,6 +197,12 @@ void PulsatingScience::on_sliderPulsarMagneticAxisInclination_valueChanged(int v
ui.lcdPulsarMagneticAxisInclination->display(QString::number(value));
}
void PulsatingScience::on_sliderPulsarBeamAngle_valueChanged(int value)
{
ui.pulsarGlWidget->setPulsarBeamAngle(value);
ui.lcdPulsarBeamAngle->display(QString::number(value));
}
void PulsatingScience::rotationAxesToggled() {
if(m_rotationAxesVisible) {
on_actionRotationAxes_toggled(false);
......
......@@ -50,6 +50,7 @@ public slots:
void on_sliderPulsarSpinFrequency_valueChanged(int value);
void on_sliderPulsarSpinAxisInclination_valueChanged(int value);
void on_sliderPulsarMagneticAxisInclination_valueChanged(int value);
void on_sliderPulsarBeamAngle_valueChanged(int value);
void rotationAxesToggled();
void on_actionRotationAxes_toggled(bool checked);
......
......@@ -232,6 +232,55 @@
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Beam Spread Angle</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSlider" name="sliderPulsarBeamAngle">
<property name="maximum">
<number>180</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="sliderPosition">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLCDNumber" name="lcdPulsarBeamAngle">
<property name="numDigits">
<number>6</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
<property name="value" stdset="0">
<double>20.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string>deg</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment