Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions

mitk::LookupTablePropertyDeserializer Class Reference

Inheritance diagram for mitk::LookupTablePropertyDeserializer:
Inheritance graph
[legend]
Collaboration diagram for mitk::LookupTablePropertyDeserializer:
Collaboration graph
[legend]

List of all members.

Public Types

typedef
LookupTablePropertyDeserializer 
Self
typedef BasePropertyDeserializer Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual BaseProperty::Pointer Deserialize (TiXmlElement *element)

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 LookupTablePropertyDeserializer ()
virtual ~LookupTablePropertyDeserializer ()

Detailed Description

Definition at line 30 of file mitkLookupTablePropertyDeserializer.cpp.


Member Typedef Documentation

Reimplemented from mitk::BasePropertyDeserializer.

Definition at line 34 of file mitkLookupTablePropertyDeserializer.cpp.

Reimplemented from mitk::BasePropertyDeserializer.

Definition at line 34 of file mitkLookupTablePropertyDeserializer.cpp.

Reimplemented from mitk::BasePropertyDeserializer.

Definition at line 34 of file mitkLookupTablePropertyDeserializer.cpp.

Reimplemented from mitk::BasePropertyDeserializer.

Definition at line 34 of file mitkLookupTablePropertyDeserializer.cpp.


Constructor & Destructor Documentation

mitk::LookupTablePropertyDeserializer::LookupTablePropertyDeserializer (  ) [inline, protected]

Definition at line 147 of file mitkLookupTablePropertyDeserializer.cpp.

{}
virtual mitk::LookupTablePropertyDeserializer::~LookupTablePropertyDeserializer (  ) [inline, protected, virtual]

Definition at line 148 of file mitkLookupTablePropertyDeserializer.cpp.

{}

Member Function Documentation

virtual BaseProperty::Pointer mitk::LookupTablePropertyDeserializer::Deserialize ( TiXmlElement element ) [inline, virtual]

Reimplemented from mitk::BasePropertyDeserializer.

Definition at line 37 of file mitkLookupTablePropertyDeserializer.cpp.

References TiXmlNode::FirstChildElement(), mitk::LookupTableProperty::New(), mitk::LookupTable::New(), TiXmlNode::NextSiblingElement(), TiXmlElement::QueryDoubleAttribute(), TiXmlElement::QueryIntAttribute(), and TIXML_SUCCESS.

    {
      if (!element) return NULL;

#if ( (VTK_MAJOR_VERSION < 5) && (VTK_MINOR_VERSION < 4) )
      typedef float OUR_VTK_FLOAT_TYPE;
      float range[2];
      float  rgba[4];
#else
      typedef double OUR_VTK_FLOAT_TYPE;
      double range[2];
      double  rgba[4];
#endif

      double d;  // bec. of tinyXML's interface that takes a pointer to float or double...

      vtkLookupTable* lut = vtkLookupTable::New();

      int numberOfColors;
      int scale;
      int ramp; // hope the int values don't change betw. vtk versions... 
      if ( element->QueryIntAttribute( "NumberOfColors", &numberOfColors ) == TIXML_SUCCESS )
      {
        lut->SetNumberOfTableValues( numberOfColors );
      }
      else
        return NULL;
      if ( element->QueryIntAttribute( "Scale", &scale ) == TIXML_SUCCESS )
      {
        lut->SetScale( scale );
      }
      else
        return NULL;
      if ( element->QueryIntAttribute( "Ramp", &ramp ) == TIXML_SUCCESS )
      {
        lut->SetRamp( ramp );
      }
      else
        return NULL;

      TiXmlElement* child = element->FirstChildElement("HueRange");
      if (child) 
      {
        if ( child->QueryDoubleAttribute( "min", &d ) != TIXML_SUCCESS ) 
          return NULL; 
        range[0] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        if ( child->QueryDoubleAttribute( "max", &d ) != TIXML_SUCCESS ) 
          return NULL; 
        range[1] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        lut->SetHueRange( range );
      }

                    child = element->FirstChildElement("ValueRange");
      if (child)
      {
        if ( child->QueryDoubleAttribute( "min", &d ) != TIXML_SUCCESS ) return NULL; range[0] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        if ( child->QueryDoubleAttribute( "max", &d ) != TIXML_SUCCESS ) return NULL; range[1] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        lut->SetValueRange( range );
      }

                    child = element->FirstChildElement("SaturationRange");
      if (child)
      {
        if ( child->QueryDoubleAttribute( "min", &d ) != TIXML_SUCCESS ) return NULL; range[0] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        if ( child->QueryDoubleAttribute( "max", &d ) != TIXML_SUCCESS ) return NULL; range[1] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        lut->SetSaturationRange( range );
      }

                    child = element->FirstChildElement("AlphaRange");
      if (child)
      {
        if ( child->QueryDoubleAttribute( "min", &d ) != TIXML_SUCCESS ) return NULL; range[0] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        if ( child->QueryDoubleAttribute( "max", &d ) != TIXML_SUCCESS ) return NULL; range[1] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        lut->SetAlphaRange( range );
      }

                    child = element->FirstChildElement("TableRange");
      if (child)
      {
        if ( child->QueryDoubleAttribute( "min", &d ) != TIXML_SUCCESS ) return NULL; range[0] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        if ( child->QueryDoubleAttribute( "max", &d ) != TIXML_SUCCESS ) return NULL; range[1] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
        lut->SetTableRange( range );
      }
                     
      child = element->FirstChildElement("Table");
      if (child) 
      {
        unsigned int index(0);
        for( TiXmlElement* grandChild = child->FirstChildElement("RgbaColor"); grandChild; grandChild = grandChild->NextSiblingElement("RgbaColor"))
        {
          if ( grandChild->QueryDoubleAttribute("R", &d) != TIXML_SUCCESS ) return NULL; rgba[0] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
          if ( grandChild->QueryDoubleAttribute("G", &d) != TIXML_SUCCESS ) return NULL; rgba[1] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
          if ( grandChild->QueryDoubleAttribute("B", &d) != TIXML_SUCCESS ) return NULL; rgba[2] = static_cast<OUR_VTK_FLOAT_TYPE>(d);
          if ( grandChild->QueryDoubleAttribute("A", &d) != TIXML_SUCCESS ) return NULL; rgba[3] = static_cast<OUR_VTK_FLOAT_TYPE>(d);

          lut->SetTableValue( index, rgba );
          ++index;
        }
      }

      LookupTable::Pointer mitkLut = LookupTable::New();
      mitkLut->SetVtkLookupTable( lut );

      lut->Delete(); 

      return LookupTableProperty::New(mitkLut).GetPointer();
    }
virtual const char* mitk::LookupTablePropertyDeserializer::GetClassName (  ) const [virtual]

Reimplemented from mitk::BasePropertyDeserializer.

static Pointer mitk::LookupTablePropertyDeserializer::New (  ) [static]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines