Layout MonitorAvailability LightWave 7.0 The Layout monitor global returns functions for initializing and displaying a progress dialog in Layout. This is primarily for showing the progress of lengthy or complex operations in non-handler plug-in classes. Filters and file importer classes have their own monitor mechanisms. See also the monitor global for Modeler. Global Call LWLMonFuncs *lmonf; lmonf = global( LWLMONFUNCS_GLOBAL, GFUSE_TRANSIENT ); The global function returns a pointer to an LWLMonFuncs. typedef struct st_LWLMonFuncs {
LWLMonID (*create) (void);
void (*setup) (LWLMonID, char *title, unsigned int flags,
const char *histfile);
void (*setwinpos)(LWLMonID, int x, int y, int w, int h);
void (*init) (LWLMonID, unsigned int total, const char *);
int (*step) (LWLMonID, unsigned int incr, const char *);
void (*done) (LWLMonID);
void (*destroy) (LWLMonID);
} LWLMonFuncs;
Example This code fragment creates and displays a monitor in Layout. Displaying progress to the user is helpful but not essential, so in most cases failure in some part of the monitor processing shouldn't cause your plug-in to fail. #include <lwserver.h>
#include <lwgeneric.h>
#include <lwmonitor.h>
#include <time.h>
LWLMonFuncs *monf;
LWLMonID mon;
int i, total, step;
/* get the global and a monitor */
monf = global( LWLMONFUNCS_GLOBAL, GFUSE_TRANSIENT );
if ( monf ) {
mon = monf->create();
if ( mon )
monf->setup( mon, "Just Testing", LMO_REVIEW, NULL );
}
...
/* perform a lengthy task */
if ( monf && mon ) monf->init( mon, total, "Starting..." );
for ( i = 0; i < total; i += step ) {
...do something...
if ( monf && mon )
if ( monf->step( mon, step, NULL )) {
monf->step( mon, 0, "Aborted!" );
break;
}
}
if ( monf && mon ) monf->done( mon );
...
/* no longer need the monitor */
if ( monf && mon ) monf->destroy( mon );
|