]> Creatis software - cpPlugins.git/commitdiff
Merge ssh://git.creatis.insa-lyon.fr/cpPlugins
authorjose guzman <jose@gmail.com>
Thu, 8 Oct 2015 15:54:55 +0000 (17:54 +0200)
committerjose guzman <jose@gmail.com>
Thu, 8 Oct 2015 15:54:55 +0000 (17:54 +0200)
CMakeLists.txt
appli/examples/example_ContourWidget.cxx
lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx [new file with mode: 0644]
lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.h [new file with mode: 0644]

index c15e1286d6f72ea8aa4a09aa2ed9595b83fca595..76b21ce10d7efb99d67b0bb61fddbc09a66cd609 100644 (file)
@@ -47,16 +47,19 @@ ENDIF(BUILD_SHARED_LIBRARIES)
 ## = Packages and options =
 ## ========================
 
-INCLUDE(CheckCXXCompilerFlag)
-CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
-IF(COMPILER_SUPPORTS_CXX11)
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-ELSEIF(COMPILER_SUPPORTS_CXX0X)
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-ELSE()
-  MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
-ENDIF()
+# it seems that by default on Visual Studio Compiler supports c++11, so it only need to be test on other O.S.
+       if(NOT MSVC)
+       INCLUDE(CheckCXXCompilerFlag)
+       CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+       CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+       IF(COMPILER_SUPPORTS_CXX11)
+         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+       ELSEIF(COMPILER_SUPPORTS_CXX0X)
+         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+       ELSE()
+         MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
+       ENDIF()
+endif(NOT MSVC)
 
 # Prepare header to build shared libs (windows)
 INCLUDE(GenerateExportHeader)
index a523ce6c1c654839e0ef38e183884995e23c179b..c3b405cde3c3d59440d9bd94831d66771f1a5746 100644 (file)
@@ -48,45 +48,45 @@ public:
                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();
        }
@@ -195,9 +195,9 @@ int main(int argc, char *argv[])
                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 =
diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx
new file mode 100644 (file)
index 0000000..2bcfa2d
--- /dev/null
@@ -0,0 +1,102 @@
+#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$
diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.h
new file mode 100644 (file)
index 0000000..2a77bbc
--- /dev/null
@@ -0,0 +1,60 @@
+#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
+        );
+         cpPlugins_Id_Macro(
+                 cpPlugins::BasicFilters::BinaryErodeImageFilter,
+                 "ImageToImageFilter"
+                 );
+
+    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$