Top | ![]() |
![]() |
![]() |
![]() |
VisuNodeArrayVisuNodeArray — Defines the elementary structure to store informations about an element in a box. |
struct | VisuNodeArray |
struct | VisuNodeArrayClass |
enum | VisuNodeArrayIterType |
struct | VisuNodeArrayIter |
VisuNodeProperty |
In V_Sim, elements are drawn in a box. The VisuNode structure is used to represent an instance of an element position somewhere in the box. This element can have several characteristics such as its translation or its visibility.
All nodes are stored in a VisuData object in a two dimensional array. The first dimension is indexed by the VisuElement of the node and the second corresponds to the number of this node for this element. When a node is own by a VisuData, the two integers, that control the indexes in this array, are not negative. See the VisuNode structure for further explanations.
The only basic informations own by the VisuNode structure is
basicaly its position. To add further informations (such as
orientation for the spin), define a node property using
visu_node_array_property_newPointer()
.
void visu_node_newValues (VisuNode *node
,float xyz[3]
);
Set the coordinates and set all other values to default.
void visu_node_copy (VisuNode *nodeTo
,VisuNode *nodeFrom
);
Copy all attributes of the object nodeFrom
to nodeTo
.
gboolean visu_node_setVisibility (VisuNode *node
,gboolean visibility
);
This method is used to turn on or off the drawing of the specified node.
gboolean
visu_node_getVisibility (VisuNode *node
);
This method is used get the status of the drawing state of a node.
gboolean visu_node_setCoordinates (VisuNode *node
,float xyz[3]
);
This method is used to change coordinates of node
.
Since: 3.7
void (*VisuNodeArrayElementPropertyInit) (VisuElement *element
,GValue *value
);
Prototype of routine used to initialise an element property.
Since: 3.7
void visu_node_array_allocate (VisuNodeArray *array
,GArray *elements
,GArray *nNodes
);
Reallocate the internal arrays to match elements
and nNodes
.
array |
a VisuNodeArray object. |
|
elements |
the size of nNodes. |
[in][element-type VisuElement*] |
nNodes |
an array giving the number of nodes per element. |
[in][element-type guint] |
void visu_node_array_allocateByNames (VisuNodeArray *array
,GArray *nNodesPerElement
,GArray *elementNames
);
This method allocates the storing part of the given VisuNodeArray structure and store all the VisuNodes.
array |
a VisuNodeArray object; |
|
nNodesPerElement |
number of VisuNode per VisuElement;. |
[in][element-type guint] |
elementNames |
names of elements;. |
[in][element-type utf8] |
void
visu_node_array_freeNodes (VisuNodeArray *nodeArray
);
Deallocate all nodes of the object and related properties but keep the object alive.
void visu_node_array_allocateNodesForElement (VisuNodeArray *array
,guint eleId
,guint nNodes
);
This routine is used to allocate space for nNodes
of a
VisuElement. This VisuElement is identified by its internal id,
see visu_node_array_getElementId()
. If this VisuElement has
already enough space in this array
, nothing is done, otherwise
space is reallocated.
array |
a VisuNodeArray object ; |
|
eleId |
an internal VisuElement id ; |
|
nNodes |
a positive number of nodes. |
Since: 3.7
void visu_node_array_populationIncrease (VisuNodeArray *nodeArray
,GArray *ids
);
Emits the “PopulationIncrease” signal.
Since: 3.8
void visu_node_array_removeNodes (VisuNodeArray *nodeArray
,GArray *nodeNumbers
);
Remove the given VisuNode from the nodeArray
. The properties
are also updated.
nodeArray |
a VisuNodeArray object. |
|
nodeNumbers |
an array of integers (negative terminated). |
[element-type guint] |
void visu_node_array_removeNodesOfElement (VisuNodeArray *nodeArray
,VisuElement *element
);
Remove all the VisuNode from the element element
. The properties
are also updated.
Since: 3.7
gboolean
visu_node_array_removeAllDuplicateNodes
(VisuNodeArray *nodeArray
);
Remove all nodes that are not original in the box.
gint visu_node_array_getOriginal (VisuNodeArray *nodeArray
,guint nodeId
);
Test if the given nodeId
is an original or a replica for the
periodisation.
gboolean visu_node_array_setOriginal (VisuNodeArray *nodeArray
,guint nodeId
);
Make nodeId
an original node.
gboolean visu_node_array_compareElements (VisuNodeArray *data1
,VisuNodeArray *data2
);
This method is used to compare the composition of the given two VisuData objects. The test is only done on VisuElement lists.
TRUE if the two objects contains exactly the same VisuElement objects (not one more or one less or one different), FALSE otherwise.
VisuElement * visu_node_array_getElement (VisuNodeArray *data
,const VisuNode *node
);
This routine gets the VisuElement the node
belongs to.
Since: 3.7
VisuNode * visu_node_array_setElement (VisuNodeArray *data
,VisuNode *node
,const VisuElement *element
);
Change the nature of the VisuElement of node
to be element
.
Since: 3.8
gboolean visu_node_array_containsElement (const VisuNodeArray *array
,const VisuElement *element
);
Tests if element
is contained in array
. element
may be part of
array
but without nodes.
Since: 3.8
gint visu_node_array_getElementId (const VisuNodeArray *array
,const VisuElement *element
);
This routines returns the internal id used to represent element
,
or -1 if not found.
Since: 3.7
guint
visu_node_array_getNNodes (const VisuNodeArray *array
);
This routines returns the number of VisuNode stored in array
.
Since: 3.7
guint
visu_node_array_getNOriginalNodes (const VisuNodeArray *array
);
This routines returns the number of original VisuNode stored in array
.
Since: 3.7
guint visu_node_array_getNElements (VisuNodeArray *array
,gboolean physical
);
The parameter array
stores several VisuNode of VisuElement. This
routine is used to get the number of VisuElement that are used by
this array
. Depending on physical
value, the number of
VisuElement representing physical element or not is retrieved. The
actual returned number of VisuElement take into account only
elements with a positive number of nodes.
Since: 3.7
GArray * visu_node_array_setElementProperty (VisuNodeArray *data
,const gchar *name
,VisuNodeArrayElementPropertyInit init
);
Create a new array to stores properties related to elements. If the
property name
already exists the previous one is destroyed. The
init
routine is called for each VisuElement of the data
.
data |
a VisuNodeArray object. |
|
name |
a string to identify the property. |
|
init |
an init routine. |
[scope call] |
Since: 3.7
GArray * visu_node_array_getElementProperty (VisuNodeArray *data
,const gchar *name
);
This routine is used to retrieve an array of GValue for each
element of the data
array.
an array of GValue, indexed by the id of
each VisuElement of data
.
[transfer none][element-type GLib.Value]
Since: 3.7
VisuNode * visu_node_array_getNewNode (VisuNodeArray *nodeArray
,const VisuElement *element
);
Return the location of an unstored node for the given VisuElement. The returned node is then added in the list of used nodes.
Since: 3.8
VisuNode * visu_node_array_getNewNodeForId (VisuNodeArray *nodeArray
,guint iEle
);
Return the location of an unstored node for the given VisuElement. The returned node is then added in the list of used nodes.
gboolean visu_node_array_switchNumber (VisuNodeArray *nodeArray
,guint from
,guint to
);
Two nodes of nodeArray
switches their number.
Since: 3.6
VisuNode * visu_node_array_copyNode (VisuNodeArray *nodeArray
,VisuNode *node
);
Return the location of an unstored node that is the deep copy of the given node. The returned node is then added in the list of used nodes.
VisuNode * visu_node_array_getFromId (VisuNodeArray *array
,guint number
);
This methods retrieves the VisuNode identified by the integer number
.
The number must be strictly positive. No error is raised if no node corresponds
to the given number.
gboolean visu_node_array_setNodeVisibility (VisuNodeArray *nodeArray
,guint id
,gboolean status
);
Change the visibility of node id
in nodeArray
. If id
is out of
bound, nothing is done and no error raised. If visibility is indeed
changed, then “VisibilityChanged” signal is emitted.
Since: 3.8
void visu_node_array_shiftNodes (VisuNodeArray *array
,const GArray *ids
,const float delta[3]
);
Apply delta
on the coordinates of every nodes in ids
.
array |
a VisuNodeArray object. |
|
ids |
a set of VisuNode ids. |
[element-type uint] |
delta |
a shift in cartesian coordinates. |
[array fixed-size=3] |
Since: 3.8
void visu_node_array_moveNodes (VisuNodeArray *array
,const GArray *ids
,const GArray *xyz
);
Apply translations on all nodes defined by ids
. Displacements are
read from xyz
which is an array containing as many float triplets
as nodes in ids.
array |
a VisuNodeArray object. |
|
ids |
a set of VisuNode ids. |
[element-type uint] |
xyz |
a set of cartesian displacements. |
[element-type float] |
Since: 3.8
void visu_node_array_rotateNodes (VisuNodeArray *array
,const GArray *ids
,const float axis[3]
,const float center[3]
,float angle
);
Apply the rotation defined by angle
along axis
passing by center
to all nodes referenced in ids
.
array |
a VisuNodeArray object. |
|
ids |
a set of VisuNode ids. |
[element-type uint] |
axis |
an axis orientation. |
[array fixed-size=3] |
center |
point coordinates. |
[array fixed-size=3] |
angle |
an angle in degrees. |
Since: 3.8
VisuNodeProperty * visu_node_array_property_newPointer (VisuNodeArray *nodeArray
,const char *key
,GFunc freeFunc
,GCopyFunc newAndCopyFunc
,gpointer user_data
);
This method creates and allocates a new area to store nodes associated data that
can be retrieve with the key
. These data are pointers on allocated memory
locations. When the property is removed with the visu_node_freePropertry (or the
associated VisuNodeArray is free) the area is free and freeFunc
is called for
each token (or g_free()
if freeFunc
is NULL).
The method newAndCopyFunc
is used when the number of nodes is increased,
if the const gpointer of the GCopyFunc is not NULL, then we require a copy,
if it is NULL, then the routine must create a new token with
default values.
If the property already exists, it is returned.
nodeArray |
a VisuNodeArray object ; |
|
key |
a string ; |
|
freeFunc |
a method to free each token (can be NULL). |
[allow-none][scope call] |
newAndCopyFunc |
a method to create or copy each token. |
[scope call] |
user_data |
a user defined pointer that will be given to the free and copy routine. |
[closure] |
VisuNodeProperty * visu_node_array_property_newFloatArray (VisuNodeArray *nodeArray
,const char *key
,guint len
);
This method creates and allocates a new area to store nodes associated data that
can be retrieve with the key
. These data are constant float arrays
of length len
.
If the property already exists, it is returned.
nodeArray |
a VisuNodeArray object ; |
|
key |
a string ; |
|
len |
the number of floats to be stored per node. |
Since: 3.8
VisuNodeProperty * visu_node_array_property_newInteger (VisuNodeArray *nodeArray
,const char *key
);
This method creates and allocates a new area to store nodes associated integer
values. This is the same than visu_node_array_property_newPointer()
but for static
integers instead of pointers as data.
void visu_node_array_freeProperty (VisuNodeArray *nodeArray
,const char *key
);
This method free the given property and all associated data.
void visu_node_array_traceProperty (VisuNodeArray *array
,const gchar *id
);
This is a debug method. It outputs on stderr the values for all
nodes of the property id
.
VisuNodeProperty * visu_node_array_getProperty (VisuNodeArray *nodeArray
,const char *key
);
This method is used to retrieve the node property associated to the given key
.
#define visu_node_setpropertyValue(nodeArray, node, key, value)
This method is used to store some values associated with
the given node
of the given nodeArray
. These values can be pointers to
anything allocated (will be free automatically when the property is deleted) or
they can be static values. This depends on the construction of the node property.
These values are described by the key
, and can be retrieved with the
visu_node_array_getPropertyValue()
method.
See visu_node_property_setValue()
to directly set a value associated to a node.
nodeArray |
a VisuNodeArray object ; |
|
node |
a VisuNode object ; |
|
key |
a string ; |
|
value |
A GValue pointer this the value to be stored. |
void visu_node_property_setValue (VisuNodeProperty *nodeProp
,const VisuNode *node
,const GValue *value
);
This method is used to store some values associated with
the given node
of the given nodeArray
. These values can be pointers to
anything allocated (will be free automatically when the property is deleted) or
they can be static values. This depends on the construction of the node property.
These values can be retrieved with the visu_node_property_getValue()
method.
See visu_node_array_getProperty()
to get a property by its name.
nodeProp |
a VisuNodeProperty object ; |
|
node |
a VisuNode object ; |
|
value |
A GValue pointer this the value to be stored. |
#define visu_node_array_getPropertyValue(nodeArray, node, key, value)
This method is used to retrieve some data associated to
the specified node
, stored in the given data
. These return data
should not be freed after used. The read value is stored in the given
GValue pointer. This GValue must be of the right type, depending on the
creation of the VisuNodeProperty.
nodeArray |
a VisuNodeArray object ; |
|
node |
a VisuNode object ; |
|
key |
a string ; |
|
value |
an initialise GValue location. |
GValue * visu_node_property_getValue (const VisuNodeProperty *nodeProp
,const VisuNode *node
,GValue *value
);
This method is used to retrieve some data associated to
the specified node
, stored in the given data
. These return data
should not be freed after used. The read value is stored in the given
GValue pointer. This GValue must be of the right type, depending on the
creation of the VisuNodeProperty.
nodeProp |
a VisuNodeArray object ; |
|
node |
a VisuNode object ; |
|
value |
an initialise GValue location. |
VisuNodeArray *
visu_node_property_getArray (const VisuNodeProperty *nodeProp
);
Retrieve the VisuNodeArray nodeProp
is attached to.
Since: 3.8
void
visu_node_property_reset (VisuNodeProperty *prop
);
Reset to zero all values, deallocating allocated memory, if any.
Since: 3.8
gboolean (*VisuNodeArrayIterFunc) (VisuNodeArray *array
,const VisuNodeArrayIter *iter
,gpointer data
);
Prototype of function that evaluates a boolean condition on a given node in a node iteration.
array |
the VisuNodeArray object the function deals with. |
[transfer full] |
iter |
the VisuNodeArrayIter object the function works on. |
|
data |
some user data. |
[closure] |
Since: 3.8
void visu_node_array_iter_new (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Set values to a VisuNodeArrayIter object to iterate over nodes. Its contain is initialised with the array size (number of elements, number of nodes per element...).
array |
a VisuNodeArray object ; |
|
iter |
an alocated iterator. |
[out caller-allocates][transfer full] |
void visu_node_array_iterStart (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Initialise the node and element internal pointers for a run over the nodes.
void visu_node_array_iterStartVisible (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Initialise the node and element internal pointers for a run over the visible nodes (see visu_node_array_iterNextVisible).
void visu_node_array_iterStartNumber (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Initialise the node and element internal pointers for a run following the node oder.
void visu_node_array_iterStartList (VisuNodeArray *array
,VisuNodeArrayIter *iter
,GList *lst
);
Set values to a VisuNodeArrayIter object to iterate over nodes of the given list.
array |
a VisuNodeArray object ; |
|
iter |
an alocated iterator. |
[out caller-allocates][transfer full] |
lst |
a list of node ids to iterate on. |
[element-type guint][transfer none] |
Since: 3.7
void visu_node_array_iterStartArray (VisuNodeArray *array
,VisuNodeArrayIter *iter
,GArray *arr
);
Set values to a VisuNodeArrayIter object to iterate over nodes of the given array.
array |
a VisuNodeArray object ; |
|
iter |
an alocated iterator. |
[out caller-allocates][transfer full] |
arr |
an array of node ids to iterate on. |
[element-type guint][transfer full] |
Since: 3.8
void visu_node_array_iterRestartNode (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
The element internal pointer must be associated. Then, it returns the node pointer to the first node for this element.
void visu_node_array_iterWhere (VisuNodeArray *array
,VisuNodeArrayIter *iter
,VisuNodeArrayIterFunc where
,gpointer data
);
Starts iter
to iterate on nodes of array
, when the condition
defined by where
evaluates to TRUE. iter
is then to be used with
visu_node_array_iterNextArray()
.
array |
a VisuNodeArray object ; |
|
iter |
an alocated iterator. |
[out caller-allocates][transfer full] |
where |
the function to evaluate on each node. |
[closure data][scope call] |
data |
user data. |
[closure][allow-none] |
Since: 3.8
void visu_node_array_iterNext (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Modify node and element internal pointers to the next node, or NULL if none remains.
void visu_node_array_iterNextNode (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Modify node internal pointer to the next node, or NULL if
none remains. Contrary to visu_node_array_iterNext()
it does not go to the
next element if one exists.
void visu_node_array_iterNextNodeNumber (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Modify node internal pointer to the next node, increasing the id of the current node. The element internal pointer is also updated accordingly. If no more nodes exist after the given one, node and element internal pointers are set to NULL.
void visu_node_array_iterNextNodeOriginal (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Modify node internal pointer to the next original node, or NULL if
none remains. Contrary to visu_node_array_iterNext()
it does not go to the
next element if one exists.
Since: 3.6
void visu_node_array_iterNextList (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Modify node and element internal pointers to the next node from the starting list, or NULL if none remains.
Since: 3.7
void visu_node_array_iterNextArray (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Modify node and element internal pointers to the next node from the starting array, or NULL if none remains.
Since: 3.8
void visu_node_array_iterNextElement (VisuNodeArray *array
,VisuNodeArrayIter *iter
,gboolean allowEmpty
);
Modify element internal pointer to the next element and set node
to the first one, or NULL if none remains. If allowEmpty
is TRUE,
this iterator may return an element with no nodes, otherwise, it
skips elements with no nodes.
void visu_node_array_iterNextVisible (VisuNodeArray *array
,VisuNodeArrayIter *iter
);
Go to the next rendered node (changing element if required).
gboolean
visu_node_array_iter_next (VisuNodeArrayIter *iter
);
Run the iterator to go to next item.
Since: 3.6
gboolean visu_node_array_iter_next2 (VisuNodeArrayIter *iter1
,VisuNodeArrayIter *iter2
);
Iterator to run on a pair of different nodes.
Since: 3.6
struct VisuNodeArrayClass { VisuObjectClass parent; };
Class structure of VisuNodeArray objects.
The kind of iterator to be used on VisuData objects.
run on nodes, as V_Sim internal storage, fastest. |
||
run on nodes as entered in the input file. |
||
run on nodes as given in a GList. |
||
run on nodes as given in a GArray. |
||
run on visible nodes only (internal sort). |
||
run on original nodes only (internal sort). |
||
run on all nodes of a specific element. |
||
run on elements only. |
Since: 3.6
struct VisuNodeArrayIter { VisuNodeArray *array; guint idMax; guint nAllStoredNodes; guint nElements; guint iElement; guint nStoredNodes; VisuNode *node; VisuElement *element; VisuNodeArrayIterType type; gboolean init; GList *itLst; GArray *arr; guint itArr; };
This structure is an iterator over the nodes of a VisuData object.
Create it with visu_node_array_iter_new()
. Then the numbers are allocated and
correspond to the value of the VisuData object. Use visu_node_array_iterStart()
to initialise the iterator for a run over the nodes, visu_node_array_iterNext()
to associate node
and element
to the next node, or NULL if there is no
more node to run over.
VisuNodeArray * |
a pointer the iterator is associated to ; |
|
guint |
current higher id used to identified nodes. |
|
guint |
the total number of stored nodes for the associated VisuData ; |
|
guint |
the number of VisuElement for the associated VisuData ; |
|
guint |
the index corresponding to |
|
guint |
the number of stored nodes for the current |
|
VisuNode * |
a pointer on a current node ; |
|
VisuElement * |
a pointer on a current element. |
|
VisuNodeArrayIterType |
the kind of iterator, see VisuNodeArrayIterType. |
|
gboolean |
an internal flag. |
|
GList * |
an internal list iterator. |
|
GArray * |
an iternal list of nodes to iterate on. |
|
guint |
an internal iterator on array. |
typedef struct _VisuNodeProperty VisuNodeProperty;
This structure defines a storage for one property for each node of a given
VisuNodeArray. Use visu_node_array_property_newPointer()
or
visu_node_array_property_newInteger()
to create one property.
“n-original-nodes”
property“n-original-nodes” guint
total number of original nodes.
Flags: Read
Default value: 0
“ElementMaskableChanged”
signalvoid user_function (VisuNodeArray *nodes, VisuElement *ele, gpointer user_data)
Gets emitted when the maskable characteristic of one element changes.
nodes |
the object which received the signal ; |
|
ele |
the VisuElement that has its visibility changed |
|
user_data |
user data set when the signal handler was connected. |
Flags: No Hooks
Since: 3.8
“ElementVisibilityChanged”
signalvoid user_function (VisuNodeArray *nodes, VisuElement *ele, gpointer user_data)
Gets emitted when the visibility characteristic of one element changes.
nodes |
the object which received the signal ; |
|
ele |
the VisuElement that has its visibility changed |
|
user_data |
user data set when the signal handler was connected. |
Flags: No Hooks
Since: 3.8
“PopulationDecrease”
signalvoid user_function (VisuNodeArray *nodes, GArray *ids, gpointer user_data)
Gets emitted when the number of nodes has changed,
decreasing. ids
contains all removed ids.
When emitted, nodes have already been removed, so no external
routines should keep pointers on these nodes.
nodes |
the object which received the signal ; |
|
ids |
an array of VisuNode ids. |
[element-type guint][array] |
user_data |
user data set when the signal handler was connected. |
Flags: No Hooks
Since: 3.4
“PopulationIncrease”
signalvoid user_function (VisuNodeArray *nodes, GArray *ids, gpointer user_data)
Gets emitted when the number of nodes has changed,
increasing. ids
contains all new ids.
nodes |
the object which received the signal ; |
|
ids |
an array of VisuNode ids. |
[element-type guint][array] |
user_data |
user data set when the signal handler was connected. |
Flags: No Hooks
Since: 3.4
“position-changed”
signalvoid user_function (VisuNodeArray *nodes, GArray *ids, gpointer user_data)
Gets emitted when one or more nodes have moved, because of translations or because the user has moved them manually.
nodes |
the object which received the signal ; |
|
ids |
ids of moved nodes. |
[allow-none][element-type guint] |
user_data |
user data set when the signal handler was connected. |
Flags: No Hooks
Since: 3.2