1 /* This file is part of the hkl library.
3 * The hkl library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * The hkl library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright (C) 2003-2010 Synchrotron SOLEIL
17 * L'Orme des Merisiers Saint-Aubin
18 * BP 48 91192 GIF-sur-YVETTE CEDEX
20 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
25 #include <glib-object.h>
28 #include "hkl-gui-pseudoaxes.h"
36 #define HKL_GUI_TYPE_WINDOW (hkl_gui_window_get_type ())
37 #define HKL_GUI_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HKL_GUI_TYPE_WINDOW, HklGuiWindow))
38 #define HKL_GUI_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HKL_GUI_TYPE_WINDOW, HklGuiWindowClass))
39 #define HKL_GUI_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HKL_GUI_TYPE_WINDOW))
40 #define HKL_GUI_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HKL_GUI_TYPE_WINDOW))
41 #define HKL_GUI_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HKL_GUI_TYPE_WINDOW, HklGuiWindowClass))
43 #define EMBED_BREAKPOINT asm volatile ("int3;")
45 G_DEFINE_TYPE (HklGuiWindow
, hkl_gui_window
, G_TYPE_OBJECT
);
48 REFLECTION_COL_INDEX
= 0,
53 REFLECTION_COL_REFLECTION
,
54 REFLECTION_COL_N_COLUMNS
68 PSEUDO_AXIS_COL_PARAMETER
= 0,
69 PSEUDO_AXIS_COL_ENGINE
,
72 PSEUDO_AXIS_COL_WRITE
,
73 PSEUDO_AXIS_COL_N_COLUMNS
77 PARAMETER_COL_PARAMETER
= 0,
80 PARAMETER_COL_N_COLUMNS
84 SAMPLE_COL_SAMPLE
= 0,
96 SOLUTION_COL_INDEX
= 0,
97 SOLUTION_COL_N_COLUMNS
101 DIFFRACTOMETER_COL_NAME
= 0,
102 DIFFRACTOMETER_COL_FACTORY
,
103 DIFFRACTOMETER_COL_DIFFRACTOMETER
,
104 DIFFRACTOMETER_COL_N_COLUMNS
111 struct diffractometer_t
{
112 HklGeometry
*geometry
;
113 HklDetector
*detector
;
114 HklEngineList
*engines
;
118 static struct diffractometer_t
*
119 create_diffractometer(HklFactory
*factory
)
121 struct diffractometer_t
*self
;
123 self
= malloc(sizeof(*self
));
125 self
->geometry
= hkl_factory_create_new_geometry (factory
);
126 self
->engines
= hkl_factory_create_new_engine_list (factory
);
127 self
->detector
= hkl_detector_factory_new (HKL_DETECTOR_TYPE_0D
);
128 hkl_detector_idx_set (self
->detector
, 1);
134 delete_diffractometer(struct diffractometer_t
*self
)
136 hkl_geometry_free(self
->geometry
);
137 hkl_engine_list_free(self
->engines
);
138 hkl_detector_free(self
->detector
);
143 dump_diffractometer(struct diffractometer_t
*self
)
145 /* hkl_geometry_fprintf(stderr, self->geometry); */
146 /* hkl_engine_list_fprintf(stderr, self->engines); */
147 /* hkl_detector_fprintf(stderr, self->detector); */
151 diffractometer_engine_list_init(struct diffractometer_t
*self
,
154 g_return_if_fail(self
!= NULL
);
155 g_return_if_fail(sample
!= NULL
);
157 hkl_engine_list_init(self
->engines
,
167 struct _HklGuiWindowPrivate
{
169 GtkLabel
* _label_UB11
;
170 GtkLabel
* _label_UB12
;
171 GtkLabel
* _label_UB13
;
172 GtkLabel
* _label_UB21
;
173 GtkLabel
* _label_UB22
;
174 GtkLabel
* _label_UB23
;
175 GtkLabel
* _label_UB31
;
176 GtkLabel
* _label_UB32
;
177 GtkLabel
* _label_UB33
;
179 GtkSpinButton
* _spinbutton_a
;
180 GtkSpinButton
* _spinbutton_b
;
181 GtkSpinButton
* _spinbutton_c
;
182 GtkSpinButton
* _spinbutton_alpha
;
183 GtkSpinButton
* _spinbutton_beta
;
184 GtkSpinButton
* _spinbutton_gamma
;
185 GtkSpinButton
* _spinbutton_a_min
;
186 GtkSpinButton
* _spinbutton_b_min
;
187 GtkSpinButton
* _spinbutton_c_min
;
188 GtkSpinButton
* _spinbutton_alpha_min
;
189 GtkSpinButton
* _spinbutton_beta_min
;
190 GtkSpinButton
* _spinbutton_gamma_min
;
191 GtkSpinButton
* _spinbutton_a_max
;
192 GtkSpinButton
* _spinbutton_b_max
;
193 GtkSpinButton
* _spinbutton_c_max
;
194 GtkSpinButton
* _spinbutton_alpha_max
;
195 GtkSpinButton
* _spinbutton_beta_max
;
196 GtkSpinButton
* _spinbutton_gamma_max
;
197 GtkSpinButton
* _spinbutton_lambda
;
198 GtkSpinButton
* _spinbutton_a_star
;
199 GtkSpinButton
* _spinbutton_b_star
;
200 GtkSpinButton
* _spinbutton_c_star
;
201 GtkSpinButton
* _spinbutton_alpha_star
;
202 GtkSpinButton
* _spinbutton_beta_star
;
203 GtkSpinButton
* _spinbutton_gamma_star
;
204 GtkSpinButton
* _spinbutton_ux
;
205 GtkSpinButton
* _spinbutton_uy
;
206 GtkSpinButton
* _spinbutton_uz
;
207 GtkSpinButton
* _spinbutton_U11
;
208 GtkSpinButton
* _spinbutton_U12
;
209 GtkSpinButton
* _spinbutton_U13
;
210 GtkSpinButton
* _spinbutton_U21
;
211 GtkSpinButton
* _spinbutton_U22
;
212 GtkSpinButton
* _spinbutton_U23
;
213 GtkSpinButton
* _spinbutton_U31
;
214 GtkSpinButton
* _spinbutton_U32
;
215 GtkSpinButton
* _spinbutton_U33
;
216 GtkCheckButton
* _checkbutton_a
;
217 GtkCheckButton
* _checkbutton_b
;
218 GtkCheckButton
* _checkbutton_c
;
219 GtkCheckButton
* _checkbutton_alpha
;
220 GtkCheckButton
* _checkbutton_beta
;
221 GtkCheckButton
* _checkbutton_gamma
;
222 GtkCheckButton
* _checkbutton_ux
;
223 GtkCheckButton
* _checkbutton_uy
;
224 GtkCheckButton
* _checkbutton_uz
;
225 GtkTreeView
* _treeview_reflections
;
226 GtkTreeView
* _treeview_crystals
;
227 GtkTreeView
* _treeview_axes
;
228 GtkTreeView
* _treeview_pseudo_axes
;
229 GtkTreeView
* _treeview_pseudo_axes_parameters
;
230 GtkTreeView
* _treeview_solutions
;
231 GtkToolButton
* _toolbutton_add_reflection
;
232 GtkToolButton
* _toolbutton_goto_reflection
;
233 GtkToolButton
* _toolbutton_del_reflection
;
234 GtkToolButton
* _toolbutton_setUB
;
235 GtkToolButton
* _toolbutton_computeUB
;
236 GtkToolButton
* _toolbutton_add_crystal
;
237 GtkToolButton
* _toolbutton_copy_crystal
;
238 GtkToolButton
* _toolbutton_del_crystal
;
239 GtkToolButton
* _toolbutton_affiner
;
240 GtkStatusbar
* _statusbar
;
241 GtkImageMenuItem
* _menuitem5
;
242 GtkVBox
* _box_info_bar
; /* fake for the infor bar */
247 GtkComboBox
* _combobox1
;
248 GtkListStore
* _liststore_diffractometer
;
249 GtkListStore
* _liststore_axis
;
250 GtkListStore
* _liststore_pseudo_axes
;
251 GtkListStore
* _liststore_solutions
;
252 GtkListStore
* _liststore_reflections
;
253 GtkListStore
* _liststore_crystals
;
255 GtkInfoBar
*info_bar
;
256 GtkLabel
*info_message
;
258 darray(HklGuiEngine
*) pseudo_frames
;
260 struct diffractometer_t
*diffractometer
; /* unowned */
261 HklSample
*sample
; /* unowned */
262 HklLattice
*reciprocal
;
265 #define HKL_GUI_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), HKL_GUI_TYPE_WINDOW, HklGuiWindowPrivate))
268 finalize_liststore_diffractometer(GtkTreeModel
*model
,
273 struct diffractometer_t
*diffractometer
;
275 gtk_tree_model_get(model
, iter
,
276 DIFFRACTOMETER_COL_DIFFRACTOMETER
, &diffractometer
,
278 delete_diffractometer(diffractometer
);
283 finalize_liststore_samples(GtkTreeModel
*model
,
288 HklSample
*sample
= NULL
;
290 gtk_tree_model_get(model
, iter
,
291 SAMPLE_COL_SAMPLE
, &sample
,
293 hkl_sample_free(sample
);
298 finalize (GObject
* object
)
300 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(object
);
302 g_object_unref(priv
->builder
);
304 darray_free(priv
->pseudo_frames
);
306 gtk_tree_model_foreach(GTK_TREE_MODEL(priv
->_liststore_diffractometer
),
307 finalize_liststore_diffractometer
,
310 gtk_tree_model_foreach(GTK_TREE_MODEL(priv
->_liststore_crystals
),
311 finalize_liststore_samples
,
314 G_OBJECT_CLASS (hkl_gui_window_parent_class
)->finalize (object
);
317 HklGuiWindow
* hkl_gui_window_new (void)
319 return g_object_new (HKL_GUI_TYPE_WINDOW
, NULL
);
323 #define get_object(builder, type, priv, name) priv->_ ## name = type(gtk_builder_get_object(builder, #name))
326 hkl_gui_window_get_widgets_and_objects_from_ui (HklGuiWindow
* self
)
328 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
331 g_return_if_fail (self
!= NULL
);
333 priv
->builder
= builder
= gtk_builder_new ();
334 gtk_builder_add_from_file (builder
, "ghkl.ui", NULL
);
336 get_object(builder
, GTK_LIST_STORE
, priv
, liststore_diffractometer
);
337 get_object(builder
, GTK_LIST_STORE
, priv
, liststore_axis
);
338 get_object(builder
, GTK_LIST_STORE
, priv
, liststore_pseudo_axes
);
339 get_object(builder
, GTK_LIST_STORE
, priv
, liststore_reflections
);
340 get_object(builder
, GTK_LIST_STORE
, priv
, liststore_crystals
);
342 get_object(builder
, GTK_LABEL
, priv
, label_UB11
);
343 get_object(builder
, GTK_LABEL
, priv
, label_UB12
);
344 get_object(builder
, GTK_LABEL
, priv
, label_UB13
);
345 get_object(builder
, GTK_LABEL
, priv
, label_UB21
);
346 get_object(builder
, GTK_LABEL
, priv
, label_UB22
);
347 get_object(builder
, GTK_LABEL
, priv
, label_UB23
);
348 get_object(builder
, GTK_LABEL
, priv
, label_UB31
);
349 get_object(builder
, GTK_LABEL
, priv
, label_UB32
);
350 get_object(builder
, GTK_LABEL
, priv
, label_UB33
);
352 get_object(builder
, GTK_BUTTON
, priv
, button2
);
354 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_a
);
355 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_a_min
);
356 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_a_max
);
357 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_a_star
);
359 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_b
);
360 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_b_min
);
361 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_b_max
);
362 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_b_star
);
364 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_c
);
365 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_c_min
);
366 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_c_max
);
367 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_c_star
);
369 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_alpha
);
370 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_alpha_min
);
371 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_alpha_max
);
372 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_alpha_star
);
374 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_beta
);
375 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_beta_min
);
376 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_beta_max
);
377 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_beta_star
);
379 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_gamma
);
380 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_gamma_min
);
381 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_gamma_max
);
382 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_gamma_star
);
384 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_lambda
);
386 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_ux
);
387 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_uy
);
388 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_uz
);
390 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_U11
);
391 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_U12
);
392 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_U13
);
393 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_U21
);
394 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_U22
);
395 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_U23
);
396 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_U31
);
397 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_U32
);
398 get_object(builder
, GTK_SPIN_BUTTON
, priv
, spinbutton_U33
);
401 get_object(builder
, GTK_CHECK_BUTTON
, priv
, checkbutton_a
);
402 get_object(builder
, GTK_CHECK_BUTTON
, priv
, checkbutton_b
);
403 get_object(builder
, GTK_CHECK_BUTTON
, priv
, checkbutton_c
);
404 get_object(builder
, GTK_CHECK_BUTTON
, priv
, checkbutton_alpha
);
405 get_object(builder
, GTK_CHECK_BUTTON
, priv
, checkbutton_beta
);
406 get_object(builder
, GTK_CHECK_BUTTON
, priv
, checkbutton_gamma
);
407 get_object(builder
, GTK_CHECK_BUTTON
, priv
, checkbutton_ux
);
408 get_object(builder
, GTK_CHECK_BUTTON
, priv
, checkbutton_uy
);
409 get_object(builder
, GTK_CHECK_BUTTON
, priv
, checkbutton_uz
);
412 get_object(builder
, GTK_TREE_VIEW
, priv
, treeview_reflections
);
413 get_object(builder
, GTK_TREE_VIEW
, priv
, treeview_crystals
);
414 get_object(builder
, GTK_TREE_VIEW
, priv
, treeview_axes
);
415 get_object(builder
, GTK_TREE_VIEW
, priv
, treeview_pseudo_axes
);
416 get_object(builder
, GTK_TREE_VIEW
, priv
, treeview_solutions
);
417 priv
->_treeview_pseudo_axes_parameters
= GTK_TREE_VIEW(gtk_builder_get_object (builder
, "treeview_pseudoAxes_parameters"));
420 get_object(builder
, GTK_TOOL_BUTTON
, priv
, toolbutton_add_reflection
);
421 get_object(builder
, GTK_TOOL_BUTTON
, priv
, toolbutton_goto_reflection
);
422 get_object(builder
, GTK_TOOL_BUTTON
, priv
, toolbutton_del_reflection
);
423 get_object(builder
, GTK_TOOL_BUTTON
, priv
, toolbutton_setUB
);
424 get_object(builder
, GTK_TOOL_BUTTON
, priv
, toolbutton_computeUB
);
425 get_object(builder
, GTK_TOOL_BUTTON
, priv
, toolbutton_add_crystal
);
426 get_object(builder
, GTK_TOOL_BUTTON
, priv
, toolbutton_copy_crystal
);
427 get_object(builder
, GTK_TOOL_BUTTON
, priv
, toolbutton_del_crystal
);
428 get_object(builder
, GTK_TOOL_BUTTON
, priv
, toolbutton_affiner
);
430 get_object(builder
, GTK_STATUSBAR
, priv
, statusbar
);
432 get_object(builder
, GTK_IMAGE_MENU_ITEM
, priv
, menuitem5
);
434 get_object(builder
, GTK_VBOX
, priv
, vbox7
);
435 get_object(builder
, GTK_VBOX
, priv
, vbox2
);
436 get_object(builder
, GTK_VBOX
, priv
, box_info_bar
);
438 get_object(builder
, GTK_DIALOG
, priv
, dialog1
);
440 get_object(builder
, GTK_COMBO_BOX
, priv
, combobox1
);
442 gtk_builder_connect_signals (builder
, self
);
446 update_pseudo_axes_frames (HklGuiWindow
* self
)
448 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
449 HklGuiEngine
**engine
;
451 g_return_if_fail (self
!= NULL
);
453 darray_foreach(engine
, priv
->pseudo_frames
){
454 hkl_gui_engine_update(*engine
);
459 raise_error(HklGuiWindow
*self
, HklError
**error
)
461 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
463 g_return_if_fail (self
!= NULL
);
464 g_return_if_fail (error
!= NULL
);
466 /* show an error message */
467 gtk_label_set_text (GTK_LABEL (priv
->info_message
),
468 hkl_error_message_get(*error
));
469 gtk_info_bar_set_message_type (priv
->info_bar
,
471 gtk_widget_show (GTK_WIDGET(priv
->info_bar
));
473 hkl_error_clear(error
);
477 clear_error(HklGuiWindow
*self
, HklError
**error
)
479 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
481 g_return_if_fail (self
!= NULL
);
483 gtk_widget_hide(GTK_WIDGET(priv
->info_bar
));
487 _update_axis (GtkTreeModel
*model
, GtkTreePath
*path
,
488 GtkTreeIter
*iter
, gpointer data
)
490 HklParameter
*parameter
;
491 gdouble value
, min
, max
;
493 gtk_tree_model_get (model
, iter
,
494 AXIS_COL_AXIS
, ¶meter
,
497 hkl_parameter_min_max_unit_get(parameter
, &min
, &max
);
498 value
= hkl_parameter_value_unit_get(parameter
);
500 gtk_list_store_set(GTK_LIST_STORE(model
), iter
,
501 AXIS_COL_READ
, value
,
502 AXIS_COL_WRITE
, value
,
510 update_axes (HklGuiWindow
* self
)
512 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
514 g_return_if_fail (self
!= NULL
);
516 gtk_tree_model_foreach(GTK_TREE_MODEL(priv
->_liststore_axis
),
522 _update_pseudo_axes (GtkTreeModel
*model
, GtkTreePath
*path
,
523 GtkTreeIter
*iter
, gpointer data
)
525 HklParameter
*parameter
;
526 gdouble value
, min
, max
;
528 gtk_tree_model_get (model
, iter
,
529 PSEUDO_AXIS_COL_PARAMETER
, ¶meter
,
532 hkl_parameter_min_max_unit_get(parameter
, &min
, &max
);
533 value
= hkl_parameter_value_unit_get(parameter
);
535 gtk_list_store_set(GTK_LIST_STORE(model
), iter
,
536 PSEUDO_AXIS_COL_READ
, value
,
537 PSEUDO_AXIS_COL_WRITE
, value
,
543 update_pseudo_axes (HklGuiWindow
* self
)
545 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
547 g_return_if_fail (self
!= NULL
);
549 gtk_tree_model_foreach(GTK_TREE_MODEL(priv
->_liststore_pseudo_axes
),
555 update_solutions (HklGuiWindow
* self
)
557 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
558 const HklGeometryList
*geometries
;
559 const darray_item
*items
;
560 GtkTreeIter iter
= {0};
562 g_return_if_fail (self
!= NULL
);
564 geometries
= hkl_engine_list_geometries(priv
->diffractometer
->engines
);
566 gtk_list_store_clear(priv
->_liststore_solutions
);
567 items
= hkl_geometry_list_items_get(geometries
);
568 if (darray_size(*items
)){
569 gint n_values
= gtk_tree_model_get_n_columns (GTK_TREE_MODEL(priv
->_liststore_solutions
));
570 GValue
*values
= g_new0(GValue
, n_values
);
571 gint
*columns
= g_new0(gint
, n_values
);
574 /* prepare the GValue before using them */
575 g_value_init(&values
[0], G_TYPE_INT
);
576 for(i
=1; i
<n_values
; ++i
)
577 g_value_init(&values
[i
], G_TYPE_DOUBLE
);
579 for(i
=0; i
<darray_size(*items
);++i
){
581 const HklGeometry
*geometry
;
582 HklParameter
**parameter
;
583 const darray_parameter
*parameters
;
585 geometry
= hkl_geometry_list_item_geometry_get(darray_item(*items
, i
));
586 parameters
= hkl_geometry_axes_get(geometry
);
588 g_value_set_int(&values
[column
], i
);
591 darray_foreach(parameter
, *parameters
){
592 double value
= hkl_parameter_value_unit_get(*parameter
);
595 g_value_set_double(&values
[column
], value
);
596 columns
[column
] = column
;
598 gtk_list_store_insert_with_valuesv(priv
->_liststore_solutions
,
600 columns
, values
, n_values
);
608 update_source (HklGuiWindow
* self
)
610 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
612 g_return_if_fail (self
!= NULL
);
614 gtk_spin_button_set_value (priv
->_spinbutton_lambda
,
615 hkl_geometry_wavelength_get(priv
->diffractometer
->geometry
));
619 update_reflections (HklGuiWindow
*self
)
621 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
623 gtk_list_store_clear (priv
->_liststore_reflections
);
626 HklSampleReflection
* reflection
= NULL
;
629 reflection
= hkl_sample_first_reflection_get(priv
->sample
);
631 GtkTreeIter iter
= {0};
635 hkl_sample_reflection_hkl_get(reflection
, &h
, &k
, &l
);
636 flag
= hkl_sample_reflection_flag_get(reflection
);
638 gtk_list_store_append (priv
->_liststore_reflections
, &iter
);
640 gtk_list_store_set (priv
->_liststore_reflections
,
642 REFLECTION_COL_INDEX
, index
++,
646 REFLECTION_COL_FLAG
, flag
,
647 REFLECTION_COL_REFLECTION
, reflection
,
649 reflection
= hkl_sample_next_reflection_get(priv
->sample
,
656 hkl_engine_to_axes(HklGuiWindow
*self
, HklEngine
*engine
)
658 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
659 HklError
*error
= NULL
;
662 g_return_val_if_fail (self
!= NULL
, FALSE
);
663 g_return_val_if_fail (engine
!= NULL
, FALSE
);
665 if(hkl_engine_set(engine
, &error
)){
666 clear_error(self
, &error
);
667 hkl_engine_list_select_solution(priv
->diffractometer
->engines
, 0);
668 hkl_engine_list_get(priv
->diffractometer
->engines
);
671 update_pseudo_axes (self
);
672 update_pseudo_axes_frames (self
);
674 raise_error(self
, &error
);
675 dump_diffractometer(priv
->diffractometer
);
678 update_solutions (self
);
683 pseudo_axes_frame_changed_cb (HklGuiEngine
*gui_engine
, HklGuiWindow
*self
)
687 g_return_if_fail (self
!= NULL
);
689 g_object_get(G_OBJECT(gui_engine
),
693 hkl_engine_to_axes(self
, engine
);
697 set_up_pseudo_axes_frames (HklGuiWindow
* self
)
699 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
700 HklGuiEngine
**pseudo
;
703 darray_engine
*engines
;
705 g_return_if_fail (self
!= NULL
);
707 darray_foreach (pseudo
, priv
->pseudo_frames
){
708 gtk_container_remove(GTK_CONTAINER(priv
->_vbox2
),
709 GTK_WIDGET (hkl_gui_engine_get_frame (*pseudo
)));
710 g_object_unref(*pseudo
);
712 darray_size (priv
->pseudo_frames
) = 0;
714 engines
= hkl_engine_list_engines (priv
->diffractometer
->engines
);
715 darray_foreach (engine
, *engines
){
716 HklGuiEngine
*pseudo
;
718 pseudo
= hkl_gui_engine_new (*engine
);
719 darray_append(priv
->pseudo_frames
, pseudo
);
720 gtk_container_add (GTK_CONTAINER (priv
->_vbox2
),
721 GTK_WIDGET (hkl_gui_engine_get_frame(pseudo
)));
723 g_signal_connect_object (pseudo
,
725 G_CALLBACK(pseudo_axes_frame_changed_cb
),
729 gtk_widget_show_all (GTK_WIDGET (priv
->_vbox2
));
734 set_up_diffractometer_model (HklGuiWindow
* self
)
736 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
738 HklFactory
**factories
;
740 g_return_if_fail (self
!= NULL
);
742 factories
= hkl_factory_get_all(&n
);
744 GtkTreeIter iter
= {0};
746 gtk_list_store_append (priv
->_liststore_diffractometer
, &iter
);
747 gtk_list_store_set (priv
->_liststore_diffractometer
,
749 DIFFRACTOMETER_COL_NAME
, hkl_factory_name(factories
[i
]),
750 DIFFRACTOMETER_COL_FACTORY
, factories
[i
],
751 DIFFRACTOMETER_COL_DIFFRACTOMETER
, NULL
,
757 set_up_tree_view_axes (HklGuiWindow
* self
)
759 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
760 HklParameter
**parameter
;
761 const darray_parameter
*parameters
;
762 GtkCellRenderer
* renderer
= NULL
;
763 GtkTreeViewColumn
* column
= NULL
;
766 g_return_if_fail (self
!= NULL
);
768 gtk_list_store_clear (priv
->_liststore_axis
);
770 parameters
= hkl_geometry_axes_get(priv
->diffractometer
->geometry
);
771 darray_foreach (parameter
, *parameters
){
772 GtkTreeIter iter
= {0};
774 gtk_list_store_append (priv
->_liststore_axis
, &iter
);
775 gtk_list_store_set (priv
->_liststore_axis
, &iter
,
776 AXIS_COL_AXIS
, *parameter
,
777 AXIS_COL_NAME
, hkl_parameter_name_get(*parameter
),
785 set_up_tree_view_pseudo_axes (HklGuiWindow
* self
)
787 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
788 HklParameter
**parameter
;
789 const darray_parameter
*parameters
;
791 const darray_engine
*engines
;
793 GtkCellRendererText
* renderer
= NULL
;
794 GtkTreeViewColumn
* column
= NULL
;
797 g_return_if_fail (self
!= NULL
);
799 gtk_list_store_clear(priv
->_liststore_pseudo_axes
);
801 engines
= hkl_engine_list_engines(priv
->diffractometer
->engines
);
802 darray_foreach(engine
, *engines
){
803 parameters
= hkl_engine_pseudo_axes(*engine
);
804 darray_foreach(parameter
, *parameters
){
805 GtkTreeIter iter
= {0};
807 gtk_list_store_append (priv
->_liststore_pseudo_axes
, &iter
);
808 gtk_list_store_set (priv
->_liststore_pseudo_axes
, &iter
,
809 PSEUDO_AXIS_COL_PARAMETER
, *parameter
,
810 PSEUDO_AXIS_COL_ENGINE
, *engine
,
811 PSEUDO_AXIS_COL_NAME
, hkl_parameter_name_get(*parameter
),
816 update_pseudo_axes (self
);
820 _delete_column(gpointer data
,
823 gtk_tree_view_remove_column (GTK_TREE_VIEW(user_data
),
824 GTK_TREE_VIEW_COLUMN(data
));
828 set_up_tree_view_solutions (HklGuiWindow
* self
)
830 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
831 const darray_parameter
*parameters
;
833 GtkCellRenderer
* renderer
= NULL
;
834 GtkTreeViewColumn
* column
= NULL
;
839 g_return_if_fail (self
!= NULL
);
841 parameters
= hkl_geometry_axes_get(priv
->diffractometer
->geometry
);
843 n_columns
= SOLUTION_COL_N_COLUMNS
+ darray_size(*parameters
);
845 /* prepare types for the liststore */
846 types
= g_new0 (GType
, n_columns
);
848 /* first remove all the columns */
849 columns
= gtk_tree_view_get_columns (priv
->_treeview_solutions
);
850 g_list_foreach(columns
, _delete_column
, priv
->_treeview_solutions
);
851 g_list_free(columns
);
853 /* now add the index column */
854 renderer
= gtk_cell_renderer_text_new ();
855 column
= gtk_tree_view_column_new_with_attributes ("index",
857 SOLUTION_COL_INDEX
, NULL
);
859 gtk_tree_view_append_column (priv
->_treeview_solutions
, column
);
860 types
[0] = G_TYPE_INT
;
862 /* add the axes column */
863 for(i
=1; i
<n_columns
; ++i
){
864 HklParameter
*parameter
;
866 parameter
= darray_item(*parameters
, i
- SOLUTION_COL_N_COLUMNS
);
867 renderer
= gtk_cell_renderer_text_new ();
868 column
= gtk_tree_view_column_new_with_attributes (hkl_parameter_name_get(parameter
),
872 gtk_tree_view_append_column (priv
->_treeview_solutions
, column
);
873 types
[i
] = G_TYPE_DOUBLE
;
876 if (priv
->_liststore_solutions
)
877 g_object_unref(priv
->_liststore_solutions
);
878 priv
->_liststore_solutions
= gtk_list_store_newv (n_columns
, types
);
881 gtk_tree_view_set_model (priv
->_treeview_solutions
,
882 GTK_TREE_MODEL(priv
->_liststore_solutions
));
884 update_solutions (self
);
888 set_up_info_bar(HklGuiWindow
*self
)
890 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
891 GtkWidget
*content_area
;
893 g_return_if_fail (self
!= NULL
);
895 /* set up info bar until we can use glade for this purpose or
900 priv
->info_bar
= GTK_INFO_BAR(gtk_info_bar_new ());
901 gtk_widget_set_no_show_all (GTK_WIDGET(priv
->info_bar
), TRUE
);
903 priv
->info_message
= GTK_LABEL(gtk_label_new (""));
904 gtk_widget_show (GTK_WIDGET(priv
->info_message
));
906 content_area
= gtk_info_bar_get_content_area (GTK_INFO_BAR (priv
->info_bar
));
907 gtk_container_add (GTK_CONTAINER (content_area
),
908 GTK_WIDGET(priv
->info_message
));
909 gtk_info_bar_add_button (priv
->info_bar
,
910 GTK_STOCK_OK
, GTK_RESPONSE_OK
);
911 g_signal_connect (priv
->info_bar
, "response",
912 G_CALLBACK (gtk_widget_hide
), NULL
);
914 gtk_box_pack_start(GTK_BOX(priv
->_box_info_bar
),
915 GTK_WIDGET(priv
->info_bar
),
920 hkl_gui_window_combobox1_changed_cb(GtkComboBox
*combobox
, gpointer
*user_data
)
922 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
923 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
925 struct diffractometer_t
*dif
= NULL
;
927 GtkTreeIter iter
= {0};
929 if(gtk_combo_box_get_active_iter (combobox
, &iter
)){
930 gtk_tree_model_get(GTK_TREE_MODEL(priv
->_liststore_diffractometer
),
932 DIFFRACTOMETER_COL_FACTORY
, &factory
,
933 DIFFRACTOMETER_COL_DIFFRACTOMETER
, &dif
,
937 dif
= create_diffractometer(factory
);
938 gtk_list_store_set(priv
->_liststore_diffractometer
,
940 DIFFRACTOMETER_COL_DIFFRACTOMETER
, dif
,
945 priv
->diffractometer
= dif
;
946 /* TODO check if this is the right place for this */
947 hkl_engine_list_init(dif
->engines
, dif
->geometry
, dif
->detector
, priv
->sample
);
949 set_up_pseudo_axes_frames(self
);
950 set_up_tree_view_axes(self
);
951 //hkl_gui_window_set_up_tree_view_pseudo_axes_parameters(self);
952 set_up_tree_view_pseudo_axes(self
);
954 /* FIXME create the right solution Model Column */
955 /* this._solutionModelColumns = 0; */
956 set_up_tree_view_solutions(self
);
957 set_up_info_bar(self
);
966 hkl_gui_window_cellrendererspin1_edited_cb(GtkCellRendererText
*renderer
,
971 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
972 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
973 GtkTreeIter iter
= {0};
975 HklParameter
* parameter
= NULL
;
977 g_return_if_fail (renderer
!= NULL
);
978 g_return_if_fail (path
!= NULL
);
979 g_return_if_fail (new_text
!= NULL
);
980 g_return_if_fail (user_data
!= NULL
);
982 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv
->_liststore_axis
),
985 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_axis
), &iter
,
986 AXIS_COL_AXIS
, ¶meter
,
989 value
= atof(new_text
); /* TODO need to check for the right conversion */
990 hkl_parameter_value_unit_set (parameter
, value
, NULL
);
991 hkl_geometry_axis_set(priv
->diffractometer
->geometry
,
994 hkl_engine_list_get(priv
->diffractometer
->engines
);
996 /* ok so set the model with the new value */
997 gtk_list_store_set (priv
->_liststore_axis
, &iter
,
998 AXIS_COL_READ
, value
,
999 AXIS_COL_WRITE
, value
,
1002 update_pseudo_axes (self
);
1003 update_pseudo_axes_frames (self
);
1009 hkl_gui_window_cellrendererspin3_edited_cb(GtkCellRendererText
*renderer
,
1014 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
1015 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1016 GtkTreeIter iter
= {0};
1017 gdouble value
= 0.0;
1018 HklParameter
* parameter
= NULL
;
1021 g_return_if_fail (renderer
!= NULL
);
1022 g_return_if_fail (path
!= NULL
);
1023 g_return_if_fail (new_text
!= NULL
);
1024 g_return_if_fail (user_data
!= NULL
);
1026 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv
->_liststore_axis
),
1029 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_axis
), &iter
,
1030 AXIS_COL_AXIS
, ¶meter
,
1033 value
= atof(new_text
); /* TODO need to check for the right conversion */
1034 hkl_parameter_min_max_unit_get (parameter
, &shit
, &max
);
1035 hkl_parameter_min_max_unit_set (parameter
, value
, max
);
1037 gtk_list_store_set (priv
->_liststore_axis
, &iter
,
1038 AXIS_COL_MIN
, value
,
1041 update_pseudo_axes (self
);
1047 hkl_gui_window_cellrendererspin4_edited_cb(GtkCellRendererText
*renderer
,
1052 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
1053 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1054 GtkTreeIter iter
= {0};
1055 gdouble value
= 0.0;
1056 HklParameter
* parameter
= NULL
;
1059 g_return_if_fail (renderer
!= NULL
);
1060 g_return_if_fail (path
!= NULL
);
1061 g_return_if_fail (new_text
!= NULL
);
1062 g_return_if_fail (user_data
!= NULL
);
1064 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv
->_liststore_axis
),
1067 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_axis
), &iter
,
1068 AXIS_COL_AXIS
, ¶meter
,
1071 value
= atof(new_text
); /* TODO need to check for the right conversion */
1072 hkl_parameter_min_max_unit_get (parameter
, &min
, &shit
);
1073 hkl_parameter_min_max_unit_set (parameter
, min
, value
);
1075 gtk_list_store_set (priv
->_liststore_axis
, &iter
,
1076 AXIS_COL_MAX
, value
,
1079 update_pseudo_axes (self
);
1083 /* pseudo axis write */
1085 hkl_gui_window_cellrenderertext5_edited_cb(GtkCellRendererText
*renderer
,
1090 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
1091 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1092 GtkTreeIter iter
= {0};
1093 gdouble value
= 0.0;
1095 HklParameter
* parameter
= NULL
;
1096 HklEngine
*engine
= NULL
;
1097 HklError
*error
= NULL
;
1099 g_return_if_fail (renderer
!= NULL
);
1100 g_return_if_fail (path
!= NULL
);
1101 g_return_if_fail (new_text
!= NULL
);
1102 g_return_if_fail (user_data
!= NULL
);
1104 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv
->_liststore_pseudo_axes
),
1107 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_pseudo_axes
), &iter
,
1108 PSEUDO_AXIS_COL_PARAMETER
, ¶meter
,
1109 PSEUDO_AXIS_COL_ENGINE
, &engine
,
1112 value
= atof(new_text
); /* TODO need to check for the right conversion */
1113 old_value
= hkl_parameter_value_unit_get(parameter
);
1115 g_assert(error
!= NULL
|| error
== NULL
);
1116 hkl_parameter_value_unit_set (parameter
, value
, &error
);
1118 raise_error(self
, &error
);
1121 if (hkl_engine_to_axes(self
, engine
)){
1122 gtk_list_store_set (priv
->_liststore_pseudo_axes
,
1124 PSEUDO_AXIS_COL_WRITE
, value
,
1127 hkl_parameter_value_unit_set(parameter
, old_value
, NULL
);
1133 hkl_gui_window_treeview_solutions_cursor_changed_cb (GtkTreeView
*tree_view
,
1136 HklGuiWindow
* self
= HKL_GUI_WINDOW(user_data
);
1137 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1139 GtkTreePath
* path
= NULL
;
1140 GtkTreeViewColumn
* focus_column
= NULL
;
1141 GtkTreeIter iter
= {0};
1144 g_return_if_fail (tree_view
!= NULL
);
1145 g_return_if_fail (user_data
!= NULL
);
1147 gtk_tree_view_get_cursor (tree_view
, &path
, &focus_column
);
1148 gtk_tree_model_get_iter (GTK_TREE_MODEL(priv
->_liststore_solutions
), &iter
, path
);
1149 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_solutions
), &iter
,
1150 SOLUTION_COL_INDEX
, &index
,
1153 hkl_engine_list_select_solution (priv
->diffractometer
->engines
, index
);
1154 hkl_engine_list_get (priv
->diffractometer
->engines
);
1157 update_pseudo_axes (self
);
1158 update_pseudo_axes_frames (self
);
1160 gtk_tree_path_free (path
);
1165 hkl_gui_window_cellrenderertext7_edited_cb(GtkCellRendererText
* _sender
, const gchar
* path
,
1166 const gchar
* new_text
, gpointer self
)
1168 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1170 g_return_if_fail (self
!= NULL
);
1171 g_return_if_fail (path
!= NULL
);
1172 g_return_if_fail (new_text
!= NULL
);
1178 HklSampleReflection
* reflection
= NULL
;
1179 GtkTreeIter iter
= {0};
1181 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1183 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1185 REFLECTION_COL_REFLECTION
, &reflection
,
1188 hkl_sample_reflection_hkl_get (reflection
, &h
, &k
, &l
);
1190 hkl_sample_reflection_hkl_set (reflection
, h
, k
, l
);
1191 gtk_list_store_set (priv
->_liststore_reflections
,
1193 REFLECTION_COL_H
, h
,
1200 hkl_gui_window_cellrenderertext8_edited_cb (GtkCellRendererText
* _sender
, const gchar
* path
,
1201 const gchar
* new_text
, gpointer self
)
1203 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1205 g_return_if_fail (self
!= NULL
);
1206 g_return_if_fail (path
!= NULL
);
1207 g_return_if_fail (new_text
!= NULL
);
1213 HklSampleReflection
* reflection
= NULL
;
1214 GtkTreeIter iter
= {0};
1216 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1218 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1220 REFLECTION_COL_REFLECTION
, &reflection
,
1223 hkl_sample_reflection_hkl_get (reflection
, &h
, &k
, &l
);
1225 hkl_sample_reflection_hkl_set (reflection
, h
, k
, l
);
1226 gtk_list_store_set (priv
->_liststore_reflections
,
1228 REFLECTION_COL_K
, k
,
1235 hkl_gui_window_cellrenderertext9_edited_cb (GtkCellRendererText
* _sender
, const gchar
* path
,
1236 const gchar
* new_text
, gpointer self
)
1238 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1240 g_return_if_fail (self
!= NULL
);
1241 g_return_if_fail (path
!= NULL
);
1242 g_return_if_fail (new_text
!= NULL
);
1248 HklSampleReflection
* reflection
= NULL
;
1249 GtkTreeIter iter
= {0};
1251 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1253 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1255 REFLECTION_COL_REFLECTION
, &reflection
,
1258 hkl_sample_reflection_hkl_get (reflection
, &h
, &k
, &l
);
1260 hkl_sample_reflection_hkl_set (reflection
, h
, k
, l
);
1261 gtk_list_store_set (priv
->_liststore_reflections
,
1263 REFLECTION_COL_L
, l
,
1268 /* reflection flag */
1270 hkl_gui_window_cellrenderertoggle1_toggled_cb (GtkCellRendererToggle
* renderer
, const gchar
* path
,
1273 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1275 g_return_if_fail (self
!= NULL
);
1276 g_return_if_fail (path
!= NULL
);
1280 HklSampleReflection
* reflection
= NULL
;
1281 GtkTreeIter iter
= {0};
1283 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1285 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1287 REFLECTION_COL_REFLECTION
, &reflection
,
1290 flag
= gtk_cell_renderer_toggle_get_active(renderer
);
1291 hkl_sample_reflection_flag_set (reflection
, flag
);
1292 gtk_list_store_set (priv
->_liststore_reflections
,
1294 REFLECTION_COL_FLAG
, flag
,
1300 hkl_gui_window_treeview_reflections_key_press_event_cb (GtkWidget
* _sender
, GdkEventKey
* event
,
1307 hkl_gui_window_toolbutton_add_reflection_clicked_cb(GtkToolButton
* _sender
,
1310 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1312 if (priv
->diffractometer
== NULL
){
1313 gtk_statusbar_push (priv
->_statusbar
, 0,
1314 "Please select a diffractometer before adding reflections");
1319 HklSampleReflection
*reflection
= NULL
;
1320 GtkTreeIter iter
= {0};
1324 reflection
= hkl_sample_reflection_new(priv
->diffractometer
->geometry
,
1325 priv
->diffractometer
->detector
,
1327 hkl_sample_add_reflection(priv
->sample
, reflection
);
1328 flag
= hkl_sample_reflection_flag_get(reflection
);
1330 n_rows
= gtk_tree_model_iter_n_children(GTK_TREE_MODEL(priv
->_liststore_reflections
),
1332 gtk_list_store_insert_with_values (priv
->_liststore_reflections
,
1334 REFLECTION_COL_INDEX
, n_rows
,
1335 REFLECTION_COL_H
, 0.,
1336 REFLECTION_COL_K
, 0.,
1337 REFLECTION_COL_L
, 0.,
1338 REFLECTION_COL_FLAG
, flag
,
1339 REFLECTION_COL_REFLECTION
, reflection
,
1345 hkl_gui_window_toolbutton_goto_reflection_clicked_cb (GtkToolButton
* _sender
, gpointer user_data
)
1347 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
1348 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1350 g_return_if_fail (self
!= NULL
);
1353 GtkTreeSelection
* selection
= NULL
;
1356 selection
= gtk_tree_view_get_selection (priv
->_treeview_reflections
);
1357 nb_rows
= gtk_tree_selection_count_selected_rows (selection
);
1360 HklSampleReflection
*reflection
;
1361 GtkTreeIter iter
= {0};
1362 GtkTreeModel
* model
= NULL
;
1363 GtkTreePath
*treepath
;
1366 model
= GTK_TREE_MODEL(priv
->_liststore_reflections
);
1368 list
= gtk_tree_selection_get_selected_rows (selection
,
1371 treepath
= g_list_nth_data(list
, 0);
1373 gtk_tree_model_get_iter (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1376 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1378 REFLECTION_COL_REFLECTION
, &reflection
,
1381 hkl_geometry_set (priv
->diffractometer
->geometry
,
1382 hkl_sample_reflection_geometry_get(reflection
));
1384 update_source (self
);
1388 update_pseudo_axes (self
);
1390 g_list_free_full (list
, (GDestroyNotify
) gtk_tree_path_free
);
1393 gtk_statusbar_push (priv
->_statusbar
, 0,
1394 "Please select only one reflection.");
1396 gtk_statusbar_push (priv
->_statusbar
, 0,
1397 "Please select at least one reflection.");
1402 _del_reflection(gpointer data
, gpointer user_data
)
1404 HklSampleReflection
*reflection
;
1405 GtkTreeIter iter
= {0};
1406 GtkTreePath
*treepath
= data
;
1407 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1409 gtk_tree_model_get_iter (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1412 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_reflections
),
1414 REFLECTION_COL_REFLECTION
, &reflection
,
1416 hkl_sample_del_reflection(priv
->sample
, reflection
);
1420 hkl_gui_window_toolbutton_del_reflection_clicked_cb (GtkToolButton
* _sender
, gpointer user_data
)
1422 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
1423 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1424 HklSample
* sample
= NULL
;
1426 g_return_if_fail (self
!= NULL
);
1429 GtkTreeSelection
* selection
= NULL
;
1432 selection
= gtk_tree_view_get_selection (priv
->_treeview_reflections
);
1433 nb_rows
= gtk_tree_selection_count_selected_rows (selection
);
1435 GtkTreeModel
* model
= NULL
;
1439 GtkMessageDialog
* dialog
;
1441 model
= GTK_TREE_MODEL(priv
->_liststore_reflections
);
1442 list
= gtk_tree_selection_get_selected_rows (selection
, &model
);
1445 dialog
= GTK_MESSAGE_DIALOG(
1446 gtk_message_dialog_new (NULL
,
1447 GTK_DIALOG_DESTROY_WITH_PARENT
,
1448 GTK_MESSAGE_WARNING
,
1450 "Are you sure that you want to delete reflections"));
1452 switch (gtk_dialog_run (GTK_DIALOG(dialog
))) {
1453 case GTK_RESPONSE_YES
:
1455 g_list_foreach(list
, _del_reflection
, self
);
1456 update_reflections (self
);
1462 gtk_widget_destroy (GTK_WIDGET(dialog
));
1463 g_list_free_full (list
, (GDestroyNotify
) gtk_tree_path_free
);
1465 gtk_statusbar_push (priv
->_statusbar
, 0,
1466 "Please select at least one reflection.");
1473 hkl_gui_window_cellrenderertext10_edited_cb(GtkCellRendererText
* _sender
, const gchar
* path
,
1474 const gchar
* new_text
, gpointer user_data
)
1476 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1478 GtkTreeModel
* model
= NULL
;
1479 GtkTreeIter iter
= {0};
1480 HklSample
* sample
= NULL
;
1483 g_return_if_fail (user_data
!= NULL
);
1484 g_return_if_fail (path
!= NULL
);
1485 g_return_if_fail (new_text
!= NULL
);
1487 model
= GTK_TREE_MODEL(priv
->_liststore_crystals
);
1489 gtk_tree_model_get_iter_from_string (model
, &iter
, path
);
1491 gtk_tree_model_get (model
, &iter
,
1492 SAMPLE_COL_SAMPLE
, &sample
,
1495 hkl_sample_name_set (sample
, new_text
);
1497 gtk_list_store_set(priv
->_liststore_crystals
, &iter
,
1498 SAMPLE_COL_NAME
, new_text
,
1502 #define set_lattice(lattice, parameter) do{ \
1503 const HklParameter *p; \
1504 gdouble min, max, value; \
1506 p = hkl_lattice_## parameter ##_get((lattice)); \
1507 value = hkl_parameter_value_unit_get(p); \
1508 hkl_parameter_min_max_unit_get(p, &min, &max); \
1509 fit = hkl_parameter_fit_get(p); \
1510 gtk_spin_button_set_value(priv->_spinbutton_## parameter, value); \
1511 gtk_spin_button_set_value(priv->_spinbutton_## parameter ##_min, min); \
1512 gtk_spin_button_set_value(priv->_spinbutton_## parameter ##_max, max); \
1513 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(priv->_checkbutton_ ## parameter), fit); \
1517 update_lattice (HklGuiWindow
* self
)
1519 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1521 g_return_if_fail (self
!= NULL
);
1523 if (priv
->sample
!= NULL
) {
1524 const HklLattice
*lattice
;
1525 lattice
= hkl_sample_lattice_get(priv
->sample
);
1526 set_lattice(lattice
, a
);
1527 set_lattice(lattice
, b
);
1528 set_lattice(lattice
, c
);
1529 set_lattice(lattice
, alpha
);
1530 set_lattice(lattice
, beta
);
1531 set_lattice(lattice
, gamma
);
1535 #define set_reciprocal_lattice(lattice, parameter) do{ \
1536 const HklParameter *p; \
1538 p = hkl_lattice_## parameter ##_get((lattice)); \
1539 value = hkl_parameter_value_unit_get(p); \
1540 gtk_spin_button_set_value(priv->_spinbutton_## parameter ##_star, value); \
1544 update_reciprocal_lattice (HklGuiWindow
* self
)
1546 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1548 g_return_if_fail (self
!= NULL
);
1550 if (priv
->sample
!= NULL
) {
1551 hkl_lattice_reciprocal (hkl_sample_lattice_get(priv
->sample
),
1554 set_reciprocal_lattice(priv
->reciprocal
, a
);
1555 set_reciprocal_lattice(priv
->reciprocal
, b
);
1556 set_reciprocal_lattice(priv
->reciprocal
, c
);
1557 set_reciprocal_lattice(priv
->reciprocal
, alpha
);
1558 set_reciprocal_lattice(priv
->reciprocal
, beta
);
1559 set_reciprocal_lattice(priv
->reciprocal
, gamma
);
1563 #define set_ux_uy_uz(sample, parameter) do { \
1564 const HklParameter *p; \
1565 p = hkl_sample_## parameter ##_get((sample)); \
1566 gboolean fit = hkl_parameter_fit_get(p); \
1567 gtk_spin_button_set_value(priv->_spinbutton_## parameter, \
1568 hkl_parameter_value_unit_get(p)); \
1569 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(priv->_checkbutton_## parameter), fit); \
1573 update_ux_uy_uz (HklGuiWindow
* self
)
1575 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1577 g_return_if_fail (self
!= NULL
);
1579 if (priv
->sample
!= NULL
) {
1580 set_ux_uy_uz(priv
->sample
, ux
);
1581 set_ux_uy_uz(priv
->sample
, uy
);
1582 set_ux_uy_uz(priv
->sample
, uz
);
1587 update_UB (HklGuiWindow
* self
)
1589 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1591 g_return_if_fail (self
!= NULL
);
1593 if (priv
->sample
!= NULL
) {
1594 const HklMatrix
*UB
= hkl_sample_UB_get (priv
->sample
);
1595 gchar
*text
= g_new0 (gchar
, G_ASCII_DTOSTR_BUF_SIZE
);
1597 gtk_label_set_text(priv
->_label_UB11
,
1598 g_ascii_dtostr(text
,
1599 G_ASCII_DTOSTR_BUF_SIZE
,
1600 hkl_matrix_get(UB
, 0, 0)));
1601 gtk_label_set_text(priv
->_label_UB12
,
1602 g_ascii_dtostr(text
,
1603 G_ASCII_DTOSTR_BUF_SIZE
,
1604 hkl_matrix_get(UB
, 0, 1)));
1605 gtk_label_set_text(priv
->_label_UB13
,
1606 g_ascii_dtostr(text
,
1607 G_ASCII_DTOSTR_BUF_SIZE
,
1608 hkl_matrix_get(UB
, 0, 2)));
1609 gtk_label_set_text(priv
->_label_UB21
,
1610 g_ascii_dtostr(text
,
1611 G_ASCII_DTOSTR_BUF_SIZE
,
1612 hkl_matrix_get(UB
, 1, 0)));
1613 gtk_label_set_text(priv
->_label_UB22
,
1614 g_ascii_dtostr(text
,
1615 G_ASCII_DTOSTR_BUF_SIZE
,
1616 hkl_matrix_get(UB
, 1, 1)));
1617 gtk_label_set_text(priv
->_label_UB23
,
1618 g_ascii_dtostr(text
,
1619 G_ASCII_DTOSTR_BUF_SIZE
,
1620 hkl_matrix_get(UB
, 1, 2)));
1621 gtk_label_set_text(priv
->_label_UB31
,
1622 g_ascii_dtostr(text
,
1623 G_ASCII_DTOSTR_BUF_SIZE
,
1624 hkl_matrix_get(UB
, 2, 0)));
1625 gtk_label_set_text(priv
->_label_UB32
,
1626 g_ascii_dtostr(text
,
1627 G_ASCII_DTOSTR_BUF_SIZE
,
1628 hkl_matrix_get(UB
, 2, 1)));
1629 gtk_label_set_text(priv
->_label_UB33
,
1630 g_ascii_dtostr(text
,
1631 G_ASCII_DTOSTR_BUF_SIZE
,
1632 hkl_matrix_get(UB
, 2, 2)));
1638 hkl_gui_window_treeview_crystals_cursor_changed_cb (GtkTreeView
* _sender
, gpointer user_data
)
1640 GtkTreePath
* path
= NULL
;
1641 GtkTreeViewColumn
* column
= NULL
;
1642 GtkTreeIter iter
= {0};
1644 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
1645 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1648 g_return_if_fail (user_data
!= NULL
);
1650 gtk_tree_view_get_cursor (priv
->_treeview_crystals
, &path
, &column
);
1652 if (gtk_tree_model_get_iter (GTK_TREE_MODEL(priv
->_liststore_crystals
),
1653 &iter
, path
) == TRUE
){
1654 gtk_tree_model_get (GTK_TREE_MODEL(priv
->_liststore_crystals
),
1656 SAMPLE_COL_SAMPLE
, &sample
,
1660 priv
->sample
= sample
;
1661 diffractometer_engine_list_init(priv
->diffractometer
,
1663 update_reflections(self
);
1664 update_lattice(self
);
1665 update_reciprocal_lattice (self
);
1666 update_ux_uy_uz (self
);
1668 update_pseudo_axes (self
);
1669 update_pseudo_axes_frames (self
);
1672 gtk_tree_path_free (path
);
1679 _add_sample(HklGuiWindow
*self
, HklSample
*sample
)
1681 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1682 GtkTreeIter iter
= {0};
1683 const HklLattice
*lattice
;
1684 gdouble a
, b
, c
, alpha
, beta
, gamma
;
1686 g_return_val_if_fail (self
!= NULL
, iter
);
1688 lattice
= hkl_sample_lattice_get(sample
);
1689 a
= hkl_parameter_value_unit_get(hkl_lattice_a_get(lattice
));
1690 b
= hkl_parameter_value_unit_get(hkl_lattice_b_get(lattice
));
1691 c
= hkl_parameter_value_unit_get(hkl_lattice_c_get(lattice
));
1692 alpha
= hkl_parameter_value_unit_get(hkl_lattice_alpha_get(lattice
));
1693 beta
= hkl_parameter_value_unit_get(hkl_lattice_beta_get(lattice
));
1694 gamma
= hkl_parameter_value_unit_get(hkl_lattice_gamma_get(lattice
));
1696 gtk_list_store_insert_with_values(priv
->_liststore_crystals
,
1698 SAMPLE_COL_SAMPLE
, sample
,
1699 SAMPLE_COL_NAME
, hkl_sample_name_get(sample
),
1703 SAMPLE_COL_ALPHA
, alpha
,
1704 SAMPLE_COL_BETA
, beta
,
1705 SAMPLE_COL_GAMMA
, gamma
,
1711 set_up_tree_view_crystals (HklGuiWindow
* self
)
1713 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1714 GtkTreeIter iter
= {0};
1715 GtkTreePath
*path
= NULL
;
1717 g_return_if_fail (self
!= NULL
);
1719 iter
= _add_sample(self
, priv
->sample
);
1721 path
= gtk_tree_model_get_path(GTK_TREE_MODEL(priv
->_liststore_crystals
),
1724 gtk_tree_view_set_cursor(priv
->_treeview_crystals
, path
, NULL
, FALSE
);
1726 gtk_tree_path_free(path
);
1730 _add_sample_and_edit_name(HklGuiWindow
*self
, HklSample
*sample
)
1732 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
1733 GtkTreeIter iter
= {0};
1734 GtkTreePath
* path
= NULL
;
1735 GtkTreeViewColumn
* column
= NULL
;
1737 iter
= _add_sample(self
, sample
);
1739 path
= gtk_tree_model_get_path(GTK_TREE_MODEL(priv
->_liststore_crystals
),
1741 column
= gtk_tree_view_get_column (priv
->_treeview_crystals
, 0);
1742 gtk_tree_view_set_cursor (priv
->_treeview_crystals
, path
, column
, TRUE
);
1744 gtk_tree_path_free(path
);
1748 hkl_gui_window_toolbutton_add_crystal_clicked_cb (GtkToolButton
* _sender
, gpointer user_data
)
1750 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
1751 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1754 g_return_if_fail (user_data
!= NULL
);
1756 sample
= hkl_sample_new ("new");
1758 _add_sample_and_edit_name(self
, sample
);
1762 hkl_gui_window_toolbutton_copy_crystal_clicked_cb (GtkToolButton
* _sender
, gpointer user_data
)
1764 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
1765 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1766 HklSample
*copy
= NULL
;
1768 g_return_if_fail (self
!= NULL
);
1771 copy
= hkl_sample_new_copy(priv
->sample
);
1773 _add_sample_and_edit_name(self
, copy
);
1775 gtk_statusbar_push (priv
->_statusbar
, (guint
) 0, "Please select a crystal to copy.");
1779 hkl_gui_window_toolbutton_del_crystal_clicked_cb (GtkToolButton
* _sender
, gpointer user_data
)
1781 HklGuiWindow
*self
= HKL_GUI_WINDOW(user_data
);
1782 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(user_data
);
1784 g_return_if_fail (user_data
!= NULL
);
1786 if (priv
->sample
!= NULL
) {
1789 n_rows
= gtk_tree_model_iter_n_children(GTK_TREE_MODEL(priv
->_liststore_crystals
),
1794 GtkTreeIter iter
= {0};
1795 GtkTreePath
*path
= NULL
;
1796 GtkTreeViewColumn
*column
= NULL
;
1798 gtk_tree_view_get_cursor(priv
->_treeview_crystals
,
1801 if (gtk_tree_model_get_iter (GTK_TREE_MODEL(priv
->_liststore_crystals
),
1802 &iter
, path
) == TRUE
) {
1803 gtk_tree_path_free(path
);
1805 hkl_sample_free(priv
->sample
);
1806 if (gtk_list_store_remove(priv
->_liststore_crystals
,
1808 path
= gtk_tree_model_get_path(GTK_TREE_MODEL(priv
->_liststore_crystals
),
1810 gtk_tree_view_set_cursor(priv
->_treeview_crystals
,
1822 static void _hkl_gui_window_on_spinbutton_lambda_value_changed_gtk_spin_button_value_changed (GtkSpinButton* _sender, gpointer self) {
1824 hkl_gui_window_on_spinbutton_lambda_value_changed (self);
1829 static void _hkl_gui_window_on_spinbutton_uxuyuz_value_changed_gtk_spin_button_value_changed (GtkSpinButton* _sender, gpointer self) {
1831 hkl_gui_window_on_spinbutton_uxuyuz_value_changed (self);
1836 static void _hkl_gui_window_on_button2_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self) {
1838 hkl_gui_window_on_button2_clicked (self);
1843 static void _hkl_gui_window_on_checkbutton_a_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
1845 hkl_gui_window_on_checkbutton_a_toggled (self);
1850 static void _hkl_gui_window_on_checkbutton_b_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
1852 hkl_gui_window_on_checkbutton_b_toggled (self);
1857 static void _hkl_gui_window_on_checkbutton_c_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
1859 hkl_gui_window_on_checkbutton_c_toggled (self);
1864 static void _hkl_gui_window_on_checkbutton_alpha_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
1866 hkl_gui_window_on_checkbutton_alpha_toggled (self);
1871 static void _hkl_gui_window_on_checkbutton_beta_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
1873 hkl_gui_window_on_checkbutton_beta_toggled (self);
1878 static void _hkl_gui_window_on_checkbutton_gamma_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
1880 hkl_gui_window_on_checkbutton_gamma_toggled (self);
1885 static void _hkl_gui_window_on_checkbutton_Ux_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
1887 hkl_gui_window_on_checkbutton_Ux_toggled (self);
1892 static void _hkl_gui_window_on_checkbutton_Uy_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
1894 hkl_gui_window_on_checkbutton_Uy_toggled (self);
1899 static void _hkl_gui_window_on_checkbutton_Uz_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
1901 hkl_gui_window_on_checkbutton_Uz_toggled (self);
1906 static void _hkl_gui_window_on_tree_view_pseudo_axes_cursor_changed_gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self) {
1908 hkl_gui_window_on_tree_view_pseudo_axes_cursor_changed (self);
1913 static gboolean _hkl_gui_window_on_tree_view_crystals_key_press_event_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self) {
1915 result = hkl_gui_window_on_tree_view_crystals_key_press_event (event, self);
1924 static void _hkl_gui_window_on_toolbutton_setUB_clicked_gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
1926 hkl_gui_window_on_toolbutton_setUB_clicked (self);
1931 static void _hkl_gui_window_on_toolbutton_computeUB_clicked_gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
1933 hkl_gui_window_on_toolbutton_computeUB_clicked (self);
1938 static void _hkl_gui_window_on_toolbutton_affiner_clicked_gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
1940 hkl_gui_window_on_toolbutton_affiner_clicked (self);
1945 static void _hkl_gui_window_on_menuitem5_activate_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
1947 hkl_gui_window_on_menuitem5_activate (self);
1952 static void _hkl_gui_window_on_button1_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self) {
1954 hkl_gui_window_on_button1_clicked (self);
1959 static void _hkl_gui_window_on_combobox1_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
1961 hkl_gui_window_on_combobox1_changed (self);
1964 static void _hkl_gui_window_on_cell_tree_view_pseudo_axes_is_initialized_toggled_gtk_cell_renderer_toggle_toggled (GtkCellRendererToggle* _sender, const gchar* path, gpointer self) {
1966 hkl_gui_window_on_cell_tree_view_pseudo_axes_is_initialized_toggled (path, self);
1971 static void _hkl_gui_window_on_cell_tree_view_pseudo_axes_parameters_value_edited_gtk_cell_renderer_text_edited (GtkCellRendererText* _sender, const gchar* path, const gchar* new_text, gpointer self) {
1973 hkl_gui_window_on_cell_tree_view_pseudo_axes_parameters_value_edited (path, new_text, self);
1978 static void hkl_gui_window_set_up_tree_view_pseudo_axes_parameters (HklGuiWindow* self) {
1979 GtkCellRendererText* renderer = NULL;
1980 GtkTreeViewColumn* column = NULL;
1981 GtkTreeView* _tmp0_;
1982 GList* _tmp1_ = NULL;
1985 GtkCellRendererText* _tmp5_;
1986 GtkCellRendererText* _tmp6_;
1987 GtkTreeViewColumn* _tmp7_;
1988 GtkTreeView* _tmp8_;
1989 GtkTreeViewColumn* _tmp9_;
1990 GtkCellRendererText* _tmp10_;
1991 GtkCellRendererText* _tmp11_;
1992 GtkCellRendererText* _tmp12_;
1993 GtkCellRendererText* _tmp13_;
1994 GtkTreeViewColumn* _tmp14_;
1995 GtkTreeView* _tmp15_;
1996 GtkTreeViewColumn* _tmp16_;
1998 g_return_if_fail (self != NULL);
2000 _tmp0_ = priv->_treeview_pseudo_axes_parameters;
2002 _tmp1_ = gtk_tree_view_get_columns (_tmp0_);
2009 GList* col_collection = NULL;
2010 GList* col_it = NULL;
2012 col_collection = _tmp2_;
2014 for (col_it = col_collection; col_it != NULL; col_it = col_it->next) {
2016 GtkTreeViewColumn* col = NULL;
2018 col = (GtkTreeViewColumn*) col_it->data;
2021 GtkTreeView* _tmp3_;
2022 GtkTreeViewColumn* _tmp4_;
2024 _tmp3_ = priv->_treeview_pseudo_axes_parameters;
2028 gtk_tree_view_remove_column (_tmp3_, _tmp4_);
2034 _tmp5_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
2036 g_object_ref_sink (_tmp5_);
2038 _g_object_unref0 (renderer);
2044 _tmp7_ = gtk_tree_view_column_new_with_attributes ("name", (GtkCellRenderer*) _tmp6_, "text", PARAMETER_COL_NAME, NULL);
2046 g_object_ref_sink (_tmp7_);
2048 _g_object_unref0 (column);
2052 _tmp8_ = priv->_treeview_pseudo_axes_parameters;
2056 gtk_tree_view_append_column (_tmp8_, _tmp9_);
2058 _tmp10_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
2060 g_object_ref_sink (_tmp10_);
2062 _g_object_unref0 (renderer);
2068 g_signal_connect_object (_tmp11_, "edited", (GCallback) _hkl_gui_window_on_cell_tree_view_pseudo_axes_parameters_value_edited_gtk_cell_renderer_text_edited, self, 0);
2072 g_object_set (_tmp12_, "editable", TRUE, NULL);
2076 _tmp14_ = gtk_tree_view_column_new_with_attributes ("read", (GtkCellRenderer*) _tmp13_, "text", PARAMETER_COL_VALUE, NULL);
2078 g_object_ref_sink (_tmp14_);
2080 _g_object_unref0 (column);
2084 _tmp15_ = priv->_treeview_pseudo_axes_parameters;
2088 gtk_tree_view_append_column (_tmp15_, _tmp16_);
2090 _g_list_free0 (columns);
2092 _g_object_unref0 (column);
2094 _g_object_unref0 (renderer);
2099 static void _hkl_gui_window_on_tree_view1_cursor_changed_gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self) {
2101 hkl_gui_window_on_tree_view1_cursor_changed (self);
2111 static void hkl_gui_window_set_up_3D (HklGuiWindow* self) {
2112 HklGeometry* _tmp0_;
2113 HklGeometryConfig* _tmp1_;
2114 HklGeometryType _tmp2_;
2116 HklGui3DFrame* _tmp8_;
2117 GtkFrame* _tmp9_ = NULL;
2121 g_return_if_fail (self != NULL);
2123 _tmp0_ = priv->geometry;
2125 _tmp1_ = _tmp0_->config;
2127 _tmp2_ = (*_tmp1_).type;
2131 case HKL_GEOMETRY_TYPE_KAPPA6C:
2134 HklGeometry* _tmp3_;
2135 HklGui3DFrame* _tmp4_;
2137 _tmp3_ = priv->geometry;
2139 _tmp4_ = hkl_gui_3d_frame_new ("../data/diffabs.yaml", _tmp3_);
2141 _g_object_unref0 (priv->Frame3D);
2143 priv->Frame3D = _tmp4_;
2149 case HKL_GEOMETRY_TYPE_KAPPA4C_VERTICAL:
2152 HklGeometry* _tmp5_;
2153 HklGui3DFrame* _tmp6_;
2155 _tmp5_ = priv->geometry;
2157 _tmp6_ = hkl_gui_3d_frame_new ("../data/cristal4C.yaml", _tmp5_);
2159 _g_object_unref0 (priv->Frame3D);
2161 priv->Frame3D = _tmp6_;
2172 _tmp7_ = priv->_vbox7;
2174 _tmp8_ = priv->Frame3D;
2176 _tmp9_ = hkl_gui_3d_frame_frame (_tmp8_);
2180 gtk_box_pack_start ((GtkBox*) _tmp7_, (GtkWidget*) _tmp10_, TRUE, TRUE, (guint) 0);
2182 _g_object_unref0 (_tmp10_);
2184 _tmp11_ = priv->_vbox7;
2186 gtk_widget_show_all ((GtkWidget*) _tmp11_);
2192 static void hkl_gui_window_update_pseudo_axes_parameters (HklGuiWindow* self) {
2194 GeeMapIterator* _tmp1_ = NULL;
2195 GeeMapIterator* iter;
2197 g_return_if_fail (self != NULL);
2199 _tmp0_ = priv->hash_store_pseudo_axis_parameter;
2201 _tmp1_ = gee_abstract_map_map_iterator ((GeeAbstractMap*) _tmp0_);
2207 GeeMapIterator* _tmp2_;
2208 gboolean _tmp3_ = FALSE;
2209 GtkListStore* model = NULL;
2210 GtkTreeIter iter2 = {0};
2211 gboolean valid = FALSE;
2212 GeeMapIterator* _tmp4_;
2213 gpointer _tmp5_ = NULL;
2214 GtkListStore* _tmp6_;
2215 GtkTreeIter _tmp7_ = {0};
2216 gboolean _tmp8_ = FALSE;
2220 _tmp3_ = gee_map_iterator_next (_tmp2_);
2230 _tmp5_ = gee_map_iterator_get_value (_tmp4_);
2232 _g_object_unref0 (model);
2234 model = (GtkListStore*) _tmp5_;
2238 _tmp8_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) _tmp6_, &_tmp7_);
2247 HklParameter* parameter = NULL;
2248 GtkListStore* _tmp10_;
2249 GtkTreeIter _tmp11_;
2250 GtkListStore* _tmp12_;
2251 GtkTreeIter _tmp13_;
2252 HklParameter* _tmp14_;
2253 const gchar* _tmp15_;
2254 HklParameter* _tmp16_;
2255 HklParameter _tmp17_;
2256 gdouble _tmp18_ = 0.0;
2257 GtkListStore* _tmp19_;
2258 gboolean _tmp20_ = FALSE;
2272 gtk_tree_model_get ((GtkTreeModel*) _tmp10_, &_tmp11_, PARAMETER_COL_PARAMETER, ¶meter, -1);
2278 _tmp14_ = parameter;
2280 _tmp15_ = (*_tmp14_).name;
2282 _tmp16_ = parameter;
2286 _tmp18_ = hkl_parameter_get_value_unit (&_tmp17_);
2288 gtk_list_store_set (_tmp12_, &_tmp13_, PARAMETER_COL_NAME, _tmp15_, PARAMETER_COL_VALUE, _tmp18_, -1);
2292 _tmp20_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp19_, &iter2);
2298 _g_object_unref0 (model);
2302 _g_object_unref0 (iter);
2315 static void hkl_gui_window_on_tree_view_pseudo_axes_cursor_changed (HklGuiWindow* self) {
2316 GtkTreePath* path = NULL;
2317 GtkTreeViewColumn* focus_column = NULL;
2318 GtkListStore* model = NULL;
2319 GtkTreeIter iter = {0};
2320 HklPseudoAxis* pseudoAxis = NULL;
2321 GtkTreeView* _tmp0_;
2322 GtkTreePath* _tmp1_ = NULL;
2323 GtkTreeViewColumn* _tmp2_ = NULL;
2324 GtkTreeViewColumn* _tmp3_;
2325 GtkListStore* _tmp4_;
2326 GtkTreeIter _tmp5_ = {0};
2327 GtkListStore* _tmp6_;
2330 gpointer _tmp9_ = NULL;
2331 GtkTreeView* _tmp10_;
2333 g_return_if_fail (self != NULL);
2335 _tmp0_ = priv->_treeview_pseudo_axes;
2337 gtk_tree_view_get_cursor (_tmp0_, &_tmp1_, &_tmp2_);
2339 _gtk_tree_path_free0 (path);
2343 _g_object_unref0 (focus_column);
2345 _tmp3_ = _g_object_ref0 (_tmp2_);
2347 focus_column = _tmp3_;
2349 _tmp4_ = priv->store_pseudo_axis;
2351 gtk_tree_model_get_iter ((GtkTreeModel*) _tmp4_, &_tmp5_, path);
2355 _tmp6_ = priv->store_pseudo_axis;
2359 gtk_tree_model_get ((GtkTreeModel*) _tmp6_, &_tmp7_, PSEUDO_AXIS_COL_PSEUDOAXIS, &pseudoAxis, -1);
2361 _tmp8_ = priv->hash_store_pseudo_axis_parameter;
2363 _tmp9_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp8_, pseudoAxis);
2365 _g_object_unref0 (model);
2367 model = (GtkListStore*) _tmp9_;
2369 _tmp10_ = priv->_treeview_pseudo_axes_parameters;
2371 gtk_tree_view_set_model (_tmp10_, (GtkTreeModel*) model);
2373 _g_object_unref0 (model);
2375 _g_object_unref0 (focus_column);
2377 _gtk_tree_path_free0 (path);
2381 static void hkl_gui_window_on_spinbutton_lambda_value_changed (HklGuiWindow* self) {
2382 HklGeometry* _tmp0_;
2383 GtkSpinButton* _tmp1_;
2384 gdouble _tmp2_ = 0.0;
2386 g_return_if_fail (self != NULL);
2388 _tmp0_ = priv->geometry;
2390 _tmp1_ = priv->_spinbutton_lambda;
2392 _tmp2_ = gtk_spin_button_get_value (_tmp1_);
2394 _tmp0_->source.wave_length = _tmp2_;
2396 hkl_gui_window_update_pseudo_axes (self);
2398 hkl_gui_window_update_pseudo_axes_frames (self);
2403 static void hkl_gui_window_on_spinbutton_uxuyuz_value_changed (HklGuiWindow* self) {
2405 g_return_if_fail (self != NULL);
2410 static void hkl_gui_window_on_button2_clicked (HklGuiWindow* self) {
2411 HklSampleList* _tmp0_;
2416 g_return_if_fail (self != NULL);
2418 _tmp0_ = priv->samples;
2420 _tmp1_ = _tmp0_->current;
2426 if (_tmp2_ != NULL) {
2429 GtkSpinButton* _tmp4_;
2430 gdouble _tmp5_ = 0.0;
2431 GtkSpinButton* _tmp6_;
2432 gdouble _tmp7_ = 0.0;
2433 GtkSpinButton* _tmp8_;
2434 gdouble _tmp9_ = 0.0;
2435 GtkSpinButton* _tmp10_;
2436 gdouble _tmp11_ = 0.0;
2437 GtkSpinButton* _tmp12_;
2438 gdouble _tmp13_ = 0.0;
2439 GtkSpinButton* _tmp14_;
2440 gdouble _tmp15_ = 0.0;
2442 GtkSpinButton* _tmp17_;
2443 gdouble _tmp18_ = 0.0;
2444 GtkSpinButton* _tmp19_;
2445 gdouble _tmp20_ = 0.0;
2446 GtkSpinButton* _tmp21_;
2447 gdouble _tmp22_ = 0.0;
2449 HklLattice* _tmp24_;
2450 HklParameter* _tmp25_;
2451 GtkSpinButton* _tmp26_;
2452 gdouble _tmp27_ = 0.0;
2453 GtkSpinButton* _tmp28_;
2454 gdouble _tmp29_ = 0.0;
2455 HklParameter _tmp30_;
2457 HklLattice* _tmp32_;
2458 HklParameter* _tmp33_;
2459 GtkSpinButton* _tmp34_;
2460 gdouble _tmp35_ = 0.0;
2461 GtkSpinButton* _tmp36_;
2462 gdouble _tmp37_ = 0.0;
2463 HklParameter _tmp38_;
2465 HklLattice* _tmp40_;
2466 HklParameter* _tmp41_;
2467 GtkSpinButton* _tmp42_;
2468 gdouble _tmp43_ = 0.0;
2469 GtkSpinButton* _tmp44_;
2470 gdouble _tmp45_ = 0.0;
2471 HklParameter _tmp46_;
2473 HklLattice* _tmp48_;
2474 HklParameter* _tmp49_;
2475 GtkSpinButton* _tmp50_;
2476 gdouble _tmp51_ = 0.0;
2477 GtkSpinButton* _tmp52_;
2478 gdouble _tmp53_ = 0.0;
2479 HklParameter _tmp54_;
2481 HklLattice* _tmp56_;
2482 HklParameter* _tmp57_;
2483 GtkSpinButton* _tmp58_;
2484 gdouble _tmp59_ = 0.0;
2485 GtkSpinButton* _tmp60_;
2486 gdouble _tmp61_ = 0.0;
2487 HklParameter _tmp62_;
2489 HklLattice* _tmp64_;
2490 HklParameter* _tmp65_;
2491 GtkSpinButton* _tmp66_;
2492 gdouble _tmp67_ = 0.0;
2493 GtkSpinButton* _tmp68_;
2494 gdouble _tmp69_ = 0.0;
2495 HklParameter _tmp70_;
2500 _tmp4_ = priv->_spinbutton_a;
2502 _tmp5_ = gtk_spin_button_get_value (_tmp4_);
2504 _tmp6_ = priv->_spinbutton_b;
2506 _tmp7_ = gtk_spin_button_get_value (_tmp6_);
2508 _tmp8_ = priv->_spinbutton_c;
2510 _tmp9_ = gtk_spin_button_get_value (_tmp8_);
2512 _tmp10_ = priv->_spinbutton_alpha;
2514 _tmp11_ = gtk_spin_button_get_value (_tmp10_);
2516 _tmp12_ = priv->_spinbutton_beta;
2518 _tmp13_ = gtk_spin_button_get_value (_tmp12_);
2520 _tmp14_ = priv->_spinbutton_gamma;
2522 _tmp15_ = gtk_spin_button_get_value (_tmp14_);
2524 hkl_sample_set_lattice (_tmp3_, _tmp5_, _tmp7_, _tmp9_, _tmp11_ * HKL_DEGTORAD, _tmp13_ * HKL_DEGTORAD, _tmp15_ * HKL_DEGTORAD);
2528 _tmp17_ = priv->_spinbutton_ux;
2530 _tmp18_ = gtk_spin_button_get_value (_tmp17_);
2532 _tmp19_ = priv->_spinbutton_uy;
2534 _tmp20_ = gtk_spin_button_get_value (_tmp19_);
2536 _tmp21_ = priv->_spinbutton_uz;
2538 _tmp22_ = gtk_spin_button_get_value (_tmp21_);
2540 hkl_sample_set_U_from_euler (_tmp16_, _tmp18_ * HKL_DEGTORAD, _tmp20_ * HKL_DEGTORAD, _tmp22_ * HKL_DEGTORAD);
2544 _tmp24_ = _tmp23_->lattice;
2546 _tmp25_ = _tmp24_->a;
2548 _tmp26_ = priv->_spinbutton_a_min;
2550 _tmp27_ = gtk_spin_button_get_value (_tmp26_);
2552 _tmp28_ = priv->_spinbutton_a_max;
2554 _tmp29_ = gtk_spin_button_get_value (_tmp28_);
2558 hkl_parameter_set_range_unit (&_tmp30_, _tmp27_, _tmp29_);
2562 _tmp32_ = _tmp31_->lattice;
2564 _tmp33_ = _tmp32_->b;
2566 _tmp34_ = priv->_spinbutton_b_min;
2568 _tmp35_ = gtk_spin_button_get_value (_tmp34_);
2570 _tmp36_ = priv->_spinbutton_b_max;
2572 _tmp37_ = gtk_spin_button_get_value (_tmp36_);
2576 hkl_parameter_set_range_unit (&_tmp38_, _tmp35_, _tmp37_);
2580 _tmp40_ = _tmp39_->lattice;
2582 _tmp41_ = _tmp40_->c;
2584 _tmp42_ = priv->_spinbutton_c_min;
2586 _tmp43_ = gtk_spin_button_get_value (_tmp42_);
2588 _tmp44_ = priv->_spinbutton_c_max;
2590 _tmp45_ = gtk_spin_button_get_value (_tmp44_);
2594 hkl_parameter_set_range_unit (&_tmp46_, _tmp43_, _tmp45_);
2598 _tmp48_ = _tmp47_->lattice;
2600 _tmp49_ = _tmp48_->alpha;
2602 _tmp50_ = priv->_spinbutton_alpha_min;
2604 _tmp51_ = gtk_spin_button_get_value (_tmp50_);
2606 _tmp52_ = priv->_spinbutton_alpha_max;
2608 _tmp53_ = gtk_spin_button_get_value (_tmp52_);
2612 hkl_parameter_set_range_unit (&_tmp54_, _tmp51_, _tmp53_);
2616 _tmp56_ = _tmp55_->lattice;
2618 _tmp57_ = _tmp56_->beta;
2620 _tmp58_ = priv->_spinbutton_beta_min;
2622 _tmp59_ = gtk_spin_button_get_value (_tmp58_);
2624 _tmp60_ = priv->_spinbutton_beta_max;
2626 _tmp61_ = gtk_spin_button_get_value (_tmp60_);
2630 hkl_parameter_set_range_unit (&_tmp62_, _tmp59_, _tmp61_);
2634 _tmp64_ = _tmp63_->lattice;
2636 _tmp65_ = _tmp64_->gamma;
2638 _tmp66_ = priv->_spinbutton_gamma_min;
2640 _tmp67_ = gtk_spin_button_get_value (_tmp66_);
2642 _tmp68_ = priv->_spinbutton_gamma_max;
2644 _tmp69_ = gtk_spin_button_get_value (_tmp68_);
2648 hkl_parameter_set_range_unit (&_tmp70_, _tmp67_, _tmp69_);
2652 hkl_gui_window_update_crystal_model (self, _tmp71_);
2654 hkl_gui_window_update_reciprocal_lattice (self);
2656 hkl_gui_window_update_UB (self);
2658 hkl_gui_window_update_pseudo_axes (self);
2660 hkl_gui_window_update_pseudo_axes_frames (self);
2666 static void hkl_gui_window_on_checkbutton_a_toggled (HklGuiWindow* self) {
2667 HklSampleList* _tmp0_;
2672 g_return_if_fail (self != NULL);
2674 _tmp0_ = priv->samples;
2676 _tmp1_ = _tmp0_->current;
2682 if (_tmp2_ != NULL) {
2686 HklParameter* _tmp5_;
2687 GtkCheckButton* _tmp6_;
2688 gboolean _tmp7_ = FALSE;
2692 _tmp4_ = _tmp3_->lattice;
2696 _tmp6_ = priv->_checkbutton_a;
2698 _tmp7_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp6_);
2700 (*_tmp5_).fit = _tmp7_;
2706 static void hkl_gui_window_on_checkbutton_b_toggled (HklGuiWindow* self) {
2707 HklSampleList* _tmp0_;
2712 g_return_if_fail (self != NULL);
2714 _tmp0_ = priv->samples;
2716 _tmp1_ = _tmp0_->current;
2722 if (_tmp2_ != NULL) {
2726 HklParameter* _tmp5_;
2727 GtkCheckButton* _tmp6_;
2728 gboolean _tmp7_ = FALSE;
2732 _tmp4_ = _tmp3_->lattice;
2736 _tmp6_ = priv->_checkbutton_b;
2738 _tmp7_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp6_);
2740 (*_tmp5_).fit = _tmp7_;
2746 static void hkl_gui_window_on_checkbutton_c_toggled (HklGuiWindow* self) {
2747 HklSampleList* _tmp0_;
2752 g_return_if_fail (self != NULL);
2754 _tmp0_ = priv->samples;
2756 _tmp1_ = _tmp0_->current;
2762 if (_tmp2_ != NULL) {
2766 HklParameter* _tmp5_;
2767 GtkCheckButton* _tmp6_;
2768 gboolean _tmp7_ = FALSE;
2772 _tmp4_ = _tmp3_->lattice;
2776 _tmp6_ = priv->_checkbutton_c;
2778 _tmp7_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp6_);
2780 (*_tmp5_).fit = _tmp7_;
2786 static void hkl_gui_window_on_checkbutton_alpha_toggled (HklGuiWindow* self) {
2787 HklSampleList* _tmp0_;
2792 g_return_if_fail (self != NULL);
2794 _tmp0_ = priv->samples;
2796 _tmp1_ = _tmp0_->current;
2802 if (_tmp2_ != NULL) {
2806 HklParameter* _tmp5_;
2807 GtkCheckButton* _tmp6_;
2808 gboolean _tmp7_ = FALSE;
2812 _tmp4_ = _tmp3_->lattice;
2814 _tmp5_ = _tmp4_->alpha;
2816 _tmp6_ = priv->_checkbutton_alpha;
2818 _tmp7_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp6_);
2820 (*_tmp5_).fit = _tmp7_;
2826 static void hkl_gui_window_on_checkbutton_beta_toggled (HklGuiWindow* self) {
2827 HklSampleList* _tmp0_;
2832 g_return_if_fail (self != NULL);
2834 _tmp0_ = priv->samples;
2836 _tmp1_ = _tmp0_->current;
2842 if (_tmp2_ != NULL) {
2846 HklParameter* _tmp5_;
2847 GtkCheckButton* _tmp6_;
2848 gboolean _tmp7_ = FALSE;
2852 _tmp4_ = _tmp3_->lattice;
2854 _tmp5_ = _tmp4_->beta;
2856 _tmp6_ = priv->_checkbutton_beta;
2858 _tmp7_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp6_);
2860 (*_tmp5_).fit = _tmp7_;
2866 static void hkl_gui_window_on_checkbutton_gamma_toggled (HklGuiWindow* self) {
2867 HklSampleList* _tmp0_;
2872 g_return_if_fail (self != NULL);
2874 _tmp0_ = priv->samples;
2876 _tmp1_ = _tmp0_->current;
2882 if (_tmp2_ != NULL) {
2886 HklParameter* _tmp5_;
2887 GtkCheckButton* _tmp6_;
2888 gboolean _tmp7_ = FALSE;
2892 _tmp4_ = _tmp3_->lattice;
2894 _tmp5_ = _tmp4_->gamma;
2896 _tmp6_ = priv->_checkbutton_gamma;
2898 _tmp7_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp6_);
2900 (*_tmp5_).fit = _tmp7_;
2906 static void hkl_gui_window_on_checkbutton_Ux_toggled (HklGuiWindow* self) {
2907 HklSampleList* _tmp0_;
2912 g_return_if_fail (self != NULL);
2914 _tmp0_ = priv->samples;
2916 _tmp1_ = _tmp0_->current;
2922 if (_tmp2_ != NULL) {
2925 HklParameter* _tmp4_;
2926 GtkCheckButton* _tmp5_;
2927 gboolean _tmp6_ = FALSE;
2931 _tmp4_ = _tmp3_->ux;
2933 _tmp5_ = priv->_checkbutton_Ux;
2935 _tmp6_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp5_);
2937 (*_tmp4_).fit = _tmp6_;
2943 static void hkl_gui_window_on_checkbutton_Uy_toggled (HklGuiWindow* self) {
2944 HklSampleList* _tmp0_;
2949 g_return_if_fail (self != NULL);
2951 _tmp0_ = priv->samples;
2953 _tmp1_ = _tmp0_->current;
2959 if (_tmp2_ != NULL) {
2962 HklParameter* _tmp4_;
2963 GtkCheckButton* _tmp5_;
2964 gboolean _tmp6_ = FALSE;
2968 _tmp4_ = _tmp3_->uy;
2970 _tmp5_ = priv->_checkbutton_Uy;
2972 _tmp6_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp5_);
2974 (*_tmp4_).fit = _tmp6_;
2980 static void hkl_gui_window_on_checkbutton_Uz_toggled (HklGuiWindow* self) {
2981 HklSampleList* _tmp0_;
2986 g_return_if_fail (self != NULL);
2988 _tmp0_ = priv->samples;
2990 _tmp1_ = _tmp0_->current;
2996 if (_tmp2_ != NULL) {
2999 HklParameter* _tmp4_;
3000 GtkCheckButton* _tmp5_;
3001 gboolean _tmp6_ = FALSE;
3005 _tmp4_ = _tmp3_->uz;
3007 _tmp5_ = priv->_checkbutton_Uz;
3009 _tmp6_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp5_);
3011 (*_tmp4_).fit = _tmp6_;
3016 static void hkl_gui_window_on_cell_tree_view_pseudo_axes_is_initialized_toggled (const gchar* path, HklGuiWindow* self) {
3017 GtkTreeModel* model = NULL;
3018 GtkTreeIter iter = {0};
3019 HklPseudoAxis* pseudoAxis = NULL;
3020 gboolean old_flag = FALSE;
3021 GtkTreeView* _tmp0_;
3022 GtkTreeModel* _tmp1_ = NULL;
3023 GtkTreeModel* _tmp2_;
3024 GtkTreeModel* _tmp3_;
3025 const gchar* _tmp4_;
3026 GtkTreeIter _tmp5_ = {0};
3027 GtkTreeModel* _tmp6_;
3031 g_return_if_fail (self != NULL);
3033 g_return_if_fail (path != NULL);
3035 _tmp0_ = priv->_treeview_pseudo_axes;
3037 _tmp1_ = gtk_tree_view_get_model (_tmp0_);
3039 _tmp2_ = _g_object_ref0 (_tmp1_);
3041 _g_object_unref0 (model);
3049 gtk_tree_model_get_iter_from_string (_tmp3_, &_tmp5_, _tmp4_);
3057 gtk_tree_model_get (_tmp6_, &_tmp7_, PSEUDO_AXIS_COL_PSEUDOAXIS, &pseudoAxis, PSEUDO_AXIS_COL_INITIALIZED, &old_flag, -1);
3063 HklPseudoAxis* _tmp9_;
3064 HklPseudoAxisEngine* _tmp10_;
3065 gboolean _tmp11_ = FALSE;
3067 _tmp9_ = pseudoAxis;
3069 _tmp10_ = _tmp9_->engine;
3071 _tmp11_ = hkl_pseudo_axis_engine_initialize (_tmp10_, NULL);
3075 hkl_gui_window_update_pseudo_axes (self);
3080 _g_object_unref0 (model);
3085 static void hkl_gui_window_on_cell_tree_view_pseudo_axes_parameters_value_edited (const gchar* path, const gchar* new_text, HklGuiWindow* self) {
3086 GtkListStore* model = NULL;
3087 GtkTreeIter iter = {0};
3088 gdouble value = 0.0;
3089 HklParameter* parameter;
3090 GtkTreeView* _tmp0_;
3091 GtkTreeModel* _tmp1_ = NULL;
3092 GtkListStore* _tmp2_;
3093 const gchar* _tmp3_;
3094 GtkTreeIter _tmp4_ = {0};
3096 const gchar* _tmp6_;
3097 gdouble _tmp7_ = 0.0;
3098 HklParameter _tmp8_;
3101 g_return_if_fail (self != NULL);
3103 g_return_if_fail (path != NULL);
3105 g_return_if_fail (new_text != NULL);
3109 _tmp0_ = priv->_treeview_pseudo_axes_parameters;
3111 _tmp1_ = gtk_tree_view_get_model (_tmp0_);
3113 _tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GTK_TYPE_LIST_STORE) ? ((GtkListStore*) _tmp1_) : NULL);
3115 _g_object_unref0 (model);
3121 gtk_tree_model_get_iter_from_string ((GtkTreeModel*) model, &_tmp4_, _tmp3_);
3127 gtk_tree_model_get ((GtkTreeModel*) model, &_tmp5_, PARAMETER_COL_PARAMETER, parameter, -1);
3131 _tmp7_ = double_parse (_tmp6_);
3135 _tmp8_ = *parameter;
3137 hkl_parameter_set_value_unit (&_tmp8_, value);
3141 gtk_list_store_set (model, &_tmp9_, PARAMETER_COL_VALUE, value, -1);
3143 hkl_gui_window_update_pseudo_axes (self);
3145 hkl_gui_window_update_pseudo_axes_parameters (self);
3147 _g_object_unref0 (model);
3158 static void _gtk_tree_path_free0_ (gpointer var) {
3160 (var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL));
3165 static void _g_list_free__gtk_tree_path_free0_ (GList* self) {
3167 g_list_foreach (self, (GFunc) _gtk_tree_path_free0_, NULL);
3176 static gpointer _gtk_tree_path_copy0 (gpointer self) {
3178 return self ? gtk_tree_path_copy (self) : NULL;
3185 static void hkl_gui_window_on_toolbutton_setUB_clicked (HklGuiWindow* self) {
3186 HklSampleList* _tmp0_;
3189 g_return_if_fail (self != NULL);
3191 _tmp0_ = priv->samples;
3193 _tmp1_ = _tmp0_->current;
3195 if (_tmp1_ != NULL) {
3198 HklSampleList* _tmp2_;
3200 HklMatrix _tmp4_ = {0};
3203 gint _tmp6__length1;
3205 gint _tmp7__length1;
3206 GtkSpinButton* _tmp8_;
3207 gdouble _tmp9_ = 0.0;
3211 gint _tmp12__length1;
3213 gint _tmp13__length1;
3214 GtkSpinButton* _tmp14_;
3215 gdouble _tmp15_ = 0.0;
3219 gint _tmp18__length1;
3221 gint _tmp19__length1;
3222 GtkSpinButton* _tmp20_;
3223 gdouble _tmp21_ = 0.0;
3227 gint _tmp24__length1;
3229 gint _tmp25__length1;
3230 GtkSpinButton* _tmp26_;
3231 gdouble _tmp27_ = 0.0;
3235 gint _tmp30__length1;
3237 gint _tmp31__length1;
3238 GtkSpinButton* _tmp32_;
3239 gdouble _tmp33_ = 0.0;
3243 gint _tmp36__length1;
3245 gint _tmp37__length1;
3246 GtkSpinButton* _tmp38_;
3247 gdouble _tmp39_ = 0.0;
3251 gint _tmp42__length1;
3253 gint _tmp43__length1;
3254 GtkSpinButton* _tmp44_;
3255 gdouble _tmp45_ = 0.0;
3259 gint _tmp48__length1;
3261 gint _tmp49__length1;
3262 GtkSpinButton* _tmp50_;
3263 gdouble _tmp51_ = 0.0;
3267 gint _tmp54__length1;
3269 gint _tmp55__length1;
3270 GtkSpinButton* _tmp56_;
3271 gdouble _tmp57_ = 0.0;
3273 HklSampleList* _tmp59_;
3275 HklSampleList* _tmp61_;
3278 HklSampleList* _tmp64_;
3281 _tmp2_ = priv->samples;
3283 _tmp3_ = _tmp2_->current;
3285 hkl_sample_get_UB (_tmp3_, &_tmp4_);
3293 _tmp6_ = _tmp5_.data;
3295 _tmp6__length1 = -1;
3299 _tmp7__length1 = -1;
3301 _tmp8_ = priv->_spinbutton_U11;
3303 _tmp9_ = gtk_spin_button_get_value (_tmp8_);
3307 _tmp10_ = _tmp7_[0];
3311 _tmp12_ = _tmp11_.data;
3313 _tmp12__length1 = -1;
3315 _tmp13_ = _tmp12_[0];
3317 _tmp13__length1 = -1;
3319 _tmp14_ = priv->_spinbutton_U12;
3321 _tmp15_ = gtk_spin_button_get_value (_tmp14_);
3323 _tmp13_[1] = _tmp15_;
3325 _tmp16_ = _tmp13_[1];
3329 _tmp18_ = _tmp17_.data;
3331 _tmp18__length1 = -1;
3333 _tmp19_ = _tmp18_[0];
3335 _tmp19__length1 = -1;
3337 _tmp20_ = priv->_spinbutton_U13;
3339 _tmp21_ = gtk_spin_button_get_value (_tmp20_);
3341 _tmp19_[2] = _tmp21_;
3343 _tmp22_ = _tmp19_[2];
3347 _tmp24_ = _tmp23_.data;
3349 _tmp24__length1 = -1;
3351 _tmp25_ = _tmp24_[1];
3353 _tmp25__length1 = -1;
3355 _tmp26_ = priv->_spinbutton_U21;
3357 _tmp27_ = gtk_spin_button_get_value (_tmp26_);
3359 _tmp25_[0] = _tmp27_;
3361 _tmp28_ = _tmp25_[0];
3365 _tmp30_ = _tmp29_.data;
3367 _tmp30__length1 = -1;
3369 _tmp31_ = _tmp30_[1];
3371 _tmp31__length1 = -1;
3373 _tmp32_ = priv->_spinbutton_U22;
3375 _tmp33_ = gtk_spin_button_get_value (_tmp32_);
3377 _tmp31_[1] = _tmp33_;
3379 _tmp34_ = _tmp31_[1];
3383 _tmp36_ = _tmp35_.data;
3385 _tmp36__length1 = -1;
3387 _tmp37_ = _tmp36_[1];
3389 _tmp37__length1 = -1;
3391 _tmp38_ = priv->_spinbutton_U23;
3393 _tmp39_ = gtk_spin_button_get_value (_tmp38_);
3395 _tmp37_[2] = _tmp39_;
3397 _tmp40_ = _tmp37_[2];
3401 _tmp42_ = _tmp41_.data;
3403 _tmp42__length1 = -1;
3405 _tmp43_ = _tmp42_[2];
3407 _tmp43__length1 = -1;
3409 _tmp44_ = priv->_spinbutton_U31;
3411 _tmp45_ = gtk_spin_button_get_value (_tmp44_);
3413 _tmp43_[0] = _tmp45_;
3415 _tmp46_ = _tmp43_[0];
3419 _tmp48_ = _tmp47_.data;
3421 _tmp48__length1 = -1;
3423 _tmp49_ = _tmp48_[2];
3425 _tmp49__length1 = -1;
3427 _tmp50_ = priv->_spinbutton_U32;
3429 _tmp51_ = gtk_spin_button_get_value (_tmp50_);
3431 _tmp49_[1] = _tmp51_;
3433 _tmp52_ = _tmp49_[1];
3437 _tmp54_ = _tmp53_.data;
3439 _tmp54__length1 = -1;
3441 _tmp55_ = _tmp54_[2];
3443 _tmp55__length1 = -1;
3445 _tmp56_ = priv->_spinbutton_U33;
3447 _tmp57_ = gtk_spin_button_get_value (_tmp56_);
3449 _tmp55_[2] = _tmp57_;
3451 _tmp58_ = _tmp55_[2];
3453 _tmp59_ = priv->samples;
3455 _tmp60_ = _tmp59_->current;
3457 hkl_sample_set_UB (_tmp60_, &UB);
3459 _tmp61_ = priv->samples;
3461 _tmp62_ = _tmp61_->current;
3465 hkl_sample_fprintf (_tmp63_, _tmp62_);
3467 hkl_gui_window_update_lattice (self);
3469 hkl_gui_window_update_lattice_parameters (self);
3471 hkl_gui_window_update_reciprocal_lattice (self);
3473 _tmp64_ = priv->samples;
3475 _tmp65_ = _tmp64_->current;
3477 hkl_gui_window_update_crystal_model (self, _tmp65_);
3479 hkl_gui_window_update_UB (self);
3481 hkl_gui_window_update_UxUyUz (self);
3483 hkl_gui_window_update_pseudo_axes (self);
3485 hkl_gui_window_update_pseudo_axes_frames (self);
3493 static void hkl_gui_window_on_toolbutton_computeUB_clicked (HklGuiWindow* self) {
3494 HklSampleList* _tmp0_;
3499 g_return_if_fail (self != NULL);
3501 _tmp0_ = priv->samples;
3503 _tmp1_ = _tmp0_->current;
3509 if (_tmp2_ != NULL) {
3515 hkl_sample_compute_UB_busing_levy (_tmp3_, (gsize) 0, (gsize) 1);
3517 hkl_gui_window_update_UB (self);
3519 hkl_gui_window_update_UxUyUz (self);
3521 hkl_gui_window_update_pseudo_axes (self);
3523 hkl_gui_window_update_pseudo_axes_frames (self);
3529 static void hkl_gui_window_on_toolbutton_affiner_clicked (HklGuiWindow* self) {
3530 HklSampleList* _tmp0_;
3536 g_return_if_fail (self != NULL);
3538 _tmp0_ = priv->samples;
3540 _tmp1_ = _tmp0_->current;
3546 if (_tmp2_ != NULL) {
3552 hkl_sample_affine (_tmp3_);
3558 hkl_gui_window_update_crystal_model (self, _tmp4_);
3560 hkl_gui_window_update_lattice (self);
3562 hkl_gui_window_update_reciprocal_lattice (self);
3564 hkl_gui_window_update_UB (self);
3566 hkl_gui_window_update_UxUyUz (self);
3573 static gboolean hkl_gui_window_on_tree_view_crystals_key_press_event (GdkEventKey* event, HklGuiWindow* self) {
3574 gboolean result = FALSE;
3576 g_return_val_if_fail (self != NULL, FALSE);
3578 g_return_val_if_fail (event != NULL, FALSE);
3587 static void hkl_gui_window_on_menuitem5_activate (HklGuiWindow* self) {
3590 g_return_if_fail (self != NULL);
3592 _tmp0_ = priv->_dialog1;
3594 gtk_widget_show ((GtkWidget*) _tmp0_);
3599 void hkl_gui_window_on_button1_clicked (HklGuiWindow* self) {
3602 g_return_if_fail (self != NULL);
3604 _tmp0_ = priv->_dialog1;
3606 gtk_widget_hide ((GtkWidget*) _tmp0_);
3613 hkl_gui_window_class_init (HklGuiWindowClass
*class)
3615 GObjectClass
*gobject_class
= G_OBJECT_CLASS (class);
3617 g_type_class_add_private (class, sizeof (HklGuiWindowPrivate
));
3619 /* virtual method */
3620 gobject_class
->finalize
= finalize
;
3624 static void hkl_gui_window_init (HklGuiWindow
* self
)
3626 HklGuiWindowPrivate
*priv
= HKL_GUI_WINDOW_GET_PRIVATE(self
);
3628 priv
->diffractometer
= NULL
;
3630 darray_init(priv
->pseudo_frames
);
3632 priv
->sample
= hkl_sample_new ("test");
3633 priv
->reciprocal
= hkl_lattice_new_default ();
3635 hkl_gui_window_get_widgets_and_objects_from_ui (self
);
3637 set_up_diffractometer_model (self
);
3639 set_up_tree_view_crystals (self
);
3641 //hkl_gui_window_update_source (self);
3644 int main (int argc
, char ** argv
)
3646 gtk_init (&argc
, &argv
);
3648 hkl_gui_window_new ();