#include "SeedWidget.h"
+#include <vtkCommand.h>
#include <vtkProperty.h>
#include <vtkRenderWindowInteractor.h>
#include <cpExtensions/QT/SimpleMPRWidget.h>
+// -------------------------------------------------------------------------
+// This callback is responsible for changing update time
+namespace cpPluginsWidgets
+{
+ /**
+ */
+ class SeedWidgetCallback
+ : public vtkCommand
+ {
+ public:
+ static SeedWidgetCallback* New( )
+ { return( new SeedWidgetCallback ); }
+ virtual void Execute( vtkObject* caller, unsigned long id, void* data )
+ {
+ if(
+ id == vtkCommand::CursorChangedEvent ||
+ id == vtkCommand::PlacePointEvent
+ )
+ this->Widget->Modified( );
+ }
+ SeedWidget* Widget;
+ };
+
+} // ecapseman
+
// -------------------------------------------------------------------------
void cpPluginsWidgets::SeedWidget::WidgetData::
-Configure( vtkRenderWindowInteractor* interactor, vtkImageActor* actor )
+Configure(
+ cpPluginsWidgets::SeedWidget* parent,
+ vtkRenderWindowInteractor* interactor, vtkImageActor* actor
+ )
{
this->Placer = vtkSmartPointer< vtkImageActorPointPlacer >::New( );
this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
this->Seed->SetHandleRepresentation( this->Handle );
this->Widget->SetRepresentation( this->Seed );
this->Widget->SetInteractor( interactor );
+
+ vtkSmartPointer< SeedWidgetCallback > cb =
+ vtkSmartPointer< SeedWidgetCallback >::New( );
+ cb->Widget = parent;
+ this->Widget->AddObserver( vtkCommand::PlacePointEvent, cb );
+ this->Widget->AddObserver( vtkCommand::CursorChangedEvent, cb );
}
// -------------------------------------------------------------------------
this->Widget->Off( );
}
-// -------------------------------------------------------------------------
-itk::ModifiedTimeType cpPluginsWidgets::SeedWidget::
-GetMTime( ) const
-{
- this->Modified( );
- return( this->Superclass::GetMTime( ) );
-}
-
// -------------------------------------------------------------------------
cpPluginsWidgets::SeedWidget::
SeedWidget( )
void cpPluginsWidgets::SeedWidget::
_GenerateData( )
{
+ std::cout << "seeds" << std::endl;
if( this->m_Configured )
{
+ std::cout << "ok" << std::endl;
auto points = this->_CreateVTK< vtkPoints >( );
for(
auto wIt = this->m_Widgets.begin( );
if( actor != NULL )
{
WidgetData d;
- d.Configure( *iIt, actor );
+ d.Configure( this, *iIt, actor );
d.On( );
this->m_Widgets.push_back( d );
this->m_Configured = true;
} // rof
} // fi
- if( !( this->m_Configured ) )
+ if( this->m_Configured )
+ this->Modified( );
+ else
this->_Error(
"Could not create valid widget: are there any valid actors?"
);