[vtk-developers] modification to vtkImagePlaneWidget

Dean Inglis dean.inglis at camris.ca
Tue Mar 21 13:36:54 EST 2006


A recent post to vtk users 

http: //public.kitware.com/pipermail/vtkusers/2006-March/084308.html

has prompted me to look at the definition of margins in vtkIPW.
Currently I set a default margin offset of 5% of
the width or height of the widget's plane.

Currently the API is not designed to distinguish
constituent movement modes from button/modifier
combinations, only meta actions, for example: 

  switch (this->RightButtonAction)
    {
    case vtkImagePlaneWidget::CURSOR_ACTION:
      this->StartCursor();
      break;
    case vtkImagePlaneWidget::SLICE_MOTION_ACTION:
      this->StartSliceMotion();
      break;
    case vtkImagePlaneWidget::WINDOW_LEVEL_ACTION:
      this->StartWindowLevel();
      break;
    }

with SLICE_MOTION_ACTION specified further by
determining where on the vtkIPW plane a pick occurred
(with respect to margins) and whether control or 
shift key + modifiers were active.

I would like to add MarginSizeX and MarginSizeY 
in place of the hard coded 5% constraints using
the following API:

  // Description:
  // Set the size of the margins based on a percentage of the
  // plane's width and height, limited between 0 and 50%.
  vtkSetClampMacro(MarginSizeX,double, 0.0, 0.5);
  vtkGetMacro(MarginSizeX, double);
  vtkSetClampMacro(MarginSizeY,double, 0.0, 0.5);
  vtkGetMacro(MarginSizeY, double);

plus a few minor additions to the AdjustMargins method:

  if ( x2D > planeSize1 ) { x2D = planeSize1; }
  else if ( x2D < 0.0 ) { x2D = 0.0; }
  if ( y2D > planeSize2 ) { y2D = planeSize2; }
  else if ( y2D < 0.0 ) { y2D = 0.0; }

  // Divide plane into three zones for different user interactions:
  // four corners -- spin around the plane's normal at its center
  // four edges   -- rotate around one of the plane's axes at its center
  // center area  -- push
  //
  double marginX = planeSize1 * this->MarginSizeX;
  double marginY = planeSize2 * this->MarginSizeY;

Setting the margin sizes to 0 disables margin
interactions: spinning and rotating. Edge specific 
extension/scaling is disabled but not eliminated
if the user uses shift or control keys: overall 
scaling or translation can still occur with those
key + mouse combinations.

Any thoughts?

Dean

PS: sorry I haven't had time to get onboard the new widget
design paradigm and revamp vtkIPW, vtkSplineWidget etc.

   
 



More information about the vtk-developers mailing list