1 /* GamessBasis.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 #include <stdlib.h>
21 #include <ctype.h>
22 #include <math.h>
23 #include <string.h>
24 
25 #include "../../Config.h"
26 #include "../Common/Global.h"
27 #include "../Gamess/GamessTypes.h"
28 #include "../Gamess/GamessGlobal.h"
29 #include "../Utils/Utils.h"
30 #include "../Utils/UtilsInterface.h"
31 #include "../Utils/GabeditTextEdit.h"
32 #include "../Common/Windows.h"
33 #include "../Utils/Constants.h"
34 
35 static GtkWidget *buttonDiffuseL = NULL;
36 static GtkWidget *buttonDiffuseS = NULL;
37 static GtkWidget *basisFrame = NULL;
38 static GtkWidget *comboBasisType = NULL;
39 /*************************************************************************************************************/
40 static gchar* listBasisSetView[] = {
41                             "MINI", "MIDI", "STO-2G", "STO-3G", "STO-4G", "STO-5G", "STO-6G",
42                             "3-21G", "6-21G", "4-31G", "5-31G", "6-31G", "6-311G", "Double Zeta Valance",
43                             "Dunning/Hay DZ", "Triple Zeta Valance", "Mclean/Chandler", "SBKJC Valance",
44                             "Hay/Wadt Valance",
45 			    "cc-pVDz","cc-pVTz","cc-pVQz","cc-pV5z","cc-pV6z",
46 			    "aug-cc-pVDz","aug-cc-pVTz","aug-cc-pVQz","aug-cc-pV5z","aug-cc-pV6z",
47 			    "cc-pCVDz","cc-pCVTz","cc-pCVQz","cc-pCV5z","cc-pCV6z",
48 			    "aug-cc-pCVDz","aug-cc-pCVTz","aug-cc-pCVQz","aug-cc-pCV5z","aug-cc-pCV6z",
49 			    "PC0","PC1","PC2","PC3","PC4",
50 			    "APC0","APC1","APC2","APC3","APC4"
51 };
52 static gchar* listBasisSetReal[] = {
53 	"GBASIS=MINI", "GBASIS=MIDI", "GBASIS=STO NGAUSS=2", "GBASIS=STO NGAUSS=3", "GBASIS=STO NGAUSS=4",
54 	"GBASIS=STO NGAUSS=5", "GBASIS=STO NGAUSS=6",
55 	"GBASIS=N21 NGAUSS=3", "GBASIS=N21 NGAUSS=6",
56 	"GBASIS=N31 NGAUSS=4", "GBASIS=N31 NGAUSS=5",
57 	"GBASIS=N31 NGAUSS=6", "GBASIS=N311 NGAUSS=6",
58 	"GBASIS=DZV", "GBASIS=DH", "GBASIS=TZV", "GBASIS=MC",
59 	"GBASIS=SBKJC",
60 	"GBASIS=HW",
61 	"GBASIS=CCD", "GBASIS=CCT", "GBASIS=CCQ", "GBASIS=CC5", "GBASIS=CC6",
62 	"GBASIS=ACCD", "GBASIS=ACCT", "GBASIS=ACCQ", "GBASIS=ACC5", "GBASIS=ACC6",
63 	"GBASIS=CCDC", "GBASIS=CCTC", "GBASIS=CCQC", "GBASIS=CC5C", "GBASIS=CC6C",
64 	"GBASIS=ACCDC", "GBASIS=ACCTC", "GBASIS=ACCQC", "GBASIS=ACC5C", "GBASIS=ACC6C",
65 	"GBASIS=PC0","GBASIS=PC1","GBASIS=PC2","GBASIS=PC3","GBASIS=PC4",
66 	"GBASIS=APC0","GBASIS=APC1","GBASIS=APC2","GBASIS=APC3","GBASIS=APC4"
67 
68 };
69 static guint numberOfBasisSet = G_N_ELEMENTS (listBasisSetView);
70 static gchar selectedBasisSet[BSIZE]="MINI";
71 /*************************************************************************************************************/
72 static gchar* listBasisTypeView[] = { N_("Default"),"Cartezian", "Spherical" };
73 static gchar* listBasisTypeReal[] = { "NONE","ISPHER=0", "ISPHER=1" };
74 static guint numberOfBasisType = G_N_ELEMENTS (listBasisTypeView);
75 static gchar selectedBasisType[BSIZE]="NONE";
76 /*************************************************************************************************************/
77 static gchar* listBasisDPolView[] = {  "0","1", "2","3"};
78 static gchar* listBasisDPolReal[] = {  "NONE","NDFUNC=1", "NDFUNC=2","NDFUNC=3" };
79 static guint numberOfBasisDPol = G_N_ELEMENTS (listBasisDPolView);
80 static gchar selectedBasisDPol[BSIZE]="NONE";
81 /*************************************************************************************************************/
82 static gchar* listBasisFPolView[] = {  "0","1"};
83 static gchar* listBasisFPolReal[] = {  "NONE","NFFUNC=1"};
84 static guint numberOfBasisFPol = G_N_ELEMENTS (listBasisFPolView);
85 static gchar selectedBasisFPol[BSIZE]="NONE";
86 /*************************************************************************************************************/
87 static gchar* listBasisPPolView[] = {  "0","1", "2","3"};
88 static gchar* listBasisPPolReal[] = {  "NONE","NPFUNC=1", "NPFUNC=2","NPFUNC=3" };
89 static guint numberOfBasisPPol = G_N_ELEMENTS (listBasisPPolView);
90 static gchar selectedBasisPPol[BSIZE]="NONE";
91 /*************************************************************************************************************/
92 static gchar* listBasisPolarView[] = {  N_("Default"),"Pople", "Pople N311","Dunning","Huzinaga","Hondo7"};
93 static gchar* listBasisPolarReal[] = {  "NONE","POLAR=POPLE", "POLAR=POPN311","POLAR=DUNNING","POLAR=HUZINAGA","POLAR=HONDO7" };
94 static guint numberOfBasisPolar = G_N_ELEMENTS (listBasisPolarView);
95 static gchar selectedBasisPolar[BSIZE]="NONE";
96 /*************************************************************************************************************/
initGamessBasisFrame()97 void initGamessBasisFrame()
98 {
99 	basisFrame = NULL;
100 }
101 /*************************************************************************************************************/
setSensitiveGamessBasisFrame(gboolean sensitive)102 void setSensitiveGamessBasisFrame(gboolean sensitive)
103 {
104 	if(!basisFrame) return;
105 	gtk_widget_set_sensitive(basisFrame, sensitive);
106 }
107 /*************************************************************************************************************/
putGamessBasisDiffuseFunctions()108 static void putGamessBasisDiffuseFunctions()
109 {
110 	if(!GTK_TOGGLE_BUTTON (buttonDiffuseL)->active
111 	   && !GTK_TOGGLE_BUTTON (buttonDiffuseS)->active) return;
112         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
113         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$BASIS",-1);
114 	if(GTK_TOGGLE_BUTTON (buttonDiffuseL)->active)
115         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " DIFFSP=.TRUE.",-1);
116 	if(GTK_TOGGLE_BUTTON (buttonDiffuseS)->active)
117         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " DIFFS=.TRUE.",-1);
118 
119         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
120         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
121 }
122 /************************************************************************************************************/
putGamessBasisPolInfoInTextEditor()123 static void putGamessBasisPolInfoInTextEditor()
124 {
125 	gchar* s=NULL;
126 	if(
127 		strcmp(selectedBasisDPol,"NONE")==0
128 	     && strcmp(selectedBasisPPol,"NONE")==0
129 	     && strcmp(selectedBasisPPol,"NONE")==0
130 	     && strcmp(selectedBasisPolar,"NONE")==0
131 	 ) return;
132         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
133         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$BASIS",-1);
134 	s=selectedBasisDPol;
135 	if(strcmp(s,"NONE")!=0)
136 	{
137         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
138         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, s,-1);
139 	}
140 	s=selectedBasisFPol;
141 	if(strcmp(s,"NONE")!=0)
142 	{
143         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
144         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, s,-1);
145 	}
146 	s=selectedBasisPPol;
147 	if(strcmp(s,"NONE")!=0)
148 	{
149         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
150         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, s,-1);
151 	}
152 	s=selectedBasisPolar;
153 	if(strcmp(s,"NONE")!=0)
154 	{
155         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
156         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, s,-1);
157 	}
158         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
159         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
160 }
161 /*************************************************************************************************************/
putGamessBasisSetInfoInTextEditor()162 static void putGamessBasisSetInfoInTextEditor()
163 {
164         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
165         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$BASIS",-1);
166         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
167         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedBasisSet,-1);
168         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
169         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
170 	if(strcmp(selectedBasisSet,"GBASIS=SBKJC")==0)
171 	{
172         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
173         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
174         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ECP=SBKJC",-1);
175         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
176         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
177 	}
178 	if(strcmp(selectedBasisSet,"GBASIS=HW")==0)
179 	{
180         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
181         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
182         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ECP=HW",-1);
183         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
184         	gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
185 	}
186 }
187 /*************************************************************************************************************/
putGamessBasisTypeInfoInTextEditor()188 static void putGamessBasisTypeInfoInTextEditor()
189 {
190 	if(strcmp(selectedBasisType,"NONE")==0)return;
191         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
192         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$CONTRL",-1);
193         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
194         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedBasisType,-1);
195         gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
196         gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
197 }
198 /*************************************************************************************************************/
putGamessBasisInfoInTextEditor()199 void putGamessBasisInfoInTextEditor()
200 {
201 	putGamessBasisSetInfoInTextEditor();
202 	putGamessBasisTypeInfoInTextEditor();
203 	putGamessBasisPolInfoInTextEditor();
204 	putGamessBasisDiffuseFunctions();
205 }
206 /************************************************************************************************************/
setGamessBasisType()207 static void setGamessBasisType()
208 {
209 	GtkTreeIter iter;
210 
211 	if (!comboBasisType) return;
212 	if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX(comboBasisType), &iter)) return;
213 	if (comboBasisType && GTK_IS_COMBO_BOX(comboBasisType))
214 	{
215 		if(strstr(selectedBasisSet,"CC") || strstr(selectedBasisSet,"PC") )
216 			gtk_combo_box_set_active(GTK_COMBO_BOX(comboBasisType), 2);
217 		else
218 			gtk_combo_box_set_active(GTK_COMBO_BOX(comboBasisType), 0);
219 	}
220 }
221 /************************************************************************************************************/
traitementBasisSet(GtkComboBox * combobox,gpointer d)222 static void traitementBasisSet (GtkComboBox *combobox, gpointer d)
223 {
224 	GtkTreeIter iter;
225 	gchar* data = NULL;
226 	gchar* res = NULL;
227 	gint i;
228 	/* gchar* s;*/
229 	if (gtk_combo_box_get_active_iter (combobox, &iter))
230 	{
231 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
232 		gtk_tree_model_get (model, &iter, 0, &data, -1);
233 	}
234 	for(i=0;i<numberOfBasisSet;i++)
235 	{
236 		if(strcmp((gchar*)data,listBasisSetView[i])==0) res = listBasisSetReal[i];
237 	}
238 	if(res) sprintf(selectedBasisSet,"%s",res);
239 	else  sprintf(selectedBasisSet,"MINI");
240 	setGamessBasisType();
241 
242 	/* for(s=selectedBasisSet;*s != 0;s++) *s = toupper(*s);*/
243 }
244 /********************************************************************************************************/
create_list_basisset()245 static GtkWidget *create_list_basisset()
246 {
247         GtkTreeIter iter;
248         GtkTreeStore *store;
249 	GtkTreeModel *model;
250 	GtkWidget *combobox;
251 	GtkCellRenderer *renderer;
252 	gint i;
253         GtkTreeIter iter0;
254 
255 	store = gtk_tree_store_new (1,G_TYPE_STRING);
256 
257 	for(i=0;i<numberOfBasisSet;i++)
258 	{
259         	gtk_tree_store_append (store, &iter, NULL);
260 		if(i==0) iter0 = iter;
261         	gtk_tree_store_set (store, &iter, 0, listBasisSetView[i], -1);
262 	}
263 
264         model = GTK_TREE_MODEL (store);
265 	combobox = gtk_combo_box_new_with_model (model);
266 	/*
267 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
268 	*/
269 	g_object_unref (model);
270 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementBasisSet), NULL);
271 	renderer = gtk_cell_renderer_text_new ();
272 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
273 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
274 
275 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
276 
277 	return combobox;
278 }
279 /************************************************************************************************************/
traitementBasisType(GtkComboBox * combobox,gpointer d)280 static void traitementBasisType (GtkComboBox *combobox, gpointer d)
281 {
282 	GtkTreeIter iter;
283 	gchar* data = NULL;
284 	gchar* res = NULL;
285 	gint i;
286 	/* gchar* s;*/
287 	if (gtk_combo_box_get_active_iter (combobox, &iter))
288 	{
289 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
290 		gtk_tree_model_get (model, &iter, 0, &data, -1);
291 	}
292 	for(i=0;i<numberOfBasisType;i++)
293 	{
294 		if(strcmp((gchar*)data,listBasisTypeView[i])==0) res = listBasisTypeReal[i];
295 	}
296 	if(res) sprintf(selectedBasisType,"%s",res);
297 	else  sprintf(selectedBasisType,"NONE");
298 
299 	/* for(s=selectedBasisType;*s != 0;s++) *s = toupper(*s);*/
300 }
301 /********************************************************************************************************/
create_list_basistype()302 static GtkWidget *create_list_basistype()
303 {
304         GtkTreeIter iter;
305         GtkTreeStore *store;
306 	GtkTreeModel *model;
307 	GtkWidget *combobox;
308 	GtkCellRenderer *renderer;
309 	gint i;
310         GtkTreeIter iter0;
311 
312 	store = gtk_tree_store_new (1,G_TYPE_STRING);
313 
314 	for(i=0;i<numberOfBasisType;i++)
315 	{
316         	gtk_tree_store_append (store, &iter, NULL);
317 		if(i==0) iter0 = iter;
318         	gtk_tree_store_set (store, &iter, 0, listBasisTypeView[i], -1);
319 	}
320 
321         model = GTK_TREE_MODEL (store);
322 	combobox = gtk_combo_box_new_with_model (model);
323 	/*
324 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
325 	*/
326 	g_object_unref (model);
327 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementBasisType), NULL);
328 	renderer = gtk_cell_renderer_text_new ();
329 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
330 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
331 
332 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
333 
334 	return combobox;
335 }
336 /************************************************************************************************************/
traitementBasisDPol(GtkComboBox * combobox,gpointer d)337 static void traitementBasisDPol (GtkComboBox *combobox, gpointer d)
338 {
339 	GtkTreeIter iter;
340 	gchar* data = NULL;
341 	gchar* res = NULL;
342 	gint i;
343 	/* gchar* s;*/
344 	if (gtk_combo_box_get_active_iter (combobox, &iter))
345 	{
346 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
347 		gtk_tree_model_get (model, &iter, 0, &data, -1);
348 	}
349 	for(i=0;i<numberOfBasisDPol;i++)
350 	{
351 		if(strcmp((gchar*)data,listBasisDPolView[i])==0) res = listBasisDPolReal[i];
352 	}
353 	if(res) sprintf(selectedBasisDPol,"%s",res);
354 	else  sprintf(selectedBasisDPol,"NONE");
355 
356 	/* for(s=selectedBasisDPol;*s != 0;s++) *s = toupper(*s);*/
357 }
358 /********************************************************************************************************/
create_list_BasisDPol()359 static GtkWidget *create_list_BasisDPol()
360 {
361         GtkTreeIter iter;
362         GtkTreeStore *store;
363 	GtkTreeModel *model;
364 	GtkWidget *combobox;
365 	GtkCellRenderer *renderer;
366 	gint i;
367         GtkTreeIter iter0;
368 
369 	store = gtk_tree_store_new (1,G_TYPE_STRING);
370 
371 	for(i=0;i<numberOfBasisDPol;i++)
372 	{
373         	gtk_tree_store_append (store, &iter, NULL);
374 		if(i==0) iter0 = iter;
375         	gtk_tree_store_set (store, &iter, 0, listBasisDPolView[i], -1);
376 	}
377 
378         model = GTK_TREE_MODEL (store);
379 	combobox = gtk_combo_box_new_with_model (model);
380 	/*
381 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
382 	*/
383 	g_object_unref (model);
384 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementBasisDPol), NULL);
385 	renderer = gtk_cell_renderer_text_new ();
386 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
387 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
388 
389 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
390 
391 	return combobox;
392 }
393 /************************************************************************************************************/
traitementBasisFPol(GtkComboBox * combobox,gpointer d)394 static void traitementBasisFPol (GtkComboBox *combobox, gpointer d)
395 {
396 	GtkTreeIter iter;
397 	gchar* data = NULL;
398 	gchar* res = NULL;
399 	gint i;
400 	/* gchar* s;*/
401 	if (gtk_combo_box_get_active_iter (combobox, &iter))
402 	{
403 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
404 		gtk_tree_model_get (model, &iter, 0, &data, -1);
405 	}
406 	for(i=0;i<numberOfBasisFPol;i++)
407 	{
408 		if(strcmp((gchar*)data,listBasisFPolView[i])==0) res = listBasisFPolReal[i];
409 	}
410 	if(res) sprintf(selectedBasisFPol,"%s",res);
411 	else  sprintf(selectedBasisFPol,"NONE");
412 
413 	/* for(s=selectedBasisFPol;*s != 0;s++) *s = toupper(*s);*/
414 }
415 /********************************************************************************************************/
create_list_BasisFPol()416 static GtkWidget *create_list_BasisFPol()
417 {
418         GtkTreeIter iter;
419         GtkTreeStore *store;
420 	GtkTreeModel *model;
421 	GtkWidget *combobox;
422 	GtkCellRenderer *renderer;
423 	gint i;
424         GtkTreeIter iter0;
425 
426 	store = gtk_tree_store_new (1,G_TYPE_STRING);
427 
428 	for(i=0;i<numberOfBasisFPol;i++)
429 	{
430         	gtk_tree_store_append (store, &iter, NULL);
431 		if(i==0) iter0 = iter;
432         	gtk_tree_store_set (store, &iter, 0, listBasisFPolView[i], -1);
433 	}
434 
435         model = GTK_TREE_MODEL (store);
436 	combobox = gtk_combo_box_new_with_model (model);
437 	/*
438 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
439 	*/
440 	g_object_unref (model);
441 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementBasisFPol), NULL);
442 	renderer = gtk_cell_renderer_text_new ();
443 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
444 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
445 
446 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
447 
448 	return combobox;
449 }
450 /************************************************************************************************************/
traitementBasisPPol(GtkComboBox * combobox,gpointer d)451 static void traitementBasisPPol (GtkComboBox *combobox, gpointer d)
452 {
453 	GtkTreeIter iter;
454 	gchar* data = NULL;
455 	gchar* res = NULL;
456 	gint i;
457 	/* gchar* s;*/
458 	if (gtk_combo_box_get_active_iter (combobox, &iter))
459 	{
460 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
461 		gtk_tree_model_get (model, &iter, 0, &data, -1);
462 	}
463 	for(i=0;i<numberOfBasisPPol;i++)
464 	{
465 		if(strcmp((gchar*)data,listBasisPPolView[i])==0) res = listBasisPPolReal[i];
466 	}
467 	if(res) sprintf(selectedBasisPPol,"%s",res);
468 	else  sprintf(selectedBasisPPol,"NONE");
469 
470 	/* for(s=selectedBasisPPol;*s != 0;s++) *s = toupper(*s);*/
471 }
472 /********************************************************************************************************/
create_list_BasisPPol()473 static GtkWidget *create_list_BasisPPol()
474 {
475         GtkTreeIter iter;
476         GtkTreeStore *store;
477 	GtkTreeModel *model;
478 	GtkWidget *combobox;
479 	GtkCellRenderer *renderer;
480 	gint i;
481         GtkTreeIter iter0;
482 
483 	store = gtk_tree_store_new (1,G_TYPE_STRING);
484 
485 	for(i=0;i<numberOfBasisPPol;i++)
486 	{
487         	gtk_tree_store_append (store, &iter, NULL);
488 		if(i==0) iter0 = iter;
489         	gtk_tree_store_set (store, &iter, 0, listBasisPPolView[i], -1);
490 	}
491 
492         model = GTK_TREE_MODEL (store);
493 	combobox = gtk_combo_box_new_with_model (model);
494 	/*
495 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
496 	*/
497 	g_object_unref (model);
498 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementBasisPPol), NULL);
499 	renderer = gtk_cell_renderer_text_new ();
500 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
501 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
502 
503 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
504 
505 	return combobox;
506 }
507 /************************************************************************************************************/
traitementBasisPolar(GtkComboBox * combobox,gpointer d)508 static void traitementBasisPolar (GtkComboBox *combobox, gpointer d)
509 {
510 	GtkTreeIter iter;
511 	gchar* data = NULL;
512 	gchar* res = NULL;
513 	gint i;
514 	/* gchar* s;*/
515 	if (gtk_combo_box_get_active_iter (combobox, &iter))
516 	{
517 		GtkTreeModel* model = gtk_combo_box_get_model(combobox);
518 		gtk_tree_model_get (model, &iter, 0, &data, -1);
519 	}
520 	for(i=0;i<numberOfBasisPolar;i++)
521 	{
522 		if(strcmp((gchar*)data,listBasisPolarView[i])==0) res = listBasisPolarReal[i];
523 	}
524 	if(res) sprintf(selectedBasisPolar,"%s",res);
525 	else  sprintf(selectedBasisPolar,"NONE");
526 
527 	/* for(s=selectedBasisPolar;*s != 0;s++) *s = toupper(*s);*/
528 }
529 /********************************************************************************************************/
create_list_BasisPolar()530 static GtkWidget *create_list_BasisPolar()
531 {
532         GtkTreeIter iter;
533         GtkTreeStore *store;
534 	GtkTreeModel *model;
535 	GtkWidget *combobox;
536 	GtkCellRenderer *renderer;
537 	gint i;
538         GtkTreeIter iter0;
539 
540 	store = gtk_tree_store_new (1,G_TYPE_STRING);
541 
542 	for(i=0;i<numberOfBasisPolar;i++)
543 	{
544         	gtk_tree_store_append (store, &iter, NULL);
545 		if(i==0) iter0 = iter;
546         	gtk_tree_store_set (store, &iter, 0, listBasisPolarView[i], -1);
547 	}
548 
549         model = GTK_TREE_MODEL (store);
550 	combobox = gtk_combo_box_new_with_model (model);
551 	/*
552 	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
553 	*/
554 	g_object_unref (model);
555 	g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementBasisPolar), NULL);
556 	renderer = gtk_cell_renderer_text_new ();
557 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
558 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
559 
560 	gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
561 
562 	return combobox;
563 }
564 /************************************************************************************************************/
createGamessBasisFrame(GtkWidget * win,GtkWidget * box)565 void createGamessBasisFrame(GtkWidget *win, GtkWidget *box)
566 {
567 	GtkWidget* frame;
568 	GtkWidget* vboxFrame;
569 	GtkWidget* sep;
570 	GtkWidget* combo = NULL;
571 	gint l=0;
572 	gint c=0;
573 	gint ncases=1;
574 	GtkWidget *table = gtk_table_new(9,3,FALSE);
575 
576 	buttonDiffuseL = NULL;
577 	buttonDiffuseS = NULL;
578 	comboBasisType = NULL;
579 
580 	frame = gtk_frame_new (_("Basis"));
581 	basisFrame = frame;
582 	gtk_widget_show (frame);
583 	gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 3);
584 	gtk_frame_set_label_align (GTK_FRAME (frame), 0.5, 0.5);
585 
586 	vboxFrame = gtk_vbox_new (FALSE, 3);
587 	gtk_widget_show (vboxFrame);
588 	gtk_container_add (GTK_CONTAINER (frame), vboxFrame);
589 	gtk_box_pack_start (GTK_BOX (vboxFrame), table, TRUE, TRUE, 0);
590 
591 	/*------------------ Basis set -----------------------------------------*/
592 	l=0;
593 	c = 0; ncases=1;
594 	add_label_table(table,_("Basis set"),l,c);
595 	c = 1; ncases=1;
596 	add_label_table(table,":",l,c);
597 	combo = create_list_basisset();
598 	c = 2; ncases=1;
599 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
600 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
601 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
602                   2,2);
603 	/*------------------ Basis set -----------------------------------------*/
604 	l++;
605 	c = 0; ncases=1;
606 	add_label_table(table,_("Type"),l,c);
607 	c = 1; ncases=1;
608 	add_label_table(table,":",l,c);
609 	combo = create_list_basistype();
610 	comboBasisType = combo;
611 	c = 2; ncases=1;
612 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
613 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
614 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
615                   2,2);
616 	/*------------------ separator -----------------------------------------*/
617 	l++;
618 	sep = gtk_hseparator_new ();;
619 	c = 0; ncases=3;
620 	gtk_table_attach(GTK_TABLE(table),sep,c,c+ncases,l,l+1,
621 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
622 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
623                   2,2);
624 	/*------------------ #D heavy atom polarization functions ------------*/
625 	l++;
626 	c = 0; ncases=1;
627 	add_label_table(table,_("#D heavy atom polarization functions"),l,c);
628 	c = 1; ncases=1;
629 	add_label_table(table,":",l,c);
630 	combo = create_list_BasisDPol();
631 	c = 2; ncases=1;
632 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
633 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
634 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
635                   2,2);
636 	/*------------------ #F heavy atom polarization functions ------------*/
637 	l++;
638 	c = 0; ncases=1;
639 	add_label_table(table,_("#F heavy atom polarization functions"),l,c);
640 	c = 1; ncases=1;
641 	add_label_table(table,":",l,c);
642 	combo = create_list_BasisFPol();
643 	c = 2; ncases=1;
644 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
645 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
646 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
647                   2,2);
648 	/*------------------ ##light atom polarization functions ------------*/
649 	l++;
650 	c = 0; ncases=1;
651 	add_label_table(table,_("#light atom polarization functions"),l,c);
652 	c = 1; ncases=1;
653 	add_label_table(table,":",l,c);
654 	combo = create_list_BasisPPol();
655 	c = 2; ncases=1;
656 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
657 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
658 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
659                   2,2);
660 	/*------------------ Polar ------------*/
661 	l++;
662 	c = 0; ncases=1;
663 	add_label_table(table,_("Polar"),l,c);
664 	c = 1; ncases=1;
665 	add_label_table(table,":",l,c);
666 	combo = create_list_BasisPolar();
667 	c = 2; ncases=1;
668 	gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
669 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
670 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
671                   2,2);
672 	/*------------------ Diifuse L ------------*/
673 	l++;
674 	c = 0; ncases=3;
675 	buttonDiffuseL = gtk_check_button_new_with_label (_("Diffuse L-shell on heavy atoms"));
676 	gtk_table_attach(GTK_TABLE(table),buttonDiffuseL,c,c+ncases,l,l+1,
677 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
678 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
679                   2,2);
680 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (buttonDiffuseL), FALSE);
681 	/*------------------ Diifuse S ------------*/
682 	l++;
683 	c = 0; ncases=3;
684 	buttonDiffuseS = gtk_check_button_new_with_label (_("Diffuse s-shell on hydrogens "));
685 	gtk_table_attach(GTK_TABLE(table),buttonDiffuseS,c,c+ncases,l,l+1,
686 		(GtkAttachOptions)	(GTK_FILL | GTK_EXPAND),
687 		(GtkAttachOptions)	(GTK_FILL | GTK_SHRINK),
688                   2,2);
689 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (buttonDiffuseS), FALSE);
690 }
691