Scene Objects Surface Editor Globals Table of Contents

State Query

Availability  LightWave® 6.0
Component  Modeler
Header  lwmodeler.h

This global provides a set of functions that return information about the current modeling environment.

Global Call

   LWStateQueryFuncs *query;
   query = global( LWSTATEQUERYFUNCS_GLOBAL, GFUSE_TRANSIENT );

The global function returns a pointer to an LWStateQueryFuncs.

   typedef struct st_LWStateQueryFuncs {
      int          (*numLayers) (void);
      unsigned int (*layerMask) (EltOpLayer);
      const char * (*surface)   (void);
      unsigned int (*bbox)      (EltOpLayer, double *minmax);
      const char * (*layerList) (EltOpLayer, const char *);
      const char * (*object)    (void);
      int          (*mode)      (int);
      const char * (*vmap)      (int, LWID *);
   } LWStateQueryFuncs;
nlayers = numLayers()
Returns the number of data layers for the current object.

mask = layerMask( oplayer )
Returns bits for the data layers included in the EltOpLayer selection. If bit i of the mask is set, then layer i + 1 of the current object belongs to the set defined by the oplayer argument. This function is provided primarily for backward compatibility. New code should use the layerList function, which is designed for multiple objects and an unlimited number of layers.

surfname = surface()
Returns the name of the current default surface.

npoints = bbox( oplayer, box )
Returns the number of points in the layer selection. If box isn't NULL, it is an array of six doubles that will receive the bounding box of the points in the layer selection, in the order (x0, x1, y0, y1, z0, z1).

layers = layerList( oplayer, objname )
Returns a string containing layer numbers for the given EltOpLayer and object. The layer numbers in the string are separated by spaces, with the highest numbered layer listed first. The object name is its filename, or NULL for the current object.

objname = object()
Returns the filename of the current object. If the geometry in the current layers hasn't been saved to a file yet, this returns the reference name (the name that would be returned by the Object Functions refName function). If no object has been loaded into Modeler, this returns NULL.

m = mode( setting )
Returns the state of a user interface setting. The setting codes are

LWM_MODE_SELECTION
Returns the selection mode (points, polygons, volume) as an integer.
LWM_MODE_SYMMETRY
Returns the state of the symmetry toggle.

vmapname = vmap( index, lwid )
Returns the name of the currently selected vertex map, and stores the LWID of the vmap in the second argument. The index can be one of the following.
LWM_VMAP_WEIGHT
LWM_VMAP_TEXTURE
LWM_VMAP_MORPH

Example

This code fragment exercises the query functions.

   #include <lwserver.h>
   #include <lwmodeler.h>

   LWStateQueryFuncs *query;
   double box[ 6 ];
   char *surfname, *layers, *objname;
   int nlayers, npoints;

   query = global( LWSTATEQUERYFUNCS_GLOBAL, GFUSE_TRANSIENT );
   if ( !query ) return AFUNC_BADGLOBAL;

   nlayers  = query->numLayers();
   npoints  = query->bbox( OPLYR_PRIMARY, box );
   surfname = query->surface();
   objname  = query->object();
   layers   = query->layerList( OPLYR_FG, objname );