GtkHst1D

GtkHst1D — A viewer for HstFunction objects

Synopsis


#include <gtk-hst/gtkhistogram.h>


enum        GtkHstColors;
#define     GTK_TYPE_HST_COLORS
enum        GtkHstAxisPos;
#define     GTK_TYPE_HST_AXIS_POS
enum        GtkHstAttr;
#define     GTK_TYPE_HST_ATTR
enum        GtkHstAxisType;
#define     GTK_TYPE_HST_AXIS_TYPE
            Canvas;
            GtkHst1DEvent;
            GtkHst1D;
            GtkHst1DClass;
GtkWidget*  gtk_hst1d_new                   (HstFunction *ff);
void        gtk_hst1d_add_curve             (GtkHst1D *h,
                                             HstFunction *f);
void        gtk_hst1d_remove_curves         (GtkHst1D *h);
void        gtk_hst1d_monitor_start         (GtkHst1D *h,
                                             int tim);
void        gtk_hst1d_monitor_stop          (GtkHst1D *h);
void        gtk_hst1d_draw_x_axis           (GtkHst1D *h,
                                             GtkHstAxisPos val);
void        gtk_hst1d_draw_y_axis           (GtkHst1D *h,
                                             GtkHstAxisPos val);
gchar*      gtk_hst1d_get_xtitle            (GtkHst1D *hst);
void        gtk_hst1d_set_xtitle            (GtkHst1D *hst,
                                             const char *tit);
gchar*      gtk_hst1d_get_ytitle            (GtkHst1D *hst);
void        gtk_hst1d_set_ytitle            (GtkHst1D *hst,
                                             const char *tit);
void        gtk_hst1d_filled                (GtkHst1D *h,
                                             gboolean z);
gboolean    gtk_hst1d_is_filled             (GtkHst1D *h);
void        gtk_hst1d_logx                  (GtkHst1D *h,
                                             gboolean z);
gboolean    gtk_hst1d_is_logx               (GtkHst1D *h);
void        gtk_hst1d_logy                  (GtkHst1D *h,
                                             gboolean z);
gboolean    gtk_hst1d_is_logy               (GtkHst1D *h);
void        gtk_hst1d_show_stats            (GtkHst1D *h,
                                             gboolean z);
gboolean    gtk_hst1d_stats                 (GtkHst1D *h);
void        gtk_hst1d_set_curve_colors      (GtkHst1D *h,
                                             ...);
void        gtk_hst1d_add_curve_color       (GtkHst1D *h,
                                             gchar *color_name);
int         gtk_hst1d_get_n_func            (GtkHst1D *h);
HstFunction* gtk_hst1d_get_func             (GtkHst1D *h,
                                             int n);
void        gtk_hst1d_set_func              (GtkHst1D *h,
                                             HstFunction *f);
void        gtk_hst1d_sync_range            (GtkHst1D *h,
                                             gboolean z);
void        gtk_hst1d_set_colors            (GtkHst1D *h,
                                             ...);


Object Hierarchy


  GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkHst1D
                           +----GtkHst2D

Implemented Interfaces

GtkHst1D implements AtkImplementorIface.

Properties


  "filled"               gboolean              : Read / Write
  "func"                 gpointer              : Read / Write
  "hxmax"                gdouble               : Read / Write
  "hxmin"                gdouble               : Read / Write
  "hymax"                gdouble               : Read / Write
  "hymin"                gdouble               : Read / Write
  "logx"                 gboolean              : Read / Write
  "logy"                 gboolean              : Read / Write
  "pixmap"               GdkPixbuf             : Read
  "stats"                gboolean              : Read / Write
  "vmax"                 gdouble               : Read / Write
  "vmin"                 gdouble               : Read / Write
  "xtitle"               gchararray            : Read / Write
  "ytitle"               gchararray            : Read / Write

Description

This widget visualizes any object deriving from HstFunction. It can display simultaneously varous HstFunction objects. One just have to add them to the list by calling gtk_hst1d_add_curve. They can also be retreived later by means of gtk_hst1d_get_func

In the case of 1D histograms one can magnify one of the axis, or both. You can choose a given range in any of the axis by selecting it with the left button of the mouse while pressing:

  • CTRL for the X axis or

  • SHIFT for the Y axis

The original range is restored pressing the mouse middle button.

Click the mouse right button to explore the popup menu and change some of the histogram attributes.

Details

enum GtkHstColors

typedef enum {
    HST_COLOR_FOREGROUND,
    HST_COLOR_BACKGROUND,
    HST_COLOR_AXIS,
    HST_NCOLORS
}  GtkHstColors;

This emumeration is used to specified the colors for the canvas were the HstFunction object will be drawn.


GTK_TYPE_HST_COLORS

#define GTK_TYPE_HST_COLORS (gtk_hst_colors_get_type())


enum GtkHstAxisPos

typedef enum {
   HST_AXIS_NONE   = 0,
   HST_AXIS_LEFT   = 1,
   HST_AXIS_MIDDLE = 2,
   HST_AXIS_RIGHT  = 4,
   HST_AXIS_X_MASK = 0x0f,
   HST_AXIS_Y_MASK = 0xf0,
   HST_AXIS_Z_MASK = 0xf00
} GtkHstAxisPos;


GTK_TYPE_HST_AXIS_POS

#define GTK_TYPE_HST_AXIS_POS (gtk_hst_axis_pos_get_type())


enum GtkHstAttr

typedef enum {
   HST_FILLED = 1,
   HST_LOGX   = 2,
   HST_LOGY   = 4,
   HST_STATS  = 8
} GtkHstAttr;


GTK_TYPE_HST_ATTR

#define GTK_TYPE_HST_ATTR ( gtk_hst_attr_get_type() )


enum GtkHstAxisType

typedef enum {
    HST_X_AXIS,
    HST_Y_AXIS,
    HST_Z_AXIS
} GtkHstAxisType;


GTK_TYPE_HST_AXIS_TYPE

#define GTK_TYPE_HST_AXIS_TYPE ( gtk_hst_axis_type() )


Canvas

typedef struct {
    int ch,cw,width,height;
    int sch,scw;
    int wx,wy,wz;
    int ox,oy,oz;
    int px0,px1;
    int py0,py1;
    int pz0,pz1;
    GdkRectangle cscale;

    gboolean   fixed;
    double xmin,xmax;
    double ymin,ymax;
    double zmin,zmax;
    double xstp,ystp,zstp;
    double sx, sy,sz,  ex, ey, ez;
    gboolean   logx,logy;
    double lxmin,lymin;
    GList  *curve_colors;
    PangoLayout *legend;
    int     leg_x,leg_y;
} Canvas;


GtkHst1DEvent

typedef struct _GtkHst1DEvent GtkHst1DEvent;


GtkHst1D

typedef struct _GtkHst1D GtkHst1D;


GtkHst1DClass

typedef struct {
    GtkWidgetClass parent_class;
      
    void (*draw_pixmap) (GtkHst1D *h);
    void (*draw_frame) (GtkHst1D *h);
    void (*draw_stats) (GtkHst1D *h);
    void (*draw_axis) (GtkHst1D *h);
    void (* mouse ) (GtkHst1D *h);
    void (*xtra_menu)(GtkHst1D *h, GtkWidget *w);
} GtkHst1DClass;

An object deriving from GtkHst1D has defined a number of methods which are call in the process of drawing the object.

GtkWidgetClass parent_class;
draw_pixmap () draws the curve or curves.
draw_frame () computes the range of the axis
draw_stats () draws the statistics in the case of plotting a histogram
draw_axis () draws the axis
mouse ()
xtra_menu () if provided, it serves as a hook to add items in the popup menu.

gtk_hst1d_new ()

GtkWidget*  gtk_hst1d_new                   (HstFunction *ff);

ff : A HstFunction object to be drawn. This is the object that will define the range of the axis. Return value: a GtkWidget
Returns :

gtk_hst1d_add_curve ()

void        gtk_hst1d_add_curve             (GtkHst1D *h,
                                             HstFunction *f);

It adds a new function to the list. However, only the points in the range of the main function will be show.

h : A GtkHst1D object
f : A HstFunction object that will added to the list of functions to be drawn.

gtk_hst1d_remove_curves ()

void        gtk_hst1d_remove_curves         (GtkHst1D *h);

Clears the list of functions to draw

h : A GtkHst1D object

gtk_hst1d_monitor_start ()

void        gtk_hst1d_monitor_start         (GtkHst1D *h,
                                             int tim);

It sets up a timeout callback that will re-draw the functions in the list every tim milliseconds.

h : A GtkHst1D object
tim : the time interval

gtk_hst1d_monitor_stop ()

void        gtk_hst1d_monitor_stop          (GtkHst1D *h);

Stops the automatic re-drawing of the curves

h : A GtkHst1D object

gtk_hst1d_draw_x_axis ()

void        gtk_hst1d_draw_x_axis           (GtkHst1D *h,
                                             GtkHstAxisPos val);

Specifies where to draw the X axis

h : A GtkHst1D object
val :

gtk_hst1d_draw_y_axis ()

void        gtk_hst1d_draw_y_axis           (GtkHst1D *h,
                                             GtkHstAxisPos val);

Specifies where to draw the Y axis

h : A GtkHst1D object
val :

gtk_hst1d_get_xtitle ()

gchar*      gtk_hst1d_get_xtitle            (GtkHst1D *hst);

hst : A GtkHst1D object
Returns : the title or label of the X axis

gtk_hst1d_set_xtitle ()

void        gtk_hst1d_set_xtitle            (GtkHst1D *hst,
                                             const char *tit);

Sets the label of the X axis

hst : A GtkHst1D object
tit : the new tittle

gtk_hst1d_get_ytitle ()

gchar*      gtk_hst1d_get_ytitle            (GtkHst1D *hst);

hst : A GtkHst1D object
Returns : the title or label of the Y axis

gtk_hst1d_set_ytitle ()

void        gtk_hst1d_set_ytitle            (GtkHst1D *hst,
                                             const char *tit);

Sets the label of the Y axis

hst : A GtkHst1D object
tit : the new tittle

gtk_hst1d_filled ()

void        gtk_hst1d_filled                (GtkHst1D *h,
                                             gboolean z);

If f is set, theh function will be drawn as a filled curve, otherwise only a line will be drawn.

h : A GtkHst1D object
z : boolean flag

gtk_hst1d_is_filled ()

gboolean    gtk_hst1d_is_filled             (GtkHst1D *h);

h : A GtkHst1D object
Returns : the value of the filled flag

gtk_hst1d_logx ()

void        gtk_hst1d_logx                  (GtkHst1D *h,
                                             gboolean z);

If f is set, theh function will be drawn with logarithmic scale

h : A GtkHst1D object
z : boolean flag

gtk_hst1d_is_logx ()

gboolean    gtk_hst1d_is_logx               (GtkHst1D *h);

h : A GtkHst1D object
Returns : if true, logarithmic scale is being used for the X axis

gtk_hst1d_logy ()

void        gtk_hst1d_logy                  (GtkHst1D *h,
                                             gboolean z);

If f is set, the Y axis will use logarithmic scale

h : A GtkHst1D object
z : boolean flag

gtk_hst1d_is_logy ()

gboolean    gtk_hst1d_is_logy               (GtkHst1D *h);

h : A GtkHst1D object
Returns : if true, logarithmic scale is being used for the Y axis

gtk_hst1d_show_stats ()

void        gtk_hst1d_show_stats            (GtkHst1D *h,
                                             gboolean z);

If f is set we draw a summary if the statistics, like numbe of entries, mean value, etc.

h : A GtkHst1D object
z : boolean flag

gtk_hst1d_stats ()

gboolean    gtk_hst1d_stats                 (GtkHst1D *h);

h : A GtkHst1D object
Returns : if true, we are drawing the stats.

gtk_hst1d_set_curve_colors ()

void        gtk_hst1d_set_curve_colors      (GtkHst1D *h,
                                             ...);

h : A GtkHst1D object
... :

gtk_hst1d_add_curve_color ()

void        gtk_hst1d_add_curve_color       (GtkHst1D *h,
                                             gchar *color_name);

Appends a color with this name to the list of colors for the variuos functions to draw. The color name should be recognized by gdk_color_parse

h : a GtkHst1D object
color_name : an existing color name

gtk_hst1d_get_n_func ()

int         gtk_hst1d_get_n_func            (GtkHst1D *h);

h : A GtkHst1D object
Returns : the number of functions to be drawn.

gtk_hst1d_get_func ()

HstFunction* gtk_hst1d_get_func             (GtkHst1D *h,
                                             int n);

h : A GtkHst1D object
n : the index of the function to be retrieved
Returns : The HstFunction object that is stored at position n in the list of function to be drawn.

gtk_hst1d_set_func ()

void        gtk_hst1d_set_func              (GtkHst1D *h,
                                             HstFunction *f);

Sets f as the main function to draw. THis will be the function defining the range of the axis.

h : A GtkHst1D object
f : A HstFunction object

gtk_hst1d_sync_range ()

void        gtk_hst1d_sync_range            (GtkHst1D *h,
                                             gboolean z);

If z is true, the widget will recompute the range of the axis and will redraw the curves whenever the the range of the main HstFunction changes.

h : A GtkHst1D object
z : a boolean flag

gtk_hst1d_set_colors ()

void        gtk_hst1d_set_colors            (GtkHst1D *h,
                                             ...);

Sets the colors for the axis, background an foreground of the canvas. The colors are given with names that gdk_parse_color understands preceded by the item that will receive the color.

h : a GtkHst1D object
... : NULL terminated list of color names.

Property Details

The "filled" property

  "filled"               gboolean              : Read / Write

If set draws a filled histogram.

Default value: FALSE


The "func" property

  "func"                 gpointer              : Read / Write

The pointer of the main function to be displayed in the widget. This is the function that will fix the range of the axis.


The "hxmax" property

  "hxmax"                gdouble               : Read / Write

Maximum value of X in the histogram range.

Default value: 1


The "hxmin" property

  "hxmin"                gdouble               : Read / Write

Minimum value of X in the histogram range.

Default value: 0


The "hymax" property

  "hymax"                gdouble               : Read / Write

Maximum value of Y in the histogram range.

Default value: 1


The "hymin" property

  "hymin"                gdouble               : Read / Write

Minimum value of Y in the histogram range.

Default value: 0


The "logx" property

  "logx"                 gboolean              : Read / Write

If set shows X axis in log scale.

Default value: FALSE


The "logy" property

  "logy"                 gboolean              : Read / Write

If set shows Y axis in log scale.

Default value: FALSE


The "pixmap" property

  "pixmap"               GdkPixbuf             : Read

Pixbuffer.


The "stats" property

  "stats"                gboolean              : Read / Write

If set shows the statistics.

Default value: FALSE


The "vmax" property

  "vmax"                 gdouble               : Read / Write

Maximum value to be shown.

Default value: 1


The "vmin" property

  "vmin"                 gdouble               : Read / Write

Minimum value to be shown.

Default value: 0


The "xtitle" property

  "xtitle"               gchararray            : Read / Write

Label for X axis.

Default value: "X"


The "ytitle" property

  "ytitle"               gchararray            : Read / Write

Label for Y axis.

Default value: "Y"