## visu_nodes visu_nodes — Defines the elementary structure to store informations about an element in a box. |

## Synopsis

    typedef             VisuNode;
    void                visuNodeCopy                        (VisuNode *nodeTo,
                                                             VisuNode *nodeFrom);
    gboolean            visuNodeGet_visibility              (VisuNode *node);
    int                 visuNodeSet_visibility              (VisuNode *node,
                                                             gboolean visibility);

    VisuNodeArray*      visuNodeNew_nodes                   (unsigned int nTypes,
                                                             unsigned int *nNodes);
    void                visuNodeFree_nodes                  (VisuNodeArray *nodeArray);
    void                visuNodeAllocate_newNodes           (VisuNodeArray *nodeArray,
                                                             unsigned int iEle,
                                                             unsigned int step);
    VisuNode*           visuNodeGet_newNode                 (VisuNodeArray *nodeArray,
                                                             unsigned int iEle);
    VisuNode*           visuNodeGet_copyNode                (VisuNodeArray *nodeArray,
                                                             VisuNode *node);
    void                visuNodeNew_values                  (VisuNode *node,
                                                             float xyz[3]);
    void                visuNodeRemove_nodes                (VisuNodeArray *nodeArray,
                                                             int *nodeNumbers);
    gboolean            visuNodeRemove_allDuplicateNodes    (VisuNodeArray *nodeArray,
                                                             int **nodeNumbers);

    typedef             VisuNodeProperty;
    struct              VisuNodeProperty_struct;
    void                visuNodeFree_property               (VisuNodeArray *nodeArray,
                                                             const char *key);
    VisuNodeProperty*   visuNodeGet_property                (VisuNodeArray *nodeArray,
                                                             const char *key);
    #define             visuNodeSet_propertyValue           (nodeArray, node, key, value)
    #define             visuNodeGet_propertyValue           (nodeArray, node, key, value)
    VisuNodeProperty*   visuNodeNew_intProperty             (VisuNodeArray *nodeArray,
                                                             const char *key);
    VisuNodeProperty*   visuNodeNew_pointerProperty         (VisuNodeArray *nodeArray,
                                                             const char *key,
                                                             GFunc freeFunc,
                                                             GCopyFunc newAndCopyFunc,
                                                             gpointer user_data);
    GValue*             visuNodePropertyGet_value           (VisuNodeProperty *nodeProp,
                                                             VisuNode *node,
                                                             GValue *value);
    void                visuNodePropertySet_value           (VisuNodeProperty *nodeProp,
                                                             VisuNode *node,
                                                             GValue *value);
    void                visuNodeTrace_property              (VisuNodeArray *array,
                                                             const gchar *id);

## Description

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), the node must be attached to a VisuData and then `visuDataAdd_nodeProperty()` can be used.

## Details

### VisuNode

    typedef struct node_struct VisuNode;

Short way to address node_struct objects.

### visuNodeCopy ()

    void                visuNodeCopy                        (VisuNode *nodeTo,
                                                             VisuNode *nodeFrom);

Copy all attributes of the object `nodeFrom` to `nodeTo`.

`nodeTo` : | an allocated VisuNode object ;
`nodeFrom` : | an allocated VisuNode object.

### visuNodeGet_visibility ()

    gboolean            visuNodeGet_visibility              (VisuNode *node);

This method is used get the status of the drawing state of a node.

`node` : | a VisuNode object.
Returns : | true if the node is rendered, false otherwise.

### visuNodeSet_visibility ()

    int                 visuNodeSet_visibility              (VisuNode *node,
                                                             gboolean visibility);

This method is used to turn on or off the drawing of the specified node.

`node` : | a VisuNode object ;
`visibility` : | a boolean.
Returns : | true if the calling method should recreate the node list with a call to the `visuData_createAllNodes()` method.

### visuNodeNew_nodes ()

    VisuNodeArray*      visuNodeNew_nodes                   (unsigned int nTypes,
                                                             unsigned int *nNodes);

Create a new VisuNodeArray structure, allocate all necessary values.

`nTypes` : | the size of nNodes.
`nNodes` : | an array giving the number of nodes per element.
Returns : | a newly created VisuNodeArray object.

### visuNodeFree_nodes ()

    void                visuNodeFree_nodes                  (VisuNodeArray *nodeArray);

Free the given object and all associated memory.

`nodeArray` : | a VisuNodeArray object.

### visuNodeAllocate_newNodes ()

    void                visuNodeAllocate_newNodes           (VisuNodeArray *nodeArray,
                                                             unsigned int iEle,
                                                             unsigned int step);

When a new node is required, using `visuNodeGet_newNode()` or `visuNodeGet_copyNode()` the storing arrays are expand automatically with a fixed increment. If the user wants to control this increment, he should call this routine before the `get()` ones with the appropriated `step` value.

`nodeArray` : | a VisuNodeArray object ;
`iEle` : | the id of a VisuElement to expand the number of allocated nodes ;
`step` : | the number of newly allocated nodes.

### visuNodeGet_newNode ()

    VisuNode*           visuNodeGet_newNode                 (VisuNodeArray *nodeArray,
                                                             unsigned int iEle);

Return the location of an unstored node for the given VisuElement. The returned node is then added in the list of used nodes.

`nodeArray` : | a VisuNodeArray object ;
`iEle` : | an integer between 0 and `nodeArray->ntypes` - 1.
Returns : | the location of a newly used node.

### visuNodeGet_copyNode ()

    VisuNode*           visuNodeGet_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.

`nodeArray` : | a VisuNodeArray object ;
`node` : | a node of the given VisuNodeArray.
Returns : | the location of a newly used node.

### visuNodeNew_values ()

    void                visuNodeNew_values                  (VisuNode *node,
                                                             float xyz[3]);

Set the coordinates and set all other values to default.

`node` : | an allocated VisuNode object ;
`xyz` : | the coordinates to set.

### visuNodeRemove_nodes ()

    void                visuNodeRemove_nodes                (VisuNodeArray *nodeArray,
                                                             int *nodeNumbers);

Remove the given VisuNode from the `nodeArray`. The properties are also updated.

`nodeArray` : | a VisuNodeArray object.
`nodeNumbers` : | an array of integers (negative terminated).

### visuNodeRemove_allDuplicateNodes ()

    gboolean            visuNodeRemove_allDuplicateNodes    (VisuNodeArray *nodeArray,
                                                             int **nodeNumbers);

Remove all nodes that are not original in the box. The list of removed nodes ids are stored in `nodeNumbers`. This array is allocated and should be freed with `g_free()`. If no nodes are removed, this array is not allocated.

`nodeArray` : | a VisuNodeArray object.
`nodeNumbers` : | a location to create an arry of int.
Returns : | TRUE if some nodes have been removed (and `nodeNumbers` allocated).

### VisuNodeProperty

    typedef struct VisuNodeProperty_struct VisuNodeProperty;

A convenient name for VisuNodeProperty_struct structures.

### struct VisuNodeProperty_struct

    struct VisuNodeProperty_struct;

This structure defines a storage for one property for each node of a given VisuNodeArray. Use `visuNodeNew_property()` to create one property.

### visuNodeFree_property ()

    void                visuNodeFree_property               (VisuNodeArray *nodeArray,
                                                             const char *key);

This method free the given property and all associated data.

`nodeArray` : | a VisuNodeArray object.
`key` : | the name of the property to be removed.

### visuNodeGet_property ()

    VisuNodeProperty*   visuNodeGet_property                (VisuNodeArray *nodeArray,
                                                             const char *key);

This method is used to retrieve the node property associated to the given `key`.

`nodeArray` : | a VisuNodeArray object ;
`key` : | a string.
Returns : | a VisuNodeProperty.

### visuNodeSet_propertyValue()

    #define             visuNodeSet_propertyValue(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 `visuNodeGet_propertyValue()` method.

See `visuNodePropertySet_value()` 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.

### visuNodeGet_propertyValue()

    #define             visuNodeGet_propertyValue(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.
Returns : | some data associated to the key, stored the given GValue location.

### visuNodeNew_intProperty ()

    VisuNodeProperty*   visuNodeNew_intProperty             (VisuNodeArray *nodeArray,
                                                             const char *key);

This method creates and allocates a new area to store nodes associated integer values. This is the same than `visuNodeNew_pointerProperty()` but for static integers instead of pointers as data.

`nodeArray` : | a VisuNodeArray object ;
`key` : | a string.
Returns : | the newly created VisuNodeProperty object.

### visuNodeNew_pointerProperty ()

    VisuNodeProperty*   visuNodeNew_pointerProperty         (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 visuNodeFree_propertry (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.

`nodeArray` : | a VisuNodeArray object ;
`key` : | a string ;
`freeFunc` : | a method to free each token (can be NULL).
`newAndCopyFunc` : | a method to create or copy each token.
`user_data` : | a user defined pointer that will be given to the free and copy routine.
Returns : | the newly created VisuNodeProperty object.

### visuNodePropertyGet_value ()

    GValue*             visuNodePropertyGet_value           (VisuNodeProperty *nodeProp,
                                                             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.
Returns : | some data associated to the key, stored the given GValue location.

### visuNodePropertySet_value ()

    void                visuNodePropertySet_value           (VisuNodeProperty *nodeProp,
                                                             VisuNode *node,
                                                             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 `visuNodePropertyGet_value()` method.

See `visuNodeGet_property()` 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.

### visuNodeTrace_property ()

    void                visuNodeTrace_property              (VisuNodeArray *array,
                                                             const gchar *id);

This is a debug method. It outputs on stderr the values for all nodes of the property `id`.

`array` : | a VisuNodeArray object ;
`id` : | a property name.