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-2013 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>
26 void HKLWindow::on_treeView_pseudoAxes_cursor_changed(void)
30 Gtk::TreeModel::Path path
;
31 Gtk::TreeViewColumn
* column
;
32 _TreeView_pseudoAxes
->get_cursor(path
, column
);
33 Gtk::ListStore::Row row
= *(_pseudoAxeModel
->get_iter(path
));
34 HklParameter
*parameter
= row
[_pseudoAxeModelColumns
.parameter
];
35 _TreeView_pseudoAxes_parameters
->set_model(_mapPseudoAxeParameterModel
[parameter
]);
38 void HKLWindow::on_treeViewCrystals_cursor_changed(void)
42 Gtk::TreeModel::Path path
;
43 Gtk::TreeViewColumn
* column
;
44 _treeViewCrystals
->get_cursor(path
, column
);
45 Gtk::TreeModel::iterator iter
= _crystalModel
->get_iter(path
);
46 Gtk::ListStore::Row row
= *(iter
);
48 Glib::ustring name
= row
[_crystalModelColumns
.name
];
49 _sample
= _samples
[name
];
50 hkl_engine_list_init(_engines
, _geometry
, _detector
, _sample
);
51 _treeViewReflections
->set_model(_mapReflectionModel
[name
]);
52 this->updateLattice();
53 this->updateLatticeParameters();
54 this->updateReciprocalLattice();
57 this->updatePseudoAxes();
58 this->updatePseudoAxesFrames();
61 void HKLWindow::on_spinbutton_a_value_changed(void)
64 // TODO change the cell background color if not synchro
67 void HKLWindow::on_spinbutton_b_value_changed(void)
70 // TODO change the cell background color if not synchro
73 void HKLWindow::on_spinbutton_c_value_changed(void)
76 // TODO change the cell background color if not synchro
79 void HKLWindow::on_spinbutton_alpha_value_changed(void)
82 // TODO change the cell background color if not synchro
85 void HKLWindow::on_spinbutton_beta_value_changed(void)
88 // TODO change the cell background color if not synchro
91 void HKLWindow::on_spinbutton_gamma_value_changed(void)
94 // TODO change the cell background color if not synchro
97 void HKLWindow::on_spinbutton_a_min_value_changed(void)
100 // TODO change the cell background color if not synchro
103 void HKLWindow::on_spinbutton_b_min_value_changed(void)
106 // TODO change the cell background color if not synchro
109 void HKLWindow::on_spinbutton_c_min_value_changed(void)
112 // TODO change the cell background color if not synchro
115 void HKLWindow::on_spinbutton_alpha_min_value_changed(void)
118 // TODO change the cell background color if not synchro
121 void HKLWindow::on_spinbutton_beta_min_value_changed(void)
124 // TODO change the cell background color if not synchro
127 void HKLWindow::on_spinbutton_gamma_min_value_changed(void)
130 // TODO change the cell background color if not synchro
133 void HKLWindow::on_spinbutton_a_max_value_changed(void)
136 // TODO change the cell background color if not synchro
139 void HKLWindow::on_spinbutton_b_max_value_changed(void)
142 // TODO change the cell background color if not synchro
145 void HKLWindow::on_spinbutton_c_max_value_changed(void)
148 // TODO change the cell background color if not synchro
151 void HKLWindow::on_spinbutton_alpha_max_value_changed(void)
154 // TODO change the cell background color if not synchro
157 void HKLWindow::on_spinbutton_beta_max_value_changed(void)
160 // TODO change the cell background color if not synchro
163 void HKLWindow::on_spinbutton_gamma_max_value_changed(void)
166 // TODO change the cell background color if not synchro
169 void HKLWindow::on_spinbutton_lambda_value_changed(void)
174 hkl_geometry_wavelength_set(this->_geometry
,
175 _spinbutton_lambda
->get_value());
176 this->updatePseudoAxes();
177 this->updatePseudoAxesFrames();
181 void HKLWindow::on_spinbutton_uxuyuz_value_changed(void)
184 // TODO change the cell background color if not synchro
187 void HKLWindow::on_button2_clicked(void)
193 HklParameter
*parameter
;
196 lattice
= hkl_lattice_new(_spinbutton_a
->get_value(),
197 _spinbutton_b
->get_value(),
198 _spinbutton_c
->get_value(),
199 _spinbutton_alpha
->get_value() * HKL_DEGTORAD
,
200 _spinbutton_beta
->get_value() * HKL_DEGTORAD
,
201 _spinbutton_gamma
->get_value() * HKL_DEGTORAD
);
204 parameter
= hkl_parameter_new_copy(hkl_lattice_a_get(lattice
));
205 hkl_parameter_min_max_unit_set(parameter
,
206 _spinbutton_a_min
->get_value(),
207 _spinbutton_a_max
->get_value());
208 hkl_lattice_a_set(lattice
, parameter
);
209 hkl_parameter_free(parameter
);
212 parameter
= hkl_parameter_new_copy(hkl_lattice_b_get(lattice
));
213 hkl_parameter_min_max_unit_set(parameter
,
214 _spinbutton_b_min
->get_value(),
215 _spinbutton_b_max
->get_value());
216 hkl_lattice_b_set(lattice
, parameter
);
217 hkl_parameter_free(parameter
);
219 parameter
= hkl_parameter_new_copy(hkl_lattice_c_get(lattice
));
220 hkl_parameter_min_max_unit_set(parameter
,
221 _spinbutton_c_min
->get_value(),
222 _spinbutton_c_max
->get_value());
223 hkl_lattice_c_set(lattice
, parameter
);
224 hkl_parameter_free(parameter
);
226 parameter
= hkl_parameter_new_copy(hkl_lattice_alpha_get(lattice
));
227 hkl_parameter_min_max_unit_set(parameter
,
228 _spinbutton_alpha_min
->get_value(),
229 _spinbutton_alpha_max
->get_value());
230 hkl_lattice_alpha_set(lattice
, parameter
);
231 hkl_parameter_free(parameter
);
233 parameter
= hkl_parameter_new_copy(hkl_lattice_beta_get(lattice
));
234 hkl_parameter_min_max_unit_set(parameter
,
235 _spinbutton_beta_min
->get_value(),
236 _spinbutton_beta_max
->get_value());
237 hkl_lattice_beta_set(lattice
, parameter
);
238 hkl_parameter_free(parameter
);
240 parameter
= hkl_parameter_new_copy(hkl_lattice_gamma_get(lattice
));
241 hkl_parameter_min_max_unit_set(parameter
,
242 _spinbutton_gamma_min
->get_value(),
243 _spinbutton_gamma_max
->get_value());
244 hkl_lattice_gamma_set(lattice
, parameter
);
245 hkl_parameter_free(parameter
);
248 hkl_sample_lattice_set(_sample
, lattice
);
249 U
= hkl_matrix_new_euler(_spinbutton_ux
->get_value() * HKL_DEGTORAD
,
250 _spinbutton_uy
->get_value() * HKL_DEGTORAD
,
251 _spinbutton_uz
->get_value() * HKL_DEGTORAD
);
252 hkl_sample_U_set(_sample
, U
);
254 hkl_lattice_free(lattice
);
256 this->updateCrystalModel(_sample
);
257 this->updateReciprocalLattice();
259 this->updatePseudoAxes();
260 this->updatePseudoAxesFrames();
264 #define ON_CHECKBUTTON_LATTICE_PARAMETER_TOGGLE(p, sample) \
265 void HKLWindow::on_checkbutton_##p##_toggled(void) \
269 HklLattice *lattice = hkl_lattice_new_copy(hkl_sample_lattice_get((sample))); \
270 HklParameter *parameter = hkl_parameter_new_copy(hkl_lattice_##p##_get(lattice)); \
271 hkl_parameter_fit_set(parameter, _checkbutton_##p->get_active()); \
272 hkl_lattice_##p##_set(lattice, parameter); \
273 hkl_sample_lattice_set((sample), lattice); \
274 hkl_parameter_free(parameter); \
275 hkl_lattice_free(lattice); \
279 ON_CHECKBUTTON_LATTICE_PARAMETER_TOGGLE(a
, _sample
);
280 ON_CHECKBUTTON_LATTICE_PARAMETER_TOGGLE(b
, _sample
);
281 ON_CHECKBUTTON_LATTICE_PARAMETER_TOGGLE(c
, _sample
);
282 ON_CHECKBUTTON_LATTICE_PARAMETER_TOGGLE(alpha
, _sample
);
283 ON_CHECKBUTTON_LATTICE_PARAMETER_TOGGLE(beta
, _sample
);
284 ON_CHECKBUTTON_LATTICE_PARAMETER_TOGGLE(gamma
, _sample
);
286 #define ON_CHECKBUTTON_UXUYUZ_TOGGLED(p, sample) \
287 void HKLWindow::on_checkbutton_##p##_toggled(void) \
291 HklParameter *parameter = hkl_parameter_new_copy(hkl_sample_##p##_get((sample))); \
292 hkl_parameter_fit_set(parameter, _checkbutton_##p->get_active()); \
293 hkl_sample_##p##_set(sample, parameter); \
294 hkl_parameter_free(parameter); \
298 ON_CHECKBUTTON_UXUYUZ_TOGGLED(ux
, _sample
)
299 ON_CHECKBUTTON_UXUYUZ_TOGGLED(uy
, _sample
)
300 ON_CHECKBUTTON_UXUYUZ_TOGGLED(uz
, _sample
)
302 void HKLWindow::on_cell_TreeView_axes_read_edited(Glib::ustring
const & spath
,
303 Glib::ustring
const & newText
)
307 Gtk::TreePath
path(spath
);
308 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _TreeView_axes
->get_model();
309 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
310 Gtk::ListStore::Row row
= *(iter
);
311 HklParameter
*axis
= row
[_axeModelColumns
.axis
];
314 sscanf(newText
.c_str(), "%lf", &value
);
315 hkl_parameter_value_unit_set(axis
, value
, NULL
);
316 hkl_geometry_axis_set(this->_geometry
, axis
);
318 row
[_axeModelColumns
.read
] = value
;
319 this->updatePseudoAxes();
320 this->updatePseudoAxesFrames();
324 _Scene
->is_colliding();
325 _Scene
->invalidate();
330 void HKLWindow::on_cell_TreeView_axes_write_edited(Glib::ustring
const & spath
,
331 Glib::ustring
const & newText
)
335 Gtk::TreePath
path(spath
);
336 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _TreeView_axes
->get_model();
337 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
338 Gtk::ListStore::Row row
= *(iter
);
340 HklParameter
*axis
= row
[_axeModelColumns
.axis
];
342 sscanf(newText
.c_str(), "%lf", &value
);
343 hkl_parameter_value_unit_set(axis
, value
, NULL
);
344 hkl_geometry_axis_set(this->_geometry
, axis
);
346 row
[_axeModelColumns
.write
] = value
;
347 this->updatePseudoAxes();
348 this->updatePseudoAxesFrames();
352 _Scene
->is_colliding();
353 _Scene
->invalidate();
358 void HKLWindow::on_cell_TreeView_axes_min_edited(Glib::ustring
const & spath
,
359 Glib::ustring
const & newText
)
363 Gtk::TreePath
path(spath
);
364 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _TreeView_axes
->get_model();
365 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
366 Gtk::ListStore::Row row
= *(iter
);
367 HklParameter
*axis
= row
[_axeModelColumns
.axis
];
373 sscanf(newText
.c_str(), "%lf", &value
);
375 hkl_parameter_min_max_unit_get(axis
, &shit
, &max
);
376 hkl_parameter_min_max_unit_set(axis
, value
, max
);
377 hkl_geometry_axis_set(this->_geometry
, axis
);
379 row
[_axeModelColumns
.min
] = value
;
380 this->updatePseudoAxes();
383 void HKLWindow::on_cell_TreeView_axes_max_edited(Glib::ustring
const & spath
,
384 Glib::ustring
const & newText
)
388 Gtk::TreePath
path(spath
);
389 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _TreeView_axes
->get_model();
390 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
391 Gtk::ListStore::Row row
= *(iter
);
392 HklParameter
*axis
= row
[_axeModelColumns
.axis
];
397 sscanf(newText
.c_str(), "%lf", &value
);
399 hkl_parameter_min_max_unit_get(axis
, &min
, &shit
);
400 hkl_parameter_min_max_unit_set(axis
, min
, value
);
401 hkl_geometry_axis_set(this->_geometry
, axis
);
403 row
[_axeModelColumns
.max
] = value
;
404 this->updatePseudoAxes();
408 void HKLWindow::on_cell_TreeView_pseudoAxes_write_edited(Glib::ustring
const & spath
,
409 Glib::ustring
const & newText
)
414 HklParameter
*parameter
;
418 Gtk::TreePath
path(spath
);
419 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _TreeView_pseudoAxes
->get_model();
420 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
421 Gtk::ListStore::Row row
= *(iter
);
423 parameter
= row
[_pseudoAxeModelColumns
.parameter
];
424 engine
= row
[_pseudoAxeModelColumns
.engine
];
425 sscanf(newText
.c_str(), "%lf", &value
);
427 if(hkl_parameter_value_unit_set(parameter
, value
, NULL
))
428 if(hkl_engine_set(engine
, NULL
)){
429 hkl_engine_list_select_solution(this->_engines
, 0);
431 row
[_pseudoAxeModelColumns
.write
] = value
;
433 this->updatePseudoAxes();
434 this->updatePseudoAxesFrames();
435 this->updateSolutions();
439 _Scene
->is_colliding();
440 _Scene
->invalidate();
446 //PseudoAxes Parameters
447 void HKLWindow::on_cell_TreeView_pseudoAxes_parameters_value_edited(Glib::ustring
const & spath
,
448 Glib::ustring
const & newText
)
453 HklParameter
*parameter
;
455 Gtk::TreePath
path(spath
);
456 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _TreeView_pseudoAxes_parameters
->get_model();
457 Gtk::ListStore::Row row
= *(listStore
->get_iter(path
));
458 sscanf(newText
.c_str(), "%lf", &value
);
460 parameter
= row
[_parameterModelColumns
.parameter
];
461 /* TODO error check */
462 hkl_parameter_value_unit_set(parameter
, value
, NULL
);
464 row
[_parameterModelColumns
.value
] = value
;
465 this->updatePseudoAxes();
466 this->update_pseudoAxes_parameters();
469 void HKLWindow::on_cell_TreeView_crystals_name_edited(Glib::ustring
const & spath
,
470 Glib::ustring
const & newText
)
474 Gtk::TreePath
path(spath
);
475 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _treeViewCrystals
->get_model();
476 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
477 Gtk::ListStore::Row row
= *(iter
);
478 Glib::ustring name
= row
[_crystalModelColumns
.name
];
479 std::map
<std::string
, HklSample
*>::iterator it
= _samples
.find(name
);
480 if (it
!= _samples
.end()){
481 HklSample
*sample
= it
->second
;
483 hkl_sample_name_set(sample
, newText
.c_str());
485 _samples
.insert(std::pair
<std::string
, HklSample
*>(hkl_sample_name_get(sample
),
488 this-> updateTreeViewCrystals();
492 void HKLWindow::on_cell_TreeView_reflections_h_edited(Glib::ustring
const & spath
,
493 Glib::ustring
const & newText
)
497 Gtk::TreePath
path(spath
);
498 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _treeViewReflections
->get_model();
499 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
500 Gtk::ListStore::Row row
= *(iter
);
506 HklSampleReflection
*reflection
;
508 reflection
= row
[_reflectionModelColumns
.reflection
];
510 hkl_sample_reflection_hkl_get(reflection
, &h
, &k
, &l
);
511 sscanf(newText
.c_str(), "%lf", &h
);
512 hkl_sample_reflection_hkl_set(reflection
, h
, k
, l
);
513 row
[_reflectionModelColumns
.h
] = h
;
515 row
[_reflectionModelColumns
.flag
] = hkl_sample_reflection_flag_get(reflection
);
517 this->updateCrystalModel(_sample
);
521 void HKLWindow::on_cell_TreeView_reflections_k_edited(Glib::ustring
const & spath
,
522 Glib::ustring
const & newText
)
526 Gtk::TreePath
path(spath
);
527 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _treeViewReflections
->get_model();
528 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
529 Gtk::ListStore::Row row
= *(iter
);
535 HklSampleReflection
*reflection
;
538 reflection
= row
[_reflectionModelColumns
.reflection
];
540 hkl_sample_reflection_hkl_get(reflection
, &h
, &k
, &l
);
541 sscanf(newText
.c_str(), "%lf", &k
);
542 hkl_sample_reflection_hkl_set(reflection
, h
, k
, l
);
543 row
[_reflectionModelColumns
.k
] = k
;
545 row
[_reflectionModelColumns
.flag
] = hkl_sample_reflection_flag_get(reflection
);
546 this->updateCrystalModel(_sample
);
550 void HKLWindow::on_cell_TreeView_reflections_l_edited(Glib::ustring
const & spath
,
551 Glib::ustring
const & newText
)
555 Gtk::TreePath
path(spath
);
556 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _treeViewReflections
->get_model();
557 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
558 Gtk::ListStore::Row row
= *(iter
);
564 HklSampleReflection
*reflection
;
566 reflection
= row
[_reflectionModelColumns
.reflection
];
568 hkl_sample_reflection_hkl_get(reflection
, &h
, &k
, &l
);
569 sscanf(newText
.c_str(), "%lf", &l
);
570 hkl_sample_reflection_hkl_set(reflection
, h
, k
, l
);
571 row
[_reflectionModelColumns
.l
] = l
;
573 row
[_reflectionModelColumns
.flag
] = hkl_sample_reflection_flag_get(reflection
);
575 this->updateCrystalModel(_sample
);
579 void HKLWindow::on_cell_TreeView_reflections_flag_toggled(Glib::ustring
const & spath
)
583 Gtk::TreePath
path(spath
);
584 Glib::RefPtr
<Gtk::TreeModel
> listStore
= _treeViewReflections
->get_model();
585 Gtk::TreeModel::iterator iter
= listStore
->get_iter(path
);
586 Gtk::ListStore::Row row
= *(iter
);
590 HklSampleReflection
*reflection
;
592 reflection
= row
[_reflectionModelColumns
.reflection
];
593 flag
= !hkl_sample_reflection_flag_get(reflection
);
594 hkl_sample_reflection_flag_set(reflection
, flag
);
595 row
[_reflectionModelColumns
.flag
] = flag
;
599 void HKLWindow::on_toolbutton_add_reflection_clicked(void)
604 HklSampleReflection
*reflection
;
609 reflection
= hkl_sample_reflection_new(_geometry
, _detector
, h
, k
, l
);
610 hkl_sample_add_reflection(_sample
, reflection
);
612 this->updateReflections(_sample
,
613 _mapReflectionModel
[hkl_sample_name_get(_sample
)]);
617 void HKLWindow::on_toolbutton_goto_reflection_clicked(void)
622 Glib::RefPtr
<Gtk::TreeSelection
> selection
= _treeViewReflections
->get_selection();
623 unsigned int nb_rows
= selection
->count_selected_rows();
625 Gtk::TreeSelection::ListHandle_Path list_path
= selection
->get_selected_rows();
626 Gtk::TreePath path
= *(list_path
.begin());
627 Glib::RefPtr
<Gtk::ListStore
> liststore
= _mapReflectionModel
[hkl_sample_name_get(_sample
)];
628 Gtk::ListStore::Row row
= *(liststore
->get_iter(path
));
629 HklSampleReflection
*reflection
= row
[_reflectionModelColumns
.reflection
];
631 hkl_geometry_set(this->_geometry
,
632 hkl_sample_reflection_geometry_get(reflection
));
634 this->updateSource();
636 this->updatePseudoAxes();
639 _Scene
->is_colliding();
640 _Scene
->invalidate();
645 _statusBar
->push("Please select only one reflection.");
647 _statusBar
->push("Please select one reflection.");
652 void HKLWindow::on_toolbutton_del_reflection_clicked(void)
657 Glib::RefPtr
<Gtk::TreeSelection
> selection
= _treeViewReflections
->get_selection();
658 unsigned int nb_rows
= selection
->count_selected_rows();
660 Gtk::TreeSelection::ListHandle_Path list
= selection
->get_selected_rows();
661 Gtk::TreeSelection::ListHandle_Path::iterator iter
= list
.begin();
662 Gtk::TreeSelection::ListHandle_Path::iterator last
= list
.end();
663 Glib::RefPtr
<Gtk::ListStore
> liststore
= _mapReflectionModel
[hkl_sample_name_get(_sample
)];
664 // fill indexes with the reflections index
665 std::vector
<HklSampleReflection
*> to_delete
;
667 Gtk::ListStore::Row row
= *(liststore
->get_iter(*iter
));
668 to_delete
.push_back(row
[_reflectionModelColumns
.reflection
]);
671 std::ostringstream os
;
672 os
<< "Are you sure you want to delete reflections :";
673 for(unsigned int i
=0; i
< to_delete
.size();i
++){
676 hkl_sample_reflection_hkl_get(to_delete
[i
], &h
, &k
, &l
);
683 _message
= new Gtk::MessageDialog("", false,
684 Gtk::MESSAGE_WARNING
,
685 Gtk::BUTTONS_YES_NO
);
686 _message
->set_message(os
.str());
688 int respons
= _message
->run();
690 case Gtk::RESPONSE_YES
:
691 for(unsigned int i
=0;i
<to_delete
.size();i
++){
692 hkl_sample_del_reflection(_sample
,
695 this->updateReflections(_sample
, liststore
);
700 _statusBar
->push("Please select at least one reflection.");
703 void HKLWindow::on_toolbutton_setUB_clicked(void)
708 HklMatrix
*UB
= hkl_matrix_new_full(
709 _spinbutton_U11
->get_value(),
710 _spinbutton_U12
->get_value(),
711 _spinbutton_U13
->get_value(),
712 _spinbutton_U21
->get_value(),
713 _spinbutton_U22
->get_value(),
714 _spinbutton_U23
->get_value(),
715 _spinbutton_U31
->get_value(),
716 _spinbutton_U32
->get_value(),
717 _spinbutton_U33
->get_value());
719 hkl_sample_UB_set(_sample
, UB
);
722 this->updateLattice();
723 this->updateLatticeParameters();
724 this->updateReciprocalLattice();
725 this->updateCrystalModel(_sample
);
727 this->updateUxUyUz();
728 this->updatePseudoAxes();
729 this->updatePseudoAxesFrames();
733 void HKLWindow::on_toolbutton_computeUB_clicked(void)
738 const HklSampleReflection
*r1
= hkl_sample_first_reflection_get(_sample
);
739 const HklSampleReflection
*r2
= hkl_sample_next_reflection_get(_sample
,
740 const_cast<HklSampleReflection
*>(r1
));
742 hkl_sample_compute_UB_busing_levy(_sample
, r1
, r2
);
744 this->updateUxUyUz();
745 this->updatePseudoAxes();
746 this->updatePseudoAxesFrames();
750 void HKLWindow::on_toolbutton_add_crystal_clicked(void)
754 _sample
= hkl_sample_new("new_sample");
756 _samples
.insert(std::pair
<std::string
, HklSample
*>(hkl_sample_name_get(_sample
),
758 this->updateTreeViewCrystals();
760 // activate for edition the name of the new crystal
761 Gtk::TreeModel::Path path
;
762 Gtk::TreeView::Column
* column
;
763 _treeViewCrystals
->get_cursor(path
, column
);
764 column
= _treeViewCrystals
->get_column(0);
765 _treeViewCrystals
->set_cursor(path
, *column
, true);
769 void HKLWindow::on_toolbutton_copy_crystal_clicked(void)
774 Glib::ustring newname
;
775 HklSample
*old_sample
= _sample
;
778 _statusBar
->push("Please select a crystal to copy.");
782 sample
= hkl_sample_new_copy(_sample
);
783 hkl_sample_name_set(sample
, "copy");
784 _samples
.insert(std::pair
<std::string
, HklSample
*>(hkl_sample_name_get(sample
),
787 this->updateTreeViewCrystals();
789 // activate for edition the name of the new crystal
790 Gtk::TreeModel::Path path
;
791 Gtk::TreeView::Column
* column
;
792 _treeViewCrystals
->get_cursor(path
, column
);
793 column
= _treeViewCrystals
->get_column(0);
794 _treeViewCrystals
->set_cursor(path
, *column
, true);
797 void HKLWindow::on_toolbutton_del_crystal_clicked(void)
801 _samples
.erase(_samples
.find(hkl_sample_name_get(_sample
)));
802 this->updateTreeViewCrystals();
805 void HKLWindow::on_toolbutton_affiner_clicked(void)
810 Glib::ustring method
;
812 hkl_sample_affine(_sample
);
814 this->updateCrystalModel(_sample
);
815 this->updateLattice();
816 this->updateReciprocalLattice();
818 this->updateUxUyUz();
821 bool HKLWindow::on_treeViewReflections_key_press_event(GdkEventKey
* event
)
825 switch (event
->keyval
)
829 on_toolbutton_add_reflection_clicked();
833 on_toolbutton_del_reflection_clicked();
839 bool HKLWindow::on_treeViewCrystals_key_press_event(GdkEventKey
* event
)
843 switch (event
->keyval
)
847 on_toolbutton_add_crystal_clicked();
851 on_toolbutton_del_crystal_clicked();
857 void HKLWindow::on_treeview1_cursor_changed(void)
861 Gtk::TreeModel::Path path
;
862 Gtk::TreeViewColumn
* column
;
863 _treeview1
->get_cursor(path
, column
);
864 Gtk::TreeModel::iterator iter
= _solutionModel
->get_iter(path
);
865 Gtk::ListStore::Row row
= *(iter
);
866 const HklGeometryListItem
*item
= row
[_solutionModelColumns
->item
];
868 const HklGeometry
*geometry
= hkl_geometry_list_item_geometry_get(item
);
869 hkl_engine_list_geometry_set(this->_engines
, geometry
);
872 this->updatePseudoAxes();
873 this->updatePseudoAxesFrames();
876 _Scene
->is_colliding();
877 _Scene
->invalidate();
882 void HKLWindow::on_pseudoAxesFrame_changed(void)
887 this->updatePseudoAxes();
888 this->updatePseudoAxesFrames();
889 this->updateSolutions();
892 void HKLWindow::on_menuitem5_activate(void)
899 void HKLWindow::on_button1_clicked(void)
906 void HKLWindow::on_combobox1_changed(void)
910 size_t idx
= _combobox1
->get_active_row_number();
912 HklFactory
**factories
;
914 factories
= hkl_factory_get_all(&n
);
915 this->_factory
= factories
[idx
];
918 hkl_geometry_free(_geometry
);
919 _geometry
= hkl_factory_create_new_geometry(this->_factory
);
922 hkl_engine_list_free(_engines
);
923 _engines
= hkl_factory_create_new_engine_list(this->_factory
);
924 hkl_engine_list_init(_engines
, _geometry
, _detector
, _sample
);
926 this->set_up_pseudo_axes_frames();
927 this->set_up_TreeView_axes();
928 this->set_up_TreeView_pseudoAxes_parameters();
929 this->set_up_TreeView_pseudoAxes();
931 _solutionModelColumns
= 0;
932 this->set_up_TreeView_treeview1();