## ================
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 =
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)
}
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( );
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( ) );
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( );
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
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
}
// -------------------------------------------------------------------------
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( );
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( );
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( );
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 );
}
// -------------------------------------------------------------------------
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 );
this->SetSliceNumber( this->GetSliceNumber( ) );
else
this->SetSliceNumber( this->GetSliceNumberMaxValue( ) );
+ this->ResetCursor( );
this->Modified( );
}
}
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 )
{
} // 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$