1 /* Gaussian.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 <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include "../Common/Global.h"
26 #include "../Utils/UtilsInterface.h"
27 #include "../Utils/Utils.h"
28 #include "../Utils/GabeditTextEdit.h"
29 #include "../Geometry/GeomGlobal.h"
30 #include "../Geometry/GeomXYZ.h"
31 #include "../Geometry/InterfaceGeom.h"
32 #include "../Utils/AtomsProp.h"
33 #include "GaussGlobal.h"
34 #include "GInterfaceRoute.h"
35 #include "GInterfaceGeom.h"
36 #include "GInterfaceBasis.h"
37 
38 static GtkWidget *NoteBook;
39 static GtkWidget *Wins=NULL;
40 static gboolean AddMP2=FALSE;
41 static gboolean AddConical=FALSE;
42 GtkWidget *hboxb;
43 static   gint iinsert;
44 static gboolean amber = FALSE;
45 
46 /*******************************************************************/
DestroyWinsGauss(GtkWidget * win)47 void DestroyWinsGauss(GtkWidget *win)
48 {
49 	destroy(Wins,NULL);
50         Wins = NULL;
51         EntryCS[0] = 0;
52 }
53 /*******************************************************************/
to_cancel_win(GtkWidget * win,gpointer data)54 static void to_cancel_win(GtkWidget* win,gpointer data)
55 {
56   Cancel_YesNo(win,data, destroy_children);
57 }
58 /*******************************************************************/
GetLink1()59 static void GetLink1()
60 {
61  gint nchar;
62  gchar *t = NULL;
63  gchar *t1 = NULL;
64  gchar *t2 = NULL;
65  gchar *DestOrig;
66  gchar *DestStrLink;
67  gchar *temp;
68  gint n;
69 
70  nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
71  gabedit_text_set_point(GABEDIT_TEXT(text),nchar);
72  gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"--Link1--\n",-1);
73 
74  t1=gabedit_text_get_chars(text,0,-1);
75  uppercase(t1);
76 
77  t= g_strdup("%Chk=");
78  uppercase(t);
79  DestOrig = strstr( t1,t);
80  DestStrLink = NULL;
81  if(StrLink != NULL)
82  {
83   	t2= g_strdup(StrLink);
84  	uppercase(t2);
85  	DestStrLink = strstr( t2,t);
86  }
87  if(DestStrLink == NULL)
88  {
89  	if(DestOrig == NULL)
90  	{
91  		gabedit_text_set_point(GABEDIT_TEXT(text),0);
92  		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"%Chk=checkfile\n",-1);
93  		nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
94  		gabedit_text_set_point(GABEDIT_TEXT(text),nchar);
95  		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"%Chk=checkfile\n",-1);
96  	}
97  	else
98  	{
99 		temp = g_malloc(100);
100                 n = DestOrig - t1;
101                 g_free(t1);
102  		t1=gabedit_text_get_chars(text,0,-1);
103 		sscanf(t1+n,"%s",temp);
104                 temp = g_strdup_printf("%s\n",temp);
105  		nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
106  		gabedit_text_set_point(GABEDIT_TEXT(text),nchar);
107  		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,temp,-1);
108         	g_free(temp);
109  	}
110  }
111 
112  if(t) g_free(t);
113  if(t1) g_free(t1);
114  if(t2) g_free(t2);
115 
116 }
117 /*******************************************************************/
GetInfoBasisT(gint i)118 static void GetInfoBasisT(gint i)
119 {
120               	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,BasisT[i].CenterName,-1);
121               	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," 0\n",-1);
122               	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,BasisT[i].BasisName,-1);
123                	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n*******\n",-1);
124 }
125 /*******************************************************************/
GetInfoBasisC(gint i)126 static void GetInfoBasisC(gint i)
127 {
128  	gchar *temp;
129               temp=g_strdup_printf(" %d 0\n",BasisC[i].Number);
130               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,temp,-1);
131               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,BasisC[i].BasisName,-1);
132               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n*******\n",-1);
133 }
134 /*******************************************************************/
GetInfoBasisLower()135 static void GetInfoBasisLower()
136 {
137 	gint i;
138         gboolean chang=FALSE;
139 
140            for (i=0;i<NSymbCenters;i++)
141          	if(BasisC[i].Changed)
142               		if( !strcmp(BasisC[i].Layer,"Low") )
143 			{
144 				chang=TRUE;
145 				break;
146 			}
147 
148           if(!chang)
149           {
150             for (i=0;i<NSymbTypes;i++)
151               if( strcmp(BasisT[i].BasisName,_("None"))  )
152               	if( !strcmp(BasisT[i].Layer,"Low") )
153 			GetInfoBasisT(i);
154           }
155           else
156            for (i=0;i<NSymbCenters;i++)
157               		if( strcmp(BasisC[i].BasisName,_("None")) )
158               			if( !strcmp(BasisC[i].Layer,"Low") )
159 					GetInfoBasisC(i);
160         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n",-1);
161 }
162 /*******************************************************************/
GetInfoBasisMedium()163 static void GetInfoBasisMedium()
164 {
165 	gint i;
166         gboolean chang=FALSE;
167 
168            for (i=0;i<NSymbCenters;i++)
169          	if(BasisC[i].Changed)
170               		if( !strcmp(BasisC[i].Layer,"Medium") )
171 			{
172 				chang=TRUE;
173 				break;
174 			}
175 
176           if(!chang)
177           {
178             for (i=0;i<NSymbTypes;i++)
179               	if( strcmp(BasisT[i].BasisName,_("None"))  )
180               		if( !strcmp(BasisT[i].Layer,"Medium") )
181 				GetInfoBasisT(i);
182           }
183 	  else
184            for (i=0;i<NSymbCenters;i++)
185               		if( strcmp(BasisC[i].BasisName,_("None")) )
186               			if( !strcmp(BasisC[i].Layer,"Medium") )
187 					GetInfoBasisC(i);
188         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n",-1);
189 }
190 /*******************************************************************/
GetInfoBasisHight()191 static void GetInfoBasisHight()
192 {
193 	gint i;
194         gboolean chang=FALSE;
195 
196            for (i=0;i<NSymbCenters;i++)
197          	if(BasisC[i].Changed)
198               		if( !strcmp(BasisC[i].Layer,"High") || !strcmp(BasisC[i].Layer," ") )
199 			{
200 				chang=TRUE;
201 				break;
202 			}
203               printf("coucou\n");
204               printf("%s\n",BasisC[0].BasisName);
205 
206           if(!chang)
207           {
208             for (i=0;i<NSymbTypes;i++)
209               if( strcmp(BasisT[i].BasisName,_("None"))  )
210               	if( !strcmp(BasisT[i].Layer,"High") || !strcmp(BasisT[i].Layer," "))
211 			GetInfoBasisT(i);
212           }
213 	  else
214            for (i=0;i<NSymbCenters;i++)
215               		if( strcmp(BasisC[i].BasisName,_("None")) )
216               			if( !strcmp(BasisC[i].Layer,"High") || !strcmp(BasisC[i].Layer," ") )
217 					GetInfoBasisC(i);
218         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n",-1);
219 }
220 /*******************************************************************/
GetInfoBasis()221 static void GetInfoBasis( )
222 {
223 	gint i;
224 	gint nMethodes=0;
225 
226         for(i=0;i<3;i++)
227 		if(Methodes[i] !=NULL)
228 			nMethodes++;
229 
230               printf("nMethodes = %d\n",nMethodes);
231         if(nMethodes<2)
232 	{
233 		if(strcmp(Methodes[0],_("Semi-Empirical Methods")) && strcmp(Methodes[0],_("Molecular Mechanics Methods")))
234 	 		GetInfoBasisHight();
235 	}
236        else
237         if(nMethodes<3)
238         {
239 		if(strcmp(Methodes[2],_("Semi-Empirical Methods")) && strcmp(Methodes[2],_("Molecular Mechanics Methods")))
240          		if(Basis[2] !=NULL && !strcmp(Basis[2],"GEN") ) GetInfoBasisLower();
241 		if(strcmp(Methodes[1],_("Semi-Empirical Methods")) && strcmp(Methodes[1],_("Molecular Mechanics Methods")))
242          		if(Basis[1] !=NULL && !strcmp(Basis[1],"GEN") ) GetInfoBasisMedium();
243 		if(strcmp(Methodes[0],_("Semi-Empirical Methods")) && strcmp(Methodes[0],_("Molecular Mechanics Methods")))
244          		if(Basis[0] !=NULL && !strcmp(Basis[0],"GEN") ) GetInfoBasisHight();
245 		if(strcmp(Methodes[2],_("Semi-Empirical Methods")) && strcmp(Methodes[2],_("Molecular Mechanics Methods")))
246          		if(Basis[2] !=NULL && !strcmp(Basis[2],"GEN") ) GetInfoBasisLower();
247 		if(strcmp(Methodes[1],_("Semi-Empirical Methods")) && strcmp(Methodes[1],_("Molecular Mechanics Methods")))
248          		if(Basis[1] !=NULL && !strcmp(Basis[1],"GEN") ) GetInfoBasisMedium();
249         }
250        else
251        {
252 		if(strcmp(Methodes[2],_("Semi-Empirical Methods")) && strcmp(Methodes[2],_("Molecular Mechanics Methods")))
253          		if(Basis[2] !=NULL && !strcmp(Basis[2],"GEN") ) GetInfoBasisLower();
254 		if(strcmp(Methodes[1],_("Semi-Empirical Methods")) && strcmp(Methodes[1],_("Molecular Mechanics Methods")))
255          		if(Basis[1] !=NULL && !strcmp(Basis[1],"GEN") ) GetInfoBasisMedium();
256 		if(strcmp(Methodes[0],_("Semi-Empirical Methods")) && strcmp(Methodes[0],_("Molecular Mechanics Methods")))
257          		if(Basis[0] !=NULL && !strcmp(Basis[0],"GEN") ) GetInfoBasisHight();
258 		if(strcmp(Methodes[2],_("Semi-Empirical Methods")) && strcmp(Methodes[2],_("Molecular Mechanics Methods")))
259          		if(Basis[2] !=NULL && !strcmp(Basis[2],"GEN") ) GetInfoBasisLower();
260 		if(strcmp(Methodes[1],_("Semi-Empirical Methods")) && strcmp(Methodes[1],_("Molecular Mechanics Methods")))
261          		if(Basis[1] !=NULL && !strcmp(Basis[1],"GEN") ) GetInfoBasisMedium();
262 		if(strcmp(Methodes[2],_("Semi-Empirical Methods")) && strcmp(Methodes[2],_("Molecular Mechanics Methods")))
263          		if(Basis[2] !=NULL && !strcmp(Basis[2],"GEN") ) GetInfoBasisLower();
264        }
265 }
266 /*******************************************************************/
TestButtonActive(GtkWidget * button)267 static gboolean TestButtonActive(GtkWidget *button)
268 {
269          if (GTK_TOGGLE_BUTTON (button)->active)
270                return TRUE;
271          else return FALSE;
272 }
273 /*******************************************************************/
GetInfoLink()274 static void GetInfoLink( )
275 {
276 
277         if(StrLink)
278         {
279 			gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,StrLink,-1);
280 			g_free(StrLink);
281 			StrLink = NULL;
282         }
283 }
284 /*******************************************************************/
GetInfoGene()285 static void GetInfoGene( )
286 {
287 
288 	gint i;
289         if(StrLink)
290         {
291 			gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,StrLink,-1);
292 			g_free(StrLink);
293 			StrLink = NULL;
294         }
295 
296 	for (i=0;i<8;i++) {
297 		if(TestButtonActive(CheckButtons[i]) )
298 		{
299 			gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n#",-1);
300 		 break;
301 		}
302 	}
303 	if(TestButtonActive(CheckButtons[0]) )
304               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Gfinput IOP(6/7=3) ",-1);
305 	if(TestButtonActive(CheckButtons[1]) )
306               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Pop=full ",-1);
307 
308 	if(TestButtonActive(CheckButtons[5]) )
309               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Density ",-1);
310 	if(TestButtonActive(CheckButtons[2]) )
311               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Archive ",-1);
312         else
313               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Test ",-1);
314 	if(TestButtonActive(CheckButtons[3]) )
315               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Nosymm ",-1);
316 	if(TestButtonActive(CheckButtons[6]) || TestButtonActive(CheckButtons[7]) )
317               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Guess(",-1);
318 	if(TestButtonActive(CheckButtons[6]))
319         {
320               	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"Mix",-1);
321 		if(TestButtonActive(CheckButtons[7]))
322               		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,",Read",-1);
323         }else
324            {
325 		if(TestButtonActive(CheckButtons[7]))
326               		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"Read",-1);
327            }
328 	if(TestButtonActive(CheckButtons[6]) || TestButtonActive(CheckButtons[7]) )
329               gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,") ",-1);
330 	if(TestButtonActive(CheckButtons[8]) )
331         {
332               	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Geom=Check ",-1);
333 		GeomFromCheck = TRUE;
334         }
335 
336 }
337 /*******************************************************************/
GetInfoTitle()338 static void GetInfoTitle( )
339 {
340         gchar *temp;
341         temp=gabedit_text_get_chars(TextTitle,0,-1);
342         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
343         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
344         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, temp,-1);
345         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
346         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
347 }
348 /*******************************************************************/
GetInfoPFS()349 static void GetInfoPFS(  )
350 {
351 	gboolean okTimeDependent = FALSE;
352 	if( TtimeDependent!=NULL)
353   	if (!strcmp(Methodes[0],_("Density Functional Methods"))
354 			|| !strcmp(Methodes[0],_("Hartree Fock"))
355 			|| !strcmp(Methodes[0],_("Hybrid Functional Methods"))
356 	  )
357 		okTimeDependent = TRUE;
358 
359 	if( (Tfreq!=NULL) || (Tscf!=NULL) || (Tpolar!=NULL) || (okTimeDependent) )
360 			gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n# ",-1);
361 
362         if(Tfreq!=NULL)
363 	{
364         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,Tfreq,-1);
365 		g_free(Tfreq);
366 		Tfreq=NULL;
367 	}
368         if(Tscf!=NULL)
369 	{
370         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,Tscf,-1);
371 		g_free(Tscf);
372 		Tscf=NULL;
373 	}
374         if(Tpolar!=NULL)
375 	{
376         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,Tpolar,-1);
377 		g_free(Tpolar);
378 		Tpolar=NULL;
379 	}
380         if(TtimeDependent!=NULL && okTimeDependent)
381 	{
382         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,TtimeDependent,-1);
383 		g_free(TtimeDependent);
384 		TtimeDependent=NULL;
385 	}
386 }
387 /*******************************************************************/
get_info_basis(gint im)388 static gchar *get_info_basis(gint im)
389 {
390        	gchar *temp;
391        	gchar **tmp;
392   	G_CONST_RETURN gchar *entrytext;
393         gint nentry=0;
394         gboolean Modify=FALSE;
395 
396         if(EntryBasis[0][im]!=NULL)nentry++;
397         if(EntryBasis[1][im]!=NULL)nentry++;
398         if( strcmp(Basis[im],"GEN") )
399         {
400         	tmp = g_strsplit(Basis[im],"G",2);
401         	temp = g_strdup(tmp[0]);
402         }
403         else temp = g_strdup(Basis[im]);
404 
405   	if (strcmp(temp,Basis[im]) ) Modify=TRUE;
406         if(EntryBasis[0][im]!=NULL)
407         {
408   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryBasis[0][im]));
409   		if (strcmp(entrytext,_("No")) ) temp=g_strdup_printf("%s%s",temp,entrytext);
410         }
411   	if (Modify) temp = g_strdup_printf("%sG",temp);
412         if(EntryBasis[1][im]!=NULL)
413         {
414   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryBasis[1][im]));
415   		if (strcmp(entrytext,_("No")) )
416         	{
417   			if (strcmp(entrytext,_("Yes")) ) temp=g_strdup_printf("%s%s",temp,entrytext);
418                 	else temp=g_strdup_printf("AUG-%s",temp);
419         	}
420         }
421 
422        return temp;
423 }
424 /*******************************************************************/
get_info_method(gint im)425 static gchar *get_info_method(gint im)
426 {
427        	gchar *temp;
428   	G_CONST_RETURN gchar *entrytext;
429        	gchar **tmp;
430         gboolean Modify=FALSE;
431 
432   	entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[0][im]));
433         tmp = g_strsplit(entrytext,")",2);
434 	if(strstr(entrytext,"TDDFT")) temp=g_strdup_printf(" TD");
435 	else temp=g_strdup(entrytext);
436 
437   	if (strcmp(temp,tmp[0])) Modify=TRUE;
438 
439   	if (!strcmp(Methodes[im],_("Density Functional Methods")) )
440         {
441   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[1][im]));
442         	temp=g_strdup_printf("%s%s",temp,entrytext);
443   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[2][im]));
444   		if (!strcmp(entrytext,"LC-"))
445         		temp=g_strdup_printf("%s%s",entrytext,temp);
446         }
447         else
448   	if (!strcmp(Methodes[im],_("MP Methods")) )
449         {
450   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[1][im]));
451         	temp=g_strdup_printf("%s(%s",temp,entrytext);
452   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[2][im]));
453   		if (strcmp(entrytext,_("default")) )
454         	temp=g_strdup_printf("%s,%s",temp,entrytext);
455         	temp=g_strdup_printf("%s)",temp);
456         }
457         else
458   	if (!strcmp(Methodes[im],_("Excited States")) )
459         {
460   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[1][im]));
461 		temp=g_strdup_printf("%s(%s",temp,entrytext);
462 
463   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[2][im]));
464   		if (strcmp(entrytext,_("default")) )
465         		temp=g_strdup_printf("%s,Nstates=%s",temp,entrytext);
466   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[3][im]));
467   		if (strcmp(entrytext,_("default")) )
468         		temp=g_strdup_printf("%s,Root=%s",temp,entrytext);
469         	temp=g_strdup_printf("%s)",temp);
470         }
471         else
472   	if (!strcmp(Methodes[im],_("CASSCF Method")) )
473         {
474         	temp=g_strdup("CASSCF");
475   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[0][im]));
476         	temp=g_strdup_printf("%s(%s",temp,entrytext);
477   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[1][im]));
478         	temp=g_strdup_printf("%s,%s",temp,entrytext);
479   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[2][im]));
480   		if (strcmp(entrytext,_("No")) )
481         		AddMP2=TRUE;
482   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[3][im]));
483   		if (strcmp(entrytext,_("No")) )
484         		temp=g_strdup_printf("%s,Spin",temp);
485   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[4][im]));
486   		if (strcmp(entrytext,_("No")) )
487  			AddConical=TRUE;
488   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[5][im]));
489   		if (strcmp(entrytext,_("default")) )
490         		temp=g_strdup_printf("%s,Nroot=%s",temp,entrytext);
491         	temp=g_strdup_printf("%s)",temp);
492         }
493         else
494   	if (!strcmp(Methodes[im],_("CI Methods")) )
495         {
496         	temp=g_strdup(tmp[0]);
497   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[1][im]));
498                 if(Modify)
499         	temp=g_strdup_printf("%s,%s",temp,entrytext);
500                 else
501         	temp=g_strdup_printf("%s(%s",temp,entrytext);
502 
503   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[2][im]));
504         	temp=g_strdup_printf("%s,Conver=%s",temp,entrytext);
505   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryMethods[3][im]));
506         	temp=g_strdup_printf("%s,MaxCyc=%s",temp,entrytext);
507         	temp=g_strdup_printf("%s)",temp);
508         }
509 
510        return temp;
511 }
512 /*******************************************************************/
AddWithBasis(gchar * method,gchar * basis)513 static void AddWithBasis(gchar* method, gchar* basis)
514 {
515 		if(strstr(method,"TD("))
516 		{
517         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"B3LYP/",-1);
518         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basis,-1);
519         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,method,-1);
520 		}
521 		else
522 		{
523         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,method,-1);
524         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"/",-1);
525         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,basis,-1);
526 		}
527 }
528 /*******************************************************************/
GetInfoMB()529 static void GetInfoMB(  )
530 {
531         gboolean ONIOM=FALSE;
532         gchar *temp;
533 
534         if ( Methodes[0]!=NULL )
535 	{
536             temp = get_info_method(0);
537 	    if(!strcmp(temp,"AMBER")) amber = TRUE;
538        	    if ( Methodes[1]!=NULL )
539 	    {
540             	temp = get_info_method(1);
541 	    	if(!strcmp(temp,"AMBER")) amber = TRUE;
542 	    }
543        	    if ( Methodes[2]!=NULL )
544 	    {
545             	temp = get_info_method(2);
546 	    	if(!strcmp(temp,"AMBER")) amber = TRUE;
547 	    }
548 	}
549         else
550         {
551             temp=g_strdup("HF");
552 	    Methodes[0]=g_strdup("HF");
553         }
554         if ( (Methodes[1]!=NULL) ) ONIOM=TRUE;
555         if ( (Methodes[2]!=NULL) ) ONIOM=TRUE;
556         if ( ONIOM) {
557         	gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,"ONIOM(",-1);
558         }
559 
560         temp=get_info_method(0);
561 	if(strcmp(Methodes[0],_("Semi-Empirical Methods")) && strcmp(Methodes[0],_("Molecular Mechanics Methods")))
562 	{
563         	if (Basis[0]!=NULL) AddWithBasis(temp, get_info_basis(0));
564 		else gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,temp,-1);
565 	}
566 	else gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,temp,-1);
567 
568         if ( Methodes[1]!=NULL )
569         {
570             	temp=get_info_method(1);
571         	gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,":",-1);
572 		if(strcmp(Methodes[1],_("Semi-Empirical Methods")) && strcmp(Methodes[1],_("Molecular Mechanics Methods")))
573 		{
574         		if (Basis[1]!=NULL) AddWithBasis(temp, get_info_basis(1));
575 			else gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,temp,-1);
576 		}
577 		else gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,temp,-1);
578         }
579 
580         if ( Methodes[2]!=NULL )
581         {
582             	temp=get_info_method(2);
583         	gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,":",-1);
584 		if(strcmp(Methodes[2],_("Semi-Empirical Methods")) && strcmp(Methodes[2],_("Molecular Mechanics Methods")))
585 		{
586         		if (Basis[2]!=NULL) AddWithBasis(temp, get_info_basis(2));
587 			else gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,temp,-1);
588 		}
589 		else gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,temp,-1);
590         }
591         if ( ONIOM)
592         	gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,")",-1);
593 
594 }
595 /*******************************************************************/
GetInfoType()596 static void GetInfoType()
597 {
598        	gchar *temp;
599   	G_CONST_RETURN gchar *entrytext;
600 
601         if(Types==NULL || !strcmp(Types,_("Single Point")) )
602         return;
603         if(AddConical)
604 	{
605        		gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL," Opt=Conical ",-1);
606         	return;
607 	}
608 
609   	entrytext = gtk_entry_get_text(GTK_ENTRY(EntryTypes[0]));
610 	if(strcmp(entrytext,_("default"))) temp=g_strdup_printf("Opt(%s",entrytext);
611 	else temp=g_strdup_printf("Opt(");
612 
613   	entrytext = gtk_entry_get_text(GTK_ENTRY(EntryTypes[1]));
614         if( strcmp(entrytext,_("default")) ) temp=g_strdup_printf("%s,%s",temp,entrytext);
615 
616   	entrytext = gtk_entry_get_text(GTK_ENTRY(EntryTypes[2]));
617         if( strcmp(entrytext,_("default")) ) temp=g_strdup_printf("%s,MaxCycle=%s",temp,entrytext);
618 
619   	entrytext = gtk_entry_get_text(GTK_ENTRY(EntryTypes[3]));
620         if( strcmp(entrytext,_("default")) ) temp=g_strdup_printf("%s,StepSize=%s",temp,entrytext);
621 
622   	entrytext = gtk_entry_get_text(GTK_ENTRY(EntryTypes[4]));
623         if( strcmp(entrytext,_("No")) ) temp=g_strdup_printf("%s,Saddle=%s",temp,entrytext);
624 
625   	entrytext = gtk_entry_get_text(GTK_ENTRY(EntryTypes[5]));
626         if( strcmp(entrytext,_("No")) ) temp=g_strdup_printf("%s,TS, noeigentest",temp);
627 
628         temp=g_strdup_printf("%s) ",temp);
629 	if(strstr(temp,"Opt()")) temp=g_strdup_printf("Opt ");
630 	if(strstr(temp,"Opt(,")) temp[4]=' ';
631 
632 	gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,"\n# ",-1);
633        	gabedit_text_insert (GABEDIT_TEXT(text),NULL,NULL,NULL,temp,-1);
634 
635 }
636 /*******************************************************************/
SaveGauss(GtkWidget * widget,gpointer data)637 void SaveGauss( GtkWidget *widget, gpointer   data )
638 {
639         save_as_doc();
640  	data_modify(FALSE);
641        	iedit=1;
642        	gabedit_text_set_editable(GABEDIT_TEXT(text), TRUE);
643 }
644 /*******************************************************************/
GetChargesAndMultiplicities()645 static void GetChargesAndMultiplicities( )
646 {
647   	G_CONST_RETURN gchar *entrytext;
648 
649         if(EntryCS[0]!=NULL)
650 	{
651   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[0]));
652         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
653         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
654 
655   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[1]));
656         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
657         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
658         }
659         if(EntryCS[2]!=NULL)
660 	{
661   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[2]));
662         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
663         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
664 
665   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[3]));
666         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
667         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
668 
669   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[2]));
670         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
671         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
672 
673   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[3]));
674         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
675         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
676         }
677         if(EntryCS[4]!=NULL)
678 	{
679   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[4]));
680         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
681         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
682 
683   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[5]));
684         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
685         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
686 
687   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[4]));
688         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
689         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
690 
691   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[5]));
692         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
693         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
694 
695   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[4]));
696         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
697         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
698 
699   		entrytext = gtk_entry_get_text(GTK_ENTRY(EntryCS[5]));
700         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,entrytext,-1);
701         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," \t",-1);
702         }
703 
704         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n",-1);
705 }
706 /*******************************************************************/
GetInfoZMatrix()707 static void GetInfoZMatrix( )
708 {
709   	guint i;
710   	gchar *line;
711 	SAtomsProp prop;
712 
713 	if(iframe==1) GetChargesAndMultiplicitiesFromMain( );
714 	else GetChargesAndMultiplicities( );
715 
716         if(GeomFromCheck)
717         {
718         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n",-1);
719 		return;
720         }
721 
722         for(i=0;i<NcentersZmat;i++)
723         {
724 		if(!amber)
725 			line=g_strdup_printf("%s",Geom[i].Symb);
726 		else
727   			line=g_strdup_printf("%s-%s-%s",
728 				Geom[i].Symb,Geom[i].mmType,Geom[i].Charge);
729 
730         	if(Geom[i].Nentry>NUMBER_ENTRY_0)
731   			line=g_strdup_printf("%s\t%s\t%s",line,Geom[i].NR,Geom[i].R);
732         	if(Geom[i].Nentry>NUMBER_ENTRY_R)
733   			line=g_strdup_printf("%s\t%s\t%s",line,Geom[i].NAngle,Geom[i].Angle);
734         	if(Geom[i].Nentry>NUMBER_ENTRY_ANGLE)
735   			line=g_strdup_printf("%s\t%s\t%s",line,Geom[i].NDihedral,Geom[i].Dihedral);
736   		if (strcmp(Geom[i].Layer," ") )
737   			line=g_strdup_printf("%s  0\t %s\n",line,Geom[i].Layer);
738 		else
739   			line=g_strdup_printf("%s\n",line);
740  		prop = prop_atom_get(Geom[i].Symb);
741         	gabedit_text_insert (GABEDIT_TEXT(text), NULL,NULL, &prop.color,line,-1);
742         }
743 
744 
745         if(NVariables>0)
746         for(i=0;i<NVariables;i++)
747         {
748         	if(Variables[i].Used)
749 		{
750         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"Variables :\n",-1);
751 			break;
752 		}
753         }
754         for(i=0;i<NVariables;i++)
755         {
756         	if(Variables[i].Used)
757 		{
758   			line=g_strdup_printf("%s\t%s\n",Variables[i].Name,Variables[i].Value);
759         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,line,-1);
760 		}
761         }
762 
763 
764         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n",-1);
765 
766 }
767 /*******************************************************************/
GetInfoXYZ()768 static void GetInfoXYZ( )
769 {
770   	guint i;
771   	gchar *line;
772 	SAtomsProp prop;
773 	gboolean medium = geometry_with_medium_layer();
774 	gboolean lower = geometry_with_lower_layer();
775 	gboolean redundant = TRUE;
776   	G_CONST_RETURN gchar *entrytext =  NULL;
777 	gint nV = 0;
778 	gint ivar0 = -1;
779 
780   	if(Types && strcmp(Types,_("Single Point"))) entrytext =  gtk_entry_get_text(GTK_ENTRY(EntryTypes[0]));
781 	if(entrytext && !strstr(entrytext,"Redundant") && !strstr(entrytext,"Default") && !strstr(entrytext,"default")) redundant = FALSE;
782 
783 	if(iframe==1) GetChargesAndMultiplicitiesFromMain( );
784 	else GetChargesAndMultiplicities( );
785 
786         if(GeomFromCheck)
787         {
788         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n",-1);
789 		return;
790 	}
791         if(VariablesXYZ && NVariablesXYZ>0)
792         for(i=0;i<NVariablesXYZ;i++) if(VariablesXYZ[i].Used) nV++;
793         if(nV<1 || nV== 3*NcentersXYZ) ivar0=0;
794 
795         for(i=0;i<NcentersXYZ;i++)
796         {
797 		if(!amber)
798 		{
799 			if(!redundant) line=g_strdup_printf("%s\t0\t%s\t%s\t%s", GeomXYZ[i].Symb,GeomXYZ[i].X,GeomXYZ[i].Y,GeomXYZ[i].Z);
800 			else
801 			{
802 				gchar X[100];
803 				gchar Y[100];
804 				gchar Z[100];
805 				gint ivar=ivar0;
806 				sprintf(X,"%s",GeomXYZ[i].X);
807 				sprintf(Y,"%s",GeomXYZ[i].Y);
808 				sprintf(Z,"%s",GeomXYZ[i].Z);
809 				if(!test(GeomXYZ[i].X))
810 				{
811 					ivar = 0;
812 					sprintf(X,"%0.10f",get_value_variableXYZ(GeomXYZ[i].X));
813 				}
814 				if(!test(GeomXYZ[i].Y))
815 				{
816 					ivar = 0;
817 					sprintf(Y,"%0.10f",get_value_variableXYZ(GeomXYZ[i].Y));
818 				}
819 				if(!test(GeomXYZ[i].Z))
820 				{
821 					ivar = 0;
822 					sprintf(Z,"%0.10f",get_value_variableXYZ(GeomXYZ[i].Z));
823 				}
824   				line=g_strdup_printf("%s\t%d\t%s\t%s\t%s", GeomXYZ[i].Symb,ivar,X,Y,Z);
825 			}
826 		}
827 		else
828 		{
829 			if(!redundant)
830   			line=g_strdup_printf("%s-%s-%s\t0\t%s\t%s\t%s",
831 				GeomXYZ[i].Symb,GeomXYZ[i].mmType,GeomXYZ[i].Charge,
832 				GeomXYZ[i].X,GeomXYZ[i].Y,GeomXYZ[i].Z);
833 			else
834 			{
835 				gchar X[100];
836 				gchar Y[100];
837 				gchar Z[100];
838 				gint ivar = -1;
839 				sprintf(X,"%s",GeomXYZ[i].X);
840 				sprintf(Y,"%s",GeomXYZ[i].Y);
841 				sprintf(Z,"%s",GeomXYZ[i].Z);
842 				if(!test(GeomXYZ[i].X))
843 				{
844 					ivar = 0;
845 					sprintf(X,"%0.10f",get_value_variableXYZ(GeomXYZ[i].X));
846 				}
847 				if(!test(GeomXYZ[i].Y))
848 				{
849 					ivar = 0;
850 					sprintf(Y,"%0.10f",get_value_variableXYZ(GeomXYZ[i].Y));
851 				}
852 				if(!test(GeomXYZ[i].Z))
853 				{
854 					ivar = 0;
855 					sprintf(Z,"%0.10f",get_value_variableXYZ(GeomXYZ[i].Z));
856 				}
857   				line=g_strdup_printf("%s-%s-%s\t%d\t%s\t%s\t%s",
858 				GeomXYZ[i].Symb,GeomXYZ[i].mmType,GeomXYZ[i].Charge,ivar,
859 				X,Y,Z);
860 			}
861 		}
862 
863   		if (strcmp(GeomXYZ[i].Layer," ") && (medium||lower) )
864 		{
865 			if(strstr(GeomXYZ[i].Layer,"Hi"))
866   				line=g_strdup_printf("%s\t %s\n",line,GeomXYZ[i].Layer);
867 			else
868 			{
869 				gint j;
870 				gint k=-1;
871         			for(j=0;j<NcentersXYZ;j++)
872 				{
873 					if(i==j) continue;
874 					if(strstr(GeomXYZ[j].Layer,"Lo")) continue;
875 					if(strstr(GeomXYZ[i].Layer,"Me")
876 						&& (strstr(GeomXYZ[j].Layer,"Me") || strstr(GeomXYZ[j].Layer,"Lo")) )
877 						continue;
878 
879 					if(connecteds(i,j))
880 					{
881 						k = j;
882 						break;
883 					}
884 				}
885 				if(k==-1)
886   					line=g_strdup_printf("%s\t %s\n",line,GeomXYZ[i].Layer);
887 				else
888 				{
889 					gchar tmp[100];
890 					sprintf(tmp,"H-H-0.1");
891 					if(!strcmp(GeomXYZ[k].mmType,"CA")) sprintf(tmp,"H-HA-0.170");
892 					if(!strcmp(GeomXYZ[k].mmType,"S")) sprintf(tmp,"H-H-0.1");
893 					if(!strcmp(GeomXYZ[k].mmType,"SH")) sprintf(tmp,"H-HS-0.1");
894 					if(!strcmp(GeomXYZ[k].mmType,"OH")) sprintf(tmp,"H-HO-0.440");
895 					if(!strcmp(GeomXYZ[k].mmType,"N")) sprintf(tmp,"H-H-0.275");
896 					if(!strcmp(GeomXYZ[k].mmType,"N2")) sprintf(tmp,"H-H-0.431");
897 					if(!strcmp(GeomXYZ[k].mmType,"NA")) sprintf(tmp,"H-H-0.431");
898 					if(!strcmp(GeomXYZ[k].Symb,"CT")) sprintf(tmp,"H-H?-0.033");
899 					if(!strcmp(GeomXYZ[k].mmType,"CR")) sprintf(tmp,"H-H5-0.06");
900 					if(!strcmp(GeomXYZ[k].mmType,"CK")) sprintf(tmp,"H-H5-0.06");
901 					if(!strcmp(GeomXYZ[k].mmType,"CW")) sprintf(tmp,"H-H4-0.229");
902 					if(!strcmp(GeomXYZ[k].mmType,"CM")) sprintf(tmp,"H-H4-0.229");
903 					if(!strcmp(GeomXYZ[k].mmType,"CV")) sprintf(tmp,"H-H4-0.229");
904   					line=g_strdup_printf("%s\t %s\t %s\t %d\n",line,GeomXYZ[i].Layer,tmp,k+1);
905 				}
906 			}
907 		}
908 		else
909   			line=g_strdup_printf("%s\n",line);
910  		prop = prop_atom_get(GeomXYZ[i].Symb);
911         	gabedit_text_insert (GABEDIT_TEXT(text), NULL,NULL, &prop.color,line,-1);
912         }
913         if(NVariablesXYZ>0 && !redundant)
914         for(i=0;i<NVariablesXYZ;i++)
915         {
916         	if(VariablesXYZ[i].Used)
917 		{
918         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,_("Variables :\n"),-1);
919 			break;
920 		}
921         }
922         if(NVariablesXYZ>0 && !redundant)
923         for(i=0;i<NVariablesXYZ;i++)
924         {
925         	if(VariablesXYZ[i].Used)
926 		{
927   			line=g_strdup_printf("%s\t%s\n",VariablesXYZ[i].Name,VariablesXYZ[i].Value);
928         		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,line,-1);
929 		}
930         }
931 
932         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n",-1);
933 
934 }
935 /*******************************************************************/
GetInfoUnits()936 void GetInfoUnits()
937 {
938  gchar *Tompon;
939  gchar *Destdiez;
940  gchar *DestdiezOld;
941  gchar *Enter;
942  guint Position;
943  gint nchar;
944  gchar *t;
945  gchar *t1;
946 
947  Tompon=gabedit_text_get_chars(text,0,-1);
948  nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
949  DestdiezOld = Tompon;
950  Destdiez = NULL;
951 
952  t = g_strdup("Units");
953  uppercase(t);
954  t1= g_strdup(Tompon);
955  uppercase(t1);
956  Destdiez = strstr( t1,t);
957 
958  if(Destdiez != NULL)
959  {
960 
961 	 Position = Destdiez - t1;
962          nchar = 0;
963 	 Enter = strstr( Destdiez, " ");
964          if( Enter == NULL || Enter > strstr( Destdiez, "\n") )
965           	Enter = strstr( Destdiez, "\n");
966          nchar = Enter - Destdiez ;
967  	 gabedit_text_set_point(GABEDIT_TEXT(text),Position);
968 	 gabedit_text_forward_delete(GABEDIT_TEXT(text),nchar);
969  	if(Units == 0)
970   		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"Units(Au,Deg)",-1);
971  	else
972   		gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"Units(Ang,Deg)",-1);
973  }
974  else
975  {
976  	nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
977  	Position = nchar;
978  	if(nchar != 0)
979  	{
980   		while(strlen(DestdiezOld)>0)
981   		{
982   			Destdiez = strstr( DestdiezOld, "#");
983   			if(Destdiez != NULL)
984   			{
985         			DestdiezOld = Destdiez+1;
986   				Enter = strstr( Destdiez, "\n");
987  				Position = Enter - Tompon+1 ;
988         			Destdiez = NULL;
989   			}
990   			else
991     				break;
992   		}
993  	}
994  gabedit_text_set_point(GABEDIT_TEXT(text),Position);
995  if(Units == 0)
996   gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"# Units(Au,Deg)\n",-1);
997  else
998   gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"# Units(Ang,Deg)\n",-1);
999  }
1000  nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
1001  gabedit_text_set_point(GABEDIT_TEXT(text),nchar);
1002  g_free(t);
1003  g_free(t1);
1004  g_free(Tompon);
1005 
1006 }
1007 /*******************************************************************/
GetInfoAll(GtkWidget * widget,gpointer data)1008 void GetInfoAll( GtkWidget *widget, gpointer   data )
1009 {
1010 	printf("iframe = %d\n",iframe);
1011 	if(iframe==1)
1012 	{
1013 		if(iinsert != 0)
1014 		{
1015 			reset_name_files();
1016 			ClearText(text);
1017 		}
1018 		else
1019 		{
1020 			GetLink1();
1021 		}
1022 		data_modify(TRUE);
1023 		GetInfoLink();
1024 
1025 		if(TestButtonActive(CheckButtons[4]) ) gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"#P ",-1);
1026 		else gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"# ",-1);
1027 
1028 		GetInfoMB();
1029 		GetInfoType();
1030 		GetInfoPFS();
1031 		GetInfoGene();
1032 		if(AddMP2) gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," MP2 ",-1);
1033 		GetInfoTitle();
1034 	}
1035 	else
1036 	if(iframe==2)
1037 	{
1038 		GetInfoUnits();
1039 		if( MethodeGeom == GEOM_IS_ZMAT) GetInfoZMatrix();
1040 		else if( MethodeGeom == GEOM_IS_XYZ) GetInfoXYZ();
1041 		GeomFromCheck = FALSE;
1042 	}
1043 	else
1044 	if(iframe==3)
1045 	{
1046         	GetInfoBasis();
1047 	}
1048 }
1049 /*******************************************************************/
putInfoAll(GtkWidget * Wins,gpointer data)1050 static void putInfoAll( GtkWidget *Wins, gpointer   data )
1051 {
1052 	if(iinsert != 0)
1053 	{
1054 		reset_name_files();
1055 		ClearText(text);
1056 	}
1057 	else
1058 	{
1059 		GetLink1();
1060 	}
1061 	data_modify(TRUE);
1062 	GetInfoLink();
1063 
1064 	if(TestButtonActive(CheckButtons[4]) ) gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"#P ",-1);
1065 	else gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"# ",-1);
1066 
1067 	GetInfoMB();
1068 	GetInfoType();
1069 	GetInfoPFS();
1070 	GetInfoGene();
1071 	if(AddMP2) gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," MP2 ",-1);
1072 	GetInfoTitle();
1073 	GetInfoUnits();
1074 	if( MethodeGeom == GEOM_IS_ZMAT) GetInfoZMatrix();
1075 	else if( MethodeGeom == GEOM_IS_XYZ) GetInfoXYZ();
1076 	GeomFromCheck = FALSE;
1077   	if(Wins) DestroyWinsGauss(Wins);
1078 }
1079 /*******************************************************************/
insert_gaussian(gint itype)1080 void insert_gaussian(gint itype)
1081 {
1082   GtkWidget *button;
1083   gint i;
1084 
1085   gtk_notebook_set_current_page((GtkNotebook*)NoteBookText,0);
1086 
1087   if(Wins) DestroyWinsGauss(Wins);
1088   iframe=itype;
1089   iinsert=0;
1090 
1091   fileopen.command=g_strdup(NameCommandGaussian);
1092   Wins= gtk_dialog_new ();
1093   gtk_window_set_position(GTK_WINDOW(Wins),GTK_WIN_POS_NONE);
1094   gtk_window_set_transient_for(GTK_WINDOW(Wins),GTK_WINDOW(Fenetre));
1095   gtk_window_set_title(&GTK_DIALOG(Wins)->window,_("Gaussian input"));
1096 
1097   init_child(Wins,DestroyWinsGauss,_(" Gauss input "));
1098   g_signal_connect(G_OBJECT(Wins),"delete_event",(GCallback)destroy_children,NULL);
1099 
1100   NoteBook = gtk_notebook_new();
1101   gtk_box_pack_start(GTK_BOX (GTK_DIALOG(Wins)->vbox), NoteBook,FALSE, FALSE, 0);
1102   switch(iframe)
1103          {
1104           case 2:
1105                 i=iframe;
1106                 if(GeomIsOpen && TypeGeomOpen !=0 )
1107                 {
1108                       if(WindowGeom)
1109 			gtk_widget_destroy(WindowGeom);
1110                 }
1111                 WindowGeom = Wins;
1112 		GAjoutePageGeom(NoteBook);
1113                 iframe = i;
1114                 TypeGeomOpen = 2;
1115                   break;
1116           case 3:
1117 		GAjoutePageBasis(NoteBook);
1118                 if(TypeGeomOpen == 2)
1119                 {
1120  		     geom_is_not_open();
1121                      TypeGeomOpen = 0;
1122                      WindowGeom = NULL;
1123                 }
1124                 break;
1125          }
1126 	iedit=1;
1127 
1128   gtk_box_set_homogeneous (GTK_BOX( GTK_DIALOG(Wins)->action_area), FALSE);
1129 
1130 
1131   gtk_widget_realize(Wins);
1132 
1133   button = create_button(Wins,"Cancel");
1134   gtk_box_pack_end (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, FALSE, TRUE, 5);
1135   g_signal_connect_swapped(G_OBJECT(button), "clicked",G_CALLBACK(to_cancel_win),GTK_OBJECT(Wins));
1136   GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1137   gtk_widget_show (button);
1138 
1139   button = create_button(Wins,"OK");
1140   gtk_box_pack_end (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, FALSE, TRUE, 5);
1141   GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1142   gtk_widget_grab_default(button);
1143   gtk_widget_show (button);
1144   g_signal_connect(G_OBJECT(button), "clicked", (GCallback)GetInfoAll,NULL);
1145   g_signal_connect(G_OBJECT(button), "clicked", (GCallback)data_modify,NULL);
1146   g_signal_connect_swapped(G_OBJECT(button), "clicked",G_CALLBACK(destroy_children),GTK_OBJECT(Wins));
1147 
1148 
1149   gtk_widget_show_all(Wins);
1150 
1151 }
1152 
1153 /*******************************************************************/
gauss(gint ioption)1154 void gauss(gint ioption)
1155 {
1156 	GtkWidget *button;
1157 
1158 	if(
1159 		(MethodeGeom == GEOM_IS_XYZ && NcentersXYZ<1) ||
1160 		(MethodeGeom == GEOM_IS_ZMAT && NcentersZmat<1)  ||
1161 		(MethodeGeom != GEOM_IS_XYZ && MethodeGeom != GEOM_IS_ZMAT)
1162 	)
1163 	{
1164 		Message(
1165 			_(
1166 			"You must initially define your geometry.\n\n"
1167 			"From the principal Menu select : Geometry/Draw\n"
1168 			"and draw (or read) your molecule."),
1169 			_("Error"),TRUE);
1170 		return;
1171 	}
1172 
1173 	if(Wins) DestroyWinsGauss(Wins);
1174 	fileopen.command=g_strdup(NameCommandGaussian);
1175 
1176 	iframe=1;
1177 	AddMP2=FALSE;
1178 	AddConical=FALSE;
1179 
1180 	if(!ioption) iinsert = 0;
1181 	else iinsert = 1;
1182 	gtk_notebook_set_current_page((GtkNotebook*)NoteBookText,0);
1183 
1184 	Wins= gtk_dialog_new ();
1185 	gtk_window_set_position(GTK_WINDOW(Wins),GTK_WIN_POS_NONE);
1186 	gtk_window_set_transient_for(GTK_WINDOW(Wins),GTK_WINDOW(Fenetre));
1187 	gtk_window_set_title(&GTK_DIALOG(Wins)->window,_("Gaussian input"));
1188 
1189 
1190 	init_child(Wins,DestroyWinsGauss,_(" Gauss input "));
1191 	g_signal_connect(G_OBJECT(Wins),"delete_event",(GCallback)destroy_children,NULL);
1192 
1193 	NoteBook = gtk_notebook_new();
1194 	gtk_box_pack_start(GTK_BOX (GTK_DIALOG(Wins)->vbox), NoteBook,TRUE, TRUE, 0);
1195 
1196 	GAjoutePageRouteMain(NoteBook,Wins);
1197 	GAjoutePageRouteOptions(NoteBook,Wins);
1198 
1199 	gtk_widget_realize(Wins);
1200 	gtk_box_set_homogeneous (GTK_BOX( GTK_DIALOG(Wins)->action_area), TRUE);
1201 
1202 	button = create_button(Wins,_("Cancel"));
1203 	GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1204 	gtk_box_pack_start (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, TRUE, TRUE, 0);
1205 	g_signal_connect_swapped(G_OBJECT(button),"clicked",G_CALLBACK(to_cancel_win),GTK_OBJECT(Wins));
1206 	gtk_widget_show (button);
1207 
1208 	button = create_button(Wins,_("OK"));
1209 	g_signal_connect(G_OBJECT(button), "clicked", (GCallback)putInfoAll,NULL);
1210 	gtk_box_pack_end (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, TRUE, TRUE, 0);
1211 	GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1212 	gtk_widget_grab_default(button);
1213 	gtk_widget_show (button);
1214 
1215 	gtk_widget_show_all(Wins);
1216 	if(iinsert != 0)
1217 	{
1218   		gtk_widget_hide (CheckButtons[7]);
1219   		gtk_widget_hide (CheckButtons[8]);
1220 	}
1221 	else
1222 	{
1223   		GTK_TOGGLE_BUTTON (CheckButtons[7])->active=TRUE;
1224   		GTK_TOGGLE_BUTTON (CheckButtons[8])->active=TRUE;
1225 	}
1226 	GeomFromCheck = FALSE;
1227 }
1228