1 /* OrcaGuess.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 "../Orca/OrcaTypes.h"
28 #include "../Orca/OrcaGlobal.h"
29 #include "../Orca/OrcaBasis.h"
30 #include "../Utils/Utils.h"
31 #include "../Utils/UtilsInterface.h"
32 #include "../Utils/GabeditTextEdit.h"
33 #include "../Common/Windows.h"
34 #include "../Utils/Constants.h"
35
36 static GtkWidget *guessFrame = NULL;
37 /*************************************************************************************************************/
38 static gchar* listGuessMethodView[] = {
39 "Default",
40 "PATOM : polarized atoms guess",
41 "PMODEL : model potential guess",
42 "HUECKEL : extended Huckel guess",
43 "HCORE : one-electron matrix guess",
44 };
45 static gchar* listGuessMethodReal[] = {
46 "NONE",
47 "PATOM",
48 "PMODEL",
49 "HUECKEL",
50 "HCORE",
51
52 };
53 static guint numberOfGuessMethods = G_N_ELEMENTS (listGuessMethodView);
54 static gchar selectedGuessMethod[BSIZE]="NONE";
55 /*************************************************************************************************************/
initOrcaGuessFrame()56 void initOrcaGuessFrame()
57 {
58 guessFrame = NULL;
59 }
60 /*************************************************************************************************************/
putOrcaGuessOptionsInfoInTextEditor()61 static void putOrcaGuessOptionsInfoInTextEditor()
62 {
63 }
64 /************************************************************************************************************/
putOrcaGuessMethodInfoInTextEditor()65 static void putOrcaGuessMethodInfoInTextEditor()
66 {
67 if( strcmp(selectedGuessMethod,"NONE")==0 ) return;
68 {
69 gchar buffer[BSIZE];
70 sprintf(buffer," %s ",selectedGuessMethod);
71 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, buffer,-1);
72 }
73 }
74 /*************************************************************************************************************/
putOrcaGuessInfoInTextEditor()75 void putOrcaGuessInfoInTextEditor()
76 {
77 putOrcaGuessMethodInfoInTextEditor();
78 putOrcaGuessOptionsInfoInTextEditor();
79
80 }
81 /************************************************************************************************************/
traitementGuessMethod(GtkComboBox * combobox,gpointer d)82 static void traitementGuessMethod (GtkComboBox *combobox, gpointer d)
83 {
84 GtkTreeIter iter;
85 gchar* data = NULL;
86 gchar* res = NULL;
87 gint i;
88
89
90 /* gchar* s;*/
91 if (gtk_combo_box_get_active_iter (combobox, &iter))
92 {
93 GtkTreeModel* model = gtk_combo_box_get_model(combobox);
94 gtk_tree_model_get (model, &iter, 0, &data, -1);
95 }
96 for(i=0;i<numberOfGuessMethods;i++)
97 {
98 if(strcmp((gchar*)data,listGuessMethodView[i])==0) res = listGuessMethodReal[i];
99 }
100 if(res) sprintf(selectedGuessMethod,"%s",res);
101 else sprintf(selectedGuessMethod,"Default");
102
103 }
104 /********************************************************************************************************/
create_list_guessmethods()105 static GtkWidget *create_list_guessmethods()
106 {
107 GtkTreeIter iter;
108 GtkTreeStore *store;
109 GtkTreeModel *model;
110 GtkWidget *combobox;
111 GtkCellRenderer *renderer;
112 gint i;
113 GtkTreeIter iter0;
114
115 store = gtk_tree_store_new (1,G_TYPE_STRING);
116
117 for(i=0;i<numberOfGuessMethods;i++)
118 {
119 gtk_tree_store_append (store, &iter, NULL);
120 if(i==0) iter0 = iter;
121 gtk_tree_store_set (store, &iter, 0, listGuessMethodView[i], -1);
122 }
123
124 model = GTK_TREE_MODEL (store);
125 combobox = gtk_combo_box_new_with_model (model);
126 /*
127 gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
128 */
129 g_object_unref (model);
130 g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementGuessMethod), NULL);
131 renderer = gtk_cell_renderer_text_new ();
132 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
133 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
134
135 gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
136
137 return combobox;
138 }
139 /************************************************************************************************************/
createOrcaGuessFrame(GtkWidget * win,GtkWidget * box)140 void createOrcaGuessFrame(GtkWidget *win, GtkWidget *box)
141 {
142 GtkWidget* frame;
143 GtkWidget* vboxFrame;
144 GtkWidget* sep;
145 GtkWidget* combo = NULL;
146 gint l=0;
147 gint c=0;
148 gint ncases=1;
149 GtkWidget *table = gtk_table_new(4,3,FALSE);
150
151 frame = gtk_frame_new (_("Mo Guess"));
152 guessFrame = frame;
153 gtk_widget_show (frame);
154 gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 3);
155 gtk_frame_set_label_align (GTK_FRAME (frame), 0.5, 0.5);
156
157 vboxFrame = gtk_vbox_new (FALSE, 3);
158 gtk_widget_show (vboxFrame);
159 gtk_container_add (GTK_CONTAINER (frame), vboxFrame);
160 gtk_box_pack_start (GTK_BOX (vboxFrame), table, TRUE, TRUE, 0);
161
162 /*------------------ Guess Method -----------------------------------------*/
163 l=0;
164 c = 0; ncases=1;
165 add_label_table(table,_("Initial Guess"),l,c);
166 c = 1; ncases=1;
167 add_label_table(table,":",l,c);
168 combo = create_list_guessmethods();
169 c = 2; ncases=1;
170 gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
171 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
172 (GtkAttachOptions) (GTK_FILL | GTK_SHRINK),
173 2,2);
174 /*------------------ separator -----------------------------------------*/
175 l++;
176 sep = gtk_hseparator_new ();
177 c = 0; ncases=3;
178 gtk_table_attach(GTK_TABLE(table),sep,c,c+ncases,l,l+1,
179 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
180 (GtkAttachOptions) (GTK_FILL | GTK_SHRINK),
181 2,2);
182
183 }
184