atomes 1.3.2
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
w_library.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-2026 by CNRS and University of Strasbourg */
15
22
23/*
24* This file: 'w_library.c'
25*
26* Contains:
27*
28
29 - The functions to create the molecular library
30 - The functions to read the 'Simple chemical XML' files
31
32*
33* List of functions:
34
35 int clean_xml_data (xmlDoc * doc, xmlTextReaderPtr reader);
36 int sml_preview (const char * filetoread);
37 int get_family (gchar * str);
38 int get_sml_files ();
39 int select_from_library (gboolean visible, project * this_proj, atom_search * asearch);
40 int insert_this_project_from_lib (int id, gboolean visible, project * this_proj, atom_search * asearch);
41
42 double get_z_from_periodic_table (gchar * lab);
43
44 gchar * replace_markup (char * init, char * key, char * rep);
45 gchar * substitute_string (gchar * init, gchar * o_motif, gchar * n_motif);
46 gchar * check_xml_string (gchar * init);
47 gchar * open_sml_file (const char * filetoread, int fam);
48
49 void sort_files (int num_f);
50 void fill_molecule_tree (GtkListStore * store);
51 void fill_family_tree (GtkListStore * store);
52 void insert_preview ();
53 void prepare_preview (int active, int id, gboolean visible);
54
55 G_MODULE_EXPORT void select_library_data (GtkTreeView * tree_view, GtkTreePath * path, GtkTreeViewColumn * column, gpointer data);
56 G_MODULE_EXPORT void set_library_markup (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data);
57 G_MODULE_EXPORT void run_select_from_library (GtkDialog * lib, gint response_id, gpointer data);
58
59 GtkWidget * library_tree (GtkListStore * store, int id, gchar * name);
60
61*/
62
63#include "global.h"
64#include "bind.h"
65#include "interface.h"
66#include "project.h"
67#include "glview.h"
68#include "glwindow.h"
69#include <libxml/xmlreader.h>
70
72 {"X", i18n("Unknown"), 0, 0},
73 {"H", i18n("Hydrogen"), 1, 1.008},
74 {"He", i18n("Helium"), 2, 4.003},
75 {"Li", i18n("Lithium"), 3, 6.94},
76 {"Be", i18n("Beryllium"), 4, 9.012},
77 {"B", i18n("Boron"), 5, 10.81},
78 {"C", i18n("Carbon"), 6, 12.011},
79 {"N", i18n("Nitrogen"), 7, 14.007},
80 {"O", i18n("Oxygen"), 8, 15.999},
81 {"F", i18n("Fluorine"), 9, 18.998},
82 {"Ne", i18n("Neon"), 10, 20.18},
83 {"Na", i18n("Sodium"), 11, 22.99},
84 {"Mg", i18n("Magnesium"), 12, 24.305},
85 {"Al", i18n("Aluminium"), 13, 26.982},
86 {"Si", i18n("Silicon"), 14, 28.085},
87 {"P", i18n("Phosphorus"), 15, 30.974},
88 {"S", i18n("Sulfur"), 16, 32.06},
89 {"Cl", i18n("Chlorine"), 17, 35.45},
90 {"Ar", i18n("Argon"), 18, 39.948},
91 {"K", i18n("Potassium"), 19, 39.098},
92 {"Ca", i18n("Calcium"), 20, 40.078},
93 {"Sc", i18n("Scandium"), 21, 44.956},
94 {"Ti", i18n("Titanium"), 22, 47.867},
95 {"V", i18n("Vanadium"), 23, 50.942},
96 {"Cr", i18n("Chromium"), 24, 51.996},
97 {"Mn", i18n("Manganese"), 25, 54.938},
98 {"Fe", i18n("Iron"), 26, 55.845},
99 {"Co", i18n("Cobalt"), 27, 58.933},
100 {"Ni", i18n("Nickel"), 28, 58.693},
101 {"Cu", i18n("Copper"), 29, 63.546},
102 {"Zn", i18n("Zinc"), 30, 65.38},
103 {"Ga", i18n("Gallium"), 31, 69.723},
104 {"Ge", i18n("Germanium"), 32, 72.63},
105 {"As", i18n("Arsenic"), 33, 74.922},
106 {"Se", i18n("Selenium"), 34, 78.971},
107 {"Br", i18n("Bromine"), 35, 79.904},
108 {"Kr", i18n("Krypton"), 36, 83.798},
109 {"Rb", i18n("Rubidium"), 37, 85.468},
110 {"Sr", i18n("Strontium"), 38, 87.62},
111 {"Y", i18n("Yttrium"), 39, 88.906},
112 {"Zr", i18n("Zirconium"), 40, 91.224},
113 {"Nb", i18n("Niobium"), 41, 92.906},
114 {"Mo", i18n("Molybdenum"), 42, 95.95},
115 {"Tc", i18n("Technetium"), 43, 98},
116 {"Ru", i18n("Ruthenium"), 44, 101.07},
117 {"Rh", i18n("Rhodium"), 45, 102.906},
118 {"Pd", i18n("Palladium"), 46, 106.42},
119 {"Ag", i18n("Silver"), 47, 107.868},
120 {"Cd", i18n("Cadmium"), 48, 112.414},
121 {"In", i18n("Indium"), 49, 114.818},
122 {"Sn", i18n("Tin"), 50, 118.71},
123 {"Sb", i18n("Antimony"), 51, 121.76},
124 {"Te", i18n("Tellurium"), 52, 127.6},
125 {"I", i18n("Iodine"), 53, 126.904},
126 {"Xe", i18n("Xenon"), 54, 131.293},
127 {"Cs", i18n("Caesium"), 55, 132.905},
128 {"Ba", i18n("Barium"), 56, 137.327},
129 {"La", i18n("Lanthanum"), 57, 138.905},
130 {"Ce", i18n("Cerium"), 58, 140.116},
131 {"Pr", i18n("Praseodymium"), 59, 140.908},
132 {"Nd", i18n("Neodymium"), 60, 144.242},
133 {"Pm", i18n("Promethium"), 61, 145},
134 {"Sm", i18n("Samarium"), 62, 150.36},
135 {"Eu", i18n("Europium"), 63, 151.964},
136 {"Gd", i18n("Gadolinium"), 64, 157.25},
137 {"Tb", i18n("Terbium"), 65, 158.925},
138 {"Dy", i18n("Dysprosium"), 66, 162.5},
139 {"Ho", i18n("Holmium"), 67, 164.93},
140 {"Er", i18n("Erbium"), 68, 167.259},
141 {"Tm", i18n("Thulium"), 69, 168.934},
142 {"Yb", i18n("Ytterbium"), 70, 173.045},
143 {"Lu", i18n("Lutetium"), 71, 174.967},
144 {"Hf", i18n("Hafnium"), 72, 178.49},
145 {"Ta", i18n("Tantalum"), 73, 180.948},
146 {"W", i18n("Tungsten"), 74, 183.84},
147 {"Re", i18n("Rhenium"), 75, 186.207},
148 {"Os", i18n("Osmium"), 76, 190.23},
149 {"Ir", i18n("Iridium"), 77, 192.217},
150 {"Pt", i18n("Platinum"), 78, 195.084},
151 {"Au", i18n("Gold"), 79, 196.967},
152 {"Hg", i18n("Mercury"), 80, 200.592},
153 {"Tl", i18n("Thallium"), 81, 204.38},
154 {"Pb", i18n("Lead"), 82, 207.2},
155 {"Bi", i18n("Bismuth"), 83, 208.98},
156 {"Po", i18n("Polonium"), 84, 209},
157 {"At", i18n("Astatine"), 85, 210},
158 {"Rn", i18n("Radon"), 86, 222},
159 {"Fr", i18n("Francium"), 87, 223},
160 {"Ra", i18n("Radium"), 88, 226},
161 {"Ac", i18n("Actinium"), 89, 227},
162 {"Th", i18n("Thorium"), 90, 232.038},
163 {"Pa", i18n("Protactinium"), 91, 231.036},
164 {"U", i18n("Uranium"), 92, 238.029},
165 {"Np", i18n("Neptunium"), 93, 237},
166 {"Pu", i18n("Plutonium"), 94, 244},
167 {"Am", i18n("Americium"), 95, 243},
168 {"Cm", i18n("Curium"), 96, 247},
169 {"Bk", i18n("Berkelium"), 97, 247},
170 {"Cf", i18n("Californium"), 98, 251},
171 {"Es", i18n("Einsteinium"), 99, 252},
172 {"Fm", i18n("Fermium"), 100, 257},
173 {"Md", i18n("Mendelevium"), 101, 258},
174 {"No", i18n("Nobelium"), 102, 258},
175 {"Lr", i18n("Lawrencium"), 103, 262},
176 {"Rf", i18n("Rutherfordium"), 104, 267},
177 {"Db", i18n("Dubnium"), 105, 268},
178 {"Sg", i18n("Seaborgium"), 106, 269},
179 {"Bh", i18n("Bohrium"), 107, 270},
180 {"Hs", i18n("Hassium"), 108, 277},
181 {"Mt", i18n("Meitnerium"), 109, 278},
182 {"Ds", i18n("Darmstadtium"), 110, 281},
183 {"Rg", i18n("Roentgenium"), 111, 282},
184 {"Cn", i18n("Copernicium"), 112, 285},
185 {"Nh", i18n("Nihonium"), 113, 286},
186 {"Fl", i18n("Flerovium"), 114, 289},
187 {"Mc", i18n("Moscovium"), 115, 289},
188 {"Lv", i18n("Livermorium"), 116, 293},
189 {"Ts", i18n("Tennessine"), 117, 294},
190 {"Og", i18n("Oganesson"), 118, 294},
191 {"D", i18n("Deuterium"), 1, 2.014000}};
192
194 { i18n("Atom"), NULL, -1, 0 },
195 { NULL, "H", 1, 1 },
196 { NULL, "B", 5, 1 },
197 { NULL, "C", 6, 1 },
198 { NULL, "N", 7, 1 },
199 { NULL, "O", 8, 1 },
200 { NULL, "F", 9, 1 },
201 { NULL, "S", 16, 1 },
202 { NULL, "Cl", 17, 1 },
203 { NULL, i18n("Other ..."), -1, 1 },
204 { i18n("Library"), NULL, -1, 0 },
205 { NULL, "H<sub>2</sub>O", -1, 3 },
206 { NULL, "CH<sub>4</sub>", -1, 5 },
207 { NULL, i18n("Toluene"), -1, 15 },
208 { NULL, "Cp", -1, 10 },
209 { NULL, "C<sub>60</sub>", -1, 60},
210 { NULL, i18n("Ni-Phthalocyanine"), -1, 57 },
211 { NULL, i18n("More ..."), -1, -1 },
212 { NULL, NULL, -1, 0 }};
213
214#define FAMILY 27
215gchar * family_list[FAMILY]={i18n("Misc"),
216 i18n("Alcohols"),
217 i18n("Aldehydes"),
218 i18n("Alkanes"),
219 i18n("Alkenes"),
220 i18n("Alkynes"),
221 i18n("Amides"),
222 i18n("Amines"),
223 i18n("Amino acids"),
224 i18n("Aromatics"),
225 i18n("Carboxylic acids"),
226 i18n("Cyclic alkanes"),
227 i18n("Cyclic alkenes"),
228 i18n("Ethers"),
229 i18n("Fatty acids"),
230 i18n("Fullerenes"),
231 i18n("Heterocycles"),
232 i18n("Macrocycles"),
233 i18n("Ketones"),
234 i18n("Nitriles"),
235 i18n("Nucleobases"),
236 i18n("Nucleotides"),
237 i18n("Steroids"),
238 i18n("Sugars (Linears)"),
239 i18n("Sugars (Cyclics)"),
240 i18n("Sulfoxides"),
241 i18n("Thiols")};
242
243gchar * family_dir[FAMILY]={"Misc",
244 "Alcohols",
245 "Aldehydes",
246 "Alkanes",
247 "Alkenes",
248 "Alkynes",
249 "Amides",
250 "Amines",
251 "Amino_acids",
252 "Aromatics",
253 "Carboxylic_acids",
254 "Cyclic_alkanes",
255 "Cyclic_alkenes",
256 "Ethers",
257 "Fatty_acids",
258 "Fullerenes",
259 "Heterocycles",
260 "Macrocycles",
261 "Ketones",
262 "Nitriles",
263 "Nucleobases",
264 "Nucleotides",
265 "Steroids",
266 "Linear_sugars",
267 "Cyclic_sugars",
268 "Sulfoxides",
269 "Thiols"};
270
271#ifdef GTK3
272#ifndef G_OS_WIN32
273extern void gtk_window_change_gdk_visual (GtkWidget * win);
274#endif // G_OS_WIN32
275#endif // GTK3
276
277extern gboolean create_3d_model (int p, gboolean load);
278extern G_MODULE_EXPORT void on_realize (GtkGLArea * area, gpointer data);
279extern xmlNodePtr findnode (xmlNodePtr startnode, char * nname);
280extern int action_atoms_from_project (project * this_proj, atom_search * asearch, gboolean visible);
281extern void to_insert_in_project (int stat, int orig, project * this_proj, atom_search * asearch, gboolean visible);
282extern void create_object_from_library (int p);
284GtkListStore * family_store;
286GtkListStore * molecule_store;
287GtkTreeIter first_mol_iter;
288GtkTreeSelection * libselect[2];
292gchar ** mol_name;
293GtkWidget * lib_preview_box = NULL;
294GtkWidget * lib_preview_plot = NULL;
296gchar * other_name[5];
297gchar * lib_info = NULL;
300
309{
310 int i;
311 for (i=0; i<120; i++)
312 {
313 if (g_strcmp0 (periodic_table_info[i].lab, lab) == 0) return periodic_table_info[i].Z;
314 }
315 return 0.0;
316}
317
326int clean_xml_data (xmlDoc * doc, xmlTextReaderPtr reader)
327{
328 xmlFreeDoc(doc);
329 xmlFreeTextReader(reader);
330 xmlCleanupParser();
331 return 0;
332}
333
343gchar * replace_markup (char * init, char * key, char * rep)
344{
345 gchar * buffer = NULL;
346 char * p = NULL;
347 int inilen = strlen(init);
348 int oldlen = strlen(key);
349 int newlen = (rep) ? strlen(rep) : 0;
350
351 // Is key in init
352 p = strstr(init, key);
353 if (! p) return g_strdup(init);
354
355 buffer = g_malloc0 ((inilen+newlen-oldlen+1)*sizeof*buffer);
356 buffer[0] = '\0';
357
358 // Copy what is before the pattern
359 strncat(buffer, init, p - init);
360
361 // Replace
362 if (rep) strcat(buffer, rep);
363
364 // Add the rest of the key
365 strcat(buffer, p+oldlen);
366 return buffer;
367}
368
378gchar * substitute_string (gchar * init, gchar * o_motif, gchar * n_motif)
379{
380 gchar * str_a, * str_b;
381 str_a = replace_markup (init, o_motif, n_motif);
382 str_b = g_strdup_printf ("%s", init);
383 while (g_strcmp0 (str_a, str_b))
384 {
385 g_free (str_b);
386 str_b = g_strdup_printf ("%s", str_a);
387 g_free (str_a);
388 str_a = replace_markup (str_b, o_motif, n_motif);
389 }
390 g_free (str_b);
391 return str_a;
392}
393
401gchar * check_xml_string (gchar * init)
402{
403 gchar * str = g_strdup_printf ("%s", substitute_string (init, "--i--", "<i>"));
404 str = g_strdup_printf ("%s", substitute_string (str, "--I--", "</i>"));
405 str = g_strdup_printf ("%s", substitute_string (str, "--b--", "<sup>"));
406 str = g_strdup_printf ("%s", substitute_string (str, "--e--", "</sup>"));
407 str = g_strdup_printf ("%s", substitute_string (str, "--c--", "<sub>"));
408 str = g_strdup_printf ("%s", substitute_string (str, "--f--", "</sub>"));
409
410 return str;
411}
412
420int sml_preview (const char * filetoread)
421{
422 int i, j, k;
423 xmlDoc * doc;
424 xmlTextReaderPtr reader;
425 xmlNodePtr racine, name_node, info_node, chem_node;
426 xmlNodePtr n_node, at_node, sp_node, coord_node;
427 xmlNodePtr spec_node, lab_node, lot_node, pbc_node;
428 xmlAttrPtr xspec;
429 xmlChar * content;
430
431 if (lib_proj != NULL) close_project (lib_proj);
432 init_project (TRUE);
434
435 reader = xmlReaderForFile(filetoread, NULL, 0);
436 doc = xmlParseFile(filetoread);
437 racine = xmlDocGetRootElement(doc);
438
439 name_node = findnode (racine -> children, "names");
440 if (name_node == NULL) return clean_xml_data (doc, reader);
441 n_node = findnode (name_node -> children, "library-name");
442 if (n_node == NULL) return clean_xml_data (doc, reader);
443 content = xmlNodeGetContent(n_node);
444 lib_proj -> name = g_strdup_printf ("%s", content);
445 xmlFree (content);
446 lib_proj -> name = check_xml_string (lib_proj -> name);
447 n_node = findnode (name_node -> children, "iupac-name");
448 if (n_node == NULL) return clean_xml_data (doc, reader);
449 o_names = 0;
450 content = xmlNodeGetContent(n_node);
451 other_name[0] = g_strdup_printf ("%s", content);
452 xmlFree (content);
453 o_names ++;
454 n_node = findnode (name_node -> children, "other-names");
455 if (n_node)
456 {
457 n_node = n_node -> children;
458 for (name_node = n_node; name_node && o_names < 5; name_node = name_node->next)
459 {
460 if (name_node -> type == XML_ELEMENT_NODE)
461 {
462 content = xmlNodeGetContent(name_node);
463 other_name[o_names] = g_strdup_printf ("%s", content);
464 xmlFree (content);
465 o_names ++;
466 }
467 }
468 }
469 info_node = findnode(racine -> children, "information");
470 if (info_node)
471 {
472 content = xmlNodeGetContent(info_node);
473 lib_info = g_strdup_printf ("%s", content);
474 xmlFree (content);
475 }
476 else
477 {
478 if (lib_info) g_free (lib_info);
479 lib_info = NULL;
480 }
481 chem_node = findnode(racine -> children, "chemistry");
482 if (chem_node == NULL) return clean_xml_data (doc, reader);
483 at_node = findnode (chem_node -> children, "atoms");
484 if (at_node == NULL) return clean_xml_data (doc, reader);
485 content = xmlNodeGetContent(at_node);
486 lib_proj -> natomes = (int)string_to_double ((gpointer)content);
487 xmlFree (content);
488
489 sp_node = findnode (chem_node -> children, "species");
490 if (sp_node == NULL) return clean_xml_data (doc, reader);
491 spec_node = sp_node -> properties -> children;
492 if (spec_node == NULL) return clean_xml_data (doc, reader);
493 content = xmlNodeGetContent(spec_node);
494 lib_proj -> nspec = (int)string_to_double ((gpointer)content);
495 xmlFree (content);
496 if (lib_proj -> natomes < 1 || lib_proj -> nspec < 1) return clean_xml_data (doc, reader);
498 lab_node = sp_node -> children;
499 if (lab_node == NULL) return clean_xml_data (doc, reader);
500 j = 0;
501 for (i=0; i<lib_proj -> nspec; i++)
502 {
503 lab_node = findnode (lab_node, "label");
504 if (lab_node == NULL) return clean_xml_data (doc, reader);
505 content = xmlNodeGetContent(lab_node);
506 lib_proj -> chemistry -> label[i] = g_strdup_printf ("%s", content);
507 xmlFree (content);
508 xspec = lab_node -> properties;
509 if (xspec == NULL) return clean_xml_data (doc, reader);
510 while (xspec)
511 {
512 lot_node = xspec -> children;
513 if (lot_node == NULL) return clean_xml_data (doc, reader);
514 if (g_strcmp0 ("num",(char *)xspec -> name) == 0)
515 {
516 content = xmlNodeGetContent(lot_node);
517 lib_proj -> chemistry -> nsps[i] = (int)string_to_double ((gpointer)content);
518 xmlFree (content);
519 lib_proj -> chemistry -> chem_prop[CHEM_Z][i] = get_z_from_periodic_table (lib_proj -> chemistry -> label[i]);
520 k = (int)lib_proj -> chemistry -> chem_prop[CHEM_Z][i];
521 lib_proj -> chemistry -> chem_prop[CHEM_M][i] = periodic_table_info[k].M;
522 lib_proj -> chemistry -> chem_prop[CHEM_R][i] = set_radius_ (& k, & j);
523 }
524 xspec = xspec -> next;
525 }
526 lab_node = lab_node -> next;
527 }
529 initcutoffs (active_chem, lib_proj -> nspec);
530 at_node = findnode (racine -> children, "coordinates");
531 if (at_node == NULL) return clean_xml_data (doc, reader);
532 coord_node = at_node -> children;
533 if (coord_node == NULL) return clean_xml_data (doc, reader);
534 for (i=0; i<lib_proj -> natomes; i++)
535 {
536 coord_node = findnode (coord_node, "atom");
537 if (coord_node == NULL) return clean_xml_data (doc, reader);
538 xspec = coord_node -> properties;
539 if (xspec == NULL) return clean_xml_data (doc, reader);
540 while (xspec)
541 {
542 lot_node = xspec -> children;
543 if (lot_node == NULL) return clean_xml_data (doc, reader);
544 content = xmlNodeGetContent(lot_node);
545 if (g_strcmp0 ("x",(char *)xspec -> name) == 0)
546 {
547 lib_proj -> atoms[0][i].x = string_to_double ((gpointer)content);
548 }
549 else if (g_strcmp0 ("y",(char *)xspec -> name) == 0)
550 {
551 lib_proj -> atoms[0][i].y = string_to_double ((gpointer)content);
552 }
553 else if (g_strcmp0 ("z",(char *)xspec -> name) == 0)
554 {
555 lib_proj -> atoms[0][i].z = string_to_double ((gpointer)content);
556 }
557 else if (g_strcmp0 ("sp",(char *)xspec -> name) == 0)
558 {
559 lib_proj -> atoms[0][i].sp = (int)string_to_double ((gpointer)content);
560 lib_proj -> atoms[0][i].show[0] = TRUE;
561 }
562 xmlFree (content);
563 xspec = xspec -> next;
564 }
565 coord_node = coord_node -> next;
566 }
567 pbc_node = findnode (racine -> children, "lattice");
568 if (pbc_node != NULL)
569 {
570
571 }
572 xmlFreeDoc(doc);
573 xmlFreeTextReader(reader);
574 xmlCleanupParser();
575 return 1;
576}
577
586gchar * open_sml_file (const char * filetoread, int fam)
587{
588 xmlDoc * doc;
589 xmlTextReaderPtr reader;
590 const xmlChar sml[8]="scl-xml";
591 xmlChar * cdata;
592 xmlNodePtr racine, node;
593 /*
594 * build an xmlReader for that file
595 */
596 reader = xmlReaderForFile(filetoread, NULL, 0);
597 if (reader == NULL)
598 {
599 return NULL;
600 }
601 else
602 {
603 doc = xmlParseFile(filetoread);
604 if (doc == NULL) return NULL;
605 racine = xmlDocGetRootElement(doc);
606 if (g_strcmp0 ((char *)(racine -> name), (char *)sml) != 0)
607 {
608 clean_xml_data (doc, reader);
609 return NULL;
610 }
611 node = racine -> children;
612 node = findnode(node, "class");
613 cdata = xmlNodeGetContent(node);
614 if (g_strcmp0 ((gchar *)cdata, family_list[fam]) != 0)
615 {
616 xmlFree (cdata);
617 clean_xml_data (doc, reader);
618 return NULL;
619 }
620 xmlFree (cdata);
621 node = findnode (racine -> children, "names");
622 if (node == NULL)
623 {
624 clean_xml_data (doc, reader);
625 return NULL;
626 }
627 node = findnode (node -> children, "library-name");
628 if (node == NULL)
629 {
630 clean_xml_data (doc, reader);
631 return NULL;
632 }
633 cdata = xmlNodeGetContent(node);
634 xmlFreeDoc(doc);
635 xmlFreeTextReader(reader);
636 xmlCleanupParser();
637 return (gchar *)cdata;
638 }
639}
640
648int get_family (gchar * str)
649{
650 int i;
651 for (i=0; i<FAMILY; i++)
652 {
653 if (g_strcmp0 (str, _(family_list[i])) == 0) return i;
654 }
655 return -1;
656}
657
665void sort_files (int num_f)
666{
667 int i, j;
668 gchar * str = NULL;
669 for(i=0;i<num_f;i++)
670 {
671 for(j=i+1;j<num_f;j++)
672 {
673 if(g_strcmp0 (mol_name[i],mol_name[j])>0)
674 {
675 str = g_strdup_printf ("%s", mol_name[i]);
676 mol_name[i] = g_strdup_printf ("%s", mol_name[j]);
677 mol_name[j] = g_strdup_printf ("%s", str);
678 str = g_strdup_printf ("%s", sml_file_name[i]);
679 sml_file_name[i] = g_strdup_printf ("%s", sml_file_name[j]);
680 sml_file_name[j] = g_strdup_printf ("%s", str);
681 }
682 }
683 }
684 for(i=0;i<num_f;i++)
685 {
687 }
688}
689
696{
697 int val = 0;
698 gchar * str, * fsml;
699 gchar * libdir;
700#ifdef G_OS_WIN32
701 libdir = g_strdup_printf ("%s\\molecules\\%s", PACKAGE_LIB_DIR, family_dir[the_family]);
702 gchar * libwin32 = g_strdup_printf ("%s\\molecules\\%s\\*.sml", PACKAGE_LIB_DIR, family_dir[the_family]);
703 WIN32_FIND_DATA ffd;
704 HANDLE hFind = FindFirstFile (libwin32, & ffd);
705 if (hFind != INVALID_HANDLE_VALUE)
706 {
707 if (ffd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
708 {
709 str = g_strdup_printf ("%s\\%s", libdir, (char *)ffd.cFileName);
710 if (open_sml_file(str, the_family) != NULL) val ++;
711 g_free (str);
712 }
713 while (FindNextFile(hFind, &ffd) != 0)
714 {
715 if (ffd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
716 {
717 str = g_strdup_printf ("%s\\%s", libdir, (char *)ffd.cFileName);
718 if (open_sml_file(str, the_family) != NULL) val ++;
719 g_free (str);
720 }
721 }
722 FindClose(hFind);
723 }
724#else
725 libdir = g_strdup_printf ("%s/molecules/%s", PACKAGE_LIB_DIR, family_dir[the_family]);
726 DIR * d;
727 struct dirent * dir;
728 d = opendir(libdir);
729 if (d)
730 {
731 while ((dir = readdir(d)) != NULL)
732 {
733 if (dir -> d_type == DT_REG)
734 {
735 str = g_strdup_printf ("%s/%s", libdir, dir -> d_name);
736 if (open_sml_file(str, the_family) != NULL) val ++;
737 g_free (str);
738 }
739 }
740 closedir(d);
741 }
742#endif
743 if (val > 0)
744 {
745 sml_file_name = g_malloc0(val*sizeof*sml_file_name);
746 mol_name = g_malloc0(val*sizeof*mol_name);
747 val = 0;
748#ifdef G_OS_WIN32
749 hFind = FindFirstFile (libwin32, & ffd);
750 if (hFind != INVALID_HANDLE_VALUE)
751 {
752 if (ffd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
753 {
754 str = g_strdup_printf ("%s\\%s", libdir, (char *)ffd.cFileName);
755 fsml = open_sml_file(str, the_family);
756 if (fsml != NULL)
757 {
758 sml_file_name[val] = g_strdup_printf ("%s", str);
759 mol_name[val] = g_strdup_printf ("%s", fsml);
760 val ++;
761 g_free (fsml);
762 }
763 g_free (str);
764 }
765 while (FindNextFile(hFind, &ffd) != 0)
766 {
767 if (ffd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
768 {
769 str = g_strdup_printf ("%s\\%s", libdir, (char *)ffd.cFileName);
770 fsml = open_sml_file(str, the_family);
771 if (fsml != NULL)
772 {
773 sml_file_name[val] = g_strdup_printf ("%s", str);
774 mol_name[val] = g_strdup_printf ("%s", fsml);
775 val ++;
776 g_free (fsml);
777 }
778 g_free (str);
779 }
780 }
781 FindClose(hFind);
782 }
783#else
784 d = opendir (libdir);
785 if (d)
786 {
787 while ((dir = readdir(d)) != NULL)
788 {
789 if (dir -> d_type == DT_REG)
790 {
791 str = g_strdup_printf ("%s/%s", libdir, dir -> d_name);
792 fsml = open_sml_file(str, the_family);
793 if (fsml != NULL)
794 {
795 sml_file_name[val] = g_strdup_printf ("%s", str);
796 mol_name[val] = g_strdup_printf ("%s", fsml);
797 val ++;
798 g_free (fsml);
799 }
800 g_free (str);
801 }
802 }
803 closedir(d);
804 }
805#endif
806 sort_files (val);
807 }
808 return val;
809}
810
818void fill_molecule_tree (GtkListStore * store)
819{
820 GtkTreeIter mol_level;
821 int i;
822 for (i=0; i<get_sml_files (); i++)
823 {
824 if (i == 0)
825 {
826 gtk_list_store_append (store, & first_mol_iter);
827 gtk_list_store_set (store, & first_mol_iter, 0, -(i+1), 1, mol_name[i], -1);
828 }
829 else
830 {
831 gtk_list_store_append (store, & mol_level);
832 gtk_list_store_set (store, & mol_level, 0, -(i+1), 1, mol_name[i], -1);
833 }
834 }
835}
836
844void fill_family_tree (GtkListStore * store)
845{
846 GtkTreeIter family_level;
847 int i;
848 for (i=0; i<FAMILY; i++)
849 {
850 if (i == 0)
851 {
852 gtk_list_store_append (store, & first_family_iter);
853 gtk_list_store_set (store, & first_family_iter, 0, i, 1, _(family_list[i]), -1);
854 }
855 else
856 {
857 gtk_list_store_append (store, & family_level);
858 gtk_list_store_set (store, & family_level, 0, i, 1, _(family_list[i]), -1);
859 }
860 }
861}
862
869{
870 gchar * str;
871 lib_preview_plot = gtk_fixed_new ();
872 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, lib_preview_box, lib_preview_plot, FALSE, FALSE, 0);
873 GtkWidget * grid = gtk_grid_new ();
874 gtk_fixed_put (GTK_FIXED(lib_preview_plot), grid, 0, 10);
875 gtk_widget_set_size_request (grid, -1, 200);
876 gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
877 gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
878 gtk_grid_set_row_spacing (GTK_GRID (grid), 1);
879 gtk_grid_set_column_spacing (GTK_GRID (grid), 1);
880
881 gtk_grid_attach (GTK_GRID (grid), lib_proj -> modelgl -> plot, 0, 0, 4, 4);
882 gtk_grid_attach (GTK_GRID (grid), markup_label(_("<i>Formula:</i>"), 100, -1, 0.0, 0.5), 5, 1, 3, 1);
883 int i;
884 for (i=0; i<lib_proj -> nspec; i++)
885 {
886 if (i > 0)
887 {
888 str = g_strdup_printf ("%s <b>%s", str, lib_proj -> chemistry -> label[i]);
889 }
890 else
891 {
892 str = g_strdup_printf ("<b>%s", lib_proj -> chemistry -> label[i]);
893 }
894 if (lib_proj -> chemistry -> nsps[i] > 1)
895 {
896 str = g_strdup_printf ("%s<sub>%d</sub>", str, lib_proj -> chemistry -> nsps[i]);
897 }
898 str = g_strdup_printf ("%s</b>", str);
899 }
900 gtk_grid_attach (GTK_GRID (grid), markup_label(str, 100, -1, 0.0, 0.5), 8, 1, 3, 1);
901 gtk_grid_attach (GTK_GRID (grid), markup_label(_("<i>Molecular mass:</i>"), 100, -1, 0.0, 0.5), 5, 2, 3, 1);
902 g_free (str);
903 double mass = 0.0;
904 for (i=0; i<lib_proj -> nspec; i++)
905 {
906 mass += (lib_proj -> chemistry -> nsps[i]*lib_proj -> chemistry -> chem_prop[CHEM_M][i]);
907 }
908 str = g_strdup_printf ("<b>%.3f g/mol</b>", mass);
909 gtk_grid_attach (GTK_GRID (grid), markup_label(str, 100, -1, 0.0, 0.5), 8, 2, 3, 1);
910 g_free (str);
911
912 gtk_grid_attach (GTK_GRID (grid), markup_label(_("<i>IUPAC name:</i>"), 100, -1, 0.0, 0.5), 0, 5, 3, 1);
913 str = g_strdup_printf ("<b>%s</b>", check_xml_string(other_name[0]));
914 gtk_grid_attach (GTK_GRID (grid), markup_label(str, 100, 30, 0.0, 0.5), 3, 5, 11, 1);
915
916 GtkWidget * hbox, * vbox;
917 if (o_names > 1)
918 {
919 hbox = create_hbox (0);
920 gtk_fixed_put (GTK_FIXED(lib_preview_plot), hbox, 0, 230);
922 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vbox, FALSE, FALSE, 0);
923 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(_("<i>Other name(s):</i>"), 100, 30, 0.0, 0.5), FALSE, FALSE, 0);
924 for (i=1; i<o_names; i++)
925 {
926 if (i > 1)
927 {
928 str = g_strdup_printf ("%s\n<b>%s</b>", str, check_xml_string(other_name[i]));
929 }
930 else
931 {
932 str = g_strdup_printf ("<b>%s</b>", check_xml_string(other_name[i]));
933 }
934 }
936 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vbox, FALSE, FALSE, 15);
937 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, 100, 30+20*(o_names-2), 0.0, 0.5), FALSE, FALSE, 0);
938 g_free (str);
939 }
940
941 if (lib_info)
942 {
943 hbox = create_hbox (0);
944 gtk_fixed_put (GTK_FIXED(lib_preview_plot), hbox, 0, 230+15*(o_names-1));
946 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vbox, FALSE, FALSE, 0);
947 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(_("<i>Information:</i>"), 100, 30, 0.0, 0.5), FALSE, FALSE, 0);
949 str = g_strdup_printf ("<b>%s</b>", check_xml_string(lib_info));
950 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vbox, FALSE, FALSE, 15);
951 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, 100, 30, 0.0, 0.5), FALSE, FALSE, 0);
952 g_free (str);
953 }
955}
956
966void prepare_preview (int active, int id, gboolean visible)
967{
968 if (sml_file_name != NULL)
969 {
970 if (sml_preview (sml_file_name[id]))
971 {
973 lib_proj -> run = TRUE;
975 create_3d_model (lib_proj -> id, FALSE);
976 if (visible)
977 {
979 }
980 else
981 {
982 on_realize (NULL, lib_proj -> modelgl);
983 }
984 bonds_update = 0;
985 active_glwin = lib_proj -> modelgl;
986 active_glwin -> init = FALSE;
987 active_image = active_glwin -> anim -> last -> img;
988 lib_proj -> runc[0] = TRUE;
990 on_calc_bonds_released (NULL, NULL);
991 lib_proj -> modelgl -> anim -> last -> img -> quality = 30;
992 lib_proj -> modelgl -> anim -> last -> img -> rep = ORTHOGRAPHIC;
993 lib_proj -> modelgl -> anim -> last -> img -> xyz -> axis = NONE;
994 lib_proj -> modelgl -> anim -> last -> img -> abc -> box = NONE;
995 if (visible)
996 {
997 gtk_widget_set_size_request (lib_proj -> modelgl -> plot, 150, 150);
998 update (lib_proj -> modelgl);
999 }
1000 active_project_changed (active);
1001 }
1002 }
1003}
1004
1015G_MODULE_EXPORT void select_library_data (GtkTreeView * tree_view, GtkTreePath * path, GtkTreeViewColumn * column, gpointer data)
1016{
1017 GtkTreeIter row;
1018 GtkTreeModel * model = gtk_tree_view_get_model(tree_view);
1019 if (gtk_tree_model_get_iter (model, & row, path))
1020 {
1021 GValue val = {0, };
1022 GValue vbl = {0, };
1023 gtk_tree_model_get_value (model, & row, 0, & val);
1024 gtk_tree_model_get_value (model, & row, 1, & vbl);
1025 int i = (int)g_value_get_int (& val);
1026 if (i > -1)
1027 {
1028 the_family = i;
1029 gtk_list_store_clear (molecule_store);
1031 gtk_tree_selection_select_iter (libselect[1], & first_mol_iter);
1032 prepare_preview (activep, 0, TRUE);
1033 }
1034 else
1035 {
1036 the_molecule = g_strdup_printf ("%s", (char *)g_value_get_string (& vbl));
1037 prepare_preview (activep, -i-1, TRUE);
1038 }
1039 }
1040}
1041
1053G_MODULE_EXPORT void set_library_markup (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
1054{
1055 set_renderer_markup (mod, iter, renderer, 1);
1056}
1057
1067GtkWidget * library_tree (GtkListStore * store, int id, gchar * name)
1068{
1069 GtkWidget * scrol = create_scroll (NULL, 150, 300, GTK_SHADOW_ETCHED_IN);
1070 GtkTreeViewColumn * datacol;
1071 GtkCellRenderer * datacel;
1072 GtkWidget * dataview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store));
1073 datacel = gtk_cell_renderer_text_new ();
1074 datacol = gtk_tree_view_column_new_with_attributes (name, datacel, "text", 1, NULL);
1075 gtk_tree_view_column_set_cell_data_func (datacol, datacel, set_library_markup, NULL, NULL);
1076 gtk_tree_view_append_column(GTK_TREE_VIEW(dataview), datacol);
1077 gtk_tree_view_column_set_alignment (datacol, 0.5);
1078 gtk_tree_view_set_activate_on_single_click (GTK_TREE_VIEW(dataview), TRUE);
1079 g_signal_connect (G_OBJECT(dataview), "row-activated", G_CALLBACK(select_library_data), NULL);
1080 g_object_unref (store);
1081 libselect[id] = gtk_tree_view_get_selection (GTK_TREE_VIEW(dataview));
1082 gtk_tree_selection_set_mode (libselect[id], GTK_SELECTION_SINGLE);
1083 add_container_child (CONTAINER_SCR, scrol, dataview);
1084 return scrol;
1085}
1086
1087gboolean lib_res;
1089
1099G_MODULE_EXPORT void run_select_from_library (GtkDialog * lib, gint response_id, gpointer data)
1100{
1101 gboolean done = FALSE;
1102 atom_search * asearch = (atom_search *)data;
1103 project * this_proj = get_project_by_id (asearch -> proj);
1104 GtkWidget * vbox;
1105 switch (response_id)
1106 {
1107 case GTK_RESPONSE_APPLY:
1108 vbox = dialog_get_content_area ((GtkWidget *)lib);
1109 widget_set_sensitive (vbox, FALSE);
1110 if (this_proj -> modelgl) this_proj -> modelgl -> other_status = 2;
1113 if (asearch -> action == INSERT)
1114 {
1115 to_insert_in_project (FROM_LIBRARY, -1, this_proj, asearch, lib_visible);
1116 if (! lib_visible)
1117 {
1118 gboolean vis;
1119 if (this_proj -> modelgl)
1120 {
1121 vis = (this_proj -> modelgl -> atom_win) ? this_proj -> modelgl -> atom_win -> visible : FALSE;
1122 }
1123 else
1124 {
1125 vis = FALSE;
1126 }
1127 inserted_from_lib += action_atoms_from_project (this_proj, asearch, vis);
1128 }
1129 if (this_proj -> modelgl) this_proj -> modelgl -> nth_copy ++;
1130 }
1132 widget_set_sensitive (vbox, TRUE);
1133 if (asearch -> action == REPLACE) done = TRUE;
1134 break;
1135 default:
1136 if (this_proj -> modelgl)
1137 {
1138 if (this_proj -> modelgl -> mode == EDITION) asearch -> todo[0] = 0;
1139 }
1140 lib_res = 0;
1141 done = TRUE;
1142 break;
1143 }
1144 if (done) destroy_this_dialog (lib);
1145}
1146
1156int select_from_library (gboolean visible, project * this_proj, atom_search * asearch)
1157{
1158 int active = activep;
1159 int nats = this_proj -> natomes;
1160 lib_visible = visible;
1161 GtkWidget * lib = dialogmodal (_("Library"), GTK_WINDOW((this_proj -> modelgl) ? this_proj -> modelgl -> win : atomes_main_window));
1162#ifdef GTK3
1163#ifdef GTKGLAREA
1164#ifndef OSX
1165#ifndef G_OS_WIN32
1166 if (! atomes_visual) gtk_window_change_gdk_visual (lib);
1167#endif // G_OS_WIN32
1168#endif // OSX
1169#endif // GTKGLAREA
1170#endif // GTK3
1171 gtk_dialog_add_button (GTK_DIALOG(lib), (asearch -> action == REPLACE) ? _("Replace") : _("Insert"), GTK_RESPONSE_APPLY);
1172 GtkWidget * vbox = dialog_get_content_area (lib);
1173 GtkWidget * hbox = create_hbox (5);
1174 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1175 sml_file_name = mol_name = NULL;
1176 family_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
1178 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, library_tree (family_store, 0, _("Family")), FALSE, FALSE, 0);
1179 molecule_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
1180 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, library_tree (molecule_store, 1, _("Molecule")), FALSE, FALSE, 0);
1182 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lib_preview_box, FALSE, FALSE, 10);
1183 lib_preview_plot = NULL;
1184 the_family = 0;
1185 gtk_tree_selection_select_iter (libselect[0], & first_family_iter);
1186 gtk_list_store_clear (molecule_store);
1188 gtk_tree_selection_select_iter (libselect[1], & first_mol_iter);
1189 show_the_widgets (lib);
1190 prepare_preview (active, 0, TRUE);
1191 if (this_proj -> modelgl) this_proj -> modelgl -> nth_copy = 0;
1193 run_this_gtk_dialog (lib, G_CALLBACK(run_select_from_library), asearch);
1194 active_project_changed (active);
1195 if (! nats && active_project -> natomes)
1196 {
1197 int i;
1198 if (active_image -> style == SPACEFILL)
1199 {
1200 i = OGL_STYLES + active_image -> filled_type;
1202 }
1203 else
1204 {
1205 i = active_image -> style;
1207 }
1209 }
1210 if (sml_file_name != NULL) g_free (sml_file_name);
1211 if (mol_name != NULL) g_free (mol_name);
1212 if (lib_proj != NULL) close_project (lib_proj);
1213 lib_proj = NULL;
1214 lib_preview_plot = NULL;
1215 return lib_res;
1216}
1217
1228int insert_this_project_from_lib (int id, gboolean visible, project * this_proj, atom_search * asearch)
1229{
1230 sml_file_name = mol_name = NULL;
1231 int family[6] = {0, 3, 9, 9, 15, 17};
1232 int molec[6] = {0, 8, 36, 21, 11, 0};
1233 int active = activep;
1234 int nats = this_proj -> natomes;
1235 the_family = family[id];
1236 if (get_sml_files ())
1237 {
1238 prepare_preview (active, molec[id], FALSE);
1239 if (this_proj -> modelgl) this_proj -> modelgl -> other_status = 2;
1241 if (asearch -> action == INSERT)
1242 {
1243 to_insert_in_project (FROM_LIBRARY, -1, this_proj, asearch, visible);
1244 }
1245 }
1246 active_project_changed (active);
1247 if (! nats && active_project -> natomes)
1248 {
1249 int i;
1250 if (active_image -> style == SPACEFILL)
1251 {
1252 i = OGL_STYLES + active_image -> filled_type;
1254 }
1255 else
1256 {
1257 i = active_image -> style;
1259 }
1261 }
1262 if (sml_file_name != NULL) g_free (sml_file_name);
1263 if (mol_name != NULL) g_free (mol_name);
1264 if (lib_proj != NULL) close_project (lib_proj);
1265 lib_proj = NULL;
1266 return FROM_LIBRARY;
1267}
atom_search * remove_search
Definition popup.c:174
insertion_menu mol[]
Definition w_library.c:193
Binding to the Fortran90 subroutines.
double set_radius_(int *, int *)
gchar * substitute_string(gchar *init, gchar *o_motif, gchar *n_motif)
substitute all patterns in string
Definition w_library.c:378
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
void close_project(project *to_close)
close a project
Definition close_p.c:260
ColRGBA col
Definition d_measures.c:77
int atoms[NUM_STYLES][2]
GtkTreePath * path
Definition datab.c:103
GtkTreeIter row
Definition datab.c:104
float val
Definition dlp_init.c:117
dint rep
Definition dlp_edit.c:2242
gchar * filetoread
gchar * PACKAGE_LIB_DIR
Definition global.c:89
GtkWidget * atomes_main_window
Definition global.c:208
int activep
Definition global.c:162
int bonds_update
Definition global.c:173
int atomes_visual
Definition global.c:168
#define i18n(String)
Definition global.c:80
double string_to_double(gpointer string)
convert string to double
Definition global.c:612
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:533
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:2139
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:552
element_data periodic_table_info[]
Definition w_library.c:71
project * proj
chemical_data * active_chem
Definition project.c:48
#define BSEP
Definition global.h:262
void set_renderer_markup(GtkTreeModel *mod, GtkTreeIter *iter, GtkCellRenderer *renderer, int col)
set Pango text markup for a GtkCellRenderer
Definition gtk-misc.c:1764
#define NONE
Definition global.h:285
G_MODULE_EXPORT void on_calc_bonds_released(GtkWidget *widg, gpointer data)
compute bonding properties
Definition bdcall.c:559
#define CHEM_R
Definition global.h:320
@ CONTAINER_SCR
Definition global.h:268
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:861
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1672
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:340
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:247
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2235
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:849
#define CHEM_M
Definition global.h:319
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2213
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:267
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:837
#define CHEM_Z
Definition global.h:318
project * active_project
Definition project.c:47
void initcutoffs(chemical_data *chem, int species)
initialize bond cutoffs
Definition bdcall.c:245
image * active_image
Definition project.c:52
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:202
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:461
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
image * plot
Definition ogl_draw.c:72
action
Definition glview.h:197
@ EDITION
Definition glview.h:167
@ ORTHOGRAPHIC
Definition glview.h:160
@ REPLACE
Definition glview.h:234
@ INSERT
Definition glview.h:236
@ SPACEFILL
Definition glview.h:183
@ WIREFRAME
Definition glview.h:182
@ FROM_LIBRARY
Definition glwin.h:80
#define OGL_STYLES
Definition glwin.h:107
void set_this_style(glwin *view, int style)
set general style for atom(s) and bond(s)
Definition m_style.c:293
Function declarations for the creation of the OpenGL window.
void init_project(gboolean alloc_box)
initialize a new project
Definition init_p.c:273
void init_atomes_analysis(project *this_proj, gboolean apply_defaults)
initialize analysis data structures for atomes
Definition initc.c:223
Messaging function declarations.
void alloc_proj_data(project *this_proj, int cid)
allocate data
Definition open_p.c:224
int inserted_from_lib
Definition w_library.c:299
Function declarations for reading atomes project file Function declarations for saving atomes proje...
void active_project_changed(int id)
change the active project
Definition update_p.c:220
Definition glwin.h:332
Definition glwin.h:350
int action_atoms_from_project(project *this_proj, atom_search *asearch, gboolean visible)
apply atom edition action to project (motion, remove, replace, insert, random move)
GtkWidget * lib_preview_box
Definition w_library.c:293
G_MODULE_EXPORT void on_realize(GtkGLArea *area, gpointer data)
gchar * check_xml_string(gchar *init)
check for, and correct tags in XML string
Definition w_library.c:401
gchar * family_list[FAMILY]
Definition w_library.c:215
GtkListStore * family_store
Definition w_library.c:284
GtkListStore * molecule_store
Definition w_library.c:286
xmlNodePtr findnode(xmlNodePtr startnode, char *nname)
find XML node
int the_family
Definition w_library.c:289
int get_sml_files()
get the library 'Simple chemical library XML' files
Definition w_library.c:695
gchar * substitute_string(gchar *init, gchar *o_motif, gchar *n_motif)
substitute all patterns in string
Definition w_library.c:378
double get_z_from_periodic_table(gchar *lab)
get Z from atom label
Definition w_library.c:308
gchar ** mol_name
Definition w_library.c:292
void fill_molecule_tree(GtkListStore *store)
fill molecule list store
Definition w_library.c:818
#define FAMILY
Definition w_library.c:214
gchar ** sml_file_name
Definition w_library.c:291
int get_family(gchar *str)
get molecular family id
Definition w_library.c:648
gboolean lib_res
Definition w_library.c:1087
G_MODULE_EXPORT void set_library_markup(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
set font markup in the molecular library tree store
Definition w_library.c:1053
int o_names
Definition w_library.c:298
gchar * other_name[5]
Definition w_library.c:296
void sort_files(int num_f)
sort file(s) by molecular family and name
Definition w_library.c:665
int sml_preview(const char *filetoread)
retrieve preview information from 'Simple chemical library XML' file
Definition w_library.c:420
GtkTreeIter first_family_iter
Definition w_library.c:285
project * lib_proj
Definition w_library.c:295
GtkTreeIter first_mol_iter
Definition w_library.c:287
GtkTreeSelection * libselect[2]
Definition w_library.c:288
gboolean lib_visible
Definition w_library.c:1088
void fill_family_tree(GtkListStore *store)
fill molecular family list store
Definition w_library.c:844
void prepare_preview(int active, int id, gboolean visible)
prepare library molecule preview
Definition w_library.c:966
void create_object_from_library(int p)
create object using the molecular library
GtkWidget * lib_preview_plot
Definition w_library.c:294
gboolean create_3d_model(int p, gboolean load)
Definition glwindow.c:1353
int clean_xml_data(xmlDoc *doc, xmlTextReaderPtr reader)
free XML data
Definition w_library.c:326
GtkWidget * library_tree(GtkListStore *store, int id, gchar *name)
create library tree store widget
Definition w_library.c:1067
int insert_this_project_from_lib(int id, gboolean visible, project *this_proj, atom_search *asearch)
insert object from the library
Definition w_library.c:1228
gchar * replace_markup(char *init, char *key, char *rep)
replace pattern in string
Definition w_library.c:343
void to_insert_in_project(int stat, int orig, project *this_proj, atom_search *asearch, gboolean visible)
to insert object in project
void insert_preview()
insert preview in library window and visualize
Definition w_library.c:868
G_MODULE_EXPORT void run_select_from_library(GtkDialog *lib, gint response_id, gpointer data)
select from library - running the dialog
Definition w_library.c:1099
gchar * family_dir[FAMILY]
Definition w_library.c:243
gchar * open_sml_file(const char *filetoread, int fam)
open 'Simple chemical library XML' file
Definition w_library.c:586
G_MODULE_EXPORT void select_library_data(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data)
select library element callback
Definition w_library.c:1015
int select_from_library(gboolean visible, project *this_proj, atom_search *asearch)
select object to insert from the library
Definition w_library.c:1156
gchar * lib_info
Definition w_library.c:297
gchar * the_molecule
Definition w_library.c:290
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72
GtkWidget * lab
Definition workspace.c:73