Index: Core/Code/DataManagement/mitkTransferFunction.cpp =================================================================== --- Core/Code/DataManagement/mitkTransferFunction.cpp (revision 24894) +++ Core/Code/DataManagement/mitkTransferFunction.cpp (working copy) @@ -103,7 +103,6 @@ return true; } - void TransferFunction::SetScalarOpacityPoints(TransferFunction::ControlPoints points) { m_ScalarOpacityFunction->RemoveAllPoints(); @@ -296,266 +295,4 @@ m_Min = (int)GetHistogram()->GetBinMin(0,0); m_Max = (int)GetHistogram()->GetBinMax(0, GetHistogram()->Size()-1); } - -void TransferFunction::SetTransferFunctionMode( int mode ) -{ - //Define Transfer Function - enum TransferFunctionMode{ - TF_CT_DEFAULT, - TF_CT_BLACK_WHITE, - TF_CT_THORAX_LARGE, - TF_CT_THORAX_SMALL, - TF_CT_BONE, - TF_CT_BONE_GRADIENT, - TF_CT_CARDIAC, - TF_MR_GENERIC - }; - - //remove all old points - m_ScalarOpacityFunction->RemoveAllPoints(); - m_ColorTransferFunction->RemoveAllPoints(); - m_GradientOpacityFunction->RemoveAllPoints(); - - switch( mode ) - { - case ( TF_CT_DEFAULT ): - /* - // grayvalue->opacity - { - vtkPiecewiseFunction *f=m_ScalarOpacityFunction; - f->AddPoint(135.063521,0.000000); - f->AddPoint(180.498182,0.027847); - f->AddPoint(948.137931,1.000000); - } - - // gradient at grayvalue->opacity - { - vtkPiecewiseFunction *f=m_GradientOpacityFunction; - f->AddPoint(560.695000,1.000000); - } - - // grayvalue->color - { - vtkColorTransferFunction *f=m_ColorTransferFunction; - f->AddRGBPoint( -24.956443,0.650980,0.000000,0.000000); - f->AddRGBPoint( 208.586207,0.972549,0.227451,0.160784); - f->AddRGBPoint( 238.860254,0.980392,0.352941,0.145098); - f->AddRGBPoint( 279.903212,1.000000,0.858824,0.149020); - f->AddRGBPoint( 355.631579,1.000000,0.647059,0.152941); - f->AddRGBPoint( 455.103448,1.000000,1.000000,1.000000); - f->AddRGBPoint( 623.773140,1.000000,0.800000,0.396078); - f->AddRGBPoint( 796.767695,1.000000,0.901961,0.815686); - f->AddRGBPoint( 930.838475,1.000000,1.000000,1.000000); - f->AddRGBPoint(1073.558984,1.000000,0.839216,0.423529); - f->AddRGBPoint(1220.604356,1.000000,0.772549,0.490196); - } - */ - // grayvalue->opacity - { - vtkPiecewiseFunction *f=m_ScalarOpacityFunction; - f->AddPoint(132.108911,0.000000); - f->AddPoint(197.063492,0.041333); - f->AddPoint(1087.917989,0.700000); - } - - // gradient at grayvalue->opacity - { - vtkPiecewiseFunction *f=m_GradientOpacityFunction; - f->AddPoint(560.695000,1.000000); - } - - // grayvalue->color - { - vtkColorTransferFunction *f=m_ColorTransferFunction; - f->AddRGBPoint(176.881890,0.650980,0.000000,0.000000); - f->AddRGBPoint(239.427822,0.933333,0.000000,0.000000); - f->AddRGBPoint(301.973753,1.000000,0.800000,0.062745); - f->AddRGBPoint(495.866142,1.000000,0.905882,0.666667); - f->AddRGBPoint(677.249344,1.000000,0.882353,0.215686); - f->AddRGBPoint(808.595801,1.000000,1.000000,1.000000); - } - - break; - - case ( TF_CT_BLACK_WHITE ): - - //Set Opacity - m_ScalarOpacityFunction->AddPoint( 135.063521, 0.0 ); - m_ScalarOpacityFunction->AddPoint( 948.137931, 1.0 ); - - - //Set Color - m_ColorTransferFunction->AddRGBPoint( 122.088929, 0.352941, 0.352941, 0.352941); - m_ColorTransferFunction->AddRGBPoint( 372.931034, 1.000000, 1.000000, 1.000000 ); - - //Set Gradient - m_GradientOpacityFunction->Initialize(); - m_GradientOpacityFunction->AddPoint( 560.695000, 1); - - break; - - case ( TF_CT_THORAX_LARGE ): - - // grayvalue->opacity - { - vtkPiecewiseFunction *f=m_ScalarOpacityFunction; - f->AddPoint(76.721239,0.000000); - f->AddPoint(139.524336,0.000000); - f->AddPoint(274.458333,0.228650); - f->AddPoint(638.420139,0.721763); - } - - // gradient at grayvalue->opacity - { - vtkPiecewiseFunction *f=m_GradientOpacityFunction; - f->AddPoint(560.695000,1.000000); - } - // grayvalue->color - { - vtkColorTransferFunction *f=m_ColorTransferFunction; - f->AddRGBPoint( 85.382743,0.478431,0.000000,0.000000); - f->AddRGBPoint( 198.201327,0.933333,0.000000,0.000000); - f->AddRGBPoint( 254.610619,1.000000,0.800000,0.062745); - f->AddRGBPoint( 336.0907085,1.000000,0.905882,0.666667); - f->AddRGBPoint( 630.672566,1.000000,1.000000,1.000000); - } - break; - - case ( TF_CT_THORAX_SMALL ): - - // grayvalue->opacity - { - vtkPiecewiseFunction *f=m_ScalarOpacityFunction; - f->AddPoint(147.216912,0.000000); - f->AddPoint(274.458333,0.228650); - f->AddPoint(430.330882,0.675532); - } - - // gradient at grayvalue->opacity - { - vtkPiecewiseFunction *f=m_GradientOpacityFunction; - f->AddPoint(560.695000,1.000000); - } - - // grayvalue->color - { - vtkColorTransferFunction *f=m_ColorTransferFunction; - f->AddRGBPoint( 129.607774,0.478431,0.000000,0.000000); - f->AddRGBPoint( 213.812721,0.933333,0.000000,0.000000); - f->AddRGBPoint( 348.540636,1.000000,0.800000,0.062745); - f->AddRGBPoint( 500.419118,1.000000,0.898039,0.776471); - f->AddRGBPoint( 579.268382,1.000000,1.000000,1.000000); - } - break; - - case ( TF_CT_BONE ): - - // grayvalue->opacity - { - vtkPiecewiseFunction *f=m_ScalarOpacityFunction; - f->AddPoint(126.413793,0.000000); - f->AddPoint(178.312160,0.014663); - f->AddPoint(247.509982,0.000000); - f->AddPoint(1013.010889,1.000000); - } - // gradient at grayvalue->opacity - { - vtkPiecewiseFunction *f=m_GradientOpacityFunction; - f->AddPoint(485.377495,1.000000); - } - // grayvalue->color - { - vtkColorTransferFunction *f=m_ColorTransferFunction; - f->AddRGBPoint( 312.382940,1.000000,0.564706,0.274510); - f->AddRGBPoint( 455.103448,1.000000,0.945098,0.768627); - f->AddRGBPoint( 623.773140,1.000000,0.800000,0.333333); - f->AddRGBPoint( 796.767695,1.000000,0.901961,0.815686); - f->AddRGBPoint( 930.838475,1.000000,1.000000,1.000000); - f->AddRGBPoint(1073.558984,1.000000,0.839216,0.423529); - f->AddRGBPoint(1220.604356,1.000000,0.772549,0.490196); - } - break; - - case ( TF_CT_BONE_GRADIENT ): - - // grayvalue->opacity - { - vtkPiecewiseFunction *f=m_ScalarOpacityFunction; - f->AddPoint(126.413793,0.000000); - f->AddPoint(186.961887,0.146628); - f->AddPoint(247.509982,0.000000); - f->AddPoint(1013.010889,1.000000); - } - // gradient at grayvalue->opacity - { - vtkPiecewiseFunction *f=m_GradientOpacityFunction; - f->AddPoint(22.617060,0.000000); - f->AddPoint(65.865699,1.000000); - } - // grayvalue->color - { - vtkColorTransferFunction *f=m_ColorTransferFunction; - f->AddRGBPoint( 312.382940,1.000000,0.564706,0.274510); - f->AddRGBPoint( 455.103448,1.000000,0.945098,0.768627); - f->AddRGBPoint( 623.773140,1.000000,0.800000,0.333333); - f->AddRGBPoint( 796.767695,1.000000,0.901961,0.815686); - f->AddRGBPoint( 930.838475,1.000000,1.000000,1.000000); - f->AddRGBPoint(1073.558984,1.000000,0.839216,0.423529); - f->AddRGBPoint(1220.604356,1.000000,0.772549,0.490196); - } - break; - - case ( TF_CT_CARDIAC ): - - //Set Opacity - m_ScalarOpacityFunction->AddPoint( 150.246824, 0.000000 ); - m_ScalarOpacityFunction->AddPoint( 179.974592, 0.202346); - m_ScalarOpacityFunction->AddPoint( 276.589837, 0.000000); - m_ScalarOpacityFunction->AddPoint( 781.961887, 1.000000); - - //Set Color - m_ColorTransferFunction->AddRGBPoint( 395.500907,1.000000,0.000000,0.000000); - m_ColorTransferFunction->AddRGBPoint( 410.364791,1.000000,0.749020,0.000000); - m_ColorTransferFunction->AddRGBPoint( 484.684211,1.000000,0.878431,0.662745); - m_ColorTransferFunction->AddRGBPoint( 588.731397,1.000000,0.784314,0.482353); - - //Set Gradient - m_GradientOpacityFunction->AddPoint( 246.862069, 0.215827 ); - - break; - - case ( TF_MR_GENERIC ): - - //Set Opacity - m_ScalarOpacityFunction->AddPoint( 0, 0 ); - m_ScalarOpacityFunction->AddPoint( 20, 0 ); - m_ScalarOpacityFunction->AddPoint( 40, 0.15 ); - m_ScalarOpacityFunction->AddPoint( 120, 0.3 ); - m_ScalarOpacityFunction->AddPoint( 220, 0.375 ); - m_ScalarOpacityFunction->AddPoint( 1024, 0.5); - - //Set Color - m_ColorTransferFunction->AddRGBPoint( 0, 0, 0, 0 ); - m_ColorTransferFunction->AddRGBPoint( 20, 0.168627, 0, 0 ); - m_ColorTransferFunction->AddRGBPoint( 40, 0.403922, 0.145098, 0.0784314 ); - m_ColorTransferFunction->AddRGBPoint( 120, 0.780392, 0.607843, 0.380392 ); - m_ColorTransferFunction->AddRGBPoint( 220, 0.847059, 0.835294, 0.788235 ); - m_ColorTransferFunction->AddRGBPoint( 1024, 1, 1, 1 ); - - //Set Gradient - m_GradientOpacityFunction->AddPoint( 0, 1 ); - m_GradientOpacityFunction->AddPoint( 255, 1); - - break; - - - default: - - break; - } - - m_ScalarOpacityFunction->Modified(); - m_ColorTransferFunction->Modified(); - m_GradientOpacityFunction->Modified(); -} -} // namespace +}// namespace \ No newline at end of file Index: Core/Code/DataManagement/mitkTransferFunction.h =================================================================== --- Core/Code/DataManagement/mitkTransferFunction.h (revision 24894) +++ Core/Code/DataManagement/mitkTransferFunction.h (working copy) @@ -74,13 +74,13 @@ /** \brief Get/Set min/max of transfer function range for initialization. */ itkGetMacro(Max,int); - /** \brief Get wrapped vtk transfer function. */ + /** \brief Get/Set wrapped vtk transfer function. */ itkGetMacro(ScalarOpacityFunction,vtkPiecewiseFunction*); - /** \brief Get wrapped vtk transfer function. */ + /** \brief Get/Set wrapped vtk transfer function. */ itkGetMacro(GradientOpacityFunction,vtkPiecewiseFunction*); - /** \brief Get wrapped vtk transfer function. */ + /** \brief Get/Set wrapped vtk transfer function. */ itkGetMacro(ColorTransferFunction,vtkColorTransferFunction*); /** \brief Get histogram used for transfer function initialization. */ @@ -95,11 +95,7 @@ /** \brief Initialize the internal histogram and min/max range based on the * specified mitk::Image. */ - void InitializeHistogram( const mitk::Image* image ); - - /** Initialize transfer function to the specified preset.*/ - void SetTransferFunctionMode( int mode ); - + void InitializeHistogram( const mitk::Image* image ); /** \brief Insert control points and values into the scalar opacity transfer * function. */ @@ -144,7 +140,6 @@ /** \brief Remove the specified control point from the color transfer function. */ int RemoveRGBPoint(double x); - /** \brief Removes all control points from the scalar opacity transfer function. */ void ClearScalarOpacityPoints(); Index: Core/Code/DataManagement/mitkTransferFunctionInitializer.cpp =================================================================== --- Core/Code/DataManagement/mitkTransferFunctionInitializer.cpp (revision 0) +++ Core/Code/DataManagement/mitkTransferFunctionInitializer.cpp (revision 0) @@ -0,0 +1,281 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2010-05-10 18:06:04 +0200 (Mo, 10 Mai 2010) $ +Version: $Revision: 22790 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkTransferFunctionInitializer.h" + + +namespace mitk +{ + + TransferFunctionInitializer::TransferFunctionInitializer(mitk::TransferFunction::Pointer transferFunction) +{ + if (transferFunction.IsNotNull()) + { + m_transferFunction = transferFunction; + } +} + +TransferFunctionInitializer::~TransferFunctionInitializer() +{ + +} + +void TransferFunctionInitializer::SetTransferFunction(mitk::TransferFunction::Pointer transferFunction) +{ + m_transferFunction = transferFunction; +} + +void TransferFunctionInitializer::SetTransferFunctionMode( int mode ) +{ + if(m_transferFunction) + { + m_Mode = mode; + this->InitTransferFunctionMode(); + } +} + +void TransferFunctionInitializer::RemoveAllPoints() +{ + m_transferFunction->GetScalarOpacityFunction()->RemoveAllPoints(); + m_transferFunction->GetColorTransferFunction()->RemoveAllPoints(); + m_transferFunction->GetGradientOpacityFunction()->RemoveAllPoints(); +} + +void TransferFunctionInitializer::SetModified() +{ + m_transferFunction->GetScalarOpacityFunction()->Modified(); + m_transferFunction->GetColorTransferFunction()->Modified(); + m_transferFunction->GetGradientOpacityFunction()->Modified(); +} + +void TransferFunctionInitializer::InitTransferFunctionMode() +{ + if(m_transferFunction) + { + this->RemoveAllPoints(); + switch( this->m_Mode ) + { + case TF_CT_DEFAULT: + this->SetCtDefaultMode(); + break; + + case TF_CT_BLACK_WHITE: + this->SetCtBlackWhiteMode(); + break; + + case TF_CT_THORAX_LARGE: + this->SetCtThoraxLargeMode(); + break; + + case TF_CT_THORAX_SMALL: + this->SetCtThoraxSmallMode(); + break; + + case TF_CT_BONE: + this->SetCtBoneMode(); + break; + + case TF_CT_BONE_GRADIENT: + this->SetCtBoneGradientMode(); + break; + + case TF_CT_CARDIAC: + this->SetCtCardiacMode(); + break; + + case TF_MR_GENERIC: + this->SetMrGenericMode(); + break; + + default: + itkExceptionMacro(<< "No Mode set!"); + break; + } + + this->SetModified(); + } else { + itkExceptionMacro(<< "No Transferfunction set!"); + } +} + +void TransferFunctionInitializer::SetCtDefaultMode() +{ + // grayvalue->opacity + m_transferFunction->GetScalarOpacityFunction()->AddPoint(132.108911,0.000000); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(197.063492,0.041333); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(1087.917989,0.700000); + + // gradient at grayvalue->opacity + m_transferFunction->GetGradientOpacityFunction()->AddPoint(560.695000,1.000000); + + // grayvalue->color + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(176.881890,0.650980,0.000000,0.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(239.427822,0.933333,0.000000,0.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(301.973753,1.000000,0.800000,0.062745); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(495.866142,1.000000,0.905882,0.666667); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(677.249344,1.000000,0.882353,0.215686); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(808.595801,1.000000,1.000000,1.000000); +} + +void TransferFunctionInitializer::SetCtBlackWhiteMode() +{ + //Set Opacity + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 135.063521, 0.0 ); + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 948.137931, 1.0 ); + + + //Set Color + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 122.088929, 0.352941, 0.352941, 0.352941); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 372.931034, 1.000000, 1.000000, 1.000000 ); + + //Set Gradient + m_transferFunction->GetGradientOpacityFunction()->Initialize(); + m_transferFunction->GetGradientOpacityFunction()->AddPoint( 560.695000, 1); + +} + +void TransferFunctionInitializer::SetCtThoraxLargeMode() +{ + // grayvalue->opacity + + m_transferFunction->GetScalarOpacityFunction()->AddPoint(76.721239,0.000000); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(139.524336,0.000000); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(274.458333,0.228650); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(638.420139,0.721763); + + + // gradient at grayvalue->opacity + m_transferFunction->GetGradientOpacityFunction()->AddPoint(560.695000,1.000000); + + // grayvalue->color + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 85.382743,0.478431,0.000000,0.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 198.201327,0.933333,0.000000,0.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 254.610619,1.000000,0.800000,0.062745); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 336.0907085,1.000000,0.905882,0.666667); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 630.672566,1.000000,1.000000,1.000000); +} + +void TransferFunctionInitializer::SetCtThoraxSmallMode() +{ + // grayvalue->opacity + m_transferFunction->GetScalarOpacityFunction()->AddPoint(147.216912,0.000000); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(274.458333,0.228650); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(430.330882,0.675532); + + + // gradient at grayvalue->opacity + m_transferFunction->GetGradientOpacityFunction()->AddPoint(560.695000,1.000000); + + + // grayvalue->color + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 129.607774,0.478431,0.000000,0.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 213.812721,0.933333,0.000000,0.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 348.540636,1.000000,0.800000,0.062745); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 500.419118,1.000000,0.898039,0.776471); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 579.268382,1.000000,1.000000,1.000000); +} + +void TransferFunctionInitializer::SetCtBoneMode() +{ + // grayvalue->opacity + m_transferFunction->GetScalarOpacityFunction()->AddPoint(126.413793,0.000000); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(178.312160,0.014663); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(247.509982,0.000000); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(1013.010889,1.000000); + + // gradient at grayvalue->opacity + m_transferFunction->GetGradientOpacityFunction()->AddPoint(485.377495,1.000000); + + // grayvalue->color + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 312.382940,1.000000,0.564706,0.274510); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 455.103448,1.000000,0.945098,0.768627); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 623.773140,1.000000,0.800000,0.333333); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 796.767695,1.000000,0.901961,0.815686); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 930.838475,1.000000,1.000000,1.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(1073.558984,1.000000,0.839216,0.423529); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(1220.604356,1.000000,0.772549,0.490196); + +} + +void TransferFunctionInitializer::SetCtBoneGradientMode() +{ + // grayvalue->opacity + m_transferFunction->GetScalarOpacityFunction()->AddPoint(126.413793,0.000000); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(186.961887,0.146628); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(247.509982,0.000000); + m_transferFunction->GetScalarOpacityFunction()->AddPoint(1013.010889,1.000000); + + // gradient at grayvalue->opacity + m_transferFunction->GetGradientOpacityFunction()->AddPoint(22.617060,0.000000); + m_transferFunction->GetGradientOpacityFunction()->AddPoint(65.865699,1.000000); + + // grayvalue->color + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 312.382940,1.000000,0.564706,0.274510); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 455.103448,1.000000,0.945098,0.768627); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 623.773140,1.000000,0.800000,0.333333); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 796.767695,1.000000,0.901961,0.815686); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 930.838475,1.000000,1.000000,1.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(1073.558984,1.000000,0.839216,0.423529); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint(1220.604356,1.000000,0.772549,0.490196); +} + +void TransferFunctionInitializer::SetCtCardiacMode() +{ + //Set Opacity + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 150.246824, 0.000000 ); + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 179.974592, 0.202346); + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 276.589837, 0.000000); + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 781.961887, 1.000000); + + //Set Color + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 395.500907,1.000000,0.000000,0.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 410.364791,1.000000,0.749020,0.000000); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 484.684211,1.000000,0.878431,0.662745); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 588.731397,1.000000,0.784314,0.482353); + + //Set Gradient + m_transferFunction->GetGradientOpacityFunction()->AddPoint( 246.862069, 0.215827 ); +} + +void TransferFunctionInitializer::SetMrGenericMode() +{ + //Set Opacity + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 0, 0 ); + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 20, 0 ); + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 40, 0.15 ); + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 120, 0.3 ); + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 220, 0.375 ); + m_transferFunction->GetScalarOpacityFunction()->AddPoint( 1024, 0.5); + + //Set Color + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 0, 0, 0, 0 ); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 20, 0.168627, 0, 0 ); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 40, 0.403922, 0.145098, 0.0784314 ); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 120, 0.780392, 0.607843, 0.380392 ); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 220, 0.847059, 0.835294, 0.788235 ); + m_transferFunction->GetColorTransferFunction()->AddRGBPoint( 1024, 1, 1, 1 ); + + //Set Gradient + m_transferFunction->GetGradientOpacityFunction()->AddPoint( 0, 1 ); + m_transferFunction->GetGradientOpacityFunction()->AddPoint( 255, 1); +} + +mitk::TransferFunction::Pointer TransferFunctionInitializer::GetTransferFunction() +{ + return m_transferFunction; +} +} // namespace Index: Core/Code/DataManagement/mitkTransferFunctionInitializer.h =================================================================== --- Core/Code/DataManagement/mitkTransferFunctionInitializer.h (revision 0) +++ Core/Code/DataManagement/mitkTransferFunctionInitializer.h (revision 0) @@ -0,0 +1,97 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2010-05-10 18:06:04 +0200 (Mo, 10 Mai 2010) $ +Version: $Revision: 22790 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITK_TRANSFER_FUNCTION_MODE_CREATOR_H_HEADER_INCLUDED +#define MITK_TRANSFER_FUNCTION_MODE_CREATOR_H_HEADER_INCLUDED + +#include +#include +#include + +#include "mitkTransferFunction.h" + +#include +#include + +#include "mitkCommon.h" + +namespace mitk { + +/** + * \brief Wrapper class for VTK scalar opacity, gradient opacity, and color + * transfer functions. + * + * Holds a copy of each of the three standard VTK transfer functions (scalar + * opacity, gradient opacity, color) and provides an interface for manipulating + * their control points. Each original function can be retrieved by a Get() + * method. + * + * NOTE: Currently, transfer function initialization based on histograms or + * computed-tomography-presets is also provided by this class, but will likely + * be separated into a specific initializer class. + */ + class MITK_CORE_EXPORT TransferFunctionInitializer : public itk::Object +{ +public: + mitkClassMacro(TransferFunctionInitializer, itk::Object); + + itkNewMacro( TransferFunctionInitializer ); + mitkNewMacro1Param(TransferFunctionInitializer, TransferFunction::Pointer); + + void SetTransferFunction(TransferFunction::Pointer transferFunction); + mitk::TransferFunction::Pointer GetTransferFunction(); + void SetTransferFunctionMode(int mode); + + void InitTransferFunctionMode(); + +protected: + TransferFunctionInitializer(TransferFunction::Pointer transferFunction = NULL); + virtual ~TransferFunctionInitializer(); + +private: + int m_Mode; + mitk::TransferFunction::Pointer m_transferFunction; + + //Define Transfer Function + enum TransferFunctionMode{ + TF_CT_DEFAULT, + TF_CT_BLACK_WHITE, + TF_CT_THORAX_LARGE, + TF_CT_THORAX_SMALL, + TF_CT_BONE, + TF_CT_BONE_GRADIENT, + TF_CT_CARDIAC, + TF_MR_GENERIC + }; + + //remove all old points + void RemoveAllPoints(); + void SetModified(); + void SetCtDefaultMode(); + void SetCtBlackWhiteMode(); + void SetCtThoraxLargeMode(); + void SetCtThoraxSmallMode(); + void SetCtBoneMode(); + void SetCtBoneGradientMode(); + void SetCtCardiacMode(); + void SetMrGenericMode(); + +}; + +} + +#endif /* MITK_TRANSFER_FUNCTION_MODE_CREATOR_H_HEADER_INCLUDED */ Index: Core/Code/Rendering/mitkVolumeDataVtkMapper3D.cpp =================================================================== --- Core/Code/Rendering/mitkVolumeDataVtkMapper3D.cpp (revision 24894) +++ Core/Code/Rendering/mitkVolumeDataVtkMapper3D.cpp (working copy) @@ -25,6 +25,7 @@ #include "mitkLevelWindowProperty.h" #include "mitkLookupTableProperty.h" #include "mitkTransferFunctionProperty.h" +#include "mitkTransferFunctionInitializer.h" #include "mitkColorProperty.h" #include "mitkVtkPropRenderer.h" #include "mitkRenderingManager.h" @@ -608,7 +609,8 @@ { // add a default transfer function mitk::TransferFunction::Pointer tf = mitk::TransferFunction::New(); - tf->SetTransferFunctionMode(0); + mitk::TransferFunctionInitializer::Pointer tfInit = mitk::TransferFunctionInitializer::New(tf); + tfInit->SetTransferFunctionMode(0); node->SetProperty ( "TransferFunction", mitk::TransferFunctionProperty::New ( tf.GetPointer() ) ); } } Index: Core/Code/Testing/mitkTransferFunctionTest.cpp =================================================================== --- Core/Code/Testing/mitkTransferFunctionTest.cpp (revision 24894) +++ Core/Code/Testing/mitkTransferFunctionTest.cpp (working copy) @@ -16,6 +16,7 @@ =========================================================================*/ #include "mitkTransferFunction.h" +#include "mitkTransferFunctionInitializer.h" #include "mitkTestingMacros.h" @@ -218,7 +219,59 @@ myTransferFunction->GetRGBPoints().size() == 0, "Clearing color transfer function points (resulting array should be empty)" ); + /******************TRANSFERFUNCTION INITIALIZER TEST***************************/ + mitk::TransferFunction::Pointer dummyTransferFunction = mitk::TransferFunction::New(); + mitk::TransferFunctionInitializer::Pointer transferInit = mitk::TransferFunctionInitializer::New(dummyTransferFunction); + MITK_TEST_CONDITION_REQUIRED( + transferInit->GetTransferFunction().IsNotNull(), + "Testing if Transferfunction is set" ); + MITK_TEST_CONDITION_REQUIRED( + transferInit->GetTransferFunction() == dummyTransferFunction, + "Testing if Transferfunction is the correct one" ); + transferInit->SetTransferFunction(myTransferFunction); + + MITK_TEST_CONDITION_REQUIRED( + transferInit->GetTransferFunction().IsNotNull(), + "Testing if Set Transferfunction works" ); + MITK_TEST_CONDITION_REQUIRED( + transferInit->GetTransferFunction() == myTransferFunction, + "Testing if Set Transferfunction sets the correct one" ); + + const int size = 8; + int arPointNumbers[size][3] = {{3,1,6}, + {2,1,2}, + {4,1,5}, + {3,1,5}, + {4,1,7}, + {4,2,7}, + {4,1,4}, + {6,2,6}}; + + std::string names[size] = {"SetDefaultMode", + "SetCtBlackWhiteMode", + "SetCtThoraxLargeMode", + "SetCtThoraxSmallMode", + "SetCtBoneMode", + "SetCtBoneGradientMode", + "SetCtCardiacMode", + "SetMrGenericMode"}; + + for(int i =0; iSetTransferFunctionMode(i); + + std::cout << "Punkte: " << myTransferFunction->GetScalarOpacityFunction()->GetSize() << std::endl; + MITK_TEST_CONDITION_REQUIRED( + myTransferFunction->GetScalarOpacityFunction()->GetSize() == arPointNumbers[i][0], + "Testing if in " << names[i] << " the Scalar Opacity Function is set" ); + MITK_TEST_CONDITION_REQUIRED( + myTransferFunction->GetGradientOpacityFunction()->GetSize() == arPointNumbers[i][1], + "Testing if in " << names[i] << " the Gradient Opacity Function is set" ); + MITK_TEST_CONDITION_REQUIRED( + myTransferFunction->GetColorTransferFunction()->GetSize() == arPointNumbers[i][2], + "Testing if in " << names[i] << " the Color Transfer Function is set" ); + } // always end with this! MITK_TEST_END() } Index: Modules/MitkExt/Rendering/mitkGPUVolumeMapper3D.cpp =================================================================== --- Modules/MitkExt/Rendering/mitkGPUVolumeMapper3D.cpp (revision 24894) +++ Modules/MitkExt/Rendering/mitkGPUVolumeMapper3D.cpp (working copy) @@ -28,6 +28,7 @@ #include "mitkLevelWindowProperty.h" #include "mitkLookupTableProperty.h" #include "mitkTransferFunctionProperty.h" +#include "mitkTransferFunctionInitializer.h" #include "mitkColorProperty.h" #include "mitkVtkPropRenderer.h" #include "mitkRenderingManager.h" @@ -547,7 +548,8 @@ { // add a default transfer function mitk::TransferFunction::Pointer tf = mitk::TransferFunction::New(); - tf->SetTransferFunctionMode(0); + mitk::TransferFunctionInitializer::Pointer tfInit = mitk::TransferFunctionInitializer::New(tf); + tfInit->SetTransferFunctionMode(0); node->SetProperty ( "TransferFunction", mitk::TransferFunctionProperty::New ( tf.GetPointer() ) ); } } Index: Modules/QmitkExt/QmitkTransferFunctionGeneratorWidget.cpp =================================================================== --- Modules/QmitkExt/QmitkTransferFunctionGeneratorWidget.cpp (revision 24894) +++ Modules/QmitkExt/QmitkTransferFunctionGeneratorWidget.cpp (working copy) @@ -19,7 +19,7 @@ #include #include - +#include #include #include @@ -205,7 +205,8 @@ m_TransferFunctionComboBox->setCurrentIndex( 0 ); // -- Creat new TransferFunction - tfpToChange->GetValue()->SetTransferFunctionMode( mode ); + mitk::TransferFunctionInitializer::Pointer tfInit = mitk::TransferFunctionInitializer::New(tfpToChange->GetValue()); + tfInit->SetTransferFunctionMode(mode); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalUpdateCanvas(); m_InfoPreset->setText( QString( (std::string("selected ")+ std::string(presetNames[mode+1])).c_str() ) );