Referência ao ficheiro src/vapiMacro.h

Functions to handle and define Macros. Mais...

#include "vapi.h"
#include "vapiLists.h"
#include "vapiOperation.h"
#include "vapiResult.h"
#include "vapiOptions.h"
#include <gtk/gtk.h>

Diagrama de dependências de inclusão para vapiMacro.h:

Este grafo mostra quais são os ficheiros que incluem directamente ou indirectamente este ficheiro:

Ir para o código fonte deste ficheiro.

Estruturas de Dados

struct  _vMacroHeader
struct  _vMacroItem

Definições de tipos

typedef vList vMacro
 This is just a better way to describe a Macro. It is useful because you can see what you are handling.
typedef _vMacroHeader vMacroHeader
 this is a Header that describes the Macro.
typedef _vMacroItem vMacroItem
 Describe a MacroItem Macros are Operations with Options that are set.

Funções

void vapiApplyMacro (vMacroHeader *MacroHeader, vImages *Images, vBoolean ResetResult, vBoolean SaveSequence)
 Applies the macro on the images supplied.
void vapiApplyMacroUntil (vMacroHeader *MacroHeader, vImages *Images, int Until)
 Applies the macro on the images supplied until the selected item.
void vapiConditionalJump (vImages *Images, vOptions *Options, vMacroResult *PreviousResult)
 Analises the Decision Value and makes a jump if necessary. While the macro is being applyied, we can jump from one item to another. This function detects this and performs the jump, based on the PreviousResults.
void vapiLoadMacro (vImages *Images, vOptions *options, vMacroResult *PreviousResult)
 This is an operation to load other macros inside a macro. It can load the mother (!) macro, creating infinite loops. Be careful.
void vapiMacroAddItem (vMacro *Macro, vEffect *Operation, vOptions *Options)
 Appends a configured operation to the end of the macro.
void vapiMacroAddItemPositioned (vMacro *Macro, vEffect *Operation, vOptions *Options, int position)
 inserts an item into the desired position.
int vapiMacroCountElements (vMacro *Macro)
 Count the Number of elements of a macro.
void vapiMacroDelete (vMacroHeader *MacroHeader)
 Frees the entire MacroHeader.
void vapiMacroDeleteItem (vMacro *Macro, int Delete)
 deletes an operation from the macro.
int vapiMacroGetMacroIndex (vMacro *Macro, const char *MacroName, int order)
 gets the number of the operation in wich a macro is called.
vMacroHeadervapiMacroNew (const char *MacroName)
 Create a New Macro.
vMacroItemvapiMacroSelectItem (vMacro *Macro, int Item)
 gets an item of the macro.
char * vapiMacroTag (const char *previousMacroTag, int operationNumber)
 Generate the current macroTag. MacroTags are a way to identify macros called from within other macros.
void vapiMacroToText (vMacro *Macro)
 Exports the Macro to text, performing a list of the operations that this Macro uses. it is printed to stdout.
void vapiMacroUpdateComment (vMacroHeader *MacroHeader, const char *MacroComment)
 To update the comment field of a Macro.
void vapiMacroUpdateName (vMacroHeader *MacroHeader, const char *MacroName)
 Updates the Macro Name.
void vMacroItemFree (vMacroItem *Free)
 frees a Macro item. This is used in the function to delete an item.


Descrição detalhada

Functions to handle and define Macros.

Definido no ficheiro vapiMacro.h.


Documentação dos tipos

vMacro

This is just a better way to describe a Macro. It is useful because you can see what you are handling.

Definido na linha 30 do ficheiro vapiMacro.h.

vMacroHeader

this is a Header that describes the Macro.

vMacroItem

Describe a MacroItem Macros are Operations with Options that are set.


Documentação das funções

void vapiApplyMacro ( vMacroHeader MacroHeader,
vImages Images,
vBoolean  ResetResult,
vBoolean  SaveSequence 
)

Applies the macro on the images supplied.

Parâmetros:
Images images handler
SaveSequence If it saves each operation's image output (true/false).
ResetResult If the result's structure should be reseted or not.

Definido na linha 91 do ficheiro vapiMacro.c.

Referências _vImages::Actual, _vMacroResult::End, gtkImActual, _vMacroResult::JumpTo, _vMacroHeader::Macro, _vMacroHeader::MacroName, _vMacroItem::Operation, _vMacroItem::Options, _vMacroHeader::PreviousResult, v_bypass_get(), v_printf(), v_stopby_get(), vapiApplyOperation(), vapiGtkImagesFastUpdateInterface(), vapiGtkMacroRunningTest(), vapiMacroCountElements(), vapiMacroSelectItem(), vapiResultCheckMacroTag(), vapiResultSetCurrentMacroTag(), vFALSE e vResultReset().

Referenciado por vapiCalibrateCameraGetConstant(), vapiGtkApplyMacroThread() e vapiLoadMacro().

00093 {
00094         vMacroItem *Item;
00095         int i = 0, MacroSize;
00096         char *filename, *macroTag;
00097         MacroSize = vapiMacroCountElements (MacroHeader->Macro);
00098         if (MacroSize == 0)
00099         {
00100                 return;
00101         }
00102         /*
00103          * Fazer Reset aos Resultados Memorizados, se existirem.
00104          */
00105         if (ResetResult)
00106         {
00107                 vResultReset ((vMacroResult *) MacroHeader->PreviousResult);
00108         }
00109         macroTag = vapiResultCheckMacroTag (MacroHeader->PreviousResult);
00110         for (i = 0; i < MacroSize; i++)
00111         {
00112                 if (!vapiGtkMacroRunningTest ())
00113                 {
00114                         return;
00115                 }
00116                 if (!v_bypass_get (macroTag, i))
00117                 {
00118                         continue;
00119                 }
00120                 vapiResultSetCurrentMacroTag (MacroHeader->PreviousResult,
00121                                               macroTag, i);
00122                 if (MacroHeader->PreviousResult->End)
00123                 {
00124 
00125                         MacroHeader->PreviousResult->End = vFALSE;
00126                         return;
00127                 }
00128                 Item = vapiMacroSelectItem (MacroHeader->Macro, i);
00129                 vapiApplyOperation (Images, (vEffect *) Item->Operation,
00130                                     (vOptions *) Item->Options,
00131                                     MacroHeader->PreviousResult);
00132                 if (v_stopby_get (macroTag, i))
00133                 {
00134                         vapiGtkImagesFastUpdateInterface (Images->Actual,
00135                                                           gtkImActual);
00136                 }
00137                 if (SaveSequence)
00138                 {
00139                         filename = v_printf ("%s_Operation_%d.jpg",
00140                                              MacroHeader->MacroName, i);
00141                         cvSaveImage (filename, Images->Actual);
00142                         free (filename);
00143 
00144                 }
00145                 if (MacroHeader->PreviousResult->JumpTo != -1)
00146                 {
00147                         i = MacroHeader->PreviousResult->JumpTo - 1;
00148                         MacroHeader->PreviousResult->JumpTo = -1;
00149                         continue;
00150                 }
00151         }
00152         free (macroTag);
00153 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiApplyMacroUntil ( vMacroHeader MacroHeader,
vImages Images,
int  Until 
)

Applies the macro on the images supplied until the selected item.

Parâmetros:
Images images handler

Definido na linha 214 do ficheiro vapiMacro.c.

Referências _vImages::Actual, _vMacroResult::End, gtkImActual, _vMacroResult::JumpTo, _vMacroHeader::Macro, _vMacroItem::Operation, _vMacroItem::Options, _vMacroHeader::PreviousResult, v_bypass_get(), v_stopby_get(), vapiApplyOperation(), vapiGtkImagesFastUpdateInterface(), vapiGtkMacroRunningTest(), vapiMacroCountElements(), vapiMacroSelectItem(), vapiResultCheckMacroTag(), vapiResultSetCurrentMacroTag() e vFALSE.

Referenciado por vapiGtkApplyMacroUntilThread() e vapiGtkMacroTablesApplyUntil().

00215 {
00216         vMacroItem *Item;
00217         int i = 0, MacroSize;
00218         char *macroTag;
00219 
00220         MacroSize = vapiMacroCountElements (MacroHeader->Macro);
00221         if (MacroSize == 0)
00222         {
00223                 return;
00224         }
00225         macroTag = vapiResultCheckMacroTag (MacroHeader->PreviousResult);
00226         for (i = 0; i < MacroSize; i++)
00227         {
00228                 if (!vapiGtkMacroRunningTest ())
00229                 {
00230                         return;
00231                 }
00232                 if (!v_bypass_get (macroTag, i))
00233                 {
00234                         continue;
00235                 }
00236                 vapiResultSetCurrentMacroTag (MacroHeader->PreviousResult,
00237                                               macroTag, i);
00238                 if (MacroHeader->PreviousResult->End)
00239                 {
00240                         MacroHeader->PreviousResult->End = vFALSE;
00241                         return;
00242                 }
00243                 Item = vapiMacroSelectItem (MacroHeader->Macro, i);
00244                 vapiApplyOperation (Images, (vEffect *) Item->Operation,
00245                                     (vOptions *) Item->Options,
00246                                     MacroHeader->PreviousResult);
00247                 if (v_stopby_get (macroTag, i))
00248                 {
00249                         vapiGtkImagesFastUpdateInterface (Images->Actual,
00250                                                           gtkImActual);
00251                 }
00252                 if (MacroHeader->PreviousResult->JumpTo != -1)
00253                 {
00254 
00255                         i = MacroHeader->PreviousResult->JumpTo - 1;
00256                         MacroHeader->PreviousResult->JumpTo = -1;
00257                         continue;
00258                 }
00259                 if (i == Until)
00260                 {
00261                         return;
00262                 }
00263         }
00264         free (macroTag);
00265 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiConditionalJump ( vImages Images,
vOptions Options,
vMacroResult PreviousResult 
)

Analises the Decision Value and makes a jump if necessary. While the macro is being applyied, we can jump from one item to another. This function detects this and performs the jump, based on the PreviousResults.

Definido na linha 268 do ficheiro vapiMacro.c.

Referências _vMacroResult::Decision, _vOptions::ints, _vMacroResult::JumpTo, v_debug e vFALSE.

00270 {
00271         if (PreviousResult->Decision)
00272         {
00273                 v_debug ("JUMP TO TRUE");
00274                 PreviousResult->JumpTo = Options->ints[0];
00275                 PreviousResult->Decision = vFALSE;
00276 
00277         }
00278         else
00279         {
00280                 v_debug ("JUMP TO FALSE");
00281                 PreviousResult->JumpTo = Options->ints[1];
00282         }
00283 }

void vapiLoadMacro ( vImages Images,
vOptions options,
vMacroResult PreviousResult 
)

This is an operation to load other macros inside a macro. It can load the mother (!) macro, creating infinite loops. Be careful.

Parâmetros:
PreviousResult The previous has to be passed, because it will be used in the child macro.

Definido na linha 177 do ficheiro vapiMacro.c.

Referências _vOptions::CustomOptions, _vMacroHeader::Macro, _vMacroHeader::MacroName, _vMacroHeader::PreviousResult, v_error(), vapiApplyMacro() e vFALSE.

Referenciado por vapiAvailableEfects().

00179 {
00180         vMacroHeader *originalMacroHeader, *tempMacroHeader;
00181 
00182         if (((vEffectOptions *) options->CustomOptions)->Macros == NULL)
00183         {
00184                 v_error ("Macro Não seleccionada correctamente");
00185                 return;
00186         }
00187 
00188         tempMacroHeader = malloc (sizeof (vMacroHeader));
00189         originalMacroHeader =
00190                 ((vEffectOptions *) options->CustomOptions)->Macros;
00191         tempMacroHeader->Macro = originalMacroHeader->Macro;
00192         tempMacroHeader->MacroName = originalMacroHeader->MacroName;
00193         tempMacroHeader->PreviousResult = PreviousResult;
00194 #ifdef VAPI_WITHOUT_INTERFACE
00195         vapiApplyMacro (tempMacroHeader, Images, vFALSE, vFALSE);
00196 #else
00197         vapiApplyMacro (tempMacroHeader, Images, vFALSE, vFALSE);
00198 #endif
00199 
00200         free (tempMacroHeader);
00201 
00202 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiMacroAddItem ( vMacro Macro,
vEffect Operation,
vOptions Options 
)

Appends a configured operation to the end of the macro.

Parâmetros:
Operation The Operation to add
Options the options data
Macro the Macro (not the MacroHeader).

Definido na linha 46 do ficheiro vapiMacro.c.

Referências _vMacroItem::Operation, _vMacroItem::Options e v_list_append().

Referenciado por vapiCalibrateCameraCreateMacro(), vapiGtkMacroAppendItem() e vapiMacroFromXML().

00047 {
00048         vMacroItem *MacroItem;
00049 
00050         MacroItem = malloc (sizeof (vMacroItem));
00051         MacroItem->Operation = Operation;
00052         MacroItem->Options = Options;
00053         v_list_append ((vList *) Macro, MacroItem);
00054 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiMacroAddItemPositioned ( vMacro Macro,
vEffect Operation,
vOptions Options,
int  position 
)

inserts an item into the desired position.

Parâmetros:
Operation The Operation to add
Options the options data
position The place where to add the new item.

Definido na linha 76 do ficheiro vapiMacro.c.

Referências _vMacroItem::Operation, _vMacroItem::Options, v_list_insert() e vapiMacroToText().

Referenciado por vapiGtkMacroInsertItem().

00078 {
00079         vMacroItem *MacroItem;
00080 
00081         MacroItem = malloc (sizeof (vMacroItem));
00082         MacroItem->Operation = Operation;
00083         MacroItem->Options = Options;
00084 
00085         v_list_insert ((vList *) Macro, MacroItem, position);
00086 
00087         vapiMacroToText (Macro);
00088 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

int vapiMacroCountElements ( vMacro Macro  ) 

Count the Number of elements of a macro.

Retorna:
the number of operations of a macro.

Definido na linha 57 do ficheiro vapiMacro.c.

Referências v_list_count_elements().

Referenciado por vapiApplyMacro(), vapiApplyMacroUntil(), vapiGtkMacroInsertItem(), vapiGtkMacroItemMoveDown(), vapiGtkMacroItemMoveToBottom(), vapiGtkMacroTableModel(), vapiMacroToText() e vapiMacroToXML().

00058 {
00059         return v_list_count_elements ((vList *) Macro);
00060 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiMacroDelete ( vMacroHeader MacroHeader  ) 

Frees the entire MacroHeader.

Definido na linha 205 do ficheiro vapiMacro.c.

Referências _vMacroHeader::Macro, _vMacroHeader::PreviousResult, v_list_free() e vMacroItemFree().

Referenciado por vapiCalibrateCameraGetConstant() e vapiMacroListDeleteItem().

00206 {
00207 
00208         v_list_free (MacroHeader->Macro, (vFreeFunction *) & vMacroItemFree);
00209         free (MacroHeader->PreviousResult);
00210         free (MacroHeader);
00211 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiMacroDeleteItem ( vMacro Macro,
int  Delete 
)

deletes an operation from the macro.

Aviso:
It releases the options structure.
Parâmetros:
Delete the number of the operation (in the macro) to delete

Definido na linha 63 do ficheiro vapiMacro.c.

Referências v_list_delete_item() e vMacroItemFree().

Referenciado por vapiGtkMacroDeleteItem().

00064 {
00065         v_list_delete_item ((vList *) Macro,
00066                             (vFreeFunction *) & vMacroItemFree, Delete);
00067 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

int vapiMacroGetMacroIndex ( vMacro Macro,
const char *  MacroName,
int  order 
)

gets the number of the operation in wich a macro is called.

Parâmetros:
MacroName The name of the macro that is called.
order the order of the call (if it is the first call, ou the n call).
Retorna:
the number of the item that makes the call (LoadMacro function). Returns -1 if the call does not exist.

Definido na linha 293 do ficheiro vapiMacro.c.

Referências _vChar::ch, _vOptions::chars, _vEffect::name, _vMacroItem::Operation, _vMacroItem::Options, v_list_count_elements() e v_list_get().

00294 {
00295 
00296         int MacroSize, tempOrder = 0, i;
00297         vMacroItem *item;
00298 
00299         MacroSize = v_list_count_elements (Macro);
00300 
00301         for (i = 0; i < MacroSize; i++)
00302         {
00303                 item = v_list_get (Macro, i);
00304 
00305                 if (!strcmp (item->Operation->name, "Executar Tarefa"))
00306                 {
00307                         if (!strcmp (item->Options->chars[0].ch, MacroName))
00308                         {
00309                                 if (++tempOrder == order)
00310                                 {
00311                                         return i;
00312                                 }
00313                         }
00314                 }
00315         }
00316         return -1;
00317 }

Grafo de chamadas desta função:

vMacroHeader* vapiMacroNew ( const char *  MacroName  ) 

Create a New Macro.

Ficheiro vapiMacroList.c

Trata da criação e gestão das Macros de macros para processar imagens.

Criado 28/11/2006

Definido na linha 31 do ficheiro vapiMacro.c.

Referências _vMacroHeader::Macro, _vMacroHeader::MacroComment, _vMacroHeader::MacroName, _vMacroHeader::PreviousResult, vapiMacroResultInit() e vapiReturnStringPointer().

Referenciado por vapiCalibrateCameraGetConstant(), vapiGtkMacroCreate() e vapiMacroFromXML().

00032 {
00033         vMacroHeader *MacroHeader;
00034         vMacro *Macro = malloc (sizeof (vMacro));
00035         *Macro = NULL;
00036         MacroHeader = malloc (sizeof (vMacroHeader));
00037         MacroHeader->PreviousResult = vapiMacroResultInit ();
00038         MacroHeader->MacroName = vapiReturnStringPointer (MacroName);
00039         MacroHeader->Macro = Macro;
00040         MacroHeader->MacroComment = vapiReturnStringPointer ("");
00041 
00042         return MacroHeader;
00043 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

vMacroItem* vapiMacroSelectItem ( vMacro Macro,
int  Item 
)

gets an item of the macro.

Retorna:
a pointer to the MacroItem.
Parâmetros:
Item the number of the item to fetch.
Aviso:
the pointer can't be freed.

Definido na linha 70 do ficheiro vapiMacro.c.

Referências v_list_get().

Referenciado por vapiApplyMacro(), vapiApplyMacroUntil(), vapiGtkMacroSelectItem(), vapiGtkMacroSelectNext(), vapiGtkMacroTableModel(), vapiGtkMacroTablesApplyUntil(), vapiGtkMacroUpdateItemOptions(), vapiMacroToText() e vapiMacroToXML().

00071 {
00072         return (v_list_get ((vList *) Macro, Item));
00073 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

char* vapiMacroTag ( const char *  previousMacroTag,
int  operationNumber 
)

Generate the current macroTag. MacroTags are a way to identify macros called from within other macros.

Retorna:
A pointer to the macroTag string. This pointer must be freed when not used.

Definido na linha 334 do ficheiro vapiMacro.c.

Referências v_printf().

Referenciado por vapiGtkMacroTableAux() e vapiResultSetCurrentMacroTag().

00335 {
00336         return v_printf ("%s:%d", previousMacroTag, operationNumber);
00337 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiMacroToText ( vMacro Macro  ) 

Exports the Macro to text, performing a list of the operations that this Macro uses. it is printed to stdout.

Definido na linha 156 do ficheiro vapiMacro.c.

Referências vapiMacroCountElements() e vapiMacroSelectItem().

Referenciado por vapiMacroAddItemPositioned().

00157 {
00158         vMacroItem *Item;
00159         int i, MacroSize;
00160         MacroSize = vapiMacroCountElements (Macro);
00161 
00162         for (i = 0; i < MacroSize; i++)
00163         {
00164                 /*
00165                  * Carregar os dados do Operation.
00166                  */
00167                 Item = vapiMacroSelectItem (Macro, i);
00168 
00169                 /*
00170                  * Executar o Operation com os parâmetros definidos.
00171                  */
00172 
00173         }
00174 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiMacroUpdateComment ( vMacroHeader MacroHeader,
const char *  MacroComment 
)

To update the comment field of a Macro.

Parâmetros:
Macrocomment the comment to put in the Macro.

Definido na linha 320 do ficheiro vapiMacro.c.

Referências _vMacroHeader::MacroComment e vapiReturnStringPointer().

Referenciado por vapiGtkMacroChange(), vapiGtkMacroCreate() e vapiMacroFromXML().

00321 {
00322         free (MacroHeader->MacroComment);
00323         MacroHeader->MacroComment = vapiReturnStringPointer (MacroComment);
00324 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiMacroUpdateName ( vMacroHeader MacroHeader,
const char *  MacroName 
)

Updates the Macro Name.

Parâmetros:
MacroName The Macro's new name.

Definido na linha 327 do ficheiro vapiMacro.c.

Referências _vMacroHeader::MacroName e vapiReturnStringPointer().

Referenciado por vapiGtkMacroChange().

00328 {
00329         free (MacroHeader->MacroName);
00330         MacroHeader->MacroName = vapiReturnStringPointer (MacroName);
00331 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vMacroItemFree ( vMacroItem Free  ) 

frees a Macro item. This is used in the function to delete an item.

Definido na linha 286 do ficheiro vapiMacro.c.

Referências _vMacroItem::Operation, _vMacroItem::Options e vOperationOptionsFree().

Referenciado por vapiMacroDelete() e vapiMacroDeleteItem().

00287 {
00288         vOperationOptionsFree (Free->Options, Free->Operation);
00289         free (Free);
00290 }

Grafo de chamadas desta função:

Here is the caller graph for this function:


Gerado em Tue Jul 24 10:38:31 2007 para Vapi por  doxygen 1.5.1