+#include <cpExtensions/Visualization/MPRActors.h>
+
+// -------------------------------------------------------------------------
+typedef cpPlugins::Interface::Interface TInterface;
+typedef cpPlugins::Interface::ProcessObject TFilter;
+typedef cpPlugins::Interface::Parameters TParameters;
+typedef cpPlugins::Interface::Image TImage;
+
+typedef cpExtensions::Visualization::MPRActors TMPRActors;
+
+// -------------------------------------------------------------------------
+class SliderCallback
+ : public vtkCommand
+{
+public:
+ static SliderCallback* New( )
+ {
+ return new SliderCallback;
+ }
+ virtual void Execute( vtkObject* caller, unsigned long eId , void* data )
+ {
+ vtkSliderWidget* wdg =
+ reinterpret_cast< vtkSliderWidget* >( caller );
+ if( wdg == NULL )
+ return;
+ vtkSliderRepresentation* rep =
+ static_cast< vtkSliderRepresentation* >(
+ wdg->GetRepresentation( )
+ );
+ if( rep == NULL )
+ return;
+ std::string title = rep->GetTitleText( );
+ if( title == "X" )
+ this->Actors->SetSlice( 0, int( rep->GetValue( ) ) );
+ else if( title == "Y" )
+ this->Actors->SetSlice( 1, int( rep->GetValue( ) ) );
+ else if( title == "Z" )
+ this->Actors->SetSlice( 2, int( rep->GetValue( ) ) );
+ else if( title == "Window" )
+ this->Actors->SetWindow( rep->GetValue( ) );
+ else if( title == "Level" )
+ this->Actors->SetLevel( rep->GetValue( ) );
+ }
+ SliderCallback( )
+ : vtkCommand( )
+ {
+ }
+
+public:
+ TMPRActors* Actors;
+};
+
+// -------------------------------------------------------------------------
+struct Slider
+{
+ vtkSmartPointer< vtkSliderRepresentation2D > Representation;
+ vtkSmartPointer< vtkSliderWidget > Widget;
+
+ Slider(
+ double min_value,
+ double max_value,
+ double value,
+ const std::string& title,
+ vtkRenderWindowInteractor* iren,
+ double p1x, double p1y, double p2x, double p2y,
+ SliderCallback* callback = NULL
+ )
+ {
+ this->Representation =
+ vtkSmartPointer< vtkSliderRepresentation2D >::New( );
+ this->Representation->SetMinimumValue( min_value );
+ this->Representation->SetMaximumValue( max_value );
+ this->Representation->SetValue( value );
+ this->Representation->SetTitleText( title.c_str( ) );
+ this->Representation->GetPoint1Coordinate( )->
+ SetCoordinateSystemToNormalizedDisplay();
+ this->Representation->GetPoint1Coordinate( )->
+ SetValue( p1x, p1y );
+ this->Representation->GetPoint2Coordinate( )->
+ SetCoordinateSystemToNormalizedDisplay();
+ this->Representation->GetPoint2Coordinate( )->SetValue( p2x, p2y );
+
+ this->Widget = vtkSmartPointer< vtkSliderWidget >::New( );
+ this->Widget->SetInteractor( iren );
+ this->Widget->SetRepresentation( this->Representation );
+ this->Widget->SetAnimationModeToAnimate( );
+ this->Widget->EnabledOn( );
+ if( callback != NULL )
+ this->Widget->AddObserver( vtkCommand::InteractionEvent, callback );
+ }
+};
+
+// -------------------------------------------------------------------------