I created a vtkButtonWidget and want to do some work when I click the buttonwidget with the left button of mouse, so I add a observer to the buttonwidget, but when I click ,it has no action. what is wrong with the codes?
class vtkButtonCallback : public vtkCommand
{
public:
static vtkButtonCallback *New()
{
return new vtkButtonCallback;
}
virtual void Execute(vtkObject caller, unsigned long, void)
{
if (ev == vtkCommand::LeftButtonPressEvent)
{
return;
}
}
};
// Create the widget and its representation
vtkSmartPointer<vtkTexturedButtonRepresentation2D> buttonRepresentation =
vtkSmartPointer<vtkTexturedButtonRepresentation2D>::New();
buttonRepresentation->SetNumberOfStates(1);
buttonRepresentation->SetButtonTexture(0, image1);
vtkSmartPointer<vtkButtonWidget> buttonWidget =
vtkSmartPointer<vtkButtonWidget>::New();
buttonWidget->SetInteractor(renderWindowInteractor);
buttonWidget->SetRepresentation(buttonRepresentation);
vtkButtonCallback *myBtnCallback = vtkButtonCallback::New();
buttonWidget->AddObserver(vtkCommand::LeftButtonPressEvent, myBtnCallback);