89 int * min_bs, * max_bs;
98 g_debug (
"coord -> species = %d", coord -> species);
102 g_debug (
" --- start geo[%d] ---", i);
103 g_debug (
"geo i = %d, totcoord[%d] = %d", i, i, coord -> totcoord[i]);
104 if ((i < 2 || i > 3) && coord -> totcoord[i])
106 j = (i < 2) ? coord -> species : 1;
107 g_debug (
" spec i = %d, jmax= %d", i, j);
111 min_bs[k] = max_bs[k] = coord -> partial_geo[k][0][0];
112 for (m=0; m<coord -> species; m++)
114 min_bs[k] =
min (min_bs[k], coord -> partial_geo[k][0][m]);
115 max_bs[k] =
max (max_bs[k], coord -> partial_geo[k][0][m]);
117 for (l=1; l<coord -> ntg[i][k]; l++)
119 for (m=0; m<coord -> species; m++)
121 min_bs[k] =
min (min_bs[k], coord -> partial_geo[k][l][m]);
122 max_bs[k] =
max (max_bs[k], coord -> partial_geo[k][l][m]);
128 g_debug (
" coord i = %d, k = %d, coord -> ntg[%d][%d] = %d", i, k, i, k, coord -> ntg[i][k]);
129 test = (this_proj) ?
test_this_coord (this_proj, k, i, 0, min_bs[k], max_bs[k]) : 0;
130 str = g_strdup_printf (
" l = %d, coord -> geolist[%d][%d][%d]= %d, num[at,%d]= %d", 0, i, k, 0, coord -> geolist[i][k][0], 0, test);
131 if (coord -> ntg[i][k] > 1)
133 for (l=1; l<coord -> ntg[i][k]; l++)
135 test = (this_proj) ?
test_this_coord (this_proj, k, i, l, min_bs[k], max_bs[k]) : 0;
136 str = g_strdup_printf (
"%s\n l = %d, coord -> geolist[%d][%d][%d]= %d, num[at,%d]= %d", str, l, i, k, l, coord -> geolist[i][k][l], l, test);
147 str = g_strdup_printf (
" Partials geo\n k = %d, coord -> partial_geo[%d][%d][%d]= %d", k, k, 0, 0, coord -> partial_geo[k][0][0]);
150 str = g_strdup_printf (
"%s\n k = %d, coord -> partial_geo[%d][%d][%d]= %d", str, k, k, 0, l, coord -> partial_geo[k][0][l]);
152 if (coord -> ntg[i][k] > 1)
154 for (l=1; l<coord -> ntg[i][k]; l++)
156 str = g_strdup_printf (
"%s\n\n k = %d, coord -> partial_geo[%d][%d][%d]= %d", str, k, k, l, 0, coord -> partial_geo[k][l][0]);
159 str = g_strdup_printf (
"%s\n k = %d, coord -> partial_geo[%d][%d][%d]= %d", str, k, k, l, m, coord -> partial_geo[k][l][m]);
169 g_debug (
" --- end geo[%d] ---", i);
178 g_debug (
"Coord is empty no species !");
192 coord_info * new_coord = g_malloc0 (
sizeof*new_coord);
194 if (! old_coord -> species)
return new_coord;
195 new_coord -> species = old_coord -> species;
196 new_coord -> cmax = old_coord -> cmax;
197 new_coord -> cmin = old_coord -> cmin;
200 new_coord -> totcoord[i] = old_coord -> totcoord[i];
201 if ((i < 2 || i > 3) && old_coord -> totcoord[i])
203 j = (i < 2) ? new_coord -> species : 1;
204 new_coord -> ntg[i] =
duplicate_int (j, old_coord -> ntg[i]);
205 new_coord -> geolist[i] = g_malloc0 (j*
sizeof*new_coord -> geolist[i]);
206 if (i == 1) new_coord -> partial_geo = g_malloc0 (j*
sizeof*new_coord -> partial_geo);
209 new_coord -> geolist[i][k] =
duplicate_int (new_coord -> ntg[i][k], old_coord -> geolist[i][k]);
212 new_coord -> partial_geo[k] = g_malloc0 (new_coord -> ntg[i][k]*
sizeof*new_coord -> partial_geo[k]);
213 for (l=0; l<new_coord -> ntg[i][k]; l++)
215 new_coord -> partial_geo[k][l] =
duplicate_int (new_coord -> species, old_coord -> partial_geo[k][l]);
242 int new_spec,
int rem,
int adds,
int * spid,
int *** tmpgeo,
243 gboolean * showcoord[2], gboolean * showpoly[2])
245 int i, j, k, l, m, n, o, p, q, r, s;
248 g_free (edit -> coord);
249 edit -> coord = g_malloc0 (
sizeof*edit -> coord);
251 this_proj -> coord -> cmin = 20;
252 this_proj -> coord -> cmax = 0;
258 if (i)
tmp_coord -> partial_geo = g_malloc (new_spec*
sizeof*
tmp_coord -> partial_geo);
259 showcoord[i] =
allocbool(old_coord -> totcoord[i]);
260 showpoly[i] =
allocbool(old_coord -> totcoord[i]);
265 for (k=0; k<new_spec+rem; k++)
271 tntg =
allocint (old_coord -> ntg[i][k]);
273 for (m=0; m<old_coord -> ntg[i][k]; m++)
287 for (q=0; q<new_spec+rem; q++)
289 if (spid[q] && old_coord -> partial_geo[k][m][q] != old_coord -> partial_geo[k][o][q])
303 if (old_coord -> geolist[i][k][m] == old_coord -> geolist[i][k][o])
319 for (p=0; p<this_proj -> natomes; p++)
321 if (this_proj ->
atoms[0][p].sp == s)
323 if (this_proj ->
atoms[0][p].coord[i] == m)
343 p = (k < new_spec+rem-adds) ? k : new_spec+rem-adds;
345 for (r=0; r<p; r++) q += this_proj -> coord -> ntg[i][r];
347 for (r=0; r<j; r++) p +=
tmp_coord -> ntg[i][r];
349 for (n=0; n<old_coord -> ntg[i][k]; n++)
354 tmp_coord -> geolist[i][j][m] = old_coord -> geolist[i][k][n];
355 this_proj -> coord -> cmax =
max (
tmp_coord -> geolist[i][j][m], this_proj -> coord -> cmax);
356 this_proj -> coord -> cmin =
min (
tmp_coord -> geolist[i][j][m], this_proj -> coord -> cmin);
357 if (k < new_spec-adds+rem)
359 if (n < this_proj -> coord -> ntg[i][k])
362 showcoord[i][p+m] = this_proj -> modelgl -> anim -> last ->
img -> show_coord[i][q+n];
363 showpoly[i][p+m] = this_proj -> modelgl -> anim -> last ->
img -> show_poly[i][q+n];
367 showcoord[i][p+m] = TRUE;
368 showpoly[i][p+m] = FALSE;
374 showcoord[i][p+m] = TRUE;
375 showpoly[i][p+m] = FALSE;
380 for (r=0; r<new_spec+rem; r++)
384 tmp_coord -> partial_geo[j][m][o] = old_coord -> partial_geo[k][n][r];
397 s += (spid[k]) ? 1 : 0;
420 gboolean * showcoord[2], gboolean * showpoly[2], gboolean * showfrag,
421 gboolean update_it, gboolean update_mol)
426 g_free (this_proj -> modelgl -> gcid[i]);
427 this_proj -> modelgl -> gcid[i] = NULL;
432 for (j=0; j<new_spec; j++)
437 for (j=0; j<new_spec; j++)
440 for (k=0; k<coord -> ntg[1][j]; k++)
partial_geo_out_ (& j, & k, & new_spec, coord -> partial_geo[j][k]);
445 this_proj -> coord -> totcoord[i] += nmols;
446 if (this_proj -> coord -> totcoord[i])
448 this_proj -> modelgl -> adv_bonding[i-2] = TRUE;
454 this_proj -> modelgl -> adv_bonding[i-2] = FALSE;
459 if (this_proj -> coord -> totcoord[i])
461 this_proj -> modelgl -> adv_bonding[i-2] = TRUE;
468 this_proj -> modelgl -> adv_bonding[1] = FALSE;
469 this_proj -> coord -> totcoord[3] = 0;
478 for (i=0; i<2; i++) viz[i] =
allocbool (this_proj -> natomes);
479 for (i=0; i<this_proj -> natomes; i++)
481 for (j=0; j<2; j++) viz[j][i] = this_proj ->
atoms[0][i].show[j];
487 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
489 if (this_proj -> modelgl -> ogl_geom[0][i][j])
491 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_geom[0][i][j]))
493 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][i][j]) != showcoord[i][j])
495 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][i][j], showcoord[i][j]);
499 if (this_proj -> modelgl -> ogl_poly[0][i][j])
501 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_poly[0][i][j]))
503 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_poly[0][i][j]) != showpoly[i][j])
505 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_poly[0][i][j], showpoly[i][j]);
510 g_free (showcoord[i]);
511 g_free (showpoly[i]);
513 for (i=0; i<this_proj -> coord -> totcoord[2]; i++)
515 if (this_proj -> modelgl -> ogl_geom[0][2][i])
517 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_geom[0][2][i]))
519 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][2][i]) != showfrag[i])
521 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][2][i], showfrag[i]);
527 for (i=0; i<this_proj -> natomes; i++)
529 for (j=0; j<2; j++) this_proj ->
atoms[0][i].show[j] = viz[j][i];
531 for (i=0; i<2; i++) g_free (viz[i]);
552 int old_spec = this_proj -> nspec;
554 int new_spec = old_spec + add - rem;
555 gboolean * showcoord[2];
556 gboolean * showpoly[2];
557 gboolean update_it = FALSE;
559 clean_coords_and_geoms (this_proj, this_proj -> modelgl -> atom_win, new_spec, rem, add, num, tmpgeo, showcoord, showpoly);
567 this_proj -> nspec = new_spec;
570 if ((add && old_spec) || rem)
572 int h, i, j, k, l, m, n, o, p, q;
573 image * new_img = g_malloc0 (
sizeof*new_img);
575 image * old_img = this_proj -> modelgl -> anim -> last ->
img;
579 for (j=0; j<old_spec; j++)
584 new_img -> show_atom[i][j-k] = old_img -> show_atom[i][j];
585 new_img -> show_label[i][j-k] = old_img -> show_label[i][j];
589 for (h=0; h<2*old_spec; h++)
591 i = (h < old_spec) ? h : h - old_spec;
595 k = (h < old_spec) ? 0 : 1;
596 l = h - k*old_spec - j + k*new_spec;
597 new_img -> sphererad[l] = old_img -> sphererad[h];
598 new_img -> atomicrad[l] = old_img -> atomicrad[h];
599 new_img -> pointrad[l] = old_img -> pointrad[h];
600 new_img -> at_color[l].red = old_img -> at_color[h].red;
601 new_img -> at_color[l].green = old_img -> at_color[h].green;
602 new_img -> at_color[l].blue = old_img -> at_color[h].blue;
603 new_img -> at_color[l].alpha = old_img -> at_color[h].alpha;
604 for (m=0; m<2*old_spec; m++)
606 n = (m < old_spec) ? m : m - old_spec;
610 p = (m < old_spec) ? 0 : 1;
611 q = m - p*old_spec - o + p*new_spec;
612 new_img -> linerad[l][q] = old_img -> linerad[h][m];
613 new_img -> bondrad[l][q] = old_img -> bondrad[h][m];
620 if (old_img -> show_atom[i] != NULL)
622 g_free (old_img -> show_atom[i]);
623 old_img -> show_atom[i] = NULL;
625 if (old_img -> show_label[i] != NULL)
627 g_free (old_img -> show_label[i]);
628 old_img -> show_label[i] = NULL;
633 g_free (old_img -> spcolor[i]);
634 old_img -> spcolor[i] = NULL;
636 g_free (old_img -> sphererad);
637 g_free (old_img -> atomicrad);
638 g_free (old_img -> pointrad);
639 g_free (old_img -> at_color);
640 g_free (old_img -> linerad);
641 g_free (old_img -> bondrad);
644 old_img -> show_atom[i] =
duplicate_bool (new_spec, new_img -> show_atom[i]);
645 old_img -> show_label[i] =
duplicate_bool (new_spec, new_img -> show_label[i]);
650 old_img -> at_color =
duplicate_color (2*new_spec, new_img -> at_color);
651 old_img -> linerad = g_malloc (2*new_spec*
sizeof*old_img -> linerad);
652 old_img -> bondrad = g_malloc (2*new_spec*
sizeof*old_img -> bondrad);
653 for (i=0; i<2*new_spec; i++)
655 old_img -> linerad[i] =
duplicate_double (2*new_spec, new_img -> linerad[i]);
656 old_img -> bondrad[i] =
duplicate_double (2*new_spec, new_img -> bondrad[i]);
660 old_img -> spcolor[i] = NULL;
663 old_img -> spcolor[i] = g_malloc (new_spec*
sizeof*old_img -> spcolor[i]);
667 old_img -> spcolor[i] = g_malloc (1*
sizeof*old_img -> spcolor[i]);
668 old_img -> spcolor[i][0] = NULL;
684 for (i=1; i<
OGL_COORDS; i++) this_proj -> modelgl -> ogl_coord[i] = NULL;
685 for (i=0; i<
OGL_RINGS; i++) this_proj -> modelgl -> ogl_rings[i] = NULL;
686 this_proj -> modelgl -> ogl_chains[0] = NULL;
692 new_coord_menus (this_proj, this_proj -> modelgl -> atom_win -> coord, new_spec, nmols, showcoord, showpoly, showfrag, update_it, (add || rem) ? FALSE : (! nmols) ? TRUE : FALSE);