952
/***********************************************/
953
/* change the properties of all selected atoms */
954
/***********************************************/
955
/* NB: this is a bit dangerous as you change everything in the */
956
/* selection to the specified value - even (eg) incompatible elements */
957
void selection_properties_change(gint type)
959
gint n, growth, region, translate;
963
struct elem_pak edata;
964
struct model_pak *model;
965
struct core_pak *core;
967
model = sysenv.active_model;
970
if (!model->selection)
976
text = gtk_entry_get_text(GTK_ENTRY(apd_label));
977
n = elem_symbol_test(text);
980
get_elem_data(n, &edata, model);
981
/* make sure we alow enough space for the string and the \0 */
982
n = (LABEL_SIZE-1 > strlen(text)) ? strlen(text) : LABEL_SIZE-1;
983
for (list=model->selection ; list ; list=g_slist_next(list))
986
g_free(core->atom_label);
987
core->atom_label = g_strdup(text);
988
/* update atttached shell */
991
struct shel_pak *shell = core->shell;
992
g_free(shell->shell_label);
993
shell->shell_label = g_strdup(text);
995
/* NEW - don't update element specific data if the element type was not */
996
/* changed - ie the user has just made a labelling change (eg C -> C1) */
997
if (edata.number != core->atom_code)
999
core->atom_code = edata.number;
1000
core->bond_cutoff = edata.cova;
1002
init_atom_colour(core, model);
1003
init_atom_charge(core, model);
1006
g_slist_free(model->unique_atom_list);
1007
model->unique_atom_list = find_unique(ELEMENT, model);
1013
charge = str_to_float(gtk_entry_get_text(GTK_ENTRY(apd_charge)));
1014
for (list=model->selection ; list ; list=g_slist_next(list))
1018
core->charge = charge;
1019
core->lookup_charge = FALSE;
1024
case CORE_GROWTH_SLICE:
1025
growth = str_to_float(gtk_entry_get_text(GTK_ENTRY(apd_growth)));
1026
growth = CLAMP(growth, 0, 1);
1027
for (list=model->selection ; list ; list=g_slist_next(list))
1030
core->growth = growth;
1031
if (model->colour_scheme == GROWTH_SLICE)
1032
atom_colour_scheme(GROWTH_SLICE, core, model);
1037
region = str_to_float(gtk_entry_get_text(GTK_ENTRY(apd_region)));
1038
if (region > model->region_max)
1039
model->region_max = region;
1041
for (list=model->selection ; list ; list=g_slist_next(list))
1044
core->region = region;
1046
(core->shell)->region = region;
1048
if (model->colour_scheme == REGION)
1049
atom_colour_scheme(REGION, core, model);
1053
case CORE_TRANSLATE:
1054
translate = str_to_float(gtk_entry_get_text(GTK_ENTRY(apd_translate)));
1055
translate = CLAMP(translate, 0, 1);
1056
for (list=model->selection ; list ; list=g_slist_next(list))
1059
core->translate = translate;
1061
(core->shell)->translate = translate;
1063
if (model->colour_scheme == TRANSLATE)
1064
atom_colour_scheme(TRANSLATE, core, model);
1069
text = gtk_entry_get_text(GTK_ENTRY(apd_type));
1070
for (list=model->selection ; list ; list=g_slist_next(list))
1073
if (core->atom_type)
1074
g_free(core->atom_type);
1075
core->atom_type = g_strdup(text);
1080
gui_refresh(GUI_MODEL_PROPERTIES);
1081
gui_refresh(GUI_CANVAS);
1084
/*****************************/
1085
/* commit changes to an atom */
1086
/*****************************/
1087
void atom_properties_change(GtkWidget *w, gint type)
1089
gint n, growth, region, translate;
1091
struct elem_pak edata;
1092
struct model_pak *model;
1094
model = sysenv.active_model;
1098
/* act on multiple atoms? */
1099
if (g_slist_length(model->selection) > 1)
1101
selection_properties_change(type);
1111
text = gtk_entry_get_text(GTK_ENTRY(apd_label));
1112
g_free(apd_core->atom_label);
1113
apd_core->atom_label = g_strdup(text);
1114
n = elem_symbol_test(text);
1116
/* update atttached shell */
1117
if (apd_core->shell)
1119
struct shel_pak *shell = apd_core->shell;
1120
g_free(shell->shell_label);
1121
shell->shell_label = g_strdup(text);
1124
/* if recognized -> update */
1127
get_elem_data(n, &edata, model);
1129
/* NEW - don't update element specific data if the element type was not */
1130
/* changed - ie the user has just made a labelling change (eg C -> C1) */
1131
if (n != apd_core->atom_code)
1133
apd_core->atom_code = n;
1134
apd_core->bond_cutoff = edata.cova;
1136
init_atom_colour(apd_core, model);
1137
init_atom_charge(apd_core, model);
1139
g_slist_free(model->unique_atom_list);
1140
model->unique_atom_list = find_unique(ELEMENT, model);
1144
gui_refresh(GUI_MODEL_PROPERTIES);
1149
text = gtk_entry_get_text(GTK_ENTRY(apd_type));
1150
if (apd_core->atom_type)
1151
g_free(apd_core->atom_type);
1152
apd_core->atom_type = g_strdup(text);
1156
text = gtk_entry_get_text(GTK_ENTRY(apd_charge));
1157
apd_core->charge = str_to_float(text);
1158
apd_core->lookup_charge = FALSE;
1163
text = gtk_entry_get_text(GTK_ENTRY(apd_x));
1164
apd_core->x[0] = str_to_float(text);
1165
coords_compute(model);
1169
text = gtk_entry_get_text(GTK_ENTRY(apd_y));
1170
apd_core->x[1] = str_to_float(text);
1171
coords_compute(model);
1175
text = gtk_entry_get_text(GTK_ENTRY(apd_z));
1176
apd_core->x[2] = str_to_float(text);
1177
coords_compute(model);
1180
case CORE_GROWTH_SLICE:
1181
text = gtk_entry_get_text(GTK_ENTRY(apd_growth));
1182
growth = CLAMP(str_to_float(text), 0, 1);
1183
apd_core->growth = growth;
1184
if (model->colour_scheme == GROWTH_SLICE)
1185
atom_colour_scheme(GROWTH_SLICE, apd_core, model);
1189
text = gtk_entry_get_text(GTK_ENTRY(apd_region));
1190
region = str_to_float(text);
1191
if (region > model->region_max)
1192
model->region_max = region;
1193
apd_core->region = region;
1194
if (apd_core->shell)
1195
(apd_core->shell)->region = region;
1196
if (model->colour_scheme == REGION)
1197
atom_colour_scheme(REGION, apd_core, model);
1200
case CORE_TRANSLATE:
1201
text = gtk_entry_get_text(GTK_ENTRY(apd_translate));
1202
translate = CLAMP(str_to_float(text), 0, 1);
1203
apd_core->translate = translate;
1204
if (apd_core->shell)
1205
(apd_core->shell)->translate = translate;
1206
if (model->colour_scheme == TRANSLATE)
1207
atom_colour_scheme(TRANSLATE, apd_core, model);
1211
printf("Not yet modifiable...\n");
1213
gui_refresh(GUI_CANVAS);
1216
/*************************************/
1217
/* updates the dialog for a new atom */
1218
/*************************************/
1219
void gui_refresh_selection(void)
1222
gchar *element, *label, *type, *charge, *x, *y, *z, *growth, *region, *translate;
1223
struct core_pak *core;
1224
struct model_pak *model;
1226
model = sysenv.active_model;
1230
GSList *list = model->selection;
1231
if (g_slist_length(list) == 1)
1237
/* data available */
1238
element = g_strdup(elements[core->atom_code].symbol);
1239
label = g_strdup(core->atom_label);
1241
if (core->atom_type)
1242
type = g_strdup(core->atom_type);
1244
type = g_strdup("");
1246
q = atom_charge(core); /* Replaced by C. Fisher 2004 */
1247
charge = g_strdup_printf("%9.4f", q);
1249
x = g_strdup_printf("%9.4f", core->x[0]);
1250
y = g_strdup_printf("%9.4f", core->x[1]);
1251
z = g_strdup_printf("%9.4f", core->x[2]);
1253
growth = g_strdup_printf("%d", core->growth);
1254
region = g_strdup_printf("%d", core->region);
1255
translate = g_strdup_printf("%d", core->translate);
1261
/* otherwise defaults */
1262
element = g_strdup("");
1263
label = g_strdup("");
1264
type = g_strdup("");
1265
charge = g_strdup("");
1269
growth = g_strdup("");
1270
region = g_strdup("");
1271
translate = g_strdup("");
1274
/* prevent changes from messing up the atom_properties_change() callback */
1278
gtk_entry_set_text(GTK_ENTRY(apd_label), label);
1279
gtk_entry_set_text(GTK_ENTRY(apd_type), type);
1280
gtk_entry_set_text(GTK_ENTRY(apd_charge), charge);
1281
gtk_entry_set_text(GTK_ENTRY(apd_x), x);
1282
gtk_entry_set_text(GTK_ENTRY(apd_y), y);
1283
gtk_entry_set_text(GTK_ENTRY(apd_z), z);
1284
gtk_entry_set_text(GTK_ENTRY(apd_growth), growth);
1285
gtk_entry_set_text(GTK_ENTRY(apd_region), region);
1286
gtk_entry_set_text(GTK_ENTRY(apd_translate), translate);
1303
/*******************************************/
1304
/* display the properties of a single atom */
1305
/*******************************************/
1306
void gui_edit_widget(GtkWidget *box)
1308
GtkWidget *frame, *hbox, *vbox, *entry;
1311
g_return_if_fail(box != NULL);
1313
/* two column element data display */
1314
hbox = gtk_hbox_new(FALSE, 0);
1315
gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0);
1317
/* left vbox - titles */
1318
vbox = gtk_vbox_new(TRUE, 0);
1319
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
1321
/* TODO - put in a for loop? */
1323
entry = gtk_entry_new();
1324
gtk_entry_set_text(GTK_ENTRY(entry), "Label");
1325
gtk_entry_set_editable(GTK_ENTRY(entry), FALSE);
1326
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
1328
entry = gtk_entry_new();
1329
gtk_entry_set_text(GTK_ENTRY(entry), "FF Type");
1330
gtk_entry_set_editable(GTK_ENTRY(entry), FALSE);
1331
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
1333
entry = gtk_entry_new();
1334
gtk_entry_set_text(GTK_ENTRY(entry), "X");
1335
gtk_entry_set_editable(GTK_ENTRY(entry), FALSE);
1336
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
1338
entry = gtk_entry_new();
1339
gtk_entry_set_text(GTK_ENTRY(entry), "Y");
1340
gtk_entry_set_editable(GTK_ENTRY(entry), FALSE);
1341
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
1343
entry = gtk_entry_new();
1344
gtk_entry_set_text(GTK_ENTRY(entry), "Z");
1345
gtk_entry_set_editable(GTK_ENTRY(entry), FALSE);
1346
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
1348
entry = gtk_entry_new();
1349
gtk_entry_set_text(GTK_ENTRY(entry), "Charge");
1350
gtk_entry_set_editable(GTK_ENTRY(entry), FALSE);
1351
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
1353
entry = gtk_entry_new();
1354
gtk_entry_set_text(GTK_ENTRY(entry), "Growth");
1355
gtk_entry_set_editable(GTK_ENTRY(entry), FALSE);
1356
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
1358
entry = gtk_entry_new();
1359
gtk_entry_set_text(GTK_ENTRY(entry), "Region");
1360
gtk_entry_set_editable(GTK_ENTRY(entry), FALSE);
1361
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
1363
entry = gtk_entry_new();
1364
gtk_entry_set_text(GTK_ENTRY(entry), "Translate");
1365
gtk_entry_set_editable(GTK_ENTRY(entry), FALSE);
1366
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
1368
/* right vbox - data */
1369
vbox = gtk_vbox_new(TRUE, 0);
1370
gtk_box_pack_end(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
1372
apd_label = gtk_entry_new();
1373
gtk_box_pack_start(GTK_BOX(vbox), apd_label, FALSE, FALSE, 0);
1375
apd_type = gtk_entry_new();
1376
gtk_box_pack_start(GTK_BOX(vbox), apd_type, FALSE, FALSE, 0);
1378
apd_x = gtk_entry_new();
1379
gtk_box_pack_start(GTK_BOX(vbox), apd_x, FALSE, FALSE, 0);
1381
apd_y = gtk_entry_new();
1382
gtk_box_pack_start(GTK_BOX(vbox), apd_y, FALSE, FALSE, 0);
1384
apd_z = gtk_entry_new();
1385
gtk_box_pack_start(GTK_BOX(vbox), apd_z, FALSE, FALSE, 0);
1387
apd_charge = gtk_entry_new();
1388
gtk_box_pack_start(GTK_BOX(vbox), apd_charge, FALSE, FALSE, 0);
1390
apd_growth = gtk_entry_new();
1391
gtk_box_pack_start(GTK_BOX(vbox), apd_growth, FALSE, FALSE, 0);
1393
apd_region = gtk_entry_new();
1394
gtk_box_pack_start(GTK_BOX(vbox), apd_region, FALSE, FALSE, 0);
1396
apd_translate = gtk_entry_new();
1397
gtk_box_pack_start(GTK_BOX(vbox), apd_translate, FALSE, FALSE, 0);
1399
/* attach callbacks (NB: set initial data first) */
1400
g_signal_connect(GTK_OBJECT(apd_label), "activate",
1401
GTK_SIGNAL_FUNC(atom_properties_change), GINT_TO_POINTER(NAME));
1402
g_signal_connect(GTK_OBJECT(apd_type), "activate",
1403
GTK_SIGNAL_FUNC(atom_properties_change), GINT_TO_POINTER(CORE_FF));
1405
g_signal_connect(GTK_OBJECT(apd_x), "activate",
1406
GTK_SIGNAL_FUNC(atom_properties_change), GINT_TO_POINTER(COORD_X));
1407
g_signal_connect(GTK_OBJECT(apd_y), "activate",
1408
GTK_SIGNAL_FUNC(atom_properties_change), GINT_TO_POINTER(COORD_Y));
1409
g_signal_connect(GTK_OBJECT(apd_z), "activate",
1410
GTK_SIGNAL_FUNC(atom_properties_change), GINT_TO_POINTER(COORD_Z));
1412
g_signal_connect(GTK_OBJECT(apd_charge), "activate",
1413
GTK_SIGNAL_FUNC(atom_properties_change), GINT_TO_POINTER(CHARGE));
1415
g_signal_connect(GTK_OBJECT(apd_growth), "activate",
1416
GTK_SIGNAL_FUNC(atom_properties_change),
1417
GINT_TO_POINTER(CORE_GROWTH_SLICE));
1419
g_signal_connect(GTK_OBJECT(apd_region), "activate",
1420
GTK_SIGNAL_FUNC(atom_properties_change), GINT_TO_POINTER(CORE_REGION));
1421
g_signal_connect(GTK_OBJECT(apd_translate), "activate",
1422
GTK_SIGNAL_FUNC(atom_properties_change), GINT_TO_POINTER(CORE_TRANSLATE));
1425
frame = gtk_frame_new(NULL);
1426
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 0);
1427
gtk_container_set_border_width(GTK_CONTAINER(frame), PANEL_SPACING);
1428
vbox = gtk_vbox_new(TRUE, 1);
1429
gtk_container_add(GTK_CONTAINER(frame), vbox);
1431
gui_button_x("Add atoms", gtk_mode_switch, (gpointer) ATOM_ADD, vbox);
1432
gui_button_x("Add bonds", gtk_mode_switch, (gpointer) BOND_SINGLE, vbox);
1433
gui_button_x("Delete bonds", gtk_mode_switch, (gpointer) BOND_DELETE, vbox);
1434
gui_button_x("Normal mode", gtk_mode_switch, (gpointer) FREE, vbox);
1436
frame = gtk_frame_new(NULL);
1437
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 0);
1438
gtk_container_set_border_width(GTK_CONTAINER(frame), PANEL_SPACING);
1439
vbox = gtk_vbox_new(TRUE, 1);
1440
gtk_container_add(GTK_CONTAINER(frame), vbox);
1442
gui_button_x("Mark as ghost", select_flag_ghost, NULL, vbox);
1443
gui_button_x("Mark as normal", select_flag_normal, NULL, vbox);