atomes 1.2.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
cell_cut.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2025 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'cell_cut.c'
24*
25* Contains:
26*
27
28 - The functions to create the 'slab cutting' tab of the cell edition window
29
30*
31* List of functions:
32
33 G_MODULE_EXPORT gboolean scroll_set_slab_alpha (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data);
34
35 void create_slab_info (project * this_proj);
36 void slab_alpha_has_changed (gpointer data, GLfloat v);
37 void invert_selection (project * this_proj);
38
39 G_MODULE_EXPORT void setup_passivate (GtkButton * but, gpointer data);
40 G_MODULE_EXPORT void set_slab_property (GtkCheckButton * but, gpointer data);
41 G_MODULE_EXPORT void set_slab_property (GtkToggleButton * but, gpointer data);
42 G_MODULE_EXPORT void set_slab_option (GtkComboBox * box, gpointer data);
43 G_MODULE_EXPORT void set_slab_type (GtkComboBox * box, gpointer data);
44 G_MODULE_EXPORT void set_slab_alpha (GtkRange * range, gpointer data);
45 G_MODULE_EXPORT void select_this_slab (GtkButton * but, gpointer data);
46 G_MODULE_EXPORT void cut_this_slab (GtkButton * but, gpointer data);
47
48 GtkWidget * prepare_slab_box (int sid, project * this_proj);
49 GtkWidget * create_slab_param_combo (int sid, project * this_proj);
50 GtkWidget * cut_in_model (project * this_proj);
51
52*/
53
54#include "cell_edit.h"
55#include "atom_edit.h"
56
57extern G_MODULE_EXPORT void set_filter_changed (GtkComboBox * box, gpointer data);
58
67G_MODULE_EXPORT void setup_passivate (GtkButton * but, gpointer data)
68{
69 project * this_proj = (project *)data;
70
71 gchar * str = g_strdup_printf ("Cell edition - %s: surface passivation", this_proj -> name);
72 GtkWidget * dial = dialogmodal (prepare_for_title(str), GTK_WINDOW(this_proj -> modelgl -> cell_win -> win));
73 g_free (str);
74 this_proj -> modelgl -> search_widg[8] -> passivating = TRUE;
75 GtkWidget * vbox = dialog_get_content_area (dial);
76 GtkWidget * scrollsets = create_scroll (NULL, -1, -1, GTK_SHADOW_NONE);
77 add_container_child (CONTAINER_SCR, scrollsets, action_tab (6, this_proj));
78 widget_set_sensitive (this_proj -> modelgl -> search_widg[8] -> object_box, 0);
79 gtk_widget_set_size_request (scrollsets, 760, 350);
80 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, scrollsets, FALSE, FALSE, 10);
81 GtkWidget * info = markup_label ("Select any object(s) <b>A</b> to be replaced when creating the slab, then select the object(s) <b>B</b> to insert in its place.\n"
82 "When cutting into the model any bond to <b>A</b> with the new surface, will be passivated by <b>B</b>", -1, -1, 0.5, 0.5);
83 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, info, FALSE, FALSE, 20);
84 show_the_widgets (dial);
85 if (! this_proj -> modelgl -> search_widg[8] -> in_selection)
86 {
87 combo_set_active (this_proj -> modelgl -> search_widg[8] -> atom_box, 0);
88 set_filter_changed (GTK_COMBO_BOX(this_proj -> modelgl -> search_widg[8] -> atom_box), this_proj -> modelgl -> search_widg[8]);
89 }
90 else
91 {
92 combo_set_active (this_proj -> modelgl -> search_widg[8] -> atom_box, 0);
93 set_spec_changed (GTK_COMBO_BOX(this_proj -> modelgl -> search_widg[8] -> atom_box), this_proj -> modelgl -> search_widg[8]);
94 }
95 g_signal_connect (G_OBJECT(dial), "response", G_CALLBACK(destroy_this_dialog), NULL);
96 dialog_id ++;
97 Event_loop[dialog_id] = g_main_loop_new (NULL, FALSE);
98 g_main_loop_run (Event_loop[dialog_id]);
99 this_proj -> modelgl -> search_widg[8] -> passivating = FALSE;
100}
101
109void create_slab_info (project * this_proj)
110{
111 this_proj -> modelgl -> cell_win -> slab_info = destroy_this_widget (this_proj -> modelgl -> cell_win -> slab_info);
112 this_proj -> modelgl -> cell_win -> slab_info = create_vbox (BSEP);
113 GtkWidget * hbox = create_hbox (0);
114 add_box_child_start (GTK_ORIENTATION_VERTICAL, this_proj -> modelgl -> cell_win -> slab_info, hbox, FALSE, FALSE, 5);
115 gchar * str;
116 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("- Volume: ", 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
117 str = g_strdup_printf ("<b>%f</b>", this_proj -> modelgl -> cell_win -> slab_vol);
118 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 90, -1, 0.0, 0.5), FALSE, FALSE, 10);
119 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("&#xC5;<sup>3</sup>", 20, -1, 0.5, 0.5), FALSE, FALSE, 0);
120 g_free (str);
121 hbox = create_hbox (0);
122 add_box_child_start (GTK_ORIENTATION_VERTICAL, this_proj -> modelgl -> cell_win -> slab_info, hbox, FALSE, FALSE, 5);
123 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("- Atom(s) in slab: ", 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
124 str = g_strdup_printf ("<b>%d</b>", this_proj -> modelgl -> cell_win -> slab_atoms);
125 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 20);
126 g_free (str);
127 int i;
128 for (i=0; i<this_proj -> nspec; i++)
129 {
130 hbox = create_hbox (0);
131 add_box_child_start (GTK_ORIENTATION_VERTICAL, this_proj -> modelgl -> cell_win -> slab_info, hbox, FALSE, FALSE, 0);
132 str = g_strdup_printf ("\t - %s atom(s) in slab: ", this_proj -> chemistry -> label[i]);
133 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
134 g_free (str);
135 str = g_strdup_printf ("<b>%d</b>", this_proj -> modelgl -> cell_win -> slab_lot[i]);
136 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 20);
137 g_free (str);
138 }
139 add_box_child_start (GTK_ORIENTATION_VERTICAL, this_proj -> modelgl -> cell_win -> slab_info_box, this_proj -> modelgl -> cell_win -> slab_info, FALSE, FALSE, 0);
140 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_info);
141}
142
143#ifdef GTK4
152G_MODULE_EXPORT void set_slab_property (GtkCheckButton * but, gpointer data)
153#else
162G_MODULE_EXPORT void set_slab_property (GtkToggleButton * but, gpointer data)
163#endif
164{
165 dint * dat = (dint *)data;
166 glwin * view = get_project_by_id(dat -> a) -> modelgl;
167 gboolean status = button_get_status ((GtkWidget *)but);
168 switch (dat -> b)
169 {
170 case 0:
171 view -> cell_win -> slab_show = status;
172 break;
173 case 1:
174 view -> cell_win -> slab_pbc = status;
175 break;
176 case 2:
177 view -> cell_win -> slab_act = status;
178 break;
179 case 3:
180 view -> cell_win -> slab_out = status;
181 break;
182 case 4:
183 view -> cell_win -> slab_passivate = status;
184 widget_set_sensitive (view -> cell_win -> passivate, view -> cell_win -> slab_passivate);
185 if (view -> cell_win -> slab_passivate)
186 {
187 prepare_atom_edition (& view -> colorp[0][0], FALSE);
188 view -> search_widg[8] = allocate_atom_search (dat -> a, REPLACE, 8, get_project_by_id(dat -> a) -> nspec);
189 view -> search_widg[8] -> status = 2;
190 setup_passivate (NULL, get_project_by_id(dat -> a));
191 }
192 else
193 {
194 g_free (view -> search_widg[8]);
195 view -> search_widg[8] = NULL;
196 if (! view -> atom_win -> visible)
197 {
198 g_free (view -> atom_win);
199 view -> atom_win = NULL;
200 }
201 }
202 break;
203 }
204 if (view -> cell_win -> slab_show)
205 {
206 view -> create_shaders[SLABS] = TRUE;
207 }
208 else
209 {
210 cleaning_shaders (view, SLABS);
211 }
212 update (view);
213}
214
223GtkWidget * prepare_slab_box (int sid, project * this_proj)
224{
225 gchar * option[6]={"- Position the center of the slab: ", // 6, 7, 8
226 "- Size of the slab: ", // 9, 10, 11
227 "- Size of the slab: ", // 12, 13
228 "- Size of the slab: ", // 14
229 "- Parallelepiped Angles: ", // 15, 16, 17
230 "- Slab rotation: "}; // 18, 19, 20
231 GtkWidget * vbox = create_vbox (BSEP);
232 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(option[sid], 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
233 int i;
234 switch (sid)
235 {
236 case 0:
237 for (i=6; i<9; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
238 break;
239 case 1:
240 for (i=9; i<12; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
241 break;
242 case 2:
243 for (i=12; i<14; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
244 break;
245 case 3:
246 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, 14), FALSE, FALSE, 0);
247 break;
248 case 4:
249 for (i=15; i<18; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
250 break;
251 case 5:
252 for (i=18; i<21; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
253 break;
254 }
255 return vbox;
256}
257
266G_MODULE_EXPORT void set_slab_option (GtkComboBox * box, gpointer data)
267{
268 project * this_proj = (project *)data;
269 int i, j;
270 i = combo_get_active ((GtkWidget *)box);
271 for (j=0; j<6; j++)
272 {
273 hide_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[j]);
274 }
275 switch (i)
276 {
277 case 0:
278 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[0]);
279 break;
280 case 1:
281 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[1+this_proj -> modelgl -> cell_win -> slab_type]);
282 break;
283 default:
284 if (this_proj -> modelgl -> cell_win -> slab_type)
285 {
286 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[5]);
287 }
288 else
289 {
290 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[i+2]);
291 }
292 break;
293 }
294}
295
304GtkWidget * create_slab_param_combo (int sid, project * this_proj)
305{
306 GtkWidget * combo = create_combo ();
307 gchar * options[4] = {"Position", "Size", "Angles", "Rotation"};
308 int i, j, k;
309 i = 4 - sid;
310 for (j=0; j<i; j++)
311 {
312 k = (! sid) ? j : (sid == 1 && j == 2) ? 3 : j;
313 combo_text_append (combo, options[k]);
314 }
315 combo_set_active (combo, 0);
316 g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK(set_slab_option), this_proj);
317 return combo;
318}
319
328G_MODULE_EXPORT void set_slab_type (GtkComboBox * box, gpointer data)
329{
330 project * this_proj = (project *)data;
331 int i;
332 for (i=0; i<3; i++) hide_the_widgets (this_proj -> modelgl -> cell_win -> slab_hbox[i]);
333 this_proj -> modelgl -> cell_win -> slab_type = i = combo_get_active ((GtkWidget *)box);
334 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_hbox[i]);
335 combo_set_active (this_proj -> modelgl -> cell_win -> slab_param[i], 0);
336 set_slab_option (GTK_COMBO_BOX(this_proj -> modelgl -> cell_win -> slab_param[i]), this_proj);
337 if (this_proj -> modelgl -> n_shaders[SLABS][0])
338 {
339 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
340 update (this_proj -> modelgl);
341 }
342}
343
352void slab_alpha_has_changed (gpointer data, GLfloat v)
353{
354 glwin * view = (glwin *)data;
355 view -> cell_win -> slab_alpha = v;
356 if (view -> n_shaders[SLABS][0])
357 {
358 view -> create_shaders[SLABS] = TRUE;
359 update (view);
360 }
361}
362
373G_MODULE_EXPORT gboolean scroll_set_slab_alpha (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
374{
375 slab_alpha_has_changed (data, (GLfloat) value);
376 return FALSE;
377}
378
387G_MODULE_EXPORT void set_slab_alpha (GtkRange * range, gpointer data)
388{
389 slab_alpha_has_changed (data, (GLfloat) gtk_range_get_value (range));
390}
391
399void invert_selection (project * this_proj)
400{
401 save_all_selections (this_proj -> modelgl, 0);
402 int i, j, k;
403 if (this_proj -> modelgl -> mode == EDITION)
404 {
405 // Invert the saved coordinates as well
406 double ** saved_c = NULL;
407 i = this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected;
408 if (i < this_proj -> natomes)
409 {
410 saved_c = g_malloc0 ((this_proj -> natomes - i)*sizeof*saved_c);
411 k = 0;
412 for (j=0; j<this_proj -> natomes; j++)
413 {
414 if (! this_proj -> atoms[0][j].pick[0])
415 {
416 saved_c[k] = allocdouble (3);
417 saved_c[k][0] = this_proj -> atoms[0][j].x;
418 saved_c[k][1] = this_proj -> atoms[0][j].y;
419 saved_c[k][2] = this_proj -> atoms[0][j].z;
420 k ++;
421 }
422 }
423 }
424 g_free (this_proj -> modelgl -> saved_coord[1]);
425 this_proj -> modelgl -> saved_coord[1] = NULL;
426 if (saved_c)
427 {
428 this_proj -> modelgl -> saved_coord[1] = g_malloc0 ((this_proj -> natomes - i)*sizeof*this_proj -> modelgl -> saved_coord[1]);
429 for (j=0; j<this_proj -> natomes - i; j++)
430 {
431 this_proj -> modelgl -> saved_coord[1][j] = duplicate_double(3, saved_c[j]);
432 }
433 g_free (saved_c);
434 }
435 }
436 for (i=0; i<this_proj -> natomes; i++)
437 {
438 process_selected_atom (this_proj, this_proj -> modelgl, i, 0, 0, 0);
439 }
440 update_all_selections (this_proj -> modelgl, 0);
441 if (this_proj -> modelgl -> mode == EDITION)
442 {
443 this_proj -> modelgl -> baryc[1] = get_bary (this_proj, 1);
444 }
445 int shaders[1] = {SELEC};
446 re_create_md_shaders (1, shaders, this_proj);
447}
448
457G_MODULE_EXPORT void select_this_slab (GtkButton * but, gpointer data)
458{
459 project * this_proj = (project *)data;
460 this_proj -> modelgl -> cell_win -> cut_this_slab = TRUE;
461 opengl_project_changed (this_proj -> id);
462 selected_aspec = -1;
463#ifdef GTK4
464 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
465#else
466 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
467#endif
468 save_all_selections (this_proj -> modelgl, 0);
469 create_slab_lists (this_proj);
470 update_all_selections (this_proj -> modelgl, 0);
471 if (this_proj -> modelgl -> cell_win -> slab_act) invert_selection (this_proj);
472 this_proj -> modelgl -> cell_win -> cut_this_slab = FALSE;
473 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
474 int shaders[1] = {SELEC};
475 re_create_md_shaders (1, shaders, this_proj);
476 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
477 update (this_proj -> modelgl);
478}
479
488G_MODULE_EXPORT void cut_this_slab (GtkButton * but, gpointer data)
489{
490 project * this_proj = (project *)data;
491 int is_out, i;
492 if (this_proj -> modelgl-> cell_win -> slab_atoms)
493 {
494 if (! this_proj -> modelgl -> cell_win -> slab_passivate || do_we_have_objects_in_selection(this_proj, this_proj -> modelgl -> search_widg[8], FALSE))
495 {
496 is_out = this_proj -> modelgl -> cell_win -> slab_out;
497 if (this_proj -> modelgl -> search_widg[8]) this_proj -> modelgl -> search_widg[8] -> passivating = FALSE;
498 gchar * infom[2] = {"Cut and modify model ?\n This is irreversible !", "Cut and create new project ?"};
499 if (ask_yes_no("Cut", infom[is_out], GTK_MESSAGE_WARNING, this_proj -> modelgl -> cell_win -> win))
500 {
501 this_proj -> modelgl -> cell_win -> cut_this_slab = TRUE;
502 if (is_out) preserve_ogl_selection (this_proj -> modelgl);
503 opengl_project_changed (this_proj -> id);
504 selected_aspec = -1;
505#ifdef GTK4
506 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
507#else
508 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
509#endif
510 save_all_selections (this_proj -> modelgl, 0);
511 create_slab_lists (this_proj);
512 update_all_selections (this_proj -> modelgl, 0);
513 is_selected = 1;
514 if (this_proj -> modelgl -> cell_win -> slab_act) invert_selection (this_proj);
515 switch (is_out)
516 {
517 case 0:
518 // Modify project
519 if (this_proj -> modelgl -> cell_win -> slab_passivate)
520 {
521 if (this_proj -> modelgl -> atom_win)
522 {
523#ifdef GTK4
524 remove_the_atoms (NULL, NULL, & cut_sel);
525#else
526 remove_the_atoms (NULL, & cut_sel);
527#endif
528 this_proj -> modelgl -> cell_win -> slab_passivate = FALSE;
529 to_passivate_using_the_objects (this_proj, this_proj -> modelgl -> search_widg[8]);
530 this_proj -> modelgl -> cell_win -> slab_passivate = TRUE;
531 }
532 }
533 else
534 {
535#ifdef GTK4
536 remove_the_atoms (NULL, NULL, & cut_sel);
537#else
538 remove_the_atoms (NULL, & cut_sel);
539#endif
540 }
541 break;
542 case 1:
543 // Create new project
544 if (this_proj -> modelgl -> cell_win -> slab_passivate)
545 {
546#ifdef GTK4
547 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
548#else
549 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
550#endif
551 }
552#ifdef GTK4
553 edit_in_new_project (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
554#else
555 edit_in_new_project (NULL, & this_proj -> modelgl -> colorp[0][0]);
556#endif
557 if (this_proj -> modelgl -> cell_win -> slab_passivate)
558 {
559#ifdef GTK4
560 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
561#else
562 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
563#endif
564 this_proj -> modelgl -> cell_win -> cut_this_slab = FALSE;
565 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
566 update (this_proj -> modelgl);
568 active_glwin -> cell_win = g_malloc0(sizeof*active_glwin -> cell_win);
569 active_glwin -> cell_win -> slab_lot = allocint (active_project -> nspec);
570 active_glwin -> cell_win -> slab_type = this_proj -> modelgl -> cell_win ->slab_type;
571 active_glwin -> cell_win -> slab_pbc = this_proj -> modelgl -> cell_win ->slab_pbc;
572 active_glwin -> cell_win -> slab_act = this_proj -> modelgl -> cell_win -> slab_act;
573 active_glwin -> cell_win -> slab_passivate = TRUE;
574 for (i=0; i<21; i++) active_glwin -> cell_win -> cparam[i] = this_proj -> modelgl -> cell_win -> cparam[i];
575 prepare_atom_edition (& active_glwin -> colorp[0][0], FALSE);
576 active_glwin -> search_widg[8] = allocate_atom_search (activep, REPLACE, 8, this_proj -> modelgl -> search_widg[8] -> todo_size);
577 active_glwin -> search_widg[8] -> status = 2;
578 active_glwin -> search_widg[8] -> object = this_proj -> modelgl -> search_widg[8] -> object;
579 active_glwin -> search_widg[8] -> filter = this_proj -> modelgl -> search_widg[8] -> filter;
580 active_glwin -> search_widg[8] -> in_selection = this_proj -> modelgl -> search_widg[8] -> in_selection;
581 active_glwin -> search_widg[8] -> todo_size = this_proj -> modelgl -> search_widg[8] -> todo_size;
582 active_glwin -> search_widg[8] -> todo = duplicate_int (active_glwin -> search_widg[8] -> todo_size, this_proj -> modelgl -> search_widg[8] -> todo);
583 active_glwin -> atom_win -> to_be_inserted[3] = duplicate_atomic_object (this_proj -> modelgl -> atom_win -> to_be_inserted[3]);
585 tmp_a = this_proj -> modelgl -> atom_win -> to_be_inserted[3];
586 tmp_b = active_glwin -> atom_win -> to_be_inserted[3];
587 while (tmp_a -> next)
588 {
589 tmp_b -> next = duplicate_atomic_object (tmp_a -> next);
590 tmp_b -> next -> prev = tmp_b;
591 tmp_b = tmp_b -> next;
592 tmp_a = tmp_a -> next;
593 }
595#ifdef GTK4
596 select_unselect_atoms (NULL, NULL, & active_glwin -> colorp[0][0]);
597#else
598 select_unselect_atoms (NULL, & active_glwin -> colorp[0][0]);
599#endif
601 active_glwin -> cell_win -> cut_this_slab = TRUE;
604 if (active_glwin -> cell_win -> slab_act) invert_selection (active_project);
605#ifdef GTK4
606 remove_the_atoms (NULL, NULL, & cut_sel);
607#else
608 remove_the_atoms (NULL, & cut_sel);
609#endif
610 active_glwin -> cell_win -> slab_passivate = FALSE;
612 active_glwin -> cell_win -> slab_passivate = TRUE;
613 g_free (active_glwin -> search_widg[8]);
614 active_glwin -> search_widg[8] = NULL;
615 if (! active_glwin -> atom_win -> visible)
616 {
617 g_free (active_glwin -> atom_win);
618 active_glwin -> atom_win = NULL;
619 }
620 g_free (active_glwin -> cell_win);
621 active_glwin -> cell_win = NULL;
622 }
623 break;
624 }
625#ifdef GTK4
626// select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
627#else
628// select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
629#endif
630 if (is_out) restore_ogl_selection (this_proj -> modelgl);
631 this_proj -> modelgl -> cell_win -> cut_this_slab = FALSE;
632 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
633 update (this_proj -> modelgl);
634 }
635 }
636 else
637 {
638 show_info ("Nothing to passivate the bond(s) to be broken:\nDeactivate passivating or adjust option(s) properly !", 0, this_proj -> modelgl -> cell_win -> win);
639 }
640 }
641 else
642 {
643 show_info ("The slab is empty, nothing to do !", 0, this_proj -> modelgl -> cell_win -> win);
644 }
645}
646
654GtkWidget * cut_in_model (project * this_proj)
655{
656 int i;
657 GtkWidget * layout;
658 i = (this_proj -> nspec > 3) ? 15 * (this_proj -> nspec - 3) : 0;
659#ifdef G_OS_WIN32
660 layout = create_layout (800, 510+i);
661#else
662 layout = create_layout (800, 420+i);
663#endif
664 GtkWidget * box = create_vbox (BSEP);
665 layout_add_widget (layout, box, 10, 10);
666 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label("Cut slab in the simulation box: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
667
668 GtkWidget * hbox = create_hbox (0);
669 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 5);
670 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button ("<b>Show/Hide slab</b>", 25, -1, this_proj -> modelgl -> cell_win -> slab_show,
671 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[0]), FALSE, FALSE, 20);
672 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button ("Use PBC to select atoms", 25, -1, this_proj -> modelgl -> cell_win -> slab_pbc,
673 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[1]), FALSE, FALSE, 0);
674 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button ("Invert cutting (all but the slab)", 25, -1, this_proj -> modelgl -> cell_win -> slab_act,
675 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[2]), FALSE, FALSE, 20);
676 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button ("Export in new project", 25, -1, this_proj -> modelgl -> cell_win -> slab_out,
677 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[3]), FALSE, FALSE, 0);
678
679 hbox = create_hbox (0);
680 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 10);
681 GtkWidget * hox = create_hbox (0);
682 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, hox, FALSE, FALSE, 0);
683 GtkWidget * combo = create_combo ();
684 gchar * type[3] = {"Parallelepiped", "Cylinder", "Sphere"};
685 for (i=0; i<3; i++) combo_text_append (combo, type[i]);
686 combo_set_active (combo, this_proj -> modelgl -> cell_win -> slab_type);
687 g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK(set_slab_type), this_proj);
688 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hox, markup_label("- Shape of the slab: ", 200, -1, 0.0, 0.5), FALSE, FALSE, 0);
689 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hox, combo, FALSE, FALSE, 5);
690
691 // Passivation
692 hox = create_hbox (0);
693 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, hox, FALSE, FALSE, 100);
694 GtkWidget * but = check_button ("Passivate surface", -1, -1, this_proj -> modelgl -> cell_win -> slab_passivate,
695 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[4]);
696 // widget_set_sensitive (but, 0);
697 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hox, but, FALSE, FALSE, 20);
698 this_proj -> modelgl -> cell_win -> passivate = create_button ("Options", IMG_NONE, NULL, 100, -1, GTK_RELIEF_NORMAL, G_CALLBACK(setup_passivate), this_proj);
699 widget_set_sensitive (this_proj -> modelgl -> cell_win -> passivate, this_proj -> modelgl -> cell_win -> slab_passivate);
700 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hox, this_proj -> modelgl -> cell_win -> passivate, FALSE, FALSE, 0);
701
702 GtkWidget * hhbox = create_hbox (0);
703 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hhbox, FALSE, FALSE, 5);
704 GtkWidget * vbox = create_vbox (BSEP);
705 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, vbox, FALSE, FALSE, 0);
706 this_proj -> modelgl -> cell_win -> slab_opts = create_vbox (BSEP);
707 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, this_proj -> modelgl -> cell_win -> slab_opts, FALSE, FALSE, 5);
708 for (i=0; i<3; i++)
709 {
710 this_proj -> modelgl -> cell_win -> slab_hbox[i] = create_hbox (0);
711 add_box_child_start (GTK_ORIENTATION_VERTICAL, this_proj -> modelgl -> cell_win -> slab_opts, this_proj -> modelgl -> cell_win -> slab_hbox[i], FALSE, FALSE, 5);
712 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, this_proj -> modelgl -> cell_win -> slab_hbox[i], markup_label("- Select option to tweak: ", 200, -1, 0.0, 0.5), FALSE, FALSE, 0);
713 this_proj -> modelgl -> cell_win -> slab_param[i] = create_slab_param_combo (i, this_proj);
714 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, this_proj -> modelgl -> cell_win -> slab_hbox[i], this_proj -> modelgl -> cell_win -> slab_param[i], FALSE, FALSE, 5);
715 }
716 for (i=0; i<6; i++)
717 {
718 this_proj -> modelgl -> cell_win -> slab_box[i] = prepare_slab_box (i, this_proj);
719 add_box_child_start (GTK_ORIENTATION_VERTICAL, this_proj -> modelgl -> cell_win -> slab_opts, this_proj -> modelgl -> cell_win -> slab_box[i], FALSE, FALSE, 5);
720 }
721
723 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, vbox, FALSE, FALSE, 40);
724 GtkWidget * vvbox = create_vbox (BSEP);
725 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, vvbox, FALSE, FALSE, 20);
726 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, markup_label("<u>Slab information:</u>", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
727 hbox = create_hbox (0);
728 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 5);
729 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("- Opacity: ", 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
730 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, create_hscale (0.0, 1.0, 0.01, this_proj -> modelgl -> cell_win -> slab_alpha, GTK_POS_LEFT, 2, 150,
731 G_CALLBACK(set_slab_alpha), G_CALLBACK(scroll_set_slab_alpha), this_proj -> modelgl), FALSE, FALSE, 10);
732 this_proj -> modelgl -> cell_win -> slab_info_box = create_vbox (BSEP);
733 create_slab_info (this_proj);
734 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, this_proj -> modelgl -> cell_win -> slab_info_box, FALSE, FALSE, 5);
735
736 hbox = create_hbox (0);
737 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 5);
738 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, create_button ("Select atom(s) in this slab !", IMG_NONE, NULL, 100, -1, GTK_RELIEF_NORMAL, G_CALLBACK(select_this_slab), this_proj), FALSE, FALSE, 100);
739 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("<b>or</b>", 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
740 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, create_button ("Cut this slab now !", IMG_NONE, NULL, 100, -1, GTK_RELIEF_NORMAL, G_CALLBACK(cut_this_slab), this_proj), FALSE, FALSE, 30);
741
743 return layout;
744}
gboolean do_we_have_objects_in_selection(project *this_proj, atom_search *asearch, gboolean editing)
check for object(s) in selection to apply action
void prepare_atom_edition(gpointer data, gboolean visible)
prepare atom edition
Definition atom_edit.c:453
atom_search * allocate_atom_search(int proj, int action, int searchid, int tsize)
allocate atom search data structure
Definition atom_edit.c:386
Function declarations for the mode edition window.
GtkWidget * action_tab(int aid, project *this_proj)
create model edtion action tab
int is_selected
Definition popup.c:181
atomic_object * duplicate_atomic_object(atomic_object *old_obj)
duplicate an insert object
vec3_t get_bary(project *this_proj, int status)
get barycenter of atomic coordinates
Definition atom_move.c:170
void to_passivate_using_the_objects(project *this_proj, atom_search *asearch)
prepare passivation (delete of an object, then insert of another one at the same location)
G_MODULE_EXPORT void set_spec_changed(GtkComboBox *box, gpointer data)
change the search chemical species
Definition w_search.c:3827
void restore_ogl_selection(glwin *view)
restore a saved atom selection
Definition calc.c:218
int selected_aspec
Definition popup.c:179
void preserve_ogl_selection(glwin *view)
copy the atom selection, so that it can be re-used once the input assistant is closed.
Definition calc.c:264
GtkFileFilter * filter[NCFORMATS+1]
Definition callbacks.c:1416
G_MODULE_EXPORT void set_slab_property(GtkToggleButton *but, gpointer data)
set slab property toggle callback GTK3
Definition cell_cut.c:162
G_MODULE_EXPORT void set_slab_type(GtkComboBox *box, gpointer data)
change slab type
Definition cell_cut.c:328
void invert_selection(project *this_proj)
invert atom(s) selection
Definition cell_cut.c:399
void slab_alpha_has_changed(gpointer data, GLfloat v)
change slab opacity
Definition cell_cut.c:352
G_MODULE_EXPORT void set_slab_option(GtkComboBox *box, gpointer data)
change slab option combo
Definition cell_cut.c:266
G_MODULE_EXPORT void set_filter_changed(GtkComboBox *box, gpointer data)
change the search filter
Definition w_search.c:3856
G_MODULE_EXPORT gboolean scroll_set_slab_alpha(GtkRange *range, GtkScrollType scroll, gdouble value, gpointer data)
change slab opactiy callback - scoll
Definition cell_cut.c:373
GtkWidget * cut_in_model(project *this_proj)
create the cut slab tab
Definition cell_cut.c:654
G_MODULE_EXPORT void cut_this_slab(GtkButton *but, gpointer data)
cut this slab callback
Definition cell_cut.c:488
void create_slab_info(project *this_proj)
create slab information widget
Definition cell_cut.c:109
G_MODULE_EXPORT void setup_passivate(GtkButton *but, gpointer data)
passivate button callback
Definition cell_cut.c:67
G_MODULE_EXPORT void select_this_slab(GtkButton *but, gpointer data)
select / unselect atom(s) in slab callback
Definition cell_cut.c:457
GtkWidget * create_slab_param_combo(int sid, project *this_proj)
create slab parameters combo widget
Definition cell_cut.c:304
G_MODULE_EXPORT void set_slab_alpha(GtkRange *range, gpointer data)
change slab opactiy callback - range
Definition cell_cut.c:387
GtkWidget * prepare_slab_box(int sid, project *this_proj)
create slab parameters widget box
Definition cell_cut.c:223
Function declarations for the cell edition window.
GtkWidget * create_cell_entries(project *this_proj, int i)
create the cell entry widgets
Definition cell_shift.c:402
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
color colorp[64]
PangoLayout * layout
Definition curve.c:79
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
void create_slab_lists(project *this_proj)
prepare slab(s) OpenGL rendering
Definition d_box.c:899
void process_selected_atom(project *this_proj, glwin *view, int id, int ac, int se, int pi)
process selected atom
Definition selection.c:514
atom_in_selection * tmp_a
Definition d_measures.c:69
atom_in_selection * tmp_b
Definition d_measures.c:69
int atoms[NUM_STYLES][2]
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:560
double * duplicate_double(int num, double *old_val)
copy a list of double
Definition global.c:608
int dialog_id
Definition global.c:167
int activep
Definition global.c:159
GMainLoop * Event_loop[5]
Definition global.c:178
int nprojects
Definition global.c:158
double * allocdouble(int val)
allocate a double * pointer
Definition global.c:459
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
@ IMG_NONE
Definition global.h:262
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:909
glwin * active_glwin
Definition project.c:53
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:2095
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:520
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
#define BSEP
Definition global.h:247
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
void layout_add_widget(GtkWidget *layout, GtkWidget *child, int x_pos, int y_pos)
Add a GtkWidget in a GtkLayout.
Definition gtk-misc.c:856
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1893
@ CONTAINER_SCR
Definition global.h:253
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
Definition gtk-misc.c:1955
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:984
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:835
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1646
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:308
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:215
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2200
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:823
G_MODULE_EXPORT void select_unselect_atoms(GtkWidget *widg, gpointer data)
select / unselect a type of atom(s) callback GTK3
Definition popup.c:1550
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:961
GtkWidget * create_layout(int x, int y)
create a GtkLayout / GtkFixed widget
Definition gtk-misc.c:890
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2169
GtkWidget * create_hscale(float min, float max, float delta, float val, int pos, int round, int size, GCallback handler, GCallback scroll_handler, gpointer data)
create an horizontal scale GtkWidget
Definition gtk-misc.c:754
tint cut_sel
Definition gui.c:145
gchar * prepare_for_title(gchar *init)
prepare a string for a window title, getting rid of all markup
Definition tools.c:71
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:235
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:198
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:811
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1855
G_MODULE_EXPORT void edit_in_new_project(GtkWidget *widg, gpointer data)
create new project using selection callback GTK3
Definition popup.c:2191
project * active_project
Definition project.c:47
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:182
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
G_MODULE_EXPORT void remove_the_atoms(GtkWidget *widg, gpointer data)
remove selected atom(s) callback GTK3
Definition popup.c:1296
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:450
void re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
gboolean pick
@ EDITION
Definition glview.h:167
void cleaning_shaders(glwin *view, int shader)
re-initialize an OpenGL shader
void update_all_selections(glwin *view, int pi)
update the selection data: bonds, angles and dihedrals
Definition selection.c:387
void save_all_selections(glwin *view, int pi)
save all selection data
Definition selection.c:372
@ REPLACE
Definition glview.h:234
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ LABEL
Definition glwin.h:98
@ SLABS
Definition glwin.h:101
@ SELEC
Definition glwin.h:91
void show_info(char *information, int val, GtkWidget *win)
add / show information message to widget
Definition interface.c:234
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:356
void active_project_changed(int id)
change the active project
Definition update_p.c:175
Definition glwin.h:351
Definition global.h:99
Definition glwin.h:965
int b
Definition tab-1.c:95
int a
Definition tab-1.c:95
int status
Definition w_advance.c:178
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72