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