]> Creatis software - cpPlugins.git/commitdiff
PolyLine updated.
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 10 Oct 2016 00:09:14 +0000 (19:09 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 10 Oct 2016 00:09:14 +0000 (19:09 -0500)
14 files changed:
lib/Instances/CMakeLists.txt
lib/Instances/cpPlugins_Paths.i
lib/cpBaseQtApplication/Block.cxx
lib/cpExtensions/DataStructures/PolyLineParametricPath.h
lib/cpExtensions/DataStructures/PolyLineParametricPath.hxx
lib/cpExtensions/Utility.h
lib/cpPlugins/BaseObjects/Widget.h
lib/cpPlugins/Interface/Plugins.cxx
plugins/Widgets/LineWidget.cxx
plugins/Widgets/LineWidget.h
plugins/Widgets/SeedWidget.cxx
plugins/Widgets/SeedWidget.h
plugins/Widgets/SplineWidget.cxx
plugins/Widgets/SplineWidget.h

index bf7d66505243d96188cc31d2d63d7e77d90b9ede..455a407927e8fc66f3bfe69c87aace427e18ebc9 100644 (file)
@@ -7,7 +7,7 @@ SET(_all_instances)
 FOREACH(_instance ${_instances})
   CompileInstances(
     _lib_name
-       ${PROJECT_BINARY_DIR}/lib
+    ${PROJECT_BINARY_DIR}/lib
     ${_instance} ${cpPlugins_NUMBER_OF_FILES}
     "" "${prj_VERSION}" "${prj_SHORT_VERSION}"
     )
index 2b8c8a814fc0c58dc32bce0497dda04d5d389824..7be53abd3fc66957b82187f274229f851039f598 100644 (file)
@@ -7,6 +7,7 @@
 ** ==============
 
 i cpPlugins_Images.h
+t cpExtensions/Algorithms/BezierCurveFunction
 t cpExtensions/DataStructures/PolyLineParametricPath
 t itkPath
 t itkParametricPath
@@ -21,6 +22,7 @@ t itkVectorContainer
 ** == Instances ==
 ** ===============
 
+c cpExtensions::Algorithms::BezierCurveFunction< itk::Vector< #reals#, #process?_dims# > >
 c itk::Path< double, itk::ContinuousIndex< double, #process_dims# >, #process_dims# >
 c itk::ParametricPath< #process_dims# >
 c itk::PolyLineParametricPath< #process_dims# >
index 36b579fb0eb208405a20470fbddc1b02658afdf3..5ee8f08776a639c1c3b8ea217207a9926a8b0465 100644 (file)
@@ -13,6 +13,7 @@
 #include <cpBaseQtApplication/Port.h>\r
 #include <cpBaseQtApplication/Connection.h>\r
 #include <cpBaseQtApplication/Editor.h>\r
+#include <cpPlugins/BaseObjects/Widget.h>\r
 \r
 // -------------------------------------------------------------------------\r
 cpBaseQtApplication::Block::\r
@@ -296,14 +297,27 @@ contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )
   QMenu menu;\r
   QAction* configureAction = menu.addAction( "Configure" );\r
   QAction* updateAction = menu.addAction( "Update" );\r
-  QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
+  auto widget =\r
+    dynamic_cast< cpPlugins::BaseObjects::Widget* >(\r
+      this->m_Filter.GetPointer( )\r
+      );\r
+  QAction* enableAction = NULL;\r
+  if( widget != NULL )\r
+    enableAction =\r
+      menu.addAction( ( widget->GetEnabled( ) )? "Disable": "Enable" );\r
 \r
+  QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
   if( selectedAction == configureAction )\r
   {\r
     auto dlg = this->m_Filter->CreateQDialog( );\r
     if( dlg != NULL )\r
       dlg->exec( );\r
   }\r
+  else if( selectedAction == enableAction )\r
+  {\r
+    if( widget != NULL )\r
+      widget->SetEnabled( !( widget->GetEnabled( ) ) );\r
+  }\r
   else if( selectedAction == updateAction )\r
     this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );\r
 }\r
index e8046eac90e76207393d1dcd66ed2e837d6761d0..3358d0fc4c13d130b6bb34b6ce23068c9eb8c2d3 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <itkPolyLineParametricPath.h>
 #include <itkImageBase.h>
+#include <cpExtensions/Algorithms/BezierCurveFunction.h>
 
 namespace cpExtensions
 {
@@ -26,6 +27,9 @@ namespace cpExtensions
       typedef typename TImageBase::DirectionType       TDirection;
       typedef typename Superclass::ContinuousIndexType TContinuousIndex;
 
+      typedef typename TPoint::VectorType TVector;
+      typedef cpExtensions::Algorithms::BezierCurveFunction< TVector > TBezier;
+
     public:
       itkNewMacro( Self );
       itkTypeMacro( PolyLineParametricPath, itk::PolyLineParametricPath );
@@ -38,9 +42,11 @@ namespace cpExtensions
       itkSetMacro( Origin, TPoint );
 
     public:
+      void AddVertex( const TContinuousIndex& vertex );
       unsigned long GetSize( ) const;
       TContinuousIndex GetVertex( unsigned long i ) const;
       TPoint GetPoint( unsigned long i ) const;
+      TPoint GetSmoothPoint( double u ) const;
 
       virtual void SetSpacing( const TSpacing& spac );
       virtual void SetSpacing( const double spac[ _VDim ] );
@@ -69,6 +75,8 @@ namespace cpExtensions
       Self& operator=( const Self& other );
 
     protected:
+      typename TBezier::Pointer m_Bezier;
       TSpacing   m_Spacing;
       TPoint     m_Origin;
       TDirection m_Direction;
index 306ab79fe41fda72fa44de5d1f36043fc100e5c2..5e26816e47876a55d8501f8aad605a0b6381bdeb 100644 (file)
@@ -4,6 +4,18 @@
 #include <itkMath.h>
 #include <itkNumericTraits.h>
 
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+void cpExtensions::DataStructures::PolyLineParametricPath< _VDim >::
+AddVertex( const TContinuousIndex& vertex )
+{
+  this->Superclass::AddVertex( vertex );
+  this->m_Bezier->AddPoint(
+    this->GetPoint( this->GetSize( ) - 1 ).GetVectorFromOrigin( )
+    );
+  this->Modified( );
+}
+
 // -------------------------------------------------------------------------
 template< unsigned int _VDim >
 unsigned long cpExtensions::DataStructures::PolyLineParametricPath< _VDim >::
@@ -42,6 +54,18 @@ GetPoint( unsigned long i ) const
   return( pnt );
 }
 
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+typename cpExtensions::DataStructures::PolyLineParametricPath< _VDim >::
+TPoint cpExtensions::DataStructures::PolyLineParametricPath< _VDim >::
+GetSmoothPoint( double u ) const
+{
+  TPoint p;
+  p.Fill( 0 );
+  p += this->m_Bezier->Evaluate( u );
+  return( p );
+}
+
 // -------------------------------------------------------------------------
 template< unsigned int _VDim >
 void cpExtensions::DataStructures::PolyLineParametricPath< _VDim >::
@@ -129,6 +153,8 @@ cpExtensions::DataStructures::PolyLineParametricPath< _VDim >::
 PolyLineParametricPath( )
   : Superclass( )
 {
+  this->m_Bezier = TBezier::New( );
+
   this->m_Spacing.Fill( 1.0 );
   this->m_Origin.Fill( 0.0 );
   this->m_Direction.SetIdentity( );
index 28677864b915423b9e43931556b56780eae9b817..b79f37985be42382e0d9ca36c156d2b06a29a152 100644 (file)
@@ -17,9 +17,9 @@
 #endif // cpExtensions_OS_Windows
 
 // -------------------------------------------------------------------------
-#define cpExtensions_CHRONO                                             \
-  std::chrono::duration_cast< std::chrono::milliseconds >(              \
-    std::chrono::system_clock::now( ).time_since_epoch( )               \
+#define cpExtensions_CHRONO                                     \
+  std::chrono::duration_cast< std::chrono::milliseconds >(      \
+    std::chrono::system_clock::now( ).time_since_epoch( )       \
     ).count( )
 
 // -------------------------------------------------------------------------
index 1451b7b0f1ae16aa2dee0456cb7e31ed3f8e1faf..83960e6387c3a3f198cb87f3c4246fd85643a5c3 100644 (file)
@@ -32,6 +32,7 @@ namespace cpPlugins
       virtual void EnabledOff( );
       virtual void Clear( ) = 0;
       virtual void SetEnabled( bool v ) = 0;
+      virtual bool GetEnabled( ) const = 0;
 
     protected:
       Widget( );
index 260172e467c41e1b0d93ca5a1d0d6d419189aaa7..c114404b1e332602749ebca4f24f045120e0c20c 100644 (file)
@@ -127,15 +127,15 @@ LoadEnvironments( )
                 {
                   if( fname.substr( pos ) == ext )
                   {
-           std::regex re( lib );
-std::smatch match;
-if( std::regex_search( fname, match, re ) && match.size( ) >= 1 )
- {
-            std::stringstream str;
-            str
-              << pth << cpPlugins_PATH_SEPARATOR << fname;
-            libs.insert( str.str( ) );
-  } // fi
+                    std::regex re( lib );
+                    std::smatch match;
+                    if( std::regex_search( fname, match, re ) && match.size( ) >= 1 )
                   {
+                      std::stringstream str;
+                      str
+                        << pth << cpPlugins_PATH_SEPARATOR << fname;
+                      libs.insert( str.str( ) );
+                    } // fi
 
                   } // fi
 
@@ -169,13 +169,13 @@ if( std::regex_search( fname, match, re ) && match.size( ) >= 1 )
     if( lib != "" )
     {
       if( this->m_Libraries.find( lib ) == this->m_Libraries.end( ) )
-{
-          std::string error = "";
-          void* hnd = cpPlugins::OS::DLLManager::Load( lib, error );
-          if( hnd != NULL )
-            this->m_Libraries[ lib ] = hnd;
+      {
+        std::string error = "";
+        void* hnd = cpPlugins::OS::DLLManager::Load( lib, error );
+        if( hnd != NULL )
+          this->m_Libraries[ lib ] = hnd;
 
-} // fi
+      } // fi
 
     } // fi
 
@@ -191,16 +191,16 @@ LoadPaths( const std::string& dir )
   if( !cpExtensions::IsPathSeparator( dir.back( ) ) )
     fname << cpExtensions_PATH_SEPARATOR;
   fname << cpPlugins_PATHS;
-    std::string buffer;
-    if( cpExtensions::Read( buffer, fname.str( ) ) )
-    {
-      std::istringstream input( buffer );
-      for( std::string line; std::getline( input, line ); )
-        envs << line << cpPlugins_ENV_SEPARATOR;
+  std::string buffer;
+  if( cpExtensions::Read( buffer, fname.str( ) ) )
+  {
+    std::istringstream input( buffer );
+    for( std::string line; std::getline( input, line ); )
+      envs << line << cpPlugins_ENV_SEPARATOR;
 
-    } // fi
-    if( envs.str( ).size( ) > 0 )
-      this->AddEnvironments( envs.str( ) );
+  } // fi
+  if( envs.str( ).size( ) > 0 )
+    this->AddEnvironments( envs.str( ) );
 }
 
 // -------------------------------------------------------------------------
index 8887463e1252e9a175bdf7ac8cbdc9d2eafcf24b..953aa4dd0337f5567081af275fb46e6745e405c4 100644 (file)
@@ -30,6 +30,20 @@ SetEnabled( bool v )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+bool cpPluginsWidgets::LineWidget::
+GetEnabled( ) const
+{
+  auto wdg = this->GetVTK< const vtkLineWidget2 >( );
+  if( wdg != NULL )
+  {
+    vtkLineWidget2* w = const_cast< vtkLineWidget2* >( wdg );
+    return( w->GetEnabled( ) != 0 );
+  }
+  else
+    return( false );
+}
+
 // -------------------------------------------------------------------------
 cpPluginsWidgets::LineWidget::
 LineWidget( )
index 281cacdd790f43d33cbeae91cae458b71d81961c..bd65e847d80b90f32d725a7c4a190cf1a22b9857 100644 (file)
@@ -22,6 +22,7 @@ namespace cpPluginsWidgets
   public:
     virtual void Clear( ) cpPlugins_OVERRIDE;
     virtual void SetEnabled( bool v ) cpPlugins_OVERRIDE;
+    virtual bool GetEnabled( ) const cpPlugins_OVERRIDE;
 
   protected:
     typedef std::set< vtkProp* > TProps;
index f0c9094e80e639b3494e1b51c5c7cf5a1155c5c2..fe19381e96eec259beaf299f35bdb9e56cede84c 100644 (file)
@@ -36,6 +36,20 @@ SetEnabled( bool v )
   } // rof
 }
 
+// -------------------------------------------------------------------------
+bool cpPluginsWidgets::SeedWidget::
+GetEnabled( ) const
+{
+  if( this->m_Widgets.size( ) > 0 )
+  {
+    auto i = this->m_Widgets.begin( );
+    TWidget* w = const_cast< TWidget* >( i->second.GetPointer( ) );
+    return( w->GetEnabled( ) != 0 );
+  }
+  else
+    return( false );
+}
+
 // -------------------------------------------------------------------------
 cpPluginsWidgets::SeedWidget::
 SeedWidget( )
index 7449b948def012cd689370628dc9b586398bfd57..945ee037d7d5fc4be63cf6b14251a7426b187820 100644 (file)
@@ -41,6 +41,7 @@ namespace cpPluginsWidgets
   public:
     virtual void Clear( ) cpPlugins_OVERRIDE;
     virtual void SetEnabled( bool v ) cpPlugins_OVERRIDE;
+    virtual bool GetEnabled( ) const cpPlugins_OVERRIDE;
 
   protected:
     /**
index 057d4e783d10e7407d6ec8ae5a62cc24b997242d..a1b153885924ac396e6d634f2ea62cf8d6b6cdca 100644 (file)
@@ -26,6 +26,20 @@ SetEnabled( bool v )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+bool cpPluginsWidgets::SplineWidget::
+GetEnabled( ) const
+{
+  auto wdg = this->GetVTK< const vtkSplineWidget >( );
+  if( wdg != NULL )
+  {
+    vtkSplineWidget* w = const_cast< vtkSplineWidget* >( wdg );
+    return( w->GetEnabled( ) != 0 );
+  }
+  else
+    return( false );
+}
+
 // -------------------------------------------------------------------------
 cpPluginsWidgets::SplineWidget::
 SplineWidget( )
index 7eaeccdabeefcf1e6ff4698f827beed43a503e14..d89ccb7ef316e87b813bac0cc1e4396d20f2ca0d 100644 (file)
@@ -32,6 +32,7 @@ namespace cpPluginsWidgets
   public:
     virtual void Clear( ) cpPlugins_OVERRIDE;
     virtual void SetEnabled( bool v ) cpPlugins_OVERRIDE;
+    virtual bool GetEnabled( ) const cpPlugins_OVERRIDE;
 
   protected:
     bool m_Configured;