src/vapi.c

Ir para a documentação deste ficheiro.
00001 #include <stdio.h>
00002 #include <cv.h>
00003 #include <cvaux.h>
00004 #include <highgui.h>
00005 #include "vapi.h"
00006 #include "vapiLists.h"
00007 #include "vapiAux.h"
00008 #include "vapiMacro.h"
00009 #include "vapiIOList.h"
00010 #include "vapiIOXML.h"
00011 #include "vapiIOData.h"
00012 #include "vapiImages.h"
00013 #include "vapiImagesAux.h"
00014 #include "vapiCameraSettings.h"
00015 #include "vapiMacroXML.h"
00016 #include "vapiOperationList.h"
00017 #include "vapiGroups.h"
00018 #include "vapiOperationsData.h"
00019 #include "vapiCameraAcquisition.h"
00020 #include <stdlib.h>
00021 #ifndef VAPI_WITHOUT_INTERFACE
00022 #include <gtk/gtk.h>
00023 #include <glade/glade.h>
00024 #include "vapiGtkInterface.h"   /* temporário, deveremos mudar o nome */
00025 #include "vapiGtkAux.h"
00026 #endif
00027 
00028 static void
00029 vapiParseCommandOptions (int argc, char *argv[],
00030                          vCameraSettings * CameraSettings);
00031 
00045 int
00046 main (int argc, char *argv[])
00047 {
00048         int a;
00049         vOperationList *OperationList;
00050         vGroupList *GroupList;
00051         vCameraSettings *CameraSettings;
00052         vMacroList *MacroList;
00053         vImages *Images;
00054 
00055 #ifndef VAPI_WITHOUT_INTERFACE
00056         /*
00057          * Este código serve para iniciar a Brra de Progressos Quando
00058          *  temos interface gráfica.
00059          */
00060         GladeXML *xml;
00061         GtkWidget *imSplashLogo;
00062 
00063         /*
00064          * Carregar a interface
00065          */
00066         xml = vapiGtkLoadInterface ();
00067         LoadScreen = glade_xml_get_widget (xml, "LoadScreen");
00068         LoadScreenProgress = glade_xml_get_widget (xml, "LoadScreenProgress");
00069         LoadScreenMessage = glade_xml_get_widget (xml, "LoadScreenMessage");
00070         imSplashLogo = glade_xml_get_widget (xml, "imSplashLogo");
00071         gtk_widget_show_all (LoadScreen);
00072         gtk_image_set_from_file ((GtkImage *) imSplashLogo,
00073                                  "pixmaps/splash_logo.png");
00074 #endif
00075         /*
00076          * Para a barra de estado no splash, temos:
00077          *  .Iniciar lista de operações.
00078          *  .Iniciar Lista de Macros.
00079          *  .Carregar Handle de Câmara.
00080          *  .Carregar Imagens de trabalho
00081          *  .Carregar Interface:
00082          *   - Carregar Elementos (widgets).
00083          *   - Configurar Elementos
00084          *   - Definir estruturas Auxiliares
00085          *   - Definir Eventos
00086          *   - Mostrar a interface
00087          *   - Carregar as Imagens na interface
00088          */
00089         MainLoadDone = vFALSE;
00090         vapi_loading_progress ("A iniciar lista de Operações");
00091 
00092         GroupList = vapiGroupListNew ();
00093         vapiGroupListAddItem (GroupList, "Todas");
00094         OperationList = vapiOperationListInit(GroupList);
00095         vapiLoadAllOperations();
00096 
00097 
00098         vapi_loading_progress ("A iniciar Lista de Macros");
00099 
00100         MacroList = vapiMacroListNew ();
00101         /*
00102          * Carregar Macros Exemplo.
00103          */
00104         vapi_loading_progress ("A Carregar Macros de Exemplo");
00105         vapiLoadExampleMacros (MacroList, OperationList);
00106 
00107 
00108         vapi_loading_progress ("A Carregar Imagens da Câmara");
00109         Images = vImagesGlobalInit ();
00110 
00111         /*
00112          * Definir a Camara
00113          */
00114         vapiGlobalCameraSettingsInit ();
00115         CameraSettings = vapiCameraSettingsRetrieveGlobal ();
00116         vapiParseCommandOptions (argc, argv, CameraSettings);
00117 
00118         HaveAcquisitionLoadingProgress = vTRUE;
00119         vapiGetSnapshot (Images, CameraSettings);
00120         vapiOriginal2Actual (Images);
00121 
00122         /*
00123          * Carregar Definições de Periféricos
00124          */
00125 
00126         /* Criar Lista de Hardware */
00127 
00128         GlobalIOList = vapiIOListNew ();
00129         GlobalIOGroups = vapiGroupListNew ();
00130         vapiGroupListAddItem (GlobalIOGroups, "Todos");
00131         vapiIORegisterSupportedHw ();
00132         vapiIOListAddGroup (GlobalIOList, GlobalIOGroups);
00133 
00134 
00135         /*
00136          * Criar lista de hardware préviamente configurado.
00137          * FIXME: Deve ser carregado de XML hw préviamente configurado.
00138          */
00139         GlobalIOListConfigured = vapiIOListConfiguredNew ();
00140 
00141         vapiIOConfiguredListFromXML ();
00142 
00143         /*
00144          * Iniciar a interface
00145          */
00146 
00147         vapi_loading_progress ("A iniciar a Interface");
00148         a = interface_os_linux (OperationList, GroupList,
00149                                 CameraSettings, MacroList, Images, xml);
00150 
00151         /*
00152          * Libertar memória
00153          */
00154 
00155         //vImagesFree (Images);
00156 
00157         return a;
00158 }
00159 
00166 static vBoolean
00167 vapiParseCommandOptionsCheckOpt (int argc, char *argv[], int order,
00168                                  const char *opt, int numberOfsettings)
00169 {
00170         if (!strcmp (argv[order], opt))
00171         {
00172                 if (numberOfsettings > 0)
00173                 {
00174                         if ((order + numberOfsettings) >= argc)
00175                         {
00176                                 return vTRUE;
00177                         }
00178                         return vTRUE;
00179                 }
00180                 return vFALSE;
00181         }
00182         return vFALSE;
00183 
00184 }
00185 
00189 static void
00190 vapiParseCommandOptions (int argc, char *argv[],
00191                          vCameraSettings * CameraSettings)
00192 {
00193         int i;
00194         if (argc <= 0)
00195         {
00196                 return;
00197         }
00198 
00199         for (i = 0; i < argc; i++)
00200         {
00201                 /*
00202                  * Local Camera
00203                  */
00204                 if (vapiParseCommandOptionsCheckOpt (argc, argv, i, "-lc", 1))
00205                 {
00206                         vapiCameraSettingsSetTypeLocal (CameraSettings,
00207                                                         atoi (argv[++i]));
00208                 }
00209 
00210                 /*
00211                  * Local File
00212                  */
00213                 if (vapiParseCommandOptionsCheckOpt (argc, argv, i, "-lf", 1))
00214                 {
00215                         vapiCameraSettingsSetTypeLocalFile (CameraSettings,
00216                                                             argv[++i]);
00217                 }
00218         }
00219 
00220 
00221 }

Gerado em Tue Jul 24 10:34:58 2007 para Vapi por  doxygen 1.5.1