1 /*   EXTRAITS DE LA LICENCE
2 	Copyright CEA, contributeurs : Damien
3 	CALISTE, laboratoire L_Sim, (2015-2019)
4 
5 	Adresse mèl :
6 	CALISTE, damien P caliste AT cea P fr.
7 
8 	Ce logiciel est un programme informatique servant à visualiser des
9 	structures atomiques dans un rendu pseudo-3D.
10 
11 	Ce logiciel est régi par la licence CeCILL soumise au droit français et
12 	respectant les principes de diffusion des logiciels libres. Vous pouvez
13 	utiliser, modifier et/ou redistribuer ce programme sous les conditions
14 	de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
15 	sur le site "http://www.cecill.info".
16 
17 	Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
18 	pris connaissance de la licence CeCILL, et que vous en avez accepté les
19 	termes (cf. le fichier Documentation/licence.fr.txt fourni avec ce logiciel).
20 */
21 
22 /*   LICENCE SUM UP
23 	Copyright CEA, contributors : Damien
24 	CALISTE, laboratoire L_Sim, (2015-2019)
25 
26 	E-mail address:
27 	CALISTE, damien P caliste AT cea P fr.
28 
29 	This software is a computer program whose purpose is to visualize atomic
30 	configurations in 3D.
31 
32 	This software is governed by the CeCILL  license under French law and
33 	abiding by the rules of distribution of free software.  You can  use,
34 	modify and/ or redistribute the software under the terms of the CeCILL
35 	license as circulated by CEA, CNRS and INRIA at the following URL
36 	"http://www.cecill.info".
37 
38 	The fact that you are presently reading this means that you have had
39 	knowledge of the CeCILL license and that you accept its terms. You can
40 	find a copy of this licence shipped with this software at Documentation/licence.en.txt.
41 */
42 
43 #ifndef NODEPROP_H
44 #define NODEPROP_H
45 
46 #include <glib.h>
47 #include <glib-object.h>
48 
49 #include <visu_nodes.h>
50 
51 G_BEGIN_DECLS
52 
53 #define VISU_TYPE_NODE_VALUES	         (visu_node_values_get_type ())
54 #define VISU_NODE_VALUES(obj)	         (G_TYPE_CHECK_INSTANCE_CAST(obj, VISU_TYPE_NODE_VALUES, VisuNodeValues))
55 #define VISU_NODE_VALUES_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST(klass, VISU_TYPE_NODE_VALUES, VisuNodeValuesClass))
56 #define VISU_IS_NODE_VALUES(obj)         (G_TYPE_CHECK_INSTANCE_TYPE(obj, VISU_TYPE_NODE_VALUES))
57 #define VISU_IS_NODE_VALUES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, VISU_TYPE_NODE_VALUES))
58 #define VISU_NODE_VALUES_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS(obj, VISU_TYPE_NODE_VALUES, VisuNodeValuesClass))
59 
60 /**
61  * VisuNodeValuesPrivate:
62  *
63  * Private data for #VisuNodeValues objects.
64  */
65 typedef struct _VisuNodeValuesPrivate VisuNodeValuesPrivate;
66 
67 /**
68  * VisuNodeValues:
69  *
70  * Common name to refer to a #_VisuNodeValues.
71  */
72 typedef struct _VisuNodeValues VisuNodeValues;
73 struct _VisuNodeValues
74 {
75   VisuObject parent;
76 
77   VisuNodeValuesPrivate *priv;
78 };
79 
80 /**
81  * VisuNodeValuesFromString:
82  * @vals: a #VisuNodeValues object.
83  * @node: a #VisuNode pointer.
84  * @string: a string.
85  *
86  * Prototype of functions used to parse @string and store its content
87  * for @node in @vals.
88  *
89  * Since: 3.8
90  *
91  * Returns: TRUE on success.
92  */
93 typedef gboolean (*VisuNodeValuesFromString)(VisuNodeValues *vals,
94                                              VisuNode *node,
95                                              const gchar *string);
96 /**
97  * VisuNodeValuestoString:
98  * @vals: a #VisuNodeValues object.
99  * @node: a #VisuNode pointer.
100  *
101  * Prototype of functions used to stringify the node values of @node
102  * from @vals.
103  *
104  * Since: 3.8
105  *
106  * Returns: (transfer full): a newly created string representing the
107  * values of @node.
108  */
109 typedef gchar* (*VisuNodeValuestoString)(const VisuNodeValues *vals,
110                                          const VisuNode *node);
111 /**
112  * VisuNodeValuesSetAt:
113  * @vals: a #VisuNodeValues object.
114  * @node: a #VisuNode pointer.
115  * @value: a value.
116  *
117  * Prototype of functions used to store the content of @value for
118  * @node in @vals.
119  *
120  * Since: 3.8
121  *
122  * Returns: TRUE on success.
123  */
124 typedef gboolean (*VisuNodeValuesSetAt)(VisuNodeValues *vals,
125                                         const VisuNode *node,
126                                         GValue *value);
127 /**
128  * VisuNodeValuesGetAt:
129  * @vals: a #VisuNodeValues object.
130  * @node: a #VisuNode pointer.
131  * @value: a value.
132  *
133  * Prototype of functions used to store in @value the values
134  * associated to @node from @vals.
135  *
136  * Since: 3.8
137  *
138  * Returns: TRUE on success.
139  */
140 typedef gboolean (*VisuNodeValuesGetAt)(const VisuNodeValues *vals,
141                                         const VisuNode *node,
142                                         GValue *value);
143 
144 /**
145  * VisuNodeValuesClass:
146  * @parent: private.
147  * @parse: a routine to get values from a string.
148  * @serialize: a routine to write format into a string.
149  * @setAt: a routine to store values at a node.
150  * @getAt: a routine to get values at a node.
151  *
152  * Common name to refer to a #_VisuNodeValuesClass.
153  */
154 typedef struct _VisuNodeValuesClass VisuNodeValuesClass;
155 struct _VisuNodeValuesClass
156 {
157   VisuObjectClass parent;
158 
159   VisuNodeValuesFromString parse;
160   VisuNodeValuestoString   serialize;
161 
162   VisuNodeValuesSetAt setAt;
163   VisuNodeValuesGetAt getAt;
164 };
165 
166 /**
167  * visu_node_values_get_type:
168  *
169  * This method returns the type of #VisuNodeValues, use
170  * VISU_TYPE_NODE_VALUES instead.
171  *
172  * Since: 3.8
173  *
174  * Returns: the type of #VisuNodeValues.
175  */
176 GType visu_node_values_get_type(void);
177 
178 VisuNodeValues* visu_node_values_new(VisuNodeArray *arr,
179                                      const gchar *label,
180                                      GType type, guint dim);
181 gboolean visu_node_values_fromArray(VisuNodeValues *vals, const VisuNodeArray *arr);
182 
183 const gchar* visu_node_values_getLabel(const VisuNodeValues *vals);
184 guint visu_node_values_getDimension(const VisuNodeValues *vals);
185 
186 void visu_node_values_setEditable(VisuNodeValues *vals, gboolean status);
187 gboolean visu_node_values_getEditable(const VisuNodeValues *vals);
188 
189 gboolean visu_node_values_setFromString(VisuNodeValues *vals,
190                                         VisuNode *node,
191                                         const gchar *from);
192 gboolean visu_node_values_setFromStringForId(VisuNodeValues *vals,
193                                              guint nodeId,
194                                              const gchar *from);
195 gchar* visu_node_values_toString(const VisuNodeValues *vals,
196                                  const VisuNode *node);
197 gchar* visu_node_values_toStringFromId(const VisuNodeValues *vals,
198                                        guint nodeId);
199 
200 gboolean visu_node_values_setAt(VisuNodeValues *vals, const VisuNode *node,
201                                 GValue *value);
202 gboolean visu_node_values_getAt(const VisuNodeValues *vals,
203                                 const VisuNode *node,
204                                 GValue *value);
205 gpointer visu_node_values_getPtrAt(const VisuNodeValues *vals,
206                                    const VisuNode *node);
207 gboolean visu_node_values_copy(VisuNodeValues *vals, const VisuNodeValues *from);
208 
209 VisuNodeArray* visu_node_values_getArray(const VisuNodeValues *vals);
210 
211 void visu_node_values_reset(VisuNodeValues *vals);
212 
213 /**
214  * VisuNodeValuesIter:
215  * @value: the stored value.
216  * @iter: the iterator used to span nodes.
217  * @vals: the parent #VisuNodeValues object.
218  *
219  * Iterator structure used to read values of nodes.
220  *
221  * Since: 3.8
222  */
223 typedef struct _VisuNodeValuesIter VisuNodeValuesIter;
224 struct _VisuNodeValuesIter
225 {
226   GValue value;
227   VisuNodeArrayIter iter;
228 
229   /* Private. */
230   VisuNodeValues *vals;
231 };
232 gboolean visu_node_values_iter_new(VisuNodeValuesIter *iter,
233                                    VisuNodeArrayIterType type,
234                                    VisuNodeValues *vals);
235 void visu_node_values___iter__(VisuNodeValues *vals, VisuNodeValuesIter *iter);
236 gboolean visu_node_values_iter_next(VisuNodeValuesIter *iter);
237 
238 G_END_DECLS
239 
240 #endif
241