]> Creatis software - cpPlugins.git/commitdiff
Minor visual glitches
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 22 Oct 2015 00:19:40 +0000 (19:19 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 22 Oct 2015 00:19:40 +0000 (19:19 -0500)
CMakeLists.txt
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpExtensions/Visualization/ImageSliceActors.h
lib/cpExtensions/Visualization/MPRActors.cxx
lib/cpPlugins/Interface/BaseMPRWindow.cxx
lib/cpPlugins/Plugins/IO/ImageReader.cxx

index fd4ebea50ad78735129b0ce6751b1a68d9a7f147..45ffbb0fd33ce6c0255298bb8d3027f01d9b43d1 100644 (file)
@@ -21,13 +21,10 @@ ENDFOREACH(policy)
 ## ================
 
 PROJECT(cpPlugins)
-SET(prj_MAJOR_VERSION   "0")
-SET(prj_MINOR_VERSION   "0")
-SET(prj_RELEASE_VERSION "1")
-SET(
-  prj_VERSION
-  "${prj_MAJOR_VERSION}.${prj_MINOR_VERSION}.${prj_RELEASE_VERSION}"
-  )
+SET(prj_MAJ_VER "0")
+SET(prj_MIN_VER "0")
+SET(prj_REL_VER "1")
+SET(prj_VERSION "${prj_MAJ_VER}.${prj_MIN_VER}.${prj_REL_VER}")
 
 ## ===========
 ## = Options =
@@ -36,30 +33,31 @@ SET(
 OPTION(USE_QT4 "Build Qt4-based code" OFF)
 OPTION(BUILD_EXAMPLES "Build examples" OFF)
 
-OPTION(BUILD_SHARED_LIBRARIES "Build libraries as shared" OFF)
-IF(BUILD_SHARED_LIBRARIES)
-  SET(LIBRARY_TYPE SHARED)
-ELSE(BUILD_SHARED_LIBRARIES)
-  SET(LIBRARY_TYPE STATIC)
-ENDIF(BUILD_SHARED_LIBRARIES)
+SET(LIBRARY_TYPE SHARED)
 
 ## ========================
 ## = Packages and options =
 ## ========================
 
+# Force c++11 language version
 # NOTE: 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()
+  ELSE(COMPILER_SUPPORTS_CXX11)
+    CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+    IF(COMPILER_SUPPORTS_CXX0X)
+      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+    ELSE(COMPILER_SUPPORTS_CXX0X)
+      MESSAGE(
+        FATAL_ERROR
+        "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support."
+        )
+    ENDIF(COMPILER_SUPPORTS_CXX0X)
+  ENDIF(COMPILER_SUPPORTS_CXX11)
 ENDIF(NOT MSVC)
 
 # Prepare header to build shared libs (windows)
index 8287399d509c2debd9eb057895870274b483b7a9..3fedb5ca50d30191f3726b4a10abcc6fc1e0f308 100644 (file)
@@ -133,7 +133,20 @@ AddInputConnection( vtkAlgorithmOutput* aout, int axis )
   }
   else
     this->m_ImageMaps.push_back( new_map );
-  
+
+  // Update window level values
+  if( new_map != NULL )
+  {
+    double range[ 2 ];
+    dynamic_cast< vtkImageData* >( new_map->GetInput( ) )->
+      GetScalarRange( range );
+    this->m_MinWindow = double( 0 );
+    this->m_MaxWindow = range[ 1 ] - range[ 0 ];
+    this->m_MinLevel = range[ 0 ];
+    this->m_MaxLevel = range[ 1 ];
+
+  } // fi
+
   // Create mapper and actors
   vtkSmartPointer< vtkImageSliceMapper > mapper =
     vtkSmartPointer< vtkImageSliceMapper >::New( );
@@ -149,6 +162,18 @@ AddInputConnection( vtkAlgorithmOutput* aout, int axis )
 void cpExtensions::Visualization::ImageSliceActors::
 AddInputData( vtkImageData* data, int axis )
 {
+  // Update window level values
+  if( this->m_ImageMaps.size( ) == 0 )
+  {
+    double range[ 2 ];
+    data->GetScalarRange( range );
+    this->m_MinWindow = double( 0 );
+    this->m_MaxWindow = range[ 1 ] - range[ 0 ];
+    this->m_MinLevel = range[ 0 ];
+    this->m_MaxLevel = range[ 1 ];
+
+  } // fi
+
   // Configure LUT, if possible (NULL is returned if not)
   this->_ConfigureNewLUT( data );
   vtkImageMapToColors* new_map = *( this->m_ImageMaps.rbegin( ) );
@@ -174,6 +199,12 @@ AddInputData( vtkImageData* data, int axis )
 void cpExtensions::Visualization::ImageSliceActors::
 Clear( )
 {
+  // Reset values
+  this->m_MinWindow = double( 0 );
+  this->m_MaxWindow = double( 0 );
+  this->m_MinLevel = double( 0 );
+  this->m_MaxLevel = double( 0 );
+
   // Unbind from container
   this->RemoveAllItems( );
 
@@ -347,17 +378,17 @@ PushActorsInto( vtkRenderWindow* window, bool force_style )
     if( axis == 0 )
     {
       camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
-      camera->SetViewUp  ( double( 0 ), double( 1 ), double( 0 ) );
+      camera->SetViewUp  ( double( 0 ), double( 0 ), double( 1 ) );
     }
     else if( axis == 1 )
     {
-      camera->SetPosition( double( 0 ), double( 1 ), double(  0 ) );
-      camera->SetViewUp  ( double( 0 ), double( 0 ), double( -1 ) );
+      camera->SetPosition( double( 0 ), double( 1 ), double( 0 ) );
+      camera->SetViewUp  ( double( 0 ), double( 0 ), double( 1 ) );
     }
     else // if( axis == 2 )
     {
-      camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
-      camera->SetViewUp  ( double( 0 ), double( 1 ), double( 0 ) );
+      camera->SetPosition( double( 0 ), double(  0 ), double( 1 ) );
+      camera->SetViewUp  ( double( 0 ), double( -1 ), double( 0 ) );
 
     } // fi
 
@@ -511,18 +542,29 @@ GetDisplayBounds( double bounds[ 6 ] ) const
 void cpExtensions::Visualization::ImageSliceActors::
 ResetCursor( )
 {
-  vtkPoints* points = this->m_Cursor->GetPoints( );
-  points->SetPoint( 0, 0, 0, 0 );
-  points->SetPoint( 1, 0, 0, 0 );
-  points->SetPoint( 2, 0, 0, 0 );
-  points->SetPoint( 3, 0, 0, 0 );
-  points->SetPoint( 4, 0, 0, 0 );
-  points->SetPoint( 5, 0, 0, 0 );
-  points->SetPoint( 6, 0, 0, 0 );
-  points->SetPoint( 7, 0, 0, 0 );
-  this->m_Cursor->Modified( );
-  this->m_CursorMapper->Modified( );
-  this->m_CursorActor->Modified( );
+  if( this->m_SliceMappers.size( ) > 0 )
+  {
+    double bounds[ 6 ];
+    this->m_SliceMappers[ 0 ]->GetInput( )->GetBounds( bounds );
+    double pos[] = { bounds[ 0 ], bounds[ 2 ], bounds[ 4 ] };
+    this->SetCursor( pos );
+  }
+  else
+  {
+    vtkPoints* points = this->m_Cursor->GetPoints( );
+    points->SetPoint( 0, 0, 0, 0 );
+    points->SetPoint( 1, 0, 0, 0 );
+    points->SetPoint( 2, 0, 0, 0 );
+    points->SetPoint( 3, 0, 0, 0 );
+    points->SetPoint( 4, 0, 0, 0 );
+    points->SetPoint( 5, 0, 0, 0 );
+    points->SetPoint( 6, 0, 0, 0 );
+    points->SetPoint( 7, 0, 0, 0 );
+    this->m_Cursor->Modified( );
+    this->m_CursorMapper->Modified( );
+    this->m_CursorActor->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -671,12 +713,11 @@ SetWindow( double w )
   if( lut == NULL )
     return;
 
-  /* TODO: Min and Max values are assigned 0!!!
-     if( w < this->MinWindow )
-     w = this->MinWindow;
-     if( w > this->MaxWindow )
-     w = this->MaxWindow;
-  */
+  if( w < this->m_MinWindow )
+    w = this->m_MinWindow;
+  if( w > this->m_MaxWindow )
+    w = this->m_MaxWindow;
+
   lut->SetWindow( w );
   lut->Build( );
   this->m_ImageMaps[ 0 ]->Modified( );
@@ -698,12 +739,11 @@ SetLevel( double l )
   if( lut == NULL )
     return;
 
-  /* TODO: Min and Max values are assigned 0!!!
-     if( l < this->MinLevel )
-     l = this->MinLevel;
-     if( l > this->MaxLevel )
-     l = this->MaxLevel;
-  */
+  if( l < this->m_MinLevel )
+    l = this->m_MinLevel;
+  if( l > this->m_MaxLevel )
+    l = this->m_MaxLevel;
+
   lut->SetLevel( l );
   lut->Build( );
   this->m_ImageMaps[ 0 ]->Modified( );
@@ -725,16 +765,15 @@ SetWindowLevel( double w, double l )
   if( lut == NULL )
     return;
 
-  /* TODO: Min and Max values are assigned 0!!!
-     if( w < this->MinWindow )
-     w = this->MinWindow;
-     if( w > this->MaxWindow )
-     w = this->MaxWindow;
-     if( l < this->MinLevel )
-     l = this->MinLevel;
-     if( l > this->MaxLevel )
-     l = this->MaxLevel;
-  */
+  if( w < this->m_MinWindow )
+    w = this->m_MinWindow;
+  if( w > this->m_MaxWindow )
+    w = this->m_MaxWindow;
+  if( l < this->m_MinLevel )
+    l = this->m_MinLevel;
+  if( l > this->m_MaxLevel )
+    l = this->m_MaxLevel;
+
   lut->SetWindow( w );
   lut->SetLevel( l );
   lut->Build( );
@@ -1109,6 +1148,8 @@ _ConfigureStyle( )
   this->m_Style->AddMouseClickCommand( Self::_MouseClickCommand, this );
   this->m_Style->AddMouseWheelCommand( Self::_MouseWheelCommand, this );
   this->m_Style->AddKeyCommand( Self::_KeyCommand, this );
+  this->m_Style->AddEnterCommand( Self::_EnterCommand, this );
+  this->m_Style->AddLeaveCommand( Self::_LeaveCommand, this );
 }
 
 // -------------------------------------------------------------------------
@@ -1140,11 +1181,6 @@ _ConfigureNewLUT( vtkImageData* data )
     lut->SetLevel( ( range[ 1 ] + range[ 0 ] ) / double( 2 ) );
     lut->Build( );
     this->m_ImageMaps[ 0 ]->SetLookupTable( lut );
-
-    this->m_MinWindow = double( 0 );
-    this->m_MaxWindow = range[ 1 ] - range[ 0 ];
-    this->m_MinLevel = range[ 0 ];
-    this->m_MaxLevel = range[ 1 ];
   }
   else
     this->SetLookupTableAsColor( nImgs, 1, 0, 0 );
@@ -1180,6 +1216,7 @@ _ConfigureNewInput( int axis )
     this->SetSliceNumber( this->GetSliceNumber( ) );
   else
     this->SetSliceNumber( this->GetSliceNumberMaxValue( ) );
+  this->ResetCursor( );
   this->Modified( );
 }
 
@@ -1203,18 +1240,15 @@ _MouseMoveCommand(
   }
   else if( btn == TStyle::ButtonID_Left )
   {
-    /* TODO
-       unsigned int nC = actors->m_SlicesCommands.size( );
-       if( !alt && ctr && !sft && nC > 0 )
-       {
-       for( unsigned int i = 0; i < nC; ++i )
-       actors->m_SlicesCommands[ i ].first(
-       pos, actors->GetAxis( ), actors->m_SlicesCommands[ i ].second
-       );
-       actors->Render( );
-
-       } // fi
-    */
+    if( !alt && ctr && !sft )
+    {
+      // Interactively move slices
+      auto i = actors->m_SlicesCommands.begin( );
+      for( ; i != actors->m_SlicesCommands.end( ); ++i )
+        i->first( pos, actors->GetAxis( ), i->second );
+      actors->Render( );
+
+    } // fi
   }
   else if( btn == TStyle::ButtonID_Right )
   {
@@ -1341,4 +1375,30 @@ _KeyCommand( void* data, const char& key )
   } // hctiws
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+_EnterCommand( void* data )
+{
+  ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
+  if( actors == NULL )
+    return;
+
+  actors->ResetCursor( );
+  actors->m_CursorActor->VisibilityOn( );
+  actors->Render( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+_LeaveCommand( void* data )
+{
+  ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
+  if( actors == NULL )
+    return;
+
+  actors->ResetCursor( );
+  actors->m_CursorActor->VisibilityOff( );
+  actors->Render( );
+}
+
 // eof - $RCSfile$
index 5349dac2a1eeec319b791c8d41e97c5847779488..c5165c5665d5b7a2ab3f58b6240dd7fc53ea2c61 100644 (file)
@@ -157,6 +157,8 @@ namespace cpExtensions
         void* data,
         const char& key
         );
+      static void _EnterCommand( void* data );
+      static void _LeaveCommand( void* data );
 
     private:
       // Purposely not implemented
index d814fe794cae1938d9e7257e0769fd69d05a3a12..150651e860bb9ddc61bd9e3016d4091135467c8a 100644 (file)
@@ -396,7 +396,7 @@ MPRActors( )
     this->Slices[ 0 ][ i ]->AddWindowLevelCommand(
       Self::_WindowLevelCommand, this
       );
-    // this->Slices[ 0 ][ i ]->AddSlicesCommand( Self::_SlicesCommand, this );
+    this->Slices[ 0 ][ i ]->AddSlicesCommand( Self::_SlicesCommand, this );
 
   } // rof
 }
@@ -411,15 +411,21 @@ cpExtensions::Visualization::MPRActors::
 void cpExtensions::Visualization::MPRActors::
 _SlicesCommand( double* pos, int axis, void* data )
 {
-  /*
-    MPRActors* actors = reinterpret_cast< MPRActors* >( data );
-    if( actors == NULL )
+  MPRActors* actors = reinterpret_cast< MPRActors* >( data );
+  if( actors == NULL )
     return;
-    for( unsigned int j = 0; j < 3; ++j )
+  for( unsigned int j = 0; j < 3; ++j )
+  {
     if( actors->Slices[ 0 ][ j ]->GetAxis( ) != axis )
-    actors->Slices[ 0 ][ j ]->SetSlice( pos );
-    actors->Modified( );
-  */
+    {
+      actors->Slices[ 0 ][ j ]->SetSlice( pos );
+      actors->Slices[ 1 ][ j ]->SetSlice( pos );
+      actors->Slices[ 0 ][ j ]->Render( );
+      actors->Slices[ 1 ][ j ]->Render( );
+
+    } // fi
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------
index d55632c6d1dde34e34e813d27b5d520e0b1d6324..04bc870d6af69882164fa5b3ba1cfb36577bdca3 100644 (file)
@@ -29,7 +29,7 @@ BaseMPRWindow( QWidget* parent )
   this->m_YVTK = new QVTKWidget( this );
   this->m_ZVTK = new QVTKWidget( this );
   this->m_WVTK = new QVTKWidget( this );
-  this->addWidgets( this->m_XVTK, this->m_YVTK, this->m_ZVTK, this->m_WVTK );
+  this->addWidgets( this->m_YVTK, this->m_XVTK, this->m_ZVTK, this->m_WVTK );
 
   // Create and associate vtk renderers
   this->m_MPRObjects = vtkSmartPointer< TMPRObjects >::New( );
index 6068c88390f47c205978a09e4250e8c3cbb7482e..f544617e4685aa3245c144ee78a78f883c6493fe 100644 (file)
@@ -18,11 +18,20 @@ ExecConfigurationDialog( QWidget* parent )
 
 #ifdef cpPlugins_Interface_QT4
 
+  QStringList filters;
+  filters
+    << "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)"
+    << "Any files (*)";
+
+  std::vector< std::string > names;
+  this->m_Parameters->GetStringList( names, "FileNames" );
+  std::string name = ( names.size( ) > 0 )? names[ 0 ]: ".";
+
   // Show dialog and check if it was accepted
   QFileDialog dialog( parent );
   dialog.setFileMode( QFileDialog::ExistingFiles );
-  dialog.setDirectory( QFileDialog::tr( "." ) );
-  dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) );
+  dialog.setDirectory( QFileDialog::tr( name.c_str( ) ) );
+  dialog.setNameFilters( filters );
   if( dialog.exec( ) )
   {
     QStringList names = dialog.selectedFiles( );