diff --git a/Core/Code/DataManagement/mitkAnnotationProperty.cpp b/Core/Code/DataManagement/mitkAnnotationProperty.cpp index f47fff0e7c..0f66d50afe 100644 --- a/Core/Code/DataManagement/mitkAnnotationProperty.cpp +++ b/Core/Code/DataManagement/mitkAnnotationProperty.cpp @@ -1,118 +1,119 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkAnnotationProperty.h" mitk::AnnotationProperty::AnnotationProperty() : m_Position(0.0) { } mitk::AnnotationProperty::AnnotationProperty( const char *label, const Point3D &position ) : m_Label( "" ), m_Position( position ) { if ( label != NULL ) { m_Label = label; } } mitk::AnnotationProperty::AnnotationProperty( const std::string &label, const Point3D &position ) : m_Label( label ), m_Position( position ) { } mitk::AnnotationProperty::AnnotationProperty( const char *label, ScalarType x, ScalarType y, ScalarType z ) : m_Label( "" ) { if ( label != NULL ) { m_Label = label; } m_Position[0] = x; m_Position[1] = y; m_Position[2] = z; } mitk::AnnotationProperty::AnnotationProperty( const std::string &label, ScalarType x, ScalarType y, ScalarType z ) : m_Label( label ) { m_Position[0] = x; m_Position[1] = y; m_Position[2] = z; } mitk::AnnotationProperty::AnnotationProperty(const mitk::AnnotationProperty& other) : BaseProperty(other) , m_Label(other.m_Label) , m_Position(other.m_Position) { } const mitk::Point3D &mitk::AnnotationProperty::GetPosition() const { return m_Position; } void mitk::AnnotationProperty::SetPosition( const mitk::Point3D &position ) { if (m_Position != position) { m_Position = position; this->Modified(); } } bool mitk::AnnotationProperty::IsEqual( const BaseProperty &property ) const { return ( (this->m_Label == static_cast(property).m_Label ) && (this->m_Position == static_cast(property).m_Position ) ); } bool mitk::AnnotationProperty::Assign( const BaseProperty &property ) { this->m_Label = static_cast(property).m_Label; this->m_Position = static_cast(property).m_Position; return true; } std::string mitk::AnnotationProperty::GetValueAsString() const { std::stringstream myStr; myStr << this->GetLabel() << this->GetPosition(); return myStr.str(); } itk::LightObject::Pointer mitk::AnnotationProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkClippingProperty.cpp b/Core/Code/DataManagement/mitkClippingProperty.cpp index bf6f1bbe06..8fe852888a 100644 --- a/Core/Code/DataManagement/mitkClippingProperty.cpp +++ b/Core/Code/DataManagement/mitkClippingProperty.cpp @@ -1,125 +1,126 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkClippingProperty.h" namespace mitk { ClippingProperty::ClippingProperty() : m_ClippingEnabled( false ), m_Origin(0.0), m_Normal(0.0) { } ClippingProperty::ClippingProperty(const ClippingProperty& other) : BaseProperty(other) , m_ClippingEnabled(other.m_ClippingEnabled) , m_Origin(other.m_Origin) , m_Normal(other.m_Normal) { } ClippingProperty::ClippingProperty( const Point3D &origin, const Vector3D &normal ) : m_ClippingEnabled( true ), m_Origin( origin ), m_Normal( normal ) { } bool ClippingProperty::GetClippingEnabled() const { return m_ClippingEnabled; } void ClippingProperty::SetClippingEnabled( bool enabled ) { if (m_ClippingEnabled != enabled) { m_ClippingEnabled = enabled; this->Modified(); } } const Point3D &ClippingProperty::GetOrigin() const { return m_Origin; } void ClippingProperty::SetOrigin( const Point3D &origin ) { if (m_Origin != origin) { m_Origin = origin; this->Modified(); } } const Vector3D &ClippingProperty::GetNormal() const { return m_Normal; } void ClippingProperty::SetNormal( const Vector3D &normal ) { if (m_Normal != normal) { m_Normal = normal; this->Modified(); } } bool ClippingProperty::IsEqual( const BaseProperty &property ) const { return ((this->m_ClippingEnabled == static_cast(property).m_ClippingEnabled) && (this->m_Origin == static_cast(property).m_Origin ) && (this->m_Normal == static_cast(property).m_Normal ) ); } bool ClippingProperty::Assign( const BaseProperty &property ) { this->m_ClippingEnabled = static_cast(property).m_ClippingEnabled; this->m_Origin = static_cast(property).m_Origin; this->m_Normal = static_cast(property).m_Normal; return true; } std::string ClippingProperty::GetValueAsString() const { std::stringstream myStr; myStr << this->GetClippingEnabled() << this->GetOrigin() << this->GetNormal(); return myStr.str(); } itk::LightObject::Pointer ClippingProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } } // namespace diff --git a/Core/Code/DataManagement/mitkColorProperty.cpp b/Core/Code/DataManagement/mitkColorProperty.cpp index 108dd82f68..315d18e5a9 100644 --- a/Core/Code/DataManagement/mitkColorProperty.cpp +++ b/Core/Code/DataManagement/mitkColorProperty.cpp @@ -1,99 +1,100 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "mitkColorProperty.h" mitk::ColorProperty::ColorProperty() : m_Color(0.0f) { } mitk::ColorProperty::ColorProperty(const mitk::ColorProperty& other) : BaseProperty(other) , m_Color(other.m_Color) { } mitk::ColorProperty::ColorProperty(const float color[3]) : m_Color(color) { } mitk::ColorProperty::ColorProperty(const float red, const float green, const float blue) { m_Color.Set(red, green, blue); } mitk::ColorProperty::ColorProperty(const mitk::Color & color) : m_Color(color) { } bool mitk::ColorProperty::IsEqual(const BaseProperty& property) const { return this->m_Color == static_cast(property).m_Color; } bool mitk::ColorProperty::Assign(const BaseProperty& property) { this->m_Color = static_cast(property).m_Color; return true; } const mitk::Color & mitk::ColorProperty::GetColor() const { return m_Color; } void mitk::ColorProperty::SetColor(const mitk::Color & color ) { if(m_Color!=color) { m_Color = color; Modified(); } } void mitk::ColorProperty::SetValue(const mitk::Color & color ) { SetColor(color); } void mitk::ColorProperty::SetColor( float red, float green, float blue ) { float tmp[3] = { red, green, blue }; SetColor(mitk::Color(tmp)); } std::string mitk::ColorProperty::GetValueAsString() const { std::stringstream myStr; myStr.imbue(std::locale::classic()); myStr << GetValue() ; return myStr.str(); } const mitk::Color & mitk::ColorProperty::GetValue() const { return GetColor(); } itk::LightObject::Pointer mitk::ColorProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkEnumerationProperty.cpp b/Core/Code/DataManagement/mitkEnumerationProperty.cpp index 4ae81f1618..fc01ee2bb4 100644 --- a/Core/Code/DataManagement/mitkEnumerationProperty.cpp +++ b/Core/Code/DataManagement/mitkEnumerationProperty.cpp @@ -1,205 +1,206 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkEnumerationProperty.h" #include // static map members of EnumerationProperty. These Maps point to per-classname-maps of ID <-> String. Accessed by GetEnumIds() and GetEnumString(). mitk::EnumerationProperty::IdMapForClassNameContainerType mitk::EnumerationProperty::s_IdMapForClassName; mitk::EnumerationProperty::StringMapForClassNameContainerType mitk::EnumerationProperty::s_StringMapForClassName; mitk::EnumerationProperty::EnumerationProperty() { m_CurrentValue = 0; } mitk::EnumerationProperty::EnumerationProperty(const EnumerationProperty& other) : BaseProperty(other) , m_CurrentValue(other.m_CurrentValue) { } bool mitk::EnumerationProperty::AddEnum( const std::string& name, const IdType& id ) { if ( ( ! IsValidEnumerationValue( name ) ) && ( ! IsValidEnumerationValue( id ) ) ) { GetEnumIds().insert( std::make_pair( id, name ) ); GetEnumStrings().insert( std::make_pair( name, id ) ); return true; } else { return false; } } bool mitk::EnumerationProperty::SetValue( const std::string& name ) { if ( IsValidEnumerationValue( name ) ) { m_CurrentValue = GetEnumId( name ); Modified(); return true; } else { return false; } } bool mitk::EnumerationProperty::SetValue( const IdType& id ) { if ( IsValidEnumerationValue( id ) ) { m_CurrentValue = id; Modified(); return true; } else { return false; } } mitk::EnumerationProperty::IdType mitk::EnumerationProperty::GetValueAsId() const { return m_CurrentValue; } std::string mitk::EnumerationProperty::GetValueAsString() const { return GetEnumString( m_CurrentValue ); } void mitk::EnumerationProperty::Clear() { GetEnumIds().clear(); GetEnumStrings().clear(); m_CurrentValue = 0; } mitk::EnumerationProperty::EnumIdsContainerType::size_type mitk::EnumerationProperty::Size() const { return GetEnumIds().size(); } mitk::EnumerationProperty::EnumConstIterator mitk::EnumerationProperty::Begin() const { return GetEnumIds().begin(); } mitk::EnumerationProperty::EnumConstIterator mitk::EnumerationProperty::End() const { return GetEnumIds().end(); } std::string mitk::EnumerationProperty::GetEnumString( const IdType& id ) const { if ( IsValidEnumerationValue( id ) ) { return GetEnumIds().find( id )->second; } else { return "invalid enum id or enums empty"; } } mitk::EnumerationProperty::IdType mitk::EnumerationProperty::GetEnumId( const std::string& name ) const { if ( IsValidEnumerationValue( name ) ) { return GetEnumStrings().find( name )->second; } else { return 0; } } bool mitk::EnumerationProperty::IsEqual( const BaseProperty& property ) const { const Self& other = static_cast(property); return this->Size() == other.Size() && this->GetValueAsId() == other.GetValueAsId() && std::equal( this->Begin(), this->End(), other.Begin() ); } bool mitk::EnumerationProperty::Assign( const BaseProperty& property ) { const Self& other = static_cast(property); this->GetEnumIds() = other.GetEnumIds(); this->GetEnumStrings() = other.GetEnumStrings(); this->m_CurrentValue = other.m_CurrentValue; this->Size() == other.Size() && this->GetValueAsId() == other.GetValueAsId() && std::equal( this->Begin(), this->End(), other.Begin() ); return true; } bool mitk::EnumerationProperty::IsValidEnumerationValue( const IdType& val ) const { return ( GetEnumIds().find( val ) != GetEnumIds().end() ); } bool mitk::EnumerationProperty::IsValidEnumerationValue( const std::string& val ) const { return ( GetEnumStrings().find( val ) != GetEnumStrings().end() ); } mitk::EnumerationProperty::EnumIdsContainerType& mitk::EnumerationProperty::GetEnumIds() { std::string className = this->GetNameOfClass(); // virtual! return s_IdMapForClassName[ className ]; } const mitk::EnumerationProperty::EnumIdsContainerType& mitk::EnumerationProperty::GetEnumIds() const { std::string className = this->GetNameOfClass(); // virtual! return s_IdMapForClassName[ className ]; } mitk::EnumerationProperty::EnumStringsContainerType& mitk::EnumerationProperty::GetEnumStrings() { std::string className = this->GetNameOfClass(); // virtual! return s_StringMapForClassName[ className ]; } const mitk::EnumerationProperty::EnumStringsContainerType& mitk::EnumerationProperty::GetEnumStrings() const { std::string className = this->GetNameOfClass(); // virtual! return s_StringMapForClassName[ className ]; } itk::LightObject::Pointer mitk::EnumerationProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkGenericProperty.h b/Core/Code/DataManagement/mitkGenericProperty.h index 3437bc9973..e9aac09b70 100644 --- a/Core/Code/DataManagement/mitkGenericProperty.h +++ b/Core/Code/DataManagement/mitkGenericProperty.h @@ -1,146 +1,148 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKGENERICPROPERTY_H_HEADER_INCLUDED_C1061CEE #define MITKGENERICPROPERTY_H_HEADER_INCLUDED_C1061CEE #include #include #include #include "mitkVector.h" #include #include "mitkBaseProperty.h" namespace mitk { #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable: 4522) #endif /*! @ brief Template class for generating properties for int, float, bool, etc. This class template can be instantiated for all classes/internal types that fulfills these requirements: - an operator<< so that the properties value can be put into a std::stringstream - an operator== so that two properties can be checked for equality Note: you must use the macro mitkSpecializeGenericProperty to provide specializations for concrete types (e.g. BoolProperty). Please see mitkProperties.h for examples. If you don't use the mitkSpecializeGenericProperty Macro, GetNameOfClass() returns a wrong name. */ template class MITK_EXPORT GenericProperty : public BaseProperty { public: mitkClassMacro(GenericProperty, BaseProperty); mitkNewMacro1Param(GenericProperty, T); itkCloneMacro(Self) typedef T ValueType; itkSetMacro(Value,T); itkGetConstMacro(Value,T); virtual std::string GetValueAsString() const { std::stringstream myStr; myStr << GetValue() ; return myStr.str(); } using BaseProperty::operator=; protected: GenericProperty() {} GenericProperty(T x) : m_Value(x) {} GenericProperty(const GenericProperty& other) : BaseProperty(other) , m_Value(other.m_Value) {} T m_Value; private: // purposely not implemented GenericProperty& operator=(const GenericProperty&); virtual itk::LightObject::Pointer InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } virtual bool IsEqual(const BaseProperty& other) const { return (this->m_Value == static_cast(other).m_Value); } virtual bool Assign(const BaseProperty& other) { this->m_Value = static_cast(other).m_Value; return true; } }; #ifdef _MSC_VER # pragma warning(pop) #endif } // namespace mitk /** * Generates a specialized subclass of mitk::GenericProperty. * This way, GetNameOfClass() returns the value provided by PropertyName. * Please see mitkProperties.h for examples. * @param PropertyName the name of the subclass of GenericProperty * @param Type the value type of the GenericProperty * @param Export the export macro for DLL usage */ #define mitkDeclareGenericProperty(PropertyName,Type,Export) \ class Export PropertyName: public GenericProperty< Type > \ { \ public: \ mitkClassMacro(PropertyName, GenericProperty< Type >); \ itkNewMacro(PropertyName); \ mitkNewMacro1Param(PropertyName, Type); \ using BaseProperty::operator=; \ protected: \ PropertyName(); \ PropertyName(const PropertyName&); \ PropertyName(Type x); \ private: \ itk::LightObject::Pointer InternalClone() const; \ }; #define mitkDefineGenericProperty(PropertyName,Type,DefaultValue) \ mitk::PropertyName::PropertyName() : Superclass(DefaultValue) { } \ mitk::PropertyName::PropertyName(const PropertyName& other) : GenericProperty< Type >(other) {} \ mitk::PropertyName::PropertyName(Type x) : Superclass(x) {} \ itk::LightObject::Pointer mitk::PropertyName::InternalClone() const { \ itk::LightObject::Pointer result(new Self(*this)); \ + result->UnRegister(); \ return result; \ } \ #endif /* MITKGENERICPROPERTY_H_HEADER_INCLUDED_C1061CEE */ diff --git a/Core/Code/DataManagement/mitkGroupTagProperty.cpp b/Core/Code/DataManagement/mitkGroupTagProperty.cpp index 0c93e446d3..c965d11e9f 100644 --- a/Core/Code/DataManagement/mitkGroupTagProperty.cpp +++ b/Core/Code/DataManagement/mitkGroupTagProperty.cpp @@ -1,46 +1,47 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkGroupTagProperty.h" mitk::GroupTagProperty::GroupTagProperty() : mitk::BaseProperty() { } mitk::GroupTagProperty::GroupTagProperty(const GroupTagProperty& other) : mitk::BaseProperty(other) { } bool mitk::GroupTagProperty::IsEqual(const BaseProperty& /*property*/) const { // if other property is also a GroupTagProperty, then it is equal to us, because tags have no value themselves return true; } bool mitk::GroupTagProperty::Assign(const BaseProperty& /*property*/) { return true; } itk::LightObject::Pointer mitk::GroupTagProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkLevelWindowProperty.cpp b/Core/Code/DataManagement/mitkLevelWindowProperty.cpp index c46fecf837..1f24b8a3d9 100755 --- a/Core/Code/DataManagement/mitkLevelWindowProperty.cpp +++ b/Core/Code/DataManagement/mitkLevelWindowProperty.cpp @@ -1,86 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkLevelWindowProperty.h" mitk::LevelWindowProperty::LevelWindowProperty() { } mitk::LevelWindowProperty::LevelWindowProperty(const mitk::LevelWindowProperty& other) : BaseProperty(other) , m_LevWin(other.m_LevWin) { } mitk::LevelWindowProperty::LevelWindowProperty(const mitk::LevelWindow &levWin) { SetLevelWindow(levWin); } mitk::LevelWindowProperty::~LevelWindowProperty() { } bool mitk::LevelWindowProperty::IsEqual(const BaseProperty& property) const { return this->m_LevWin == static_cast(property).m_LevWin; } bool mitk::LevelWindowProperty::Assign(const BaseProperty& property) { this->m_LevWin = static_cast(property).m_LevWin; return true; } const mitk::LevelWindow & mitk::LevelWindowProperty::GetLevelWindow() const { return m_LevWin; } const mitk::LevelWindow & mitk::LevelWindowProperty::GetValue() const { return GetLevelWindow(); } void mitk::LevelWindowProperty::SetLevelWindow(const mitk::LevelWindow &levWin) { if(m_LevWin != levWin) { m_LevWin = levWin; Modified(); } } void mitk::LevelWindowProperty::SetValue(const ValueType& levWin) { SetLevelWindow(levWin); } std::string mitk::LevelWindowProperty::GetValueAsString() const { std::stringstream myStr; myStr << "L:" << m_LevWin.GetLevel() << " W:" << m_LevWin.GetWindow(); return myStr.str(); } itk::LightObject::Pointer mitk::LevelWindowProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkLookupTable.cpp b/Core/Code/DataManagement/mitkLookupTable.cpp index 3931ca2df8..a40549ea36 100644 --- a/Core/Code/DataManagement/mitkLookupTable.cpp +++ b/Core/Code/DataManagement/mitkLookupTable.cpp @@ -1,309 +1,310 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkLookupTable.h" #include #include #include mitk::LookupTable::LookupTable() { m_LookupTable = vtkLookupTable::New(); this->SetRequestedRegionToLargestPossibleRegion(); } mitk::LookupTable::LookupTable(const LookupTable& other) : itk::DataObject() , m_LookupTable(vtkLookupTable::New()) { m_LookupTable->DeepCopy(other.m_LookupTable); } mitk::LookupTable::~LookupTable() { if ( m_LookupTable ) { m_LookupTable->Delete(); m_LookupTable = NULL; } } void mitk::LookupTable::SetVtkLookupTable( vtkLookupTable* lut ) { if(m_LookupTable == lut) { return; } if(m_LookupTable) { m_LookupTable->UnRegister(NULL); m_LookupTable = NULL; } if(lut) { lut->Register(NULL); } m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::ChangeOpacityForAll( float opacity ) { int noValues = m_LookupTable->GetNumberOfTableValues (); double rgba[ 4 ]; for ( int i = 0;i < noValues;i++ ) { m_LookupTable->GetTableValue ( i, rgba ); rgba[ 3 ] = opacity; m_LookupTable->SetTableValue ( i, rgba ); } this->Modified(); // need to call modiefied, since LookupTableProperty seems to be unchanged so no widget-updat is executed } void mitk::LookupTable::ChangeOpacity(int index, float opacity ) { int noValues = m_LookupTable->GetNumberOfTableValues (); if (index>noValues) { MITK_INFO << "could not change opacity. index exceed size of lut ... " << std::endl; return; } double rgba[ 4 ]; m_LookupTable->GetTableValue ( index, rgba ); rgba[ 3 ] = opacity; m_LookupTable->SetTableValue ( index, rgba ); this->Modified(); // need to call modiefied, since LookupTableProperty seems to be unchanged so no widget-updat is executed } vtkLookupTable* mitk::LookupTable::GetVtkLookupTable() const { return m_LookupTable; }; mitk::LookupTable::RawLookupTableType * mitk::LookupTable::GetRawLookupTable() const { if (m_LookupTable==NULL) MITK_INFO << "uuups..." << std::endl; return m_LookupTable->GetPointer( 0 ); }; /*! * \brief equality operator inplementation */ bool mitk::LookupTable::operator==( const mitk::LookupTable& other ) const { if ( m_LookupTable == other.GetVtkLookupTable()) return true; vtkLookupTable* olut = other.GetVtkLookupTable(); if (olut == NULL) return false; bool equal = (m_LookupTable->GetNumberOfColors() == olut->GetNumberOfColors()) && (m_LookupTable->GetTableRange()[0] == olut->GetTableRange()[0]) && (m_LookupTable->GetTableRange()[1] == olut->GetTableRange()[1]) && (m_LookupTable->GetHueRange()[0] == olut->GetHueRange()[0]) && (m_LookupTable->GetHueRange()[1] == olut->GetHueRange()[1]) && (m_LookupTable->GetSaturationRange()[0] == olut->GetSaturationRange()[0]) && (m_LookupTable->GetSaturationRange()[1] == olut->GetSaturationRange()[1]) && (m_LookupTable->GetValueRange()[0] == olut->GetValueRange()[0]) && (m_LookupTable->GetValueRange()[1] == olut->GetValueRange()[1]) && (m_LookupTable->GetAlphaRange()[0] == olut->GetAlphaRange()[0]) && (m_LookupTable->GetAlphaRange()[1] == olut->GetAlphaRange()[1]) && (m_LookupTable->GetRamp() == olut->GetRamp()) && (m_LookupTable->GetScale() == olut->GetScale()) && (m_LookupTable->GetAlpha() == olut->GetAlpha()) && (m_LookupTable->GetTable()->GetNumberOfTuples() == olut->GetTable()->GetNumberOfTuples()); if (equal == false) return false; //for (vtkIdType i=0; i < m_LookupTable->GetTable()->GetNumberOfTuples(); i++) //{ // if (m_LookupTable->GetTable()->GetTuple(i) != olut->GetTable()->GetTuple(i)) // return false; //} for (vtkIdType i=0; i < m_LookupTable->GetNumberOfTableValues(); i++) { //double v0_1 = m_LookupTable->GetTableValue(i)[0]; double v0_2 = olut->GetTableValue(i)[0]; //double v1_1 = m_LookupTable->GetTableValue(i)[1]; double v1_2 = olut->GetTableValue(i)[1]; //double v2_1 = m_LookupTable->GetTableValue(i)[2]; double v2_2 = olut->GetTableValue(i)[2]; //double v3_1 = m_LookupTable->GetTableValue(i)[3]; double v3_2 = olut->GetTableValue(i)[3]; bool tvequal = (m_LookupTable->GetTableValue(i)[0] == olut->GetTableValue(i)[0]) && (m_LookupTable->GetTableValue(i)[1] == olut->GetTableValue(i)[1]) && (m_LookupTable->GetTableValue(i)[2] == olut->GetTableValue(i)[2]) && (m_LookupTable->GetTableValue(i)[3] == olut->GetTableValue(i)[3]); if (tvequal == false) return false; } return true; } /*! * \brief un-equality operator implementation */ bool mitk::LookupTable::operator!=( const mitk::LookupTable& other ) const { return !(*this == other); } /*! * \brief assignment operator implementation */ mitk::LookupTable& mitk::LookupTable::operator=( const mitk::LookupTable& LookupTable ) { if ( this == &LookupTable ) { return * this; } else { m_LookupTable = LookupTable.GetVtkLookupTable(); return *this; } } void mitk::LookupTable::UpdateOutputInformation( ) { if ( this->GetSource( ) ) { this->GetSource( ) ->UpdateOutputInformation( ); } } void mitk::LookupTable::SetRequestedRegionToLargestPossibleRegion( ) {} bool mitk::LookupTable::RequestedRegionIsOutsideOfTheBufferedRegion( ) { return false; } bool mitk::LookupTable::VerifyRequestedRegion( ) { //normally we should check if the requested region lies within the //largest possible region. Since for lookup-tables we assume, that the //requested region is always the largest possible region, we can always //return true! return true; } void mitk::LookupTable::SetRequestedRegion(const itk::DataObject *) { //not implemented, since we always want to have the RequestedRegion //to be set to LargestPossibleRegion } void mitk::LookupTable::CreateColorTransferFunction(vtkColorTransferFunction*& colorFunction) { if(colorFunction==NULL) colorFunction = vtkColorTransferFunction::New(); mitk::LookupTable::RawLookupTableType *rgba = GetRawLookupTable(); int i, num_of_values=m_LookupTable->GetNumberOfTableValues(); double *cols; double *colsHead; colsHead=cols=(double *)malloc(sizeof(double)*num_of_values*3); for(i=0;iBuildFunctionFromTable(m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values-1, colsHead); free(colsHead); } void mitk::LookupTable::CreateOpacityTransferFunction(vtkPiecewiseFunction*& opacityFunction) { if(opacityFunction==NULL) opacityFunction = vtkPiecewiseFunction::New(); mitk::LookupTable::RawLookupTableType *rgba = GetRawLookupTable(); int i, num_of_values=m_LookupTable->GetNumberOfTableValues(); double *alphas; double *alphasHead; alphasHead=alphas=(double*)malloc(sizeof(double)*num_of_values); rgba+=3; for(i=0;iBuildFunctionFromTable(m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values-1, alphasHead); free(alphasHead); } void mitk::LookupTable::CreateGradientTransferFunction(vtkPiecewiseFunction*& gradientFunction) { if(gradientFunction==NULL) gradientFunction = vtkPiecewiseFunction::New(); mitk::LookupTable::RawLookupTableType *rgba = GetRawLookupTable(); int i, num_of_values=m_LookupTable->GetNumberOfTableValues(); double *alphas; double *alphasHead; alphasHead=alphas=(double*)malloc(sizeof(double)*num_of_values); rgba+=3; for(i=0;iBuildFunctionFromTable(m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values-1, alphasHead); free(alphasHead); } void mitk::LookupTable::PrintSelf(std::ostream &os, itk::Indent indent) const { os << indent; m_LookupTable->PrintHeader(os, vtkIndent()); } itk::LightObject::Pointer mitk::LookupTable::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkModalityProperty.cpp b/Core/Code/DataManagement/mitkModalityProperty.cpp index 32bfd3185a..81d6e720f0 100644 --- a/Core/Code/DataManagement/mitkModalityProperty.cpp +++ b/Core/Code/DataManagement/mitkModalityProperty.cpp @@ -1,74 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkModalityProperty.h" mitk::ModalityProperty::ModalityProperty() { AddEnumerationTypes(); } mitk::ModalityProperty::ModalityProperty( const IdType& value ) { AddEnumerationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ) ; } else { SetValue( 0 ); } } mitk::ModalityProperty::ModalityProperty( const std::string& value ) { AddEnumerationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetValue( "undefined" ); } } mitk::ModalityProperty::~ModalityProperty() { } void mitk::ModalityProperty::AddEnumerationTypes() { IdType newId = static_cast(EnumerationProperty::Size()); AddEnum( "undefined", newId++ ); AddEnum( "CR", newId++ ); // computer radiography AddEnum( "CT", newId++ ); // computed tomography AddEnum( "MR", newId++ ); // magnetic resonance AddEnum( "NM", newId++ ); // nuclear medicine AddEnum( "US", newId++ ); // ultrasound AddEnum( "Color Doppler", newId++ ); // ultrasound AddEnum( "Power Doppler", newId++ ); // ultrasound } itk::LightObject::Pointer mitk::ModalityProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkPlaneOrientationProperty.cpp b/Core/Code/DataManagement/mitkPlaneOrientationProperty.cpp index c45f1970aa..1f5d042558 100644 --- a/Core/Code/DataManagement/mitkPlaneOrientationProperty.cpp +++ b/Core/Code/DataManagement/mitkPlaneOrientationProperty.cpp @@ -1,101 +1,102 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPlaneOrientationProperty.h" namespace mitk { PlaneOrientationProperty::PlaneOrientationProperty( ) { this->AddDecorationTypes(); this->SetValue( static_cast( PLANE_DECORATION_NONE ) ); } PlaneOrientationProperty::PlaneOrientationProperty( const IdType& value ) { this->AddDecorationTypes(); if ( this->IsValidEnumerationValue( value ) ) { this->SetValue( value ) ; } else { this->SetValue( static_cast( PLANE_DECORATION_NONE ) ); } } PlaneOrientationProperty::PlaneOrientationProperty( const std::string& value ) { this->AddDecorationTypes(); if ( this->IsValidEnumerationValue( value ) ) { this->SetValue( value ); } else { this->SetValue( static_cast( PLANE_DECORATION_NONE ) ); } } int PlaneOrientationProperty::GetPlaneDecoration() { return static_cast( this->GetValueAsId() ); } void PlaneOrientationProperty::SetPlaneDecorationToNone() { this->SetValue( static_cast( PLANE_DECORATION_NONE ) ); } void PlaneOrientationProperty::SetPlaneDecorationToPositiveOrientation() { this->SetValue( static_cast( PLANE_DECORATION_POSITIVE_ORIENTATION ) ); } void PlaneOrientationProperty::SetPlaneDecorationToNegativeOrientation() { this->SetValue( static_cast( PLANE_DECORATION_NEGATIVE_ORIENTATION ) ); } void PlaneOrientationProperty::AddDecorationTypes() { this->AddEnum( "No plane decoration", static_cast( PLANE_DECORATION_NONE ) ); this->AddEnum( "Arrows in positive direction", static_cast( PLANE_DECORATION_POSITIVE_ORIENTATION ) ); this->AddEnum( "Arrows in negative direction", static_cast( PLANE_DECORATION_NEGATIVE_ORIENTATION ) ); } bool PlaneOrientationProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer PlaneOrientationProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } } // namespace diff --git a/Core/Code/DataManagement/mitkPointSetShapeProperty.cpp b/Core/Code/DataManagement/mitkPointSetShapeProperty.cpp index 45730fd356..e08ebf7d7e 100644 --- a/Core/Code/DataManagement/mitkPointSetShapeProperty.cpp +++ b/Core/Code/DataManagement/mitkPointSetShapeProperty.cpp @@ -1,78 +1,79 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPointSetShapeProperty.h" mitk::PointSetShapeProperty::PointSetShapeProperty( ) { this->AddPointSetShapes(); this->SetValue( CROSS ); } mitk::PointSetShapeProperty::PointSetShapeProperty( const IdType& value ) { this->AddPointSetShapes(); if ( IsValidEnumerationValue( value ) ) { this->SetValue( value ) ; } else MITK_WARN << "Warning: invalid point set shape"; } mitk::PointSetShapeProperty::PointSetShapeProperty( const std::string& value ) { this->AddPointSetShapes(); if ( IsValidEnumerationValue( value ) ) { this->SetValue( value ); } else MITK_WARN << "Invalid point set shape"; } int mitk::PointSetShapeProperty::GetPointSetShape() const { return static_cast( this->GetValueAsId() ); } void mitk::PointSetShapeProperty::AddPointSetShapes() { AddEnum("None", NONE); AddEnum("Vertex", VERTEX); AddEnum("Dash", DASH); AddEnum("Cross", CROSS); AddEnum("ThickCross", THICK_CROSS); AddEnum("Triangle", TRIANGLE); AddEnum("Square", SQUARE); AddEnum("Circle", CIRCLE); AddEnum("Diamond", DIAMOND); AddEnum("Arrow", ARROW); AddEnum("ThickArrow", THICK_ARROW); AddEnum("HookedArrow", HOOKED_ARROW); } bool mitk::PointSetShapeProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer mitk::PointSetShapeProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkRenderingModeProperty.cpp b/Core/Code/DataManagement/mitkRenderingModeProperty.cpp index c233ae638d..b943aedd83 100644 --- a/Core/Code/DataManagement/mitkRenderingModeProperty.cpp +++ b/Core/Code/DataManagement/mitkRenderingModeProperty.cpp @@ -1,71 +1,72 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkRenderingModeProperty.h" mitk::RenderingModeProperty::RenderingModeProperty( ) { this->AddRenderingModes(); this->SetValue( LEVELWINDOW_COLOR ); } mitk::RenderingModeProperty::RenderingModeProperty( const IdType& value ) { this->AddRenderingModes(); if ( IsValidEnumerationValue( value ) ) { this->SetValue( value ) ; } else MITK_WARN << "Warning: invalid image rendering mode"; } mitk::RenderingModeProperty::RenderingModeProperty( const std::string& value ) { this->AddRenderingModes(); if ( IsValidEnumerationValue( value ) ) { this->SetValue( value ); } else MITK_WARN << "Invalid image rendering mode"; } int mitk::RenderingModeProperty::GetRenderingMode() { return static_cast( this->GetValueAsId() ); } void mitk::RenderingModeProperty::AddRenderingModes() { AddEnum( "LevelWindow_Color", LEVELWINDOW_COLOR ); AddEnum( "LookupTable_LevelWindow_Color", LOOKUPTABLE_LEVELWINDOW_COLOR ); AddEnum( "ColorTransferFunction_LevelWindow_Color", COLORTRANSFERFUNCTION_LEVELWINDOW_COLOR ); AddEnum( "LookupTable_Color", LOOKUPTABLE_COLOR ); AddEnum( "ColorTransferFunction_Color", COLORTRANSFERFUNCTION_COLOR ); } bool mitk::RenderingModeProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer mitk::RenderingModeProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkResliceMethodProperty.cpp b/Core/Code/DataManagement/mitkResliceMethodProperty.cpp index 3713b72ece..76d6e2e0f2 100644 --- a/Core/Code/DataManagement/mitkResliceMethodProperty.cpp +++ b/Core/Code/DataManagement/mitkResliceMethodProperty.cpp @@ -1,51 +1,52 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkResliceMethodProperty.h" mitk::ResliceMethodProperty::ResliceMethodProperty( ) { AddThickSlicesTypes(); SetValue( (IdType)0 ); } mitk::ResliceMethodProperty::ResliceMethodProperty( const IdType& value ) { AddThickSlicesTypes(); if ( IsValidEnumerationValue( value ) ) SetValue( value ); } mitk::ResliceMethodProperty::ResliceMethodProperty( const std::string& value ) { AddThickSlicesTypes(); if ( IsValidEnumerationValue( value ) ) SetValue( value ); } void mitk::ResliceMethodProperty::AddThickSlicesTypes() { AddEnum( "disabled", (IdType) 0 ); AddEnum( "mip", (IdType) 1 ); AddEnum( "sum", (IdType) 2 ); AddEnum( "weighted", (IdType) 3 ); } itk::LightObject::Pointer mitk::ResliceMethodProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkShaderProperty.cpp b/Core/Code/DataManagement/mitkShaderProperty.cpp index 828e95cc55..2a5415a2a7 100644 --- a/Core/Code/DataManagement/mitkShaderProperty.cpp +++ b/Core/Code/DataManagement/mitkShaderProperty.cpp @@ -1,118 +1,119 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "mitkShaderProperty.h" #include "mitkCoreServices.h" #include "mitkIShaderRepository.h" #include #include mitk::ShaderProperty::ShaderProperty( ) { AddShaderTypes(); SetShader( (IdType)0 ); } mitk::ShaderProperty::ShaderProperty(const ShaderProperty& other) : mitk::EnumerationProperty(other) , shaderList(other.shaderList) { } mitk::ShaderProperty::ShaderProperty( const IdType& value ) { AddShaderTypes(); SetShader(value); } mitk::ShaderProperty::ShaderProperty( const std::string& value ) { AddShaderTypes(); SetShader(value); } void mitk::ShaderProperty::SetShader( const IdType& value ) { if ( IsValidEnumerationValue( value ) ) SetValue( value ); else SetValue( (IdType)0 ); } void mitk::ShaderProperty::SetShader( const std::string& value ) { if ( IsValidEnumerationValue( value ) ) SetValue( value ); else SetValue( (IdType)0 ); } mitk::EnumerationProperty::IdType mitk::ShaderProperty::GetShaderId() { return GetValueAsId(); } std::string mitk::ShaderProperty::GetShaderName() { return GetValueAsString(); } void mitk::ShaderProperty::AddShaderTypes() { AddEnum( "fixed" ); CoreServicePointer shaderRepo(CoreServices::GetShaderRepository()); std::list l = shaderRepo->GetShaders(); std::list::const_iterator i = l.begin(); while( i != l.end() ) { AddEnum( (*i)->GetName() ); i++; } } bool mitk::ShaderProperty::AddEnum( const std::string& name ,const IdType& /*id*/) { Element e; e.name=name; bool success=Superclass::AddEnum( e.name, (IdType)shaderList.size() ); shaderList.push_back(e); return success; } bool mitk::ShaderProperty::Assign(const BaseProperty &property) { Superclass::Assign(property); this->shaderList = static_cast(property).shaderList; return true; } itk::LightObject::Pointer mitk::ShaderProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkSmartPointerProperty.cpp b/Core/Code/DataManagement/mitkSmartPointerProperty.cpp index 483f04a8c3..a37148290b 100644 --- a/Core/Code/DataManagement/mitkSmartPointerProperty.cpp +++ b/Core/Code/DataManagement/mitkSmartPointerProperty.cpp @@ -1,142 +1,143 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSmartPointerProperty.h" mitk::SmartPointerProperty::ReferenceCountMapType mitk::SmartPointerProperty::m_ReferenceCount; mitk::SmartPointerProperty::ReferencesUIDMapType mitk::SmartPointerProperty::m_ReferencesUID; mitk::SmartPointerProperty::ReadInSmartPointersMapType mitk::SmartPointerProperty::m_ReadInInstances; mitk::SmartPointerProperty::ReadInTargetsMapType mitk::SmartPointerProperty::m_ReadInTargets; mitk::UIDGenerator mitk::SmartPointerProperty::m_UIDGenerator("POINTER_"); void mitk::SmartPointerProperty::PostProcessXMLReading() { for (ReadInSmartPointersMapType::iterator iter = m_ReadInInstances.begin(); iter != m_ReadInInstances.end(); ++iter) { if ( m_ReadInTargets.find(iter->second) != m_ReadInTargets.end() ) { iter->first->SetSmartPointer( m_ReadInTargets[ iter->second ] ); } } m_ReadInInstances.clear(); } /// \return The number of SmartPointerProperties that point to @param object unsigned int mitk::SmartPointerProperty::GetReferenceCountFor(itk::Object* object) { if ( m_ReferenceCount.find(object) != m_ReferenceCount.end() ) { return m_ReferenceCount[object]; } else { return 0; } } void mitk::SmartPointerProperty::RegisterPointerTarget(itk::Object* object, const std::string uid) { m_ReadInTargets[uid] = object; } std::string mitk::SmartPointerProperty::GetReferenceUIDFor(itk::Object* object) { if ( m_ReferencesUID.find(object) != m_ReferencesUID.end() ) { return m_ReferencesUID[object]; } else { return std::string("invalid"); } } bool mitk::SmartPointerProperty::IsEqual(const BaseProperty& property) const { return this->m_SmartPointer == static_cast(property).m_SmartPointer; } bool mitk::SmartPointerProperty::Assign(const BaseProperty& property) { this->m_SmartPointer = static_cast(property).m_SmartPointer; return true; } mitk::SmartPointerProperty::SmartPointerProperty(itk::Object* pointer) { SetSmartPointer( pointer ); } mitk::SmartPointerProperty::SmartPointerProperty(const SmartPointerProperty& other) : BaseProperty(other) , m_SmartPointer(other.m_SmartPointer) { } itk::Object::Pointer mitk::SmartPointerProperty::GetSmartPointer() const { return m_SmartPointer; } itk::Object::Pointer mitk::SmartPointerProperty::GetValue() const { return this->GetSmartPointer(); } void mitk::SmartPointerProperty::SetSmartPointer(itk::Object* pointer) { if(m_SmartPointer.GetPointer() != pointer) { // keep track of referenced objects if ( m_SmartPointer.GetPointer() && --m_ReferenceCount[m_SmartPointer.GetPointer()] == 0 ) // if there is no reference left, delete entry { m_ReferenceCount.erase( m_SmartPointer.GetPointer() ); m_ReferencesUID.erase( m_SmartPointer.GetPointer() ); } if ( pointer && ++m_ReferenceCount[pointer] == 1 ) // first reference --> generate UID { m_ReferencesUID[pointer] = m_UIDGenerator.GetUID(); } // change pointer m_SmartPointer = pointer; Modified(); } } void mitk::SmartPointerProperty::SetValue(const ValueType & value) { this->SetSmartPointer(value.GetPointer()); } std::string mitk::SmartPointerProperty::GetValueAsString() const { if ( m_SmartPointer.IsNotNull() ) return m_ReferencesUID[ m_SmartPointer.GetPointer() ]; else return std::string("NULL"); } itk::LightObject::Pointer mitk::SmartPointerProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkStringProperty.cpp b/Core/Code/DataManagement/mitkStringProperty.cpp index 98e5f08738..4456d8c539 100644 --- a/Core/Code/DataManagement/mitkStringProperty.cpp +++ b/Core/Code/DataManagement/mitkStringProperty.cpp @@ -1,59 +1,60 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkStringProperty.h" const char* mitk::StringProperty::PATH = "path"; mitk::StringProperty::StringProperty( const char* string ) : m_Value() { if ( string ) m_Value = string; } mitk::StringProperty::StringProperty( const std::string& s ) : m_Value( s ) { } mitk::StringProperty::StringProperty(const StringProperty& other) : BaseProperty(other) , m_Value(other.m_Value) { } bool mitk::StringProperty::IsEqual(const BaseProperty& property ) const { return this->m_Value == static_cast(property).m_Value; } bool mitk::StringProperty::Assign(const BaseProperty& property ) { this->m_Value = static_cast(property).m_Value; return true; } std::string mitk::StringProperty::GetValueAsString() const { return m_Value; } itk::LightObject::Pointer mitk::StringProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkTransferFunction.cpp b/Core/Code/DataManagement/mitkTransferFunction.cpp index d3b6b29abc..ff27981fc4 100644 --- a/Core/Code/DataManagement/mitkTransferFunction.cpp +++ b/Core/Code/DataManagement/mitkTransferFunction.cpp @@ -1,332 +1,333 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTransferFunction.h" #include "mitkImageToItk.h" #include "mitkHistogramGenerator.h" #include #include namespace mitk { TransferFunction::TransferFunction() : m_Min(0), m_Max(0) { m_ScalarOpacityFunction = vtkSmartPointer::New(); m_ColorTransferFunction = vtkSmartPointer::New(); m_GradientOpacityFunction = vtkSmartPointer::New(); m_ScalarOpacityFunction->Initialize(); m_ScalarOpacityFunction->AddPoint(0,1); m_GradientOpacityFunction->Initialize(); m_GradientOpacityFunction->AddPoint(0,1); m_ColorTransferFunction->RemoveAllPoints(); m_ColorTransferFunction->SetColorSpaceToHSV(); m_ColorTransferFunction->AddRGBPoint(0,1,1,1); } TransferFunction::TransferFunction(const TransferFunction& other) : itk::Object() , m_ScalarOpacityFunction(other.m_ScalarOpacityFunction.New()) , m_GradientOpacityFunction(other.m_GradientOpacityFunction.New()) , m_ColorTransferFunction(other.m_ColorTransferFunction.New()) , m_Min(other.m_Min) , m_Max(other.m_Max) , m_Histogram(other.m_Histogram) , m_ScalarOpacityPoints(other.m_ScalarOpacityPoints) , m_GradientOpacityPoints(other.m_GradientOpacityPoints) , m_RGBPoints(other.m_RGBPoints) { m_ScalarOpacityFunction->DeepCopy(other.m_ScalarOpacityFunction); m_GradientOpacityFunction->DeepCopy(other.m_GradientOpacityFunction); m_ColorTransferFunction->DeepCopy(other.m_ColorTransferFunction); } TransferFunction::~TransferFunction() { } bool TransferFunction::operator==(Self& other) { if ((m_Min != other.m_Min) || (m_Max != other.m_Max)) return false; bool sizes = (m_ScalarOpacityFunction->GetSize() == other.m_ScalarOpacityFunction->GetSize()) && (m_GradientOpacityFunction->GetSize() == other.m_GradientOpacityFunction->GetSize()) && (m_ColorTransferFunction->GetSize() == other.m_ColorTransferFunction->GetSize()); if (sizes == false) return false; for (int i = 0; i < m_ScalarOpacityFunction->GetSize(); i++ ) { double myVal[4]; double otherVal[4]; m_ScalarOpacityFunction->GetNodeValue(i, myVal); other.m_ScalarOpacityFunction->GetNodeValue(i, otherVal); bool equal = (myVal[0] == otherVal[0]) && (myVal[1] == otherVal[1]) && (myVal[2] == otherVal[2]) && (myVal[3] == otherVal[3]); if (equal == false) return false; } for (int i = 0; i < m_GradientOpacityFunction->GetSize(); i++ ) { double myVal[4]; double otherVal[4]; m_GradientOpacityFunction->GetNodeValue(i, myVal); other.m_GradientOpacityFunction->GetNodeValue(i, otherVal); bool equal = (myVal[0] == otherVal[0]) && (myVal[1] == otherVal[1]) && (myVal[2] == otherVal[2]) && (myVal[3] == otherVal[3]); if (equal == false) return false; } for (int i = 0; i < m_ColorTransferFunction->GetSize(); i++ ) { double myVal[6]; double otherVal[6]; m_ColorTransferFunction->GetNodeValue(i, myVal); other.m_ColorTransferFunction->GetNodeValue(i, otherVal); bool equal = (myVal[0] == otherVal[0]) // X && (myVal[1] == otherVal[1]) // R && (myVal[2] == otherVal[2]) // G && (myVal[3] == otherVal[3]) // B && (myVal[4] == otherVal[4]) // midpoint && (myVal[5] == otherVal[5]); // sharpness if (equal == false) return false; } return true; } void TransferFunction::SetScalarOpacityPoints(TransferFunction::ControlPoints points) { m_ScalarOpacityFunction->RemoveAllPoints(); for(unsigned int i=0; i<=points.size()-1;i++) { this->AddScalarOpacityPoint(points[i].first, points[i].second); } } void TransferFunction::SetGradientOpacityPoints(TransferFunction::ControlPoints points) { m_GradientOpacityFunction->RemoveAllPoints(); for(unsigned int i=0; i<=points.size()-1;i++) { this->AddGradientOpacityPoint(points[i].first, points[i].second); } } void TransferFunction::SetRGBPoints(TransferFunction::RGBControlPoints rgbpoints) { m_ColorTransferFunction->RemoveAllPoints(); for(unsigned int i=0; i<=rgbpoints.size()-1;i++) { this->AddRGBPoint(rgbpoints[i].first, rgbpoints[i].second[0], rgbpoints[i].second[1], rgbpoints[i].second[2]); } } void TransferFunction::AddScalarOpacityPoint(double x, double value) { m_ScalarOpacityFunction->AddPoint(x, value); } void TransferFunction::AddGradientOpacityPoint(double x, double value) { m_GradientOpacityFunction->AddPoint(x, value); } void TransferFunction::AddRGBPoint(double x, double r, double g, double b) { m_ColorTransferFunction->AddRGBPoint(x, r, g, b); } TransferFunction::ControlPoints &TransferFunction::GetScalarOpacityPoints() { // Retrieve data points from VTK transfer function and store them in a vector m_ScalarOpacityPoints.clear(); double *data = m_ScalarOpacityFunction->GetDataPointer(); for ( int i = 0; i < m_ScalarOpacityFunction->GetSize(); ++i ) { m_ScalarOpacityPoints.push_back( std::make_pair( data[i*2], data[i*2+1] )); } return m_ScalarOpacityPoints; } TransferFunction::ControlPoints &TransferFunction::GetGradientOpacityPoints() { // Retrieve data points from VTK transfer function and store them in a vector m_GradientOpacityPoints.clear(); double *data = m_GradientOpacityFunction->GetDataPointer(); for ( int i = 0; i < m_GradientOpacityFunction->GetSize(); ++i ) { m_GradientOpacityPoints.push_back( std::make_pair( data[i*2], data[i*2+1] )); } return m_GradientOpacityPoints; } TransferFunction::RGBControlPoints &TransferFunction::GetRGBPoints() { // Retrieve data points from VTK transfer function and store them in a vector m_RGBPoints.clear(); double *data = m_ColorTransferFunction->GetDataPointer(); for ( int i = 0; i < m_ColorTransferFunction->GetSize(); ++i ) { double rgb[] = { data[i*4+1], data[i*4+2], data[i*4+3] }; m_RGBPoints.push_back( std::make_pair( data[i*4], rgb )); } return m_RGBPoints; } int TransferFunction::RemoveScalarOpacityPoint(double x) { return m_ScalarOpacityFunction->RemovePoint(x); } int TransferFunction::RemoveGradientOpacityPoint(double x) { return m_GradientOpacityFunction->RemovePoint(x); } int TransferFunction::RemoveRGBPoint(double x) { return m_ColorTransferFunction->RemovePoint(x); } void TransferFunction::ClearScalarOpacityPoints() { m_ScalarOpacityFunction->RemoveAllPoints(); } void TransferFunction::ClearGradientOpacityPoints() { m_GradientOpacityFunction->RemoveAllPoints(); } void TransferFunction::ClearRGBPoints() { m_ColorTransferFunction->RemoveAllPoints(); } void TransferFunction::InitializeByItkHistogram( const itk::Statistics::Histogram* histogram) { m_Histogram = histogram; m_Min = (int)GetHistogram()->GetBinMin(0,0); m_Max = (int)GetHistogram()->GetBinMax(0, GetHistogram()->Size()-1); /* m_ScalarOpacityFunction->Initialize(); m_ScalarOpacityFunction->AddPoint(m_Min,0.0); m_ScalarOpacityFunction->AddPoint(0.0,0.0); m_ScalarOpacityFunction->AddPoint(m_Max,1.0); m_GradientOpacityFunction->Initialize(); m_GradientOpacityFunction->AddPoint(m_Min,0.0); m_GradientOpacityFunction->AddPoint(0.0,1.0); m_GradientOpacityFunction->AddPoint((m_Max*0.125),1.0); m_GradientOpacityFunction->AddPoint((m_Max*0.2),1.0); m_GradientOpacityFunction->AddPoint((m_Max*0.25),1.0); m_GradientOpacityFunction->AddPoint(m_Max,1.0); m_ColorTransferFunction->RemoveAllPoints(); m_ColorTransferFunction->AddRGBPoint(m_Min,1,0,0); m_ColorTransferFunction->AddRGBPoint(m_Max,1,1,0); m_ColorTransferFunction->SetColorSpaceToHSV(); MITK_INFO << "min/max in tf-c'tor:" << m_Min << "/" << m_Max << std::endl; */ } void TransferFunction::InitializeByMitkImage( const Image * image ) { HistogramGenerator::Pointer histGen= HistogramGenerator::New(); histGen->SetImage(image); histGen->SetSize(256); histGen->ComputeHistogram(); m_Histogram = histGen->GetHistogram(); m_Min = (int)GetHistogram()->GetBinMin(0,0); m_Max = (int)GetHistogram()->GetBinMax(0, GetHistogram()->Size()-1); m_ScalarOpacityFunction->Initialize(); m_ScalarOpacityFunction->AddPoint(m_Min,0.0); m_ScalarOpacityFunction->AddPoint(0.0,0.0); m_ScalarOpacityFunction->AddPoint(m_Max,1.0); m_GradientOpacityFunction->Initialize(); m_GradientOpacityFunction->AddPoint(m_Min,0.0); m_GradientOpacityFunction->AddPoint(0.0,1.0); m_GradientOpacityFunction->AddPoint((m_Max*0.125),1.0); m_GradientOpacityFunction->AddPoint((m_Max*0.2),1.0); m_GradientOpacityFunction->AddPoint((m_Max*0.25),1.0); m_GradientOpacityFunction->AddPoint(m_Max,1.0); m_ColorTransferFunction->RemoveAllPoints(); m_ColorTransferFunction->AddRGBPoint(m_Min,1,0,0); m_ColorTransferFunction->AddRGBPoint(m_Max,1,1,0); m_ColorTransferFunction->SetColorSpaceToHSV(); //MITK_INFO << "min/max in tf-c'tor:" << m_Min << "/" << m_Max << std::endl; } void TransferFunction::InitializeHistogram( const Image * image ) { HistogramGenerator::Pointer histGen= HistogramGenerator::New(); histGen->SetImage(image); histGen->SetSize(256); histGen->ComputeHistogram(); m_Histogram = histGen->GetHistogram(); m_Min = (int)GetHistogram()->GetBinMin(0,0); m_Max = (int)GetHistogram()->GetBinMax(0, GetHistogram()->Size()-1); } void TransferFunction::PrintSelf(std::ostream &os, itk::Indent indent) const { os << indent << "ScalarOpacity: "; m_ScalarOpacityFunction->PrintHeader(os, vtkIndent()); os << indent << "GradientOpacity: "; m_GradientOpacityFunction->PrintHeader(os, vtkIndent()); os << indent << "ColorTransfer: "; m_ColorTransferFunction->PrintHeader(os, vtkIndent()); os << indent << "Min: " << m_Min << ", Max: " << m_Max << std::endl; } itk::LightObject::Pointer mitk::TransferFunction::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } }// namespace diff --git a/Core/Code/DataManagement/mitkTransferFunctionProperty.cpp b/Core/Code/DataManagement/mitkTransferFunctionProperty.cpp index 13dc0ce75e..dd5f7cc657 100644 --- a/Core/Code/DataManagement/mitkTransferFunctionProperty.cpp +++ b/Core/Code/DataManagement/mitkTransferFunctionProperty.cpp @@ -1,61 +1,62 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTransferFunctionProperty.h" namespace mitk { bool TransferFunctionProperty::IsEqual(const BaseProperty& property) const { return *(this->m_Value) == *(static_cast(property).m_Value); } bool TransferFunctionProperty::Assign(const BaseProperty& property) { this->m_Value = static_cast(property).m_Value; return true; } std::string TransferFunctionProperty::GetValueAsString() const { std::stringstream myStr; myStr << GetValue(); return myStr.str(); } TransferFunctionProperty::TransferFunctionProperty() : BaseProperty(), m_Value(mitk::TransferFunction::New()) {} TransferFunctionProperty::TransferFunctionProperty(const TransferFunctionProperty& other) : BaseProperty(other) , m_Value(other.m_Value->Clone()) { } TransferFunctionProperty::TransferFunctionProperty( mitk::TransferFunction::Pointer value ) : BaseProperty(), m_Value( value ) {} itk::LightObject::Pointer TransferFunctionProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } } // namespace mitk diff --git a/Core/Code/DataManagement/mitkVtkInterpolationProperty.cpp b/Core/Code/DataManagement/mitkVtkInterpolationProperty.cpp index 556df231b8..bb70d06231 100644 --- a/Core/Code/DataManagement/mitkVtkInterpolationProperty.cpp +++ b/Core/Code/DataManagement/mitkVtkInterpolationProperty.cpp @@ -1,97 +1,98 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "mitkVtkInterpolationProperty.h" mitk::VtkInterpolationProperty::VtkInterpolationProperty( ) { AddInterpolationTypes(); SetValue( static_cast( VTK_GOURAUD ) ); } mitk::VtkInterpolationProperty::VtkInterpolationProperty( const IdType& value ) { AddInterpolationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ) ; } else { SetValue( static_cast( VTK_GOURAUD ) ); } } mitk::VtkInterpolationProperty::VtkInterpolationProperty( const std::string& value ) { AddInterpolationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetValue( static_cast( VTK_GOURAUD ) ); } } int mitk::VtkInterpolationProperty::GetVtkInterpolation() { return static_cast( GetValueAsId() ); } void mitk::VtkInterpolationProperty::SetInterpolationToFlat() { SetValue( static_cast( VTK_FLAT ) ); } void mitk::VtkInterpolationProperty::SetInterpolationToGouraud() { SetValue( static_cast( VTK_GOURAUD ) ); } void mitk::VtkInterpolationProperty::SetInterpolationToPhong() { SetValue( static_cast( VTK_PHONG ) ); } void mitk::VtkInterpolationProperty::AddInterpolationTypes() { AddEnum( "Flat", static_cast( VTK_FLAT ) ); AddEnum( "Gouraud", static_cast( VTK_GOURAUD ) ); AddEnum( "Phong", static_cast( VTK_PHONG ) ); } bool mitk::VtkInterpolationProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer mitk::VtkInterpolationProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkVtkRepresentationProperty.cpp b/Core/Code/DataManagement/mitkVtkRepresentationProperty.cpp index f0c2828743..fbe8dba5b2 100644 --- a/Core/Code/DataManagement/mitkVtkRepresentationProperty.cpp +++ b/Core/Code/DataManagement/mitkVtkRepresentationProperty.cpp @@ -1,96 +1,97 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "mitkVtkRepresentationProperty.h" mitk::VtkRepresentationProperty::VtkRepresentationProperty( ) { AddRepresentationTypes(); SetValue( static_cast( VTK_SURFACE ) ); } mitk::VtkRepresentationProperty::VtkRepresentationProperty( const IdType& value ) { AddRepresentationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetValue( static_cast( VTK_SURFACE ) ); } } mitk::VtkRepresentationProperty::VtkRepresentationProperty( const std::string& value ) { AddRepresentationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetValue( static_cast( VTK_SURFACE ) ); } } int mitk::VtkRepresentationProperty::GetVtkRepresentation() { return static_cast( GetValueAsId() ); } void mitk::VtkRepresentationProperty::SetRepresentationToPoints() { SetValue( static_cast( VTK_POINTS ) ); } void mitk::VtkRepresentationProperty::SetRepresentationToWireframe() { SetValue( static_cast( VTK_WIREFRAME ) ); } void mitk::VtkRepresentationProperty::SetRepresentationToSurface() { SetValue( static_cast( VTK_SURFACE ) ); } void mitk::VtkRepresentationProperty::AddRepresentationTypes() { AddEnum( "Points", static_cast( VTK_POINTS ) ); AddEnum( "Wireframe", static_cast( VTK_WIREFRAME ) ); AddEnum( "Surface", static_cast( VTK_SURFACE ) ); } bool mitk::VtkRepresentationProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer mitk::VtkRepresentationProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkVtkResliceInterpolationProperty.cpp b/Core/Code/DataManagement/mitkVtkResliceInterpolationProperty.cpp index 702eedbad2..acdbcd06b4 100644 --- a/Core/Code/DataManagement/mitkVtkResliceInterpolationProperty.cpp +++ b/Core/Code/DataManagement/mitkVtkResliceInterpolationProperty.cpp @@ -1,97 +1,98 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "mitkVtkResliceInterpolationProperty.h" mitk::VtkResliceInterpolationProperty::VtkResliceInterpolationProperty( ) { this->AddInterpolationTypes(); this->SetValue( static_cast( VTK_RESLICE_NEAREST ) ); } mitk::VtkResliceInterpolationProperty::VtkResliceInterpolationProperty( const IdType& value ) { this->AddInterpolationTypes(); if ( IsValidEnumerationValue( value ) ) { this->SetValue( value ) ; } else { this->SetValue( static_cast( VTK_RESLICE_NEAREST ) ); } } mitk::VtkResliceInterpolationProperty::VtkResliceInterpolationProperty( const std::string& value ) { this->AddInterpolationTypes(); if ( IsValidEnumerationValue( value ) ) { this->SetValue( value ); } else { this->SetValue( static_cast( VTK_RESLICE_NEAREST ) ); } } int mitk::VtkResliceInterpolationProperty::GetInterpolation() { return static_cast( this->GetValueAsId() ); } void mitk::VtkResliceInterpolationProperty::SetInterpolationToNearest() { this->SetValue( static_cast( VTK_RESLICE_NEAREST ) ); } void mitk::VtkResliceInterpolationProperty::SetInterpolationToLinear() { this->SetValue( static_cast( VTK_RESLICE_LINEAR ) ); } void mitk::VtkResliceInterpolationProperty::SetInterpolationToCubic() { this->SetValue( static_cast( VTK_RESLICE_CUBIC ) ); } void mitk::VtkResliceInterpolationProperty::AddInterpolationTypes() { AddEnum( "Nearest", static_cast( VTK_RESLICE_NEAREST ) ); AddEnum( "Linear", static_cast( VTK_RESLICE_LINEAR ) ); AddEnum( "Cubic", static_cast( VTK_RESLICE_CUBIC ) ); } bool mitk::VtkResliceInterpolationProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer mitk::VtkResliceInterpolationProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkVtkScalarModeProperty.cpp b/Core/Code/DataManagement/mitkVtkScalarModeProperty.cpp index 867536b3a7..cc08d72c5b 100644 --- a/Core/Code/DataManagement/mitkVtkScalarModeProperty.cpp +++ b/Core/Code/DataManagement/mitkVtkScalarModeProperty.cpp @@ -1,100 +1,101 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "mitkVtkScalarModeProperty.h" mitk::VtkScalarModeProperty::VtkScalarModeProperty( ) { AddInterpolationTypes(); SetScalarModeToDefault(); } mitk::VtkScalarModeProperty::VtkScalarModeProperty( const IdType& value ) { AddInterpolationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ) ; } else { SetScalarModeToDefault(); } } mitk::VtkScalarModeProperty::VtkScalarModeProperty( const std::string& value ) { AddInterpolationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetScalarModeToDefault(); } } int mitk::VtkScalarModeProperty::GetVtkScalarMode() { return static_cast( GetValueAsId() ); } void mitk::VtkScalarModeProperty::SetScalarModeToDefault() { SetValue( static_cast( VTK_SCALAR_MODE_DEFAULT ) ); } void mitk::VtkScalarModeProperty::SetScalarModeToPointData() { SetValue( static_cast( VTK_SCALAR_MODE_USE_POINT_DATA ) ); } void mitk::VtkScalarModeProperty::SetScalarModeToCellData() { SetValue( static_cast( VTK_SCALAR_MODE_USE_CELL_DATA ) ); } void mitk::VtkScalarModeProperty::SetScalarModeToPointFieldData() { SetValue( static_cast( VTK_SCALAR_MODE_USE_POINT_FIELD_DATA ) ); } void mitk::VtkScalarModeProperty::SetScalarModeToCellFieldData() { SetValue( static_cast( VTK_SCALAR_MODE_USE_CELL_FIELD_DATA ) ); } void mitk::VtkScalarModeProperty::AddInterpolationTypes() { AddEnum( "Default", static_cast( VTK_SCALAR_MODE_DEFAULT ) ); AddEnum( "PointData", static_cast( VTK_SCALAR_MODE_USE_POINT_DATA ) ); AddEnum( "CellData", static_cast( VTK_SCALAR_MODE_USE_CELL_DATA ) ); AddEnum( "PointFieldData", static_cast( VTK_SCALAR_MODE_USE_POINT_FIELD_DATA ) ); AddEnum( "CellFieldData", static_cast( VTK_SCALAR_MODE_USE_CELL_FIELD_DATA ) ); } bool mitk::VtkScalarModeProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer mitk::VtkScalarModeProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkVtkVolumeRenderingProperty.cpp b/Core/Code/DataManagement/mitkVtkVolumeRenderingProperty.cpp index f732ce33fa..c5ee3c3309 100644 --- a/Core/Code/DataManagement/mitkVtkVolumeRenderingProperty.cpp +++ b/Core/Code/DataManagement/mitkVtkVolumeRenderingProperty.cpp @@ -1,84 +1,85 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "mitkVtkVolumeRenderingProperty.h" mitk::VtkVolumeRenderingProperty::VtkVolumeRenderingProperty( ) { this->AddRenderingTypes(); this->SetValue( static_cast( VTK_RAY_CAST_COMPOSITE_FUNCTION ) ); } mitk::VtkVolumeRenderingProperty::VtkVolumeRenderingProperty( const IdType& value ) { this->AddRenderingTypes(); if ( IsValidEnumerationValue( value ) ) { this->SetValue( value ) ; } else MITK_INFO << "Warning: invalid rendering configuration" << std::endl; } mitk::VtkVolumeRenderingProperty::VtkVolumeRenderingProperty( const std::string& value ) { this->AddRenderingTypes(); if ( IsValidEnumerationValue( value ) ) { this->SetValue( value ); } else MITK_INFO << "Warning: invalid rendering configuration" << std::endl; } int mitk::VtkVolumeRenderingProperty::GetRenderingType() { return static_cast( this->GetValueAsId() ); } void mitk::VtkVolumeRenderingProperty::SetRenderingTypeToMIP() { this->SetValue( static_cast( VTK_VOLUME_RAY_CAST_MIP_FUNCTION ) ); } void mitk::VtkVolumeRenderingProperty::SetRenderingTypeToComposite() { this->SetValue( static_cast( VTK_RAY_CAST_COMPOSITE_FUNCTION ) ); } void mitk::VtkVolumeRenderingProperty::AddRenderingTypes() { AddEnum( "MIP", static_cast( VTK_VOLUME_RAY_CAST_MIP_FUNCTION ) ); AddEnum( "COMPOSITE", static_cast (VTK_RAY_CAST_COMPOSITE_FUNCTION)); } bool mitk::VtkVolumeRenderingProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer mitk::VtkVolumeRenderingProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/DataManagement/mitkWeakPointerProperty.cpp b/Core/Code/DataManagement/mitkWeakPointerProperty.cpp index b9d4d95fa0..8a6f744f51 100644 --- a/Core/Code/DataManagement/mitkWeakPointerProperty.cpp +++ b/Core/Code/DataManagement/mitkWeakPointerProperty.cpp @@ -1,80 +1,81 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkWeakPointerProperty.h" bool mitk::WeakPointerProperty::IsEqual(const BaseProperty& property) const { return this->m_WeakPointer == static_cast(property).m_WeakPointer; } bool mitk::WeakPointerProperty::Assign(const BaseProperty& property) { this->m_WeakPointer = static_cast(property).m_WeakPointer; return true; } mitk::WeakPointerProperty::WeakPointerProperty(itk::Object* pointer) : m_WeakPointer(pointer) { } mitk::WeakPointerProperty::WeakPointerProperty(const WeakPointerProperty& other) : mitk::BaseProperty(other) , m_WeakPointer(other.m_WeakPointer) { } mitk::WeakPointerProperty::~WeakPointerProperty() { } std::string mitk::WeakPointerProperty::GetValueAsString() const { std::stringstream ss; ss << m_WeakPointer.GetPointer(); return ss.str(); } mitk::WeakPointerProperty::ValueType mitk::WeakPointerProperty::GetWeakPointer() const { return m_WeakPointer.GetPointer(); } mitk::WeakPointerProperty::ValueType mitk::WeakPointerProperty::GetValue() const { return GetWeakPointer(); } void mitk::WeakPointerProperty::SetWeakPointer(itk::Object* pointer) { if(m_WeakPointer.GetPointer() != pointer) { m_WeakPointer = pointer; Modified(); } } void mitk::WeakPointerProperty::SetValue(const ValueType &value) { SetWeakPointer(value.GetPointer()); } itk::LightObject::Pointer mitk::WeakPointerProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Core/Code/IO/mitkLookupTableProperty.cpp b/Core/Code/IO/mitkLookupTableProperty.cpp index 7a3b011581..96b311edd3 100755 --- a/Core/Code/IO/mitkLookupTableProperty.cpp +++ b/Core/Code/IO/mitkLookupTableProperty.cpp @@ -1,80 +1,81 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkLookupTableProperty.h" mitk::LookupTableProperty::LookupTableProperty() { } mitk::LookupTableProperty::LookupTableProperty(const LookupTableProperty& other) : mitk::BaseProperty(other) , m_LookupTable(other.m_LookupTable) { } mitk::LookupTableProperty::LookupTableProperty(const mitk::LookupTable::Pointer lut) { this->SetLookupTable(lut); } bool mitk::LookupTableProperty::IsEqual(const BaseProperty& property) const { return *(this->m_LookupTable) == *(static_cast(property).m_LookupTable); } bool mitk::LookupTableProperty::Assign(const BaseProperty& property) { this->m_LookupTable = static_cast(property).m_LookupTable; return true; } std::string mitk::LookupTableProperty::GetValueAsString() const { std::stringstream ss; ss << m_LookupTable; return ss.str(); } mitk::LookupTableProperty::ValueType mitk::LookupTableProperty::GetValue() const { return m_LookupTable; } void mitk::LookupTableProperty::SetLookupTable(const mitk::LookupTable::Pointer aLookupTable) { // MITK_INFO << "setting LUT property ... " << std::endl; if((m_LookupTable != aLookupTable) || (*m_LookupTable != *aLookupTable)) { m_LookupTable = aLookupTable; Modified(); } // MITK_INFO << "setting LUT property OK! " << std::endl; } void mitk::LookupTableProperty::SetValue(const ValueType & value) { SetLookupTable(value); } itk::LightObject::Pointer mitk::LookupTableProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Modules/CameraCalibration/mitkCameraIntrinsics.cpp b/Modules/CameraCalibration/mitkCameraIntrinsics.cpp index 30e764f7b9..269ec82e4a 100644 --- a/Modules/CameraCalibration/mitkCameraIntrinsics.cpp +++ b/Modules/CameraCalibration/mitkCameraIntrinsics.cpp @@ -1,510 +1,511 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkCameraIntrinsics.h" #include #include #include mitk::CameraIntrinsics::CameraIntrinsics() : m_Valid(false), m_Mutex(itk::FastMutexLock::New()) { m_CameraMatrix = cv::Mat::zeros(3, 3, cv::DataType::type); m_CameraMatrix.at(2,2) = 1.0; m_DistorsionCoeffs = cv::Mat::zeros(1, 5, cv::DataType::type); } mitk::CameraIntrinsics::CameraIntrinsics(const CameraIntrinsics& other) : itk::Object() , mitk::XMLSerializable() , m_Valid(false) , m_Mutex(itk::FastMutexLock::New()) { this->Copy(&other); } mitk::CameraIntrinsics::~CameraIntrinsics() { } bool mitk::CameraIntrinsics::Equals( const CameraIntrinsics* other ) const { return other->GetDistorsionCoeffsAsPoint4D()== this->GetDistorsionCoeffsAsPoint4D() && other->GetFocalPoint()== this->GetFocalPoint() && other->GetPrincipalPoint() == this->GetPrincipalPoint(); } void mitk::CameraIntrinsics::Copy(const CameraIntrinsics* other) { this->SetIntrinsics( other->GetCameraMatrix().clone() , other->GetDistorsionCoeffs().clone() ); this->SetValid(other->m_Valid); } bool mitk::CameraIntrinsics::IsValid() const { itk::MutexLockHolder lock(*m_Mutex); return m_Valid; } vnl_matrix_fixed mitk::CameraIntrinsics::GetVnlCameraMatrix() const { vnl_matrix_fixed mat; mat.set_identity(); { itk::MutexLockHolder lock(*m_Mutex); mat(0,0) = m_CameraMatrix.at(0,0); mat(1,1) = m_CameraMatrix.at(1,1); mat(0,2) = m_CameraMatrix.at(0,2); mat(1,2) = m_CameraMatrix.at(1,2); } return mat; } void mitk::CameraIntrinsics::SetCameraMatrix( const vnl_matrix_fixed& _CameraMatrix ) { itk::MutexLockHolder lock(*m_Mutex); m_CameraMatrix.at(0,0) = _CameraMatrix(0,0); m_CameraMatrix.at(1,1) = _CameraMatrix(1,1); m_CameraMatrix.at(0,2) = _CameraMatrix(0,2); m_CameraMatrix.at(1,2) = _CameraMatrix(1,2); } vnl_matrix_fixed mitk::CameraIntrinsics::GetVnlCameraMatrix3x4() const { vnl_matrix_fixed mat; mat.fill(0); mat.update( this->GetVnlCameraMatrix().as_matrix() ); return mat; } void mitk::CameraIntrinsics::SetIntrinsics( const cv::Mat& _CameraMatrix , const cv::Mat& _DistorsionCoeffs) { { itk::MutexLockHolder lock(*m_Mutex); if( _CameraMatrix.cols != 3 || _CameraMatrix.rows != 3) throw std::invalid_argument("Wrong format of camera matrix. Should be 3x3" " double."); endoAssertMsg( (_DistorsionCoeffs.cols == 5) && _DistorsionCoeffs.rows == 1, "Wrong format of distorsion coefficients" " vector. Should be 5x1 double."); m_CameraMatrix = _CameraMatrix.clone(); m_DistorsionCoeffs = _DistorsionCoeffs.clone(); m_Valid = true; } this->Modified(); } void mitk::CameraIntrinsics::SetIntrinsics( const mitk::Point3D& focalPoint, const mitk::Point3D& principalPoint, const mitk::Point4D& distortionCoefficients) { { itk::MutexLockHolder lock(*m_Mutex); m_CameraMatrix.at(0,0) = focalPoint[0]; m_CameraMatrix.at(1,1) = focalPoint[1]; m_CameraMatrix.at(0,2) = principalPoint[0]; m_CameraMatrix.at(1,2) = principalPoint[1]; m_DistorsionCoeffs.at(0,0) = distortionCoefficients[0]; m_DistorsionCoeffs.at(0,1) = distortionCoefficients[1]; m_DistorsionCoeffs.at(0,2) = distortionCoefficients[2]; m_DistorsionCoeffs.at(0,3) = distortionCoefficients[3]; } this->Modified(); } void mitk::CameraIntrinsics::SetFocalLength( double x, double y ) { { itk::MutexLockHolder lock(*m_Mutex); m_CameraMatrix.at(0,0) = x; m_CameraMatrix.at(1,1) = y; } this->Modified(); } void mitk::CameraIntrinsics::SetPrincipalPoint( double x, double y ) { { itk::MutexLockHolder lock(*m_Mutex); m_CameraMatrix.at(0,2) = x; m_CameraMatrix.at(1,2) = y; } this->Modified(); } void mitk::CameraIntrinsics::SetDistorsionCoeffs( double k1, double k2, double p1, double p2 ) { { itk::MutexLockHolder lock(*m_Mutex); m_DistorsionCoeffs.at(0,0) = k1; m_DistorsionCoeffs.at(0,1) = k2; m_DistorsionCoeffs.at(0,2) = p1; m_DistorsionCoeffs.at(0,3) = p2; } this->Modified(); } cv::Mat mitk::CameraIntrinsics::GetCameraMatrix() const { itk::MutexLockHolder lock(*m_Mutex); return m_CameraMatrix.clone(); // return a copy of this small matrix } cv::Mat mitk::CameraIntrinsics::GetDistorsionCoeffs() const { itk::MutexLockHolder lock(*m_Mutex); return m_DistorsionCoeffs.clone(); // return a copy of this small matrix } cv::Mat mitk::CameraIntrinsics::GetDistorsionCoeffs() { const CameraIntrinsics* intrinsics = this; return intrinsics->GetDistorsionCoeffs(); } std::string mitk::CameraIntrinsics::ToString() const { itk::MutexLockHolder lock(*m_Mutex); std::ostringstream s; s.precision(12); const cv::Mat& CameraMatrix = m_CameraMatrix; const cv::Mat& DistorsionCoeffs = m_DistorsionCoeffs; s.str(""); s << this->GetNameOfClass() << ": "; s << "fx = " << CameraMatrix.at(0,0); s << ", fy = " << CameraMatrix.at(1,1); s << ", cx = " << CameraMatrix.at(0,2); s << ", cy = " << CameraMatrix.at(1,2); s << ", k1 = " << DistorsionCoeffs.at(0,0); s << ", k2 = " << DistorsionCoeffs.at(0,1); s << ", p1 = " << DistorsionCoeffs.at(0,2); s << ", p2 = " << DistorsionCoeffs.at(0,3); //s << ", k3 = " << DistorsionCoeffs.at(0,4); return s.str(); } void mitk::CameraIntrinsics::ToXML(TiXmlElement* elem) const { itk::MutexLockHolder lock(*m_Mutex); elem->SetValue(this->GetNameOfClass()); std::ostringstream s; s.precision(12); const cv::Mat& CameraMatrix = m_CameraMatrix; s.str(""); s << CameraMatrix.at(0,0); elem->SetAttribute( "fx", s.str() ); s.str(""); s << CameraMatrix.at(1,1); elem->SetAttribute( "fy", s.str() ); s.str(""); s << CameraMatrix.at(0,2); elem->SetAttribute( "cx", s.str() ); s.str(""); s << CameraMatrix.at(1,2); elem->SetAttribute( "cy", s.str() ); const cv::Mat& DistorsionCoeffs = m_DistorsionCoeffs; s.str(""); s << DistorsionCoeffs.at(0,0); elem->SetAttribute( "k1", s.str() ); s.str(""); s << DistorsionCoeffs.at(0,1); elem->SetAttribute( "k2", s.str() ); s.str(""); s << DistorsionCoeffs.at(0,2); elem->SetAttribute( "p1", s.str() ); s.str(""); s << DistorsionCoeffs.at(0,3); elem->SetAttribute( "p2", s.str() ); elem->SetAttribute("Valid", m_Valid); //s.str(""); s << DistorsionCoeffs.at(4,0); //elem->SetAttribute( "k3", s.str() ); } void mitk::CameraIntrinsics::FromGMLCalibrationXML(TiXmlElement* elem) { assert( elem ); assert( elem->ValueStr() == "results" ); cv::Mat CameraMatrix = cv::Mat::zeros(3, 3, cv::DataType::type); CameraMatrix.at(2,2) = 1.0; cv::Mat DistorsionCoeffs = cv::Mat::zeros(1, 5, cv::DataType::type); TiXmlElement* focus_lenXElem = elem->FirstChildElement("focus_lenX"); endoAssert( focus_lenXElem != 0 ); CameraMatrix.at(0,0) = atof( focus_lenXElem->GetText() ); TiXmlElement* focus_lenYElem = elem->FirstChildElement("focus_lenY"); endoAssert( focus_lenYElem != 0 ); CameraMatrix.at(1,1) = atof( focus_lenYElem->GetText() ); TiXmlElement* PrincipalXElem = elem->FirstChildElement("PrincipalX"); endoAssert( PrincipalXElem != 0 ); CameraMatrix.at(0,2) = atof( PrincipalXElem->GetText() ); TiXmlElement* PrincipalYElem = elem->FirstChildElement("PrincipalY"); endoAssert( PrincipalYElem != 0 ); CameraMatrix.at(1,2) = atof( PrincipalYElem->GetText() ); // DISTORSION COEFFS TiXmlElement* Dist1Elem = elem->FirstChildElement("Dist1"); endoAssert( Dist1Elem != 0 ); DistorsionCoeffs.at(0,0) = atof( Dist1Elem->GetText() ); TiXmlElement* Dist2Elem = elem->FirstChildElement("Dist2"); endoAssert( Dist2Elem != 0 ); DistorsionCoeffs.at(0,1) = atof( Dist2Elem->GetText() ); TiXmlElement* Dist3Elem = elem->FirstChildElement("Dist3"); endoAssert( Dist3Elem != 0 ); DistorsionCoeffs.at(0,2) = atof( Dist3Elem->GetText() ); TiXmlElement* Dist4Elem = elem->FirstChildElement("Dist4"); endoAssert( Dist4Elem != 0 ); DistorsionCoeffs.at(0,3) = atof( Dist4Elem->GetText() ); int valid = 0; elem->QueryIntAttribute("Valid", &valid); { itk::MutexLockHolder lock(*m_Mutex); m_Valid = static_cast(valid); m_CameraMatrix = CameraMatrix; m_DistorsionCoeffs = DistorsionCoeffs; } this->Modified(); } void mitk::CameraIntrinsics::FromXML(TiXmlElement* elem) { endoAssert ( elem ); MITK_DEBUG << elem->Value(); std::string filename; if(elem->QueryStringAttribute("file", &filename) == TIXML_SUCCESS) { this->FromXMLFile(filename); return; } else if(strcmp(elem->Value(), "CalibrationProject") == 0) { this->FromGMLCalibrationXML(elem->FirstChildElement("results")); return; } assert ( elem ); if(strcmp(elem->Value(), this->GetNameOfClass()) != 0) elem = elem->FirstChildElement(this->GetNameOfClass()); std::ostringstream err; // CAMERA MATRIX cv::Mat CameraMatrix = cv::Mat::zeros(3, 3, cv::DataType::type); CameraMatrix.at(2,2) = 1.0; double val = 0.0; if(elem->QueryDoubleAttribute("fx", &val) == TIXML_SUCCESS) CameraMatrix.at(0,0) = val; else err << "fx, "; if(elem->QueryDoubleAttribute("fy", &val) == TIXML_SUCCESS) CameraMatrix.at(1,1) = val; else err << "fy, "; if(elem->QueryDoubleAttribute("cx", &val) == TIXML_SUCCESS) CameraMatrix.at(0,2) = val; else err << "cx, "; if(elem->QueryDoubleAttribute("cy", &val) == TIXML_SUCCESS) CameraMatrix.at(1,2) = val; else err << "cy, "; // DISTORSION COEFFS endodebug( "creating DistorsionCoeffs from XML file") cv::Mat DistorsionCoeffs = cv::Mat::zeros(1, 5, cv::DataType::type); if(elem->QueryDoubleAttribute("k1", &val) == TIXML_SUCCESS) DistorsionCoeffs.at(0,0) = val; else err << "k1, "; if(elem->QueryDoubleAttribute("k2", &val) == TIXML_SUCCESS) DistorsionCoeffs.at(0,1) = val; else err << "k2, "; if(elem->QueryDoubleAttribute("p1", &val) == TIXML_SUCCESS) DistorsionCoeffs.at(0,2) = val; else err << "p1, "; if(elem->QueryDoubleAttribute("p2", &val) == TIXML_SUCCESS) DistorsionCoeffs.at(0,3) = val; else err << "p2, "; DistorsionCoeffs.at(0,4) = 0.0; /*if(elem->QueryDoubleAttribute("k3", &val) == TIXML_SUCCESS) DistorsionCoeffs.at(4,0) = val; else err << "k3, ";*/ std::string errorStr = err.str(); int errLength = errorStr.length(); if(errLength > 0) { errorStr = errorStr.substr(0, errLength-2); errorStr.append(" not found"); throw std::invalid_argument(err.str()); } int valid = 0; elem->QueryIntAttribute("Valid", &valid); { itk::MutexLockHolder lock(*m_Mutex); m_Valid = static_cast(valid); m_CameraMatrix = CameraMatrix; m_DistorsionCoeffs = DistorsionCoeffs; } this->Modified(); } double mitk::CameraIntrinsics::GetFocalLengthX() const { itk::MutexLockHolder lock(*m_Mutex); double FocalLengthX = m_CameraMatrix.at(0,0); return FocalLengthX; } double mitk::CameraIntrinsics::GetFocalLengthY() const { itk::MutexLockHolder lock(*m_Mutex); double FocalLengthY = m_CameraMatrix.at(1,1);; return FocalLengthY; } double mitk::CameraIntrinsics::GetPrincipalPointX() const { itk::MutexLockHolder lock(*m_Mutex); double PrincipalPointX = m_CameraMatrix.at(0,2); return PrincipalPointX; } double mitk::CameraIntrinsics::GetPrincipalPointY() const { itk::MutexLockHolder lock(*m_Mutex); double PrincipalPointY = m_CameraMatrix.at(1,2); return PrincipalPointY; } mitk::Point4D mitk::CameraIntrinsics::GetDistorsionCoeffsAsPoint4D() const { itk::MutexLockHolder lock(*m_Mutex); mitk::Point4D coeffs; coeffs[0] = m_DistorsionCoeffs.at(0,0); coeffs[1] = m_DistorsionCoeffs.at(0,1); coeffs[2] = m_DistorsionCoeffs.at(0,2); coeffs[3] = m_DistorsionCoeffs.at(0,3); return coeffs; } mitk::Point3D mitk::CameraIntrinsics::GetFocalPoint() const { mitk::Point3D p; p[0] = this->GetFocalLengthX(); p[1] = this->GetFocalLengthY(); p[2] = 0; return p; } mitk::Point3D mitk::CameraIntrinsics::GetPrincipalPoint() const { mitk::Point3D p; p[0] = this->GetPrincipalPointX(); p[1] = this->GetPrincipalPointY(); p[2] = 0; return p; } vnl_vector_fixed mitk::CameraIntrinsics::GetFocalPointAsVnlVector() const { vnl_vector_fixed vec; vec[0] = this->GetFocalLengthX(); vec[1] = this->GetFocalLengthY(); return vec; } vnl_vector_fixed mitk::CameraIntrinsics::GetPrincipalPointAsVnlVector() const { vnl_vector_fixed vec; vec[0] = this->GetPrincipalPointX(); vec[1] = this->GetPrincipalPointY(); return vec; } std::ostream& operator<< (std::ostream& os, mitk::CameraIntrinsics::Pointer p) { os << p->ToString(); return os; } std::string mitk::CameraIntrinsics::GetString() { return this->ToString(); } std::string mitk::CameraIntrinsics::ToOctaveString( const std::string& varName) { std::ostringstream s; s << varName << " = [" << this->GetFocalLengthX() << " 0 " << this->GetPrincipalPointX() << "; 0 " << this->GetFocalLengthY() << " " << this->GetPrincipalPointY() << ";" << " 0 0 1 ];"; return s.str(); } void mitk::CameraIntrinsics::SetValid( bool valid ) { itk::MutexLockHolder lock(*m_Mutex); m_Valid = valid; } itk::LightObject::Pointer mitk::CameraIntrinsics::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Modules/CameraCalibration/mitkCameraIntrinsicsProperty.cpp b/Modules/CameraCalibration/mitkCameraIntrinsicsProperty.cpp index eed4e54674..2bb04c0df3 100644 --- a/Modules/CameraCalibration/mitkCameraIntrinsicsProperty.cpp +++ b/Modules/CameraCalibration/mitkCameraIntrinsicsProperty.cpp @@ -1,62 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkCameraIntrinsicsProperty.h" namespace mitk { bool CameraIntrinsicsProperty::IsEqual(const BaseProperty& property) const { return this->m_Value->Equals(static_cast(property).m_Value.GetPointer()); } bool CameraIntrinsicsProperty::Assign(const BaseProperty& property) { this->m_Value = static_cast(property).m_Value; return true; } std::string CameraIntrinsicsProperty::GetValueAsString() const { std::stringstream myStr; myStr << GetValue(); return myStr.str(); } CameraIntrinsicsProperty::CameraIntrinsicsProperty() : BaseProperty() {} CameraIntrinsicsProperty::CameraIntrinsicsProperty(const CameraIntrinsicsProperty& other) : BaseProperty(other) { } CameraIntrinsicsProperty::CameraIntrinsicsProperty( mitk::CameraIntrinsics::Pointer value ) : BaseProperty(), m_Value( value ) {} itk::LightObject::Pointer CameraIntrinsicsProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } } // namespace mitk diff --git a/Modules/MitkExt/DataManagement/mitkGridRepresentationProperty.cpp b/Modules/MitkExt/DataManagement/mitkGridRepresentationProperty.cpp index e8215d37ea..f0d2fd99f7 100644 --- a/Modules/MitkExt/DataManagement/mitkGridRepresentationProperty.cpp +++ b/Modules/MitkExt/DataManagement/mitkGridRepresentationProperty.cpp @@ -1,103 +1,104 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "mitkGridRepresentationProperty.h" mitk::GridRepresentationProperty::GridRepresentationProperty( ) { AddRepresentationTypes(); SetValue( WIREFRAME ); } mitk::GridRepresentationProperty::GridRepresentationProperty(const mitk::GridRepresentationProperty& other) : mitk::EnumerationProperty(other) { } mitk::GridRepresentationProperty::GridRepresentationProperty( const IdType& value ) { AddRepresentationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetValue( WIREFRAME ); } } mitk::GridRepresentationProperty::GridRepresentationProperty( const std::string& value ) { AddRepresentationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetValue( WIREFRAME ); } } void mitk::GridRepresentationProperty::SetRepresentationToPoints() { SetValue( POINTS ); } void mitk::GridRepresentationProperty::SetRepresentationToWireframe() { SetValue( WIREFRAME ); } void mitk::GridRepresentationProperty::SetRepresentationToSurface() { SetValue( SURFACE ); } void mitk::GridRepresentationProperty::SetRepresentationToWireframeSurface() { //SetValue( WIREFRAME_SURFACE ); } void mitk::GridRepresentationProperty::AddRepresentationTypes() { AddEnum( "Points", POINTS ); AddEnum( "Wireframe", WIREFRAME ); AddEnum( "Surface", SURFACE ); //AddEnum( "WireframeSurface", WIREFRAME_SURFACE ); } bool mitk::GridRepresentationProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer mitk::GridRepresentationProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Modules/MitkExt/DataManagement/mitkGridVolumeMapperProperty.cpp b/Modules/MitkExt/DataManagement/mitkGridVolumeMapperProperty.cpp index 588ec4c20f..1b4a9573a9 100644 --- a/Modules/MitkExt/DataManagement/mitkGridVolumeMapperProperty.cpp +++ b/Modules/MitkExt/DataManagement/mitkGridVolumeMapperProperty.cpp @@ -1,91 +1,92 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "mitkGridVolumeMapperProperty.h" mitk::GridVolumeMapperProperty::GridVolumeMapperProperty( ) { AddRepresentationTypes(); SetValue( PT ); } mitk::GridVolumeMapperProperty::GridVolumeMapperProperty( const IdType& value ) { AddRepresentationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetValue( PT ); } } mitk::GridVolumeMapperProperty::GridVolumeMapperProperty( const std::string& value ) { AddRepresentationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetValue( PT ); } } void mitk::GridVolumeMapperProperty::SetVolumeMapperToPT() { SetValue( PT ); } void mitk::GridVolumeMapperProperty::SetVolumeMapperToZSweep() { SetValue( ZSWEEP ); } void mitk::GridVolumeMapperProperty::SetVolumeMapperToRayCast() { SetValue( RAYCAST ); } void mitk::GridVolumeMapperProperty::AddRepresentationTypes() { AddEnum( "Ray Cast", RAYCAST ); AddEnum( "Projected Tetrahedra", PT ); AddEnum( "ZSweep", ZSWEEP ); } bool mitk::GridVolumeMapperProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } itk::LightObject::Pointer mitk::GridVolumeMapperProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Modules/MitkExt/DataManagement/mitkLabeledImageLookupTable.cpp b/Modules/MitkExt/DataManagement/mitkLabeledImageLookupTable.cpp index 0fb3509445..7b2512127b 100644 --- a/Modules/MitkExt/DataManagement/mitkLabeledImageLookupTable.cpp +++ b/Modules/MitkExt/DataManagement/mitkLabeledImageLookupTable.cpp @@ -1,138 +1,139 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkLabeledImageLookupTable.h" #include #include /** * Default constructor. Protected to prevent "normal" creation */ mitk::LabeledImageLookupTable::LabeledImageLookupTable() : m_LevelWindow(128,256) { if ( m_LookupTable == NULL ) { itkWarningMacro("LookupTable is NULL, it should have been initialized by the default constructor of mitk::LookupTable"); m_LookupTable = vtkLookupTable::New(); } m_LookupTable->SetNumberOfTableValues(256); // set the background to black and fully transparent m_LookupTable->SetTableValue( 0, 0.0, 0.0, 0.0, 0.0 ); // initialize the remaining 255 colors with random values and // an alpha value of 1.0 double r, g, b; // // Initialize the random number generator with an arbitrary seed. // This way, the generated colors are random, but always the same... std::srand( 2 ); for ( vtkIdType index = 1 ; index < 256 ; ++index ) { GenerateRandomColor(r, g, b); m_LookupTable->SetTableValue(index, r, g, b); } // initialize the default level/window settings, // which can be accessed via GetLevelWindow(); m_LevelWindow.SetRangeMinMax(0,255); m_LevelWindow.SetWindowBounds(0,255); m_LevelWindow.SetFixed(true); } mitk::LabeledImageLookupTable::LabeledImageLookupTable(const mitk::LabeledImageLookupTable &other) : LookupTable(other) , m_LevelWindow(other.m_LevelWindow) { } /** * Virtual destructor */ mitk::LabeledImageLookupTable::~LabeledImageLookupTable() { } /** * Sets the color for a given label * @param label The pixel value used as a label in the image * @param r The red component of the rgba color value. Values sould be given in the range [0,1] * @param g The green component of the rgba color value. Values sould be given in the range [0,1] * @param b The blue component of the rgba color value. Values sould be given in the range [0,1] * @param a The alpha component of the rgba color value. Values sould be given in the range [0,1]. Default is 1. */ void mitk::LabeledImageLookupTable::SetColorForLabel ( const mitk::LabeledImageLookupTable::LabelType& label, const double& r, const double& g, const double& b, const double a ) { if ( m_LookupTable == NULL ) { itkWarningMacro("LookupTable is NULL, but it should have been initialized by the constructor"); return; } m_LookupTable->SetTableValue(label, r, g, b, a); } /** * Determines the color which will be used for coloring a given label. * @param label the label for which the color should be returned * @returns an rgba array containing the color information for the given label * Color components are expressed as [0,1] double values. */ double* mitk::LabeledImageLookupTable::GetColorForLabel ( const mitk::LabeledImageLookupTable::LabelType& label ) { if ( m_LookupTable == NULL ) { itkWarningMacro("LookupTable is NULL, but it should have been initialized by the constructor"); return NULL; } return m_LookupTable->GetTableValue( label ); } /** * Generates a random rgb color value. Values for rgb are in the range * [0,1] */ void mitk::LabeledImageLookupTable::GenerateRandomColor ( double& r, double& g, double& b ) { r = GenerateRandomNumber(); g = GenerateRandomNumber(); b = GenerateRandomNumber(); } /** * Generates a radnom number drawn from a uniform * distribution in the range [0,1]. */ double mitk::LabeledImageLookupTable::GenerateRandomNumber() { return ( ( ( double ) ( std::rand( ) ) ) / ( ( double ) ( RAND_MAX ) ) ); } itk::LightObject::Pointer mitk::LabeledImageLookupTable::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Modules/MitkExt/DataManagement/mitkOrganTypeProperty.cpp b/Modules/MitkExt/DataManagement/mitkOrganTypeProperty.cpp index 2fa7041f0e..9f0757beff 100644 --- a/Modules/MitkExt/DataManagement/mitkOrganTypeProperty.cpp +++ b/Modules/MitkExt/DataManagement/mitkOrganTypeProperty.cpp @@ -1,121 +1,122 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkOrganTypeProperty.h" mitk::OrganTypeProperty::OrganTypeProperty() { AddEnumerationTypes(); } mitk::OrganTypeProperty::OrganTypeProperty( const IdType& value ) { AddEnumerationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ) ; } else { SetValue( 0 ); } } mitk::OrganTypeProperty::OrganTypeProperty( const std::string& value ) { AddEnumerationTypes(); if ( IsValidEnumerationValue( value ) ) { SetValue( value ); } else { SetValue( "undefined" ); } } mitk::OrganTypeProperty::~OrganTypeProperty() { } void mitk::OrganTypeProperty::AddEnumerationTypes() { IdType newId = static_cast(EnumerationProperty::Size()); // On changes, please also change mitk::DataNodeFactory::DefaultColorForOrgan() AddEnum( "undefined", newId++ ); AddEnum( "Ankle", newId++ ); AddEnum( "Appendix", newId++ ); AddEnum( "Blood vessels", newId++ ); AddEnum( "Bone", newId++ ); AddEnum( "Brain", newId++ ); AddEnum( "Bronchial tree", newId++ ); AddEnum( "Coccyx", newId++ ); AddEnum( "Colon", newId++ ); AddEnum( "Cyst", newId++ ); AddEnum( "Elbow", newId++ ); AddEnum( "Eye", newId++ ); AddEnum( "Fallopian tube", newId++ ); AddEnum( "Fat", newId++ ); AddEnum( "Gall bladder", newId++ ); AddEnum( "Hand", newId++ ); AddEnum( "Heart", newId++ ); AddEnum( "Hip", newId++ ); AddEnum( "Hippocampus", newId++ ); AddEnum( "Kidney", newId++ ); AddEnum( "Knee", newId++ ); AddEnum( "Larynx", newId++ ); AddEnum( "Liver", newId++ ); AddEnum( "Lung", newId++ ); AddEnum( "Lymph node", newId++ ); AddEnum( "Muscle", newId++ ); AddEnum( "Nerve", newId++ ); AddEnum( "Nose", newId++ ); AddEnum( "Oesophagus", newId++ ); AddEnum( "Ovaries", newId++ ); AddEnum( "Pancreas", newId++ ); AddEnum( "Pelvis", newId++ ); AddEnum( "Penis", newId++ ); AddEnum( "Pharynx", newId++ ); AddEnum( "Prostate", newId++ ); AddEnum( "Rectum", newId++ ); AddEnum( "Sacrum", newId++ ); AddEnum( "Seminal vesicle", newId++ ); AddEnum( "Shoulder", newId++ ); AddEnum( "Spinal cord", newId++ ); AddEnum( "Spleen", newId++ ); AddEnum( "Stomach", newId++ ); AddEnum( "Teeth", newId++ ); AddEnum( "Testicles", newId++ ); AddEnum( "Thyroid", newId++ ); AddEnum( "Tongue", newId++ ); AddEnum( "Tumor", newId++ ); AddEnum( "Urethra", newId++ ); AddEnum( "Urinary bladder", newId++ ); AddEnum( "Uterus", newId++ ); AddEnum( "Vagina", newId++ ); AddEnum( "Vertebra", newId++ ); AddEnum( "Wrist", newId++ ); } itk::LightObject::Pointer mitk::OrganTypeProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; } diff --git a/Modules/PlanarFigure/DataManagement/mitkPlanarFigureControlPointStyleProperty.cpp b/Modules/PlanarFigure/DataManagement/mitkPlanarFigureControlPointStyleProperty.cpp index 1074cbc4ee..13bb204df5 100644 --- a/Modules/PlanarFigure/DataManagement/mitkPlanarFigureControlPointStyleProperty.cpp +++ b/Modules/PlanarFigure/DataManagement/mitkPlanarFigureControlPointStyleProperty.cpp @@ -1,79 +1,80 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPlanarFigureControlPointStyleProperty.h" mitk::PlanarFigureControlPointStyleProperty::PlanarFigureControlPointStyleProperty( ) { this->AddEnumTypes(); this->SetValue( static_cast ( Square ) ); } mitk::PlanarFigureControlPointStyleProperty::PlanarFigureControlPointStyleProperty( const IdType &value ) { this->AddEnumTypes(); if ( this->IsValidEnumerationValue( value ) ) { this->SetValue( value ) ; } else { this->SetValue( static_cast ( Square ) ); } } mitk::PlanarFigureControlPointStyleProperty::PlanarFigureControlPointStyleProperty( const std::string &value ) { this->AddEnumTypes(); if ( this->IsValidEnumerationValue( value ) ) { this->SetValue( value ); } else { this->SetValue( static_cast( Square ) ); } } void mitk::PlanarFigureControlPointStyleProperty::AddEnumTypes() { this->AddEnum( "Square", static_cast( Square ) ); this->AddEnum( "Circle", static_cast( Circle ) ); } bool mitk::PlanarFigureControlPointStyleProperty::AddEnum( const std::string& name, const IdType& id ) { return Superclass::AddEnum( name, id ); } mitk::PlanarFigureControlPointStyleProperty::Shape mitk::PlanarFigureControlPointStyleProperty::GetShape() { return static_cast( this->GetValueAsId() ); } void mitk::PlanarFigureControlPointStyleProperty::SetShape(mitk::PlanarFigureControlPointStyleProperty::Shape shape) { this->SetValue( static_cast( shape ) ); } itk::LightObject::Pointer mitk::PlanarFigureControlPointStyleProperty::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); + result->UnRegister(); return result; }