[vtk-developers] Proposal to make small enhancement to vtkSetGet

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Thu Apr 26 13:58:21 EDT 2001


hi,

I thought of a possibly useful enhancement that I could make to
vtkSetGet.h that would make constructing GUI controls for vtk objects
easier than it already is.

There are quite a few variables that use the vtkSetClampMacro for
variables that have ranges of valid values.  AFAIK, right now there is
no way to extract the actual range of allowed values.  If this
information were available it would be easy to create a scale or
slider widget to control such widgets automatically.  By adding about
10 lines of code to vtkSetGet.h it should be trivially possible to add
methods that return the max and min allowed values.  Here is sample
code.

----------------------------------------
#define vtkSetClampMacro(name,type,min,max) \
virtual void Set##name (type _arg) \
  { \
  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #nam
e " to " << _arg ); \
  if (this->name != (_arg<min?min:(_arg>max?max:_arg))) \
    { \
    this->name = (_arg<min?min:(_arg>max?max:_arg)); \
    this->Modified(); \
    } \
  } \
virtual type Get##name##Min () \
{ \
  return min; \
} \
virtual type Get##name##Max () \
{ \
  return max; \
}
----------------------------------------

Hence we will have three functions 

SetRadius()
GetRadiusMin()
GetRadiusMax()

This should not affect any existing code.  I am not sure about the
naming conventions that I have used here.  Let me know if I should use
something like GetRadiusMinValue()/GetRadiusMaxValue() or anything
else instead of what I used earlier.

What do you folks think of this proposal?  If no one objects I will
test and commit it this weekend.

prabhu




More information about the vtk-developers mailing list