remove more useless code
[hkl.git] / gui / hkl-gui.c
blob64a769f85c59423421eb34f6082a2680cb7920a0
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>
23 #include "hkl-gui.h"
24 #include <glib.h>
25 #include <glib-object.h>
26 #include <gtk/gtk.h>
27 #include "hkl.h"
28 #include "hkl-gui-pseudoaxes.h"
29 #include <gdk/gdk.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <float.h>
33 #include <math.h>
34 #include <stdio.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);
47 typedef enum {
48 REFLECTION_COL_INDEX = 0,
49 REFLECTION_COL_H,
50 REFLECTION_COL_K,
51 REFLECTION_COL_L,
52 REFLECTION_COL_FLAG,
53 REFLECTION_COL_REFLECTION,
54 REFLECTION_COL_N_COLUMNS
55 } ReflectionCol;
57 typedef enum {
58 AXIS_COL_AXIS = 0,
59 AXIS_COL_NAME,
60 AXIS_COL_READ,
61 AXIS_COL_WRITE,
62 AXIS_COL_MIN,
63 AXIS_COL_MAX,
64 AXIS_COL_N_COLUMNS
65 } AxisCol;
67 typedef enum {
68 PSEUDO_AXIS_COL_PARAMETER = 0,
69 PSEUDO_AXIS_COL_ENGINE,
70 PSEUDO_AXIS_COL_NAME,
71 PSEUDO_AXIS_COL_READ,
72 PSEUDO_AXIS_COL_WRITE,
73 PSEUDO_AXIS_COL_N_COLUMNS
74 } PseudoAxisCol;
76 typedef enum {
77 PARAMETER_COL_PARAMETER = 0,
78 PARAMETER_COL_NAME,
79 PARAMETER_COL_VALUE,
80 PARAMETER_COL_N_COLUMNS
81 } ParameterCol;
83 typedef enum {
84 SAMPLE_COL_SAMPLE = 0,
85 SAMPLE_COL_NAME,
86 SAMPLE_COL_A,
87 SAMPLE_COL_B,
88 SAMPLE_COL_C,
89 SAMPLE_COL_ALPHA,
90 SAMPLE_COL_BETA,
91 SAMPLE_COL_GAMMA,
92 SAMPLE_COL_N_COLUMNS
93 } SampleCol;
95 typedef enum {
96 SOLUTION_COL_INDEX = 0,
97 SOLUTION_COL_N_COLUMNS
98 } SolutionCol;
100 typedef enum {
101 DIFFRACTOMETER_COL_NAME = 0,
102 DIFFRACTOMETER_COL_FACTORY,
103 DIFFRACTOMETER_COL_DIFFRACTOMETER,
104 DIFFRACTOMETER_COL_N_COLUMNS
105 } DiffractometerCol;
107 /******************/
108 /* Diffractometer */
109 /******************/
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);
130 return self;
133 static void
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);
142 static void
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); */
150 static void
151 diffractometer_engine_list_init(struct diffractometer_t *self,
152 HklSample *sample)
154 g_return_if_fail(self != NULL);
155 g_return_if_fail(sample != NULL);
157 hkl_engine_list_init(self->engines,
158 self->geometry,
159 self->detector,
160 sample);
163 /****************/
164 /* HklGuiWindow */
165 /****************/
167 struct _HklGuiWindowPrivate {
168 GtkBuilder* builder;
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;
178 GtkButton* _button2;
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 */
243 GtkVBox* _vbox7;
244 GtkVBox* _vbox2;
245 GtkDialog* _dialog1;
246 GtkButton* _button1;
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))
267 static gboolean
268 finalize_liststore_diffractometer(GtkTreeModel *model,
269 GtkTreePath *path,
270 GtkTreeIter *iter,
271 gpointer data)
273 struct diffractometer_t *diffractometer;
275 gtk_tree_model_get(model, iter,
276 DIFFRACTOMETER_COL_DIFFRACTOMETER, &diffractometer,
277 -1);
278 delete_diffractometer(diffractometer);
279 return FALSE;
282 static gboolean
283 finalize_liststore_samples(GtkTreeModel *model,
284 GtkTreePath *path,
285 GtkTreeIter *iter,
286 gpointer data)
288 HklSample *sample = NULL;
290 gtk_tree_model_get(model, iter,
291 SAMPLE_COL_SAMPLE, &sample,
292 -1);
293 hkl_sample_free(sample);
294 return FALSE;
297 static void
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,
308 NULL);
310 gtk_tree_model_foreach(GTK_TREE_MODEL(priv->_liststore_crystals),
311 finalize_liststore_samples,
312 NULL);
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))
325 static void
326 hkl_gui_window_get_widgets_and_objects_from_ui (HklGuiWindow* self)
328 HklGuiWindowPrivate *priv = HKL_GUI_WINDOW_GET_PRIVATE(self);
329 GtkBuilder* builder;
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);
445 static void
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);
458 static void
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,
470 GTK_MESSAGE_ERROR);
471 gtk_widget_show (GTK_WIDGET(priv->info_bar));
473 hkl_error_clear(error);
476 static void
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));
486 static gboolean
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, &parameter,
495 -1);
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,
503 AXIS_COL_MIN, min,
504 AXIS_COL_MAX, max,
505 -1);
506 return FALSE;
509 static void
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),
517 _update_axis,
518 self);
521 static gboolean
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, &parameter,
530 -1);
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,
538 -1);
539 return FALSE;
542 static void
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),
550 _update_pseudo_axes,
551 self);
554 static void
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);
572 gint i;
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){
580 gint column = 0;
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);
589 columns[0] = column;
591 darray_foreach(parameter, *parameters){
592 double value = hkl_parameter_value_unit_get(*parameter);
594 column = column + 1;
595 g_value_set_double(&values[column], value);
596 columns[column] = column;
598 gtk_list_store_insert_with_valuesv(priv->_liststore_solutions,
599 &iter, i,
600 columns, values, n_values);
602 g_free(columns);
603 g_free(values);
607 static void
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));
618 static void
619 update_reflections (HklGuiWindow *self)
621 HklGuiWindowPrivate *priv = HKL_GUI_WINDOW_GET_PRIVATE(self);
623 gtk_list_store_clear (priv->_liststore_reflections);
625 if(priv->sample){
626 HklSampleReflection* reflection = NULL;
627 guint index = 0;
629 reflection = hkl_sample_first_reflection_get(priv->sample);
630 while(reflection){
631 GtkTreeIter iter = {0};
632 gdouble h, k, l;
633 gboolean flag;
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,
641 &iter,
642 REFLECTION_COL_INDEX, index++,
643 REFLECTION_COL_H, h,
644 REFLECTION_COL_K, k,
645 REFLECTION_COL_L, l,
646 REFLECTION_COL_FLAG, flag,
647 REFLECTION_COL_REFLECTION, reflection,
648 -1);
649 reflection = hkl_sample_next_reflection_get(priv->sample,
650 reflection);
655 static gboolean
656 hkl_engine_to_axes(HklGuiWindow *self, HklEngine *engine)
658 HklGuiWindowPrivate *priv = HKL_GUI_WINDOW_GET_PRIVATE(self);
659 HklError *error = NULL;
660 gboolean res = TRUE;
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);
670 update_axes (self);
671 update_pseudo_axes (self);
672 update_pseudo_axes_frames (self);
673 }else{
674 raise_error(self, &error);
675 dump_diffractometer(priv->diffractometer);
676 res = FALSE;
678 update_solutions (self);
679 return res;
682 static void
683 pseudo_axes_frame_changed_cb (HklGuiEngine *gui_engine, HklGuiWindow *self)
685 HklEngine *engine;
687 g_return_if_fail (self != NULL);
689 g_object_get(G_OBJECT(gui_engine),
690 "engine", &engine,
691 NULL);
693 hkl_engine_to_axes(self, engine);
696 static void
697 set_up_pseudo_axes_frames (HklGuiWindow* self)
699 HklGuiWindowPrivate *priv = HKL_GUI_WINDOW_GET_PRIVATE(self);
700 HklGuiEngine **pseudo;
701 GtkVBox* vbox2;
702 HklEngine **engine;
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,
724 "changed",
725 G_CALLBACK(pseudo_axes_frame_changed_cb),
726 self, 0);
729 gtk_widget_show_all (GTK_WIDGET (priv->_vbox2));
733 static void
734 set_up_diffractometer_model (HklGuiWindow* self)
736 HklGuiWindowPrivate *priv = HKL_GUI_WINDOW_GET_PRIVATE(self);
737 unsigned int i, n;
738 HklFactory **factories;
740 g_return_if_fail (self != NULL);
742 factories = hkl_factory_get_all(&n);
743 for(i=0; i<n; ++i){
744 GtkTreeIter iter = {0};
746 gtk_list_store_append (priv->_liststore_diffractometer, &iter);
747 gtk_list_store_set (priv->_liststore_diffractometer,
748 &iter,
749 DIFFRACTOMETER_COL_NAME, hkl_factory_name(factories[i]),
750 DIFFRACTOMETER_COL_FACTORY, factories[i],
751 DIFFRACTOMETER_COL_DIFFRACTOMETER, NULL,
752 -1);
756 static void
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;
764 GList* columns;
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),
778 -1);
781 update_axes (self);
784 static void
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;
790 HklEngine **engine;
791 const darray_engine *engines;
793 GtkCellRendererText* renderer = NULL;
794 GtkTreeViewColumn* column = NULL;
795 GList* columns;
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),
812 -1);
816 update_pseudo_axes (self);
819 static void
820 _delete_column(gpointer data,
821 gpointer user_data)
823 gtk_tree_view_remove_column (GTK_TREE_VIEW(user_data),
824 GTK_TREE_VIEW_COLUMN(data));
827 static void
828 set_up_tree_view_solutions (HklGuiWindow* self)
830 HklGuiWindowPrivate *priv = HKL_GUI_WINDOW_GET_PRIVATE(self);
831 const darray_parameter *parameters;
832 int i;
833 GtkCellRenderer* renderer = NULL;
834 GtkTreeViewColumn* column = NULL;
835 GList* columns;
836 GType* types;
837 gint n_columns;
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",
856 renderer, "text",
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),
869 renderer, "text",
870 i, NULL);
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);
879 g_free (types);
881 gtk_tree_view_set_model (priv->_treeview_solutions,
882 GTK_TREE_MODEL(priv->_liststore_solutions));
884 update_solutions (self);
887 void
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
896 * switch to gtk3 */
897 if (priv->info_bar)
898 return;
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),
916 TRUE, TRUE, 0);
919 void
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);
924 HklFactory *factory;
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),
931 &iter,
932 DIFFRACTOMETER_COL_FACTORY, &factory,
933 DIFFRACTOMETER_COL_DIFFRACTOMETER, &dif,
934 -1);
936 if (!dif){
937 dif = create_diffractometer(factory);
938 gtk_list_store_set(priv->_liststore_diffractometer,
939 &iter,
940 DIFFRACTOMETER_COL_DIFFRACTOMETER, dif,
941 -1);
943 printf("toto\n");
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);
958 #if HKL3D
959 set_up_3D(self);
960 #endif
964 /* axis read cb */
965 void
966 hkl_gui_window_cellrendererspin1_edited_cb(GtkCellRendererText *renderer,
967 gchar *path,
968 gchar *new_text,
969 gpointer user_data)
971 HklGuiWindow *self = HKL_GUI_WINDOW(user_data);
972 HklGuiWindowPrivate *priv = HKL_GUI_WINDOW_GET_PRIVATE(user_data);
973 GtkTreeIter iter = {0};
974 gdouble value = 0.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),
983 &iter,
984 path);
985 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_axis), &iter,
986 AXIS_COL_AXIS, &parameter,
987 -1);
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,
992 parameter);
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,
1000 -1);
1002 update_pseudo_axes (self);
1003 update_pseudo_axes_frames (self);
1007 /* axis min cb */
1008 void
1009 hkl_gui_window_cellrendererspin3_edited_cb(GtkCellRendererText *renderer,
1010 gchar *path,
1011 gchar *new_text,
1012 gpointer user_data)
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;
1019 gdouble shit, max;
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),
1027 &iter,
1028 path);
1029 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_axis), &iter,
1030 AXIS_COL_AXIS, &parameter,
1031 -1);
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,
1039 -1);
1041 update_pseudo_axes (self);
1045 /* axis max cb */
1046 void
1047 hkl_gui_window_cellrendererspin4_edited_cb(GtkCellRendererText *renderer,
1048 gchar *path,
1049 gchar *new_text,
1050 gpointer user_data)
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;
1057 gdouble shit, min;
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),
1065 &iter,
1066 path);
1067 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_axis), &iter,
1068 AXIS_COL_AXIS, &parameter,
1069 -1);
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,
1077 -1);
1079 update_pseudo_axes (self);
1083 /* pseudo axis write */
1084 void
1085 hkl_gui_window_cellrenderertext5_edited_cb(GtkCellRendererText *renderer,
1086 gchar *path,
1087 gchar *new_text,
1088 gpointer user_data)
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;
1094 gdouble old_value;
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),
1105 &iter,
1106 path);
1107 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_pseudo_axes), &iter,
1108 PSEUDO_AXIS_COL_PARAMETER, &parameter,
1109 PSEUDO_AXIS_COL_ENGINE, &engine,
1110 -1);
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);
1117 if(error != NULL){
1118 raise_error(self, &error);
1121 if (hkl_engine_to_axes(self, engine)){
1122 gtk_list_store_set (priv->_liststore_pseudo_axes,
1123 &iter,
1124 PSEUDO_AXIS_COL_WRITE, value,
1125 -1);
1126 }else{
1127 hkl_parameter_value_unit_set(parameter, old_value, NULL);
1132 void
1133 hkl_gui_window_treeview_solutions_cursor_changed_cb (GtkTreeView *tree_view,
1134 gpointer user_data)
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};
1142 gsize index = 0UL;
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,
1151 -1);
1153 hkl_engine_list_select_solution (priv->diffractometer->engines, index);
1154 hkl_engine_list_get (priv->diffractometer->engines);
1156 update_axes (self);
1157 update_pseudo_axes (self);
1158 update_pseudo_axes_frames (self);
1160 gtk_tree_path_free (path);
1163 /* reflection h */
1164 void
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);
1174 if (priv->sample){
1175 gdouble h = 0.0;
1176 gdouble k = 0.0;
1177 gdouble l = 0.0;
1178 HklSampleReflection* reflection = NULL;
1179 GtkTreeIter iter = {0};
1181 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv->_liststore_reflections),
1182 &iter, path);
1183 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_reflections),
1184 &iter,
1185 REFLECTION_COL_REFLECTION, &reflection,
1186 -1);
1188 hkl_sample_reflection_hkl_get (reflection, &h, &k, &l);
1189 h = atof(new_text);
1190 hkl_sample_reflection_hkl_set (reflection, h, k, l);
1191 gtk_list_store_set (priv->_liststore_reflections,
1192 &iter,
1193 REFLECTION_COL_H, h,
1194 -1);
1198 /* reflection k */
1199 void
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);
1209 if (priv->sample){
1210 gdouble h = 0.0;
1211 gdouble k = 0.0;
1212 gdouble l = 0.0;
1213 HklSampleReflection* reflection = NULL;
1214 GtkTreeIter iter = {0};
1216 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv->_liststore_reflections),
1217 &iter, path);
1218 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_reflections),
1219 &iter,
1220 REFLECTION_COL_REFLECTION, &reflection,
1221 -1);
1223 hkl_sample_reflection_hkl_get (reflection, &h, &k, &l);
1224 k = atof(new_text);
1225 hkl_sample_reflection_hkl_set (reflection, h, k, l);
1226 gtk_list_store_set (priv->_liststore_reflections,
1227 &iter,
1228 REFLECTION_COL_K, k,
1229 -1);
1233 /* reflection l */
1234 void
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);
1244 if (priv->sample){
1245 gdouble h = 0.0;
1246 gdouble k = 0.0;
1247 gdouble l = 0.0;
1248 HklSampleReflection* reflection = NULL;
1249 GtkTreeIter iter = {0};
1251 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv->_liststore_reflections),
1252 &iter, path);
1253 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_reflections),
1254 &iter,
1255 REFLECTION_COL_REFLECTION, &reflection,
1256 -1);
1258 hkl_sample_reflection_hkl_get (reflection, &h, &k, &l);
1259 l = atof(new_text);
1260 hkl_sample_reflection_hkl_set (reflection, h, k, l);
1261 gtk_list_store_set (priv->_liststore_reflections,
1262 &iter,
1263 REFLECTION_COL_L, l,
1264 -1);
1268 /* reflection flag */
1269 void
1270 hkl_gui_window_cellrenderertoggle1_toggled_cb (GtkCellRendererToggle* renderer, const gchar* path,
1271 gpointer self)
1273 HklGuiWindowPrivate *priv = HKL_GUI_WINDOW_GET_PRIVATE(self);
1275 g_return_if_fail (self != NULL);
1276 g_return_if_fail (path != NULL);
1278 if (priv->sample){
1279 gboolean flag;
1280 HklSampleReflection* reflection = NULL;
1281 GtkTreeIter iter = {0};
1283 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(priv->_liststore_reflections),
1284 &iter, path);
1285 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_reflections),
1286 &iter,
1287 REFLECTION_COL_REFLECTION, &reflection,
1288 -1);
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,
1293 &iter,
1294 REFLECTION_COL_FLAG, flag,
1295 -1);
1299 gboolean
1300 hkl_gui_window_treeview_reflections_key_press_event_cb (GtkWidget* _sender, GdkEventKey* event,
1301 gpointer self)
1303 return TRUE;
1306 void
1307 hkl_gui_window_toolbutton_add_reflection_clicked_cb(GtkToolButton* _sender,
1308 gpointer self)
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");
1315 return;
1318 if (priv->sample) {
1319 HklSampleReflection *reflection = NULL;
1320 GtkTreeIter iter = {0};
1321 gboolean flag;
1322 gint n_rows;
1324 reflection = hkl_sample_reflection_new(priv->diffractometer->geometry,
1325 priv->diffractometer->detector,
1326 0, 0, 0);
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),
1331 NULL );
1332 gtk_list_store_insert_with_values (priv->_liststore_reflections,
1333 &iter, -1,
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,
1340 -1);
1344 void
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);
1352 if (priv->sample) {
1353 GtkTreeSelection* selection = NULL;
1354 guint nb_rows = 0U;
1356 selection = gtk_tree_view_get_selection (priv->_treeview_reflections);
1357 nb_rows = gtk_tree_selection_count_selected_rows (selection);
1359 if (nb_rows == 1) {
1360 HklSampleReflection *reflection;
1361 GtkTreeIter iter = {0};
1362 GtkTreeModel* model = NULL;
1363 GtkTreePath *treepath;
1364 GList* list;
1366 model = GTK_TREE_MODEL(priv->_liststore_reflections);
1368 list = gtk_tree_selection_get_selected_rows (selection,
1369 &model);
1371 treepath = g_list_nth_data(list, 0);
1373 gtk_tree_model_get_iter (GTK_TREE_MODEL(priv->_liststore_reflections),
1374 &iter, treepath);
1376 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_reflections),
1377 &iter,
1378 REFLECTION_COL_REFLECTION, &reflection,
1379 -1);
1381 hkl_geometry_set (priv->diffractometer->geometry,
1382 hkl_sample_reflection_geometry_get(reflection));
1384 update_source (self);
1386 update_axes (self);
1388 update_pseudo_axes (self);
1390 g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
1391 } else
1392 if (nb_rows > 1)
1393 gtk_statusbar_push (priv->_statusbar, 0,
1394 "Please select only one reflection.");
1395 else
1396 gtk_statusbar_push (priv->_statusbar, 0,
1397 "Please select at least one reflection.");
1401 static void
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),
1410 &iter, treepath);
1412 gtk_tree_model_get (GTK_TREE_MODEL(priv->_liststore_reflections),
1413 &iter,
1414 REFLECTION_COL_REFLECTION, &reflection,
1415 -1);
1416 hkl_sample_del_reflection(priv->sample, reflection);
1419 void
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);
1428 if (priv->sample) {
1429 GtkTreeSelection* selection = NULL;
1430 guint nb_rows = 0U;
1432 selection = gtk_tree_view_get_selection (priv->_treeview_reflections);
1433 nb_rows = gtk_tree_selection_count_selected_rows (selection);
1434 if (nb_rows > 0) {
1435 GtkTreeModel* model = NULL;
1436 GList* list;
1437 guint* indexes;
1438 gint i;
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,
1449 GTK_BUTTONS_YES_NO,
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);
1457 break;
1459 default:
1460 break;
1462 gtk_widget_destroy (GTK_WIDGET(dialog));
1463 g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
1464 } else {
1465 gtk_statusbar_push (priv->_statusbar, 0,
1466 "Please select at least one reflection.");
1471 /* crystal name */
1472 void
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;
1481 gchar* name = 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,
1493 -1);
1495 hkl_sample_name_set (sample, new_text);
1497 gtk_list_store_set(priv->_liststore_crystals, &iter,
1498 SAMPLE_COL_NAME, new_text,
1499 -1);
1502 #define set_lattice(lattice, parameter) do{ \
1503 const HklParameter *p; \
1504 gdouble min, max, value; \
1505 gboolean fit; \
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); \
1514 }while(0)
1516 static void
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; \
1537 gdouble value; \
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); \
1541 }while(0)
1543 static void
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),
1552 priv->reciprocal);
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); \
1570 }while(0)
1572 static void
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);
1586 static void
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)));
1633 g_free(text);
1637 void
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);
1646 HklSample *sample;
1648 g_return_if_fail (user_data != NULL);
1650 gtk_tree_view_get_cursor (priv->_treeview_crystals, &path, &column);
1651 if(path){
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),
1655 &iter,
1656 SAMPLE_COL_SAMPLE, &sample,
1657 -1);
1659 if(sample){
1660 priv->sample = sample;
1661 diffractometer_engine_list_init(priv->diffractometer,
1662 priv->sample);
1663 update_reflections(self);
1664 update_lattice(self);
1665 update_reciprocal_lattice (self);
1666 update_ux_uy_uz (self);
1667 update_UB (self);
1668 update_pseudo_axes (self);
1669 update_pseudo_axes_frames (self);
1672 gtk_tree_path_free (path);
1678 static GtkTreeIter
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,
1697 &iter, -1,
1698 SAMPLE_COL_SAMPLE, sample,
1699 SAMPLE_COL_NAME, hkl_sample_name_get(sample),
1700 SAMPLE_COL_A, a,
1701 SAMPLE_COL_B, b,
1702 SAMPLE_COL_C, c,
1703 SAMPLE_COL_ALPHA, alpha,
1704 SAMPLE_COL_BETA, beta,
1705 SAMPLE_COL_GAMMA, gamma,
1706 -1);
1707 return iter;
1710 static void
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),
1722 &iter);
1724 gtk_tree_view_set_cursor(priv->_treeview_crystals, path, NULL, FALSE);
1726 gtk_tree_path_free(path);
1729 static void
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),
1740 &iter);
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);
1747 void
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);
1752 HklSample *sample;
1754 g_return_if_fail (user_data != NULL);
1756 sample = hkl_sample_new ("new");
1757 if(sample)
1758 _add_sample_and_edit_name(self, sample);
1761 void
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);
1770 if(priv->sample) {
1771 copy = hkl_sample_new_copy(priv->sample);
1772 if (copy)
1773 _add_sample_and_edit_name(self, copy);
1774 }else
1775 gtk_statusbar_push (priv->_statusbar, (guint) 0, "Please select a crystal to copy.");
1778 void
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) {
1787 guint n_rows;
1789 n_rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(priv->_liststore_crystals),
1790 NULL );
1791 if (n_rows == 1)
1792 return;
1793 else {
1794 GtkTreeIter iter = {0};
1795 GtkTreePath *path = NULL;
1796 GtkTreeViewColumn *column = NULL;
1798 gtk_tree_view_get_cursor(priv->_treeview_crystals,
1799 &path, &column);
1800 if (path){
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,
1807 &iter) == TRUE){
1808 path = gtk_tree_model_get_path(GTK_TREE_MODEL(priv->_liststore_crystals),
1809 &iter);
1810 gtk_tree_view_set_cursor(priv->_treeview_crystals,
1811 path, NULL, FALSE);
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) {
1914 gboolean result;
1915 result = hkl_gui_window_on_tree_view_crystals_key_press_event (event, self);
1917 return result;
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;
1983 GList* columns;
1984 GList* _tmp2_;
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_);
2004 columns = _tmp1_;
2006 _tmp2_ = columns;
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;
2026 _tmp4_ = col;
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);
2040 renderer = _tmp5_;
2042 _tmp6_ = 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);
2050 column = _tmp7_;
2052 _tmp8_ = priv->_treeview_pseudo_axes_parameters;
2054 _tmp9_ = column;
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);
2064 renderer = _tmp10_;
2066 _tmp11_ = 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);
2070 _tmp12_ = renderer;
2072 g_object_set (_tmp12_, "editable", TRUE, NULL);
2074 _tmp13_ = renderer;
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);
2082 column = _tmp14_;
2084 _tmp15_ = priv->_treeview_pseudo_axes_parameters;
2086 _tmp16_ = column;
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_;
2115 GtkVBox* _tmp7_;
2116 HklGui3DFrame* _tmp8_;
2117 GtkFrame* _tmp9_ = NULL;
2118 GtkFrame* _tmp10_;
2119 GtkVBox* _tmp11_;
2121 g_return_if_fail (self != NULL);
2123 _tmp0_ = priv->geometry;
2125 _tmp1_ = _tmp0_->config;
2127 _tmp2_ = (*_tmp1_).type;
2129 switch (_tmp2_) {
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_;
2145 break;
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_;
2163 break;
2166 default:
2168 break;
2172 _tmp7_ = priv->_vbox7;
2174 _tmp8_ = priv->Frame3D;
2176 _tmp9_ = hkl_gui_3d_frame_frame (_tmp8_);
2178 _tmp10_ = _tmp9_;
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) {
2193 GeeHashMap* _tmp0_;
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_);
2203 iter = _tmp1_;
2205 while (TRUE) {
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;
2218 _tmp2_ = iter;
2220 _tmp3_ = gee_map_iterator_next (_tmp2_);
2222 if (!_tmp3_) {
2224 break;
2228 _tmp4_ = iter;
2230 _tmp5_ = gee_map_iterator_get_value (_tmp4_);
2232 _g_object_unref0 (model);
2234 model = (GtkListStore*) _tmp5_;
2236 _tmp6_ = model;
2238 _tmp8_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) _tmp6_, &_tmp7_);
2240 iter2 = _tmp7_;
2242 valid = _tmp8_;
2244 while (TRUE) {
2246 gboolean _tmp9_;
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;
2260 _tmp9_ = valid;
2262 if (!_tmp9_) {
2264 break;
2268 _tmp10_ = model;
2270 _tmp11_ = iter2;
2272 gtk_tree_model_get ((GtkTreeModel*) _tmp10_, &_tmp11_, PARAMETER_COL_PARAMETER, &parameter, -1);
2274 _tmp12_ = model;
2276 _tmp13_ = iter2;
2278 _tmp14_ = parameter;
2280 _tmp15_ = (*_tmp14_).name;
2282 _tmp16_ = parameter;
2284 _tmp17_ = *_tmp16_;
2286 _tmp18_ = hkl_parameter_get_value_unit (&_tmp17_);
2288 gtk_list_store_set (_tmp12_, &_tmp13_, PARAMETER_COL_NAME, _tmp15_, PARAMETER_COL_VALUE, _tmp18_, -1);
2290 _tmp19_ = model;
2292 _tmp20_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp19_, &iter2);
2294 valid = _tmp20_;
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_;
2328 GtkTreeIter _tmp7_;
2329 GeeHashMap* _tmp8_;
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);
2341 path = _tmp1_;
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);
2353 iter = _tmp5_;
2355 _tmp6_ = priv->store_pseudo_axis;
2357 _tmp7_ = iter;
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_;
2412 HklSample* _tmp1_;
2413 HklSample* sample;
2414 HklSample* _tmp2_;
2416 g_return_if_fail (self != NULL);
2418 _tmp0_ = priv->samples;
2420 _tmp1_ = _tmp0_->current;
2422 sample = _tmp1_;
2424 _tmp2_ = sample;
2426 if (_tmp2_ != NULL) {
2428 HklSample* _tmp3_;
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;
2441 HklSample* _tmp16_;
2442 GtkSpinButton* _tmp17_;
2443 gdouble _tmp18_ = 0.0;
2444 GtkSpinButton* _tmp19_;
2445 gdouble _tmp20_ = 0.0;
2446 GtkSpinButton* _tmp21_;
2447 gdouble _tmp22_ = 0.0;
2448 HklSample* _tmp23_;
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_;
2456 HklSample* _tmp31_;
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_;
2464 HklSample* _tmp39_;
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_;
2472 HklSample* _tmp47_;
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_;
2480 HklSample* _tmp55_;
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_;
2488 HklSample* _tmp63_;
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_;
2496 HklSample* _tmp71_;
2498 _tmp3_ = sample;
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);
2526 _tmp16_ = sample;
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);
2542 _tmp23_ = sample;
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_);
2556 _tmp30_ = *_tmp25_;
2558 hkl_parameter_set_range_unit (&_tmp30_, _tmp27_, _tmp29_);
2560 _tmp31_ = sample;
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_);
2574 _tmp38_ = *_tmp33_;
2576 hkl_parameter_set_range_unit (&_tmp38_, _tmp35_, _tmp37_);
2578 _tmp39_ = sample;
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_);
2592 _tmp46_ = *_tmp41_;
2594 hkl_parameter_set_range_unit (&_tmp46_, _tmp43_, _tmp45_);
2596 _tmp47_ = sample;
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_);
2610 _tmp54_ = *_tmp49_;
2612 hkl_parameter_set_range_unit (&_tmp54_, _tmp51_, _tmp53_);
2614 _tmp55_ = sample;
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_);
2628 _tmp62_ = *_tmp57_;
2630 hkl_parameter_set_range_unit (&_tmp62_, _tmp59_, _tmp61_);
2632 _tmp63_ = sample;
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_);
2646 _tmp70_ = *_tmp65_;
2648 hkl_parameter_set_range_unit (&_tmp70_, _tmp67_, _tmp69_);
2650 _tmp71_ = sample;
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_;
2668 HklSample* _tmp1_;
2669 HklSample* sample;
2670 HklSample* _tmp2_;
2672 g_return_if_fail (self != NULL);
2674 _tmp0_ = priv->samples;
2676 _tmp1_ = _tmp0_->current;
2678 sample = _tmp1_;
2680 _tmp2_ = sample;
2682 if (_tmp2_ != NULL) {
2684 HklSample* _tmp3_;
2685 HklLattice* _tmp4_;
2686 HklParameter* _tmp5_;
2687 GtkCheckButton* _tmp6_;
2688 gboolean _tmp7_ = FALSE;
2690 _tmp3_ = sample;
2692 _tmp4_ = _tmp3_->lattice;
2694 _tmp5_ = _tmp4_->a;
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_;
2708 HklSample* _tmp1_;
2709 HklSample* sample;
2710 HklSample* _tmp2_;
2712 g_return_if_fail (self != NULL);
2714 _tmp0_ = priv->samples;
2716 _tmp1_ = _tmp0_->current;
2718 sample = _tmp1_;
2720 _tmp2_ = sample;
2722 if (_tmp2_ != NULL) {
2724 HklSample* _tmp3_;
2725 HklLattice* _tmp4_;
2726 HklParameter* _tmp5_;
2727 GtkCheckButton* _tmp6_;
2728 gboolean _tmp7_ = FALSE;
2730 _tmp3_ = sample;
2732 _tmp4_ = _tmp3_->lattice;
2734 _tmp5_ = _tmp4_->b;
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_;
2748 HklSample* _tmp1_;
2749 HklSample* sample;
2750 HklSample* _tmp2_;
2752 g_return_if_fail (self != NULL);
2754 _tmp0_ = priv->samples;
2756 _tmp1_ = _tmp0_->current;
2758 sample = _tmp1_;
2760 _tmp2_ = sample;
2762 if (_tmp2_ != NULL) {
2764 HklSample* _tmp3_;
2765 HklLattice* _tmp4_;
2766 HklParameter* _tmp5_;
2767 GtkCheckButton* _tmp6_;
2768 gboolean _tmp7_ = FALSE;
2770 _tmp3_ = sample;
2772 _tmp4_ = _tmp3_->lattice;
2774 _tmp5_ = _tmp4_->c;
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_;
2788 HklSample* _tmp1_;
2789 HklSample* sample;
2790 HklSample* _tmp2_;
2792 g_return_if_fail (self != NULL);
2794 _tmp0_ = priv->samples;
2796 _tmp1_ = _tmp0_->current;
2798 sample = _tmp1_;
2800 _tmp2_ = sample;
2802 if (_tmp2_ != NULL) {
2804 HklSample* _tmp3_;
2805 HklLattice* _tmp4_;
2806 HklParameter* _tmp5_;
2807 GtkCheckButton* _tmp6_;
2808 gboolean _tmp7_ = FALSE;
2810 _tmp3_ = sample;
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_;
2828 HklSample* _tmp1_;
2829 HklSample* sample;
2830 HklSample* _tmp2_;
2832 g_return_if_fail (self != NULL);
2834 _tmp0_ = priv->samples;
2836 _tmp1_ = _tmp0_->current;
2838 sample = _tmp1_;
2840 _tmp2_ = sample;
2842 if (_tmp2_ != NULL) {
2844 HklSample* _tmp3_;
2845 HklLattice* _tmp4_;
2846 HklParameter* _tmp5_;
2847 GtkCheckButton* _tmp6_;
2848 gboolean _tmp7_ = FALSE;
2850 _tmp3_ = sample;
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_;
2868 HklSample* _tmp1_;
2869 HklSample* sample;
2870 HklSample* _tmp2_;
2872 g_return_if_fail (self != NULL);
2874 _tmp0_ = priv->samples;
2876 _tmp1_ = _tmp0_->current;
2878 sample = _tmp1_;
2880 _tmp2_ = sample;
2882 if (_tmp2_ != NULL) {
2884 HklSample* _tmp3_;
2885 HklLattice* _tmp4_;
2886 HklParameter* _tmp5_;
2887 GtkCheckButton* _tmp6_;
2888 gboolean _tmp7_ = FALSE;
2890 _tmp3_ = sample;
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_;
2908 HklSample* _tmp1_;
2909 HklSample* sample;
2910 HklSample* _tmp2_;
2912 g_return_if_fail (self != NULL);
2914 _tmp0_ = priv->samples;
2916 _tmp1_ = _tmp0_->current;
2918 sample = _tmp1_;
2920 _tmp2_ = sample;
2922 if (_tmp2_ != NULL) {
2924 HklSample* _tmp3_;
2925 HklParameter* _tmp4_;
2926 GtkCheckButton* _tmp5_;
2927 gboolean _tmp6_ = FALSE;
2929 _tmp3_ = sample;
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_;
2945 HklSample* _tmp1_;
2946 HklSample* sample;
2947 HklSample* _tmp2_;
2949 g_return_if_fail (self != NULL);
2951 _tmp0_ = priv->samples;
2953 _tmp1_ = _tmp0_->current;
2955 sample = _tmp1_;
2957 _tmp2_ = sample;
2959 if (_tmp2_ != NULL) {
2961 HklSample* _tmp3_;
2962 HklParameter* _tmp4_;
2963 GtkCheckButton* _tmp5_;
2964 gboolean _tmp6_ = FALSE;
2966 _tmp3_ = sample;
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_;
2982 HklSample* _tmp1_;
2983 HklSample* sample;
2984 HklSample* _tmp2_;
2986 g_return_if_fail (self != NULL);
2988 _tmp0_ = priv->samples;
2990 _tmp1_ = _tmp0_->current;
2992 sample = _tmp1_;
2994 _tmp2_ = sample;
2996 if (_tmp2_ != NULL) {
2998 HklSample* _tmp3_;
2999 HklParameter* _tmp4_;
3000 GtkCheckButton* _tmp5_;
3001 gboolean _tmp6_ = FALSE;
3003 _tmp3_ = sample;
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_;
3028 GtkTreeIter _tmp7_;
3029 gboolean _tmp8_;
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);
3043 model = _tmp2_;
3045 _tmp3_ = model;
3047 _tmp4_ = path;
3049 gtk_tree_model_get_iter_from_string (_tmp3_, &_tmp5_, _tmp4_);
3051 iter = _tmp5_;
3053 _tmp6_ = model;
3055 _tmp7_ = iter;
3057 gtk_tree_model_get (_tmp6_, &_tmp7_, PSEUDO_AXIS_COL_PSEUDOAXIS, &pseudoAxis, PSEUDO_AXIS_COL_INITIALIZED, &old_flag, -1);
3059 _tmp8_ = old_flag;
3061 if (!_tmp8_) {
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);
3073 if (_tmp11_) {
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};
3095 GtkTreeIter _tmp5_;
3096 const gchar* _tmp6_;
3097 gdouble _tmp7_ = 0.0;
3098 HklParameter _tmp8_;
3099 GtkTreeIter _tmp9_;
3101 g_return_if_fail (self != NULL);
3103 g_return_if_fail (path != NULL);
3105 g_return_if_fail (new_text != NULL);
3107 parameter = 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);
3117 model = _tmp2_;
3119 _tmp3_ = path;
3121 gtk_tree_model_get_iter_from_string ((GtkTreeModel*) model, &_tmp4_, _tmp3_);
3123 iter = _tmp4_;
3125 _tmp5_ = iter;
3127 gtk_tree_model_get ((GtkTreeModel*) model, &_tmp5_, PARAMETER_COL_PARAMETER, parameter, -1);
3129 _tmp6_ = new_text;
3131 _tmp7_ = double_parse (_tmp6_);
3133 value = _tmp7_;
3135 _tmp8_ = *parameter;
3137 hkl_parameter_set_value_unit (&_tmp8_, value);
3139 _tmp9_ = iter;
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);
3169 g_list_free (self);
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_;
3187 HklSample* _tmp1_;
3189 g_return_if_fail (self != NULL);
3191 _tmp0_ = priv->samples;
3193 _tmp1_ = _tmp0_->current;
3195 if (_tmp1_ != NULL) {
3197 HklMatrix UB = {0};
3198 HklSampleList* _tmp2_;
3199 HklSample* _tmp3_;
3200 HklMatrix _tmp4_ = {0};
3201 HklMatrix _tmp5_;
3202 gdouble** _tmp6_;
3203 gint _tmp6__length1;
3204 gdouble* _tmp7_;
3205 gint _tmp7__length1;
3206 GtkSpinButton* _tmp8_;
3207 gdouble _tmp9_ = 0.0;
3208 gdouble _tmp10_;
3209 HklMatrix _tmp11_;
3210 gdouble** _tmp12_;
3211 gint _tmp12__length1;
3212 gdouble* _tmp13_;
3213 gint _tmp13__length1;
3214 GtkSpinButton* _tmp14_;
3215 gdouble _tmp15_ = 0.0;
3216 gdouble _tmp16_;
3217 HklMatrix _tmp17_;
3218 gdouble** _tmp18_;
3219 gint _tmp18__length1;
3220 gdouble* _tmp19_;
3221 gint _tmp19__length1;
3222 GtkSpinButton* _tmp20_;
3223 gdouble _tmp21_ = 0.0;
3224 gdouble _tmp22_;
3225 HklMatrix _tmp23_;
3226 gdouble** _tmp24_;
3227 gint _tmp24__length1;
3228 gdouble* _tmp25_;
3229 gint _tmp25__length1;
3230 GtkSpinButton* _tmp26_;
3231 gdouble _tmp27_ = 0.0;
3232 gdouble _tmp28_;
3233 HklMatrix _tmp29_;
3234 gdouble** _tmp30_;
3235 gint _tmp30__length1;
3236 gdouble* _tmp31_;
3237 gint _tmp31__length1;
3238 GtkSpinButton* _tmp32_;
3239 gdouble _tmp33_ = 0.0;
3240 gdouble _tmp34_;
3241 HklMatrix _tmp35_;
3242 gdouble** _tmp36_;
3243 gint _tmp36__length1;
3244 gdouble* _tmp37_;
3245 gint _tmp37__length1;
3246 GtkSpinButton* _tmp38_;
3247 gdouble _tmp39_ = 0.0;
3248 gdouble _tmp40_;
3249 HklMatrix _tmp41_;
3250 gdouble** _tmp42_;
3251 gint _tmp42__length1;
3252 gdouble* _tmp43_;
3253 gint _tmp43__length1;
3254 GtkSpinButton* _tmp44_;
3255 gdouble _tmp45_ = 0.0;
3256 gdouble _tmp46_;
3257 HklMatrix _tmp47_;
3258 gdouble** _tmp48_;
3259 gint _tmp48__length1;
3260 gdouble* _tmp49_;
3261 gint _tmp49__length1;
3262 GtkSpinButton* _tmp50_;
3263 gdouble _tmp51_ = 0.0;
3264 gdouble _tmp52_;
3265 HklMatrix _tmp53_;
3266 gdouble** _tmp54_;
3267 gint _tmp54__length1;
3268 gdouble* _tmp55_;
3269 gint _tmp55__length1;
3270 GtkSpinButton* _tmp56_;
3271 gdouble _tmp57_ = 0.0;
3272 gdouble _tmp58_;
3273 HklSampleList* _tmp59_;
3274 HklSample* _tmp60_;
3275 HklSampleList* _tmp61_;
3276 HklSample* _tmp62_;
3277 FILE* _tmp63_;
3278 HklSampleList* _tmp64_;
3279 HklSample* _tmp65_;
3281 _tmp2_ = priv->samples;
3283 _tmp3_ = _tmp2_->current;
3285 hkl_sample_get_UB (_tmp3_, &_tmp4_);
3287 (&UB);
3289 UB = _tmp4_;
3291 _tmp5_ = UB;
3293 _tmp6_ = _tmp5_.data;
3295 _tmp6__length1 = -1;
3297 _tmp7_ = _tmp6_[0];
3299 _tmp7__length1 = -1;
3301 _tmp8_ = priv->_spinbutton_U11;
3303 _tmp9_ = gtk_spin_button_get_value (_tmp8_);
3305 _tmp7_[0] = _tmp9_;
3307 _tmp10_ = _tmp7_[0];
3309 _tmp11_ = UB;
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];
3327 _tmp17_ = UB;
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];
3345 _tmp23_ = UB;
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];
3363 _tmp29_ = UB;
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];
3381 _tmp35_ = UB;
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];
3399 _tmp41_ = UB;
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];
3417 _tmp47_ = UB;
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];
3435 _tmp53_ = UB;
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;
3463 _tmp63_ = stdout;
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);
3487 (&UB);
3493 static void hkl_gui_window_on_toolbutton_computeUB_clicked (HklGuiWindow* self) {
3494 HklSampleList* _tmp0_;
3495 HklSample* _tmp1_;
3496 HklSample* sample;
3497 HklSample* _tmp2_;
3499 g_return_if_fail (self != NULL);
3501 _tmp0_ = priv->samples;
3503 _tmp1_ = _tmp0_->current;
3505 sample = _tmp1_;
3507 _tmp2_ = sample;
3509 if (_tmp2_ != NULL) {
3511 HklSample* _tmp3_;
3513 _tmp3_ = sample;
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_;
3531 HklSample* _tmp1_;
3532 HklSample* sample;
3533 HklSample* _tmp2_;
3534 HklSample* _tmp4_;
3536 g_return_if_fail (self != NULL);
3538 _tmp0_ = priv->samples;
3540 _tmp1_ = _tmp0_->current;
3542 sample = _tmp1_;
3544 _tmp2_ = sample;
3546 if (_tmp2_ != NULL) {
3548 HklSample* _tmp3_;
3550 _tmp3_ = sample;
3552 hkl_sample_affine (_tmp3_);
3556 _tmp4_ = sample;
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);
3580 result = TRUE;
3582 return result;
3587 static void hkl_gui_window_on_menuitem5_activate (HklGuiWindow* self) {
3588 GtkDialog* _tmp0_;
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) {
3600 GtkDialog* _tmp0_;
3602 g_return_if_fail (self != NULL);
3604 _tmp0_ = priv->_dialog1;
3606 gtk_widget_hide ((GtkWidget*) _tmp0_);
3612 static void
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 ();
3650 gtk_main ();
3652 return 0;