1 /* EXTRAITS DE LA LICENCE
2 Copyright CEA, contributeurs : Luc BILLARD et Damien
3 CALISTE, laboratoire L_Sim, (2001-2014)
4
5 Adresse mèl :
6 BILLARD, non joignable par mèl ;
7 CALISTE, damien P caliste AT cea P fr.
8
9 Ce logiciel est un programme informatique servant à visualiser des
10 structures atomiques dans un rendu pseudo-3D.
11
12 Ce logiciel est régi par la licence CeCILL soumise au droit français et
13 respectant les principes de diffusion des logiciels libres. Vous pouvez
14 utiliser, modifier et/ou redistribuer ce programme sous les conditions
15 de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
16 sur le site "http://www.cecill.info".
17
18 Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
19 pris connaissance de la licence CeCILL, et que vous en avez accepté les
20 termes (cf. le fichier Documentation/licence.fr.txt fourni avec ce logiciel).
21 */
22
23 /* LICENCE SUM UP
24 Copyright CEA, contributors : Luc BILLARD et Damien
25 CALISTE, laboratoire L_Sim, (2001-2014)
26
27 E-mail address:
28 BILLARD, not reachable any more ;
29 CALISTE, damien P caliste AT cea P fr.
30
31 This software is a computer program whose purpose is to visualize atomic
32 configurations in 3D.
33
34 This software is governed by the CeCILL license under French law and
35 abiding by the rules of distribution of free software. You can use,
36 modify and/ or redistribute the software under the terms of the CeCILL
37 license as circulated by CEA, CNRS and INRIA at the following URL
38 "http://www.cecill.info".
39
40 The fact that you are presently reading this means that you have had
41 knowledge of the CeCILL license and that you accept its terms. You can
42 find a copy of this licence shipped with this software at Documentation/licence.en.txt.
43 */
44 #include "box.h"
45
46 #include <GL/gl.h>
47 #include <GL/glu.h>
48
49 #include <math.h>
50 #include <string.h>
51
52 #include <opengl.h>
53 #include <visu_tools.h>
54 #include <visu_configFile.h>
55 #include <openGLFunctions/objectList.h>
56 #include <openGLFunctions/text.h>
57 #include <coreTools/toolMatrix.h>
58 #include <coreTools/toolColor.h>
59
60 /**
61 * SECTION:box
62 * @short_description: Draw a bounding box around nodes.
63 *
64 * <para>This extension allows V_Sim to draw a box around the
65 * nodes. The box is defined in the #VisuBox structure and can be
66 * retrieved with visu_box_getGeometry(). This box is not necessary
67 * orthogonal.</para>
68 * <para>It has several properties, namely, its colour, its line width
69 * and its line pattern. It is represented in OpenGL with simple lines
70 * and is affected by the antialiasing property. Defined resources:</para>
71 * <itemizedlist>
72 * <listitem>
73 * <para><emphasis>box_is_on</emphasis> (boolean): controls if a box
74 * is drawn around the rendering area (since 3.0).</para>
75 * </listitem>
76 * <listitem>
77 * <para><emphasis>box_color</emphasis> (RGB in [0;1]): defines the
78 * color of the box(since 3.0).</para>
79 * </listitem>
80 * <listitem>
81 * <para><emphasis>box_line_width</emphasis> (integer in [1;10]):
82 * defines the width of the lines of the box (since 3.0).</para>
83 * </listitem>
84 * <listitem>
85 * <para><emphasis>box_line_stipple</emphasis> (2 integers in
86 * ]0;65535]): dot scheme detail for the lines of the box. The first
87 * value is the pattern for the line of the main box and the second
88 * is the pattern for the lines of the expanded areas (since 3.4).</para>
89 * </listitem>
90 * </itemizedlist>
91 */
92
93 /* Parameters & resources*/
94 /* This is a boolean to control is the box is render or not. */
95 #define FLAG_RESOURCE_BOX_USED "box_is_on"
96 #define DESC_RESOURCE_BOX_USED "Control if a box is drawn around the rendering area ; boolean (0 or 1)"
97 static gboolean RESOURCE_BOX_USED_DEFAULT = FALSE;
98 /* A resource to control the color used to render the lines of the box. */
99 #define FLAG_RESOURCE_BOX_COLOR "box_color"
100 #define DESC_RESOURCE_BOX_COLOR "Define the color of the box ; three floating point values (0. <= v <= 1.)"
101 static float rgbDefault[4] = {1.0, 0.5, 0.1, 1.};
102 /* A resource to control the width to render the lines of the box. */
103 #define FLAG_RESOURCE_BOX_LINE "box_line_width"
104 #define DESC_RESOURCE_BOX_LINE "Define the width of the lines of the box ; one integer (1. <= v <= 10.)"
105 static float LINE_WIDTH_DEFAULT = 1.;
106 /* A resource to control the stipple to render the lines of the box. */
107 #define FLAG_RESOURCE_BOX_STIPPLE "box_line_stipple"
108 #define DESC_RESOURCE_BOX_STIPPLE "Dot scheme detail for the lines of the box (main and expanded) ; 0 < 2 integers < 2^16"
109 static guint16 stippleDefault[2] = {65535, 65280};
110
111 #define FLAG_RESOURCE_BOX_SIDE "box_side_color"
112 #define DESC_RESOURCE_BOX_SIDE "RGBA color used to draw the pristine box sides when expanded ; four floating point values (0. <= v <= 1.)"
113 static float sideRGBDefault[4] = {0.f, 0.f, 0.f, 0.3333f};
114
115 #define RESOURCE_WITH_BASIS_DEFAULT FALSE
116 /* static gboolean withBasis = FALSE; */
117 static float basisLength = 2.5f;
118
119 /* Export function that is called by visu_module to write the
120 values of resources to a file. */
121 static void exportResourcesBox(GString *data, VisuData *dataObj);
122
123 struct _VisuGlExtBoxPrivate
124 {
125 gboolean dispose_has_run;
126
127 /* Box definition. */
128 VisuBox *box;
129 gulong box_signal;
130 /* Matrix definition (to be merge later within box. */
131 float matrix[3][3];
132
133 /* Rendenring parameters. */
134 float rgb[4], sideRGB[4];
135 float lineWidth;
136 guint16 lineStipple[2];
137 };
138 static VisuGlExtBox* defaultBox;
139
140 enum
141 {
142 PROP_0,
143 COLOR_PROP,
144 SIDE_COLOR_PROP,
145 WIDTH_PROP,
146 STIPPLE_PROP,
147 EXT_STIPPLE_PROP,
148 BOX_PROP,
149 N_PROP
150 };
151 static GParamSpec *properties[N_PROP];
152
153 static void visu_gl_ext_lined_interface_init(VisuGlExtLinedInterface *iface);
154 static void visu_gl_ext_box_dispose(GObject* obj);
155 static void visu_gl_ext_box_get_property(GObject* obj, guint property_id,
156 GValue *value, GParamSpec *pspec);
157 static void visu_gl_ext_box_set_property(GObject* obj, guint property_id,
158 const GValue *value, GParamSpec *pspec);
159 static void visu_gl_ext_box_rebuild(VisuGlExt *ext);
160 static void visu_gl_ext_box_draw(VisuGlExt *ext);
161
162 static gboolean _setRGB(VisuGlExtLined *box, float rgb[4], int mask);
163 static gboolean _setLineWidth(VisuGlExtLined *box, float width);
164 static gboolean _setLineStipple(VisuGlExtLined *box, guint16 stipple);
165 static float* _getRGB(const VisuGlExtLined *box);
166 static float _getLineWidth(const VisuGlExtLined *box);
167 static guint16 _getLineStipple(const VisuGlExtLined *box);
168
169 /* Callbacks. */
170 static void onSizeChanged(VisuBox *box, gfloat extens, gpointer user_data);
171 static void onEntryUsed(VisuGlExtBox *box, VisuConfigFileEntry *entry, VisuConfigFile *obj);
172 static void onEntryColor(VisuGlExtBox *box, VisuConfigFileEntry *entry, VisuConfigFile *obj);
173 static void onEntryWidth(VisuGlExtBox *box, VisuConfigFileEntry *entry, VisuConfigFile *obj);
174 static void onEntryStipple(VisuGlExtBox *box, VisuConfigFileEntry *entry, VisuConfigFile *obj);
175 static void onEntrySide(VisuGlExtBox *box, VisuConfigFileEntry *entry, VisuConfigFile *obj);
176
G_DEFINE_TYPE_WITH_CODE(VisuGlExtBox,visu_gl_ext_box,VISU_TYPE_GL_EXT,G_ADD_PRIVATE (VisuGlExtBox)G_IMPLEMENT_INTERFACE (VISU_TYPE_GL_EXT_LINED,visu_gl_ext_lined_interface_init))177 G_DEFINE_TYPE_WITH_CODE(VisuGlExtBox, visu_gl_ext_box, VISU_TYPE_GL_EXT,
178 G_ADD_PRIVATE(VisuGlExtBox)
179 G_IMPLEMENT_INTERFACE(VISU_TYPE_GL_EXT_LINED,
180 visu_gl_ext_lined_interface_init))
181
182 static void visu_gl_ext_lined_interface_init(VisuGlExtLinedInterface *iface)
183 {
184 iface->get_width = _getLineWidth;
185 iface->set_width = _setLineWidth;
186 iface->get_stipple = _getLineStipple;
187 iface->set_stipple = _setLineStipple;
188 iface->get_rgba = _getRGB;
189 iface->set_rgba = _setRGB;
190 }
visu_gl_ext_box_class_init(VisuGlExtBoxClass * klass)191 static void visu_gl_ext_box_class_init(VisuGlExtBoxClass *klass)
192 {
193 float rgColor[2] = {0.f, 1.f};
194 float rgWidth[2] = {0.f, 10.f};
195 VisuConfigFileEntry *resourceEntry;
196
197 DBG_fprintf(stderr, "Extension Box: creating the class of the object.\n");
198 /* DBG_fprintf(stderr, " - adding new signals ;\n"); */
199
200 DBG_fprintf(stderr, " - adding new resources ;\n");
201 resourceEntry = visu_config_file_addBooleanEntry(VISU_CONFIG_FILE_RESOURCE,
202 FLAG_RESOURCE_BOX_USED,
203 DESC_RESOURCE_BOX_USED,
204 &RESOURCE_BOX_USED_DEFAULT, FALSE);
205 resourceEntry = visu_config_file_addFloatArrayEntry(VISU_CONFIG_FILE_RESOURCE,
206 FLAG_RESOURCE_BOX_COLOR,
207 DESC_RESOURCE_BOX_COLOR,
208 3, rgbDefault, rgColor, FALSE);
209 resourceEntry = visu_config_file_addFloatArrayEntry(VISU_CONFIG_FILE_RESOURCE,
210 FLAG_RESOURCE_BOX_LINE,
211 DESC_RESOURCE_BOX_LINE,
212 1, &LINE_WIDTH_DEFAULT, rgWidth, FALSE);
213 resourceEntry = visu_config_file_addStippleArrayEntry(VISU_CONFIG_FILE_RESOURCE,
214 FLAG_RESOURCE_BOX_STIPPLE,
215 DESC_RESOURCE_BOX_STIPPLE,
216 2, stippleDefault);
217 visu_config_file_entry_setVersion(resourceEntry, 3.4f);
218 resourceEntry = visu_config_file_addFloatArrayEntry(VISU_CONFIG_FILE_RESOURCE,
219 FLAG_RESOURCE_BOX_SIDE,
220 DESC_RESOURCE_BOX_SIDE,
221 4, sideRGBDefault, rgColor, FALSE);
222 visu_config_file_entry_setVersion(resourceEntry, 3.8f);
223 visu_config_file_addExportFunction(VISU_CONFIG_FILE_RESOURCE,
224 exportResourcesBox);
225
226 defaultBox = (VisuGlExtBox*)0;
227
228 /* Connect the overloading methods. */
229 G_OBJECT_CLASS(klass)->dispose = visu_gl_ext_box_dispose;
230 G_OBJECT_CLASS(klass)->set_property = visu_gl_ext_box_set_property;
231 G_OBJECT_CLASS(klass)->get_property = visu_gl_ext_box_get_property;
232 VISU_GL_EXT_CLASS(klass)->rebuild = visu_gl_ext_box_rebuild;
233 VISU_GL_EXT_CLASS(klass)->draw = visu_gl_ext_box_draw;
234
235 /**
236 * VisuGlExtBox::color:
237 *
238 * Store the color of the box.
239 *
240 * Since: 3.8
241 */
242 g_object_class_override_property(G_OBJECT_CLASS(klass), COLOR_PROP, "color");
243 /**
244 * VisuGlExtBox::side-color:
245 *
246 * Store the color of the sides drawn on the primary cell when the
247 * box is expanded.
248 *
249 * Since: 3.8
250 */
251 properties[SIDE_COLOR_PROP] = g_param_spec_boxed("side-color", "side color",
252 "color of the primary cell sides",
253 TOOL_TYPE_COLOR, G_PARAM_READWRITE);
254 g_object_class_install_property(G_OBJECT_CLASS(klass), SIDE_COLOR_PROP,
255 properties[SIDE_COLOR_PROP]);
256 /**
257 * VisuGlExtBox::width:
258 *
259 * Store the line width of the box.
260 *
261 * Since: 3.8
262 */
263 g_object_class_override_property(G_OBJECT_CLASS(klass), WIDTH_PROP, "width");
264 /**
265 * VisuGlExtBox::stipple:
266 *
267 * Store the line stipple pattern of the box.
268 *
269 * Since: 3.8
270 */
271 g_object_class_override_property(G_OBJECT_CLASS(klass), STIPPLE_PROP, "stipple");
272 /**
273 * VisuGlExtBox::expand-stipple:
274 *
275 * Store the line stipple pattern of the extension lines of the box.
276 *
277 * Since: 3.8
278 */
279 properties[EXT_STIPPLE_PROP] = g_param_spec_uint("expand-stipple", "extension line stipple",
280 "rendering line stipple pattern of extension",
281 0, 65535, stippleDefault[1],
282 G_PARAM_READWRITE);
283 g_object_class_install_property(G_OBJECT_CLASS(klass), EXT_STIPPLE_PROP,
284 properties[EXT_STIPPLE_PROP]);
285 /**
286 * VisuGlExtBox::basis:
287 *
288 * Store the #VisuBoxed object that defines the box. If %NULL, a
289 * cartesian basis-set is assumed.
290 *
291 * Since: 3.8
292 */
293 properties[BOX_PROP] = g_param_spec_object("basis", "basis-set",
294 "provides the basis-set to draw the box",
295 VISU_TYPE_BOX, G_PARAM_READWRITE);
296 g_object_class_install_property(G_OBJECT_CLASS(klass), BOX_PROP,
297 properties[BOX_PROP]);
298 }
299
visu_gl_ext_box_init(VisuGlExtBox * obj)300 static void visu_gl_ext_box_init(VisuGlExtBox *obj)
301 {
302 DBG_fprintf(stderr, "Extension Box: initializing a new object (%p).\n",
303 (gpointer)obj);
304
305 obj->priv = visu_gl_ext_box_get_instance_private(obj);
306 obj->priv->dispose_has_run = FALSE;
307
308 /* Private data. */
309 tool_matrix_setIdentity(obj->priv->matrix);
310 obj->priv->rgb[0] = rgbDefault[0];
311 obj->priv->rgb[1] = rgbDefault[1];
312 obj->priv->rgb[2] = rgbDefault[2];
313 obj->priv->rgb[3] = 1.f;
314 obj->priv->sideRGB[0] = sideRGBDefault[0];
315 obj->priv->sideRGB[1] = sideRGBDefault[1];
316 obj->priv->sideRGB[2] = sideRGBDefault[2];
317 obj->priv->sideRGB[3] = sideRGBDefault[3];
318 obj->priv->lineWidth = LINE_WIDTH_DEFAULT;
319 obj->priv->lineStipple[0] = stippleDefault[0];
320 obj->priv->lineStipple[1] = stippleDefault[1];
321 obj->priv->box = (VisuBox*)0;
322 obj->priv->box_signal = 0;
323
324 /* withBasis = RESOURCE_WITH_BASIS_DEFAULT; */
325 g_signal_connect_object(VISU_CONFIG_FILE_RESOURCE, "parsed::" FLAG_RESOURCE_BOX_USED,
326 G_CALLBACK(onEntryUsed), (gpointer)obj, G_CONNECT_SWAPPED);
327 g_signal_connect_object(VISU_CONFIG_FILE_RESOURCE, "parsed::" FLAG_RESOURCE_BOX_COLOR,
328 G_CALLBACK(onEntryColor), (gpointer)obj, G_CONNECT_SWAPPED);
329 g_signal_connect_object(VISU_CONFIG_FILE_RESOURCE, "parsed::" FLAG_RESOURCE_BOX_LINE,
330 G_CALLBACK(onEntryWidth), (gpointer)obj, G_CONNECT_SWAPPED);
331 g_signal_connect_object(VISU_CONFIG_FILE_RESOURCE, "parsed::" FLAG_RESOURCE_BOX_STIPPLE,
332 G_CALLBACK(onEntryStipple), (gpointer)obj, G_CONNECT_SWAPPED);
333 g_signal_connect_object(VISU_CONFIG_FILE_RESOURCE, "parsed::" FLAG_RESOURCE_BOX_SIDE,
334 G_CALLBACK(onEntrySide), (gpointer)obj, G_CONNECT_SWAPPED);
335
336 if (!defaultBox)
337 defaultBox = obj;
338 }
339
340 /* This method can be called several times.
341 It should unref all of its reference to
342 GObjects. */
visu_gl_ext_box_dispose(GObject * obj)343 static void visu_gl_ext_box_dispose(GObject* obj)
344 {
345 VisuGlExtBox *box;
346
347 DBG_fprintf(stderr, "Extension Box: dispose object %p.\n", (gpointer)obj);
348
349 box = VISU_GL_EXT_BOX(obj);
350 if (box->priv->dispose_has_run)
351 return;
352 box->priv->dispose_has_run = TRUE;
353
354 /* Disconnect signals. */
355 visu_gl_ext_box_setBox(box, (VisuBox*)0);
356
357 /* Chain up to the parent class */
358 G_OBJECT_CLASS(visu_gl_ext_box_parent_class)->dispose(obj);
359 }
visu_gl_ext_box_get_property(GObject * obj,guint property_id,GValue * value,GParamSpec * pspec)360 static void visu_gl_ext_box_get_property(GObject* obj, guint property_id,
361 GValue *value, GParamSpec *pspec)
362 {
363 VisuGlExtBox *self = VISU_GL_EXT_BOX(obj);
364
365 DBG_fprintf(stderr, "Extension Box: get property '%s' -> ",
366 g_param_spec_get_name(pspec));
367 switch (property_id)
368 {
369 case COLOR_PROP:
370 g_value_take_boxed(value, tool_color_new(self->priv->rgb));
371 DBG_fprintf(stderr, "%gx%gx%g.\n", self->priv->rgb[0], self->priv->rgb[1], self->priv->rgb[2]);
372 break;
373 case SIDE_COLOR_PROP:
374 g_value_take_boxed(value, tool_color_new(self->priv->sideRGB));
375 DBG_fprintf(stderr, "%gx%gx%g.\n", self->priv->rgb[0], self->priv->rgb[1], self->priv->rgb[2]);
376 break;
377 case WIDTH_PROP:
378 g_value_set_float(value, self->priv->lineWidth);
379 DBG_fprintf(stderr, "%g.\n", self->priv->lineWidth);
380 break;
381 case STIPPLE_PROP:
382 g_value_set_uint(value, (guint)self->priv->lineStipple[0]);
383 DBG_fprintf(stderr, "%d.\n", (guint)self->priv->lineStipple[0]);
384 break;
385 case EXT_STIPPLE_PROP:
386 g_value_set_uint(value, (guint)self->priv->lineStipple[1]);
387 DBG_fprintf(stderr, "%d.\n", (guint)self->priv->lineStipple[1]);
388 break;
389 case BOX_PROP:
390 g_value_set_object(value, self->priv->box);
391 DBG_fprintf(stderr, "%p.\n", (gpointer)self->priv->box);
392 break;
393 default:
394 /* We don't have any other property... */
395 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec);
396 break;
397 }
398 }
visu_gl_ext_box_set_property(GObject * obj,guint property_id,const GValue * value,GParamSpec * pspec)399 static void visu_gl_ext_box_set_property(GObject* obj, guint property_id,
400 const GValue *value, GParamSpec *pspec)
401 {
402 ToolColor *color;
403 VisuGlExtBox *self = VISU_GL_EXT_BOX(obj);
404
405 DBG_fprintf(stderr, "Extension Box: set property '%s' -> ",
406 g_param_spec_get_name(pspec));
407 switch (property_id)
408 {
409 case COLOR_PROP:
410 color = (ToolColor*)g_value_get_boxed(value);
411 _setRGB((VisuGlExtLined*)self, color->rgba, TOOL_COLOR_MASK_RGBA);
412 DBG_fprintf(stderr, "%gx%gx%g.\n", self->priv->rgb[0], self->priv->rgb[1], self->priv->rgb[2]);
413 break;
414 case SIDE_COLOR_PROP:
415 color = (ToolColor*)g_value_get_boxed(value);
416 visu_gl_ext_box_setSideRGB(self, color->rgba, TOOL_COLOR_MASK_RGBA);
417 DBG_fprintf(stderr, "%gx%gx%g.\n", self->priv->rgb[0], self->priv->rgb[1], self->priv->rgb[2]);
418 break;
419 case WIDTH_PROP:
420 _setLineWidth((VisuGlExtLined*)self, g_value_get_float(value));
421 DBG_fprintf(stderr, "%g.\n", self->priv->lineWidth);
422 break;
423 case STIPPLE_PROP:
424 _setLineStipple((VisuGlExtLined*)self, (guint16)g_value_get_uint(value));
425 DBG_fprintf(stderr, "%d.\n", (guint)self->priv->lineStipple[0]);
426 break;
427 case EXT_STIPPLE_PROP:
428 visu_gl_ext_box_setExpandStipple(self, (guint16)g_value_get_uint(value));
429 DBG_fprintf(stderr, "%d.\n", (guint)self->priv->lineStipple[1]);
430 break;
431 case BOX_PROP:
432 visu_gl_ext_box_setBox(self, VISU_BOX(g_value_get_object(value)));
433 DBG_fprintf(stderr, "%p.\n", (gpointer)g_value_get_object(value));
434 break;
435 default:
436 /* We don't have any other property... */
437 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec);
438 break;
439 }
440 }
441
442 /**
443 * visu_gl_ext_box_new:
444 * @name: (allow-none): the name to give to the extension (default is #VISU_GL_EXT_BOX_ID).
445 *
446 * Creates a new #VisuGlExt to draw a box.
447 *
448 * Since: 3.7
449 *
450 * Returns: a pointer to the #VisuGlExt it created or
451 * NULL otherwise.
452 */
visu_gl_ext_box_new(const gchar * name)453 VisuGlExtBox* visu_gl_ext_box_new(const gchar *name)
454 {
455 char *name_ = VISU_GL_EXT_BOX_ID;
456 char *description = _("Draw a box representing the limit of the area.");
457
458 DBG_fprintf(stderr,"Extension Box: new object.\n");
459
460 return g_object_new(VISU_TYPE_GL_EXT_BOX,
461 "name", (name)?name:name_, "label", _(name),
462 "description", description, "nGlObj", 1,
463 "priority", VISU_GL_EXT_PRIORITY_LOW, NULL);
464 }
465 /**
466 * visu_gl_ext_box_setBox:
467 * @box: the #VisuGlExtBox object to attach to.
468 * @boxObj: the box to get the definition of.
469 *
470 * Attach the #VisuBox to draw the frame of.
471 *
472 * Since: 3.7
473 *
474 * Returns: TRUE if the #VisuBox model is actually changed.
475 **/
visu_gl_ext_box_setBox(VisuGlExtBox * box,VisuBox * boxObj)476 gboolean visu_gl_ext_box_setBox(VisuGlExtBox *box, VisuBox *boxObj)
477 {
478 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), FALSE);
479
480 DBG_fprintf(stderr, "Extension Box: set box %p.\n", (gpointer)boxObj);
481 if (box->priv->box)
482 {
483 g_signal_handler_disconnect(G_OBJECT(box->priv->box), box->priv->box_signal);
484 g_object_unref(box->priv->box);
485 }
486 if (boxObj)
487 {
488 g_object_ref(boxObj);
489 box->priv->box_signal =
490 g_signal_connect(G_OBJECT(boxObj), "SizeChanged",
491 G_CALLBACK(onSizeChanged), (gpointer)box);
492 }
493 else
494 box->priv->box_signal = 0;
495 box->priv->box = boxObj;
496
497 visu_gl_ext_setDirty(VISU_GL_EXT(box), TRUE);
498 g_object_notify_by_pspec(G_OBJECT(box), properties[BOX_PROP]);
499 return TRUE;
500 }
501 /**
502 * visu_gl_ext_box_setBasis:
503 * @box: the #VisuGlExtBox object to attach to.
504 * @orig: (array fixed-size=3): the origin.
505 * @mat: (array fixed-size=9): the basis-set.
506 *
507 * Define the box to draw with a simple matrix basis-set and an origin.
508 *
509 * Since: 3.7
510 *
511 * Returns: TRUE if value is actually changed.
512 **/
visu_gl_ext_box_setBasis(VisuGlExtBox * box,float orig[3],float mat[3][3])513 gboolean visu_gl_ext_box_setBasis(VisuGlExtBox *box, float orig[3], float mat[3][3])
514 {
515 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), FALSE);
516
517 visu_gl_ext_box_setBox(box, (VisuBox*)0);
518 visu_gl_ext_setTranslation(VISU_GL_EXT(box), orig);
519 memcpy(box->priv->matrix, mat, sizeof(float) * 9);
520
521 visu_gl_ext_setDirty(VISU_GL_EXT(box), TRUE);
522 return TRUE;
523 }
524
_setRGB(VisuGlExtLined * box,float rgb[3],int mask)525 static gboolean _setRGB(VisuGlExtLined *box, float rgb[3], int mask)
526 {
527 VisuGlExtBoxPrivate *self;
528 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), FALSE);
529 self = VISU_GL_EXT_BOX(box)->priv;
530
531 if (mask & TOOL_COLOR_MASK_R)
532 self->rgb[0] = rgb[0];
533 if (mask & TOOL_COLOR_MASK_G)
534 self->rgb[1] = rgb[1];
535 if (mask & TOOL_COLOR_MASK_B)
536 self->rgb[2] = rgb[2];
537
538 visu_gl_ext_setDirty(VISU_GL_EXT(box), TRUE);
539 return TRUE;
540 }
541 /**
542 * visu_gl_ext_box_setSideRGB:
543 * @box: the #VisuGlExtBox to update.
544 * @rgba: (array fixed-size=4): a four floats array with values (0 <= values <= 1) for the
545 * red, the green, the blue color and the alpha channel. Only values
546 * specified by the mask are really relevant.
547 * @mask: use #TOOL_COLOR_MASK_R, #TOOL_COLOR_MASK_G,
548 * #TOOL_COLOR_MASK_B, #TOOL_COLOR_MASK_A or a combinaison to indicate
549 * what values in the @rgba array must be taken into account.
550 *
551 * Change the colour to represent the side of the super-cell. A
552 * channel alpha of zero, means that the box is rendered as wire-frame
553 * only. The sides are indeed drawn only if the box has expansion.
554 *
555 * Since: 3.7
556 *
557 * Returns: TRUE if value is actually changed.
558 */
visu_gl_ext_box_setSideRGB(VisuGlExtBox * box,float rgba[4],int mask)559 gboolean visu_gl_ext_box_setSideRGB(VisuGlExtBox *box, float rgba[4], int mask)
560 {
561 gboolean diff = FALSE;
562
563 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), FALSE);
564
565 if (mask & TOOL_COLOR_MASK_R && box->priv->sideRGB[0] != rgba[0])
566 {
567 box->priv->sideRGB[0] = rgba[0];
568 diff = TRUE;
569 }
570 if (mask & TOOL_COLOR_MASK_G && box->priv->sideRGB[1] != rgba[1])
571 {
572 box->priv->sideRGB[1] = rgba[1];
573 diff = TRUE;
574 }
575 if (mask & TOOL_COLOR_MASK_B && box->priv->sideRGB[2] != rgba[2])
576 {
577 box->priv->sideRGB[2] = rgba[2];
578 diff = TRUE;
579 }
580 if (mask & TOOL_COLOR_MASK_A && box->priv->sideRGB[3] != rgba[3])
581 {
582 box->priv->sideRGB[3] = rgba[3];
583 diff = TRUE;
584 }
585 if (!diff)
586 return FALSE;
587
588 visu_gl_ext_setDirty(VISU_GL_EXT(box), TRUE);
589 g_object_notify_by_pspec(G_OBJECT(box), properties[SIDE_COLOR_PROP]);
590 return TRUE;
591 }
_setLineWidth(VisuGlExtLined * box,float width)592 static gboolean _setLineWidth(VisuGlExtLined *box, float width)
593 {
594 VisuGlExtBoxPrivate *self;
595 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), FALSE);
596 self = VISU_GL_EXT_BOX(box)->priv;
597
598 self->lineWidth = width;
599 visu_gl_ext_setDirty(VISU_GL_EXT(box), TRUE);
600 return TRUE;
601 }
_setLineStipple(VisuGlExtLined * box,guint16 stipple)602 static gboolean _setLineStipple(VisuGlExtLined *box, guint16 stipple)
603 {
604 VisuGlExtBoxPrivate *self;
605 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), FALSE);
606 self = VISU_GL_EXT_BOX(box)->priv;
607
608 self->lineStipple[0] = stipple;
609 visu_gl_ext_setDirty(VISU_GL_EXT(box), TRUE);
610 return TRUE;
611 }
612 /**
613 * visu_gl_ext_box_setExpandStipple:
614 * @box: the #VisuGlExtBox to update.
615 * @stipple: a pattern for line stipple in OpenGL.
616 *
617 * Method used to change the value of the parameter box_line_stipple
618 * (expanded part).
619 *
620 * Returns: TRUE if value is actually changed.
621 */
visu_gl_ext_box_setExpandStipple(VisuGlExtBox * box,guint16 stipple)622 gboolean visu_gl_ext_box_setExpandStipple(VisuGlExtBox *box, guint16 stipple)
623 {
624 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), FALSE);
625
626 if (stipple == box->priv->lineStipple[1])
627 return FALSE;
628
629 box->priv->lineStipple[1] = stipple;
630 visu_gl_ext_setDirty(VISU_GL_EXT(box), TRUE);
631 g_object_notify_by_pspec(G_OBJECT(box), properties[EXT_STIPPLE_PROP]);
632 return TRUE;
633 }
634 /* Get methods. */
_getRGB(const VisuGlExtLined * box)635 static float* _getRGB(const VisuGlExtLined *box)
636 {
637 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), rgbDefault);
638
639 return ((VisuGlExtBox*)box)->priv->rgb;
640 }
641 /**
642 * visu_gl_ext_box_getSideRGB:
643 * @box: the #VisuGlExtBox to inquire.
644 *
645 * Read the colour components of the sides of the box (in [0;1]).
646 *
647 * Returns: all the colour values of the current box line.
648 */
visu_gl_ext_box_getSideRGB(VisuGlExtBox * box)649 float* visu_gl_ext_box_getSideRGB(VisuGlExtBox *box)
650 {
651 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), rgbDefault);
652
653 return box->priv->sideRGB;
654 }
_getLineWidth(const VisuGlExtLined * box)655 static float _getLineWidth(const VisuGlExtLined *box)
656 {
657 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), LINE_WIDTH_DEFAULT);
658
659 return ((VisuGlExtBox*)box)->priv->lineWidth;
660 }
_getLineStipple(const VisuGlExtLined * box)661 static guint16 _getLineStipple(const VisuGlExtLined *box)
662 {
663 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), stippleDefault[0]);
664
665 return ((VisuGlExtBox*)box)->priv->lineStipple[0];
666 }
667 /**
668 * visu_gl_ext_box_getExpandStipple:
669 * @box: the #VisuGlExtBox to inquire.
670 *
671 * Read the line stipple pattern used for box (expanded part).
672 *
673 * Returns: the value of current box line pattern.
674 */
visu_gl_ext_box_getExpandStipple(VisuGlExtBox * box)675 guint16 visu_gl_ext_box_getExpandStipple(VisuGlExtBox *box)
676 {
677 g_return_val_if_fail(VISU_IS_GL_EXT_BOX(box), stippleDefault[1]);
678
679 return box->priv->lineStipple[1];
680 }
681
682
683 /****************/
684 /* Private part */
685 /****************/
visu_gl_ext_box_rebuild(VisuGlExt * ext)686 static void visu_gl_ext_box_rebuild(VisuGlExt *ext)
687 {
688 visu_gl_ext_box_draw(ext);
689 }
onSizeChanged(VisuBox * boxObj _U_,gfloat extens _U_,gpointer user_data)690 static void onSizeChanged(VisuBox *boxObj _U_, gfloat extens _U_, gpointer user_data)
691 {
692 DBG_fprintf(stderr, "Extension Box: caught the 'SizeChanged' signal.\n");
693 visu_gl_ext_setDirty(VISU_GL_EXT(user_data), TRUE);
694 }
onEntryUsed(VisuGlExtBox * box,VisuConfigFileEntry * entry _U_,VisuConfigFile * obj _U_)695 static void onEntryUsed(VisuGlExtBox *box, VisuConfigFileEntry *entry _U_, VisuConfigFile *obj _U_)
696 {
697 visu_gl_ext_setActive(VISU_GL_EXT(box), RESOURCE_BOX_USED_DEFAULT);
698 }
onEntryColor(VisuGlExtBox * box,VisuConfigFileEntry * entry _U_,VisuConfigFile * obj _U_)699 static void onEntryColor(VisuGlExtBox *box, VisuConfigFileEntry *entry _U_, VisuConfigFile *obj _U_)
700 {
701 visu_gl_ext_lined_setRGBA(VISU_GL_EXT_LINED(box), rgbDefault, TOOL_COLOR_MASK_RGBA);
702 }
onEntryWidth(VisuGlExtBox * box,VisuConfigFileEntry * entry _U_,VisuConfigFile * obj _U_)703 static void onEntryWidth(VisuGlExtBox *box, VisuConfigFileEntry *entry _U_, VisuConfigFile *obj _U_)
704 {
705 visu_gl_ext_lined_setWidth(VISU_GL_EXT_LINED(box), LINE_WIDTH_DEFAULT);
706 }
onEntryStipple(VisuGlExtBox * box,VisuConfigFileEntry * entry _U_,VisuConfigFile * obj _U_)707 static void onEntryStipple(VisuGlExtBox *box, VisuConfigFileEntry *entry _U_, VisuConfigFile *obj _U_)
708 {
709 visu_gl_ext_lined_setStipple(VISU_GL_EXT_LINED(box), stippleDefault[0]);
710 visu_gl_ext_box_setExpandStipple(box, stippleDefault[1]);
711 }
onEntrySide(VisuGlExtBox * box,VisuConfigFileEntry * entry _U_,VisuConfigFile * obj _U_)712 static void onEntrySide(VisuGlExtBox *box, VisuConfigFileEntry *entry _U_, VisuConfigFile *obj _U_)
713 {
714 visu_gl_ext_box_setSideRGB(box, sideRGBDefault, TOOL_COLOR_MASK_RGBA);
715 }
drawSides(float ext[3],float v[8][3],float rgba[4])716 static void drawSides(float ext[3], float v[8][3], float rgba[4])
717 {
718 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
719 glDisable(GL_CULL_FACE);
720 glColor4fv(rgba);
721 if (ext[0] > 0.)
722 {
723 glBegin(GL_POLYGON);
724 glVertex3fv(v[0]);
725 glVertex3fv(v[3]);
726 glVertex3fv(v[7]);
727 glVertex3fv(v[4]);
728 glEnd();
729 glBegin(GL_POLYGON);
730 glVertex3fv(v[6]);
731 glVertex3fv(v[5]);
732 glVertex3fv(v[1]);
733 glVertex3fv(v[2]);
734 glEnd();
735 }
736 if (ext[1] > 0.)
737 {
738 glBegin(GL_POLYGON);
739 glVertex3fv(v[0]);
740 glVertex3fv(v[1]);
741 glVertex3fv(v[5]);
742 glVertex3fv(v[4]);
743 glEnd();
744 glBegin(GL_POLYGON);
745 glVertex3fv(v[6]);
746 glVertex3fv(v[7]);
747 glVertex3fv(v[3]);
748 glVertex3fv(v[2]);
749 glEnd();
750 }
751 if (ext[2] > 0.)
752 {
753 glBegin(GL_POLYGON);
754 glVertex3fv(v[0]);
755 glVertex3fv(v[1]);
756 glVertex3fv(v[2]);
757 glVertex3fv(v[3]);
758 glEnd();
759 glBegin(GL_POLYGON);
760 glVertex3fv(v[4]);
761 glVertex3fv(v[5]);
762 glVertex3fv(v[6]);
763 glVertex3fv(v[7]);
764 glEnd();
765 }
766 glEnable(GL_CULL_FACE);
767 glCullFace(GL_BACK);
768 }
769 /**
770 * visu_gl_ext_box_draw:
771 * @box: a #VisuBox object.
772 *
773 * This method create a compile list that draw a box for the given @box.
774 */
visu_gl_ext_box_draw(VisuGlExt * ext)775 static void visu_gl_ext_box_draw(VisuGlExt *ext)
776 {
777 int i, j, k;
778 float v[8][3], e[8][3];
779 float extens[3] = {0.f, 0.f, 0.f}, centre[3];
780 float material[5] = {.5f, .5f, .2f, .5f, .0f};
781 GLUquadricObj *obj;
782 gchar strLg[64];
783 VisuGlExtBox *box;
784
785 /* Nothing to draw; */
786 g_return_if_fail(VISU_IS_GL_EXT_BOX(ext));
787 box = VISU_GL_EXT_BOX(ext);
788
789 DBG_fprintf(stderr, "Extension box: creating box for"
790 " VisuBox %p.\n", (gpointer)box->priv->box);
791 if (box->priv->box)
792 {
793 visu_box_getVertices(box->priv->box, v, FALSE);
794 if (visu_box_getExtensionActive(box->priv->box))
795 visu_box_getExtension(box->priv->box, extens);
796 }
797 else
798 {
799 /* We build the vertex array. */
800 v[0][0] = 0.f;
801 v[0][1] = 0.f;
802 v[0][2] = 0.f;
803 v[1][0] = box->priv->matrix[0][0];
804 v[1][1] = box->priv->matrix[1][0];
805 v[1][2] = box->priv->matrix[2][0];
806 v[2][0] = box->priv->matrix[0][0] + box->priv->matrix[0][1];
807 v[2][1] = box->priv->matrix[1][0] + box->priv->matrix[1][1];
808 v[2][2] = box->priv->matrix[2][0] + box->priv->matrix[2][1];
809 v[3][0] = box->priv->matrix[0][1];
810 v[3][1] = box->priv->matrix[1][1];
811 v[3][2] = box->priv->matrix[2][1];
812 v[4][0] = box->priv->matrix[0][2];
813 v[4][1] = box->priv->matrix[1][2];
814 v[4][2] = box->priv->matrix[2][2];
815 v[5][0] = box->priv->matrix[0][0] + box->priv->matrix[0][2];
816 v[5][1] = box->priv->matrix[1][0] + box->priv->matrix[1][2];
817 v[5][2] = box->priv->matrix[2][0] + box->priv->matrix[2][2];
818 v[6][0] = box->priv->matrix[0][0] + box->priv->matrix[0][1] + box->priv->matrix[0][2];
819 v[6][1] = box->priv->matrix[1][0] + box->priv->matrix[1][1] + box->priv->matrix[1][2];
820 v[6][2] = box->priv->matrix[2][0] + box->priv->matrix[2][1] + box->priv->matrix[2][2];
821 v[7][0] = box->priv->matrix[0][1] + box->priv->matrix[0][2];
822 v[7][1] = box->priv->matrix[1][1] + box->priv->matrix[1][2];
823 v[7][2] = box->priv->matrix[2][1] + box->priv->matrix[2][2];
824 extens[0] = 1.f;
825 extens[1] = 1.f;
826 extens[2] = 1.f;
827 }
828
829 glDeleteLists(visu_gl_ext_getGlList(ext), 1);
830 visu_gl_ext_startDrawing(ext);
831
832 glDisable(GL_LIGHTING);
833 glDisable(GL_DITHER);
834
835 glLineWidth(box->priv->lineWidth);
836
837 /* We draw sides of the box, if specified. */
838 if ((extens[0] > 0. || extens[1] > 0. || extens[2] > 0.) &&
839 box->priv->sideRGB[3] == 1.f)
840 drawSides(extens, v, box->priv->sideRGB);
841 /* Draw the basic lines. */
842 glColor3fv(box->priv->rgb);
843 if (box->priv->lineStipple[0] != 65535)
844 {
845 glEnable(GL_LINE_STIPPLE);
846 glLineStipple(1, box->priv->lineStipple[0]);
847 }
848 glBegin(GL_LINES);
849 glVertex3fv(v[0]);
850 glVertex3fv(v[1]);
851 glVertex3fv(v[1]);
852 glVertex3fv(v[2]);
853 glVertex3fv(v[2]);
854 glVertex3fv(v[3]);
855 glVertex3fv(v[3]);
856 glVertex3fv(v[0]);
857 glVertex3fv(v[4]);
858 glVertex3fv(v[5]);
859 glVertex3fv(v[5]);
860 glVertex3fv(v[6]);
861 glVertex3fv(v[6]);
862 glVertex3fv(v[7]);
863 glVertex3fv(v[7]);
864 glVertex3fv(v[4]);
865 glVertex3fv(v[0]);
866 glVertex3fv(v[4]);
867 glVertex3fv(v[1]);
868 glVertex3fv(v[5]);
869 glVertex3fv(v[2]);
870 glVertex3fv(v[6]);
871 glVertex3fv(v[3]);
872 glVertex3fv(v[7]);
873 glEnd();
874 if (box->priv->lineStipple[0] != 65535)
875 glDisable(GL_LINE_STIPPLE);
876 /* Draw the extension lines. */
877 if (extens[0] > 0. || extens[1] > 0. || extens[2] > 0.)
878 {
879 glColor3fv(box->priv->rgb);
880 /* We draw then the expansion lines. */
881 if (box->priv->lineStipple[1] != 65535)
882 {
883 glEnable(GL_LINE_STIPPLE);
884 glLineStipple(1, box->priv->lineStipple[1]);
885 }
886 for (i = 1; i < 8; i++)
887 {
888 e[i][0] = v[i][0] - v[0][0];
889 e[i][1] = v[i][1] - v[0][1];
890 e[i][2] = v[i][2] - v[0][2];
891 }
892 glTranslatef(v[0][0], v[0][1], v[0][2]);
893 glBegin(GL_LINES);
894 /* X coordinate. */
895 for (j = -(int)extens[1]; j < 2 + (int)extens[1]; j++)
896 for (k = -(int)extens[2]; k < 2 + (int)extens[2]; k++)
897 {
898 glVertex3f(-extens[0] * e[1][0] + e[3][0] * j + e[4][0] * k,
899 -extens[0] * e[1][1] + e[3][1] * j + e[4][1] * k,
900 -extens[0] * e[1][2] + e[3][2] * j + e[4][2] * k);
901 if ((j == 0 || j == 1) && (k == 0 || k == 1))
902 {
903 glVertex3f(e[3][0] * j + e[4][0] * k,
904 e[3][1] * j + e[4][1] * k,
905 e[3][2] * j + e[4][2] * k);
906 glVertex3f(e[1][0] + e[3][0] * j + e[4][0] * k,
907 e[1][1] + e[3][1] * j + e[4][1] * k,
908 e[1][2] + e[3][2] * j + e[4][2] * k);
909 }
910 glVertex3f((1. + extens[0]) * e[1][0] + e[3][0] * j + e[4][0] * k,
911 (1. + extens[0]) * e[1][1] + e[3][1] * j + e[4][1] * k,
912 (1. + extens[0]) * e[1][2] + e[3][2] * j + e[4][2] * k);
913 }
914 /* Y coordinate. */
915 for (i = -(int)extens[0]; i < 2 + (int)extens[0]; i++)
916 for (k = -(int)extens[2]; k < 2 + (int)extens[2]; k++)
917 {
918 glVertex3f(-extens[1] * e[3][0] + e[1][0] * i + e[4][0] * k,
919 -extens[1] * e[3][1] + e[1][1] * i + e[4][1] * k,
920 -extens[1] * e[3][2] + e[1][2] * i + e[4][2] * k);
921 if ((i == 0 || i == 1) && (k == 0 || k == 1))
922 {
923 glVertex3f(e[1][0] * i + e[4][0] * k,
924 e[1][1] * i + e[4][1] * k,
925 e[1][2] * i + e[4][2] * k);
926 glVertex3f(e[3][0] + e[1][0] * i + e[4][0] * k,
927 e[3][1] + e[1][1] * i + e[4][1] * k,
928 e[3][2] + e[1][2] * i + e[4][2] * k);
929 }
930 glVertex3f((1. + extens[1]) * e[3][0] + e[1][0] * i + e[4][0] * k,
931 (1. + extens[1]) * e[3][1] + e[1][1] * i + e[4][1] * k,
932 (1. + extens[1]) * e[3][2] + e[1][2] * i + e[4][2] * k);
933 }
934 /* Z coordinate. */
935 for (i = -(int)extens[0]; i < 2 + (int)extens[0]; i++)
936 for (j = -(int)extens[1]; j < 2 + (int)extens[1]; j++)
937 {
938 glVertex3f(-extens[2] * e[4][0] + e[1][0] * i + e[3][0] * j,
939 -extens[2] * e[4][1] + e[1][1] * i + e[3][1] * j,
940 -extens[2] * e[4][2] + e[1][2] * i + e[3][2] * j);
941 if ((j == 0 || j == 1) && (i == 0 || i == 1))
942 {
943 glVertex3f(e[1][0] * i + e[3][0] * j,
944 e[1][1] * i + e[3][1] * j,
945 e[1][2] * i + e[3][2] * j);
946 glVertex3f(e[4][0] + e[1][0] * i + e[3][0] * j,
947 e[4][1] + e[1][1] * i + e[3][1] * j,
948 e[4][2] + e[1][2] * i + e[3][2] * j);
949 }
950 glVertex3f((1. + extens[2]) * e[4][0] + e[1][0] * i + e[3][0] * j,
951 (1. + extens[2]) * e[4][1] + e[1][1] * i + e[3][1] * j,
952 (1. + extens[2]) * e[4][2] + e[1][2] * i + e[3][2] * j);
953 }
954 glEnd();
955 if (box->priv->lineStipple[1] != 65535)
956 glDisable(GL_LINE_STIPPLE);
957 glTranslatef(-v[0][0], -v[0][1], -v[0][2]);
958 }
959 /* We draw sides of the box, if specified. */
960 if ((extens[0] > 0. || extens[1] > 0. || extens[2] > 0.) &&
961 box->priv->sideRGB[3] > 0.f && box->priv->sideRGB[3] < 1.f)
962 drawSides(extens, v, box->priv->sideRGB);
963
964 glEnable(GL_LIGHTING);
965 glEnable(GL_DITHER); /* WARNING: it is the default! */
966 /* Draw the basis set if needed. */
967 if (FALSE)
968 {
969 visu_box_getCentre(box->priv->box, centre);
970
971 obj = gluNewQuadric();
972 visu_gl_setHighlightColor((VisuGl*)0, material, box->priv->rgb, 1.f);
973
974 /* Draw the basis set. */
975 glPushMatrix();
976 glTranslated(0., 0., 0.);
977 glRotated(90., 0, 1, 0);
978 visu_gl_drawSmoothArrow(obj, VISU_GL_ARROW_BOTTOM_CENTERED,
979 basisLength - 0.3f, 0.1f, 10, NULL,
980 0.3f, 0.2f, 10, NULL);
981 glRasterPos3f(0.0f, 0.0f, basisLength);
982 sprintf(strLg, _("x: %7.3f"), centre[0]);
983 visu_gl_text_drawChars(strLg, VISU_GL_TEXT_SMALL);
984 glPopMatrix();
985 glPushMatrix();
986 glTranslated(0., 0., 0.);
987 glRotated(-90., 1, 0, 0);
988 visu_gl_drawSmoothArrow(obj, VISU_GL_ARROW_BOTTOM_CENTERED,
989 basisLength - 0.3f, 0.1f, 10, NULL,
990 0.3f, 0.2f, 10, NULL);
991 glRasterPos3f(0.0f, 0.0f, basisLength);
992 sprintf(strLg, _("y: %7.3f"), centre[1]);
993 visu_gl_text_drawChars(strLg, VISU_GL_TEXT_SMALL);
994 glPopMatrix();
995 glPushMatrix();
996 glTranslated(0., 0., 0.);
997 visu_gl_drawSmoothArrow(obj, VISU_GL_ARROW_BOTTOM_CENTERED,
998 basisLength - 0.3f, 0.1f, 10, NULL,
999 0.3f, 0.2f, 10, NULL);
1000 glRasterPos3f(0.0f, 0.0f, basisLength);
1001 sprintf(strLg, _("z: %7.3f"), centre[2]);
1002 visu_gl_text_drawChars(strLg, VISU_GL_TEXT_SMALL);
1003 glPopMatrix();
1004
1005 gluDeleteQuadric(obj);
1006 }
1007 glLineWidth(1.);
1008
1009 visu_gl_ext_completeDrawing(ext);
1010 }
1011
1012 /* Parameters & resources*/
1013 /* Export function that is called by visu_module to write the
1014 values of resources to a file. */
exportResourcesBox(GString * data,VisuData * dataObj _U_)1015 static void exportResourcesBox(GString *data, VisuData *dataObj _U_)
1016 {
1017 if (!defaultBox)
1018 return;
1019
1020 visu_config_file_exportComment(data, DESC_RESOURCE_BOX_USED);
1021 visu_config_file_exportEntry(data, FLAG_RESOURCE_BOX_USED, NULL,
1022 "%d", visu_gl_ext_getActive(VISU_GL_EXT(defaultBox)));
1023
1024 visu_config_file_exportComment(data, DESC_RESOURCE_BOX_COLOR);
1025 visu_config_file_exportEntry(data, FLAG_RESOURCE_BOX_COLOR, NULL,
1026 "%4.3f %4.3f %4.3f",
1027 defaultBox->priv->rgb[0], defaultBox->priv->rgb[1],
1028 defaultBox->priv->rgb[2]);
1029
1030 visu_config_file_exportComment(data, DESC_RESOURCE_BOX_LINE);
1031 visu_config_file_exportEntry(data, FLAG_RESOURCE_BOX_LINE, NULL,
1032 "%4.0f", defaultBox->priv->lineWidth);
1033
1034 visu_config_file_exportComment(data, DESC_RESOURCE_BOX_STIPPLE);
1035 visu_config_file_exportEntry(data, FLAG_RESOURCE_BOX_STIPPLE, NULL,
1036 "%d %d", defaultBox->priv->lineStipple[0],
1037 defaultBox->priv->lineStipple[1]);
1038
1039 visu_config_file_exportComment(data, DESC_RESOURCE_BOX_SIDE);
1040 visu_config_file_exportEntry(data, FLAG_RESOURCE_BOX_SIDE, NULL,
1041 "%4.3f %4.3f %4.3f %4.3f",
1042 defaultBox->priv->sideRGB[0], defaultBox->priv->sideRGB[1],
1043 defaultBox->priv->sideRGB[2], defaultBox->priv->sideRGB[3]);
1044
1045 visu_config_file_exportComment(data, "");
1046 }
1047