#include <MapArea.h>
Public Member Functions | |
MapArea (BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &glade) | |
Constructor. | |
bool | on_expose_event (GdkEventExpose *event) |
Calls drawInitial() everytime the window is loaded and reloaded. | |
void | drawInitial () |
Loads the map and waypoints (if any). | |
void | draw (std::vector< GeoCoord > waypoint) |
Draws all the waypoints. | |
void | drawRedCircle (GeoCoord waypoint) |
Draws a red circle around a single waypoint. | |
void | drawRedCircle (std::vector< GeoCoord > waypoint) |
Draws red circles around all the waypoints. | |
Public Attributes | |
Glib::RefPtr< Gdk::Pixbuf > | image |
Creating object named image from Gdk::Pixbuf. | |
Cairo::RefPtr< Cairo::Context > | cr |
Creating object named cr from Cairo Context. | |
double | m_zoom |
Contains the zoom level of the map. | |
double | m_panUD |
Contains how far the pan is shifted up and down. | |
double | m_panLR |
Contains how far the pan is shifted left and right. | |
double | relative_originX |
Contains the horizontal location of the origin (top-left corner). | |
double | relative_originY |
Contains the vertical location of the origin (top-left corner). | |
double | relative_endX |
Contains the horziontal location of the end (bottom-right corner). | |
double | relative_endY |
Contains the vertical location of the end (bottom-right corner). | |
double | scaleX |
Contains the scale between the width of image with the latitude of map. | |
double | scaleY |
Contains the scale between the height of image with the longitude of map. | |
std::vector< GeoCoord > | waypoint |
Creating object named waypoint from vector of GeoCoord. | |
FlightPlan * | flightPlan |
Pointer to object member named flightPlan. | |
Private Member Functions | |
virtual bool | on_motion_notify_event (GdkEventMotion *event) |
Prints the coordinate of map that the mouse pointer is currently in. | |
virtual bool | on_button_press_event (GdkEventButton *event) |
Saves the coordinate of the points that is clicked in the map to the flightPlan. | |
Private Attributes | |
const Glib::RefPtr < Gtk::Builder > & | m_glade |
Reference to Gtk::Builder associated with glade file. | |
double | relative_x |
Contains the horizontal location of the image, consistent with panning and zooming, with respect to the origin (left-top corner). | |
double | relative_y |
Contains the vertical location of the image, consistent with panning and zomming, with respect to the origin (left-top corner). | |
MainWindow * | m_pMainWindow |
Pointer to MainWindow object named m_pMainWindow. |
MapArea Class.
Example of a Map.
This class loads the map to the drawing area including its ability to do zooming and panning. In this case, the user could also move the waypoints around the map and the terminal would show the coordinate, consistent with current zoom and pan level (see image below). In addition, to load the point in the map from flightPlan to the window, the coordinate has to be transformed back to the coordinate of the window to make it consistent (see image below).
The Mathematics of Coordinate Transformation.
This class also asks the user to input the coordinate of top-left and bottom-right corners of the map. From these information, the map could be rotated such that the north is pointing up. The constraints in this code is that the north must be in increment of 90 degrees from the real north. This class is unable to rotate with custom angle.
This class also enables user to input waypoints by clicking a point in the map and modify them. The possible modifications are adding, deleting, and moving waypoints. These modifications could be done by series of keyboard pressing and mouse clicking. To achieve this, "A" or "a" is assigned to add waypoint, "M" or "m" is assigned to move waypoint, and "D" or "d" is assigned to delete waypoint. The procedure is followed:
1) Adding Waypoint
Press "A" or "a" and all the waypoints will be highlighted by a red circle around them.
Click the previous waypoint to where the new waypoint is going to be added.
Click a point in the map and the new waypoint will be added after the previously chosen waypoint.
Adding Waypoint.
2) Moving Waypoint
Press "M" or "m" and all the waypoints will be highlighted by a red circle around them.
Click the waypoint that wants to be moved.
Click a point in the map and the waypoint will move to the new location that was clicked.
Moving Waypoint.
3) Deleting Waypoint
Press "D" or "d" and all the waypoints will be highlighted by a red circle around them.
Click the waypoint that wants to be deleted and it will be deleted.
Deleting Waypoint.
Definition at line 56 of file MapArea.h.
uvsim::MapArea::MapArea | ( | BaseObjectType * | cobject, | |
const Glib::RefPtr< Gtk::Builder > & | glade | |||
) |
Constructor.
cobject | : The base DrawingArea object. | |
glade | : The reference to the Gtk::Builder associated with the glade file. |
Definition at line 29 of file MapArea.cc.
void uvsim::MapArea::draw | ( | std::vector< GeoCoord > | waypoint | ) |
Draws all the waypoints.
waypoint | : The GeoCoord type vector that contains the Latitude, Longitude, and Altitude of a location. |
Definition at line 147 of file MapArea.cc.
void uvsim::MapArea::drawInitial | ( | ) |
Loads the map and waypoints (if any).
Definition at line 126 of file MapArea.cc.
void uvsim::MapArea::drawRedCircle | ( | std::vector< GeoCoord > | waypoint | ) |
Draws red circles around all the waypoints.
waypoint | : vector of object of class type GeoCoord. |
Definition at line 176 of file MapArea.cc.
void uvsim::MapArea::drawRedCircle | ( | GeoCoord | waypoint | ) |
Draws a red circle around a single waypoint.
waypoint | : object of class type GeoCoord. |
Definition at line 194 of file MapArea.cc.
bool uvsim::MapArea::on_button_press_event | ( | GdkEventButton * | event | ) | [private, virtual] |
Saves the coordinate of the points that is clicked in the map to the flightPlan.
event | : The pointer to the event that is occuring. |
Definition at line 112 of file MapArea.cc.
bool uvsim::MapArea::on_expose_event | ( | GdkEventExpose * | event | ) |
Calls drawInitial() everytime the window is loaded and reloaded.
event | : The pointer to the event that is occurring. |
Definition at line 92 of file MapArea.cc.
bool uvsim::MapArea::on_motion_notify_event | ( | GdkEventMotion * | event | ) | [private, virtual] |
Prints the coordinate of map that the mouse pointer is currently in.
event | : The pointer to the event that is occuring. |
Definition at line 97 of file MapArea.cc.
Cairo::RefPtr<Cairo::Context> uvsim::MapArea::cr |
Glib::RefPtr<Gdk::Pixbuf> uvsim::MapArea::image |
const Glib::RefPtr<Gtk::Builder>& uvsim::MapArea::m_glade [private] |
double uvsim::MapArea::m_panLR |
double uvsim::MapArea::m_panUD |
MainWindow* uvsim::MapArea::m_pMainWindow [private] |
Pointer to MainWindow object named m_pMainWindow.
double uvsim::MapArea::m_zoom |
double uvsim::MapArea::relative_x [private] |
double uvsim::MapArea::relative_y [private] |
double uvsim::MapArea::scaleX |
double uvsim::MapArea::scaleY |
std::vector<GeoCoord> uvsim::MapArea::waypoint |