image_actors->AddInputData( image->GetVTK< vtkImageData >( ), 2 );
image_actors->PushActorsInto( window );
+ // Activate seed widget
+ TSliceActors::TStyle* style =
+ dynamic_cast< TSliceActors::TStyle* >( image_actors->GetStyle( ) );
+ if( style != NULL )
+ style->SeedWidgetOn( );
+
// Begin interaction
renderer->ResetCamera( );
window->Render( );
#include <cpExtensions/Interaction/ImageInteractorStyle.h>
#include <vtkImageActor.h>
+#include <vtkPropCollection.h>
+#include <vtkProperty.h>
#include <vtkRenderWindowInteractor.h>
+// -------------------------------------------------------------------------
+cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
+TSeedWidget( vtkRenderWindowInteractor* interactor, vtkImageActor* actor )
+{
+ this->Placer = vtkSmartPointer< vtkImageActorPointPlacer >::New( );
+ this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
+ this->Representation = vtkSmartPointer< vtkSeedRepresentation >::New( );
+ this->Widget = vtkSmartPointer< SeedWidget >::New( );
+
+ this->Placer->SetImageActor( actor );
+ this->Handle->GetProperty( )->SetColor( 1, 0, 0 );
+ this->Handle->SetPointPlacer( this->Placer );
+ this->Representation->SetHandleRepresentation( this->Handle );
+ this->Widget->SetRepresentation( this->Representation );
+ this->Widget->SetInteractor( interactor );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
+On( )
+{
+ this->Widget->On( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
+Off( )
+{
+ this->Widget->Off( );
+}
+
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageInteractorStyle::
Self* cpExtensions::Interaction::ImageInteractorStyle::
} // fi
}
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+SeedWidgetOn( )
+{
+ if( this->m_SeedWidget != NULL ) delete this->m_SeedWidget;
+
+ this->m_PropPicker->GetPickList( )->InitTraversal( );
+ this->m_SeedWidget = new TSeedWidget(
+ this->Interactor,
+ dynamic_cast< vtkImageActor* >(
+ this->m_PropPicker->GetPickList( )->GetNextProp( )
+ )
+ );
+ this->m_SeedWidget->On( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+SeedWidgetOff( )
+{
+ if( this->m_SeedWidget != NULL )
+ {
+ this->m_SeedWidget->Off( );
+ delete this->m_SeedWidget;
+ this->m_SeedWidget = NULL;
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageInteractorStyle::
ImageInteractorStyle( )
- : Superclass( )
+ : Superclass( ),
+ m_SeedWidget( NULL )
{
this->m_PropPicker = vtkSmartPointer< vtkPropPicker >::New( );
this->m_PropPicker->PickFromListOn( );
cpExtensions::Interaction::ImageInteractorStyle::
~ImageInteractorStyle( )
{
+ if( this->m_SeedWidget != NULL ) delete this->m_SeedWidget;
}
// -------------------------------------------------------------------------
// Widgets
struct TSeedWidget
{
- vtkSmartPointer< vtkImageActorPointPlacer > Placer;
- vtkSmartPointer< vtkPointHandleRepresentation3D > Handle;
- vtkSmartPointer< vtkSeedRepresentation > Representation;
- vtkSmartPointer< TSeedWidget > Widget;
-
- TSeedWidget( vtkRenderWindowInteractor* interactor, vtkImageActor* actor )
- {
- this->Placer = vtkSmartPointer< vtkImageActorPointPlacer >::New( );
- this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
- this->Representation = vtkSmartPointer< vtkSeedRepresentation >::New( );
- this->Widget = vtkSmartPointer< TSeedWidget >::New( );
-
- this->Placer->SetImageActor( actor );
- this->Handle->GetProperty( )->SetColor( 1, 0, 0 );
- this->Handle->SetPointPlacer( this->Placer );
- this->Representation->SetHandleRepresentation( this->Handle );
- this->Widget->SetRepresentation( this->Representation );
- this->Widget->SetInteractor( interactor );
- }
-
- void On( )
- {
- this->Widget->On( );
- }
-
- void Off( )
- {
- this->Widget->Off( );
- }
-#error ACA VOY
+ vtkSmartPointer< vtkImageActorPointPlacer > Placer;
+ vtkSmartPointer< vtkPointHandleRepresentation3D > Handle;
+ vtkSmartPointer< vtkSeedRepresentation > Representation;
+ vtkSmartPointer< SeedWidget > Widget;
+
+ TSeedWidget(
+ vtkRenderWindowInteractor* interactor, vtkImageActor* actor
+ );
+ void On( );
+ void Off( );
};
public:
// Data for local picker
virtual void AssociateImageActor( vtkImageActor* actor );
+ // Widgets
+ void SeedWidgetOn( );
+ void SeedWidgetOff( );
+
protected:
ImageInteractorStyle( );
virtual ~ImageInteractorStyle( );
protected:
vtkSmartPointer< vtkPropPicker > m_PropPicker;
+
+ TSeedWidget* m_SeedWidget;
};
} // ecapseman
SetInteractor( vtkRenderWindowInteractor* rwi )
{
this->Superclass::SetInteractor( rwi );
- TBaseStyle* s = dynamic_cast< TBaseStyle*>( rwi->GetInteractorStyle( ) );
- if( s != NULL )
+ if( rwi != NULL )
{
- s->AddMouseClickCommand( Self::_Click, this );
- s->AddMouseDoubleClickCommand( Self::_DoubleClick, this );
+ TBaseStyle* s =
+ dynamic_cast< TBaseStyle* >( rwi->GetInteractorStyle( ) );
+ if( s != NULL )
+ {
+ s->AddMouseClickCommand( Self::_Click, this );
+ s->AddMouseDoubleClickCommand( Self::_DoubleClick, this );
+
+ } // fi
} // fi
}
)
{
SeedWidget* self = reinterpret_cast< SeedWidget* >( data );
+ if( self == NULL )
+ return;
if( self->WidgetState == vtkSeedWidget::MovingSeed )
return;
} // fi
} // fi
- renderer->ResetCamera( );
+ this->ResetCamera( );
rwi->Render( );
}
return;
// Change visualization extent
+ int axis = this->GetAxis( );
for( unsigned int i = 0; i < nImages; ++i )
{
+ // Update mappers and display bounds
this->m_SliceMappers[ i ]->SetSliceNumber( slice );
this->m_SliceMappers[ i ]->Modified( );
this->m_ImageActors[ i ]->Modified( );
this->m_SliceMappers[ i ]->Update( );
+ // Update display extent (this isn't done automatically)
+ vtkImageData* image = this->m_SliceMappers[ i ]->GetInput( );
+ int ext[ 6 ];
+ image->GetExtent( ext );
+ ext[ axis << 1 ] = slice;
+ ext[ ( axis << 1 ) + 1 ] = slice;
+ this->m_ImageActors[ i ]->SetDisplayExtent( ext );
+
} // rof
double bnds[ 6 ];
plane->GeneralizedProjectPoint( x0[ 0 ], p0[ 0 ] );
plane->GeneralizedProjectPoint( x0[ 1 ], p0[ 1 ] );
- int axis = this->GetAxis( );
bnds[ 0 ] = p0[ 0 ][ 0 ];
bnds[ 1 ] = p0[ 1 ][ 0 ];
bnds[ 2 ] = p0[ 0 ][ 1 ];
this->m_Window->GetRenderers( )->GetFirstRenderer( );
if( renderer != NULL )
renderer->ResetCamera( );
+#error ACA VOY: reconfigurar la camara alrededor únicamente del plano.
}
// -------------------------------------------------------------------------