GiwXYPlot
GiwXYPlot - A plot widget


Synopsis
#include <giwxyplot.h>

                       GiwXYPlot;
GtkWidget*    giw_xyplot_new                      
                 (void);
void          
     giw_xyplot_set_range                               (GiwXYPlot *xyplot, gdouble xmin, gdouble xmax, gdouble ymin, gdouble ymax);    
void                giw_xyplot_set_autorange                        (GiwXYPlot *xyplot, XYPlotData *data);
void        
        giw_xyplot_get_range                               (GiwXYPlot *xyplot, gdouble *xmin, gdouble *xmax, gdouble *ymin, gdouble *ymax);
void         
       giw_xyplot_get_point                                (GiwXYPlot *xyplot, guint x, guint y, gdouble *xv, gdouble *yv);
void          
      giw_xyplot_set_ticks                                 (GiwXYPlot *xyplot, guint hmajor, guint hminor, guint vmajor, guint vminor);
void      
          giw_xyplot_get_ticks                                 (GiwXYPlot *xyplot, guint *hmajor, guint *hminor, guint *vmajor, guint *vminor);
void          
     giw_xyplot_set_legends_digits                  (GiwXYPlot *xyplot, guint digits);
guint         
     giw_xyplot_get_legends_digits                  (GiwXYPlot *xyplot);
void               giw_xyplot_set_background_color             (GiwXYPlot *xyplot, GdkColor color);
void               giw_xyplot_set_grids_attributes               (GiwXYPlot *xyplot, GiwXYPlotGrid grid, GdkColor color, gint line_width, GdkLineStyle line_style);
void               giw_xyplot_get_grids_attributes               (GiwXYPlot *xyplot, GiwXYPlotGrid grid, GdkColor *color, gint *line_width, GdkLineStyle *line_style);
void               giw_xyplot_enable_grids                           (GiwXYPlot *xyplot, GiwXYPlotGrid grid, gboolean enable);
void               giw_xyplot_add_data                                (GiwXYPlot *xyplot, XYPlotData *data);
void               giw_xyplot_remove_data                          (GiwXYPlot *xyplot, XYPlotData *data);
void
              giw_xyplot_configure_mouse_zoom          (GiwXYPlot *xyplot, gboolean enabled, guint button);
void
              giw_xyplot_configure_wheel_zoom           (GiwXYPlot *xyplot, gboolean enabled, gdouble factor);
void
              giw_xyplot_configure_mouse_displace      (GiwXYPlot *xyplot, gboolean enabled, guint button);
void
              giw_xyplot_configure_mouse_autorange  (GiwXYPlot *xyplot, gboolean enabled, guint button);


Object Hierarchy
GObject
   +----GtkObject
           +----GtkWidget
                    +----GiwXYPlot

Description

GiwXYPlot is a plotting widget, it can plot x-y data.

Details

GiwXYPlot
typedef struct GiwXYPlot _GiwXYPlot

The GiwXYPlot struct contains private data only, and should be manipulated using the functions below.

giw_xyplot_new()

GtkWidget*     giw_xyplot_new                                       (void);

Creates a new xyplot, with all default options.

Returns: a new xyplot.

giw_xyplot_set_range()

void                giw_xyplot_set_range                               (GiwXYPlot *xyplot, gdouble xmin, gdouble xmax, gdouble ymin, gdouble ymax);   

Sets the range of the two axis (the lower and the upper values).

xyplot: A xyplot.
xmin: The lower value for the hotizontal axis.
xmax: The upper value for the hotizontal axis.
ymin: The lower value for the vertical axis.
ymax: The upper value for the vertical axis.

typedef enum{
GIW_XYPLOT_DATA_LINES,
GIW_XYPLOT_DATA_POINTS,
GIW_XYPLOT_DATA_LINES_AND_POINTS
}GiwXYPlotDataStyle;

A structure to describe the way the data will be plotted.

GIW_XYPLOT_DATA_LINES: The data will be repesented by lines.
GIW_XYPLOT_DATA_POINTS: The data will be repesented by spots.
GIW_XYPLOT_DATA_LINES_AND_POINTS: The data will be repesented by spots and lines.
typedef struct {
   gdouble *x, *y;
   guint size;
   GiwXYPlotDataStyle style;
   guint p_width, l_width;
   GdkColor p_color, l_color;
   GdkLineStyle line_style;
}XYPlotData;

A structure to describe a data to be plotted.

x: The data x coordinates.
y: The data y coordinates.
size: How many point the data has.
style: Plot style.
p_witdh: Points width(diameter).
p_color: Points color (the red, blue and green fields will be used, not the pixel).
l_color: Lines color (the red, blue and green fields will be used, not the pixel).
l_witdh: Lines width.
line_style: Lines style


giw_xyplot_set_autorange()

void                giw_xyplot_set_autorange                        (GiwXYPlot *xyplot, XYPlotData *data);

Sets the range of the two axis using the lower and upper values of the choosen data, and leaving some space free between the last data and the edge of the plotting area. If the data field is NULL, the edge values will be calculated using all the datas in the plot.

xyplot: A xyplot.
data: The data to fit the plot.

giw_xyplot_get_range()

void                giw_xyplot_get_range                               (GiwXYPlot *xyplot, gdouble *xmin, gdouble *xmax, gdouble *ymin, gdouble *ymax);

Gets the range used.

xyplot: A xyplot.
xmin: Will receive the lower value for the hotizontal axis.
xmax: Will receive the upper value for the hotizontal axis.
ymin: Will receive the lower value for the vertical axis.
ymax: Will receive the upper value for the vertical axis.

giw_xyplot_get_point()

void                giw_xyplot_get_point                                (GiwXYPlot *xyplot, guint x, guint y, gdouble *xv, gdouble *yv);

Gets a value (x and y) of a certain pixel position in the screen. If the pixel isn't in the plotting area, xv and yv will be NULL.

xyplot: A xyplot.
x: Horizontal position of the pixel.
y: Vertical position of the pixel.
xv: Will receive the value of the horizontal coordinate.
yv: Will receive the value of the vertical coordinate.

giw_xyplot_set_ticks()

void                giw_xyplot_set_ticks                                 (GiwXYPlot *xyplot, guint hmajor, guint hminor, guint vmajor, guint vminor);

Sets the number of major and minor ticks in the two axis.

xyplot: A xyplot.
hmajor: Number of major ticks in horizontal axis.
hminor: Number of minor ticks between each major ticks in horizonatl axis.
vmajor: Number of major ticks in vertical axis.
vminor: Number of minor ticks between each major ticks in vertical axis.

giw_xyplot_get_ticks()

void                giw_xyplot_get_ticks                                 (GiwXYPlot *xyplot, guint *hmajor, guint *hminor, guint *vmajor, guint *vminor);

Gets the number of major and minor ticks in the two axis.

xyplot: A xyplot.
hmajor: Will receive the number of major ticks in horizontal axis.
hminor:
Will receive the number of minor ticks between each major ticks in horizonatl axis.
vmajor: Will receive the number of major ticks in vertical axis.
vminor:
Will receive the number of minor ticks between each major ticks in vertical axis.

giw_xyplot_set_legends_digits()

void               giw_xyplot_set_legends_digits                  (GiwXYPlot *xyplot, guint digits);

Sets the number of digits to be used by the legends (including the "." and "-" signal, if it's necessary).

xyplot: A xyplot.
digits: Number of digits.

giw_xyplot_get_legends_digits()

guint              giw_xyplot_get_legends_digits                  (GiwXYPlot *xyplot);

Gets the number of digits to be used by the legends.

xyplot: A xyplot.
return: Number of digits.

giw_xyplot_set_background_color()

void               giw_xyplot_set_background_color             (GiwXYPlot *xyplot, GdkColor color);

Sets the color to draw the background of the plotting area.

xyplot: A xyplot.
color: The desired color (the "red", "blue" and "green" flields will be use, not the "pixel").

enum GiwXYPlotGrid

typedef enum
{
  GIW_XYPLOT_HMAJOR_GRID,
  GIW_XYPLOT_HMINOR_GRID,
  GIW_XYPLOT_VMAJOR_GRID,
  GIW_XYPLOT_VMINOR_GRID
} GiwXYPlotGrid;

Determines wich grid will be used.


giw_xyplot_set_grids_attributes()

void               giw_xyplot_set_grids_attributes               (GiwXYPlot *xyplot, GiwXYPlotGrid grid, GdkColor color, gint line_width, GdkLineStyle line_style);

Sets the attributes of the grids (the line style, line width and color);

xyplot: A xyplot.
grid: Wich grid will be configured (it can't be bit wised!)
color: Color of the selected grid.
line_width: Width of the line (in pixels).
line_style: GDK_LINE_SOLID or  GDK_LINE_ON_OFF_DASH or  GDK_LINE_DOUBLE_DASH .

giw_xyplot_get_grids_attributes()

void               giw_xyplot_set_grids_attributes               (GiwXYPlot *xyplot, GiwXYPlotGrid grid, GdkColor *color, gint *line_width, GdkLineStyle *line_style);

Gets the attributes of the grids (the line style, line width and color);

xyplot: A xyplot.
grid: Wich grid will be used.
color: Will receive the color of the selected grid.
line_width: Will receive the width of the line (in pixels).
line_style: Will receive the line sytle.


giw_xyplot_enable_grids()

void               giw_xyplot_enable_grids                           (GiwXYPlot *xyplot, GiwXYPlotGrid grid, gboolean enable);

Enables or disables the individuals grids.

xyplot: A xyplot.
grid: Wich grid will be used (can't be bit wised).
enable: TRUE for enable, FALSE for disable.

giw_xyplot_add_data()

void               giw_xyplot_add_data                                (GiwXYPlot *xyplot, XYPlotData *data);

Add a data to the plot, this data can't be freed before removed from the plot with the giw_xyplot_remove_data function.
After add a data to the plot, if this data structure is changed, it's necessary redraw the widget , so the changes can be viewed. The widget can be redrawn  with the gtk_widget_queue_draw() function.


xyplot: A xyplot.
data: A pointer to the data structure to be inserted.

giw_xyplot_remove_data()

void               giw_xyplot_remove_data                                (GiwXYPlot *xyplot, XYPlotData *data);

Removes a data from the plot.


xyplot: A xyplot.
data: A pointer to the data structure to be removed.


giw_xyplot_configure_mouse_zoom()

void               giw_xyplot_configure_mouse_zoom          (GiwXYPlot *xyplot, gboolean enabled, guint button);

Configures the option of using the mouse to zoom, selecting a rectangle to zoom in it.


xyplot: A xyplot.
enabled: True if the zoom in the plot can be done with the mouse.

button: Wich button will be used to do it. 1 for the left button, 2 for the middle button and 3 for the rigth button.

giw_xyplot_configure_wheel_zoom()

void               giw_xyplot_configure_wheel_zoom           (GiwXYPlot *xyplot, gboolean enabled, gdouble factor);

Configures the option of using the mouse's wheel to zoom.


xyplot: A xyplot.
enabled: True if the zoom in the plot can be done with the mouse's wheel.

factor: The number wich will be multiply/divide the current range, to get the new range. This value must be between 0.0 and 1.0. A value next to 0 means a very quick zoom.

giw_xyplot_configure_mouse_displace()

void               giw_xyplot_configure_mouse_displace      (GiwXYPlot *xyplot, gboolean enabled, guint button);

Configures the option of using the mouse to displace (move) the plot.


xyplot: A xyplot.
enabled: True if the mouse can be used to displace the plot.

button: Wich button will be used to do it. 1 for the left button, 2 for the middle button and 3 for the rigth button.

giw_xyplot_configure_mouse_autorange()

void               giw_xyplot_configure_mouse_autorange  (GiwXYPlot *xyplot, gboolean enabled, guint button);

Configures the option of using any mouse button to set the plot range with giw_xyplot_set_autorange(),  with a NULL parameter to the data field.


xyplot: A xyplot.
enabled: True if the mouse can be used to set the autorange to the plot.

button: Wich button will be used to do it. 1 for the left button, 2 for the middle button and 3 for the rigth button.