1 /*   EXTRAITS DE LA LICENCE
2 	Copyright CEA, contributeurs : Luc BILLARD et Damien
3 	CALISTE, laboratoire L_Sim, (2001-2005)
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-2005)
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 "iface_boxed.h"
45 
46 #include "config.h"
47 
48 /**
49  * SECTION:iface_boxed
50  * @short_description: Defines a common interface for objects with a #VisuBox.
51  * @See_also: #VisuBox, #VisuData, #VisuPlane, #VisuSurface, #VisuScalarField
52  * and #VisuGlView
53  * @Title: VisuBoxed
54  *
55  * <para></para>
56  */
57 
58 enum
59   {
60     SET_BOX_SIGNAL,
61     NB_SIGNAL
62   };
63 
64 /* Internal variables. */
65 static guint _signals[NB_SIGNAL] = { 0 };
66 
67 enum {
68   PROP_0,
69   PROP_ADJUST,
70   PROP_BOX,
71   N_PROPS
72 };
73 static GParamSpec *_properties[N_PROPS];
74 
75 /* Boxed interface. */
G_DEFINE_INTERFACE(VisuBoxed,visu_boxed,G_TYPE_OBJECT)76 G_DEFINE_INTERFACE(VisuBoxed, visu_boxed, G_TYPE_OBJECT)
77 
78 static void visu_boxed_default_init(VisuBoxedInterface *iface)
79 {
80   /**
81    * VisuBoxed::setBox:
82    * @boxed: the object which received the signal.
83    * @box: the new box.
84    *
85    * Gets emitted when the bounding box is changed.
86    *
87    * Since: 3.7
88    */
89   _signals[SET_BOX_SIGNAL] =
90     g_signal_new("setBox", G_TYPE_FROM_INTERFACE (iface),
91                  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
92                  0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
93                  G_TYPE_NONE, 1, VISU_TYPE_BOX);
94 
95   /**
96    * VisuBoxed::auto-adjust:
97    *
98    * Wether to adjust or not the contain of the #VisuBoxed object when
99    * a new box is set.
100    *
101    * Since: 3.8
102    */
103   _properties[PROP_ADJUST] =
104     g_param_spec_boolean("auto-adjust", "Automatically adjust",
105                          "Adjust internals when box is set", FALSE, G_PARAM_READWRITE);
106   g_object_interface_install_property(iface, _properties[PROP_ADJUST]);
107 
108   /**
109    * VisuBoxed::box:
110    *
111    * The box used by the boxed object.
112    *
113    * Since: 3.8
114    */
115   _properties[PROP_BOX] =
116     g_param_spec_object("box", "Box", "Box", VISU_TYPE_BOX, G_PARAM_READWRITE);
117   g_object_interface_install_property(iface, _properties[PROP_BOX]);
118 }
119 
120 /**
121  * visu_boxed_getBox:
122  * @self: a #VisuBoxed object.
123  *
124  * Retrieves the #VisuBox of @self.
125  *
126  * Since: 3.7
127  *
128  * Returns: (transfer none): the #VisuBox of @self.
129  **/
visu_boxed_getBox(VisuBoxed * self)130 VisuBox* visu_boxed_getBox(VisuBoxed *self)
131 {
132   g_return_val_if_fail(VISU_IS_BOXED(self), (VisuBox*)0);
133 
134   return VISU_BOXED_GET_INTERFACE(self)->get_box(self);
135 }
136 /**
137  * visu_boxed_setBox:
138  * @self: a #VisuBoxed object.
139  * @box: (transfer none): a #VisuBoxed object.
140  *
141  * Attach the #VisuBox of @box to @boxed. If @update is %TRUE, coordinates inside
142  * @boxed are updated to fit into the new #VisuBox. A reference is
143  * taken on the #VisuBox of @box. This routine emits #VisuBoxed::setBox
144  * signal if the @self has changed its #VisuBox.
145  *
146  * Since: 3.7
147  *
148  * Returns: FALSE @boxed was already boxed with the #VisuBox of @box.
149  **/
visu_boxed_setBox(VisuBoxed * self,VisuBoxed * box)150 gboolean visu_boxed_setBox(VisuBoxed *self, VisuBoxed *box)
151 {
152   VisuBox *boxObj;
153   gboolean res;
154 
155   g_return_val_if_fail(VISU_IS_BOXED(self), FALSE);
156 
157   boxObj = (box) ? visu_boxed_getBox(box) : (VisuBox*)0;
158   res = VISU_BOXED_GET_INTERFACE(self)->set_box(self, boxObj);
159   if (res)
160     {
161       DBG_fprintf(stderr, "Iface Boxed: notify box.\n");
162       g_object_notify_by_pspec(G_OBJECT(self), _properties[PROP_BOX]);
163       DBG_fprintf(stderr, "Iface Boxed: signal box.\n");
164       g_signal_emit(G_OBJECT(self), _signals[SET_BOX_SIGNAL], 0, boxObj);
165       DBG_fprintf(stderr, "Iface Boxed: set box done.\n");
166     }
167   return res;
168 }
169