[vtk-developers] propsed mods to vtkContourWidget

Dean Inglis dean.inglis at camris.ca
Fri Mar 5 17:30:57 EST 2010


Hi all,

further to my brief vtkusers discussion with Karthik,
I would like to add a ContinuousMode bool ivar to vtkContourWidget
so that users can freehand draw on an image (for example).  Would
anyone prefer a different ivar name, e.g. "Continuous" :

widget->ContinuousModeOn();
widget->ContinuousOn();

Currently I have it working so that if the user left button clicks
the continuous drawing occurs and continues drawing whether or
not the left button is released until the right button is clicked to
terminate contour definition.

What I would like to see happen is that the
continuous mode only works if the left button is pressed and
held down.  If the left button is let up, the widget reverts back to
normal left click down and up to place nodes until right button
is clicked to terminate defining a contour.

I would also like to add functionality to the widget to respond
to a key press to delete the contour and hence reset the widget.
This would involve creating a static method

def'n:
static void ResetAction(vtkAbstractWidget*);

implementation:
void vtkContourWidget::EndSelectAction(vtkAbstractWidget *w)
{
  vtkContourWidget *self = reinterpret_cast<vtkContourWidget*>(w);
  self->Initialize();
}

and creating a new event in vtkWidgetEvent:
  ....
    TimedOut,
    ModifyEvent,
    Reset
  };
//ETX

so that in the widget's constructor we could have:

  this->CallbackMapper->SetCallbackMethod(vtkCommand::KeyPressEvent,
                                          vtkEvent::ShiftModifier, 127, 1, 
"Delete",
                                          vtkWidgetEvent::Reset,
                                          this, 
vtkContourWidget::ResetAction);


I would appreciate any comments or suggestions you may have.
Attached is the modified code that allows continuous drawing.

Dean
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vtkContourWidget.cxx
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100305/e12dfe25/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vtkContourWidget.h
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100305/e12dfe25/attachment.h>


More information about the vtk-developers mailing list