I am struggle to select an widget in order to delete it. I have an 2d image actor, and over this actor I intend to spread widgets. Nothing special. I have tried vtkDistanceWidget. Take a look what I have tried:
void CVTKDoc::CreateDistanceWidget(CVTKView* pView)
{
vtkDistanceWidget* pDistanceWidget = vtkDistanceWidget::New();
pDistanceWidget->SetInteractor(pView->m_pInteractor);
pDistanceWidget->CreateDefaultRepresentation();
static_cast<vtkDistanceRepresentation*>(pDistanceWidget->GetRepresentation())->SetLabelFormat(_T("%-#6.3g mm"));
pDistanceWidget->On();
m_pPropPicker->PickFromListOn();
m_pPropPicker->AddPickList(vtkDistanceRepresentation2D::SafeDownCast(pDistanceWidget->GetRepresentation())->GetAxis());
vtkDistanceWidgetCommand* pDistanceWidgetCommand = vtkDistanceWidgetCommand::New();
m_pPropPicker->AddObserver(vtkCommand::PickEvent, pDistanceWidgetCommand);
pDistanceWidgetCommand->Delete();
}
where m_pPropPicker is vtkPropPicker kind.
Here is the definition of vtkDistanceWidgetCommand:
#pragma once
#include <vtkCommand.h>
class vtkDistanceWidgetCommand : public vtkCommand
{
protected:
vtkDistanceWidgetCommand();
public:
virtual ~vtkDistanceWidgetCommand();
static vtkDistanceWidgetCommand* New() { return new vtkDistanceWidgetCommand; }
virtual void Execute(vtkObject* pCaller, unsigned long event, void* callData);
};
and
#include "stdafx.h"
#include "vtkDistanceWidgetCommand.h"
vtkDistanceWidgetCommand::vtkDistanceWidgetCommand()
{
}
vtkDistanceWidgetCommand::~vtkDistanceWidgetCommand()
{
}
void vtkDistanceWidgetCommand::Execute(vtkObject* pCaller, unsigned long event, void* callData)
{
TRACE("======================================================\n");
}
but when I click on 2d image, even if I click over the widget or not, Isee no trace … prove that my code is not functional. For this solution, I got from here:
http://vtk.1045678.n5.nabble.com/Interactor-on-vtkWidget-td2848124.html
this idea. Can you lead me into solve this task ? I really need it !