#include <HUDView.h>
Public Member Functions | |
HUDView (BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &glade) | |
Constructor. | |
virtual bool | on_expose_event (GdkEventExpose *ev) |
Runs this member function when the window is loaded or reloaded. | |
void | drawHUD () |
Draw the entire HUD of the vehicle. | |
void | drawTopPart () |
Draw the pitching line, air and ground region, wing line, degree's strips, and degree's numbers. | |
void | drawBottomPart () |
Draws the yaw bar and yaw ball in the GUI. | |
void | drawHeading () |
Draws the heading text of the vehicle. | |
Public Attributes | |
Cairo::RefPtr< Cairo::Context > | cr |
Creates an object named cr as a Cairo context. | |
double | rolldegree |
The data member that stores the value of rolling angle. | |
double | pitchangle |
The data member that stores the value of pitching angle. | |
double | yaw |
The data member that stores the value of yawing rate. | |
int | heading |
The data member that stores the value of heading. | |
Private Attributes | |
const Glib::RefPtr < Gtk::Builder > & | m_glade |
Pointer to glade file. |
HUDView Class.
This class draws the Heads Up Display (HUD) of the vehicle using Cairo drawing style with using basic principle of geometry and trigonometry.
There are 4 parameters that can be noticed changing in this HUD. They are:
The Heads Up Display of the Vehicle
1) Pitch Angle
The pitching angle can be changed by pressing either "K" or "k" to pitch up and "I" or "i" to pitch down in the Keyboard. it is shown by the horizon line (the intersection between blue region and brown region) in the center circle. The blue region represents the sky while the brown region represents the ground. If the vehicle is pitching up, the area blue region is increasing. On the other hand, if the vehicle is pitching down, the area of ground region is increasing. The angle of attack is measured by juding the location of horizon line within the strip that represents degree (-60, -30, 0, 30, 60).The exact value of angle of attack can also be seen in the terminal (it is printed).
The logic in the drawing is a simple gemotery and will be explained in member function drawTopPart().
Pitching Up (Left Picture) and Pitching Down (Right Picture).
2) Roll Angle
The rolling angle can be changed by pressing either "J" or "j" to bank left and ""L" or "l to bank right. It is shown by a grey thick horizontal line that lies along the diameter of the center circle. The rolling angle can also be seen in the terminal (it is printed).
The logic in the drawing is a simple geometry and will be explained in member function drawTopPart().
Banking Left (Left Picture) and Banking Right (Right Picture).
3) Yawing
The yawing rate of the vehicle can be changed by pressing "U" or "u" to yaw left and "O" ir "o" to yaw right. It can be observed from the blue ball that is located in the bottom. It will move between -45 degree to 45 degree. The yawing rate can also be seen in the terminal (it is printed).
The logic in the drawing is a simple geometry and trigonometry and will be shown in member function drawBottomPart().
Yawing Left (Left Picture) and Yawing Right (Right Picture).
4) Heading
The heading is the direction in which the vehicle is heading. It will be hooked directly to the vehicle. The value is in the range of 0 to 359. It will be shown by drawHeading().
The Direction that the vehicle is heading into
Definition at line 52 of file HUDView.h.
uvsim::HUDView::HUDView | ( | BaseObjectType * | cobject, | |
const Glib::RefPtr< Gtk::Builder > & | glade | |||
) |
Constructor.
cobject | : The base drawing area object. | |
glade | : The reference to Gtk::Builder associated with glade file. |
Definition at line 28 of file HUDView.cc.
void uvsim::HUDView::drawBottomPart | ( | ) |
Draws the yaw bar and yaw ball in the GUI.
1) Yaw Bar
The yaw bar consists of two curves with the center at 60 degree strip but with different radius of curvature. The two curves are then connected with close_path(). The yaw ball, which is going to be drawn in the yaw bar, will have the capabilities to move from -45 to 45 along the curve. However, when it reaches -45 and 45, the center of the ball will meet with the edge of the bar. Hence, the arc is extended to the right by amount of 135 + beta and to the left by amount of 45 - beta (see picture below).
2) Yaw Ball
The yaw ball is just a blue ball that is going to move along the yaw bar. The trajectory is determined by the yawing rate. The picture is shown below:
The Mathematics Behind Yawing in GUI.
Definition at line 220 of file HUDView.cc.
void uvsim::HUDView::drawHeading | ( | ) |
Draws the heading text of the vehicle.
It is created with Pango text layout. The heading is set so that it will be drawn from 0 to 359. It combines the use of type converter from integer to string so that the text can be redrawn.
Definition at line 253 of file HUDView.cc.
void uvsim::HUDView::drawHUD | ( | ) |
Draw the entire HUD of the vehicle.
It consists of four parts in order to improve speed:
1) The background, center circle, and the minimum and maximum yaw rates
The purpose of drawing these three elements are because they are not going to change or need to be redrawn when pitch angle, roll angle, and yaw are changed. This will help in increasing the speed of the GUI.
The background is set to be black.
The center circle's center is located in the middle of window no matter what the size of the window is. The radius is set to be the minimum between height of the window and width of the window divided by 3.
The minimum and maximum yaw rates are -45 and 45 respectively.The texts are drawn with Pango text layout.
2) drawTopPart()
3) drawBottomPart()
4) drawHeading()
Definition at line 41 of file HUDView.cc.
void uvsim::HUDView::drawTopPart | ( | ) |
Draw the pitching line, air and ground region, wing line, degree's strips, and degree's numbers.
1) Pitching line
The pitching line is basically a horizontal that moves up and down following the center circle. Its width is largest when it intersects the diameter and is smallest when it reaches the bottom or peak of the center circle. The pitching line represents the location of the horizon. The picture limit of pitching angle is -90 and 90.
At 90 degree pitching angle (angle of attack), it is in the form of dot in the peak of center circle. For pitching angle 90 to 270, the line will be drawn from top to buttom of center circle. For angle 270 to 360, the line will be drawn from bottom to the center of circle. After it reached 360, the value of pitching angle will be resetted to 0.
At -90 degree pitching angle (angle of attack), it is in the form of dot in the bottom of center circle. For pitching angle -90 to -270, the line will be drawn from buttom to top of center circle. For angle -270 to -360, the line will be drawn from peak to the center of circle. After it reached -360, the value of pitching angle will be resetted to 0.
2) Air and ground ground regions
The air and ground region is drawn as an arc that is connected by the pitching line. The buttom region is always brown (ground) and the upper region is always blue (sky). The size of the regions depend on the pitching angle of the vehicle.
The mathematics for the drawings of pitching line, air, and ground regions will be represented below in the picture below:
The Mathematics Behind Pitching in GUI.
3) Wing line
The wing line represents the state of wing whether it is rolling or not. It is drawn as thick grey line along the diameter of the center circle. It can rotate with respect to center of circle depends on how big the rolling angle is. If the vehicle is banking left, it will rotate counterclockwise but if the vehicle is banking right, it will rotate clockwise.
The mathematics for drawing will be represented below:
The Mathematics Behind Rolling/Banking in GUI.
4) Degree's strips
The strip is drawn in the increment of 30 degrees, starting from -60 to 60. The strip at 0 degree is the longest. The strips are located so that it follows the size of the windows.
5) Degree's numbers
The degree's numbers are drawn alongside the degree's strips. The number is placed so that it is just a couple points away from the location of the degree's strips.
Definition at line 89 of file HUDView.cc.
bool uvsim::HUDView::on_expose_event | ( | GdkEventExpose * | ev | ) | [virtual] |
Runs this member function when the window is loaded or reloaded.
This member function will run drawHUD() to draw the complete HUD.
ev | : The pointer to the event that is occuring. |
Definition at line 36 of file HUDView.cc.
Cairo::RefPtr<Cairo::Context> uvsim::HUDView::cr |
const Glib::RefPtr<Gtk::Builder>& uvsim::HUDView::m_glade [private] |
double uvsim::HUDView::pitchangle |
double uvsim::HUDView::rolldegree |
double uvsim::HUDView::yaw |