1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
/* GamessGuess.c */
/**********************************************************************************************************
Copyright (c) 2002-2012 Abdul-Rahman Allouche. All rights reserved
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the Gabedit), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
************************************************************************************************************/
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include "../../Config.h"
#include "../Common/Global.h"
#include "../Gamess/GamessTypes.h"
#include "../Gamess/GamessGlobal.h"
#include "../Utils/Utils.h"
#include "../Utils/UtilsInterface.h"
#include "../Utils/GabeditTextEdit.h"
#include "../Common/Windows.h"
#include "../Utils/Constants.h"
static GtkWidget *buttonPrintGuess = NULL;
static GtkWidget *buttonRotate = NULL;
static GtkWidget *guessFrame = NULL;
/*************************************************************************************************************/
static gchar* listGuessMethodView[] = { "Huckel", "Core" };
static gchar* listGuessMethodReal[] = { "NONE", "GUESS=HCORE" };
static guint numberOfGuessMethods = G_N_ELEMENTS (listGuessMethodView);
static gchar selectedGuessMethod[BSIZE]="NONE";
/*************************************************************************************************************/
void initGamessGuessFrame()
{
guessFrame = NULL;
}
/*************************************************************************************************************/
void setSensitiveGamessGuessFrame(gboolean sensitive)
{
if(!guessFrame) return;
gtk_widget_set_sensitive(guessFrame, sensitive);
}
/*************************************************************************************************************/
static void putGamessGuessOptionsInfoInTextEditor()
{
if(!GTK_TOGGLE_BUTTON (buttonPrintGuess)->active
&& !GTK_TOGGLE_BUTTON (buttonRotate)->active) return;
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$GUESS",-1);
if(GTK_TOGGLE_BUTTON (buttonPrintGuess)->active)
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " PRTMO=.TRUE.",-1);
if(GTK_TOGGLE_BUTTON (buttonRotate)->active)
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " MIX=.TRUE.",-1);
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
}
/************************************************************************************************************/
static void putGamessGuessMethodInfoInTextEditor()
{
if( strcmp(selectedGuessMethod,"NONE")==0 ) return;
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$GUESS",-1);
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedGuessMethod,-1);
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
gabedit_text_insert (GABEDIT_TEXT(text), NULL, &gamessColorFore.keyWord, &gamessColorBack.keyWord, "$END\n",-1);
}
/*************************************************************************************************************/
void putGamessGuessInfoInTextEditor()
{
putGamessGuessMethodInfoInTextEditor();
putGamessGuessOptionsInfoInTextEditor();
}
/************************************************************************************************************/
static void traitementGuessMethod (GtkComboBox *combobox, gpointer d)
{
GtkTreeIter iter;
gchar* data = NULL;
gchar* res = NULL;
gint i;
/* gchar* s;*/
if (gtk_combo_box_get_active_iter (combobox, &iter))
{
GtkTreeModel* model = gtk_combo_box_get_model(combobox);
gtk_tree_model_get (model, &iter, 0, &data, -1);
}
for(i=0;i<numberOfGuessMethods;i++)
{
if(strcmp((gchar*)data,listGuessMethodView[i])==0) res = listGuessMethodReal[i];
}
if(res) sprintf(selectedGuessMethod,"%s",res);
else sprintf(selectedGuessMethod,"MINI");
/* for(s=selectedGuessMethod;*s != 0;s++) *s = toupper(*s);*/
}
/********************************************************************************************************/
static GtkWidget *create_list_guessmethods()
{
GtkTreeIter iter;
GtkTreeStore *store;
GtkTreeModel *model;
GtkWidget *combobox;
GtkCellRenderer *renderer;
gint i;
GtkTreeIter iter0;
store = gtk_tree_store_new (1,G_TYPE_STRING);
for(i=0;i<numberOfGuessMethods;i++)
{
gtk_tree_store_append (store, &iter, NULL);
if(i==0) iter0 = iter;
gtk_tree_store_set (store, &iter, 0, listGuessMethodView[i], -1);
}
model = GTK_TREE_MODEL (store);
combobox = gtk_combo_box_new_with_model (model);
/*
gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
*/
g_object_unref (model);
g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementGuessMethod), NULL);
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
return combobox;
}
/************************************************************************************************************/
void createGamessGuessFrame(GtkWidget *win, GtkWidget *box)
{
GtkWidget* frame;
GtkWidget* vboxFrame;
GtkWidget* sep;
GtkWidget* combo = NULL;
gint l=0;
gint c=0;
gint ncases=1;
GtkWidget *table = gtk_table_new(4,3,FALSE);
buttonPrintGuess = NULL;
buttonRotate = NULL;
frame = gtk_frame_new (_("Mo Guess"));
guessFrame = frame;
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 3);
gtk_frame_set_label_align (GTK_FRAME (frame), 0.5, 0.5);
vboxFrame = gtk_vbox_new (FALSE, 3);
gtk_widget_show (vboxFrame);
gtk_container_add (GTK_CONTAINER (frame), vboxFrame);
gtk_box_pack_start (GTK_BOX (vboxFrame), table, TRUE, TRUE, 0);
/*------------------ Guess Method -----------------------------------------*/
l=0;
c = 0; ncases=1;
add_label_table(table,_("Initial Guess"),l,c);
c = 1; ncases=1;
add_label_table(table,":",l,c);
combo = create_list_guessmethods();
c = 2; ncases=1;
gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
(GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL | GTK_SHRINK),
2,2);
/*------------------ separator -----------------------------------------*/
l++;
sep = gtk_hseparator_new ();;
c = 0; ncases=3;
gtk_table_attach(GTK_TABLE(table),sep,c,c+ncases,l,l+1,
(GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL | GTK_SHRINK),
2,2);
/*------------------ Print Orbs L ------------*/
l++;
c = 0; ncases=3;
buttonPrintGuess = gtk_check_button_new_with_label (_("Print the initial Guess"));
gtk_table_attach(GTK_TABLE(table),buttonPrintGuess,c,c+ncases,l,l+1,
(GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL | GTK_SHRINK),
2,2);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (buttonPrintGuess), FALSE);
/*------------------ Mix ------------*/
l++;
c = 0; ncases=3;
buttonRotate = gtk_check_button_new_with_label (_("Rotate alpha and beta orbitals"));
gtk_table_attach(GTK_TABLE(table),buttonRotate,c,c+ncases,l,l+1,
(GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL | GTK_SHRINK),
2,2);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (buttonRotate), FALSE);
}
|