00001 #include <gtk/gtk.h>
00002 #include "vapiGtkInterface.h"
00003 #include "vapiGtkAux.h"
00004 #include "vapiAux.h"
00005 #include "vapiGtkAuxWindow.h"
00006 #include "vapiGtkWindowSelectOperation.h"
00007 #include "vapiOperationList.h"
00008 #include "vapiGroups.h"
00009 #include "vapiCameraSettings.h"
00010 #include "vapiGtkSetOriginWindow.h"
00011 #include "vapiGtkWindowIOAdd.h"
00012 #include "vapiGtkWindowIOConfigure.h"
00013 #include "vapiGtkImages.h"
00014 #include "vapiGtkMacrosTables.h"
00015 #include "vapiGtkMacroItemMove.h"
00016 #include "vapiGtkEventsMacros.h"
00017 #include "vapiGtkMessages.h"
00018
00019
00020
00021
00022
00023 int
00024 interface_os_linux (vOperationList * OperationList,
00025 vGroupList * GroupList,
00026 vCameraSettings * CameraSettings,
00027 vMacroList * MacroList, vImages * Images, GladeXML * xml)
00028 {
00029
00030 vapiWidgetStruct *Widgets = malloc (sizeof (vapiWidgetStruct));
00031 vapiGtkWindowSelectGroupStruct *GroupStruct =
00032 malloc (sizeof (vapiGtkWindowSelectGroupStruct));
00033 static char *vapiAuthors;
00034
00035
00036
00037 GtkWidget *MainWindow;
00038 GtkWidget *AboutDialog;
00039 GtkWidget *imCalibrateExample;
00040 GtkWidget *vBoxOperationGroups;
00041 GtkWidget *AboutButton;
00042 GError *error = NULL;
00043
00044 vapiAuthors = "Luis Matos";
00045
00046 GroupStruct->OperationList = OperationList;
00047 GroupStruct->GroupButtonList = NULL;
00048
00049
00050
00051
00052
00053 vapi_loading_progress ("A Carregar Elementos da Interface");
00054
00055 Widgets->imActual = glade_xml_get_widget (xml, "imActual");
00056 Widgets->imWork = glade_xml_get_widget (xml, "imWork");
00057 Widgets->imOriginal = glade_xml_get_widget (xml, "imOriginal");
00058
00059 Widgets->cbCam = glade_xml_get_widget (xml, "cbCam");
00060
00061 Widgets->txtMacroName = glade_xml_get_widget (xml, "txtMacroName");
00062
00063 Widgets->txtOptItemName =
00064 glade_xml_get_widget (xml, "txtOptItemName");
00065 Widgets->txtOptItemNum = glade_xml_get_widget (xml, "txtOptItemNum");
00066 Widgets->OptionsParent = glade_xml_get_widget (xml, "vbox6");
00067 Widgets->cbImageFile = glade_xml_get_widget (xml, "cbImageFile");
00068 Widgets->rbMenuCasosCamara = glade_xml_get_widget (xml, "rbCamara");
00069 Widgets->rbMenuCasosFusiveis =
00070 glade_xml_get_widget (xml, "rbFusiveis");
00071 Widgets->rbMenuCasosComprimidos =
00072 glade_xml_get_widget (xml, "rbComprimidos");
00073 Widgets->rbMenuCasosOCR = glade_xml_get_widget (xml, "rbOCR");
00074
00075 Widgets->ImageWindowTemplate =
00076 glade_xml_get_widget (xml, "ImageWindowTemplate");
00077 Widgets->imSelectTemplate =
00078 glade_xml_get_widget (xml, "imSelectTemplate");
00079 Widgets->ImageWindow = glade_xml_get_widget (xml, "ImageWindow");
00080 Widgets->imShowOriginalSize =
00081 glade_xml_get_widget (xml, "imShowOriginalSize");
00082 Widgets->ImageWindowSelectRegion =
00083 glade_xml_get_widget (xml, "ImageWindowSelectRegion");
00084 Widgets->imSelectRegion =
00085 glade_xml_get_widget (xml, "imSelectRegion");
00086 Widgets->txtOperation = glade_xml_get_widget (xml, "txtOperation");
00087 MainWindow = glade_xml_get_widget (xml, "main_window");
00088 imCalibrateExample = glade_xml_get_widget (xml, "imCalibrateExample");
00089 vBoxOperationGroups =
00090 glade_xml_get_widget (xml, "vBoxOperationGroups");
00091 GroupStruct->OperationTreeView =
00092 glade_xml_get_widget (xml, "tvSelectOperation");
00093
00094 GroupStruct->txtOperationDescription =
00095 glade_xml_get_widget (xml, "txtOperationDescription");
00096 GroupStruct->stSelectOperation = (GtkStatusbar *)
00097 glade_xml_get_widget (xml, "stSelectOperation");
00098 GroupStruct->nbOptions = glade_xml_get_widget (xml, "nbOptions");
00099 GroupStruct->txtOperation = Widgets->txtOperation;
00100 GroupStruct->winSelectOperation =
00101 glade_xml_get_widget (xml, "winSelectOperation");
00102 GroupStruct->btSelectOperation =
00103 glade_xml_get_widget (xml, "btSelectOperation");
00104 AboutButton = glade_xml_get_widget (xml, "sobre1");
00105 Widgets->winCreateMacro =
00106 glade_xml_get_widget (xml, "winCreateMacro");
00107
00108
00109
00110
00111
00112 vapi_loading_progress ("A Configurar Elementos");
00113 vapiGtkErrorDialogInit (xml);
00114
00115
00116
00117
00118
00119
00120
00121 vapi_loading_progress
00122 ("A Criar a Janela Com informção sobre o Vapi");
00123 AboutDialog = vapiGtkAboutDialog ();
00124
00125 g_signal_connect (G_OBJECT (AboutButton), "activate",
00126 G_CALLBACK (showWidget), AboutDialog);
00127
00128 g_signal_connect (G_OBJECT (AboutDialog), "delete-event",
00129 G_CALLBACK (gtk_widget_hide_on_delete),
00130 AboutDialog);
00131
00132
00133
00134
00135
00136
00137
00138 gtk_tool_button_set_stock_id ((GtkToolButton *) Widgets->cbCam, NULL);
00139 gtk_tool_button_set_icon_widget ((GtkToolButton *) Widgets->cbCam,
00140 gtk_image_new_from_file
00141 ("./pixmaps/camera-video.png"));
00142 gtk_image_set_from_file ((GtkImage *) imCalibrateExample,
00143 "pixmaps/exemplo_calibrate.png");
00144
00145 gtk_widget_show (gtk_tool_button_get_icon_widget
00146 ((GtkToolButton *) Widgets->cbCam));
00147
00148 vapiGtkWindowCalibrateCameraDefines (xml);
00149
00150
00151
00152
00153 if (!g_thread_supported ())
00154 {
00155 g_thread_init (NULL);
00156 }
00157 vapiGtkImagesThreadsInit (Widgets->imOriginal, Widgets->imActual,
00158 Widgets->imWork, Images);
00159
00160 #ifdef VAPI_OS_LINUX
00161
00162 gdk_threads_init ();
00163 #endif
00164
00165 vapiGtkConnectEvents (Widgets, Images, CameraSettings,
00166 OperationList, MacroList, xml);
00167
00168
00169
00170 vapiGtkWindowIOAddInit (xml);
00171
00172 vapiGtkWindowIOConfigureInit (xml);
00173 Widgets->OptionsList = NULL;
00174 Widgets->OptionsData = NULL;
00175 Widgets->OptionsEvents = NULL;
00176 vapiGtkEventsMacrosInit (xml, MacroList, OperationList, Images,
00177 &Widgets->OptionsData);
00178 vapiGtkMacrosTablesInit (xml, MacroList, &Widgets->OptionsList,
00179 &Widgets->OptionsData,
00180 &Widgets->OptionsEvents, Images);
00181 vapiGtkCbMacroStart ();
00182 vapiGtkMacroItemMoveInit (xml, MacroList);
00183
00184
00185
00186 vapi_loading_progress ("A Criar a interface Principal");
00187 gtk_window_set_icon_from_file ((GtkWindow *) MainWindow,
00188 "pixmaps/logo.svg", &error);
00189 gtk_widget_show_all (MainWindow);
00190 gtk_widget_grab_focus (LoadScreen);
00191 vapi_loading_progress ("A Agrupar as Operações");
00192
00193
00194 vapiGtkSelectOperationStartWindow (GroupList, GroupStruct,
00195 vBoxOperationGroups);
00196
00197
00198
00199 vapi_loading_progress ("A Carregar as Imagens na interface");
00200
00201 vapiGtkPutImage (Widgets->imOriginal, Images->Original);
00202 vapiGtkPutImage (Widgets->imWork, Images->Actual);
00203 vapiGtkPutImage (Widgets->imActual, Images->Actual);
00204
00205
00206
00207
00208 vapi_loading_progress
00209 ("A questionar a Existência de Pré-configuração");
00210 vapiGtkSetOriginWindowInit (xml, CameraSettings, Images);
00211
00212 vapi_loading_progress ("Aplicação Iniciada.");
00213
00214
00215
00216
00217 gtk_main ();
00218
00219
00220 return 0;
00221
00222 }
00223
00229 GladeXML *
00230 vapiGtkLoadInterface ()
00231 {
00232
00233 GladeXML *xml;
00234
00235 gtk_init (NULL, NULL);
00236
00237
00238
00239
00240
00241 xml = glade_xml_new ("./src/interface/interface_gtk.glade",
00242 NULL, NULL);
00243
00244
00245
00246 vapiGtkMessagesInit (xml);
00247
00248
00249
00250
00251
00252
00253 glade_xml_signal_autoconnect (xml);
00254
00255 return xml;
00256
00257 }
00258
00259 GtkWidget *
00260 vapiGtkAboutDialog ()
00261 {
00262 GtkWidget *AboutDialog;
00263 GdkPixbuf *pixbuf;
00264 GError *error = NULL;
00265 const gchar *Authors[] = { "Luis Matos <a26652@alunos.mec.ua.pt>",
00266 "Orientado por:",
00267 "Eng. AbÃlio Borges <aborges@atena-ai.pt>",
00268 "Eng. VÃtor Santos <vsantos@mec.ua.pt>", NULL
00269 };
00270
00271 AboutDialog = gtk_about_dialog_new ();
00272 gtk_window_set_position ((GtkWindow *) AboutDialog,
00273 GTK_WIN_POS_CENTER_ALWAYS);
00274 gtk_about_dialog_set_name ((GtkAboutDialog *) AboutDialog, "Vapi");
00275 gtk_about_dialog_set_authors ((GtkAboutDialog *) AboutDialog,
00276 Authors);
00277 gtk_about_dialog_set_comments ((GtkAboutDialog *) AboutDialog,
00278 "Visão Artificial Para a Indústria");
00279 gtk_about_dialog_set_copyright ((GtkAboutDialog *)
00280 AboutDialog,
00281 "ATENA - Automação Industrial \n e \n Departamento de Engenharia Mecânica \n da Universidade de Aveiro");
00282 gtk_about_dialog_set_version ((GtkAboutDialog *) AboutDialog,
00283 VAPI_VERSION);
00284 gtk_about_dialog_set_website ((GtkAboutDialog *) AboutDialog,
00285 "www.mec.ua.pt");
00286 pixbuf = gdk_pixbuf_new_from_file ("./pixmaps/logo.png", &error);
00287
00288 gtk_about_dialog_set_logo ((GtkAboutDialog *) AboutDialog, pixbuf);
00289 return AboutDialog;
00290 }