1 /* Molcas.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 "../Molcas/MolcasTypes.h"
24 #include "../Molcas/MolcasGlobal.h"
25 #include "../Molcas/MolcasVariables.h"
26 #include "../Molcas/MolcasOptimization.h"
27 #include "../Molcas/MolcasGateWay.h"
28 #include "../Molcas/MolcasSeward.h"
29 #include "../Molcas/MolcasScf.h"
30 #include "../Molcas/MolcasGridIT.h"
31 #include "../Utils/UtilsInterface.h"
32 #include "../Geometry/GeomGlobal.h"
33 #include "../Geometry/InterfaceGeom.h"
34 #include "../Utils/Utils.h"
35 #include "../Utils/AtomsProp.h"
36 #include "../Utils/Constants.h"
37 #include "../Utils/GabeditTextEdit.h"
38
39 static GtkWidget *Wins=NULL;
40 static gboolean newFile = FALSE;
41 /************************************************************************************************************/
setColors()42 static void setColors()
43 {
44 static gboolean first = TRUE;
45
46 if(!first) return;
47 first = FALSE;
48
49 molcasColorFore.program.red = 65535;
50 molcasColorFore.program.green = 0;
51 molcasColorFore.program.blue = 0;
52
53 molcasColorBack.program.red = (gushort)(65535/1.2);
54 molcasColorBack.program.green = (gushort)(65535/1.2);
55 molcasColorBack.program.blue = (gushort)(65535/1.2);
56
57 molcasColorFore.shellCommand.red = 0;
58 molcasColorFore.shellCommand.green = 65535;
59 molcasColorFore.shellCommand.blue = 65535;
60
61 molcasColorBack.shellCommand.red = (gushort)(65535/2.0);
62 molcasColorBack.shellCommand.green = (gushort)(65535/2.0);
63 molcasColorBack.shellCommand.blue = (gushort)(65535/2.0);
64
65 molcasColorFore.internCommand.red = 0;
66 molcasColorFore.internCommand.green = 65535;
67 molcasColorFore.internCommand.blue = 0;
68
69 molcasColorBack.internCommand.red = (gushort)(65535/2.0);
70 molcasColorBack.internCommand.green = (gushort)(65535/2.0);
71 molcasColorBack.internCommand.blue = (gushort)(65535/2.0);
72
73 molcasColorFore.subProgram.red = 65535;
74 molcasColorFore.subProgram.green = 0;
75 molcasColorFore.subProgram.blue = 65535;
76
77 }
78 /************************************************************************************************************/
destroyWinsMolcas(GtkWidget * win)79 void destroyWinsMolcas(GtkWidget *win)
80 {
81 destroy(Wins,NULL);
82 Wins = NULL;
83 initGateWayButtons();
84 }
85 /************************************************************************************************************/
toCancelWin(GtkWidget * win,gpointer data)86 static void toCancelWin(GtkWidget* win,gpointer data)
87 {
88 Cancel_YesNo(win,data, destroy_children);
89 }
90 /************************************************************************************************************/
putTitleInTextEditor()91 static void putTitleInTextEditor()
92 {
93 gchar buffer[BSIZE];
94
95 sprintf(buffer,"*================================================================\n");
96 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, buffer,-1);
97
98 sprintf(buffer,"* File made in Gabedit\n");
99 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, buffer,-1);
100
101 sprintf(buffer,"*================================================================\n");
102 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, buffer,-1);
103
104 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, "\n",-1);
105 }
106 /************************************************************************************************************/
putInfoInTextEditor(GtkWidget * button,gpointer data)107 static void putInfoInTextEditor(GtkWidget *button, gpointer data)
108 {
109 setColors();
110 if(newFile)
111 {
112 reset_name_files();
113 ClearText(text);
114 }
115 else
116 {
117 gint nchar;
118 nchar=gabedit_text_get_length(GABEDIT_TEXT(text));
119 gabedit_text_set_point(GABEDIT_TEXT(text),nchar);
120 }
121 data_modify(TRUE);
122
123 putTitleInTextEditor();
124 putVariablesInTextEditor();
125
126 putBeginOptimizationInTextEditor();
127
128 putGateWayInfoInTextEditor();
129 putSewardInfoInTextEditor();
130 putScfInfoInTextEditor();
131
132
133 putEndOptimizationInTextEditor();
134
135 putGridITInfoInTextEditor();
136
137 iprogram = PROG_IS_MOLCAS;
138 gtk_notebook_set_current_page((GtkNotebook*)NoteBookText,0);
139 }
140 /*********************************************************************************************/
addHboxToTable(GtkWidget * table,gint i,gint j,gint ki,gint kj)141 static GtkWidget* addHboxToTable(GtkWidget* table, gint i, gint j, gint ki, gint kj)
142 {
143 GtkWidget *hbox = gtk_hbox_new(TRUE, 5);
144
145 gtk_table_attach(GTK_TABLE(table),hbox,j,j+kj,i,i+ki,
146 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
147 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
148 3,3);
149
150 return hbox;
151 }
152 /************************************************************************************************************/
molcasInputFileWindow(gboolean newInputFile)153 static void molcasInputFileWindow(gboolean newInputFile)
154 {
155 GtkWidget *button;
156 GtkWidget *hbox = NULL;
157
158 GtkWidget *table = gtk_table_new(4,2,FALSE);
159
160 fileopen.command=g_strdup(NameCommandMolcas);
161 newFile = newInputFile;
162 setMolcasMolecule();
163 freeMolcasOptimization();
164
165 if(molcasMolecule.numberOfAtoms <1)
166 {
167 Message(
168 _(
169 "You must initially define your geometry.\n\n"
170 "From the principal Menu select : Geometry/Draw\n"
171 "and draw (or read) your molecule.")
172 , _("Error"),TRUE);
173 return;
174 }
175
176 if(Wins) destroy_children(Wins);
177
178 Wins= gtk_dialog_new ();
179 gtk_window_set_position(GTK_WINDOW(Wins),GTK_WIN_POS_CENTER);
180 gtk_window_set_transient_for(GTK_WINDOW(Wins),GTK_WINDOW(Fenetre));
181 gtk_window_set_title(>K_DIALOG(Wins)->window,_("Molcas input"));
182
183 init_child(Wins, destroyWinsMolcas,_(" Molcas input "));
184 g_signal_connect(G_OBJECT(Wins),"delete_event",(GCallback)destroy_children,NULL);
185
186 gtk_widget_realize(Wins);
187
188 button = create_button(Wins,_("Cancel"));
189 gtk_box_pack_start (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, FALSE, TRUE, 5);
190 g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK( toCancelWin),GTK_OBJECT(Wins));
191 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
192 gtk_widget_show (button);
193
194
195
196 button = create_button(Wins,_("OK"));
197
198 gtk_box_pack_start (GTK_BOX( GTK_DIALOG(Wins)->vbox), table, FALSE, TRUE, 5);
199
200 hbox =addHboxToTable(table, 0, 0, 2, 1);
201 createSystemVariablesFrame(Wins, hbox, button);
202
203 hbox =addHboxToTable(table, 0, 1, 1, 1);
204 createOptimizationFrame(Wins, hbox);
205
206 hbox =addHboxToTable(table, 1, 1, 1, 1);
207 createSymmetryFrame(Wins, hbox);
208
209 hbox =addHboxToTable(table, 2, 0, 1, 2);
210 createSolvationFrame(Wins, hbox);
211
212 hbox =addHboxToTable(table, 3, 0, 2, 3);
213 createScfFrame(Wins, hbox, button);
214
215 gtk_box_pack_start (GTK_BOX( GTK_DIALOG(Wins)->action_area), button, FALSE, TRUE, 5);
216 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
217 gtk_widget_grab_default(button);
218 gtk_widget_show (button);
219 g_signal_connect_swapped(G_OBJECT(button), "clicked",G_CALLBACK(putInfoInTextEditor),GTK_OBJECT(Wins));
220 g_signal_connect_swapped(G_OBJECT(button), "clicked",G_CALLBACK(destroy_children),GTK_OBJECT(Wins));
221
222
223 gtk_widget_show_all(Wins);
224 molcasWin = Wins;
225 }
226 /************************************************************************************************************/
newMolcas()227 void newMolcas()
228 {
229 molcasInputFileWindow(TRUE);
230 }
231 /************************************************************************************************************/
insertMolcas()232 void insertMolcas()
233 {
234 molcasInputFileWindow(FALSE);
235 }
236