atomes 1.1.16
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-2024 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 gtk_combo_box_set_active (GTK_COMBO_BOX(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 gtk_combo_box_set_active (GTK_COMBO_BOX(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;
168#ifdef GTK4
169 status = gtk_check_button_get_active (but);
170#else
171 status = gtk_toggle_button_get_active (but);
172#endif
173 switch (dat -> b)
174 {
175 case 0:
176 view -> cell_win -> slab_show = status;
177 break;
178 case 1:
179 view -> cell_win -> slab_pbc = status;
180 break;
181 case 2:
182 view -> cell_win -> slab_act = status;
183 break;
184 case 3:
185 view -> cell_win -> slab_out = status;
186 break;
187 case 4:
188 view -> cell_win -> slab_passivate = status;
189 widget_set_sensitive (view -> cell_win -> passivate, view -> cell_win -> slab_passivate);
190 if (view -> cell_win -> slab_passivate)
191 {
192 prepare_atom_edition (& view -> colorp[0][0], FALSE);
193 view -> search_widg[8] = allocate_atom_search (dat -> a, REPLACE, 8, get_project_by_id(dat -> a) -> nspec);
194 view -> search_widg[8] -> status = 2;
195 setup_passivate (NULL, get_project_by_id(dat -> a));
196 }
197 else
198 {
199 g_free (view -> search_widg[8]);
200 view -> search_widg[8] = NULL;
201 if (! view -> atom_win -> visible)
202 {
203 g_free (view -> atom_win);
204 view -> atom_win = NULL;
205 }
206 }
207 break;
208 }
209 if (view -> cell_win -> slab_show)
210 {
211 view -> create_shaders[SLABS] = TRUE;
212 }
213 else
214 {
215 cleaning_shaders (view, SLABS);
216 }
217 update (view);
218}
219
228GtkWidget * prepare_slab_box (int sid, project * this_proj)
229{
230 gchar * option[6]={"- Position the center of the slab: ", // 6, 7, 8
231 "- Size of the slab: ", // 9, 10, 11
232 "- Size of the slab: ", // 12, 13
233 "- Size of the slab: ", // 14
234 "- Parallelepiped Angles: ", // 15, 16, 17
235 "- Slab rotation: "}; // 18, 19, 20
236 GtkWidget * vbox = create_vbox (BSEP);
237 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(option[sid], 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
238 int i;
239 switch (sid)
240 {
241 case 0:
242 for (i=6; i<9; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
243 break;
244 case 1:
245 for (i=9; i<12; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
246 break;
247 case 2:
248 for (i=12; i<14; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
249 break;
250 case 3:
251 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, 14), FALSE, FALSE, 0);
252 break;
253 case 4:
254 for (i=15; i<18; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
255 break;
256 case 5:
257 for (i=18; i<21; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
258 break;
259 }
260 return vbox;
261}
262
271G_MODULE_EXPORT void set_slab_option (GtkComboBox * box, gpointer data)
272{
273 project * this_proj = (project *)data;
274 int i, j;
275 i = gtk_combo_box_get_active (box);
276 for (j=0; j<6; j++)
277 {
278 hide_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[j]);
279 }
280 switch (i)
281 {
282 case 0:
283 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[0]);
284 break;
285 case 1:
286 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[1+this_proj -> modelgl -> cell_win -> slab_type]);
287 break;
288 default:
289 if (this_proj -> modelgl -> cell_win -> slab_type)
290 {
291 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[5]);
292 }
293 else
294 {
295 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_box[i+2]);
296 }
297 break;
298 }
299}
300
309GtkWidget * create_slab_param_combo (int sid, project * this_proj)
310{
311 GtkWidget * combo = create_combo ();
312 gchar * options[4] = {"Position", "Size", "Angles", "Rotation"};
313 int i, j, k;
314 i = 4 - sid;
315 for (j=0; j<i; j++)
316 {
317 k = (! sid) ? j : (sid == 1 && j == 2) ? 3 : j;
318 combo_text_append (combo, options[k]);
319 }
320 gtk_combo_box_set_active (GTK_COMBO_BOX(combo), 0);
321 g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK(set_slab_option), this_proj);
322 return combo;
323}
324
333G_MODULE_EXPORT void set_slab_type (GtkComboBox * box, gpointer data)
334{
335 project * this_proj = (project *)data;
336 int i;
337 for (i=0; i<3; i++) hide_the_widgets (this_proj -> modelgl -> cell_win -> slab_hbox[i]);
338 this_proj -> modelgl -> cell_win -> slab_type = i = gtk_combo_box_get_active (box);
339 show_the_widgets (this_proj -> modelgl -> cell_win -> slab_hbox[i]);
340 gtk_combo_box_set_active (GTK_COMBO_BOX(this_proj -> modelgl -> cell_win -> slab_param[i]), 0);
341 set_slab_option (GTK_COMBO_BOX(this_proj -> modelgl -> cell_win -> slab_param[i]), this_proj);
342 if (this_proj -> modelgl -> n_shaders[SLABS][0])
343 {
344 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
345 update (this_proj -> modelgl);
346 }
347}
348
357void slab_alpha_has_changed (gpointer data, GLfloat v)
358{
359 glwin * view = (glwin *)data;
360 view -> cell_win -> slab_alpha = v;
361 if (view -> n_shaders[SLABS][0])
362 {
363 view -> create_shaders[SLABS] = TRUE;
364 update (view);
365 }
366}
367
378G_MODULE_EXPORT gboolean scroll_set_slab_alpha (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
379{
380 slab_alpha_has_changed (data, (GLfloat) value);
381 return FALSE;
382}
383
392G_MODULE_EXPORT void set_slab_alpha (GtkRange * range, gpointer data)
393{
394 slab_alpha_has_changed (data, (GLfloat) gtk_range_get_value (range));
395}
396
404void invert_selection (project * this_proj)
405{
406 save_all_selections (this_proj -> modelgl, 0);
407 int i, j, k;
408 if (this_proj -> modelgl -> mode == EDITION)
409 {
410 // Invert the saved coordinates as well
411 double ** saved_c = NULL;
412 i = this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected;
413 if (i < this_proj -> natomes)
414 {
415 saved_c = g_malloc0 ((this_proj -> natomes - i)*sizeof*saved_c);
416 k = 0;
417 for (j=0; j<this_proj -> natomes; j++)
418 {
419 if (! this_proj -> atoms[0][j].pick[0])
420 {
421 saved_c[k] = allocdouble (3);
422 saved_c[k][0] = this_proj -> atoms[0][j].x;
423 saved_c[k][1] = this_proj -> atoms[0][j].y;
424 saved_c[k][2] = this_proj -> atoms[0][j].z;
425 k ++;
426 }
427 }
428 }
429 g_free (this_proj -> modelgl -> saved_coord[1]);
430 this_proj -> modelgl -> saved_coord[1] = NULL;
431 if (saved_c)
432 {
433 this_proj -> modelgl -> saved_coord[1] = g_malloc0 ((this_proj -> natomes - i)*sizeof*this_proj -> modelgl -> saved_coord[1]);
434 for (j=0; j<this_proj -> natomes - i; j++)
435 {
436 this_proj -> modelgl -> saved_coord[1][j] = duplicate_double(3, saved_c[j]);
437 }
438 g_free (saved_c);
439 }
440 }
441 for (i=0; i<this_proj -> natomes; i++)
442 {
443 process_selected_atom (this_proj, this_proj -> modelgl, i, 0, 0, 0);
444 }
445 update_all_selections (this_proj -> modelgl, 0);
446 if (this_proj -> modelgl -> mode == EDITION)
447 {
448 this_proj -> modelgl -> baryc[1] = get_bary (this_proj, 1);
449 }
450 int shaders[1] = {SELEC};
451 re_create_md_shaders (1, shaders, this_proj);
452}
453
462G_MODULE_EXPORT void select_this_slab (GtkButton * but, gpointer data)
463{
464 project * this_proj = (project *)data;
465 this_proj -> modelgl -> cell_win -> cut_this_slab = TRUE;
466 opengl_project_changed (this_proj -> id);
467 selected_aspec = -1;
468#ifdef GTK4
469 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
470#else
471 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
472#endif
473 save_all_selections (this_proj -> modelgl, 0);
474 create_slab_lists (this_proj);
475 update_all_selections (this_proj -> modelgl, 0);
476 if (this_proj -> modelgl -> cell_win -> slab_act) invert_selection (this_proj);
477 this_proj -> modelgl -> cell_win -> cut_this_slab = FALSE;
478 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
479 int shaders[1] = {SELEC};
480 re_create_md_shaders (1, shaders, this_proj);
481 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
482 update (this_proj -> modelgl);
483}
484
493G_MODULE_EXPORT void cut_this_slab (GtkButton * but, gpointer data)
494{
495 project * this_proj = (project *)data;
496 int is_out, i;
497 if (this_proj -> modelgl-> cell_win -> slab_atoms)
498 {
499 if (! this_proj -> modelgl -> cell_win -> slab_passivate || do_we_have_objects_in_selection(this_proj, this_proj -> modelgl -> search_widg[8], FALSE))
500 {
501 is_out = this_proj -> modelgl -> cell_win -> slab_out;
502 if (this_proj -> modelgl -> search_widg[8]) this_proj -> modelgl -> search_widg[8] -> passivating = FALSE;
503 gchar * infom[2] = {"Cut and modify model ?\n This is irreversible !", "Cut and create new project ?"};
504 if (ask_yes_no("Cut", infom[is_out], GTK_MESSAGE_WARNING, this_proj -> modelgl -> cell_win -> win))
505 {
506 this_proj -> modelgl -> cell_win -> cut_this_slab = TRUE;
507 if (is_out) preserve_ogl_selection (this_proj -> modelgl);
508 opengl_project_changed (this_proj -> id);
509 selected_aspec = -1;
510#ifdef GTK4
511 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
512#else
513 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
514#endif
515 save_all_selections (this_proj -> modelgl, 0);
516 create_slab_lists (this_proj);
517 update_all_selections (this_proj -> modelgl, 0);
518 is_selected = 1;
519 if (this_proj -> modelgl -> cell_win -> slab_act) invert_selection (this_proj);
520 switch (is_out)
521 {
522 case 0:
523 // Modify project
524 if (this_proj -> modelgl -> cell_win -> slab_passivate)
525 {
526 if (this_proj -> modelgl -> atom_win)
527 {
528#ifdef GTK4
529 remove_the_atoms (NULL, NULL, & cut_sel);
530#else
531 remove_the_atoms (NULL, & cut_sel);
532#endif
533 this_proj -> modelgl -> cell_win -> slab_passivate = FALSE;
534 to_passivate_using_the_objects (this_proj, this_proj -> modelgl -> search_widg[8]);
535 this_proj -> modelgl -> cell_win -> slab_passivate = TRUE;
536 }
537 }
538 else
539 {
540#ifdef GTK4
541 remove_the_atoms (NULL, NULL, & cut_sel);
542#else
543 remove_the_atoms (NULL, & cut_sel);
544#endif
545 }
546 break;
547 case 1:
548 // Create new project
549 if (this_proj -> modelgl -> cell_win -> slab_passivate)
550 {
551#ifdef GTK4
552 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
553#else
554 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
555#endif
556 }
557#ifdef GTK4
558 edit_in_new_project (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
559#else
560 edit_in_new_project (NULL, & this_proj -> modelgl -> colorp[0][0]);
561#endif
562 if (this_proj -> modelgl -> cell_win -> slab_passivate)
563 {
564#ifdef GTK4
565 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
566#else
567 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
568#endif
569 this_proj -> modelgl -> cell_win -> cut_this_slab = FALSE;
570 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
571 update (this_proj -> modelgl);
573 active_glwin -> cell_win = g_malloc0(sizeof*active_glwin -> cell_win);
574 active_glwin -> cell_win -> slab_lot = allocint (active_project -> nspec);
575 active_glwin -> cell_win -> slab_type = this_proj -> modelgl -> cell_win ->slab_type;
576 active_glwin -> cell_win -> slab_pbc = this_proj -> modelgl -> cell_win ->slab_pbc;
577 active_glwin -> cell_win -> slab_act = this_proj -> modelgl -> cell_win -> slab_act;
578 active_glwin -> cell_win -> slab_passivate = TRUE;
579 for (i=0; i<21; i++) active_glwin -> cell_win -> cparam[i] = this_proj -> modelgl -> cell_win -> cparam[i];
580 prepare_atom_edition (& active_glwin -> colorp[0][0], FALSE);
581 active_glwin -> search_widg[8] = allocate_atom_search (activep, REPLACE, 8, this_proj -> modelgl -> search_widg[8] -> todo_size);
582 active_glwin -> search_widg[8] -> status = 2;
583 active_glwin -> search_widg[8] -> object = this_proj -> modelgl -> search_widg[8] -> object;
584 active_glwin -> search_widg[8] -> filter = this_proj -> modelgl -> search_widg[8] -> filter;
585 active_glwin -> search_widg[8] -> in_selection = this_proj -> modelgl -> search_widg[8] -> in_selection;
586 active_glwin -> search_widg[8] -> todo_size = this_proj -> modelgl -> search_widg[8] -> todo_size;
587 active_glwin -> search_widg[8] -> todo = duplicate_int (active_glwin -> search_widg[8] -> todo_size, this_proj -> modelgl -> search_widg[8] -> todo);
588 active_glwin -> atom_win -> to_be_inserted[3] = duplicate_atomic_object (this_proj -> modelgl -> atom_win -> to_be_inserted[3]);
590 tmp_a = this_proj -> modelgl -> atom_win -> to_be_inserted[3];
591 tmp_b = active_glwin -> atom_win -> to_be_inserted[3];
592 while (tmp_a -> next)
593 {
594 tmp_b -> next = duplicate_atomic_object (tmp_a -> next);
595 tmp_b -> next -> prev = tmp_b;
596 tmp_b = tmp_b -> next;
597 tmp_a = tmp_a -> next;
598 }
600#ifdef GTK4
601 select_unselect_atoms (NULL, NULL, & active_glwin -> colorp[0][0]);
602#else
603 select_unselect_atoms (NULL, & active_glwin -> colorp[0][0]);
604#endif
606 active_glwin -> cell_win -> cut_this_slab = TRUE;
609 if (active_glwin -> cell_win -> slab_act) invert_selection (active_project);
610#ifdef GTK4
611 remove_the_atoms (NULL, NULL, & cut_sel);
612#else
613 remove_the_atoms (NULL, & cut_sel);
614#endif
615 active_glwin -> cell_win -> slab_passivate = FALSE;
617 active_glwin -> cell_win -> slab_passivate = TRUE;
618 g_free (active_glwin -> search_widg[8]);
619 active_glwin -> search_widg[8] = NULL;
620 if (! active_glwin -> atom_win -> visible)
621 {
622 g_free (active_glwin -> atom_win);
623 active_glwin -> atom_win = NULL;
624 }
625 g_free (active_glwin -> cell_win);
626 active_glwin -> cell_win = NULL;
627 }
628 break;
629 }
630#ifdef GTK4
631// select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][0]);
632#else
633// select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][0]);
634#endif
635 if (is_out) restore_ogl_selection (this_proj -> modelgl);
636 this_proj -> modelgl -> cell_win -> cut_this_slab = FALSE;
637 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
638 update (this_proj -> modelgl);
639 }
640 }
641 else
642 {
643 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);
644 }
645 }
646 else
647 {
648 show_info ("The slab is empty, nothing to do !", 0, this_proj -> modelgl -> cell_win -> win);
649 }
650}
651
659GtkWidget * cut_in_model (project * this_proj)
660{
661 int i;
662 GtkWidget * layout;
663 i = (this_proj -> nspec > 3) ? 15 * (this_proj -> nspec - 3) : 0;
664#ifdef G_OS_WIN32
665 layout = create_layout (800, 510+i);
666#else
667 layout = create_layout (800, 420+i);
668#endif
669 GtkWidget * box = create_vbox (BSEP);
670 layout_add_widget (layout, box, 10, 10);
671 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);
672
673 GtkWidget * hbox = create_hbox (0);
674 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 5);
675 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button ("<b>Show/Hide slab</b>", 25, -1, this_proj -> modelgl -> cell_win -> slab_show,
676 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[0]), FALSE, FALSE, 20);
677 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button ("Use PBC to select atoms", 25, -1, this_proj -> modelgl -> cell_win -> slab_pbc,
678 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[1]), FALSE, FALSE, 0);
679 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,
680 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[2]), FALSE, FALSE, 20);
681 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button ("Export in new project", 25, -1, this_proj -> modelgl -> cell_win -> slab_out,
682 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[3]), FALSE, FALSE, 0);
683
684 hbox = create_hbox (0);
685 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 10);
686 GtkWidget * hox = create_hbox (0);
687 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, hox, FALSE, FALSE, 0);
688 GtkWidget * combo = create_combo ();
689 gchar * type[3] = {"Parallelepiped", "Cylinder", "Sphere"};
690 for (i=0; i<3; i++) combo_text_append (combo, type[i]);
691 gtk_combo_box_set_active (GTK_COMBO_BOX(combo), this_proj -> modelgl -> cell_win -> slab_type);
692 g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK(set_slab_type), this_proj);
693 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hox, markup_label("- Shape of the slab: ", 200, -1, 0.0, 0.5), FALSE, FALSE, 0);
694 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hox, combo, FALSE, FALSE, 5);
695
696 // Passivation
697 hox = create_hbox (0);
698 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, hox, FALSE, FALSE, 100);
699 GtkWidget * but = check_button ("Passivate surface", -1, -1, this_proj -> modelgl -> cell_win -> slab_passivate,
700 G_CALLBACK(set_slab_property), & this_proj -> modelgl -> cell_win -> slab_pointer[4]);
701 // widget_set_sensitive (but, 0);
702 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hox, but, FALSE, FALSE, 20);
703 this_proj -> modelgl -> cell_win -> passivate = create_button ("Options", IMG_NONE, NULL, 100, -1, GTK_RELIEF_NORMAL, G_CALLBACK(setup_passivate), this_proj);
704 widget_set_sensitive (this_proj -> modelgl -> cell_win -> passivate, this_proj -> modelgl -> cell_win -> slab_passivate);
705 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hox, this_proj -> modelgl -> cell_win -> passivate, FALSE, FALSE, 0);
706
707 GtkWidget * hhbox = create_hbox (0);
708 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hhbox, FALSE, FALSE, 5);
709 GtkWidget * vbox = create_vbox (BSEP);
710 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, vbox, FALSE, FALSE, 0);
711 this_proj -> modelgl -> cell_win -> slab_opts = create_vbox (BSEP);
712 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, this_proj -> modelgl -> cell_win -> slab_opts, FALSE, FALSE, 5);
713 for (i=0; i<3; i++)
714 {
715 this_proj -> modelgl -> cell_win -> slab_hbox[i] = create_hbox (0);
716 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);
717 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);
718 this_proj -> modelgl -> cell_win -> slab_param[i] = create_slab_param_combo (i, this_proj);
719 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);
720 }
721 for (i=0; i<6; i++)
722 {
723 this_proj -> modelgl -> cell_win -> slab_box[i] = prepare_slab_box (i, this_proj);
724 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);
725 }
726
728 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, vbox, FALSE, FALSE, 40);
729 GtkWidget * vvbox = create_vbox (BSEP);
730 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, vvbox, FALSE, FALSE, 20);
731 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, markup_label("<u>Slab information:</u>", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
732 hbox = create_hbox (0);
733 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 5);
734 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("- Opacity: ", 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
735 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,
736 G_CALLBACK(set_slab_alpha), G_CALLBACK(scroll_set_slab_alpha), this_proj -> modelgl), FALSE, FALSE, 10);
737 this_proj -> modelgl -> cell_win -> slab_info_box = create_vbox (BSEP);
738 create_slab_info (this_proj);
739 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, this_proj -> modelgl -> cell_win -> slab_info_box, FALSE, FALSE, 5);
740
741 hbox = create_hbox (0);
742 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 5);
743 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);
744 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("<b>or</b>", 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
745 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);
746
748 return layout;
749}
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:459
atom_search * allocate_atom_search(int proj, int action, int searchid, int tsize)
allocate atom search data structure
Definition atom_edit.c:392
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:182
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:3829
void restore_ogl_selection(glwin *view)
restore a saved atom selection
Definition calc.c:218
int selected_aspec
Definition popup.c:180
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:1405
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:333
void invert_selection(project *this_proj)
invert atom(s) selection
Definition cell_cut.c:404
void slab_alpha_has_changed(gpointer data, GLfloat v)
change slab opacity
Definition cell_cut.c:357
G_MODULE_EXPORT void set_slab_option(GtkComboBox *box, gpointer data)
change slab option combo
Definition cell_cut.c:271
G_MODULE_EXPORT void set_filter_changed(GtkComboBox *box, gpointer data)
change the search filter
Definition w_search.c:3858
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:378
GtkWidget * cut_in_model(project *this_proj)
create the cut slab tab
Definition cell_cut.c:659
G_MODULE_EXPORT void cut_this_slab(GtkButton *but, gpointer data)
cut this slab callback
Definition cell_cut.c:493
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:462
GtkWidget * create_slab_param_combo(int sid, project *this_proj)
create slab parameters combo widget
Definition cell_cut.c:309
G_MODULE_EXPORT void set_slab_alpha(GtkRange *range, gpointer data)
change slab opactiy callback - range
Definition cell_cut.c:392
GtkWidget * prepare_slab_box(int sid, project *this_proj)
create slab parameters widget box
Definition cell_cut.c:228
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:898
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:260
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:1960
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:510
#define BSEP
Definition global.h:245
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:846
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1799
@ CONTAINER_SCR
Definition global.h:251
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:1863
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:923
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:825
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1585
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:299
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:206
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2065
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
G_MODULE_EXPORT void select_unselect_atoms(GtkWidget *widg, gpointer data)
select / unselect a type of atom(s) callback GTK3
Definition popup.c:1551
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:900
GtkWidget * create_layout(int x, int y)
create a GtkLayout / GtkFixed widget
Definition gtk-misc.c:880
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
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:744
tint cut_sel
Definition gui.c:144
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:226
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:189
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
G_MODULE_EXPORT void edit_in_new_project(GtkWidget *widg, gpointer data)
create new project using selection callback GTK3
Definition popup.c:2192
project * active_project
Definition project.c:47
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
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:1297
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
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:158
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:225
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 global.h:97
Definition glwin.h:875
int b
Definition tab-1.c:95
int a
Definition tab-1.c:95
int status
Definition w_advance.c:160
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72