diff --git a/CMake/moduleExports.h.in b/CMake/moduleExports.h.in index 8e12255d76..457bd330fd 100644 --- a/CMake/moduleExports.h.in +++ b/CMake/moduleExports.h.in @@ -1,50 +1,50 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-19 21:14:21 +0200 (Di, 19 Mai 2009) $ Version: $Revision: 17326 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#include +#include "@MITK_SOURCE_DIR@/Core/Code/DataManagement/mitkExportMacros.h" #ifndef @MODULE_NAME@_EXPORTS_H #define @MODULE_NAME@_EXPORTS_H /** * provide a macro for adding compiler specific export/import declarations * to classes. * This is needed for the export of symbols, when you build a DLL. Then write * * class @MODULE_EXPORT_DEFINE@ ClassName : public SomeClass {}; */ #ifdef MITK_BUILD_STATIC #define @MODULE_EXPORT_DEFINE@ #define @MODULE_NAME@_LOCAL #else #ifdef @MODULE_PROVIDES@_EXPORTS #define @MODULE_EXPORT_DEFINE@ MITK_EXPORT #else #define @MODULE_EXPORT_DEFINE@ MITK_IMPORT #endif #define @MODULE_NAME@_LOCAL MITK_LOCAL #endif #ifndef _CMAKE_MODULENAME #ifdef @MODULE_PROVIDES@_EXPORTS #define _CMAKE_MODULENAME "@MODULE_NAME@" #endif #endif #endif diff --git a/Core/Code/Algorithms/mitkBaseProcess.h b/Core/Code/Algorithms/mitkBaseProcess.h index 951d6e11ab..b3586b5132 100644 --- a/Core/Code/Algorithms/mitkBaseProcess.h +++ b/Core/Code/Algorithms/mitkBaseProcess.h @@ -1,110 +1,111 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BASEPROCESS_H_HEADER_INCLUDED_C19BE6FC #define BASEPROCESS_H_HEADER_INCLUDED_C19BE6FC #if(_MSC_VER==1200) #include #endif #include +#include #include namespace mitk { class BaseData; //##Documentation //## @brief Superclass of all classes generating some kind of mitk::BaseData. //## //## Superclass of all classes generating some kind of mitk::BaseData. //## In itk and vtk the generated result of a ProcessObject is only guaranteed //## to be up-to-date, when Update() of the ProcessObject or the generated //## DataObject is called immediately before access of the data stored in the //## DataObject. This is also true for subclasses of mitk::BaseProcess. But //## many of the subclasses of mitk::BaseProcess define additional access //## functions to the generated output that guarantee an up-to-date result, see //## for example mitk::ImageSource. //## @ingroup Process class MITK_CORE_EXPORT BaseProcess : public itk::ProcessObject { public: mitkClassMacro(BaseProcess, itk::ProcessObject); //##Documentation //## @brief Access itk::ProcessObject::m_Updating //## //## m_Updating indicates when the pipeline is executing. //## It prevents infinite recursion when pipelines have loops. //## \sa itk::ProcessObject::m_Updating bool Updating() const { return m_Updating; } //##Documentation //## @brief Helps to deal with the weak-pointer-problem. virtual void UnRegister() const; //##Documentation //## @brief Helps to deal with the weak-pointer-problem. virtual int GetExternalReferenceCount() const; protected: BaseProcess(); virtual ~BaseProcess(); //##Documentation //## @brief Protected methods for setting outputs. //## //## Subclasses make use of them for getting output. //## These are only overwritten because of itk::DataObject::ConnectSource being //## private and non-virtual: the important stuff is done in //## mitk::BaseData::ConnectSource. virtual void SetNthOutput(unsigned int num, itk::DataObject *output); //##Documentation //## @brief Protected methods for setting outputs. //## //## Subclasses make use of them for getting output. //## These are only overwritten because of itk::DataObject::ConnectSource being //## private and non-virtual: the important stuff is done in //## mitk::BaseData::ConnectSource. virtual void AddOutput(itk::DataObject *output); private: //##Documentation //## @brief Helps to deal with the weak-pointer-problem. mutable bool m_Unregistering; //##Documentation //## @brief Helps to deal with the weak-pointer-problem. mutable bool m_CalculatingExternalReferenceCount; //##Documentation //## @brief Helps to deal with the weak-pointer-problem. mutable int m_ExternalReferenceCount; }; } // namespace mitk #endif /* BASEPROCESS_H_HEADER_INCLUDED_C19BE6FC */ diff --git a/Core/Code/Algorithms/mitkUIDGenerator.cpp b/Core/Code/Algorithms/mitkUIDGenerator.cpp index 717cc28dde..4d5be7d6bd 100644 --- a/Core/Code/Algorithms/mitkUIDGenerator.cpp +++ b/Core/Code/Algorithms/mitkUIDGenerator.cpp @@ -1,81 +1,84 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include +#include + #include +#include #include #include #include #include namespace mitk { UIDGenerator::UIDGenerator(const char* prefix, unsigned int lengthOfRandomPart) :m_Prefix(prefix), m_LengthOfRandomPart(lengthOfRandomPart) { if (lengthOfRandomPart < 5) { MITK_ERROR << lengthOfRandomPart << " are not really unique, right?" << std::endl; throw std::invalid_argument("To few digits requested"); } - srand((unsigned int) time( (time_t *)0 )); + std::srand((unsigned int) time( (time_t *)0 )); } std::string UIDGenerator::GetUID() { std::ostringstream s; s << m_Prefix; time_t tt = time(0); tm* t = gmtime(&tt); if (t) { s << t->tm_year + 1900; if (t->tm_mon < 9) s << "0"; // add a 0 for months 1 to 9 s << t->tm_mon + 1; if (t->tm_mday < 10) s << "0"; // add a 0 for days 1 to 9 s << t->tm_mday; if (t->tm_hour < 10) s << "0"; // add a 0 for hours 1 to 9 s << t->tm_hour; if (t->tm_min < 10) s << "0"; // add a 0 for minutes 1 to 9 s << t->tm_min; if (t->tm_sec < 10) s << "0"; // add a 0 for seconds 1 to 9 s << t->tm_sec; std::ostringstream rs; rs << (long int)( pow(10.0, double(m_LengthOfRandomPart)) / double(RAND_MAX) * double(rand()) ); for (size_t i = rs.str().length(); i < m_LengthOfRandomPart; ++i) { s << "X"; } s << rs.str(); } return s.str(); } } diff --git a/Core/Code/Controllers/mitkCallbackFromGUIThread.cpp b/Core/Code/Controllers/mitkCallbackFromGUIThread.cpp index b693f069ac..84d1900946 100644 --- a/Core/Code/Controllers/mitkCallbackFromGUIThread.cpp +++ b/Core/Code/Controllers/mitkCallbackFromGUIThread.cpp @@ -1,57 +1,58 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkCallbackFromGUIThread.h" +#include mitk::CallbackFromGUIThread* mitk::CallbackFromGUIThread::m_Instance = NULL; mitk::CallbackFromGUIThreadImplementation* mitk::CallbackFromGUIThread::m_Implementation = NULL; namespace mitk { CallbackFromGUIThread::CallbackFromGUIThread() { } CallbackFromGUIThread* CallbackFromGUIThread::GetInstance() { if (!m_Instance) { m_Instance = new CallbackFromGUIThread(); } return m_Instance; } void CallbackFromGUIThread::RegisterImplementation(CallbackFromGUIThreadImplementation* implementation) { m_Implementation = implementation; } void CallbackFromGUIThread::CallThisFromGUIThread(itk::Command* cmd, itk::EventObject* e) { if (m_Implementation) { m_Implementation->CallThisFromGUIThread(cmd, e); } else { MITK_ERROR << "in mitk::CallbackFromGUIThread::CallbackFromGUIThread(): no implementation registered." << std::endl; } } } // namespace diff --git a/Core/Code/Controllers/mitkStepper.h b/Core/Code/Controllers/mitkStepper.h index 8daebbeb23..f9ec3c2734 100644 --- a/Core/Code/Controllers/mitkStepper.h +++ b/Core/Code/Controllers/mitkStepper.h @@ -1,151 +1,152 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef STEPPER_H_HEADER_INCLUDED_C1E77191 #define STEPPER_H_HEADER_INCLUDED_C1E77191 #include +#include #include "mitkVector.h" #include #include #include namespace mitk { /** * \brief Helper class to step through a list * * A helper class to step through a list. Does not contain the list, just the * position in the list (between 0 and GetSteps()). Provides methods like * First (go to the first element), Next (go to the next one), etc. * * Besides the actual number of steps, the stepper can also hold a stepping * range, indicating the scalar values corresponding to the covered steps. * For example, steppers are generally used to slice a dataset with a plane; * Hereby, Steps indicates the total number of steps (positions) available for * the plane, Pos indicates the current step, and Range indicates the physical * minimum and maximum values for the plane, in this case a value in mm. * * The range can also be supplied with a unit name (a string) which can be * used by classes providing information about the stepping (e.g. graphical * sliders). * * \ingroup NavigationControl */ class MITK_CORE_EXPORT Stepper : public itk::Object { public: mitkClassMacro(Stepper, itk::Object); itkNewMacro(Self); itkGetMacro(Pos, unsigned int); virtual void SetPos(unsigned int pos) { // copied from itkMacro.h, itkSetClampMacro(...) unsigned int newPos; if ( m_Steps != 0 ) { newPos = (pos > m_Steps-1 ? m_Steps-1 : pos); } else { newPos = 0; } if (this->m_Pos != newPos ) { this->m_Pos = newPos ; this->Modified(); } } itkGetMacro(Steps, unsigned int); itkSetMacro(Steps, unsigned int); itkGetMacro(AutoRepeat, bool); itkSetMacro(AutoRepeat, bool); itkBooleanMacro(AutoRepeat); /** Causes the stepper to shift direction when the boundary is reached */ itkSetMacro(PingPong, bool); itkGetMacro(PingPong, bool); itkBooleanMacro(PingPong); /** If set to true, the Next() decreases the stepper and Previous() * decreases it */ itkSetMacro(InverseDirection, bool); itkGetMacro(InverseDirection, bool); itkBooleanMacro(InverseDirection); void SetRange( ScalarType min, ScalarType max ); void InvalidateRange(); ScalarType GetRangeMin() const; ScalarType GetRangeMax() const; bool HasValidRange() const; void RemoveRange(); bool HasRange() const; void SetUnitName( const char *unitName ); const char *GetUnitName() const; void RemoveUnitName(); bool HasUnitName() const; virtual void Next(); virtual void Previous(); virtual void First(); virtual void Last(); protected: Stepper(); virtual ~Stepper(); void Increase(); void Decrease(); unsigned int m_Pos; unsigned int m_Steps; bool m_AutoRepeat; bool m_PingPong; bool m_InverseDirection; ScalarType m_RangeMin; ScalarType m_RangeMax; bool m_RangeValid; bool m_HasRange; std::string m_UnitName; bool m_HasUnitName; }; } // namespace mitk #endif /* STEPPER_H_HEADER_INCLUDED_C1E77191 */ diff --git a/Core/Code/Controllers/mitkUndoModel.h b/Core/Code/Controllers/mitkUndoModel.h index 3f1fd92817..692e465ba1 100644 --- a/Core/Code/Controllers/mitkUndoModel.h +++ b/Core/Code/Controllers/mitkUndoModel.h @@ -1,92 +1,93 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef UNDOMODEL_H_HEADER_INCLUDED_C16ED098 #define UNDOMODEL_H_HEADER_INCLUDED_C16ED098 +#include "mitkCommon.h" #include "mitkOperation.h" #include #include namespace mitk { class UndoStackItem; class OperationEvent; class OperationActor; //##Documentation //## @brief superclass for all UndoModels //## //## all necessary operations, that all UndoModels share. //## @ingroup Undo class MITK_CORE_EXPORT UndoModel : public itk::Object { public: mitkClassMacro(UndoModel, itk::Object); // no New Macro because this is an abstract class! virtual bool SetOperationEvent(UndoStackItem* stackItem) = 0; virtual bool Undo() = 0; virtual bool Undo(bool fine) = 0; virtual bool Redo() = 0; virtual bool Redo(bool fine) = 0; //##Documentation //## @brief clears undo and Redolist virtual void Clear() = 0; //##Documentation //## @brief clears the RedoList virtual void ClearRedoList() = 0; //##Documentation //## @brief true if RedoList is empty virtual bool RedoListEmpty() = 0; //##Documentation //## @brief returns the ObjectEventId of the //## top Element in the OperationHistory of the selected //## UndoModel virtual int GetLastObjectEventIdInList() = 0; //##Documentation //## @brief returns the GroupEventId of the //## top Element in the OperationHistory of the selected //## UndoModel virtual int GetLastGroupEventIdInList() = 0; //##Documentation //## @brief returns the last specified OperationEvent in Undo-list //## corresponding to the given values; if nothing found, then returns NULL //## //## needed to get the old Position of an Element for declaring an UndoOperation virtual OperationEvent* GetLastOfType(OperationActor* destination, OperationType opType) = 0; protected: UndoModel(){}; virtual ~UndoModel(){}; }; }// namespace mitk #endif /* UNDOMODEL_H_HEADER_INCLUDED_C16ED098 */ diff --git a/Core/Code/DataManagement/mitkApplicationCursor.cpp b/Core/Code/DataManagement/mitkApplicationCursor.cpp index 5ec37f8f54..5a7d2d85f8 100644 --- a/Core/Code/DataManagement/mitkApplicationCursor.cpp +++ b/Core/Code/DataManagement/mitkApplicationCursor.cpp @@ -1,99 +1,100 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkApplicationCursor.h" +#include #include mitk::ApplicationCursorImplementation* mitk::ApplicationCursor::m_Implementation = NULL; namespace mitk { ApplicationCursor::ApplicationCursor() { } ApplicationCursor* ApplicationCursor::GetInstance() { static ApplicationCursor* m_Instance = NULL; if (!m_Instance) { m_Instance = new ApplicationCursor(); } return m_Instance; } void ApplicationCursor::RegisterImplementation(ApplicationCursorImplementation* implementation) { m_Implementation = implementation; } void ApplicationCursor::PushCursor(const char* XPM[], int hotspotX, int hotspotY) { if (m_Implementation) { m_Implementation->PushCursor(XPM, hotspotX, hotspotY); } else { MITK_ERROR << "in mitk::ApplicationCursor::PushCursor(): no implementation registered." << std::endl; throw std::logic_error("No implementation registered for mitk::ApplicationCursor."); } } void ApplicationCursor::PopCursor() { if (m_Implementation) { m_Implementation->PopCursor(); } else { MITK_ERROR << "in mitk::ApplicationCursor::PopCursor(): no implementation registered." << std::endl; throw std::logic_error("No implementation registered for mitk::ApplicationCursor."); } } const Point2I ApplicationCursor::GetCursorPosition() { if (m_Implementation) { return m_Implementation->GetCursorPosition(); } else { MITK_ERROR << "in mitk::ApplicationCursor::GetCursorPosition(): no implementation registered." << std::endl; throw std::logic_error("No implementation registered for mitk::ApplicationCursor."); } } void ApplicationCursor::SetCursorPosition(const Point2I& p) { if (m_Implementation) { m_Implementation->SetCursorPosition(p); } else { MITK_ERROR << "in mitk::ApplicationCursor::SetCursorPosition(): no implementation registered." << std::endl; throw std::logic_error("No implementation registered for mitk::ApplicationCursor."); } } } // namespace diff --git a/Core/Code/DataManagement/mitkBaseProperty.h b/Core/Code/DataManagement/mitkBaseProperty.h index 598a29ec72..5bd4622248 100644 --- a/Core/Code/DataManagement/mitkBaseProperty.h +++ b/Core/Code/DataManagement/mitkBaseProperty.h @@ -1,73 +1,74 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BASEPROPERTY_H_HEADER_INCLUDED_C1F4DF54 #define BASEPROPERTY_H_HEADER_INCLUDED_C1F4DF54 #include #include #include +#include namespace mitk { /*! \brief Abstract base class for properties \ingroup DataManagement Base class for properties. Properties are arbitrary additional information (to define a new type of information you have to define a subclass of BaseProperty) that can be added to a PropertyList. Concrete subclasses of BaseProperty should define Set-/Get-methods to assess the property value, which should be stored by value (not by reference). Subclasses must implement an operator==(const BaseProperty& property), which is used by PropertyList to check whether a property has been changed. */ class MITK_CORE_EXPORT BaseProperty : public itk::Object { public: mitkClassMacro(BaseProperty,itk::Object); /*! @brief Subclasses must implement this operator==. Operator== which is used by PropertyList to check whether a property has been changed. */ virtual bool operator==(const BaseProperty& property) const = 0; virtual BaseProperty& operator=(const BaseProperty& property); virtual std::string GetValueAsString() const; virtual bool Assignable(const BaseProperty& ) const; protected: BaseProperty(); virtual ~BaseProperty(); friend class PropertyList; // for VALUE static std::string VALUE; }; } // namespace mitk #endif /* BASEPROPERTY_H_HEADER_INCLUDED_C1F4DF54 */ diff --git a/Core/Code/DataManagement/mitkCommon.h b/Core/Code/DataManagement/mitkCommon.h index cc9b00d995..fa0d9ef3c8 100644 --- a/Core/Code/DataManagement/mitkCommon.h +++ b/Core/Code/DataManagement/mitkCommon.h @@ -1,126 +1,107 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITK_COMMON_H_DEFINED #define MITK_COMMON_H_DEFINED #ifdef _MSC_VER // This warns about truncation to 255 characters in debug/browse info #pragma warning (disable : 4786) #pragma warning (disable : 4068 ) /* disable unknown pragma warnings */ #endif //add only those headers here that are really necessary for all classes! #include "itkObject.h" #include "mitkConfig.h" #include "mitkLogMacros.h" #ifndef MITK_UNMANGLE_IPPIC #define mitkIpPicDescriptor mitkIpPicDescriptor #endif typedef unsigned int MapperSlotId; #define mitkClassMacro(className,SuperClassName) \ typedef className Self; \ typedef SuperClassName Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ itkTypeMacro(className,SuperClassName) /** * Macro for Constructors with one parameter for classes derived from itk::Lightobject **/ #define mitkNewMacro1Param(classname,type) \ static Pointer New(type _arg) \ { \ Pointer smartPtr = new classname ( _arg ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** * Macro for Constructors with two parameters for classes derived from itk::Lightobject **/ #define mitkNewMacro2Param(classname,typea,typeb) \ static Pointer New(typea _arga, typeb _argb) \ { \ Pointer smartPtr = new classname ( _arga, _argb ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** * Macro for Constructors with three parameters for classes derived from itk::Lightobject **/ #define mitkNewMacro3Param(classname,typea,typeb,typec) \ static Pointer New(typea _arga, typeb _argb, typec _argc) \ { \ Pointer smartPtr = new classname ( _arga, _argb, _argc ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** * Macro for Constructors with three parameters for classes derived from itk::Lightobject **/ #define mitkNewMacro4Param(classname,typea,typeb,typec,typed) \ static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd) \ { \ Pointer smartPtr = new classname ( _arga, _argb, _argc, _argd ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** Get a smart const pointer to an object. Creates the member * Get"name"() (e.g., GetPoints()). */ #define mitkGetObjectMacroConst(name,type) \ virtual type * Get##name () const \ { \ itkDebugMacro("returning " #name " address " << this->m_##name ); \ return this->m_##name.GetPointer(); \ } /** Creates a Clone() method for "Classname". Returns a smartPtr of a clone of the calling object*/ #define mitkCloneMacro(classname) \ virtual Pointer Clone() const \ { \ Pointer smartPtr = new classname(*this); \ return smartPtr; \ } -/** - * Macros for import/export declarations - */ -#if defined(WIN32) - #define MITK_EXPORT __declspec(dllexport) - #define MITK_IMPORT __declspec(dllimport) - #define MITK_LOCAL -#else - #if __GNUC__ >= 4 - #define MITK_EXPORT __attribute__ ((visibility ("default"))) - #define MITK_IMPORT __attribute__ ((visibility ("default"))) - #define MITK_LOCAL __attribute__ ((visibility ("hidden"))) - #else - #define MITK_EXPORT - #define MITK_IMPORT - #define MITK_LOCAL - #endif -#endif - #endif // MITK_COMMON_H_DEFINED diff --git a/Core/Code/DataManagement/mitkExportMacros.h b/Core/Code/DataManagement/mitkExportMacros.h new file mode 100644 index 0000000000..4362165767 --- /dev/null +++ b/Core/Code/DataManagement/mitkExportMacros.h @@ -0,0 +1,41 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKEXPORTMACROS_H +#define MITKEXPORTMACROS_H + +/** + * Macros for import/export declarations + */ +#if defined(WIN32) + #define MITK_EXPORT __declspec(dllexport) + #define MITK_IMPORT __declspec(dllimport) + #define MITK_LOCAL +#else + #if __GNUC__ >= 4 + #define MITK_EXPORT __attribute__ ((visibility ("default"))) + #define MITK_IMPORT __attribute__ ((visibility ("default"))) + #define MITK_LOCAL __attribute__ ((visibility ("hidden"))) + #else + #define MITK_EXPORT + #define MITK_IMPORT + #define MITK_LOCAL + #endif +#endif + +#endif // MITKEXPORTMACROS_H diff --git a/Core/Code/DataManagement/mitkGeometry3D.h b/Core/Code/DataManagement/mitkGeometry3D.h index 9c846f4d48..46528d5ff1 100644 --- a/Core/Code/DataManagement/mitkGeometry3D.h +++ b/Core/Code/DataManagement/mitkGeometry3D.h @@ -1,662 +1,663 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef GEOMETRY3D_H_HEADER_INCLUDED_C1EBD0AD #define GEOMETRY3D_H_HEADER_INCLUDED_C1EBD0AD #include +#include #include "mitkVector.h" #include "mitkOperationActor.h" #include #include #include #include class vtkLinearTransform; class vtkMatrixToLinearTransform; class vtkMatrix4x4; namespace mitk { //##Documentation //## @brief Standard 3D-BoundingBox typedef //## //## Standard 3D-BoundingBox typedef to get rid of template arguments (3D, type). typedef itk::BoundingBox BoundingBox; //##Documentation //## @brief Standard typedef for time-bounds typedef itk::FixedArray TimeBounds; typedef itk::FixedArray FixedArrayType; typedef itk::AffineGeometryFrame AffineGeometryFrame3D; //##Documentation //## @brief Describes the geometry of a data object //## //## At least, it can return the bounding box of the data object. //## //## The class holds //## \li a bounding box which is axes-parallel in intrinsic coordinates //## (often integer indices of pixels), to be accessed by //## GetBoundingBox() //## \li a transform to convert intrinsic coordinates into a //## world-coordinate system with coordinates in millimeters //## and milliseconds (all are floating point values), to //## be accessed by GetIndexToWorldTransform() //## \li a life span, i.e. a bounding box in time in ms (with //## start and end time), to be accessed by GetTimeBounds(). //## The default is minus infinity to plus infinity. //## //## Geometry3D and its sub-classes allow converting between //## intrinsic coordinates (called index or unit coordinates) //## and world-coordinates (called world or mm coordinates), //## e.g. WorldToIndex. //## In case you need integer index coordinates, provide an //## mitk::Index3D (or itk::Index) as target variable to //## WorldToIndex, otherwise you will get a continuous index //## (floating point values). //## //## An important sub-class is SlicedGeometry3D, which descibes //## data objects consisting of slices, e.g., objects of type Image. //## Conversions between world coordinates (in mm) and unit coordinates //## (e.g., pixels in the case of an Image) can be performed. //## //## For more information on related classes, see \ref Geometry. //## //## Geometry3D instances referring to an Image need a slightly //## different definition of corners, see SetImageGeometry. This //## is usualy automatically called by Image. //## //## Geometry3D have to be initialized in the method GenerateOutputInformation() //## of BaseProcess (or CopyInformation/ UpdateOutputInformation of BaseData, //## if possible, e.g., by analyzing pic tags in Image) subclasses. See also //## itk::ProcessObject::GenerateOutputInformation(), //## itk::DataObject::CopyInformation() and //## itk::DataObject::UpdateOutputInformation(). //## //## Rule: everything is in mm (ms) if not stated otherwise. //## @ingroup Geometry class MITK_CORE_EXPORT Geometry3D : public AffineGeometryFrame3D, public OperationActor { public: mitkClassMacro(Geometry3D, AffineGeometryFrame3D); typedef itk::QuaternionRigidTransform< ScalarType > QuaternionTransformType; typedef QuaternionTransformType::VnlQuaternionType VnlQuaternionType; /** Method for creation through the object factory. */ itkNewMacro(Self); // a bit of a misuse, but we want only doxygen to see the following: #ifdef DOXYGEN_SKIP //##Documentation //## @brief Get the transformation used to convert from index //## to world coordinates itkGetObjectMacro(IndexToWorldTransform, AffineTransform3D); #endif //## @brief Set the transformation used to convert from index //## to world coordinates virtual void SetIndexToWorldTransform(mitk::AffineTransform3D* transform); //##Documentation //## @brief Convenience method for setting the ITK transform //## (m_IndexToWorldTransform) via an vtkMatrix4x4 //## \sa SetIndexToWorldTransform virtual void SetIndexToWorldTransformByVtkMatrix(vtkMatrix4x4* vtkmatrix); #ifdef DOXYGEN_SKIP //##Documentation //## @brief Get bounding box (in index/unit coordinates) itkGetConstObjectMacro(BoundingBox, BoundingBoxType); //##Documentation //## @brief Get bounding box (in index/unit coordinates) as a BoundsArrayType const BoundsArrayType GetBounds() const { assert(m_BoundingBox.IsNotNull()); return m_BoundingBox->GetBounds(); } //##Documentation //## \brief Set the bounding box (in index/unit coordinates) //## //## Only possible via the BoundsArray to make clear that a //## copy of the bounding-box is stored, not a reference to it. virtual void SetBounds(const BoundsArrayType& bounds); #endif //##Documentation //## @brief Set the bounding box (in index/unit coordinates) via a float array virtual void SetFloatBounds(const float bounds[6]); //##Documentation //## @brief Set the bounding box (in index/unit coordinates) via a double array virtual void SetFloatBounds(const double bounds[6]); //##Documentation //## @brief When switching from an Image Geometry to a normal Geometry (and the other way around), you have to change the origin as well (See Geometry Documentation)! This function will change the "isImageGeometry" bool flag and changes the origin respectively. virtual void ChangeImageGeometryConsideringOriginOffset( const bool isAnImageGeometry ); //##Documentation //## @brief Get the time bounds (in ms) itkGetConstReferenceMacro(TimeBounds, TimeBounds); //##Documentation //## @brief Set the time bounds (in ms) virtual void SetTimeBounds(const TimeBounds& timebounds); //##Documentation //## @brief Get the position of the corner number \a id (in world coordinates) //## //## See SetImageGeometry for how a corner is defined on images. Point3D GetCornerPoint(int id) const; //##Documentation //## @brief Get the position of a corner (in world coordinates) //## //## See SetImageGeometry for how a corner is defined on images. Point3D GetCornerPoint(bool xFront=true, bool yFront=true, bool zFront=true) const; //##Documentation //## @brief Get vector along bounding-box in the specified @a direction in mm //## //## The length of the vector is the size of the bounding-box in the //## specified @a direction in mm //## \sa GetMatrixColumn Vector3D GetAxisVector(unsigned int direction) const { Vector3D frontToBack; frontToBack.Set_vnl_vector(m_IndexToWorldTransform->GetMatrix().GetVnlMatrix().get_column(direction)); frontToBack *= GetExtent(direction); return frontToBack; } //##Documentation //## @brief Get the center of the bounding-box in mm //## Point3D GetCenter() const { assert(m_BoundingBox.IsNotNull()); return m_IndexToWorldTransform->TransformPoint(m_BoundingBox->GetCenter()); } //##Documentation //## @brief Get the squared length of the diagonal of the bounding-box in mm //## double GetDiagonalLength2() const { Vector3D diagonalvector = GetCornerPoint()-GetCornerPoint(false, false, false); return diagonalvector.GetSquaredNorm(); } //##Documentation //## @brief Get the length of the diagonal of the bounding-box in mm //## double GetDiagonalLength() const { return sqrt(GetDiagonalLength2()); } //##Documentation //## @brief Get a VnlVector along bounding-box in the specified //## @a direction, length is spacing //## //## \sa GetAxisVector VnlVector GetMatrixColumn(unsigned int direction) const { return m_IndexToWorldTransform->GetMatrix().GetVnlMatrix().get_column(direction); } #ifdef DOXYGEN_SKIP //##Documentation //## @brief Get the extent of the bounding box (in index/unit coordinates) //## //## To access the extent in mm use GetExtentInMM ScalarType GetExtent(unsigned int direction) const; #endif //##Documentation //## @brief Get the extent of the bounding-box in the specified @a direction in mm //## //## Equals length of GetAxisVector(direction). ScalarType GetExtentInMM(int direction) const { return m_IndexToWorldTransform->GetMatrix().GetVnlMatrix().get_column(direction).magnitude()*GetExtent(direction); } //##Documentation //## @brief Set the extent of the bounding-box in the specified @a direction in mm //## //## @note This changes the matrix in the transform, @a not the bounds, which are given in units! virtual void SetExtentInMM(int direction, ScalarType extentInMM); //##Documentation //## @brief Get the m_IndexToWorldTransform as a vtkLinearTransform vtkLinearTransform* GetVtkTransform() const { return (vtkLinearTransform*)m_VtkIndexToWorldTransform; } //##Documentation //## @brief Set the origin, i.e. the upper-left corner of the plane //## virtual void SetOrigin(const Point3D& origin); //##Documentation //## @brief Translate the origin by a vector //## virtual void Translate(const Vector3D& vector); //##Documentation //## @brief Set the transform to identity //## virtual void SetIdentity(); //##Documentation //## @brief Compose new IndexToWorldTransform with a given transform. //## //## This method composes m_IndexToWorldTransform with another transform, //## modifying self to be the composition of self and other. //## If the argument pre is true, then other is precomposed with self; //## that is, the resulting transformation consists of first applying //## other to the source, followed by self. If pre is false or omitted, //## then other is post-composed with self; that is the resulting //## transformation consists of first applying self to the source, //## followed by other. virtual void Compose( const AffineGeometryFrame3D::TransformType * other, bool pre = 0 ); //##Documentation //## @brief Compose new IndexToWorldTransform with a given vtkMatrix4x4. //## //## Converts the vtkMatrix4x4 into a itk-transform and calls the previous method. virtual void Compose( const vtkMatrix4x4 * vtkmatrix, bool pre = 0 ); //##Documentation //## @brief Get the origin, e.g. the upper-left corner of the plane const Point3D& GetOrigin() const { return m_Origin; } //##Documentation //## @brief Get the origin as VnlVector //## //## \sa GetOrigin VnlVector GetOriginVnl() const { return const_cast(this)->m_Origin.Get_vnl_vector(); } //##Documentation //## @brief Convert world coordinates (in mm) of a \em point to (continuous!) index coordinates //## \warning If you need (discrete) integer index coordinates (e.g., for iterating easily over an image), //## use WorldToIndex(const mitk::Point3D& pt_mm, itk::Index &index). //## For further information about coordinates types, please see the Geometry documentation void WorldToIndex(const mitk::Point3D& pt_mm, mitk::Point3D& pt_units) const; //##Documentation //## @brief Convert (continuous or discrete) index coordinates of a \em point to world coordinates (in mm) //## For further information about coordinates types, please see the Geometry documentation void IndexToWorld(const mitk::Point3D& pt_units, mitk::Point3D& pt_mm) const; //##Documentation //## @brief Convert world coordinates (in mm) of a \em vector //## \a vec_mm to (continuous!) index coordinates. //## @deprecated First parameter (Point3D) is not used. If possible, please use void WorldToIndex(const mitk::Vector3D& vec_mm, mitk::Vector3D& vec_units) const. //## For further information about coordinates types, please see the Geometry documentation void WorldToIndex(const mitk::Point3D& atPt3d_mm, const mitk::Vector3D& vec_mm, mitk::Vector3D& vec_units) const; //##Documentation //## @brief Convert world coordinates (in mm) of a \em vector //## \a vec_mm to (continuous!) index coordinates. //## For further information about coordinates types, please see the Geometry documentation void WorldToIndex(const mitk::Vector3D& vec_mm, mitk::Vector3D& vec_units) const; //##Documentation //## @brief Convert (continuous or discrete) index coordinates of a \em vector //## \a vec_units to world coordinates (in mm) //## @deprecated First parameter (Point3D) is not used. If possible, please use void IndexToWorld(const mitk::Vector3D& vec_units, mitk::Vector3D& vec_mm) const. //## For further information about coordinates types, please see the Geometry documentation void IndexToWorld(const mitk::Point3D& atPt3d_units, const mitk::Vector3D& vec_units, mitk::Vector3D& vec_mm) const; //##Documentation //## @brief Convert (continuous or discrete) index coordinates of a \em vector //## \a vec_units to world coordinates (in mm) //## For further information about coordinates types, please see the Geometry documentation void IndexToWorld(const mitk::Vector3D& vec_units, mitk::Vector3D& vec_mm) const; //##Documentation //## @brief Convert world coordinates (in mm) of a \em point to (discrete!) index coordinates. //## This method rounds to integer indices! //## For further information about coordinates types, please see the Geometry documentation template void WorldToIndex(const mitk::Point3D& pt_mm, itk::Index &index) const { typedef itk::Index IndexType; mitk::Point3D pt_units; this->WorldToIndex(pt_mm, pt_units); int i, dim=index.GetIndexDimension(); if(dim>3) { index.Fill(0); dim=3; } for(i=0;i( pt_units[i] ); index[i]=itk::Math::RoundHalfIntegerUp( pt_units[i] ); } } //##Documentation //## @brief Deprecated for use with ITK version 3.10 or newer. //## Convert world coordinates (in mm) of a \em point to //## ITK physical coordinates (in mm, but without a possible rotation) //## //## This method is useful if you have want to access an mitk::Image //## via an itk::Image. ITK v3.8 and older did not support rotated (tilted) //## images, i.e., ITK images are always parallel to the coordinate axes. //## When accessing a (possibly rotated) mitk::Image via an itk::Image //## the rotational part of the transformation in the Geometry3D is //## simply discarded; in other word: only the origin and spacing is //## used by ITK, not the complete matrix available in MITK. //## With WorldToItkPhysicalPoint you can convert an MITK world //## coordinate (including the rotation) into a coordinate that //## can be used with the ITK image as a ITK physical coordinate //## (excluding the rotation). template void WorldToItkPhysicalPoint(const mitk::Point3D& pt_mm, itk::Point& itkPhysicalPoint) const { mitk::vtk2itk(pt_mm, itkPhysicalPoint); } //##Documentation //## @brief Deprecated for use with ITK version 3.10 or newer. //## Convert ITK physical coordinates of a \em point (in mm, //## but without a rotation) into MITK world coordinates (in mm) //## //## For more information, see WorldToItkPhysicalPoint. template void ItkPhysicalPointToWorld(const itk::Point& itkPhysicalPoint, mitk::Point3D& pt_mm) const { mitk::vtk2itk(itkPhysicalPoint, pt_mm); } //##Documentation //## @brief Initialize the Geometry3D virtual void Initialize(); //##Documentation //## @brief Is this an ImageGeometry? //## //## For more information, see SetImageGeometry itkGetConstMacro(ImageGeometry, bool); //##Documentation //## @brief Define that this Geometry3D is refering to an Image //## //## A geometry referring to an Image needs a slightly different //## definition of the position of the corners (see GetCornerPoint). //## The position of a voxel is defined by the position of its center. //## If we would use the origin (position of the (center of) the first //## voxel) as a corner and display this point, it would seem to be //## \em not at the corner but a bit within the image. Even worse for //## the opposite corner of the image: here the corner would appear //## outside the image (by half of the voxel diameter). Thus, we have //## to correct for this and to be able to do that, we need to know //## that the Geometry3D is referring to an Image. itkSetMacro(ImageGeometry, bool); itkBooleanMacro(ImageGeometry); //##Documentation //## @brief Is this Geometry3D in a state that is valid? virtual bool IsValid() const { return m_Valid; } //##Documentation //## @brief Test whether the point \a p (world coordinates in mm) is //## inside the bounding box bool IsInside(const mitk::Point3D& p) const { mitk::Point3D index; WorldToIndex(p, index); return IsIndexInside(index); } //##Documentation //## @brief Test whether the point \a p ((continous!)index coordinates in units) is //## inside the bounding box bool IsIndexInside(const mitk::Point3D& index) const { bool inside = false; //if it is an image geometry, we need to convert the index to discrete values //this is done by applying the rounding function also used in WorldToIndex (see line 323) if (m_ImageGeometry) { mitk::Point3D discretIndex; discretIndex[0]=itk::Math::RoundHalfIntegerUp( index[0] ); discretIndex[1]=itk::Math::RoundHalfIntegerUp( index[1] ); discretIndex[2]=itk::Math::RoundHalfIntegerUp( index[2] ); inside = m_BoundingBox->IsInside(discretIndex); //we have to check if the index is at the upper border of each dimension, // because the boundingbox is not centerbased if (inside) { const BoundingBox::BoundsArrayType& bounds = m_BoundingBox->GetBounds(); if((discretIndex[0] == bounds[1]) || (discretIndex[1] == bounds[3]) || (discretIndex[2] == bounds[5])) inside = false; } } else inside = m_BoundingBox->IsInside(index); return inside; } //##Documentation //## @brief Convenience method for working with ITK indices template bool IsIndexInside(const itk::Index &index) const { int i, dim=index.GetIndexDimension(); Point3D pt_index; pt_index.Fill(0); for ( i = 0; i < dim; ++i ) { pt_index[i] = index[i]; } return IsIndexInside(pt_index); } //##Documentation //## @brief Get the spacing (size of a pixel). //## itkGetConstReferenceMacro(Spacing, mitk::Vector3D); //##Documentation //## @brief Get the spacing as a float[3] array. const float* GetFloatSpacing() const; //##Documentation //## @brief Set the spacing (m_Spacing) virtual void SetSpacing(const mitk::Vector3D& aSpacing); //##Documentation //## @brief Get the DICOM FrameOfReferenceID referring to the //## used world coordinate system itkGetConstMacro(FrameOfReferenceID, unsigned int); //##Documentation //## @brief Set the DICOM FrameOfReferenceID referring to the //## used world coordinate system itkSetMacro(FrameOfReferenceID, unsigned int); //##Documentation //## @brief Copy the ITK transform //## (m_IndexToWorldTransform) to the VTK transform //## \sa SetIndexToWorldTransform void TransferItkToVtkTransform(); //##Documentation //## @brief Copy the VTK transform //## to the ITK transform (m_IndexToWorldTransform) //## \sa SetIndexToWorldTransform void TransferVtkToItkTransform(); //##Documentation //## @brief Get the parametric bounding-box //## //## See AbstractTransformGeometry for an example usage of this. itkGetConstObjectMacro(ParametricBoundingBox, BoundingBox); //##Documentation //## @brief Get the parametric bounds //## //## See AbstractTransformGeometry for an example usage of this. const BoundingBox::BoundsArrayType& GetParametricBounds() const { assert(m_ParametricBoundingBox.IsNotNull()); return m_ParametricBoundingBox->GetBounds(); } //##Documentation //## @brief Get the parametric extent //## //## See AbstractTransformGeometry for an example usage of this. mitk::ScalarType GetParametricExtent(int direction) const { assert(direction>=0 && direction<3); assert(m_ParametricBoundingBox.IsNotNull()); BoundingBoxType::BoundsArrayType bounds = m_ParametricBoundingBox->GetBounds(); return bounds[direction*2+1]-bounds[direction*2]; } //##Documentation //## @brief Get the parametric extent in mm //## //## See AbstractTransformGeometry for an example usage of this. virtual mitk::ScalarType GetParametricExtentInMM(int direction) const { return GetExtentInMM(direction); } //##Documentation //## @brief Get the parametric transform //## //## See AbstractTransformGeometry for an example usage of this. virtual const Transform3D* GetParametricTransform() const { return m_IndexToWorldTransform; } //##Documentation //## @brief Calculates a bounding-box around the geometry relative //## to a coordinate system defined by a transform //## mitk::BoundingBox::Pointer CalculateBoundingBoxRelativeToTransform(const mitk::AffineTransform3D* transform) const; //##Documentation //## @brief clones the geometry //## //## Overwrite in all sub-classes. //## Normally looks like: //## \code //## Self::Pointer newGeometry = new Self(*this); //## newGeometry->UnRegister(); //## return newGeometry.GetPointer(); //## \endcode virtual AffineGeometryFrame3D::Pointer Clone() const; //##Documentation //##@brief executes affine operations (translate, rotate, scale) virtual void ExecuteOperation(Operation* operation); protected: Geometry3D(); Geometry3D(const Geometry3D& other); static const char* GetTransformAsString( TransformType* transformType ); virtual ~Geometry3D(); virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; virtual void BackTransform(const mitk::Point3D& in, mitk::Point3D& out) const; //##Documentation //## @brief Deprecated virtual void BackTransform(const mitk::Point3D& at, const mitk::Vector3D& in, mitk::Vector3D& out) const; //Without redundant parameter Point3D virtual void BackTransform(const mitk::Vector3D& in, mitk::Vector3D& out) const; //##Documentation //## @brief Set the parametric bounds //## //## Protected in this class, made public in some sub-classes, e.g., //## ExternAbstractTransformGeometry. virtual void SetParametricBounds(const BoundingBox::BoundsArrayType& bounds); /** Resets sub-transforms that compose m_IndexToWorldTransform, by using * the current value of m_IndexToWorldTransform and setting the rotation * component to zero. */ virtual void ResetSubTransforms(); mutable mitk::BoundingBox::Pointer m_ParametricBoundingBox; mutable mitk::TimeBounds m_TimeBounds; vtkMatrix4x4* m_VtkMatrix; bool m_ImageGeometry; //##Documentation //## @brief Spacing of the data. Only significant if the geometry describes //## an Image (m_ImageGeometry==true). mitk::Vector3D m_Spacing; bool m_Valid; unsigned int m_FrameOfReferenceID; static const std::string INDEX_TO_OBJECT_TRANSFORM; static const std::string OBJECT_TO_NODE_TRANSFORM; static const std::string INDEX_TO_NODE_TRANSFORM; static const std::string INDEX_TO_WORLD_TRANSFORM; private: mutable TransformType::Pointer m_InvertedTransform; mutable unsigned long m_IndexToWorldTransformLastModified; VnlQuaternionType m_RotationQuaternion; float m_FloatSpacing[3]; vtkMatrixToLinearTransform* m_VtkIndexToWorldTransform; //##Documentation //## @brief Origin, i.e. upper-left corner of the plane //## Point3D m_Origin; }; } // namespace mitk #endif /* GEOMETRY3D_H_HEADER_INCLUDED_C1EBD0AD */ diff --git a/Core/Code/DataManagement/mitkImageDataItem.h b/Core/Code/DataManagement/mitkImageDataItem.h index 2b232e75a3..10ebb67859 100644 --- a/Core/Code/DataManagement/mitkImageDataItem.h +++ b/Core/Code/DataManagement/mitkImageDataItem.h @@ -1,137 +1,138 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef IMAGEDATAITEM_H #define IMAGEDATAITEM_H #include +#include #include "mitkPixelType.h" class vtkImageData; namespace mitk { //##Documentation //## @brief Internal class for managing references on sub-images //## //## ImageDataItem is a container for image data which is used internal in //## mitk::Image to handle the communication between the different data types for images //## used in MITK (ipPicDescriptor, mitk::Image, vtkImageData). Common for these image data //## types is the actual image data, but they differ in representation of pixel type etc. //## The class is also used to convert ipPic images to vtkImageData. //## //## The class is mainly used to extract sub-images inside of mitk::Image, like single slices etc. //## It should not be used outside of this. //## //## @param manageMemory Determines if image data is removed while destruction of ImageDataItem or not. //## @ingroup Data class MITK_CORE_EXPORT ImageDataItem : public itk::LightObject { public: mitkClassMacro(ImageDataItem, itk::LightObject); ImageDataItem(const ImageDataItem& aParent, unsigned int dimension, void *data = NULL, bool manageMemory = false, size_t offset = 0); ~ImageDataItem(); ImageDataItem(const mitk::PixelType& type, unsigned int dimension, unsigned int *dimensions, void *data, bool manageMemory); ImageDataItem(const ImageDataItem &other); void* GetData() const { return m_Data; } bool IsComplete() const { return m_IsComplete; } void SetComplete(bool complete) { m_IsComplete = complete; } int GetOffset() const { return m_Offset; } PixelType GetPixelType() const { return m_PixelType; } ImageDataItem::ConstPointer GetParent() const { return m_Parent; } mitkIpPicDescriptor* GetPicDescriptor() const { return m_PicDescriptor; } //## Returns a vtkImageData; if non is present, a new one is constructed. vtkImageData* GetVtkImageData() const { if(m_VtkImageData==NULL) ConstructVtkImageData(); return m_VtkImageData; } // Returns if image data should be deleted on destruction of ImageDataItem. bool GetManageMemory() const { return m_ManageMemory; } virtual void ConstructVtkImageData() const; unsigned long GetSize() const { return m_Size; } virtual void Modified() const; protected: unsigned char* m_Data; PixelType m_PixelType; bool m_ManageMemory; mitkIpPicDescriptor* m_PicDescriptor; mutable vtkImageData* m_VtkImageData; int m_Offset; bool m_IsComplete; unsigned long m_Size; private: ImageDataItem::ConstPointer m_Parent; template unsigned char *ConvertTensorsToRGB() const; }; } // namespace mitk #endif /* IMAGEDATAITEM_H */ diff --git a/Core/Code/DataManagement/mitkLookupTable.h b/Core/Code/DataManagement/mitkLookupTable.h index f6ac488630..a39a35583a 100644 --- a/Core/Code/DataManagement/mitkLookupTable.h +++ b/Core/Code/DataManagement/mitkLookupTable.h @@ -1,132 +1,133 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKLookupTable_H_HEADER_INCLUDED_C1EBD53D #define MITKLookupTable_H_HEADER_INCLUDED_C1EBD53D #include +#include #include "vtkLookupTable.h" #include #include class vtkColorTransferFunction; class vtkPiecewiseFunction; namespace mitk { //## //##Documentation //## @brief LookupTable containing a vtkLookupTable //## @ingroup Data //## class MITK_CORE_EXPORT LookupTable : public itk::DataObject { public: /** *@brief Some convenient typedefs. */ typedef unsigned char RawLookupTableType; mitkClassMacro( LookupTable, itk::DataObject ); itkNewMacro( Self ); /** * @returns the associated vtkLookupTable */ virtual vtkLookupTable* GetVtkLookupTable() const; virtual RawLookupTableType * GetRawLookupTable() const; virtual void SetVtkLookupTable( vtkLookupTable* lut ); virtual void ChangeOpacityForAll( float opacity ); virtual void ChangeOpacity(int index, float opacity ); /*! * \brief equality operator implementation */ virtual bool operator==( const mitk::LookupTable& LookupTable ) const; /*! * \brief non equality operator implementation */ virtual bool operator!=( const LookupTable& LookupTable ) const; /*! * \brief implementation necessary because operator made * private in itk::Object */ virtual LookupTable& operator=( const LookupTable& LookupTable ); /** * Updates the output information of the current object by calling * updateOutputInformation of the data objects source object. */ virtual void UpdateOutputInformation( ); /** * Sets the requested Region to the largest possible region. * This method is not implemented, since this is the default * behaviour of the itk pipeline and we do not support the * requested-region mechanism for lookup-tables */ virtual void SetRequestedRegionToLargestPossibleRegion( ); /** * Checks, if the requested region lies outside of the buffered region by * calling verifyRequestedRegion(). */ virtual bool RequestedRegionIsOutsideOfTheBufferedRegion( ); /** * Checks if the requested region is completely contained in * the buffered region. Since we always want to process the lookup * table as a whole, this method always returns true */ virtual bool VerifyRequestedRegion( ); /** * This method has no effect for lookup tables, since we do * not support the region-mechanism */ virtual void SetRequestedRegion( itk::DataObject *data ); LookupTable(); virtual ~LookupTable(); void CreateColorTransferFunction(vtkColorTransferFunction*& colorFunction); void CreateOpacityTransferFunction(vtkPiecewiseFunction*& opacityFunction); void CreateGradientTransferFunction(vtkPiecewiseFunction*& gradientFunction); protected: vtkLookupTable* m_LookupTable; private: }; } // namespace mitk #endif /* LookupTable_H_HEADER_INCLUDED_C1EBD53D */ diff --git a/Core/Code/DataManagement/mitkMaterial.h b/Core/Code/DataManagement/mitkMaterial.h index 82f25d2d46..55ad4f155f 100644 --- a/Core/Code/DataManagement/mitkMaterial.h +++ b/Core/Code/DataManagement/mitkMaterial.h @@ -1,478 +1,479 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_MATERIAL_H_ #define _MITK_MATERIAL_H_ #include +#include #include #include #include #include #include namespace mitk { /** * Encapsulates 3D visualization properties which are forwarded to vtk for * color mapping. This includes color, specular coefficient and power, opacity * interpolation type (flat, gouraud, phong) and representation (points, * wireframe or surface). * * @see vtkProperty */ class MITK_CORE_EXPORT Material : public itk::Object { public: mitkClassMacro( Material, itk::Object ); typedef itk::RGBPixel Color; enum InterpolationType { Flat, Gouraud, Phong }; enum RepresentationType { Points, Wireframe, Surface }; /** * Constructor. Materials are set to the following default values: * Color (0.5, 0.5, 0.5) color coefficient 1.0, specular color (1.0, 1.0, 1.0), * specular coefficient 1.0, specular power 10, opacity 1.0, interpolation * Gouraud, representation Surface. * @param node optinally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ static Pointer New() { Pointer smartPtr = new Material( ); smartPtr->UnRegister(); return smartPtr; } /** * Constructor. All values besides the given ones are set to defaults as * described in the default constructor * @param color the material color in RGB. Each RGB value should be in the * range [0..1] * @param opacity the opacity of the material. 0.0 means fully transparent * and 1.0 means solid. * @param node optinally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ static Pointer New( Color color, vtkFloatingPointType opacity = 1.0f) { Pointer smartPtr = new Material(color, opacity ); smartPtr->UnRegister(); return smartPtr; } /** * Constructor. All values besides the given ones are set to defaults as * described in the default constructor * @param red the red component of the materials color (range [0..1]) * @param green the green component of the materials color (range [0..1]) * @param blue the blue component of the materials color (range [0..1]) * @param opacity the opacity of the material. 0.0 means fully transparent * and 1.0 means solid. * @param node optionally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ static Pointer New( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue, vtkFloatingPointType opacity = 1.0f) { Pointer smartPtr = new Material(red, green, blue, opacity ); smartPtr->UnRegister(); return smartPtr; } /** * Constructor. All values besides the given ones are set to defaults as * described in the default constructor * @param red the red component of the materials color (range [0..1]) * @param green the green component of the materials color (range [0..1]) * @param blue the blue component of the materials color (range [0..1]) * @param colorCoefficient a scaling factor for the color coefficient which * will be multiplied with each color component (range [0..1]). * @param specularCoefficient controls in combination with the specular power * how shiny the material will appear (range [0..1]). * @param specularPower controls in combination with the specular coefficient * how shiny the material will appear (range [0..inf]). * @param opacity the opacity of the material. 0.0 means fully transparent * and 1.0 means solid. * @param node optionally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ static Pointer New( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue, vtkFloatingPointType colorCoefficient, vtkFloatingPointType specularCoefficient, vtkFloatingPointType specularPower, vtkFloatingPointType opacity ) { Pointer smartPtr = new Material(red, green, blue, colorCoefficient, specularCoefficient, specularPower, opacity ); smartPtr->UnRegister(); return smartPtr; } /** * Constructor. All values besides the given ones are set to defaults as * described in the default constructor * * @param color the material color in RGB. Each RGB value should be in the * range [0..1] * @param colorCoefficient a scaling factor for the color coefficient which * will be multiplied with each color component (range [0..1]). * @param specularCoefficient controls in combination with the specular power * how shiny the material will appear (range [0..1]). * @param specularPower controls in combination with the specular coefficient * how shiny the material will appear (range [0..inf]). * @param opacity the opacity of the material. 0.0 means fully transparent * and 1.0 means solid. * @param node optionally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ static Pointer New( Color color, vtkFloatingPointType colorCoefficient, vtkFloatingPointType specularCoefficient, vtkFloatingPointType specularPower, vtkFloatingPointType opacity ) { Pointer smartPtr = new Material(color, colorCoefficient, specularCoefficient, specularPower, opacity ); smartPtr->UnRegister(); return smartPtr; } /** * Copy constructor */ mitkNewMacro1Param(Material, const Material&); /** * Copy constructor, provided for convinience. The values are copied from property * and afterwards the values provided for red green blue and opacity are written into the object. */ static Pointer New( const Material& property, vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue, vtkFloatingPointType opacity = 1.0, std::string name = "" ) { Pointer smartPtr = new Material(property, red, green, blue, opacity, name ); smartPtr->UnRegister(); return smartPtr; } virtual bool Assignable(const Material& other) const; virtual Material& operator=(const Material& other); /* Sets the materials color in RGB space. The rgb components have to be * in the range [0..1] * @param color the new color of the material */ virtual void SetColor( Color color ); /** * Sets the materials color in RGB space. The rgb components have to be * in the range [0..1] * @param red the red component of the materials color (range [0..1]) * @param green the green component of the materials color (range [0..1]) * @param blue the blue component of the materials color (range [0..1]) */ virtual void SetColor( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue ); /** * Sets a attenuation coefficient for the color. A value of 0 results in * a black object. VAlid range is [0..1] * @param coefficient the color attenuation coefficient */ virtual void SetColorCoefficient( vtkFloatingPointType coefficient ); /** * Sets the specular color * @param color the specular color in RGB. Each RGB value should be in the * range [0..1] */ virtual void SetSpecularColor( Color color ); /** * Sets the specular color * @param red the red component of the specular color (range [0..1]) * @param green the green component of the specular color (range [0..1]) * @param blue the blue component of the specular color (range [0..1]) */ virtual void SetSpecularColor( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue ); /** * Sets the specular coefficient which controls the shininess of the object * together with the specular power * @param specularCoefficient the new specular coefficient. Valid range * is [0..1] */ virtual void SetSpecularCoefficient( vtkFloatingPointType specularCoefficient ); /** * Sets the specular power which controls the shininess of the object * together with the specular coefficient * @param specularCoefficient the new specular coefficient. Valid range * is [0..inf] */ virtual void SetSpecularPower( vtkFloatingPointType specularPower ); /** * Sets the opacity of the material, which controls how transparent the * object appears. Valid range is [0..1], where 0 means fully transparent * and 1 means a solid surface. * @param opacity the new opacity of the material */ virtual void SetOpacity( vtkFloatingPointType opacity ); /** * Sets the surface interpolation method of the object rendered using the * given materials. Valid Interopation types are Flat, Gouraud and Phong. * See any computer graphics book for their meaning * @param interpolation the interpolation method used for rendering of * surfaces. */ virtual void SetInterpolation( InterpolationType interpolation ); /** * Sets the surface representation method of the object rendered using the * given materials. Valid Interopation types are Points, Wireframe and * Surface. * @param representation the representation method used for rendering of * surfaces. */ virtual void SetRepresentation( RepresentationType representation ); /** * Set/Get the width of a Line. The width is expressed in screen units. The default is 1.0. */ virtual void SetLineWidth( float lineWidth ); /** * @returns the color of the material */ virtual Color GetColor() const; /** * @returns the color coefficient of the material. Range is [0..1] */ virtual vtkFloatingPointType GetColorCoefficient() const; /** * @returns the specular color of the material in rgb values, which * range from 0 .. 1 */ virtual Color GetSpecularColor() const; /** * @returns the specular coefficient used for rendering. Range is [0..1] */ virtual vtkFloatingPointType GetSpecularCoefficient() const; /** * @returns the specular power. Ranges from 0 to infinity */ virtual vtkFloatingPointType GetSpecularPower() const; /** * @returns the opacity of the material. Ranges from 0 to 1 */ virtual vtkFloatingPointType GetOpacity() const; /** * @returns the interpolation method used for rendering. */ virtual InterpolationType GetInterpolation() const; /** * @returns the representation type used for rendering. */ virtual RepresentationType GetRepresentation() const; /** * @returns the interpolation method used for rendering using the predefined * vtk constants. */ virtual int GetVtkInterpolation() const; /** * @returns the representation type used for rendering using the predefined * vtk constants. */ virtual int GetVtkRepresentation() const; /** * @returns the line width used for wireframe rendering as a fraction of screen units */ virtual float GetLineWidth() const; /** * Fills the current materials with the properties of the * given material. * @param property the materials which should be copied in the * current materials * @param copyDataNode If set to true, the data tree node and renderer * associated with the material property are also copied. Otherwise * these member variables will be left untouched */ virtual void Initialize( const Material& property ); /** * comparison operator which uses the member variables for * comparison */ virtual bool operator==( const Material& property ) const; /** * Dumps the properties to the out stream out */ void PrintSelf ( std::ostream &os, itk::Indent ) const; /** * Sets an optional name which may be associated with the material property * Please note, that this name is NOT forwarded to the data tree node * as the node name */ itkSetMacro( Name, std::string ); /** * returns the name associated with the material property */ itkGetConstMacro( Name, std::string ); protected: /** * Constructor. Materials are set to the following default values: * Color (0.5, 0.5, 0.5) color coefficient 1.0, specular color (1.0, 1.0, 1.0), * specular coefficient 1.0, specular power 10, opacity 1.0, interpolation * Gouraud, representation Surface. * @param node optinally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ Material( ); /** * Constructor. All values besides the given ones are set to defaults as * described in the default constructor * @param color the material color in RGB. Each RGB value should be in the * range [0..1] * @param opacity the opacity of the material. 0.0 means fully transparent * and 1.0 means solid. * @param node optinally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ Material( Color color, vtkFloatingPointType opacity = 1.0f ); /** * Constructor. All values besides the given ones are set to defaults as * described in the default constructor * @param red the red component of the materials color (range [0..1]) * @param green the green component of the materials color (range [0..1]) * @param blue the blue component of the materials color (range [0..1]) * @param opacity the opacity of the material. 0.0 means fully transparent * and 1.0 means solid. * @param node optionally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ Material( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue, vtkFloatingPointType opacity = 1.0f ); /** * Constructor. All values besides the given ones are set to defaults as * described in the default constructor * @param red the red component of the materials color (range [0..1]) * @param green the green component of the materials color (range [0..1]) * @param blue the blue component of the materials color (range [0..1]) * @param colorCoefficient a scaling factor for the color coefficient which * will be multiplied with each color component (range [0..1]). * @param specularCoefficient controls in combination with the specular power * how shiny the material will appear (range [0..1]). * @param specularPower controls in combination with the specular coefficient * how shiny the material will appear (range [0..inf]). * @param opacity the opacity of the material. 0.0 means fully transparent * and 1.0 means solid. * @param node optionally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ Material( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue, vtkFloatingPointType colorCoefficient, vtkFloatingPointType specularCoefficient, vtkFloatingPointType specularPower, vtkFloatingPointType opacity ); /** * Constructor. All values besides the given ones are set to defaults as * described in the default constructor * * @param color the material color in RGB. Each RGB value should be in the * range [0..1] * @param colorCoefficient a scaling factor for the color coefficient which * will be multiplied with each color component (range [0..1]). * @param specularCoefficient controls in combination with the specular power * how shiny the material will appear (range [0..1]). * @param specularPower controls in combination with the specular coefficient * how shiny the material will appear (range [0..inf]). * @param opacity the opacity of the material. 0.0 means fully transparent * and 1.0 means solid. * @param node optionally a data tree node may be defined to which the properties * are forwarded. Please note, that if this node doesn't have the * needed properties associated, they will be added. */ Material( Color color, vtkFloatingPointType colorCoefficient, vtkFloatingPointType specularCoefficient, vtkFloatingPointType specularPower, vtkFloatingPointType opacity ); /** * Copy constructor */ Material( const Material& property ); /** * Copy constructor, provided for convinience. The values are copied from property * and afterwards the values provided for red green blue and opacity are written into the object. */ Material( const Material& property, vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue, vtkFloatingPointType opacity = 1.0, std::string name = ""); virtual void InitializeStandardValues(); virtual void Update(); std::string m_Name; Color m_Color; Color m_SpecularColor; vtkFloatingPointType m_ColorCoefficient; vtkFloatingPointType m_SpecularCoefficient; vtkFloatingPointType m_SpecularPower; vtkFloatingPointType m_Opacity; float m_LineWidth; InterpolationType m_Interpolation; RepresentationType m_Representation; }; typedef itk::VectorContainer< unsigned int, Material::Pointer > MaterialVectorContainer; } #endif diff --git a/Core/Code/DataManagement/mitkNodePredicateBase.h b/Core/Code/DataManagement/mitkNodePredicateBase.h index 67a1107b0b..953fac6f9e 100644 --- a/Core/Code/DataManagement/mitkNodePredicateBase.h +++ b/Core/Code/DataManagement/mitkNodePredicateBase.h @@ -1,58 +1,59 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKNODEPREDICATEBASE_H_HEADER_INCLUDED_ #define MITKNODEPREDICATEBASE_H_HEADER_INCLUDED_ #include +#include #include "itkObject.h" namespace mitk { class DataNode; //##Documentation //## @brief Interface for evaluation conditions used in the DataStorage class GetSubset() method //## //## Classes that inherit this interface can be used as predicates in the GetSubset() method //## of mitk::DataStorage. By combining different predicate objects, the user can form complex //## queries like "give me all nodes that either contain a surface object or a binary segmentation //## and that are tagged as Organtype == 'Liver'". //## @warning NodePredicates are now derived from itk::Object and make thus use of the smart pointer concept. //## As a result predicates should only store raw pointers because for one thing they are not owners //## of these objects and should not keep them alive. //## //## @ingroup DataStorage class MITK_CORE_EXPORT NodePredicateBase: public itk::Object { public: mitkClassMacro(NodePredicateBase,itk::Object); //##Documentation //## @brief Standard Destructor virtual ~NodePredicateBase(); //##Documentation //## @brief This method will be used to evaluate the node. Has to be overwritten in subclasses virtual bool CheckNode(const mitk::DataNode* node) const = 0; }; } // namespace mitk #endif /* MITKNODEPREDICATEBASE_H_HEADER_INCLUDED_ */ diff --git a/Core/Code/IO/mitkFileSeriesReader.h b/Core/Code/IO/mitkFileSeriesReader.h index e3452b30f7..8b941aaccb 100644 --- a/Core/Code/IO/mitkFileSeriesReader.h +++ b/Core/Code/IO/mitkFileSeriesReader.h @@ -1,65 +1,66 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __MITK_FILE_SERIES_READER__H_ #define __MITK_FILE_SERIES_READER__H_ #include +#include #include #include #include namespace mitk { /** * Provides a function which generates a list of files from * a given prefix and pattern. * Subclasses may use this function to load a series of files. */ class MITK_CORE_EXPORT FileSeriesReader : public FileReader { public: mitkClassMacro( FileSeriesReader, FileReader ); typedef std::vector< std::string > MatchedFileNames; virtual MatchedFileNames GetMatchedFileNames( ); protected: FileSeriesReader(); virtual ~FileSeriesReader(); virtual bool GenerateFileList(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; MatchedFileNames m_MatchedFileNames; }; } #endif diff --git a/Core/Code/IO/mitkLog.cpp b/Core/Code/IO/mitkLog.cpp index 93f21648d7..2e24292d8d 100644 --- a/Core/Code/IO/mitkLog.cpp +++ b/Core/Code/IO/mitkLog.cpp @@ -1,145 +1,146 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Tue, 12 May 2009) $ Version: $Revision: 17179 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkLog.h" +#include "mitkLogMacros.h" #include "itkSimpleFastMutexLock.h" #include #include #include static itk::SimpleFastMutexLock logMutex; static mitk::LoggingBackend *mitkLogBackend = 0; static std::ofstream *logFile = 0; static std::stringstream *outputWindow = 0; static bool logOutputWindow = false; void mitk::LoggingBackend::EnableAdditionalConsoleWindow(bool enable) { logOutputWindow = enable; } void mitk::LoggingBackend::ProcessMessage(const mbilog::LogMessage& l ) { logMutex.Lock(); #ifdef _WIN32 mbilog::BackendCout::FormatSmart( l, (int)GetCurrentThreadId() ); #else mbilog::BackendCout::FormatSmart( l ); #endif if(logFile) { #ifdef _WIN32 mbilog::BackendCout::FormatFull( *logFile, l, (int)GetCurrentThreadId() ); #else mbilog::BackendCout::FormatFull( *logFile, l ); #endif } if(logOutputWindow) { if(outputWindow == NULL) { outputWindow = new std::stringstream();} outputWindow->str(""); outputWindow->clear(); #ifdef _WIN32 mbilog::BackendCout::FormatFull( *outputWindow, l, (int)GetCurrentThreadId() ); #else mbilog::BackendCout::FormatFull( *outputWindow, l ); #endif itk::OutputWindow::GetInstance()->DisplayText(outputWindow->str().c_str()); } logMutex.Unlock(); } void mitk::LoggingBackend::Register() { if(mitkLogBackend) return; mitkLogBackend = new mitk::LoggingBackend(); mbilog::RegisterBackend( mitkLogBackend ); } void mitk::LoggingBackend::Unregister() { if(mitkLogBackend) { SetLogFile(0); mbilog::UnregisterBackend( mitkLogBackend ); delete mitkLogBackend; mitkLogBackend=0; } } void mitk::LoggingBackend::SetLogFile(const char *file) { logMutex.Lock(); if(logFile) { MITK_INFO << "closing logfile"; logFile->close(); delete logFile; logFile = 0; } if(file) { logFile = new std::ofstream( file, std::ios_base::out | std::ios_base::app ); /* if(*logFile) { std::cout << "opening logfile '" << file << "' for writing failed"; MITK_INFO << "logging to '" << file << "'"; } else { std::cerr << "opening logfile '" << file << "' for writing failed"; MITK_ERROR << "opening logfile '" << file << "' for writing failed"; delete logFile; logFile = 0; } */ } logMutex.Unlock(); } void mitk::LoggingBackend::CatchLogFileCommandLineParameter(int &argc,char **argv) { int r; for(r=1;r=argc) { --argc; MITK_ERROR << "--logfile parameter found, but no file given"; return; } mitk::LoggingBackend::SetLogFile(argv[r+1]); for(r+=2;r +#include namespace mitk { /*! \brief mbilog backend implementation for mitk */ class MITK_CORE_EXPORT LoggingBackend : public mbilog::AbstractBackend { public: /** \brief overloaded method for receiving log message from mbilog */ void ProcessMessage(const mbilog::LogMessage& ); /** \brief registers MITK logging backend at mbilog */ static void Register(); /** \brief Unregisters MITK logging backend at mbilog */ static void Unregister(); /** \brief Sets extra log file path (additionally to the console log) */ static void SetLogFile(const char *file); /** \brief Enables an additional logging output window by means of itk::outputwindow * This might be relevant for showing log output in applications with no default output console */ static void EnableAdditionalConsoleWindow(bool enable); /** \brief Automatically extracts and removes the "--logfile " parameters from the standard C main(argc,argv) parameter list and calls SetLogFile if needed */ static void CatchLogFileCommandLineParameter(int &argc,char **argv); }; } #endif diff --git a/Core/Code/IO/mitkPixelType.cpp b/Core/Code/IO/mitkPixelType.cpp index 4f1ed89ff5..30adef76d4 100644 --- a/Core/Code/IO/mitkPixelType.cpp +++ b/Core/Code/IO/mitkPixelType.cpp @@ -1,370 +1,371 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkIpPic.h" #include "mitkPixelType.h" +#include #include #include #include #include #include "itkDiffusionTensor3D.h" #define HUNDRED_VECS(HUN) \ TEN_VECS(HUN) \ TEN_VECS(HUN+10) \ TEN_VECS(HUN+20) \ TEN_VECS(HUN+30) \ TEN_VECS(HUN+40) \ TEN_VECS(HUN+50) \ TEN_VECS(HUN+60) \ TEN_VECS(HUN+70) \ TEN_VECS(HUN+80) \ TEN_VECS(HUN+90) \ #define TEN_VECS(TEN) \ if(false){} \ N_VEC(TEN+ 1) \ N_VEC(TEN+ 2) \ N_VEC(TEN+ 3) \ N_VEC(TEN+ 4) \ N_VEC(TEN+ 5) \ N_VEC(TEN+ 6) \ N_VEC(TEN+ 7) \ N_VEC(TEN+ 8) \ N_VEC(TEN+ 9) \ N_VEC(TEN+10) \ #define N_VEC(N_DIRS) \ _N_VEC(N_DIRS,double) \ _N_VEC(N_DIRS,float) \ _N_VEC(N_DIRS,short) \ #define _N_VEC(N_DIRS,PIXTYPE) \ else if ( *m_TypeId == typeid( itk::Vector )) \ { \ found = true; \ m_TypeId = & typeid( PIXTYPE ); \ m_NumberOfComponents *= N_DIRS; \ m_Type = mitkIpPicFloat; \ m_Bpe = sizeof(PIXTYPE) * 8 * m_NumberOfComponents; \ m_ItkTypeId = &typeid( itk::Vector ); \ } \ mitk::PixelType::PixelType() : m_TypeId( NULL ), m_Type( mitkIpPicUnknown ), m_Bpe( 0 ), m_NumberOfComponents( 1 ) { } mitk::PixelType::PixelType( const mitk::PixelType& aPixelType ) { Initialize( *aPixelType.GetTypeId(), aPixelType.GetNumberOfComponents() ); } mitk::PixelType::PixelType( const std::type_info& aTypeId, int numberOfComponents, ItkIOPixelType anItkIoPixelType ) : m_TypeId( &aTypeId ), m_NumberOfComponents( numberOfComponents ) { Initialize( aTypeId, numberOfComponents, anItkIoPixelType ); } mitk::PixelType::PixelType( mitkIpPicType_t type, int bpe, int numberOfComponents ) : m_Type( type ), m_Bpe( bpe ), m_NumberOfComponents( numberOfComponents ) { Initialize( type, bpe, numberOfComponents ); } mitk::PixelType::PixelType( const mitkIpPicDescriptor* pic ) : m_NumberOfComponents( 1 ) { if ( pic != NULL ) Initialize( pic->type, pic->bpe ); else { m_TypeId = NULL; // itkExceptionMacro("pic.IsNull() has no pixel type."); } } bool mitk::PixelType::operator==(const mitk::PixelType& rhs) const { MITK_DEBUG << "operator==" << std::endl; MITK_DEBUG << "m_Type = " << m_Type << " " << rhs.m_Type << std::endl; MITK_DEBUG << "m_Bpe = " << m_Bpe << " " << rhs.m_Bpe << std::endl; MITK_DEBUG << "m_NumberOfComponents = " << m_NumberOfComponents << " " << rhs.m_NumberOfComponents << std::endl; MITK_DEBUG << "m_BitsPerComponent = " << m_BitsPerComponent << " " << rhs.m_BitsPerComponent << std::endl; return ( *(this->m_TypeId) == *(rhs.m_TypeId) && this->m_Type == rhs.m_Type && this->m_Bpe == rhs.m_Bpe && this->m_NumberOfComponents == rhs.m_NumberOfComponents && this->m_BitsPerComponent == rhs.m_BitsPerComponent ); } bool mitk::PixelType::operator!=(const mitk::PixelType& rhs) const { return !(this->operator==(rhs)); } bool mitk::PixelType::operator==(const std::type_info& typeId) const { if (GetItkTypeId() == NULL) return false; return (*GetItkTypeId() == typeId); } bool mitk::PixelType::operator!=(const std::type_info& typeId) const { return !(this->operator==(typeId)); } #define SET_ITK_TYPE_ID(anItkIoPixelType_test, numberOfComponents_test, ITK_TYPE) \ if ( (itk::ImageIOBase::anItkIoPixelType_test == anItkIoPixelType ) && \ (numberOfComponents_test == m_NumberOfComponents) \ ) \ { \ m_ItkTypeId = &typeid(ITK_TYPE); \ } #define SET_TYPE(TYPE, IPPIC_TYPE) \ if ( *m_TypeId == typeid( TYPE ) ) \ { \ m_Type = IPPIC_TYPE; \ m_Bpe = sizeof(TYPE) * 8 * m_NumberOfComponents; \ \ typedef itk::Vector Vector3Type; \ typedef itk::CovariantVector CovariantVector3Type; \ typedef itk::Point Point3Type; \ typedef itk::Vector Vector2Type; \ typedef itk::CovariantVector CovariantVector2Type; \ typedef itk::Point Point2Type; \ \ SET_ITK_TYPE_ID(UNKNOWNPIXELTYPE, 1, TYPE ) else \ SET_ITK_TYPE_ID(SCALAR, 1, TYPE ) else \ \ SET_ITK_TYPE_ID(VECTOR, 2, Vector2Type ) else \ SET_ITK_TYPE_ID(COVARIANTVECTOR, 2, CovariantVector2Type ) else \ SET_ITK_TYPE_ID(POINT, 2, Point2Type ) else \ \ SET_ITK_TYPE_ID(RGB, 3, itk::RGBPixel ) else \ /*SET_ITK_TYPE_ID(DIFFUSIONTENSOR3D, 6, itk::DiffusionTensor3D ) else */ \ SET_ITK_TYPE_ID(VECTOR, 3, Vector3Type ) else \ SET_ITK_TYPE_ID(COVARIANTVECTOR, 3, CovariantVector3Type ) else \ SET_ITK_TYPE_ID(POINT, 3, Point3Type ) else \ \ SET_ITK_TYPE_ID(RGBA, 4, itk::RGBAPixel ) else \ { \ } \ } \ else void mitk::PixelType::Initialize( const std::type_info& aTypeId, int numberOfComponents, ItkIOPixelType anItkIoPixelType ) { m_TypeId = &aTypeId; m_NumberOfComponents = numberOfComponents; if(m_NumberOfComponents == 1) m_ItkTypeId = &aTypeId; else m_ItkTypeId = NULL; SET_TYPE(double, mitkIpPicFloat) SET_TYPE(float, mitkIpPicFloat) SET_TYPE(long, mitkIpPicInt) SET_TYPE(unsigned long, mitkIpPicUInt) SET_TYPE(int, mitkIpPicInt) SET_TYPE(unsigned int, mitkIpPicUInt) SET_TYPE(short, mitkIpPicInt) SET_TYPE(unsigned short, mitkIpPicUInt) SET_TYPE(char, mitkIpPicInt) SET_TYPE(unsigned char, mitkIpPicUInt) if ( *m_TypeId == typeid( itk::DiffusionTensor3D ) ) { m_TypeId = & typeid( float ); m_NumberOfComponents *= 6; m_Type = mitkIpPicFloat; m_Bpe = sizeof(float) * 8 * m_NumberOfComponents; m_ItkTypeId = &typeid( itk::DiffusionTensor3D ); } else if ( *m_TypeId == typeid( itk::DiffusionTensor3D ) ) { m_TypeId = & typeid( double ); m_NumberOfComponents *= 6; m_Type = mitkIpPicFloat; m_Bpe = sizeof(double) * 8 * m_NumberOfComponents; m_ItkTypeId = &typeid( itk::DiffusionTensor3D ); } else if ( *m_TypeId == typeid( itk::RGBPixel ) ) { m_Type = mitkIpPicUInt; m_NumberOfComponents = 3; m_Bpe = sizeof(unsigned char) * 8 * m_NumberOfComponents; m_ItkTypeId = &typeid( itk::RGBPixel ); } else if ( *m_TypeId == typeid( itk::RGBAPixel ) ) { m_Type = mitkIpPicUInt; m_NumberOfComponents = 4; m_Bpe = sizeof(unsigned char) * 8 * m_NumberOfComponents; m_ItkTypeId = &typeid( itk::RGBAPixel ); } else { bool found = false; // the following lines allow for fixed-size vector images up to a certain size limit // (commented out for shorter compile times) //HUNDRED_VECS(000) //HUNDRED_VECS(100) //HUNDRED_VECS(200) //HUNDRED_VECS(300) //HUNDRED_VECS(400) //HUNDRED_VECS(500) //HUNDRED_VECS(600) //HUNDRED_VECS(700) // allow for fixed-size vectors of specific length // (inspired by itkPointshell.cpp, precompiled q-ball configs) //TEN_VECS(0) //N_VEC(11) //N_VEC(12) if(false){} N_VEC(2) N_VEC(3) N_VEC(6) N_VEC(42) N_VEC(92) N_VEC(162) N_VEC(252) N_VEC(362) N_VEC(492) N_VEC(642) N_VEC(812) N_VEC(1002) if(!found) itkExceptionMacro( "Pixel type currently not supported." ); } m_BitsPerComponent = m_Bpe / m_NumberOfComponents; } void mitk::PixelType::Initialize( mitkIpPicType_t type, int bpe, int numberOfComponents ) { m_Type = type; m_Bpe = bpe; m_NumberOfComponents = numberOfComponents; switch ( type ) { case mitkIpPicUnknown: m_TypeId = &typeid( void* ); break; case mitkIpPicBool: m_TypeId = &typeid( bool ); m_Bpe = sizeof(bool) * 8 * numberOfComponents; break; case mitkIpPicASCII: m_TypeId = &typeid( char ); m_Bpe = sizeof(char) * 8 * numberOfComponents; break; case mitkIpPicInt: switch ( bpe / numberOfComponents ) { case 8: m_TypeId = &typeid( char ); break; case 16: m_TypeId = &typeid( short ); break; case 32: m_TypeId = &typeid( int ); break; case 64: m_TypeId = &typeid( long ); break; default: m_TypeId = NULL; itkExceptionMacro( "Pixel type currently not supported." ); } break; case mitkIpPicUInt: switch ( bpe / numberOfComponents ) { case 8: m_TypeId = &typeid( unsigned char ); break; case 16: m_TypeId = &typeid( unsigned short ); break; case 24: m_TypeId = &typeid( unsigned char ); m_NumberOfComponents = numberOfComponents = 3; break; case 32: m_TypeId = &typeid( unsigned int ); break; case 64: m_TypeId = &typeid( unsigned long ); break; default: m_TypeId = NULL; itkExceptionMacro( "Pixel type currently not supported." ); } break; case mitkIpPicFloat: switch ( bpe / numberOfComponents ) { case 32: m_TypeId = &typeid( float ); break; case 64: m_TypeId = &typeid( double ); break; default: m_TypeId = NULL; itkExceptionMacro( "Pixel type currently not supported." ); } break; case mitkIpPicNonUniform: m_TypeId = &typeid( void* ); break; case mitkIpPicTSV: m_TypeId = &typeid( void* ); break; default: m_TypeId = NULL; itkExceptionMacro( "Pixel type currently not supported." ); break; } m_BitsPerComponent = m_Bpe / numberOfComponents; if(m_NumberOfComponents == 1) m_ItkTypeId = m_TypeId; else m_ItkTypeId = NULL; } std::string mitk::PixelType::GetItkTypeAsString() const { if (GetItkTypeId()==NULL) { return "unknown"; } else { return GetItkTypeId()->name(); } } diff --git a/Core/Code/Interactions/mitkEvent.cpp b/Core/Code/Interactions/mitkEvent.cpp index 495b9d99f5..2eb97088f3 100644 --- a/Core/Code/Interactions/mitkEvent.cpp +++ b/Core/Code/Interactions/mitkEvent.cpp @@ -1,74 +1,74 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkEvent.h" mitk::Event::Event(mitk::BaseRenderer* sender, int type, int button, int buttonState, int key) : m_Sender( sender ), m_Type( type ), m_Button( button ), m_ButtonState( buttonState ), m_Key( key ) { } mitk::Event::~Event() { } mitk::BaseRenderer* mitk::Event::GetSender() const { return m_Sender; } int mitk::Event::GetType() const { return m_Type; } int mitk::Event::GetButtonState() const { return m_ButtonState; } int mitk::Event::GetButton() const { return m_Button; } int mitk::Event::GetKey() const { return m_Key; } bool mitk::Event::operator==(const Event& event) const { const mitk::Event *input = dynamic_cast(&event); - if(input==NULL) return false; + if(input==0) return false; if ( (m_Type == event.GetType()) && (m_Button == event.GetButton()) && (m_ButtonState == event.GetButtonState()) && (m_Key == event.GetKey()) ) { return true; } else { return false; } } diff --git a/Core/Code/Interactions/mitkEventMapper.h b/Core/Code/Interactions/mitkEventMapper.h index 028ccb6109..8c8c4411ae 100644 --- a/Core/Code/Interactions/mitkEventMapper.h +++ b/Core/Code/Interactions/mitkEventMapper.h @@ -1,197 +1,202 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef EVENTMAPPER_H_HEADER_INCLUDED #define EVENTMAPPER_H_HEADER_INCLUDED #include #include #include #include +#include + +#include +#include + namespace mitk { struct ltstr { bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; } }; typedef std::string msgString; //for friendship wor to set the stateevent after calculating class GlobalInteraction; class StateMachine; class StateEvent; class EventMapperAddOn; //##Documentation //## @brief Maps an Event to its description //## //## EventMapping: //## This class mapps the Events, usually given by the OS or here by QT, to a MITK internal EventId. //## It loads all information from the xml-file (possible, understandable Events with the mitkEventID). //## If an event appears, the method MapEvent is called with the event params. //## This Method looks up the event params, and tries to find an mitkEventId to it. //## If yes, then sends the event and the found ID to the globalStateMachine, which handles all //## further operations of that event. //## For Undo-Mechanism a statechanging StateMachine::HandleEvent is connected to an ObjectEventID and an GroupEventId. //## That way a fine an raw Undo is possible (fine for ObjectID by ObjectID, raw for GroupID for GroupID) //## Here the ObjectEventID gets increased, //## not the GroupEventId(must get increased by a StateMachine, that has the information when a new Group of operation starts) //## @ingroup Interaction class MITK_CORE_EXPORT EventMapper : public vtkXMLParser { public: static EventMapper *New(); vtkTypeMacro(EventMapper,vtkXMLParser); typedef std::vector EventDescriptionVec; typedef std::vector::iterator EventDescriptionVecIter; typedef std::map ConstMap; typedef std::map::iterator ConstMapIter; typedef std::vector< itk::SmartPointer > AddOnVectorType; //##Documentation //## searches the Event in m_EventDescription //## and if included transmits the event to globalInteraction. //## If specified, a custom instance of GlobalInteraction will be used, //## otherwise the method will retrieve the default (singleton) instance. //## the optional parameter should be used in a conference to avoid a //## feedback static bool MapEvent(Event* event, GlobalInteraction* globalInteraction = NULL, int mitkPostedEventID=0 ); //##Documentation //## Searches for the event within stateEvent in the internal map of event descriptions //## If entry found the stateEvent ID is adapted //## maps the Event in m_EventDescription with the ID //## and if found returns true, //## if not found it returns false static bool RefreshStateEvent(StateEvent* stateEvent); //##Documentation //## loads an XML-File containing events and adds definition to internal mapping list //## //## Several files can be loaded. Event descriptions have to be unique or a warning will be displayed. //## If the same file is loaded twice, //## it will only be parsed the first time. //## If a file A, then a file B and then file A is to be loaded, warnings //## will be displayed when loading file A the second time. bool LoadBehavior(std::string fileName); //##Documentation //## loads Events into m_EventDescriptions from xml string //## also involved: EventMapper::startEvent(...) bool LoadBehaviorString(std::string xmlString); //##Documentation //## Try to load standard behavior file "StateMachine.xml" //## //## Search strategy: //## \li try environment variable "MITKCONF" (path to "StateMachine.xml") //## \li try "./StateMachine.xml" //## \li try via source directory (using MITKROOT from cmake-created //## mitkConfig.h) "MITKROOT/Interactions/mitkBaseInteraction/StateMachine.xml" bool LoadStandardBehavior(); //##Documentation //## reads a Tag from an XML-file //## adds Events to m_EventDescription std::string GetStyleName() const; //friendship because of SetStateEvent for computing WorldCoordinates friend class mitk::GlobalInteraction; /** * @brief adds a new EventMapper addon */ void AddEventMapperAddOn(mitk::EventMapperAddOn* newAddOn); /** * @brief removes an EventMapper addon */ void RemoveEventMapperAddOn(mitk::EventMapperAddOn* unusedAddOn); protected: EventMapper(); ~EventMapper(); //##Documentation //##@brief method only for GlobalInteraction to change the Event (from DiplayPositionEvent to PositionEvent) static void SetStateEvent(Event* event); private: //##Documentation //## @brief method used in XLM-Reading; gets called when a start-tag is read void StartElement (const char *elementName, const char **atts); //##Documentation //## @brief reads an XML-String-Attribute std::string ReadXMLStringAttribut( std::string name, const char** atts); //##Documentation //## @brief reads an XML-Integer-Attribute int ReadXMLIntegerAttribut( std::string name, const char** atts ); //##Documentation //## @brief converts the strings given by the XML-Behaviour-File to int inline int convertConstString2ConstInt(std::string input); //static std::string Convert2String(int input); //static std::string Convert2String(double input); //static std::string Convert2String(float input); //##Documentation //## @brief maps the strings to int for convertion from XML-Behaviour-File ConstMap m_EventConstMap; //##Documentation //## @brief stores the information for the connection between QT-Events and the internal EventId. //## gets this information from xml-File static EventDescriptionVec m_EventDescriptions; static std::string m_XmlFileName; static StateEvent m_StateEvent; //##Documentation //## @brief stores the name of the Event-Style loaded static std::string m_StyleName; static const std::string STYLE; static const std::string NAME; static const std::string ID; static const std::string TYPE; static const std::string BUTTON; static const std::string BUTTONSTATE; static const std::string KEY; static const std::string EVENTS; static const std::string EVENT; /** * @brief all available EventMapper addons consisting of one or more input devices */ AddOnVectorType m_AddOnVector; }; } // namespace mitk #endif /* EVENTMAPPER_H_HEADER_INCLUDED_C187864A */ diff --git a/Core/Code/Interactions/mitkStateEvent.h b/Core/Code/Interactions/mitkStateEvent.h index e0b0e5c4dd..a9d5b18568 100644 --- a/Core/Code/Interactions/mitkStateEvent.h +++ b/Core/Code/Interactions/mitkStateEvent.h @@ -1,67 +1,67 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef STATEEVENT_H_HEADER_INCLUDED_C188E5BF #define STATEEVENT_H_HEADER_INCLUDED_C188E5BF #include namespace mitk { class Event; //##Documentation //## @brief Class holding an mitk-event and the mitk-event-number for a statechange //## //## Holds an event, with which a statechange of a statemachine shall be //## done. iD represents the mitk-event-number, event all further necessary information like //## the MousePosition or a key. //## Not derived from event to hold only one object stateevent, pass it to the statemachines, //## set the next event and reuse this object //## @ingroup Interaction class MITK_CORE_EXPORT StateEvent { public: StateEvent(); //##Documentation //## @brief Constructor //## @param id: mitk internal EventID //## @param event: the information about the appeared event - StateEvent(int id, Event const* event = NULL ); + StateEvent(int id, Event const* event = 0 ); ~StateEvent(); //##Documentation //## @brief to set the params and reuse an object void Set(int id, Event const* event); int GetId() const; mitk::Event const* GetEvent() const; private: int m_Id; mitk::Event const* m_Event; }; } // namespace mitk #endif /* STATEEVENT_H_HEADER_INCLUDED_C188E5BF */ diff --git a/Core/Code/Testing/mitkPixelTypeTest.cpp b/Core/Code/Testing/mitkPixelTypeTest.cpp index a66241c710..e363f1eff1 100644 --- a/Core/Code/Testing/mitkPixelTypeTest.cpp +++ b/Core/Code/Testing/mitkPixelTypeTest.cpp @@ -1,74 +1,75 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-10-07 16:14:59 +0200 (Mi, 07 Okt 2009) $ Version: $Revision: 19343 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkTestingMacros.h" #include "mitkPixelType.h" +#include //## Documentation //## main testing method int mitkPixelTypeTest(int /*argc*/, char* /*argv*/[]) { MITK_TEST_BEGIN("PixelTypeTest"); mitk::PixelType ptype( typeid(int) ,5); MITK_TEST_CONDITION_REQUIRED( *ptype.GetTypeId() == typeid(int), "GetTypeId()"); //MITK_TEST_CONDITION_REQUIRED( ptype == typeid(int), "operator =="); MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeId() == NULL, "GetItkTypeId("); MITK_INFO << sizeof(int); MITK_TEST_CONDITION_REQUIRED( ptype.GetBpe() == 8*sizeof(int)*5, "GetBpe()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetNumberOfComponents() == 5, "GetNumberOfComponents()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetBitsPerComponent() == 8*sizeof(int), "GetBitsPerComponent()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeAsString().compare("unknown") == 0, "GetItkTypeAsString()"); { { mitk::PixelType ptype2( ptype); MITK_TEST_CONDITION_REQUIRED( *ptype.GetTypeId() == typeid(int), "ptype2( ptype)- GetTypeId()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeId() == NULL, "ptype2( ptype)-GetItkTypeId("); MITK_TEST_CONDITION_REQUIRED( ptype.GetBpe() == 8*sizeof(int)*5, "ptype2( ptype)-GetBpe()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetNumberOfComponents() == 5, "ptype2( ptype)-GetNumberOfComponents()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetBitsPerComponent() == 8*sizeof(int), "ptype2( ptype)-GetBitsPerComponent()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeAsString().compare("unknown") == 0, "ptype2( ptype)-GetItkTypeAsString()"); } { mitk::PixelType ptype2 = ptype; MITK_TEST_CONDITION_REQUIRED( *ptype.GetTypeId() == typeid(int), "ptype2 = ptype- GetTypeId()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeId() == NULL, "ptype2 = ptype- GetItkTypeId("); MITK_TEST_CONDITION_REQUIRED( ptype.GetBpe() == 8*sizeof(int)*5, "ptype2 = ptype- GetBpe()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetNumberOfComponents() == 5, "ptype2 = ptype- GetNumberOfComponents()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetBitsPerComponent() == 8*sizeof(int), "ptype2 = ptype- GetBitsPerComponent()"); MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeAsString().compare("unknown") == 0, "ptype2 = ptype- GetItkTypeAsString()"); } { mitk::PixelType ptype2 = ptype; MITK_TEST_CONDITION_REQUIRED( ptype == ptype2, "operator =="); //MITK_TEST_CONDITION_REQUIRED( ptype == typeid(int), "operator =="); mitk::PixelType ptype3(typeid(char) ,5); MITK_TEST_CONDITION_REQUIRED( ptype != ptype3, "operator !="); //MITK_TEST_CONDITION_REQUIRED( *ptype3 != typeid(int), "operator !="); } } MITK_TEST_END(); } diff --git a/Modules/IGT/IGTFilters/mitkNavigationData.h b/Modules/IGT/IGTFilters/mitkNavigationData.h index 8c5dfd9e7e..d7ceab42f9 100644 --- a/Modules/IGT/IGTFilters/mitkNavigationData.h +++ b/Modules/IGT/IGTFilters/mitkNavigationData.h @@ -1,204 +1,205 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKNAVIGATIONDATA_H_HEADER_INCLUDED_ #define MITKNAVIGATIONDATA_H_HEADER_INCLUDED_ #include #include +#include #include namespace mitk { /**Documentation * \brief Navigation Data * * This class represents the data object that is passed through the MITK-IGT navigation filter * pipeline. It encapsulates position and orientation of a tracked tool/sensor. Additionally, * it contains a data structure that contains error/plausibility information * * \ingroup IGT */ class MitkIGT_EXPORT NavigationData : public itk::DataObject { public: mitkClassMacro(NavigationData, itk::DataObject); itkNewMacro(Self); /** * \brief Type that holds the position part of the tracking data */ typedef mitk::Point3D PositionType; /** * \brief Type that holds the orientation part of the tracking data */ typedef mitk::Quaternion OrientationType; /** * \brief type that holds the error characterization of the position and orientation measurements */ typedef itk::Matrix CovarianceMatrixType; /** * \brief type that holds the time at which the data was recorded */ typedef double TimeStampType; /** * \brief sets the position of the NavigationData object */ itkSetMacro(Position, PositionType); /** * \brief returns position of the NavigationData object */ itkGetConstMacro(Position, PositionType); /** * \brief sets the orientation of the NavigationData object */ itkSetMacro(Orientation, OrientationType); /** * \brief returns the orientation of the NavigationData object */ itkGetConstMacro(Orientation, OrientationType); /** * \brief returns true if the object contains valid data */ virtual bool IsDataValid() const; /** * \brief sets the dataValid flag of the NavigationData object indicating if the object contains valid data */ itkSetMacro(DataValid, bool); /** * \brief sets the timestamp of the NavigationData object */ itkSetMacro(TimeStamp, TimeStampType); /** * \brief gets the timestamp of the NavigationData object */ itkGetConstMacro(TimeStamp, TimeStampType); /** * \brief sets the HasPosition flag of the NavigationData object */ itkSetMacro(HasPosition, bool); /** * \brief gets the HasPosition flag of the NavigationData object */ itkGetConstMacro(HasPosition, bool); /** * \brief sets the HasOrientation flag of the NavigationData object */ itkSetMacro(HasOrientation, bool); /** * \brief gets the HasOrientation flag of the NavigationData object */ itkGetConstMacro(HasOrientation, bool); /** * \brief sets the 6x6 Error Covariance Matrix of the NavigationData object */ itkSetMacro(CovErrorMatrix, CovarianceMatrixType); /** * \brief gets the 6x6 Error Covariance Matrix of the NavigationData object */ itkGetConstMacro(CovErrorMatrix, CovarianceMatrixType); /** * \brief set the name of the NavigationData object */ itkSetStringMacro(Name); /** * \brief returns the name of the NavigationData object */ itkGetStringMacro(Name); /** * \brief Graft the data and information from one NavigationData to another. * * Copies the content of data into this object. * This is a convenience method to setup a second NavigationData object with all the meta * information of another NavigationData object. * Note that this method is different than just using two * SmartPointers to the same NavigationData object since separate DataObjects are * still maintained. */ virtual void Graft(const DataObject *data); /** * \brief copy meta data of a NavigationData object * * copies all meta data from NavigationData data to this object */ virtual void CopyInformation(const DataObject* data); /** * \brief print object information */ void PrintSelf(std::ostream& os, itk::Indent indent) const; /** * Set the position part of m_CovErrorMatrix to I*error^2 * This means that all position variables are assumed to be independent */ void SetPositionAccuracy(mitk::ScalarType error); /** * Set the orientation part of m_CovErrorMatrix to I*error^2 * This means that all orientation variables are assumed to be independent */ void SetOrientationAccuracy(mitk::ScalarType error); protected: NavigationData(); virtual ~NavigationData(); /** * \brief holds the position part of the tracking data */ PositionType m_Position; /** * \brief holds the orientation part of the tracking data */ OrientationType m_Orientation; /** * \brief A 6x6 covariance matrix parameterizing the Gaussian error * distribution of the measured position and orientation. * * The hasPosition/hasOrientation fields define which entries * are valid. */ CovarianceMatrixType m_CovErrorMatrix; ///< holds the error characterization of the position and orientation /** * \brief defines if position part of m_CovErrorMatrix is valid */ bool m_HasPosition; /** * \brief defines if orientation part of m_CovErrorMatrix is valid */ bool m_HasOrientation; /** * \brief defines if the object contains valid values */ bool m_DataValid; /** * \brief contains the time at which the tracking data was recorded */ TimeStampType m_TimeStamp; /** * \brief name of the navigation data */ std::string m_Name; }; } // namespace mitk #endif /* MITKNAVIGATIONDATA_H_HEADER_INCLUDED_ */ diff --git a/Modules/IGT/IGTTrackingDevices/mitkTrackingTool.h b/Modules/IGT/IGTTrackingDevices/mitkTrackingTool.h index 3d1d5a6512..bb12f14638 100644 --- a/Modules/IGT/IGTTrackingDevices/mitkTrackingTool.h +++ b/Modules/IGT/IGTTrackingDevices/mitkTrackingTool.h @@ -1,58 +1,59 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKTRACKINGTOOL_H_HEADER_INCLUDED_ #define MITKTRACKINGTOOL_H_HEADER_INCLUDED_ #include #include +#include #include #include namespace mitk { /**Documentation * \brief Interface for all Tracking Tools * * Abstract class that defines the methods that are common for all tracking tools. * * \ingroup IGT */ class MitkIGT_EXPORT TrackingTool : public itk::Object { public: mitkClassMacro(TrackingTool, itk::Object); virtual void GetPosition(mitk::Point3D& position) const = 0; ///< returns the current position of the tool as an array of three floats (in the tracking device coordinate system) virtual void GetOrientation(mitk::Quaternion& orientation) const = 0; ///< returns the current orientation of the tool as a quaternion in a mitk::Point4D (in the tracking device coordinate system) virtual bool Enable() = 0; ///< enables the tool, so that it will be tracked virtual bool Disable() = 0; ///< disables the tool, so that it will not be tracked anymore virtual bool IsEnabled() const = 0; ///< returns whether the tool is enabled or disabled virtual bool IsDataValid() const = 0; ///< returns true if the current position data is valid (no error during tracking, tracking error below threshold, ...) virtual float GetTrackingError() const = 0; ///< returns one value that corresponds to the overall tracking error. virtual const char* GetToolName() const; ///< every tool has a name that can be used to identify it. virtual const char* GetErrorMessage() const; ///< if the data is not valid, ErrorMessage should contain a string explaining why it is invalid (the Set-method should be implemented in subclasses, it should not be accessible by the user) protected: TrackingTool(); virtual ~TrackingTool(); std::string m_ToolName; ///< every tool has a name that can be used to identify it. std::string m_ErrorMessage; ///< if a tool is invalid, this member should contain a human readable explanation of why it is invalid itk::FastMutexLock::Pointer m_MyMutex; ///< mutex to control concurrent access to the tool }; } // namespace mitk #endif /* MITKTRACKINGTOOL_H_HEADER_INCLUDED_ */