1 /* Molpro.c */
2 /**********************************************************************************************************
3 Copyright (c) 2002-2013 Abdul-Rahman Allouche. All rights reserved
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 documentation files (the Gabedit), to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
8 and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
10 The above copyright notice and this permission notice shall be included in all copies or substantial portions
11 of the Software.
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
14 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
16 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 DEALINGS IN THE SOFTWARE.
18 ************************************************************************************************************/
19
20
21 #include "../../Config.h"
22 #include "../Common/Global.h"
23 #include "../Utils/UtilsInterface.h"
24 #include "../Utils/Constants.h"
25 #include "MInterfaceGeom.h"
26 #include "MInterfaceGene.h"
27 #include "MInterfaceBasis.h"
28 #include "MInterfaceComm.h"
29 #include "../Geometry/GeomGlobal.h"
30 #include "../Geometry/InterfaceGeom.h"
31 #include "../Utils/Utils.h"
32 #include "../Utils/AtomsProp.h"
33 #include "../Utils/GabeditTextEdit.h"
34 #include "../../pixmaps/Next.xpm"
35
36 static GtkWidget *hboxb;
37 static int iinsert;
38
39
40 GtkWidget *NoteBook;
41 static GtkWidget *Wins=NULL;
42 GeneS *gen;
43 gint iset;
44
45 GeomS *geom;
46 BaseS *base;
47 CommS *comm;
48
49 /************************************************************************************************************/
DestroyWinsMolpro(GtkWidget * win)50 void DestroyWinsMolpro(GtkWidget *win)
51 {
52 destroy(Wins,NULL);
53 Wins = NULL;
54 }
55 /************************************************************************************************************/
GetInfoTitle()56 static void GetInfoTitle()
57 {
58 gchar chaine[BSIZE];
59 G_CONST_RETURN gchar *chaine1;
60 chaine1 = gtk_entry_get_text(GTK_ENTRY(gen->title));
61 sprintf(chaine,"***,%s;",chaine1);
62 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
63 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
64 }
65 /************************************************************************************************************/
GetInfoMemory()66 static void GetInfoMemory()
67 {
68 gchar chaine[BSIZE];
69 G_CONST_RETURN gchar *chaine1;
70 chaine1=gtk_entry_get_text(GTK_ENTRY(gen->memory));
71 sprintf(chaine,"Memory,%s;",chaine1);
72 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
73 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
74 }
75 /************************************************************************************************************/
insert_gth_option(gchar * type,gchar * def,const gchar * value,gchar * Commentaire)76 static void insert_gth_option(gchar *type,gchar *def, const gchar *value,gchar *Commentaire)
77 {
78 gchar *chaine;
79 chaine=g_strdup_printf("Gthresh,%s=%s; !%s\n",type,value,Commentaire);
80 if(strcmp(def,value))
81 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,chaine,-1);
82 g_free(chaine);
83 }
84 /************************************************************************************************************/
GetInfoGth()85 static void GetInfoGth()
86 {
87 guint i;
88 gchar *NameOp[14]={
89 "zero", "oneint", "twoint","preface","locali",
90 "eorder","energy","gradiant","step","orbital",
91 "civec","coeff","printci","punchci"
92 };
93 gchar *DefOp[14]={
94 "1.d-12", "1.d-12", "1.d-12","1.d-14","1.d-8",
95 "1.d-4","1.d-6","1.d-2","1.d-3","1.d-5",
96 "1.d-5","1.d-4","0.05","99"
97 };
98 gchar *CommOp[14]={
99 _("Numerical zero"),
100 _("Threshold for one-electron integrals"),
101 _("Threshold for the neglect of two-electron integrals"),
102 _("Threshold for test of prefactor in TWOINT"),
103 _("Threshold for orbital localization"),
104 _("Threshold for reordering of orbital after localization"),
105 _("Convergence threshold for energy"),
106 _("Convergence threshold for orbital gradient in MCSCF"),
107 _("Convergence threshold for step length in MCSCF orbital optimization"),
108 _("Convergence threshold for orbital optimization in the SCF program"),
109 _("Convergence threshold for CI coefficients in MCSCF and reference vector in CI"),
110 _("Convergence threshold for coefficients in CI and CCSD"),
111 _("Threshold for printing CI coefficients"),
112 _("Threshold for punching CI coefficients")
113 };
114 G_CONST_RETURN gchar *chaine[14];
115
116 chaine[0]=gtk_entry_get_text(GTK_ENTRY(gen->gth_zero));
117 chaine[1]=gtk_entry_get_text(GTK_ENTRY(gen->gth_oneint));
118 chaine[2]=gtk_entry_get_text(GTK_ENTRY(gen->gth_twoint));
119 chaine[3]=gtk_entry_get_text(GTK_ENTRY(gen->gth_prefac));
120 chaine[4]=gtk_entry_get_text(GTK_ENTRY(gen->gth_locali));
121 chaine[5]=gtk_entry_get_text(GTK_ENTRY(gen->gth_eorder));
122 chaine[6]=gtk_entry_get_text(GTK_ENTRY(gen->gth_energy));
123 chaine[7]=gtk_entry_get_text(GTK_ENTRY(gen->gth_gradiant));
124 chaine[8]=gtk_entry_get_text(GTK_ENTRY(gen->gth_step));
125 chaine[9]=gtk_entry_get_text(GTK_ENTRY(gen->gth_orbital));
126 chaine[10]=gtk_entry_get_text(GTK_ENTRY(gen->gth_civec));
127 chaine[11]=gtk_entry_get_text(GTK_ENTRY(gen->gth_coeff));
128 chaine[12]=gtk_entry_get_text(GTK_ENTRY(gen->gth_printci));
129 chaine[13]=gtk_entry_get_text(GTK_ENTRY(gen->gth_punchci));
130
131 for(i=0;i<14;i++)
132 insert_gth_option(NameOp[i],DefOp[i],chaine[i],CommOp[i]);
133
134 }
135 /************************************************************************************************************/
TestButtonActive(GtkWidget * button)136 static int TestButtonActive(GtkWidget *button)
137 {
138 if (GTK_TOGGLE_BUTTON (button)->active)
139 return 1;
140 else return 0;
141 }
142 /************************************************************************************************************/
insert_gprint_option(gchar * Type,gchar * Commentaire)143 static void insert_gprint_option(gchar *Type,gchar *Commentaire)
144 {
145 gchar *chaine;
146 chaine=g_strdup_printf("Gprint,%s; ! %s\n",Type,Commentaire);
147 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,chaine,-1);
148 }
149 /************************************************************************************************************/
GetInfoGprint()150 static void GetInfoGprint()
151 {
152 gchar *tGP[14]={
153 _("Print basis information "),
154 _("Print CI vector in MCSCF"),
155 _("Print reference CSFs and their coefficients in CI "),
156 _("Print detailed I/O information "),
157 _("Print orbitals in SCF and MCSCF "),
158 _("Print bond angle information"),
159 _("Print information for singles in CI, CCSD "),
160 _("Print bond distances "),
161 _("Print p-space configurations"),
162 _("Print variables each time they are set or changed "),
163 _("Print information for pairs in CI, CCSD "),
164 _("Print microiterations in MCSCF and CI"),
165 _("Print detailed CPU information "),
166 _("Print pair list in CI, CCSD")
167 };
168
169
170 if(TestButtonActive(gen->basis))
171 insert_gprint_option("basis",tGP[0]);
172 if(TestButtonActive(gen->civector))
173 insert_gprint_option("civector",tGP[1]);
174 if(TestButtonActive(gen->ref))
175 insert_gprint_option("ref",tGP[2]);
176 if(TestButtonActive(gen->io))
177 insert_gprint_option("io",tGP[3]);
178 if(TestButtonActive(gen->orbital))
179 insert_gprint_option("orbital",tGP[4]);
180 if(TestButtonActive(gen->angles))
181 insert_gprint_option("angles",tGP[5]);
182 if(TestButtonActive(gen->cs))
183 insert_gprint_option("cs",tGP[6]);
184 if(TestButtonActive(gen->distance))
185 insert_gprint_option("distance",tGP[7]);
186 if(TestButtonActive(gen->pspace))
187 insert_gprint_option("pspace",tGP[8]);
188 if(TestButtonActive(gen->variable))
189 insert_gprint_option("variable",tGP[9]);
190 if(TestButtonActive(gen->cp))
191 insert_gprint_option("cp",tGP[10]);
192 if(TestButtonActive(gen->micro))
193 insert_gprint_option("micro",tGP[11]);
194 if(TestButtonActive(gen->cpu))
195 insert_gprint_option("cpu",tGP[12]);
196 if(TestButtonActive(gen->pairs))
197 insert_gprint_option("pairs",tGP[13]);
198
199 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
200 }
201 /************************************************************************************************************/
insert_option(gchar * Type,gchar * ChaineCenter,gchar * Commentaire)202 static void insert_option(gchar *Type,gchar *ChaineCenter,gchar *Commentaire)
203 {
204 gchar *chaine;
205 chaine=g_strdup_printf("Gexpec,%s%s;%s\n",Type,ChaineCenter,Commentaire);
206 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,chaine,-1);
207 }
208 /************************************************************************************************************/
GetInfoGOne()209 static void GetInfoGOne()
210 {
211 gchar *tO[18]={
212 " !Compute Overlap ",
213 " !Compute Kinetic energy",
214 " !Compute Potential energy ",
215 " !Compute Delta function ",
216 " !Compute Delta4 function ",
217 " !Compute One-electron Darwin term",
218 " !Compute Mass-velocity term ",
219 " !Compute Total Cowan-Griffin Relativistic correction",
220 " !Compute Products of angular momentum operators ",
221 " !Compute Dipole moments",
222 " !Compute Second moment ",
223 " !Compute Quadrupole moments and R2 ",
224 " !Compute Electric field",
225 " !Compute Field gradients ",
226 " !Compute Angular momentum operators",
227 " !Compute Velocity",
228 " !Compute Spin-orbit operators",
229 " !Compute ECP spin-orbit operators"
230 };
231
232 gchar *ChaineCenter;
233 G_CONST_RETURN gchar *chaineC;
234 G_CONST_RETURN gchar *chaineX;
235 G_CONST_RETURN gchar *chaineY;
236 G_CONST_RETURN gchar *chaineZ;
237 if(TestButtonActive(gen->RadCenter))
238 {
239 chaineC=gtk_entry_get_text(GTK_ENTRY(gen->entryC));
240 ChaineCenter=g_strdup_printf("%s",chaineC);
241 }
242 else
243 {
244 chaineX=gtk_entry_get_text(GTK_ENTRY(gen->entryX));
245 chaineY=gtk_entry_get_text(GTK_ENTRY(gen->entryY));
246 chaineZ=gtk_entry_get_text(GTK_ENTRY(gen->entryZ));
247 ChaineCenter=g_strdup_printf(",,%s,%s,%s",chaineX,chaineY,chaineZ);
248 }
249
250 if(TestButtonActive(gen->Overlap))
251 insert_option("OV",ChaineCenter,tO[0]);
252 if(TestButtonActive(gen->Kinetic))
253 insert_option("Ekin",ChaineCenter,tO[1]);
254 if(TestButtonActive(gen->Potential))
255 insert_option("Pot",ChaineCenter,tO[2]);
256 if(TestButtonActive(gen->Delta))
257 insert_option("Delta",ChaineCenter,tO[3]);
258 if(TestButtonActive(gen->Delta4))
259 insert_option("Del4",ChaineCenter,tO[4]);
260 if(TestButtonActive(gen->Darwin))
261 insert_option("Darw",ChaineCenter,tO[5]);
262 if(TestButtonActive(gen->MassVelocity))
263 insert_option("Massv",ChaineCenter,tO[6]);
264 if(TestButtonActive(gen->CowanGriffin))
265 insert_option("Rel",ChaineCenter,tO[7]);
266 if(TestButtonActive(gen->ProductsMO))
267 {
268 insert_option("LXLX",ChaineCenter,tO[8]);
269 insert_option("LYLY",ChaineCenter," ");
270 insert_option("LZLZ",ChaineCenter," ");
271 insert_option("LXLY",ChaineCenter," ");
272 insert_option("LXLZ",ChaineCenter," ");
273 insert_option("LYLZ",ChaineCenter," ");
274 insert_option("LYLX",ChaineCenter," ");
275 insert_option("LZLX",ChaineCenter," ");
276 insert_option("LZLY",ChaineCenter," ");
277 }
278 if(TestButtonActive(gen->Dipole))
279 insert_option("Dm",ChaineCenter,tO[9]);
280 if(TestButtonActive(gen->Second))
281 insert_option("Sm",ChaineCenter,tO[10]);
282 if(TestButtonActive(gen->Quadrupole))
283 insert_option("Qm",ChaineCenter,tO[11]);
284 if(TestButtonActive(gen->Electric))
285 insert_option("Ef",ChaineCenter,tO[12]);
286 if(TestButtonActive(gen->Field))
287 insert_option("Fg",ChaineCenter,tO[13]);
288 if(TestButtonActive(gen->AngularMO))
289 {
290 insert_option("LX",ChaineCenter,tO[14]);
291 insert_option("LY",ChaineCenter," ");
292 insert_option("LZ",ChaineCenter," ");
293 }
294 if(TestButtonActive(gen->Velocity))
295 insert_option("Velo",ChaineCenter,tO[15]);
296 if(TestButtonActive(gen->SpinOrbit))
297 insert_option("Ls",ChaineCenter,tO[16]);
298 if(TestButtonActive(gen->ECP))
299 insert_option("Ecpls",ChaineCenter,tO[17]);
300 }
301 /************************************************************************************************************/
GetInfoGene()302 static void GetInfoGene()
303 {
304 gint nchar;
305 nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
306 if(iinsert)
307 {
308 reset_name_files();
309 data_modify(TRUE);
310 gabedit_text_set_point(GABEDIT_TEXT(text),0);
311 gabedit_text_forward_delete(GABEDIT_TEXT(text),nchar);
312 }
313
314 GetInfoTitle();
315 GetInfoMemory();
316 GetInfoGth();
317 GetInfoGprint();
318 GetInfoGOne();
319
320 if(iinsert) gabedit_text_set_point(GABEDIT_TEXT(text),0);
321
322 }
323 /************************************************************************************************************/
GetInfoXYZ(const gchar * SymEntry,const gchar * OptEntry)324 static void GetInfoXYZ(const gchar *SymEntry, const gchar *OptEntry)
325 {
326 guint i;
327 gchar *chaine;
328 gchar *line=NULL;
329 gchar *Xstr=NULL;
330 gchar *Ystr=NULL;
331 gchar *Zstr=NULL;
332 SAtomsProp prop;
333
334 Nelectrons = get_number_electrons(0);
335 if(NVariablesXYZ>0)
336 for(i=0;i<(guint)NVariablesXYZ;i++)
337 {
338 if(VariablesXYZ[i].Used)
339 {
340 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"!Variables :\n",-1);
341 break;
342 }
343 }
344 for(i=0;i<(guint)NVariablesXYZ;i++)
345 {
346 if(VariablesXYZ[i].Used)
347 {
348 if(Units==1)
349 line=g_strdup_printf("%s=%s;\n",
350 VariablesXYZ[i].Name,VariablesXYZ[i].Value);
351 else
352 line=g_strdup_printf("%s=%s;\n",
353 VariablesXYZ[i].Name,bohr_to_ang(VariablesXYZ[i].Value));
354
355 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,line,-1);
356 }
357 }
358
359 chaine=g_strdup("geomtyp=xyz\n");
360 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
361 chaine=g_strdup("geometry={");
362 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
363 chaine=g_strdup(SymEntry);
364 if (strcmp(chaine,_("default")) )
365 {
366 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
367 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, ";",-1);
368 }
369
370 chaine=g_strdup(OptEntry);
371 if (strcmp(chaine,_("none")) )
372 {
373 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
374 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, ";",-1);
375 }
376
377 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "ANGSTROM;",-1);
378
379 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
380
381
382 chaine=g_strdup_printf("%d ! number of atoms \n",NcentersXYZ);
383 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
384 chaine=g_strdup("GeomXYZ\n");
385 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
386
387 for(i=0;i<(guint)NcentersXYZ;i++)
388 {
389 if(Units==1)
390 line=g_strdup_printf("%s, %s, %s, %s",GeomXYZ[i].Symb,
391 GeomXYZ[i].X,GeomXYZ[i].Y,GeomXYZ[i].Z);
392 else
393 {
394 Xstr =g_strdup(GeomXYZ[i].X);
395 if(test(GeomXYZ[i].X))
396 Xstr =g_strdup(bohr_to_ang(GeomXYZ[i].X));
397 Ystr =g_strdup(GeomXYZ[i].Y);
398 if(test(GeomXYZ[i].Y))
399 Ystr =g_strdup(bohr_to_ang(GeomXYZ[i].Y));
400 Zstr =g_strdup(GeomXYZ[i].Z);
401 if(test(GeomXYZ[i].Z))
402 Zstr =g_strdup(bohr_to_ang(GeomXYZ[i].Z));
403
404 line=g_strdup_printf("%s, %s, %s, %s",GeomXYZ[i].Symb,
405 Xstr,Ystr,Zstr);
406
407 }
408 line=g_strdup_printf("%s\n",line);
409 prop = prop_atom_get(GeomXYZ[i].Symb);
410 gabedit_text_insert (GABEDIT_TEXT(text), NULL,NULL, &prop.color,line,-1);
411 }
412
413 chaine=g_strdup("}");
414 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
415 if(chaine != NULL)
416 g_free(chaine);
417 if(line != NULL)
418 g_free(line);
419 if(Xstr != NULL)
420 g_free(Xstr);
421 if(Ystr != NULL)
422 g_free(Ystr);
423 if(Zstr != NULL)
424 g_free(Zstr);
425 }
426 /************************************************************************************************************/
GetInfoZmatrix(const gchar * SymEntry,const gchar * OptEntry)427 static void GetInfoZmatrix(const gchar *SymEntry, const gchar *OptEntry)
428 {
429 guint i;
430 gchar *chaine;
431 gchar *line;
432 SAtomsProp prop;
433
434 Nelectrons = get_number_electrons(0);
435 if(NVariables>0)
436 for(i=0;i<(guint)NVariables;i++)
437 {
438 if(Variables[i].Used)
439 {
440 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"!Variables :\n",-1);
441 break;
442 }
443 }
444 for(i=0;i<(guint)NVariables;i++)
445 {
446
447 if(Variables[i].Used)
448 {
449 line=g_strdup_printf("%s = %s;\n",Variables[i].Name,Variables[i].Value);
450 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,line,-1);
451 }
452 }
453
454 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
455
456
457 chaine=g_strdup("geometry={");
458 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
459 chaine=g_strdup(SymEntry);
460 if (strcmp(chaine,_("default")) )
461 {
462 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
463 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, ";",-1);
464 }
465
466 chaine=g_strdup(OptEntry);
467 if (strcmp(chaine,_("none")) )
468 {
469 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
470 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, ";",-1);
471 }
472
473 if (Units != 0 )
474 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "ANGSTROM;",-1);
475
476
477 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
478 chaine=g_strdup("! geometry input in Z-MATRIX type generated by gabedit\n");
479 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, chaine,-1);
480
481
482 for(i=0;i<(guint)NcentersZmat;i++)
483 {
484 line=g_strdup_printf("%s",Geom[i].Symb);
485 if(Geom[i].Nentry>NUMBER_ENTRY_0)
486 line=g_strdup_printf("%s, %s, %s",line,Geom[i].NR,Geom[i].R);
487 if(Geom[i].Nentry>NUMBER_ENTRY_R)
488 line=g_strdup_printf("%s, %s, %s",line,Geom[i].NAngle,Geom[i].Angle);
489 if(Geom[i].Nentry>NUMBER_ENTRY_ANGLE)
490 line=g_strdup_printf("%s, %s, %s",line,Geom[i].NDihedral,Geom[i].Dihedral);
491
492 line=g_strdup_printf("%s;\n",line);
493 prop = prop_atom_get(Geom[i].Symb);
494 gabedit_text_insert (GABEDIT_TEXT(text), NULL,NULL, &prop.color,line,-1);
495 }
496
497
498
499
500 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "}",-1);
501
502 }
503 /************************************************************************************************************/
GetInfoGeom()504 static void GetInfoGeom()
505 {
506 gint nchar;
507 G_CONST_RETURN gchar *SymEntry;
508 G_CONST_RETURN gchar *OptEntry;
509 nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
510 if(iinsert) gabedit_text_set_point(GABEDIT_TEXT(text),nchar);
511 SymEntry = gtk_entry_get_text(GTK_ENTRY(geom->Symentry));
512 OptEntry = gtk_entry_get_text(GTK_ENTRY(geom->Optentry));
513 if(MethodeGeom == GEOM_IS_XYZ)
514 GetInfoXYZ(SymEntry,OptEntry);
515 else
516 if(MethodeGeom == GEOM_IS_ZMAT)
517 GetInfoZmatrix(SymEntry,OptEntry);
518
519 if(iinsert) gabedit_text_set_point(GABEDIT_TEXT(text),0);
520 }
521 /************************************************************************************************************/
GetInfoBasis()522 static void GetInfoBasis()
523 {
524 gint nchar;
525 gint i;
526 Cbasetot *basetot;
527
528 GtkTreeModel *model;
529 GtkTreeIter iter;
530 gchar* pathString = NULL;
531
532 model = gtk_tree_view_get_model(GTK_TREE_VIEW(base->listOfAtoms));
533
534 nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
535 if(iinsert) gabedit_text_set_point(GABEDIT_TEXT(text),nchar);
536
537
538 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\nbasis={\n",-1);
539 base->NRatoms=NRatoms;
540 for (i=1;i<=(gint)base->NRatoms;i++)
541 {
542 pathString = g_strdup_printf("%d",i-1);
543 if(!gtk_tree_model_get_iter_from_string (model, &iter, pathString))continue;
544 g_free(pathString);
545 gtk_tree_model_get (model, &iter, ATOMLIST_DATA, &basetot, -1);
546
547 if(basetot->ECP != NULL)
548 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basetot->ECP ,-1);
549 if(basetot->Orb[0] != NULL)
550 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basetot->Orb[0] ,-1);
551 if(basetot->Orb[1] != NULL)
552 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basetot->Orb[1] ,-1);
553 if(basetot->Orb[2] != NULL)
554 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basetot->Orb[2] ,-1);
555 if(basetot->Orb[3] != NULL)
556 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basetot->Orb[3] ,-1);
557 if(basetot->Orb[4] != NULL)
558 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basetot->Orb[4] ,-1);
559 if(basetot->Orb[5] != NULL)
560 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basetot->Orb[5] ,-1);
561 if(basetot->Orb[6] != NULL)
562 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basetot->Orb[6] ,-1);
563 }
564 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"}\n",-1);
565 if(iinsert) gabedit_text_set_point(GABEDIT_TEXT(text),0);
566 }
567 /************************************************************************************************************/
GetInfoComm()568 static void GetInfoComm()
569 {
570 gchar *CommText;
571 guint nchar;
572 nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
573 if(iinsert) gabedit_text_set_point(GABEDIT_TEXT(text),nchar);
574 CommText= gabedit_text_get_chars(comm->TextComm, 0, -1);
575 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, CommText,-1);
576 if(strstr( CommText,"{")) gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "}\n",-1);
577 g_free(CommText);
578 if(iinsert) gabedit_text_set_point(GABEDIT_TEXT(text),0);
579 }
580 /************************************************************************************************************/
GetInfo(GtkWidget * widget,gpointer data)581 static void GetInfo( GtkWidget *widget, gpointer data )
582 {
583 iset=iframe-1;
584 switch(iset)
585 {
586 case 0:GetInfoGene() ; break;
587 case 1:GetInfoGeom() ;
588 geom_is_not_open();
589 TypeGeomOpen = 0;
590 WindowGeom = NULL;
591 break;
592 case 2:GetInfoBasis(); break;
593 case 3:GetInfoComm();
594 if(data == NULL) destroy_children(Wins);
595 break;
596 }
597 if( data !=NULL ){
598 save_as_doc();
599 data_modify(FALSE);
600 iedit=1;
601 gabedit_text_set_editable(GABEDIT_TEXT(text), TRUE);
602 }
603
604 }
605 /************************************************************************************************************/
NewFrame(GtkWidget * widget,gpointer data)606 static void NewFrame( GtkWidget *widget, gpointer data )
607 {
608 gint i;
609 iframe++;
610 switch(iframe)
611 {
612 case 2: geom=g_malloc(sizeof(GeomS));
613 i = iframe;
614 if(GeomIsOpen && TypeGeomOpen !=0 )
615 {
616 if(WindowGeom)
617 gtk_widget_destroy(WindowGeom);
618 }
619 iframe=i;
620 WindowGeom = Wins;
621 AjoutePageGeom(NoteBook,geom);
622 TypeGeomOpen = 3;
623 break;
624 case 3: base=g_malloc(sizeof(BaseS));
625 AjoutePageBasis(Wins,NoteBook,base);
626 break;
627 case 4: comm=g_malloc(sizeof(CommS));
628 AjoutePageComm(Wins,NoteBook,comm);
629 gtk_widget_destroy(hboxb);
630 hboxb=gtk_hbox_new(TRUE,2);
631 create_label_hbox(hboxb,"FINISH",-1);
632 gtk_container_add (GTK_CONTAINER (widget), hboxb);
633 gtk_widget_show_all(widget);
634
635 break;
636 }
637 delete_all_children(Wins);
638 gtk_widget_show_all(Wins);
639 gtk_notebook_set_current_page((GtkNotebook*)NoteBook,1);
640 gtk_notebook_remove_page((GtkNotebook *)NoteBook,0);
641 }
642 /************************************************************************************************************/
to_cancel_win(GtkWidget * win,gpointer data)643 static void to_cancel_win(GtkWidget* win,gpointer data)
644 {
645 Cancel_YesNo(win,data, destroy_children);
646 }
647 /************************************************************************************************************/
insert_molpro(gint itype)648 void insert_molpro(gint itype)
649 {
650 GtkWidget *button;
651 int i;
652
653 gtk_notebook_set_current_page((GtkNotebook*)NoteBookText,0);
654 fileopen.command=g_strdup(NameCommandMolpro);
655
656 if(Wins) destroy_children(Wins);
657 iframe=itype;
658 iinsert=0;
659
660 Wins= gtk_dialog_new ();
661 /* gtk_window_set_position(GTK_WINDOW(Wins),GTK_WIN_POS_CENTER_ALWAYS);*/
662 gtk_window_set_position(GTK_WINDOW(Wins), GTK_WIN_POS_CENTER_ON_PARENT);
663 gtk_window_set_transient_for(GTK_WINDOW(Wins),GTK_WINDOW(Fenetre));
664 gtk_window_set_title(>K_DIALOG(Wins)->window,_("molpro input"));
665
666 init_child(Wins,DestroyWinsMolpro,_(" Molpro input "));
667 g_signal_connect(G_OBJECT(Wins),"delete_event",(GCallback)destroy_children,NULL);
668
669
670 NoteBook = gtk_notebook_new();
671 gtk_box_pack_start(GTK_BOX (GTK_DIALOG(Wins)->vbox), NoteBook,TRUE, TRUE, 0);
672 switch (iframe) {
673 case 1 : gen=g_malloc(sizeof(GeneS));
674 AjoutePageGene(NoteBook,gen);
675 break;
676 case 2 : geom=g_malloc(sizeof(GeomS));
677 i = iframe;
678 if(GeomIsOpen && TypeGeomOpen !=0 )
679 {
680 if(WindowGeom)
681 gtk_widget_destroy(WindowGeom);
682 }
683 iframe = i;
684 WindowGeom = Wins;
685 AjoutePageGeom(NoteBook,geom);
686 TypeGeomOpen = 3;
687 break;
688 case 3: base=g_malloc(sizeof(BaseS));
689 AjoutePageBasis(Wins,NoteBook,base);
690 break;
691
692
693 case 4: comm=g_malloc(sizeof(CommS));
694 AjoutePageComm(Wins,NoteBook,comm);
695 break;
696
697 }
698
699 gtk_box_set_homogeneous (GTK_BOX( GTK_DIALOG(Wins)->action_area), FALSE);
700
701
702 gtk_widget_realize(Wins);
703
704 button = create_button(Wins,_("Cancel"));
705 gtk_box_pack_end (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, FALSE, TRUE, 5);
706 g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK( to_cancel_win),GTK_OBJECT(Wins));
707 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
708 gtk_widget_show (button);
709
710 button = create_button(Wins,_("OK"));
711 gtk_box_pack_end (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, FALSE, TRUE, 5);
712 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
713 gtk_widget_grab_default(button);
714 gtk_widget_show (button);
715 g_signal_connect(G_OBJECT(button), "clicked", (GCallback)GetInfo,NULL);
716 g_signal_connect(G_OBJECT(button), "clicked", (GCallback)data_modify,NULL);
717 g_signal_connect_swapped(G_OBJECT(button), "clicked",G_CALLBACK(destroy_children),GTK_OBJECT(Wins));
718
719
720 gtk_widget_show_all(Wins);
721
722 }
723 /************************************************************************************************************/
molpro()724 void molpro()
725 {
726 GtkWidget *button;
727
728 gtk_notebook_set_current_page((GtkNotebook*)NoteBookText,0);
729 fileopen.command=g_strdup(NameCommandMolpro);
730
731 if(Wins) destroy_children(Wins);
732 iframe=1;
733 iinsert=1;
734
735 Wins= gtk_dialog_new ();
736 gtk_window_set_position(GTK_WINDOW(Wins),GTK_WIN_POS_CENTER);
737 gtk_window_set_transient_for(GTK_WINDOW(Wins),GTK_WINDOW(Fenetre));
738 gtk_window_set_title(>K_DIALOG(Wins)->window,_("molpro input"));
739
740 init_child(Wins,DestroyWinsMolpro,_(" Molpro input "));
741 g_signal_connect(G_OBJECT(Wins),"delete_event",(GCallback)destroy_children,NULL);
742
743 NoteBook = gtk_notebook_new();
744 gtk_box_pack_start(GTK_BOX (GTK_DIALOG(Wins)->vbox), NoteBook,TRUE, TRUE, 0);
745 gen=g_malloc(sizeof(GeneS));
746 AjoutePageGene(NoteBook,gen);
747
748
749 gtk_widget_realize(Wins);
750
751 button = create_button(Wins,_("Cancel"));
752 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
753 gtk_box_pack_start (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, TRUE, TRUE, 0);
754 g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK( to_cancel_win),GTK_OBJECT(Wins));
755 gtk_widget_show (button);
756
757 /*
758 button = create_button(Wins,"SAVE&CLOSE");
759 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
760 gtk_box_pack_start (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, TRUE, TRUE, 0);
761 g_signal_connect(G_OBJECT(button), "clicked",(GCallback)GetInfo,&iframe);
762 g_signal_connect_swapped(G_OBJECT(button), "clicked",G_CALLBACK(destroy_children),GTK_OBJECT(Wins));
763 gtk_widget_show (button);
764 */
765
766 button = gtk_button_new();
767 hboxb=gtk_hbox_new(TRUE,2);
768 gtk_container_add (GTK_CONTAINER (hboxb), create_label_pixmap(Wins,next_xpm,"Next"));
769 gtk_container_add (GTK_CONTAINER (button), hboxb);
770 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
771 gtk_box_pack_start (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, TRUE, TRUE, 0);
772 gtk_widget_show (button);
773 gtk_widget_grab_default(button);
774 g_signal_connect(G_OBJECT(button), "clicked", (GCallback)GetInfo,NULL);
775 g_signal_connect(G_OBJECT(button), "clicked", (GCallback)NewFrame,NULL);
776
777 gtk_widget_show_all(Wins);
778
779 }
780