dataFile

dataFile — Adds a possibility to colorize nodes depending on data read in an input file.

Synopsis

enum                DataFileInputScaleId;
#define             VISU_ERROR_DATA_FILE
GQuark              dataFileGet_quark                   ();
enum                DataFileErrorFlag;
int                 initDataFileModule                  ();
void                dataFileReDraw                      (VisuData *data);
gboolean            dataFileSet_used                    (VisuData *data,
                                                         int val);
int                 dataFileGet_used                    (VisuData *data);
gboolean            dataFileSet_file                    (VisuData *data,
                                                         const char *filename,
                                                         gboolean *new,
                                                         GError **error);
gboolean            dataFileGet_fileSet                 (VisuData *visuData);
gchar*              dataFileGet_file                    (VisuData *visuData);
gboolean            dataFileGet_fileMinMaxFromColumn    (VisuData *visuData,
                                                         float minMax[2],
                                                         int column);
gboolean            dataFileSet_scaleType               (VisuData *visuData,
                                                         DataFileInputScaleId scale);
DataFileInputScaleId  dataFileGet_scaleType             (VisuData *visuData);
gboolean            dataFileSet_min                     (VisuData *visuData,
                                                         float min);
gboolean            dataFileSet_max                     (VisuData *visuData,
                                                         float max);
float               dataFileGet_min                     (VisuData *visuData);
float               dataFileGet_max                     (VisuData *visuData);
gboolean            dataFileSet_colUsed                 (VisuData *visuData,
                                                         int val,
                                                         int pos);
int*                dataFileGet_colUsed                 (VisuData *visuData);
int                 dataFileGet_nbColumns               (VisuData *visuData);
gboolean            dataFileSet_shade                   (VisuData *visuData,
                                                         Shade *shade);
Shade*              dataFileGet_shade                   (VisuData *visuData);
gboolean            dataFileSet_scalingUsed             (VisuData *visuData,
                                                         int val);
int                 dataFileGet_scalingUsed             (VisuData *visuData);
gboolean            dataFileApply_hideOnMinValue        (VisuData *visuData,
                                                         int column,
                                                         float value);

Description

With this module, it is possible to colorize nodes depending on data read in an input file. An input file can be associated to a VisuData object using dataFileSet_file(). Doing this, the rendering is changed and nodes are colorized following a scheme describe later. To turn off colorization without removing the data file (for temporary turn off for instance), use dataFileSet_used().

The input file must have the same numbers of uncommented lines as there are nodes in the VisuData associated with. If less data is given, missing data are treaded as min values data. The input data file can has as much column as desired. The colorization is based on a linear color transformation. This transformation is applied on color channel in RGB mode or in HSV mode. Resulting color is given by : [resulting color vect] = [vectB] + [input data][vectA], where [input data] are input data scaled to [0;1]. It is possible to choose which column multiplies which color channel.

Using dataFileApply_hideOnMinValue(), it is possible to hide some nodes depending on given input data. If the column argument is -1, it unmask all nodes.

Details

enum DataFileInputScaleId

typedef enum
  {
    dataFile_normalize,
    dataFile_minMax
  } DataFileInputScaleId;

Control how input data are converted into [0;1], after conversion, values are clamped if needed.

dataFile_normalize

input data are converted into [0;1] using input min/max values.

dataFile_minMax

input data are converted into [0;1] using user defined min/max values.

VISU_ERROR_DATA_FILE

#define VISU_ERROR_DATA_FILE dataFileGet_quark()

dataFileGet_quark ()

GQuark              dataFileGet_quark                   ();

Internal routine for error handling.

Returns :

the GQuark associated to errors related to colour data files.

enum DataFileErrorFlag

typedef enum
  {
    DATA_FILE_ERROR_NO_COLUMN,
    DATA_FILE_ERROR_MISSING_DATA
  } DataFileErrorFlag;

Possible errors when reading a file with column data.

DATA_FILE_ERROR_NO_COLUMN

no column can be found in the file ;

DATA_FILE_ERROR_MISSING_DATA

some data are missing to match the number of nodes.

initDataFileModule ()

int                 initDataFileModule                  ();

Called by V_Sim on startup, should not be called again.

Returns :

1 if eveything goes right.

dataFileReDraw ()

void                dataFileReDraw                      (VisuData *data);

This methods is a short-cut to call visu_data_createAllNodes() and then emit the 'OpenGLAskForReDraw' signal.

May become deprecated soon.

data :

a VisuData object that holds the data file informations.

dataFileSet_used ()

gboolean            dataFileSet_used                    (VisuData *data,
                                                         int val);

When TRUE, rendering is modified by applying a colorization method to normal nodes. The color used depend on input data. See dataFileSet_file() to choose them.

data :

a VisuData object to set the colorisation tool or not ;

val :

a boolean integer.

Returns :

TRUE if val is true and if a valid input file is already in memory.

dataFileGet_used ()

int                 dataFileGet_used                    (VisuData *data);

This method retrieve the used flag, see dataFileSet_used() to set it.

data :

a VisuData object to get if the colorisation tool is set or not ;

Returns :

1 if the used flag is set.

dataFileSet_file ()

gboolean            dataFileSet_file                    (VisuData *data,
                                                         const char *filename,
                                                         gboolean *new,
                                                         GError **error);

Call this method to parse a data file and associate its values to the given VisuData object.

data :

a VisuData object to attach the data file to ;

filename :

the path to find the data file on the disk ;

new :

return TRUE if some data are associated for the first time to the given VisuData ;

error :

a location to a NULL GError.

Returns :

0 if nothing is loaded, 1 some data have been loaded.

dataFileGet_fileSet ()

gboolean            dataFileGet_fileSet                 (VisuData *visuData);

A set of data per node can be associated to a VisuData. This routine retrieves if visuData has it or not.

visuData :

a VisuData object.

Returns :

TRUE if visuData has colour data associated.

Since 3.6


dataFileGet_file ()

gchar*              dataFileGet_file                    (VisuData *visuData);

If the given visuData has an input data file already loaded, it returns its name.

visuData :

a VisuData object.

Returns :

the name of the input data file if set. This name is own by V_Sim and should not be freed.

dataFileGet_fileMinMaxFromColumn ()

gboolean            dataFileGet_fileMinMaxFromColumn    (VisuData *visuData,
                                                         float minMax[2],
                                                         int column);

This method is used to retrieve the minimum and the maximum values of the column designed by the column argument. Column are numbered beginning at 0.

visuData :

the VisuData object which the colour data are associated to ;

minMax :

an allocated array of two floating point values ;

column :

an integer.

Returns :

FALSE if column < 0 or if column is greater than the number of read column or if no file has been set.

dataFileSet_scaleType ()

gboolean            dataFileSet_scaleType               (VisuData *visuData,
                                                         DataFileInputScaleId scale);

This method is used to change the scale method used on input data. See DataFileInputScaleId for further informations. This method raises a error if no input file has already been associated to the give visuData.

visuData :

a VisuData object ;

scale :

an integer.

Returns :

1 if visu_data_createAllNodes() should be called.

dataFileGet_scaleType ()

DataFileInputScaleId  dataFileGet_scaleType             (VisuData *visuData);

Retrieve the scaling method of input data associated to the given visuData.

visuData :

a VisuData object.

Returns :

the scaling method if visuData has an input data file associated or the default value if not.

dataFileSet_min ()

gboolean            dataFileSet_min                     (VisuData *visuData,
                                                         float min);

When the scaling method is dataFile_minMax (see DataFileInputScaleId) min and max value for convert input data are user defined. Use this method to choose the minimum bound. This method raises a error if no input file has already been associated to the give visuData.

visuData :

a VisuData object ;

min :

a floating point value.

Returns :

1 if visu_data_createAllNodes() should be called.

dataFileSet_max ()

gboolean            dataFileSet_max                     (VisuData *visuData,
                                                         float max);

When the scaling method is dataFile_minMax (see DataFileInputScaleId) min and max value for convert input data are user defined. Use this method to choose the maximum bound. This method raises a error if no input file has already been associated to the give visuData.

visuData :

a VisuData object ;

max :

a floating point value.

Returns :

1 if visu_data_createAllNodes() should be called.

dataFileGet_min ()

float               dataFileGet_min                     (VisuData *visuData);

Retrieve the minimum value used when scaling is user defined.

visuData :

a VisuData object.

Returns :

the minimum bound if visuData has an input data file associated or the default value if not.

dataFileGet_max ()

float               dataFileGet_max                     (VisuData *visuData);

Retrieve the maximum value used when scaling is user defined.

visuData :

a VisuData object.

Returns :

the maximum bound if visuData has an input data file associated or the default value if not.

dataFileSet_colUsed ()

gboolean            dataFileSet_colUsed                 (VisuData *visuData,
                                                         int val,
                                                         int pos);

Choose if the loaded value should change the given channel of the colour.

visuData :

a VisuData object ;

val :

0 or 1 ;

pos :

an integer in [0;2].

Returns :

1 if visu_data_createAllNodes() should be called.

dataFileGet_colUsed ()

int*                dataFileGet_colUsed                 (VisuData *visuData);

This method is used to retrieve the vector used to adapt or not the colour to the value of the loaded data.

visuData :

a VisuData object.

Returns :

a three value array, own by V_Sim. It should not be freed.

dataFileGet_nbColumns ()

int                 dataFileGet_nbColumns               (VisuData *visuData);

This method is used to retrieve the number of columns of data read in the loaded file.

visuData :

a VisuData object.

Returns :

this number of columns.

dataFileSet_shade ()

gboolean            dataFileSet_shade                   (VisuData *visuData,
                                                         Shade *shade);

Apply all caracteristic of the given shade to the colorization the the given VisuObject.

visuData :

the VisuData object which the colour data are associated to ;

shade :

a valid Shade object.

Returns :

TRUE if visu_data_createAllNodes() should be called.

dataFileGet_shade ()

Shade*              dataFileGet_shade                   (VisuData *visuData);

Return the shade used to colourise the nodes.

visuData :

the VisuData object which the colour data are associated to.

Returns :

the Shade used (own by V_Sim).

dataFileSet_scalingUsed ()

gboolean            dataFileSet_scalingUsed             (VisuData *visuData,
                                                         int val);

Give the column id to used to take the scaling values from. Set -1 if no scaling used. The scaling is used to change the size of each node, using an homothetic factor.

visuData :

a VisuData object hosting the data values ;

val :

a column id.

Returns :

TRUE if the status changed.

dataFileGet_scalingUsed ()

int                 dataFileGet_scalingUsed             (VisuData *visuData);

Retrieve if a column is used as entry to scale the nodes.

visuData :

a VisuData object hosting the data values.

Returns :

-1 if no scaling is used.

dataFileApply_hideOnMinValue ()

gboolean            dataFileApply_hideOnMinValue        (VisuData *visuData,
                                                         int column,
                                                         float value);

Use this method hide nodes whose data from column column is lower than the given value. If column is -1, then all previous masking are cancelled.

visuData :

the VisuData object which the colour data are associated to ;

column :

a integer corresponding to a column id ;

value :

a floating point value.

Returns :

TRUE if visu_data_createAllNodes() should be called and "NodeRenderedChanged" signal should be emitted (with a NULL VisuElement parameter).