vtkRenderWindowInteractor *rwi = this->Interactor;
std::string key = rwi->GetKeySym();
+ int ctrlKeyInd = rwi->GetControlKey();
+
+ int altKeyInd = rwi->GetAltKey();
+
+ int shiftKeyInd = rwi->GetShiftKey();
+
// Output the key that was pressed
std::cout << "Pressed " << key << std::endl;
// Handle an arrow key
if (key == "Up")
- {
- contourWidget =
- vtkSmartPointer<vtkContourWidget>::New();
- contourWidget->SetInteractor(interactor);
- contourWidget->SetRepresentation(contourRep);
- contourWidget->On();
-
- std::cout << "add and move points" << std::endl;
- contourWidget->GetEventTranslator()->RemoveTranslation(
- vtkCommand::LeftButtonPressEvent);
- contourWidget->GetEventTranslator()->SetTranslation(
- vtkCommand::LeftButtonPressEvent,
- vtkWidgetEvent::Translate);
-
- //contourWidget->Initialize(pd);
- //contourWidget->Render();
+ {
- //interactor->Initialize();
- //interactor->Start();
- //Interactor->Disable();
+ std::cout << "UP" << std::endl;
+
}
// Handle a "normal" key
if (key == "Down")
{
- std::cout << "Remove points" << std::endl;
- contourWidget->GetEventTranslator()->RemoveTranslation(
- vtkCommand::LeftButtonPressEvent);
- contourWidget->GetEventTranslator()->SetTranslation(
- vtkCommand::LeftButtonPressEvent,
- vtkWidgetEvent::Delete);
+ std::cout << "DOWN" << std::endl;
}
+ if (ctrlKeyInd != 0)
+ {
+ if (key == "z" || key == "Z")
+ {
+ std::cout << "undo" << std::endl;
+
+ }
+
+ if (key == "y" || key == "Y")
+ {
+ std::cout << "redo" << std::endl;
+
+ }
+ }
+
// Forward events
vtkInteractorStyleTrackballCamera::OnKeyPress();
}
vtkSmartPointer<vtkActor>::New();
planeActor->SetMapper(mapper);
- /*vtkSmartPointer<KeyPressInteractorStyle> style =
+ vtkSmartPointer<KeyPressInteractorStyle> style =
vtkSmartPointer<KeyPressInteractorStyle>::New();
- interactor->SetInteractorStyle(style);*/
+ interactor->SetInteractorStyle(style);
// create the contour stuff
vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep =
--- /dev/null
+#include "BinaryErodeImageFilter.h"
+#include <cpPlugins/Interface/Image.h>
+
+#include <itkBinaryErodeImageFilter.h>
+#include <itkImage.h>
+#include <itkBinaryBallStructuringElement.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::BinaryErodeImageFilter::
+BinaryErodeImageFilter( )
+ : Superclass( )
+{
+ this->m_ClassName = "cpPlugins::BasicFilters::BinaryErodeImageFilter";
+ this->m_ClassCategory = "ImageToImageFilter";
+ this->SetNumberOfInputs( 1 );
+ this->SetNumberOfOutputs( 1 );
+ this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+
+ using namespace cpPlugins::Interface;
+ this->m_DefaultParameters.Configure( Parameters::Uint, "Radius" );
+
+ this->m_DefaultParameters.SetValueAsUint( "Radius", 2 );
+
+ this->m_Parameters = this->m_DefaultParameters;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::BinaryErodeImageFilter::
+~BinaryErodeImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::BasicFilters::BinaryErodeImageFilter::
+_GenerateData( )
+{
+ cpPlugins::Interface::Image* image =
+ this->GetInput< cpPlugins::Interface::Image >( 0 );
+ if( image == NULL )
+ return( "BinaryErodeImageFilter: No input image." );
+
+ itk::DataObject* itk_image = NULL;
+ std::string r = "";
+ cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
+ else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
+ else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 );
+ else r = "BinaryErodeImageFilter: Input image type not supported.";
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::BasicFilters::BinaryErodeImageFilter::
+_GD0( itk::DataObject* image )
+{
+ return(
+ this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >(
+ image
+ )
+ );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+inline std::string cpPlugins::BasicFilters::BinaryErodeImageFilter::
+_RealGD( itk::DataObject* image )
+{
+ //typedef itk::Image<I, I::ImageDimension> ImageType;
+ typedef itk::BinaryBallStructuringElement< I::PixelType, I::ImageDimension> StructuringElementType;
+ typedef itk::BinaryErodeImageFilter< I, O, StructuringElementType > _F;
+ typedef typename _F::RadiusType _RT;
+
+ // Get parameters
+ _RT rad_val;
+ rad_val.Fill( this->m_Parameters.GetValueAsUint( "Radius" ) );
+
+ // Configure filter
+
+ StructuringElementType structuringElement;
+ structuringElement.SetRadius(rad_val);
+ structuringElement.CreateStructuringElement();
+
+
+
+ _F* filter = this->_CreateITK< _F >( );
+ filter->SetInput( dynamic_cast< I* >( image ) );
+ filter->SetKernel(structuringElement);
+ filter->Update( );
+
+ // Connect output
+ cpPlugins::Interface::Image* out =
+ this->GetOutput< cpPlugins::Interface::Image >( 0 );
+ if( out != NULL )
+ {
+ out->SetITK< O >( filter->GetOutput( ) );
+ return( "" );
+ }
+ else
+ return( "BinaryErodeImageFilter: output not correctly created." );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__PLUGINS__BinaryErodeImageFilter__H__
+#define __CPPLUGINS__PLUGINS__BinaryErodeImageFilter__H__
+
+#include <cpPlugins/BasicFilters/cpPluginsBasicFilters_Export.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+
+namespace cpPlugins
+{
+ namespace BasicFilters
+ {
+ /**
+ */
+ class cpPluginsBasicFilters_EXPORT BinaryErodeImageFilter
+ : public cpPlugins::Interface::ImageToImageFilter
+ {
+ public:
+ typedef BinaryErodeImageFilter Self;
+ typedef cpPlugins::Interface::ImageToImageFilter Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro(
+ BinaryErodeImageFilter,
+ cpPluginsInterfaceImageToImageFilter
+ );
+
+ protected:
+ BinaryErodeImageFilter( );
+ virtual ~BinaryErodeImageFilter( );
+
+ virtual std::string _GenerateData( );
+
+ template< class I >
+ inline std::string _GD0( itk::DataObject* image );
+
+ template< class I, class O >
+ inline std::string _RealGD( itk::DataObject* image );
+
+ private:
+ // Purposely not implemented
+ BinaryErodeImageFilter( const Self& );
+ Self& operator=( const Self& );
+ };
+
+ // ---------------------------------------------------------------------
+ CPPLUGINS_INHERIT_PROVIDER( BinaryErodeImageFilter );
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__BinaryErodeImageFilter__H__
+
+// eof - $RCSfile$