[vtkusers] Error while passing Data to vtkCommand

Michael Knopke Michael.Knopke at gmx.de
Tue Feb 21 18:34:55 EST 2006


Hello vtkusers,
I'm new to the forum so welcome everybody.
I want to use the vtkCommand to react to an Interaction. Everything
compiles but I get access violation errors while trying to access a pointer that
was passed to vtkCommand. Strangely this does only occur with
vtkObjects not with say a slider (Borland CBuilder)...


here is the code:

class CallbackWidget : public vtkCommand
{
public:
        static CallbackWidget* New() {


                return new CallbackWidget;
        }
        void SetImageViewer (vtkImageViewer2 *iV);

        vtkImageViewer2 *newImageViewer;

        virtual void Execute(vtkObject* caller, unsigned long, void *callData) {

                newImageViewer->SetColorWindow();
                }
};

void CallbackWidget::SetImageViewer (vtkImageViewer2 *iV)
{
 newImageViewer = reinterpret_cast<vtkImageViewer2*>(iV);
 //or:
 // newImageViewer = iV;
}

//then I create an Instance of CallbackWidget and imageViewer2;

vtkImageViewer2 *imageViewer = vtkImageViewer::New();
SetInput...
...

CallbackWidget *myCallback = CallbackWidget::New();
 myCallback->SetSlider(imageViewer);

// and add an observer to an object
 imagePlaneWidget->AddObserver(vtkCommand::InteractionEvent,
 myCallback);


 PS: I tried with different objects and methods, all the same.

 Michael





More information about the vtkusers mailing list