![]() |
![]() |
![]() |
V_Sim API - Reference Manual | ![]() |
---|---|---|---|---|
visu_pairsvisu_pairs — V_Sim can draw link between nodes. This part defines a pair object and interface to draw pairs. |
#define PAIRS_MIN #define PAIRS_MAX #define PAIRS_COLOR_R #define PAIRS_COLOR_G #define PAIRS_COLOR_B void (*foreachPairsFunc) (PairsData *data, gpointer userData); typedef PairsData; int setPairsOnOff (int onOff); int setPairsAll (PairsData *data, float rgb[3], float minMax[2]); int setPairsDistance (float val, PairsData *data, int minOrMax); int setPairsDrawn (PairsData *data, gboolean drawn); int setPairsColor (PairsData *data, Color *color); void setPairsProperty (PairsData *data, const gchar *key, gpointer value); int getPairsOnOff (); float getPairsDistance (VisuElement *ele1, VisuElement *ele2, int minOrMax); PairsData* getPairsData (VisuElement *ele1, VisuElement *ele2); gboolean getPairsDrawn (PairsData *data); gpointer getPairsProperty (PairsData *data, const gchar *key); void foreachPairsData (foreachPairsFunc whatToDo, gpointer userData); int createPairs (VisuData *dataObj); void (*initEndOpenGlPairsFunc) (); void (*startEndPairsFunc) (VisuElement *ele1, VisuElement *ele2, PairsData *data); void (*pairDefinitionFunc) (VisuElement *ele1, VisuElement *ele2, PairsData *data, OpenGLView *view, double x1, double y1, double z1, double x2, double y2, double z2, float d2); struct PairsExtension_struct; typedef PairsExtension; PairsExtension* pairsExtension_new (char *name, char *printName, char *description, int sensitive, initEndOpenGlPairsFunc init, initEndOpenGlPairsFunc stop, startEndPairsFunc start, startEndPairsFunc end, pairDefinitionFunc draw); void PairsExtension_free (PairsExtension *extension); void registerPairsExtension (PairsExtension *extension); int setPairsMethod (PairsExtension *extension); void setPairsAreOutOfDate (); PairsExtension* getCurrentPairsMethods (); int isValidPairsExtension (PairsExtension *pairsModel); GList* getAllPairsMethods (); char* getNameOfPairsMethod (PairsExtension *extension); int initPairsModule ();
The visu_pairs.c defines only general methods to draw pairs. It introduces a
new object called PairsData. This stores some characteristics on links between two
VisuElement. The main characteristic is that pairs are drawn only if the length between two
nodes is in a specific range. Use setPairsDistance()
and getPairsDistance()
to tune this range.
This file does not draw any pairs. But it gives some interface to create rendering capabilities.
To create a new pair rendering module, called PairsExtension, use pairsExtension_new()
.
Basically, a PairsExtension is characterized by it drawing method. But it can have other
methods that are called in different cases. See initEndOpenGlPairsFunc()
and startEndPairsFunc()
prototypes to have more informations.
#define PAIRS_MIN 0
Flag used to define the minimum length to draw pair. This is useful with
the getPairsDistance()
and the getPairsDistance()
methods.
#define PAIRS_MAX 1
Flag used to define the maximum length to draw pair. This is useful with
the getPairsDistance()
and the getPairsDistance()
methods.
#define PAIRS_COLOR_R 0
Flag used to define the red color of a pair. This is useful to access
the rgba array of the Color object return by setPairsColor()
.
#define PAIRS_COLOR_G 1
Flag used to define the green color of a pair. This is useful to access
the rgba array of the Color object return by setPairsColor()
.
#define PAIRS_COLOR_B 2
Flag used to define the blue color of a pair. This is useful to access
the rgba array of the Color object return by setPairsColor()
.
void (*foreachPairsFunc) (PairsData *data, gpointer userData);
Prototype of functions called with the foreach method apply to each pairs.
|
a PairsData object ; |
|
some user defined data. |
int setPairsOnOff (int onOff);
Turn on or off the pairs.
|
a boolean 0 or 1. |
Returns : |
1 if createPairs() should be called and then the 'OpenGLAskForReDraw'
signal be emitted.
|
int setPairsAll (PairsData *data, float rgb[3], float minMax[2]);
This method sets length and color informations for the given pairs.
|
a PairsData object ; |
|
an array of three floating point values ; |
|
an array of two floating point values. |
Returns : |
1 if createPairs() should be called and then the 'OpenGLAskForReDraw'
signal be emitted.
|
int setPairsDistance (float val, PairsData *data, int minOrMax);
Set the minimum or the maximum length for the given pair.
|
a floating point value ; |
|
a PairsData object ; |
|
PAIRS_MAX or PAIRS_MIN. |
Returns : |
1 if createPairs() should be called or not.
|
int setPairsDrawn (PairsData *data, gboolean drawn);
A pair can or cannot be drawn, use this method to tune it.
|
a PairsData object ; |
|
a boolean. |
Returns : |
1 if createPairs() should be called.
|
int setPairsColor (PairsData *data, Color *color);
Set the color of the given pair.
|
a PairsData object ; |
|
a Color object.. |
Returns : |
1 if createPairs() should be called or not.
|
void setPairsProperty (PairsData *data, const gchar *key, gpointer value);
Each pair can store some informations that can be retrieve by a string key.
This method is used to registered a new value associated to the key key
.
|
a PairsData object ; |
|
a static string ; |
|
a pointer to some allocated data. |
int getPairsOnOff ();
Get the status of pairs, drawn or not.
Returns : |
1 if pairs are drawn. |
float getPairsDistance (VisuElement *ele1, VisuElement *ele2, int minOrMax);
A pair between ele1
and ele2
is drawn only if its length is between
a minimum and a maximum value. This method can get these values.
|
a VisuElement object ; |
|
a VisuElement object ; |
|
PAIRS_MIN or PAIRS_MAX. |
Returns : |
the minimum or the maximum value for the pair between ele1 and ele2 .
|
PairsData* getPairsData (VisuElement *ele1, VisuElement *ele2);
The object PairsData is used to characterized the link between two elements.
|
a VisuElement object ; |
|
a VisuElement object. |
Returns : |
the PairsData object associated to the given two elements. If none exists it is created. The returned value should not be freed. |
gboolean getPairsDrawn (PairsData *data);
A pair can or cannot be drawn, use this method to retrieve its state.
|
a PairsData object ; |
Returns : |
TRUE if pairs can be drawn. |
gpointer getPairsProperty (PairsData *data, const gchar *key);
Each pair can store some informations that can be retrieve by a string key.
This method is used to retrieve a stored value associated to the key key
.
|
a PairsData object ; |
|
a static string. |
Returns : |
a found value, or NULL if nothing is associated to the key .
If something is returned it should not be freed.
|
void foreachPairsData (foreachPairsFunc whatToDo, gpointer userData);
The way PairsData are stored in V_Sim is private and could changed between version. This method is used to apply some method each pairs.
|
a foreachPairsFunc() method ;
|
|
some user defined data. |
int createPairs (VisuData *dataObj);
This methods recreates the OpenGL list of the OpenGLExtension associated
to the pairs.
Thus it is the heart of the pairs drawing. When called, if a
valid PairsExtension has been set with setPairsMethod()
, it takes all the
nodes and compute all the distances between two different nodes. If this distance
is compatible with the distance of drawn pairs for the two elements it calls
the pairDefinitionFunc()
for these two nodes. WARNING! this method is very expensive
in computing cost.
|
the VisuData object to create pairs for. |
Returns : |
1 if the OpenGLAskForReDraw signal show be emitted or not. |
void (*initEndOpenGlPairsFunc) ();
Prototype of functions called at the beginning and the end of opengl pairs drawing. Such methods are useful to change some OpenGL variables such as lighting or blending...
void (*startEndPairsFunc) (VisuElement *ele1, VisuElement *ele2, PairsData *data);
Prototype of functions called at the beginning and
the end of drawing of each pairs types. ele1
and ele2
arguments are the two elements between the pair defined by data
is drawn.
This is useful to set some OpenGL definition specific to each pair, such
as the color for example.
|
a VisuElement object ; |
|
a VisuElement object ; |
|
a PairsData object. |
void (*pairDefinitionFunc) (VisuElement *ele1, VisuElement *ele2, PairsData *data, OpenGLView *view, double x1, double y1, double z1, double x2, double y2, double z2, float d2);
Prototype of function to draw a pair. Such function are called each time a pair
is drawn between the two points (x1
, y1
, z1
) and (x2
, y2
, z2
). The d2
argument
is the square distance between the two points.
|
a VisuElement object ; |
|
a VisuElement object ; |
|
a PairsData object ; |
|
a OpenGLView object, giving some constants describing the OpenGL scene ; |
|
a floating point value ; |
|
a floating point value ; |
|
a floating point value ; |
|
a floating point value ; |
|
a floating point value ; |
|
a floating point value ; |
|
a floating point value. |
struct PairsExtension_struct;
Structure to store pairs extensions. All fields are private and should not be accessed directly. This structure will not be public in near future, do not use it.
typedef struct PairsExtension_struct PairsExtension;
Common naming for PairsExtension_struct objects.
PairsExtension* pairsExtension_new (char *name, char *printName, char *description, int sensitive, initEndOpenGlPairsFunc init, initEndOpenGlPairsFunc stop, startEndPairsFunc start, startEndPairsFunc end, pairDefinitionFunc draw);
This creates a new pairs extension. Such an extension describes how to draw
links (called pairs) between elements. The sensitive
argument is to inform if
pairs must be redrawn when the OpenGL engine sends the OpenGLFacetteChanged signal.
|
name of the extension (must be non null) ; |
|
a string to label the method that can be safely translated ; |
|
a brief description of the extension (can be null) ; |
|
a boolean 0 or 1 ; |
|
a initEndOpenGlPairsFunc() method or NULL ;
|
|
a initEndOpenGlPairsFunc() method or NULL ;
|
|
a startEndPairsFunc() method or NULL ;
|
|
a startEndPairsFunc() method or NULL ;
|
|
a pairDefinitionFunc() method (not NULL).
|
Returns : |
the new PairsExtension or null if something wrong happens. |
void PairsExtension_free (PairsExtension *extension);
Free all the allocated attributes of the specified method.
|
the extension to delete. |
void registerPairsExtension (PairsExtension *extension);
A method used by user to registered a new extension.
|
an extension. |
int setPairsMethod (PairsExtension *extension);
Choose the method used to draw pairs. If necessary, createPairs()
are called.
|
a PairsExtension object. |
Returns : |
1 if the OpenGLAskForReDraw signal show be emitted or not. |
void setPairsAreOutOfDate ();
Use this method to change the internal flag that pairs should be rebuilt. It is useful when an extension of pairs has one of its parameters that has changed.
PairsExtension* getCurrentPairsMethods ();
If some process need to know the current PairsExtension. Such extension has
been set with setPairsMethod()
.
Returns : |
the current PairsExtension, NULL if none has been set. |
int isValidPairsExtension (PairsExtension *pairsModel);
Test if the given PairsExtension has been already registered by V_Sim.
|
a PairsExtension object. |
Returns : |
1 if the given extension is already stored. |
GList* getAllPairsMethods ();
Useful to know all PairsExtension.
Returns : |
a list of all the known PairsExtension. This list should be considered read-only. |
char* getNameOfPairsMethod (PairsExtension *extension);
All PairsExtension has a name.
|
a PairsExtension object. |
Returns : |
a string that is associated to the given PairsExtension. This string should not be freed. |
int initPairsModule ();
Initialise all the variable of this part. It calls all
the elements in listInitPairsFunc
(that stores the
init function of the pairs extensions). If these elements return
valid PairsExtension, they are registered through a call
to registerPairsExtension()
.
This method is called by the main program at the initialisation stage and
should not be called in others circonstempses.
Returns : |
1 if everything goes allright during the initialisation. |