17.06.2013 Views

pvbrowser manual - Flussi liberi informatici

pvbrowser manual - Flussi liberi informatici

pvbrowser manual - Flussi liberi informatici

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

16 CAPITOLO 5. PROGRAMMAZIONE<br />

int s;<br />

pvInit(ac,av,&p);<br />

/* here you may interpret ac,av and set p->user to your data */<br />

while(1)<br />

{<br />

s = pvAccept(&p);<br />

if(s != -1) pvCreateThread(&p,s);<br />

else break;<br />

}<br />

return 0;<br />

}<br />

#endif<br />

5.1.3 Maschere<br />

Dal ciclo senza fine all’interno di pvMain() vengono richiamate le singole maschere che compongono la vostra<br />

visualizzazione. Mostreremo ora la maschera iniziale di pvsexample.<br />

In show mask1() vi è un ciclo di eventi. Gli eventi sono analizzati e la corrispondente ’slot functions’ in cui<br />

dovrete inserire il vostro codice sarà richiamata. Questo file non dovrà mai essere modificato <strong>manual</strong>mente<br />

perchè sarà un compito svolto automaticamente da pvdevelop.<br />

Nella funzione genarted defineMask() i comandi per i widget che avete progettato sono inviati al client <strong>pvbrowser</strong>.<br />

<strong>pvbrowser</strong> analizzerà i comandi e chiamerà i costruttori appropriati per questi widget.<br />

Tutte le ’pv-function’ utilizzanto la struttura PARAM come primo parametro. All’interno di un elemento di<br />

questa struttura si trova il socket utilizzato per comunicare con il client. Le ’pv-function’ inviano messaggi di<br />

testo ASCII al client che interpreterà il testo e chiamarà un metodo dalla libreria Qt.<br />

L’enum all’inizio del file elenca i nomi widget che avete progettato. Questi nomi sono utilizzati come id<br />

(identificatori) all’interno delle ’pv-function’ e indirizzano al widget all’interno del client. Per questo ragione<br />

vi è un array con i puntatori ai widget all’interno del client. L’enum è un indice di questo array.<br />

Le ’slot functions’ sono incluse con un #include nella maschera.<br />

codice sorgente della parte completamente autogenerata di una maschera<br />

////////////////////////////////////////////////////////////////////////////<br />

//<br />

// show_mask1 for ProcessViewServer created: Mi Nov 8 11:58:45 2006<br />

//<br />

////////////////////////////////////////////////////////////////////////////<br />

#include "pvapp.h"<br />

// _begin_of_generated_area_ (do not edit -> use ui2pvc) -------------------<br />

// our mask contains the following objects<br />

enum {<br />

ID_MAIN_WIDGET = 0,<br />

iconView1,<br />

welcomeLabel,<br />

helpLabel,<br />

ID_END_OF_WIDGETS<br />

};<br />

static const char *toolTip[] = {<br />

"",<br />

"",<br />

"",<br />

"",<br />

""};<br />

static const char *whatsThis[] = {<br />

"",<br />

"",<br />

"",

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!