gtkartificialhorizon.c File Reference

Gtk+ based Artificial Horizon Widget. More...

#include <ground_station/gui/gtkartificialhorizon.h>
Include dependency graph for gtkartificialhorizon.c:

Go to the source code of this file.

Classes

struct  _GtkArtificialHorizonPrivate

Defines

#define GTK_ARTIFICIAL_HORIZON_GET_PRIVATE(obj)   (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_ARTIFICIAL_HORIZON_TYPE, GtkArtificialHorizonPrivate))
 Special Gtk API define. Add a macro for easy access to the private
data struct.

Typedefs

typedef struct
_GtkArtificialHorizonPrivate 
GtkArtificialHorizonPrivate
 Special Gtk API strucure. Allow to add a private data
for the widget. Defined in the C file in order to be private.

Enumerations

enum  _GTK_ARTIFICIAL_HORIZON_PROPERTY_ID {
  PROP_0, PROP_GRAYSCALE_COLOR, PROP_UNIT_IS_FEET, PROP_UNIT_STEP_VALUE,
  PROP_RADIAL_COLOR
}
 

Special Gtk API enum. Allow to identify widget's properties.

More...

Functions

 G_DEFINE_TYPE (GtkArtificialHorizon, gtk_artificial_horizon, GTK_TYPE_DRAWING_AREA)
 Special Gtk API function. Define a new object type named GtkArtificialHorizon
and all preface of the widget's functions calls with gtk_artificial_horizon.
We are inheriting the type of GtkDrawingArea.

static gboolean gtk_artificial_horizon_button_press_event (GtkWidget *widget, GdkEventButton *ev)
 Special Gtk API function. Override the _button_press_event
handler. Perform mouse button press events.
static void gtk_artificial_horizon_class_init (GtkArtificialHorizonClass *klass)
 Special Gtk API function. Function called when the class is
initialised. Allow to set certain class wide functions and
properties
. Allow to override some parent’s expose handler like :

  • set_property handler
  • destroy handler
  • configure_event handler
  • motion_notify_event handler (not use in this widget)
  • button_press_event handler (not use in this widget).

static gboolean gtk_artificial_horizon_configure_event (GtkWidget *widget, GdkEventConfigure *event)
 Special Gtk API function. Override the _configure_event handler
in order to resize the widget when the main window is resized.
static void gtk_artificial_horizon_destroy (GtkObject *object)
 Special Gtk API function. Override the _destroy handler.
Allow the destruction of all widget's pointer.
static void gtk_artificial_horizon_draw_base (GtkWidget *alt, cairo_t *cr)
static void gtk_artificial_horizon_draw_dynamic (GtkWidget *alt, cairo_t *cr)
 Special Gtk API function. This function use the cairo context
created before in order to draw scalable graphics.
static void gtk_artificial_horizon_draw_external_arc (GtkWidget *alt, cairo_t *cr)
 Private widget's function that draw the widget's external arc using cairo.
static void gtk_artificial_horizon_draw_grayscale_pattern (GtkWidget *arh, cairo_t *cr)
 Special Gtk API function. This function use the cairo context
created before in order to draw scalable graphics.
static void gtk_artificial_horizon_draw_internal_sphere (GtkWidget *alt, cairo_t *cr)
 Private widget's function that draw the widget's internal sphere using cairo.
static void gtk_artificial_horizon_draw_screws (GtkWidget *alt, cairo_t *cr)
 Private widget's function that draw the widget's screws using cairo.
static void gtk_artificial_horizon_draw_static (GtkWidget *alt, cairo_t *cr)
 Special Gtk API function. This function use the cairo context
created before in order to draw scalable graphics.
static void gtk_artificial_horizon_draw_upper_base (GtkWidget *alt, cairo_t *cr)
 Special Gtk API function. This function use the cairo context
created before in order to draw scalable graphics.
static gboolean gtk_artificial_horizon_expose (GtkWidget *graph, GdkEventExpose *event)
 Special Gtk API function. Override of the expose handler.
An “expose-event” signal is emitted when the widget need to be drawn.
A Cairo context is created for the parent's GdkWindow.
static void gtk_artificial_horizon_init (GtkArtificialHorizon *arh)
 Special Gtk API function. Function called when the creating a
new GtkArtificialHorizon. Allow to initialize some private variables of
widget.
GtkWidget * gtk_artificial_horizon_new (void)
 Special Gtk API function. This function is simply a wrapper
for convienience.
void gtk_artificial_horizon_redraw (GtkArtificialHorizon *arh)
 Special Gtk API function. Redraw the widget when called.
static void gtk_artificial_horizon_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 Special Gtk API function. Override the _set_property handler
in order to set the object parameters.
void gtk_artificial_horizon_set_value (GtkArtificialHorizon *arh, gdouble angle, gdouble y)

Variables

static gboolean gtk_artificial_horizon_debug = FALSE
static gboolean gtk_artificial_horizon_lock_update = FALSE
enum
_GTK_ARTIFICIAL_HORIZON_PROPERTY_ID 
GTK_ARTIFICIAL_HORIZON_PROPERTY_ID

Detailed Description

Gtk+ based Artificial Horizon Widget.

Author:
Gautier Dumonteil <gautier.dumonteil@gmail.com>
Version:
0.2
Date:
02/09/2010

Gtk Artificial Horizon Widget
Copyright (C) 2010, CCNY Robotics Lab
http://robotics.ccny.cuny.edu

This widget provide an easy to read artificial horizon instrument.
The design is volontary based on a real artificial horizon flight instrument
in order to be familiar to aircraft and helicopter pilots.

Pictures:

ground_station?action=AttachFile&do=get&target=gtkartificialhorizon.png
ground_station?action=AttachFile&do=get&target=gtkartificialhorizon_g.png

Example:
Add Artificial Horizon widget to an gtkvbox and set some params

 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 vbox = gtk_vbox_new(TRUE, 1);
 gtk_container_add(GTK_CONTAINER (window), vbox);
 
 art_hor = gtk_artificial_horizon_new(); 
 g_object_set(GTK_ARTIFICIAL_HORIZON (art_hor),
                "grayscale-color", false,
                "radial-color", true, NULL);
 
 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(art_hor), TRUE, TRUE, 0);
 gtk_widget_show_all(window);

The following code show how to change widget's values and redraw it:
Note that here tc's type is "GtkWidget *".

 if (IS_GTK_ARTIFICIAL_HORIZON (art_hor))
 {
        gtk_artificial_horizon_set_value (GTK_ARTIFICIAL_HORIZON (art_hor), rotation_angle,trans_y);
        gtk_artificial_horizon_redraw(GTK_ARTIFICIAL_HORIZON(art_hor));
 }              

Widget Parameters:

Widget values:

Definition in file gtkartificialhorizon.c.


Define Documentation

#define GTK_ARTIFICIAL_HORIZON_GET_PRIVATE ( obj   )     (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_ARTIFICIAL_HORIZON_TYPE, GtkArtificialHorizonPrivate))

Special Gtk API define. Add a macro for easy access to the private
data struct.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 155 of file gtkartificialhorizon.c.


Typedef Documentation

Special Gtk API strucure. Allow to add a private data
for the widget. Defined in the C file in order to be private.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en


Enumeration Type Documentation

Special Gtk API enum. Allow to identify widget's properties.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Enumerator:
PROP_0 
PROP_GRAYSCALE_COLOR 
PROP_UNIT_IS_FEET 
PROP_UNIT_STEP_VALUE 
PROP_RADIAL_COLOR 

Definition at line 127 of file gtkartificialhorizon.c.


Function Documentation

G_DEFINE_TYPE ( GtkArtificialHorizon  ,
gtk_artificial_horizon  ,
GTK_TYPE_DRAWING_AREA   
)

Special Gtk API function. Define a new object type named GtkArtificialHorizon
and all preface of the widget's functions calls with gtk_artificial_horizon.
We are inheriting the type of GtkDrawingArea.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

static gboolean gtk_artificial_horizon_button_press_event ( GtkWidget *  widget,
GdkEventButton *  ev 
) [static]

Special Gtk API function. Override the _button_press_event
handler. Perform mouse button press events.

Here, the mouse events are not used for the widget (maybe
in future released) but to allow the user to enable/disable
the debug messages.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 1471 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_class_init ( GtkArtificialHorizonClass klass  )  [static]

Special Gtk API function. Function called when the class is
initialised. Allow to set certain class wide functions and
properties
. Allow to override some parent’s expose handler like :

  • set_property handler
  • destroy handler
  • configure_event handler
  • motion_notify_event handler (not use in this widget)
  • button_press_event handler (not use in this widget).

Also register the private struct GtkArtificialHorizonPrivate with
the class and install widget properties.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 199 of file gtkartificialhorizon.c.

static gboolean gtk_artificial_horizon_configure_event ( GtkWidget *  widget,
GdkEventConfigure *  event 
) [static]

Special Gtk API function. Override the _configure_event handler
in order to resize the widget when the main window is resized.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 293 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_destroy ( GtkObject *  object  )  [static]

Special Gtk API function. Override the _destroy handler.
Allow the destruction of all widget's pointer.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 1510 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_draw_base ( GtkWidget *  alt,
cairo_t *  cr 
) [static]

Definition at line 569 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_draw_dynamic ( GtkWidget *  arh,
cairo_t *  cr 
) [static]

Special Gtk API function. This function use the cairo context
created before in order to draw scalable graphics.

See GObject,Cairo and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 501 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_draw_external_arc ( GtkWidget *  alt,
cairo_t *  cr 
) [static]

Private widget's function that draw the widget's external arc using cairo.

Definition at line 1304 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_draw_grayscale_pattern ( GtkWidget *  arh,
cairo_t *  cr 
) [static]

Special Gtk API function. This function use the cairo context
created before in order to draw scalable graphics.

See GObject,Cairo and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 668 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_draw_internal_sphere ( GtkWidget *  alt,
cairo_t *  cr 
) [static]

Private widget's function that draw the widget's internal sphere using cairo.

Definition at line 1149 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_draw_screws ( GtkWidget *  alt,
cairo_t *  cr 
) [static]

Private widget's function that draw the widget's screws using cairo.

Definition at line 875 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_draw_static ( GtkWidget *  arh,
cairo_t *  cr 
) [static]

Special Gtk API function. This function use the cairo context
created before in order to draw scalable graphics.

See GObject,Cairo and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 481 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_draw_upper_base ( GtkWidget *  arh,
cairo_t *  cr 
) [static]

Special Gtk API function. This function use the cairo context
created before in order to draw scalable graphics.

See GObject,Cairo and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 714 of file gtkartificialhorizon.c.

static gboolean gtk_artificial_horizon_expose ( GtkWidget *  arh,
GdkEventExpose *  event 
) [static]

Special Gtk API function. Override of the expose handler.
An “expose-event” signal is emitted when the widget need to be drawn.
A Cairo context is created for the parent's GdkWindow.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 322 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_init ( GtkArtificialHorizon arh  )  [static]

Special Gtk API function. Function called when the creating a
new GtkArtificialHorizon. Allow to initialize some private variables of
widget.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 246 of file gtkartificialhorizon.c.

GtkWidget* gtk_artificial_horizon_new ( void   ) 

Special Gtk API function. This function is simply a wrapper
for convienience.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 464 of file gtkartificialhorizon.c.

void gtk_artificial_horizon_redraw ( GtkArtificialHorizon arh  ) 

Special Gtk API function. Redraw the widget when called.

This function will redraw the widget canvas. In order to reexpose the canvas
(and cause it to redraw) of our parent class(GtkDrawingArea), it is needed to
use gdk_window_invalidate_rect(). The function gdk_window_invalidate_region()
need to be called as well. And finaly, in order to make all events happen, it
is needed to call gdk_window_process_all_updates().

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 394 of file gtkartificialhorizon.c.

static void gtk_artificial_horizon_set_property ( GObject *  object,
guint  prop_id,
const GValue *  value,
GParamSpec *  pspec 
) [static]

Special Gtk API function. Override the _set_property handler
in order to set the object parameters.

See GObject and GTK+ references for more informations: http://library.gnome.org/devel/references.html.en

Definition at line 1555 of file gtkartificialhorizon.c.

void gtk_artificial_horizon_set_value ( GtkArtificialHorizon arh,
gdouble  angle,
gdouble  y 
)

Definition at line 429 of file gtkartificialhorizon.c.


Variable Documentation

gboolean gtk_artificial_horizon_debug = FALSE [static]

Definition at line 178 of file gtkartificialhorizon.c.

gboolean gtk_artificial_horizon_lock_update = FALSE [static]

Definition at line 179 of file gtkartificialhorizon.c.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines


ground_station
Author(s): Gautier Dumonteil
autogenerated on Wed May 23 04:48:38 2012