![]() |
![]() |
![]() |
gtk-hst reference manual | ![]() |
---|---|---|---|---|
#include <gtk-hst/function.h> HstFunction; HstFunctionClass; HstFunction* hst_function_new (int n, double xmin, double xmax, Hst1DFunction ptr); double hst_function_eval (HstFunction *f, double x); int hst_function_npts (HstFunction *f); double hst_function_xmin (HstFunction *f); double hst_function_xmax (HstFunction *f); double hst_function_step (HstFunction *f); int hst_function_find_bin (HstFunction *f, double x); double hst_function_bin_center (HstFunction *f, int ib); int hst_function_resize (HstFunction *f, int width, int height); gchar* hst_function_get_name (HstFunction *f); void hst_function_set_name (HstFunction *f, gchar *name); typedef Tuple; struct Tuple_; typedef PointList; struct PointList_; double (*Hst1DFunction) (double );
"func" gpointer : Read / Write "name" gchararray : Read / Write "nx" gint : Read / Write "range" gpointer : Read / Write "xmax" gdouble : Read / Write "xmin" gdouble : Read / Write "xstep" gdouble : Read / Write
This is an object that wraps a 1D function and a range of validity for that function. The range is defined as an interval of evaluation and the number of points in which the function is evaluated. The range is the basis for defining an axis in a Histogram.
typedef struct _HstFunction HstFunction;
The HstFunction struct contains the following fields. (These fields should be considered read-only. They should never be set by an application.)
double (*func)(double) | A pointer to a 1D function |
int nbin | Number of bins |
gdouble xmin | Minimum value of the X range |
gdouble xmax | Maximum value of the X range |
gdouble step | Step |
gchar *name | Name of the function |
typedef struct { GObjectClass parent_class; double (*eval)(HstFunction *,double); void (*array)(HstFunction *,Tuple *, double, double); int (*resize)(HstFunction *,int w, int h); /* signals */ void (*range_changed)(HstFunction *); } HstFunctionClass;
A HstFunction implements three methods which are used to evaluate the function, to return an array of points in order to draw the function
GObjectClass parent_class ; |
|
eval () |
This is the method that evaluates the function at the given value |
array () |
Returns a list of points that serve to represent graphically the function |
resize () |
This is the method that changes the size of the graphical representation. |
range_changed () |
HstFunction* hst_function_new (int n, double xmin, double xmax, Hst1DFunction ptr);
This is a convenient function to create a HstFunction and setting its properties in one go.
n : |
number of bins |
xmin : |
minimum value of the range |
xmax : |
maximum value of the range |
ptr : |
a pointer to a real value function |
Returns : | a HstFunction object |
double hst_function_eval (HstFunction *f, double x);
f : |
a HstFunction object |
x : |
value of x at which we want to evaluate the function |
Returns : | a double. The value of the function at x: f(x) |
int hst_function_npts (HstFunction *f);
f : |
a HstFunction |
Returns : | the number of points of the function |
double hst_function_xmin (HstFunction *f);
f : |
a HstFunction |
Returns : | the lower value of the function range |
double hst_function_xmax (HstFunction *f);
f : |
a HstFunction |
Returns : | the upper value of the function range |
double hst_function_step (HstFunction *f);
f : |
a HstFunction |
Returns : | the step or binwidth of the function |
int hst_function_find_bin (HstFunction *f, double x);
f : |
a HstFunction |
x : |
the value |
Returns : | the bin that includes x
|
double hst_function_bin_center (HstFunction *f, int ib);
f : |
a HstFunction |
ib : |
bin number |
Returns : | the center of the i-th bin |
int hst_function_resize (HstFunction *f, int width, int height);
This function is used to change the size of the graphical representation of the function
f : |
a HstFunction object |
width : |
the new width |
height : |
the new height |
Returns : | an integer |
gchar* hst_function_get_name (HstFunction *f);
f : |
a HstFunction |
Returns : | the name of the function |
void hst_function_set_name (HstFunction *f, gchar *name);
Sets a name for a function
f : |
a HstFunction |
name : |
the new name for the function |
func
" property"func" gpointer : Read / Write
A pointer to a double Hst1DFunction function that is to be evaluated by HstFunction
name
" property"name" gchararray : Read / Write
The name of the function.
Default value: "<unnamed>"
nx
" property"nx" gint : Read / Write
The number of bins in the X axis
Allowed values: [1,999999]
Default value: 10
range
" property"range" gpointer : Read / Write
The range of the funtion represents any of nx, xmin, xmax. If any of those change, there will be a range-change notification.
xmax
" property"xmax" gdouble : Read / Write
The maximum value of X definig the range of validity of the function
Default value: 1
xmin
" property"xmin" gdouble : Read / Write
The minimum value of X definig the range of validity of the function
Default value: 0
void user_function (HstFunction *arg0, gpointer user_data) : Run first
This signal is emitted whenever any of the properties that define the range of the histogram change. That applies to nx, xmin or xmax.
user_data : |
user data set when the signal handler was connected. |