vwSlider - A generic slider class.


#include <vwSlider.h>

vwSlider::vwSlider ( vwMediator * concreteMediator, pfDCS * dcs);
virtual vwSlider::~vwSlider ( void);
void vwSlider::setGeomRange ( float geomRange=1.0, vwWidget::AXIS axis=X);
void vwSlider::setDataParms ( float dataMin, float dataMax, float dataVal);
void vwSlider::drag ( void);
void vwSlider::setDataDrag ( float dataVal, int doEvent=False);
void vwSlider::setParentMtx ( pfMatrix parentMtx);
virtual void vwSlider::setDragged ( int dragState);
inline float vwSlider::getDataValue ( void);
inline float vwSlider::getGeomValue ( void);
inline float vwSlider::getGeomRange ( void);
inline float vwSlider::getGeomMin ( void);
inline float vwSlider::getGeomMax ( void);
inline float vwSlider::getDataRange ( void);
inline float vwSlider::getDataMin ( void);
inline float vwSlider::getDataMax ( void);
inline vwWidget::AXIS vwSlider::getAxis ( void);
inline int vwSlider::isGeneric ( void);
inline void vwSlider::getMat ( pfMatrix &m)

virtual void vwSlider::doProcessDrag ( void);
virtual void vwSlider::updateDrag ( float geomVal);
virtual void vwSlider::applyDrag ( float newGeomVals[], int axisIndex);
inline void vwSlider::setMat ( pfMatrix &m);


   Inherited from vwWidget
virtual void vwWidget::setActive ( int activeState=True);
virtual void vwWidget::setOver ( int overState=True);
virtual void vwWidget::setVisible ( int visibiltyState=True);
inline int vwWidget::getActive ( void);
inline int vwWidget::getOver ( void);

inline int vwWidget::getPressed (

inline int vwWidget::getVisible ( void);
inline int vwWidget::getDragged ( void);
inline int vwWidget::getIdent ( void);
inline int vwWidget::getInterface ( void);
void vwWidget::getColor ( wColor colorIndex, float rgba[]);
inline void vwWidget::setColor ( wColor colorIndex=ACTIVE);
void vwWidget::registerColor ( wColor colorIndex, float *rgba);
inline int vwWidget::isOfType ( wType wdg_type);
inline pfSCS * vwWidget::getSCS ( void);
inline pfDCS * vwWidget::getDCS ( void);
inline void vwWidget::getParentMtx ( pfMatrix * m);

   Inherited from vwSubject
virtual void vwSubject::attach ( vwObserver *concreteObserver);
virtual void vwSubject::detach ( vwObserver *concreteObserver);
inline void vwSubject::setSubectData ( void * data);
inline void * vwSubject::getSubjectData ( void);
inline unsigned long vwSubject::getID ( void);


   Inherited from vwWidget
virtual void vwWidget::doSetColor ( wColor colorIndex);
virtual void vwWidget::setWType ( wType widgetType);

   Inherited from vwSubject
virtual void vwSubject::notify ( void);

vwSlider is the generic slider class publicly derived from vwWidget. A vwSlider must be initialized by a call to setGeomRange() first and then setDataParms() before it can be used. Unlike vwButton, where setPressed() generates a notify() event, setDragged(int) merely changes the slider's drag state variable. drag() calls doProcessDrag() and notify(). One can modify the slider's internal values and corresponding position without generating an event by calling setDataDrag(). Unlike other widgets, vwSlider should be accompanied by a background geometry (normally a vwFrame; see example program). Note that the slider's interface assumes a right handed coordinate system with Y up, X right and Z towards the viewer. The conversion to Performer's coordinate system is handled internally by the class. As with other widgets, a slider will not generate events, nor will it signify attribute changes due to pointer intersection if its Active State is set to False.  See vwWidget::setActive(). By default, on notify(), a vwSlider's new data value is passed as a void pointer to any concrete vwObservers attached to it.


vwSlider ( vwMediator *concreteMediator, pfDCS *dcs);

Construct a slider.

*concreteMediator specifies a pointer to the concrete mediator of the interface being created.

*dcs specifies a pointer to a Performer pfDCS containing the slider geometry.

virtual ~vwSlider ( void);

Destruct an instance.

void setGeomRange ( float geomRange, vwWidget::AXIS axis);

Initializes the slider's local coordinate range of motion and defines its axis of motion. This method must be called first for proper slider initialization.

geomRange specifies a floating point value defining the range of motion for the slider in its local coordinates. Default value is 1.0f.

axis specifies the slider's axis of motion in its local coordinate system. vwWidget::AXIS is an enum defined in vwWidget.h. Default value is vwWidget::X.

void setDataParms ( float dataMin, float dataMax, float dataVal);

This initialization method should be the second call to vwSlider after setGeomRange(). It configures the slider's data to geometry mapping and initializes the slider's position with respect to the current data value passed. setDataParms() does not generate any events.

dataMin specifies the minimum data value that the slider will send to observers during drag events. Any subsequent value smaller than dataMin which is passed to the slider via setDataDrag(), will be clamped to dataMin.

dataMax specifies the maximum data value that the slider will send to observers during drag events. Again, larger subsequent values sent to the slider will be clamped.

dataVal specifies the initial data value the slider will reflect. If it is beyond the range of dataMin and dataMax it will be clamped to the boundary of that range.

void drag ( void);

This method updates the slider's geometry and data parameters. It then generates a notify event after calling doProcessDrag(). Since intersection testing between the WAND front vector and widget geometry is used to determine the drag amount, a vwFrame should always accompany a vwSlider. This allows for drag updates even when the WAND vector moves off of the slider geometry and onto the frame geometry.

void setDataDrag ( float dataVal, int doEvent);

Modify the slider's data and geometry values explicitly. Does not generate a notify() event, nor make a call to doProcessDrag() unless the value of doEvent is True. It's default value is False. Therefore, setDataDrag() called with one argument (dataVal) will not generate an event.

dataVal specifies a new data value for the slider to reflect. If out of range, it will be clamped to the range defined by dataMin and dataMax.

doEvent specifies a value True or False (0). Its default value is False, in which case setDataDrag() wiill not generate an event. If doEvent is passed as True, along with modifying the slider's internal data structures and position, setDataDrag() will also call doProcessDrag() and notify().

void setParentMtx ( pfMatrix parentMtx);

Explicitly set the slider's parent matrix. The slider's parent matrix is initially set in its constructor by copying the static vwWidget interface pfMatrix. This static matrix is set each time vwWidget::parseWdgConfig() is called. Therefore, if this static parsing method is used to construct the interface to which the slider belongs, setParentMtx() most likely need not be called. However, if the slider's parent interface is nested in other pfDCSs or pfSCSs, it may be necessary to pass the slider the cumulative transformation matrix, including the transforms occurring in the interface pfDCS. Likewise, if vwWidget::parseWdgConfig() is not used in the interface construction, it may be necessary to pass the slider the cumulative matrix above its own pfDCS in order for the slider to work properly.

The caveat with all of this is that the correct parentMtx for the slider also depends upon how the scene graph is constructed, and which pfGroup is used as the originator of intersection traversal in vwWidget::handleWidgets() or vwWidget::isOver(). In the case where a slider geometry is not affected by the CAVE navigation pfDCS, CAVE_WAND is used for pfSegSet definition, and intersection traversal is done from the pfScene, or the interface pfDCS, the slider will normally work properly by default. However, in the case where the slider geometry is affected by the CAVE navigation pfDCS and CAVE_WAND is used for pfSegSet definition, the slider *may not* work correctly without modifying the slider's parentMtx. On the other hand. If a pfGroup node is inserted between the interface pfDCS and the CAVE navigation pfDCS, correct slider behavior should occur by using CAVE_WAND_NAV and using the inserted pfGroup as the originator of the intersection traversal.

parentMtx specifies the cumulative pfMatrix which is applied to the slider's pfDCS. It's inverse affine is used to convert slider coordinates from CAVE or world to local coordinates during calls to drag().

virtual void setDragged ( int dragState);

Unlike vwButton::setPressed(), setDragged() does not call notify(), nor does it call doProcessDrag(). It sets the slider's drag state variable and modifies the slider's color if the drag state variable is actually different from before this call. This function is primarily used internally, but may be needed externally in certain unusual situations.

dragState specifies the integer drag state. Either True or False (0).

inline float getDataValue ( void);

Returns the slider's data value.

inline float getGeomValue ( void);

Returns the slider's geometry value.

inline float getGeomMin ( void);

Returns the slider's minimum geometry value.

inline float getGeomMax ( void);

Returns the slider's maximum geometry value.

inline float getGeomRange ( void);

Returns the slider's geometry range.

virtual float getDataRange ( void);

Returns the slider's data range.

virtual float getDataMin ( void);

Returns the slider's minimum data value.

virtual float getDataMax ( void);

Returns the slider's maximum data value.

inline vwWidget::AXIS getAxis ( void);

Returns the slider's axis of motion. AXIS is an enum defined in vwWidget.h.

inline int isGeneric ( void);

Returns True if this is a generic vwSlider. Subclasses of vwSlider should set vwSlider::_generic to False in their constructor.

inline void getMat ( pfMatrix &m);

Copies the slider's pfDCS pfMatrix into the pfMatrix m.

   doProcessDrag() [Protected]
virtual void doProcessDrag ( void);

A hook operation that gets called from within drag(). This function is called before notify(), and may be overridden by classes publicly inheriting from vwSlider when a specific pre-notify behavior is required. In the case of vwSlider, doProcessDrag() does nothing.

   updateDrag() [Protected]
virtual void updateDrag ( float geomVal);

This function uses the geometry value computed by setDataDrag() to update the slider's geometric position. It also recalculates the data value after boundary clamping the geometry value. It is left non-private for certain unusual slider subclasses that may need to call it directly.

geomVal specifies the geometric location in local coordinates of the slider on its axis of movement.

   applyDrag() [Protected]
virtual void applyDrag ( float newGeomVals [], int axisIndex);

This functon applies the newly dragged position of the slider to the pfDCS of its geometry. This method is non-private to allow access and overrides to fancy slider sub-classes. It is called from within drag().

newGeomVals[] specifies the XYZW value array of the pre-updated slider translation component in local coordinates.The updated translation for the specified axis is then substituted in the application of the modified pfMatrix to the slider's pfDCS.

axisIndex specifies an index into newGeomVals[] that corresponds to the AXIS of the slider.

   setMat() [Protected]
inline void setMat ( pfMatrix &m);

Copies m into the slider's pfDCS pfMatrix.

vwSubject, vwWidget

vrmedlab.jpg (7272 bytes)