#include <iup.h>
#include <cd.h>
#include <im.h>
#include <im_image.h>
Go to the source code of this file.
Enumerations | |
enum | IupGraphImageFmt { IUPG_BMP = 0, IUPG_PCX = 1, IUPG_GIF = 2, IUPG_TIFF = 3, IUPG_RAS = 4, IUPG_SGI = 5, IUPG_JPEG = 6, IUPG_LED = 7, IUPG_TGA = 8, IUPG_RAW = 9, IUPG_PNM = 10, IUPG_ICO = 11, IUPG_PNG = 12, IUPG_SVG = -1, IUPG_PDF = -2, IUPG_PS = -3, IUPG_EPS = -4 } |
enum | IupGraphAlignment { IUPG_CENTER = CD_CENTER, IUPG_NORTH = CD_NORTH, IUPG_SOUTH = CD_SOUTH, IUPG_WEST = CD_WEST, IUPG_EAST = CD_EAST, IUPG_NWEST = CD_NORTH_WEST, IUPG_NEAST = CD_NORTH_EAST, IUPG_SWEST = CD_SOUTH_WEST, IUPG_SEAST = CD_SOUTH_EAST } |
enum | IupGraphChartType { IUPG_CHART_CART, IUPG_CHART_POLAR, IUPG_CHART_BAR, IUPG_CHART_STEP, IUPG_CHART_PIE } |
enum | ChartOrientation { IUPG_VERTICAL, IUPG_HORIZONTAL } |
enum | ChartDataInput { IUPG_USEX, IUPG_USEY, IUPG_USEP } |
enum | ColorScheme { IUPG_SINGLE, IUPG_POSNEG, IUPG_MULTIPLE } |
enum | AxisLine { IUPGRAPH_AXIS_X, IUPGRAPH_AXIS_Y, IUPGRAPH_GRID_X, IUPGRAPH_GRID_Y, IUPGRAPH_GRID_AUX_X, IUPGRAPH_GRID_AUX_Y } |
Functions | |
void * | IupGraphCreate (Ihandle *canvas, double xmin, double xmax, double ymin, double ymax) |
void * | IupGraphCreatePassive (int w, int h, double xmin, double xmax, double ymin, double ymax) |
void | IupGraphDestroy (void *graph) |
void | IupGraphRedraw (void *graph) |
void | IupGraphDump (void *graph, const char *fname, IupGraphImageFmt image_format) |
void | IupGraphFit (void *graph) |
void | IupGraphFitLimits (void *graph) |
void * | IupGraphChartCreate (int npoints, double *x, double *y, const char *name, IupGraphChartType type) |
void * | IupGraphChartCopy (void *chart) |
void * | IupGraphChartCreateCb (int npoints, int(*cb)(void *chart, int i, double *x, double *y), const char *name, IupGraphChartType type) |
int | IupGraphChartInsert (void *graph, void *chart) |
void | IupGraphChartRemove (void *graph, void *chart) |
void | IupGraphChartDestroy (void *chart) |
void | IupGraphChartDestroyAll (void *graph) |
void | IupGraphChartRefreshData (void *graph, void *chart, double *x, double *y, int npoints) |
void | IupGraphChartSetShow (void *chart, int show) |
void | IupGraphChartSetLine (void *chart, int show, float width, int style, long int color) |
void | IupGraphChartSetMark (void *chart, int show, int size, int type, long int color) |
void | IupGraphChartSetPosition (void *chart, double x, double y) |
void * | IupGraphChartGetLine (void *chart) |
void | IupGraphChartSetClient (void *chart, void *client) |
void * | IupGraphChartGetClient (void *chart) |
void * | IupGraphChartGetGraph (void *chart) |
void | IupGraphChartSetLabel_i (void *chart, int i, char *label_i) |
void * | IupGraphChartGetLabel_i (void *chart, int i) |
void | IupGraphChartSetColor_i (void *chart, int i, long int color_i) |
void | IupGraphChartPieSetPosition (void *chart, double x, double y) |
void | IupGraphChartPieSetRadius (void *chart, double radius) |
void * | IupGraphChartGetLabelConnectorLine (void *chart) |
void * | IupGraphChartGetLegend (void *chart) |
void | IupGraphAxisSetLimits (void *g, float xmin, float xmax, float ymin, float ymax, float ox, float oy, int nx, int ny) |
void | IupGraphAxisGetLimits (void *g, float *xmin, float *xmax, float *ymin, float *ymax, float *ox, float *oy, int *nx, int *ny) |
void * | IupGraphAxisGetTitleX (void *g) |
void * | IupGraphAxisGetTitleY (void *g) |
void | IupGraphAxisSetDecimalPlacesX (void *g, int d) |
void | IupGraphAxisSetDecimalPlacesY (void *g, int d) |
void * | IupGraphAxisGetLine (void *g, AxisLine line) |
void * | IupGraphScaleGetX (void *g) |
void * | IupGraphScaleGetY (void *g) |
void | IupGraphScaleSetShow (void *scale, int show) |
int | IupGraphScaleGetShow (void *scale) |
void | IupGraphScaleSetPosition (void *scale, float x, float y) |
void | IupGraphScaleGetPosition (void *scale, float *x, float *y) |
void | IupGraphWindowAxesShow (void *g, int show) |
void | IupGraphLineSetShow (void *line, int show) |
void | IupGraphLineSetWidth (void *line, float width) |
void | IupGraphLineSetStyle (void *line, int style) |
void | IupGraphLineSetColor (void *line, long int color) |
int | IupGraphLineGetShow (void *line) |
float | IupGraphLineGetWidth (void *line) |
int | IupGraphLineGetStyle (void *line) |
long int | IupGraphLineGetColor (void *line) |
void * | IupGraphTextCreate (char *text_string) |
void | IupGraphTextInsert (void *graph, void *text) |
void | IupGraphTextDestroy (void *graph, void *text) |
void * | IupGraphGetTitle (void *graph) |
void * | IupGraphChartGetTitle (void *chart) |
void | IupGraphTextSetShow (void *text, int a) |
void | IupGraphTextSetValue (void *text, char *a) |
void | IupGraphTextSetFont (void *text, char *a) |
void | IupGraphTextSetOpaque (void *text, int a) |
void | IupGraphTextSetSize (void *text, int a) |
void | IupGraphTextSetColor (void *text, long int a) |
void | IupGraphTextSetDrawbox (void *text, int a) |
void | IupGraphTextSetBoxbgcolor (void *text, long int a) |
void | IupGraphTextSetBoxlinecolor (void *text, long int a) |
void | IupGraphTextSetAlignment (void *text, int a) |
void | IupGraphTextSetPosition (void *text, float x, float y) |
void | IupGraphTextSetNormalizedPosition (void *graph, void *text, float x, float y) |
void | IupGraphTextSetAngle (void *text, float angle) |
int | IupGraphTextIsShown (void *text) |
const char * | IupGraphTextGetValue (void *text) |
const char * | IupGraphTextGetFont (void *text) |
int | IupGraphTextGetOpaque (void *text) |
int | IupGraphTextGetSize (void *text) |
long int | IupGraphTextGetTextcolor (void *text) |
int | IupGraphTextGetDrawbox (void *text) |
long int | IupGraphTextGetBoxbgcolor (void *text) |
long int | IupGraphTextGetBoxlinecolor (void *text) |
void | IupGraphTextGetPosition (void *text, float *x, float *y) |
float | IupGraphTextGetAngle (void *text) |
void | IupGraphLegendShow (void *graph, int show) |
void | IupGraphLegendSetUseChartColor (void *graph, int use) |
int | IupGraphLegendGetUseChartColor (void *graph) |
void | IupGraphLegendSetPosition (void *graph, float x, float y) |
void | IupGraphLegendSetAlignment (void *graph, int align) |
void | IupGraphLegendSetOpaque (void *graph, int a) |
void | IupGraphLegendSetBoxbgcolor (void *graph, long int a) |
int | IupGraphLegendGetOpaque (void *graph) |
void | IupGraphPickSetTolerance (void *graph, int tol) |
void | IupGraphSetZoomStep (void *graph, float step) |
void | IupGraphSetZoomFactor (void *graph, float factor) |
void | IupGraphGetZoomBox (void *graph, float *xmin, float *xmax, float *ymin, float *ymax) |
void | IupGraphSetZoomBox (void *graph, float xmin, float xmax, float ymin, float ymax) |
void | IupGraphSetClipCharts (void *graph, int clip) |
int | IupGraphGetClipCharts (void *graph) |
void | IupGraphBgSetColor (void *graph, float r, float g, float b) |
void | IupGraphBgGetColor (void *graph, float *r, float *g, float *b) |
void | IupGraphSetMouseMvCallback (void *g, void(*fcn)(double x, double y, char *r, void **curve_vector, double *picked_x, double *picked_y, int nsel_curves)) |
void | IupGraphSetMouseBtCallback (void *g, void(*fcn)(int bt, int status, double x, double y, void **curve_vector, double *picked_x, double *picked_y, int nsel_curves)) |
void | IupGraphChartSetFocusable (void *chart, int b) |
void | IupGraphChartSetPickable (void *chart, int b) |
void | IupGraphChartShowLabelX (void *chart, int b) |
void | IupGraphChartShowLabelY (void *chart, int b) |
void | IupGraphChartAllowUser2Destroy (void *chart, int b) |
void | IupGraphChartGetLimits (void *chart, double *xmin, double *xmax, double *ymin, double *ymax) |
void * | IupGraphCAreaCreate (void *chart1, void *chart2, double x0, double y0, double x1, double y1) |
void | IupGraphCAreaInsert (void *graph, void *curvearea) |
void | IupGraphCAreaSetUpper (void *carea, unsigned char r, unsigned char g, unsigned char b, unsigned char a) |
void | IupGraphCAreaSetLower (void *carea, unsigned char r, unsigned char g, unsigned char b, unsigned char a) |
void | IupGraphCAreaSetLimits (void *carea, double xmin, double xmax, double ymin, double ymax) |
int | IupGraphCAreaDestroy (void *graph, void *carea) |
void | IupGraphCAreaDestroyAll (void *graph) |
void | IupGraphChartShowMark (void *chart, int show) |
void | IupGraphChartSetMarkColor (void *chart, long int color) |
void | IupGraphChartSetMarkSize (void *chart, int size) |
void | IupGraphChartSetMarkType (void *chart, int type) |
int | IupGraphChartIsMarkShown (void *chart) |
long | IupGraphChartGetMarkColor (void *chart) |
int | IupGraphChartGetMarkSize (void *chart) |
int | IupGraphChartGetMarkType (void *chart) |
Iupgraph C style API This file conatins a set of C style functions to enable the client to create and handle IupGraph objects.
enum IupGraphAlignment |
Enumerators
enum IupGraphChartType |
enum IupGraphImageFmt |
void IupGraphBgSetColor | ( | void * | graph, |
float | r, | ||
float | g, | ||
float | b | ||
) |
Here, the color components should range from 0.0f to 1.0f
void* IupGraphCAreaCreate | ( | void * | chart1, |
void * | chart2, | ||
double | x0, | ||
double | y0, | ||
double | x1, | ||
double | y1 | ||
) |
Creates a CurveArea, which is an area plotted between two charts or between a chart and a straight segment of line. For instance, this line could be the x axis. The line is defined by two points: P0 and P1. If chart2 is NULL, the area will be considered between chart1 and the line from P0 to P1.
chart1 | Pointer to the first Chart. |
chart2 | Pointer to the second Chart. It can be NULL; in this case, x0, y0, x1 and y1 will be used. |
x0 | x component of the point P0. It is only used if chart2 is NULL. |
y0 | y component of the point P0. It is only used if chart2 is NULL. |
x1 | x component of the point P1. It is only used if chart2 is NULL. |
y1 | y component of the point P1. It is only used if chart2 is NULL. |
int IupGraphCAreaDestroy | ( | void * | graph, |
void * | carea | ||
) |
Destroys the given CurveArea
void IupGraphCAreaDestroyAll | ( | void * | graph | ) |
Destroys all CurveAreas, if any, of IupGraph
void IupGraphCAreaInsert | ( | void * | graph, |
void * | curvearea | ||
) |
Inserts a CurveArea into IupGraph.
graph | Pointer to the IupGraph where curvearea will be inserted. If it is NULL, nothing happens. |
curvearea | Pointer to the CurveArea. If is is NULL, nothing happens. |
void IupGraphCAreaSetLimits | ( | void * | carea, |
double | xmin, | ||
double | xmax, | ||
double | ymin, | ||
double | ymax | ||
) |
Sets the limits of a CurveArea.
Defines an area for clipping. CurveAreas are only drawn inside the box (xmin,xmax,ymin,ymax).
void IupGraphCAreaSetLower | ( | void * | carea, |
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a | ||
) |
Sets the appearance of the lower area in a CurveArea.
The lower area is the portion of area that lies bellow chart2 or line (P0,P1).
carea | Pointer to the CurveArea. If is is NULL, nothing happens. |
r | Red component of the background color. |
g | Green component of the background color. |
b | Blue component of the background color. |
a | Alpha component of the background color. |
void IupGraphCAreaSetUpper | ( | void * | carea, |
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a | ||
) |
Sets the appearance of the upper area in a CurveArea.
The upper area is the portion of area that lies above chart2 or line (P0,P1).
carea | Pointer to the CurveArea. If is is NULL, nothing happens. |
r | Red component of the background color. |
g | Green component of the background color. |
b | Blue component of the background color. |
a | Alpha component of the background color. |
void* IupGraphChartCopy | ( | void * | chart | ) |
Creates a completely independent copy of the given chart. The only difference is that the created Chart is not inserted in any IupGraph.
chart | Chart to be copied. |
void* IupGraphChartCreate | ( | int | npoints, |
double * | x, | ||
double * | y, | ||
const char * | name, | ||
IupGraphChartType | type | ||
) |
Creates a chart entity that is not yet inserted in Iupgraph. Thus, it can be inserted in any Iupgraph. If you want to insert it in more than one Iupgraph, I recommend to insert a copy of this chart. Call IupGraphCopyChart(chart_to_be_copied).
By default, the created chart is a line chart.
npoints | Number of points. Size of the arrays x and y. |
x | Array containing the x coordinates. Should not be a NULL pointer. |
y | Array containing the y coordinates. Should not be a NULL pointer. |
name | Title name for the Chart. Can be NULL, if no name is desired. |
void* IupGraphChartCreateCb | ( | int | npoints, |
int(*)(void *chart, int i, double *x, double *y) | cb, | ||
const char * | name, | ||
IupGraphChartType | type | ||
) |
Creates a chart with a callback (Cb) to retrieve the values of x and y. Instead of passing x and y as arguments, a pointer to the callback is passed. It is useful when the client does not have the arrays x and y stored in memory. This callback will be called not only to draw the chart, but also to compute its bounding box etc. It works in the very same way as a chart created by IupGraphChartCreate. The callback should set the values of x and y, given the index i. It must work for i in [0,npoints-1]. If it returns 0, Iupgraph will understand that i is out of bounds.
void IupGraphChartDestroy | ( | void * | chart | ) |
Destroys the given chart. If the given Chart belongs to a Iupgraph, it is first removed.
chart | Chart to be destroyed. |
void IupGraphChartDestroyAll | ( | void * | graph | ) |
Removes and destroys all charts from IupGraph
void* IupGraphChartGetClient | ( | void * | chart | ) |
Retrieves the client pointer previously set.
void* IupGraphChartGetGraph | ( | void * | chart | ) |
Retrieves the pointer of the Graph that the chart belongs to. If NULL, the chart was not inserted, yet. Useful in callback mode.
void* IupGraphChartGetLabel_i | ( | void * | chart, |
int | i | ||
) |
Returns a pointer to the text object of label i
void* IupGraphChartGetLabelConnectorLine | ( | void * | chart | ) |
Returns a LineMask object with the attributes of the line connecting the slices to its labels
void* IupGraphChartGetTitle | ( | void * | chart | ) |
Gets the title of a Chart.
int IupGraphChartInsert | ( | void * | graph, |
void * | chart | ||
) |
Inserts chart into IupGraph. If the chart is already inserted in an Iupgraph, nothing happens. If you want to insert the chart in more than one Iupgraph, you can either remove it first from a Iupgraph or create a fresh copy of the chart.
graph | Pointer to IupGraph. |
chart | Chart to be inserted. |
void IupGraphChartPieSetPosition | ( | void * | chart, |
double | x, | ||
double | y | ||
) |
Sets the pie's center position.
void IupGraphChartPieSetRadius | ( | void * | chart, |
double | radius | ||
) |
Sets the pie's outer radius
void IupGraphChartRefreshData | ( | void * | graph, |
void * | chart, | ||
double * | x, | ||
double * | y, | ||
int | npoints | ||
) |
Refreshes the data used by the Chart. Both x and y can be NULL. So, the client can change only the number of points (npoints) in this case. It is more efficient than Removing a Chart and Inserting it back, when the desire is only to change the number of points or to change the data x and/or y.
void IupGraphChartRemove | ( | void * | graph, |
void * | chart | ||
) |
Removes a Chart from IupGraph. If chart does not belong to graph, nothing happens.
graph | Pointer to IupGraph. |
chart | pointer to the Chart to be removed. |
void IupGraphChartSetClient | ( | void * | chart, |
void * | client | ||
) |
Sets a client pointer to the chart.
void IupGraphChartSetColor_i | ( | void * | chart, |
int | i, | ||
long int | color_i | ||
) |
This only works for pie charts so far. Sets the color of slice i, where i in[0,npoints].
void IupGraphChartSetLabel_i | ( | void * | chart, |
int | i, | ||
char * | label_i | ||
) |
This only works for pie charts so far. Sets the label of index i, where i in[0,npoints].
void IupGraphChartSetPosition | ( | void * | chart, |
double | x, | ||
double | y | ||
) |
Sets the center of the a polar chart or a pie chart.
chart | Pointer to the polar chart. If it is NULL or the chart is not polar or pie, nothing happens. |
void IupGraphChartSetShow | ( | void * | chart, |
int | show | ||
) |
Sets whether the chart will be shown or not
chart | Pointer to the chart object. If it is NULL, nothing happens. |
show | If 1, the chart will be shown. If 0, the chart will be hidden. |
void * IupGraphCreate | ( | Ihandle * | canvas, |
double | xmin, | ||
double | xmax, | ||
double | ymin, | ||
double | ymax | ||
) |
Creates a IupGraph associated to the given IupCanvas.
canvas | a pointer to a IupGLCanvas where the drawings will take place. This canvas MUST already be mapped! |
xmin | left margin proportional to the canvas size. Common values range from 0.0 to 0.2. |
xmax | right margin proportional to the canvas size. Common values range from 0.9 to 1.0. |
ymin | lower margin. |
ymax | upper margin. |
These margins are values that define a box inside the canvas. The values must be in [0.0,1.0]. This box is the space of the canvas that the axes will occupy. Usually y scale is on the left hand side, so xmin should be long enough to make room for it. Analogously, ymin should make enough room for x scale (usually bellow the axes).
The canvas should already be mapped, i.e. the dialog that contains it should be mapped prior to calling IupGraphCreate. This is because IupGraph needs to know the canvas' dimensions and it only makes sense after mapping.
IupGraphDestroy | ( | void * | graph | ) |
Destroys IupGraph and everything inserted in it.
graph | pointer to the IupGraph. The same pointer returned by IupGraphCreate. |
If the parameter graph is NULL, nothing happens.
void IupGraphFit | ( | void * | graph | ) |
Fits axes to the box passed as argument in function IupGraphCreate.
graph | pointer to the IupGraph. The same pointer returned by IupGraphCreate. |
This action fits the view to the default view. It is the same as to call IupGraphSetZoomFactor passing 1.0 as argument.
void IupGraphFitLimits | ( | void * | graph | ) |
Fits axes limits to the extents of the charts.
graph | pointer to the IupGraph. The same pointer returned by IupGraphCreate. This function is useful when you remove charts, or when you insert it. If the current limit is too large, is gets shrunk. |
This action does not fit the view. To fit the view, call IupGraphFit.
int IupGraphGetClipCharts | ( | void * | graph | ) |
Gets the value of the clipping flag.
void* IupGraphGetTitle | ( | void * | graph | ) |
Gets the main title of IupGraph.
void IupGraphGetZoomBox | ( | void * | graph, |
float * | xmin, | ||
float * | xmax, | ||
float * | ymin, | ||
float * | ymax | ||
) |
Gets the current zoom box. It analogous to the parameters of a camera in a 3D scene. It is useful to allow insertion and removal of charts while keeping the current view.
void IupGraphLegendSetPosition | ( | void * | graph, |
float | x, | ||
float | y | ||
) |
The values x and y are in [0.0,1.0]. They are a percentage of the whole window. I.e (0,0) is the bottom left corner and (1,1) is the top right corner.
void IupGraphPickSetTolerance | ( | void * | graph, |
int | tol | ||
) |
Tolerance in pixels. Defines a square with width=height=tol
void IupGraphRedraw | ( | void * | graph | ) |
Redraws IupGraph in the active OpenGL context.
graph | pointer to the IupGraph. The same pointer returned by IupGraphCreate. |
void IupGraphSetClipCharts | ( | void * | graph, |
int | clip | ||
) |
Sets a flag to clip or not the Charts drawings into the axes limits. By default it doesn't clip.
void IupGraphSetZoomBox | ( | void * | graph, |
float | xmin, | ||
float | xmax, | ||
float | ymin, | ||
float | ymax | ||
) |
Sets the current zoom box. It analogous to the parameters of a camera in a 3D scene. It is useful to allow insertion and removal of charts while keeping the current view.
void IupGraphSetZoomFactor | ( | void * | graph, |
float | factor | ||
) |
Sets zoom factor dafault: 1.00 (100%)
void IupGraphSetZoomStep | ( | void * | graph, |
float | step | ||
) |
Zoom step used when scrolling the mouse or Zoomming In/Out default: 0.01 (1%)
void* IupGraphTextCreate | ( | char * | text_string | ) |
Creates a new Text object that can be inserted in IupGraph
void IupGraphTextDestroy | ( | void * | graph, |
void * | text | ||
) |
Destroys a text previously inserted by IupGraphTextInsert
void IupGraphTextInsert | ( | void * | graph, |
void * | text | ||
) |
Inserts previously created text into Iupgraph
void IupGraphTextSetAlignment | ( | void * | text, |
int | a | ||
) |
Sets the point of the text's bounding box that will be used to align the text. This point will be placed at the position attribute of the text.
text | A pointer to the text object. If is is NULL, nothing happens. |
a | The value of the alignment. It can be either IUPG_CENTER, IUPG_NORTH, IUPG_SOUTH, IUPG_WEST, IUPG_EAST, IUPG_NWEST, IUPG_NEAST, IUPG_SWEST or IUPG_SEAST. |
void IupGraphTextSetAngle | ( | void * | text, |
float | angle | ||
) |
Sets the orientation angle for a text in degrees. Angle is measured counter-clockwisely from x axis.
void IupGraphTextSetNormalizedPosition | ( | void * | graph, |
void * | text, | ||
float | x, | ||
float | y | ||
) |
Sets the position of a text object normalized to the window limits. The values of x or y should lie in the interval [0.0,1.0] in order to the text to be displayed in the default view (the fit view). These values are closely related to the values passed to the function IupGraphCreate.
graph | A pointer to the IupGraph that holds the text object. If it is NULL, nothing happens. |
text | A pointer to the text object to be positioned. If it is NULL, nothing happens. |
x | X normalized coordinate according to the window limits. |
y | Y normalized coordinate according to the window limits. |
void IupGraphTextSetPosition | ( | void * | text, |
float | x, | ||
float | y | ||
) |
Sets the position of a text object in axes coordinates
text | A pointer to the text object. If is is NULL, nothing happens. |
x | X coordinate measured in the abscissae of the axes. |
y | Y coordinate measured in the ordinate of the axes. |