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/mitkCallbackFromGUIThread.h b/Core/Code/Controllers/mitkCallbackFromGUIThread.h index faa332cd19..6c075c9d1f 100644 --- a/Core/Code/Controllers/mitkCallbackFromGUIThread.h +++ b/Core/Code/Controllers/mitkCallbackFromGUIThread.h @@ -1,205 +1,207 @@ /*========================================================================= 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_CALLBACK_WITHIN_GUI_TREAD_H_INCLUDGEWQ #define MITK_CALLBACK_WITHIN_GUI_TREAD_H_INCLUDGEWQ #include -#include +#pragma GCC visibility push(default) +#include +#pragma GCC visibility pop #include namespace mitk { /*! \brief Used by CallbackFromGUIThread to pass parameters. */ template class CallbackEventOneParameter : public itk::AnyEvent { public: typedef CallbackEventOneParameter Self; typedef itk::AnyEvent Superclass; CallbackEventOneParameter(const T t ) : m_Data(t) {} virtual ~CallbackEventOneParameter() {} virtual const char * GetEventName() const { return "CallbackEventOneParameter"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_Data ); } const T GetData() const { return m_Data; } CallbackEventOneParameter(const Self& s) : itk::AnyEvent(s), m_Data(s.m_Data) {}; protected: const T m_Data; private: void operator=(const Self&); }; /*! \brief Toolkit specific implementation of mitk::CallbackFromGUIThread For any toolkit, this class has to be sub-classed. One instance of that sub-class has to be registered with mitk::CallbackFromGUIThread. See the (very simple) implmentation of QmitkCallbackFromGUIThread for an example. */ class MITK_CORE_EXPORT CallbackFromGUIThreadImplementation { public: /// Change the current application cursor virtual void CallThisFromGUIThread(itk::Command*, itk::EventObject*) = 0; virtual ~CallbackFromGUIThreadImplementation() {}; protected: private: }; /*! \brief Allows threads to call some method from within the GUI thread. This class is useful for use with GUI toolkits that are not thread-safe, e.g. Qt. Any thread that needs to work with the GUI at some time during its execution (e.g. at the end, to display some results) can use this class to ask for a call to a member function from the GUI thread. Usage example We assume that you have a class ThreadedClass, that basically lives in a thread that is different from the GUI thread. Now this class has to change some element of the GUI to indicate its status. This could be dangerous (with Qt it is for sure). The solution is, that ThreadedClass asks mitk::CallbackFromGUIThread to call a method from the GUI thread (main thread). Here is part of the header of ThreadedClass: \code class ThreadedClass : public ParentClass { public: ... // All you need // This function runs in its own thread ! void ThreadedFunction(); // This should be called from the GUI thread void ChangeGUIElementsToIndicateProgress(const itk::EventObject&); ... }; \endcode \code #include "mitkCallbackFromGUIThread.h" #include // This method runs in a thread of its own! So it can't manipulate GUI elements directly without causing trouble void ThreadedClass::ThreadedFunction() { ... // Create a command object (passing parameters comes later) itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); command->SetCallbackFunction(this, &ThreadedClass::ChangeGUIElementsToIndicateProgress); // Ask to execute that command from the GUI thread mitk::CallbackFromGUIThread::GetInstance()->CallThisFromGUIThread(command); ... } // Do dangerous GUI changing stuff here void ThreadedClass::ChangeGUIElementsToIndicateProgress(const itk::EventObject& e) { Application::GetButtonGrid()->AddButton("Stop"); // this is pseudo code } \endcode This obviously won't allow you to pass parameters to ChangeGUIElementsToIndicateProgress. If you need to do that, you have to create a kind of itk::EventObject that can be asked for a parameter (this solution is not nice, if you see a better solution, please mail to mitk-users@lists.sourceforge.net). The itk::EventObject has to be created with "new" (which can also be done by calling MakeObject on an existing EventObject). \code const mitk::OneParameterEvent* event = new mitk::OneParameterEvent(1); // this class is not yet defined but will be itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); command->SetCallbackFunction(this, &ThreadedClass::ChangeGUIElementsToIndicateProgress); mitk::CallbackFromGUIThread::GetInstance()->CallThisFromGUIThread(command, event); // DO NOT delete event now. This will be done by CallThisFromGUIThread after the command will executed. \endcode \todo Create a set of "normal" parameter-event-objects that people might want to use. */ class MITK_CORE_EXPORT CallbackFromGUIThread { public: /// This class is a singleton. static CallbackFromGUIThread* GetInstance(); /// To be called by a toolkit specific CallbackFromGUIThreadImplementation. static void RegisterImplementation(CallbackFromGUIThreadImplementation* implementation); /// Change the current application cursor void CallThisFromGUIThread(itk::Command*, itk::EventObject* e = NULL); protected: /// Purposely hidden - singleton CallbackFromGUIThread(); private: static CallbackFromGUIThreadImplementation* m_Implementation; static CallbackFromGUIThread* m_Instance; }; } // namespace #endif diff --git a/Core/Code/Controllers/mitkFocusManager.h b/Core/Code/Controllers/mitkFocusManager.h index 8eb557e041..0fecea1562 100755 --- a/Core/Code/Controllers/mitkFocusManager.h +++ b/Core/Code/Controllers/mitkFocusManager.h @@ -1,148 +1,150 @@ /*========================================================================= 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 MITKFOCUSMANAGER_H_HEADER_INCLUDED_C135A197 #define MITKFOCUSMANAGER_H_HEADER_INCLUDED_C135A197 #include #include "mitkBaseRenderer.h" #include +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop namespace mitk { //##Documentation //## @brief manages a list of BaseRenderer. //## //## A focuspointer can be set and read. //## GoToNext can be used to switch through the list. //## if the switch m_Loop is set to true, GetNext loops through the list; after //## the last it goes to the first. //## if it is not set, it returnes NULL if it steps behind the last Widget. //## @ingroup Interaction class MITK_CORE_EXPORT FocusManager : public itk::Object { public: mitkClassMacro(FocusManager, itk::Object); itkNewMacro(Self); //##Documentation //##@brief Element, that can be focused and held here. //## //## has to be an itk-Objekct in order to use itk-Smartpointer! typedef mitk::BaseRenderer FocusElement; typedef itk::WeakPointer FocusElementWeakPointer; typedef std::vector FocusElementList; typedef std::vector::iterator FocusListIterator; //##Documentation //## Destructor ~FocusManager(); //##Documentation //## Adds the widget into the set of managed Widgets after the focused //## widget and sets the focus to the added one if the list was empty before bool AddElement(FocusElement* element); //##Documentation //## removes the given widget from the list. //## true if found and removed, else false //## afterwards the focused widget is the one behind the deleted //## or if the deleted was the last, then the one before the deleted //## that way you can delete sequentialy from the back on or from front to back bool RemoveElement(FocusElement* element); //##Documentation //## returns the focused Widget FocusElement* GetFocused() const; //##Documentation //## searches the given Widget in List; //## if found, sets the focus to this widget and returns true bool SetFocused(FocusElement* element); //##Documentation //## returns, if this focused widget points behind the end of the List bool IsLast(); //##Documentation //## returns true, if the focused widget is the first in the list bool IsFirst(); //##Documentation //## returns the first widget in list const FocusElement* GetFirst() const; //##Documentation //## returns the last widget in list const FocusElement* GetLast() const; //##Documentation //## sets the focus to the next in list //## loops the list, if switch loop is true //## returns true if successful, else false bool GoToNext(); //##Documentation //## returns an iterator, that points to the //## beginning of the list //## no changes are made to the current focused element FocusListIterator GetIter(); //##Documentation //## Sets the LoopMode. //## if set to true-> the one after the last is the first void SetLoop(bool loop); friend class GlobalInteraction; protected: //##Documentation //## Constructor FocusManager(); private: //##Documentation //## stores the Widgets FocusElementList m_FocusList; //##Documentation //## holds the focused Widget itk::WeakPointer m_FocElement; //##Documentation //## switch which sets the LoopMode. //## if true, then the next after the last one is the first bool m_Loop; }; #pragma GCC visibility push(default) //##Documentation //## @brief connect to this Event to get noticed when the focus changes itkEventMacro( FocusEvent , itk::AnyEvent ); #pragma GCC visibility pop } // namespace mitk #endif /* MITKFOCUSMANAGER_H_HEADER_INCLUDED_C135A197 */ diff --git a/Core/Code/Controllers/mitkLimitedLinearUndo.h b/Core/Code/Controllers/mitkLimitedLinearUndo.h index 4752bbaecf..b7fcd6afac 100644 --- a/Core/Code/Controllers/mitkLimitedLinearUndo.h +++ b/Core/Code/Controllers/mitkLimitedLinearUndo.h @@ -1,143 +1,145 @@ /*========================================================================= 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 LIMITEDLINEARUNDO_H_HEADER_INCLUDED_C16E9C96 #define LIMITEDLINEARUNDO_H_HEADER_INCLUDED_C16E9C96 // MITK header #include #include "mitkOperationEvent.h" #include "mitkUndoModel.h" // STL header #include // ITK header -#include +#pragma GCC visibility push(default) +#include +#pragma GCC visibility pop namespace mitk { //##Documentation //## @brief A linear undo model with one undo and one redo stack. //## //## Derived from UndoModel AND itk::Object. Invokes ITK-events to signal listening //## GUI elements, whether each of the stacks is empty or not (to enable/disable button, ...) class MITK_CORE_EXPORT LimitedLinearUndo : public UndoModel { public: typedef std::vector UndoContainer; typedef std::vector::reverse_iterator UndoContainerRevIter; mitkClassMacro(LimitedLinearUndo, UndoModel); itkNewMacro(Self); virtual bool SetOperationEvent(UndoStackItem* stackItem); //##Documentation //## @brief Undoes the last changes //## //## Reads the top element of the Undo-Stack, //## executes the operation, //## swaps the OperationEvent-Undo with the Operation //## and sets it to Redo-Stack virtual bool Undo(); virtual bool Undo(bool); //##Documentation //## @brief Undoes all changes until ObjectEventID oeid virtual bool Undo(int oeid); //##Documentation //## @brief Undoes the last changes //## //## Reads the top element of the Redo-Stack, //## executes the operation, //## swaps the OperationEvent-Operation with the Undo-Operation //## and sets it to Undo-Stack virtual bool Redo(); virtual bool Redo(bool); //##Documentation //## @brief Redoes all changes until ObjectEventID oeid virtual bool Redo(int oeid); //##Documentation //## @brief Clears UndoList and RedoList virtual void Clear(); //##Documentation //## @brief Clears the RedoList virtual void ClearRedoList(); //##Documentation //## @brief True, if RedoList is empty virtual bool RedoListEmpty(); //##Documentation //## @brief Returns the ObjectEventId of the //## top element in the OperationHistory virtual int GetLastObjectEventIdInList(); //##Documentation //## @brief Returns the GroupEventId of the //## top element in the OperationHistory virtual int GetLastGroupEventIdInList(); //##Documentation //## @brief Returns the last specified OperationEvent in Undo-list //## corresponding to the given values; if nothing found, then returns NULL virtual OperationEvent* GetLastOfType(OperationActor* destination, OperationType opType); protected: //##Documentation //## Constructor LimitedLinearUndo(); //##Documentation //## Destructor virtual ~LimitedLinearUndo(); //## @brief Convenience method to free the memory of //## elements in the list and to clear the list void ClearList(UndoContainer* list); UndoContainer m_UndoList; UndoContainer m_RedoList; private: int FirstObjectEventIdOfCurrentGroup(UndoContainer& stack); }; #pragma GCC visibility push(default) /// Some itk events to notify listening GUI elements, when the undo or redo stack is empty (diable undo button) /// or when there are items in the stack (enable button) itkEventMacro( UndoStackEvent, itk::ModifiedEvent ); itkEventMacro( UndoEmptyEvent, UndoStackEvent ); itkEventMacro( RedoEmptyEvent, UndoStackEvent ); itkEventMacro( UndoNotEmptyEvent, UndoStackEvent ); itkEventMacro( RedoNotEmptyEvent, UndoStackEvent ); /// Additional unused events, if anybody wants to put an artificial limit to the possible number of items in the stack itkEventMacro( UndoFullEvent, UndoStackEvent ); itkEventMacro( RedoFullEvent, UndoStackEvent ); #pragma GCC visibility pop } //namespace mitk #endif /* LIMITEDLINEARUNDO_H_HEADER_INCLUDED_C16E9C96 */ diff --git a/Core/Code/Controllers/mitkSliceNavigationController.h b/Core/Code/Controllers/mitkSliceNavigationController.h index f6954751fc..74bf7bc9c4 100644 --- a/Core/Code/Controllers/mitkSliceNavigationController.h +++ b/Core/Code/Controllers/mitkSliceNavigationController.h @@ -1,510 +1,512 @@ /*========================================================================= 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 SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F #define SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F #include #include "mitkBaseController.h" #include "mitkRenderingManager.h" #include "mitkTimeSlicedGeometry.h" #include "mitkMessage.h" +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include #include #include namespace mitk { #define mitkTimeSlicedGeometryEventMacro( classname , super ) \ class MITK_CORE_EXPORT classname : public super { \ public: \ typedef classname Self; \ typedef super Superclass; \ classname(TimeSlicedGeometry* aTimeSlicedGeometry, unsigned int aPos) \ : Superclass(aTimeSlicedGeometry, aPos) {} \ virtual ~classname() {} \ virtual const char * GetEventName() const { return #classname; } \ virtual bool CheckEvent(const ::itk::EventObject* e) const \ { return dynamic_cast(e); } \ virtual ::itk::EventObject* MakeObject() const \ { return new Self(GetTimeSlicedGeometry(), GetPos()); } \ private: \ void operator=(const Self&); \ } class PlaneGeometry; class Geometry3D; class BaseRenderer; /** * \brief Controls the selection of the slice the associated BaseRenderer * will display * * A SliceNavigationController takes a Geometry3D as input world geometry * (TODO what are the exact requirements?) and generates a TimeSlicedGeometry * as output. The TimeSlicedGeometry holds a number of SlicedGeometry3Ds and * these in turn hold a series of Geometry2Ds. One of these Geometry2Ds is * selected as world geometry for the BaseRenderers associated to 2D views. * * The SliceNavigationController holds has Steppers (one for the slice, a * second for the time step), which control the selection of a single * Geometry2D from the TimeSlicedGeometry. SliceNavigationController generates * ITK events to tell observers, like a BaseRenderer, when the selected slice * or timestep changes. * * SliceNavigationControllers are registered as listeners to GlobalInteraction * by the QmitkStdMultiWidget. In ExecuteAction, the controllers react to * PositionEvents by setting the steppers to the slice which is nearest to the * point of the PositionEvent. * * Example: * \code * // Initialization * sliceCtrl = mitk::SliceNavigationController::New(); * * // Tell the navigator the geometry to be sliced (with geometry a * // Geometry3D::ConstPointer) * sliceCtrl->SetInputWorldGeometry(geometry.GetPointer()); * * // Tell the navigator in which direction it shall slice the data * sliceCtrl->SetViewDirection(mitk::SliceNavigationController::Transversal); * * // Connect one or more BaseRenderer to this navigator, i.e.: events sent * // by the navigator when stepping through the slices (e.g. by * // sliceCtrl->GetSlice()->Next()) will be received by the BaseRenderer * // (in this example only slice-changes, see also ConnectGeometryTimeEvent * // and ConnectGeometryEvents.) * sliceCtrl->ConnectGeometrySliceEvent(renderer.GetPointer()); * * //create a world geometry and send the information to the connected renderer(s) * sliceCtrl->Update(); * \endcode * * * You can connect visible navigators to a SliceNavigationController, e.g., a * QmitkSliderNavigator (for Qt): * * \code * // Create the visible navigator (a slider with a spin-box) * QmitkSliderNavigator* navigator = * new QmitkSliderNavigator(parent, "slidernavigator"); * * // Connect the navigator to the slice-stepper of the * // SliceNavigationController. For initialization (position, mininal and * // maximal values) the values of the SliceNavigationController are used. * // Thus, accessing methods of a navigator is normally not necessary, since * // everything can be set via the (Qt-independent) SliceNavigationController. * // The QmitkStepperAdapter converts the Qt-signals to Qt-independent * // itk-events. * new QmitkStepperAdapter(navigator, sliceCtrl->GetSlice(), "navigatoradaptor"); * \endcode * * If you do not want that all renderwindows are updated when a new slice is * selected, you can use a specific RenderingManager, which updates only those * renderwindows that should be updated. This is sometimes useful when a 3D view * does not need to be updated when the slices in some 2D views are changed. * QmitkSliderNavigator (for Qt): * * \code * // create a specific RenderingManager * mitk::RenderingManager::Pointer myManager = mitk::RenderingManager::New(); * * // tell the RenderingManager to update only renderwindow1 and renderwindow2 * myManager->AddRenderWindow(renderwindow1); * myManager->AddRenderWindow(renderwindow2); * * // tell the SliceNavigationController of renderwindow1 and renderwindow2 * // to use the specific RenderingManager instead of the global one * renderwindow1->GetSliceNavigationController()->SetRenderingManager(myManager); * renderwindow2->GetSliceNavigationController()->SetRenderingManager(myManager); * \endcode * * \todo implement for non-evenly-timed geometry! * \ingroup NavigationControl */ class MITK_CORE_EXPORT SliceNavigationController : public BaseController { public: mitkClassMacro(SliceNavigationController,BaseController); itkNewMacro(Self); mitkNewMacro1Param(Self, const char *); /** * \brief Possible view directions, \a Original will uses * the Geometry2D instances in a SlicedGeometry3D provided * as input world geometry (by SetInputWorldGeometry). */ enum ViewDirection{Transversal, Sagittal, Frontal, Original}; /** * \brief Set the input world geometry out of which the * geometries for slicing will be created. */ void SetInputWorldGeometry(const mitk::Geometry3D* geometry); itkGetConstObjectMacro(InputWorldGeometry, mitk::Geometry3D); /** * \brief Access the created geometry */ itkGetConstObjectMacro(CreatedWorldGeometry, mitk::Geometry3D); /** * \brief Set the desired view directions * * \sa ViewDirection * \sa Update(ViewDirection viewDirection, bool top = true, * bool frontside = true, bool rotated = false) */ itkSetEnumMacro(ViewDirection, ViewDirection); itkGetEnumMacro(ViewDirection, ViewDirection); /** * \brief Set the default view direction * * This is used to re-initialize the view direction of the SNC to the * default value with SetViewDirectionToDefault() * * \sa ViewDirection * \sa Update(ViewDirection viewDirection, bool top = true, * bool frontside = true, bool rotated = false) */ itkSetEnumMacro(DefaultViewDirection, ViewDirection); itkGetEnumMacro(DefaultViewDirection, ViewDirection); virtual void SetViewDirectionToDefault(); /** * \brief Do the actual creation and send it to the connected * observers (renderers) * */ virtual void Update(); /** * \brief Extended version of Update, additionally allowing to * specify the direction/orientation of the created geometry. * */ virtual void Update(ViewDirection viewDirection, bool top = true, bool frontside = true, bool rotated = false); /** * \brief Send the created geometry to the connected * observers (renderers) * * Called by Update(). */ virtual void SendCreatedWorldGeometry(); /** * \brief Tell observers to re-read the currently selected 2D geometry * * Called by mitk::SlicesRotator during rotation. */ virtual void SendCreatedWorldGeometryUpdate(); /** * \brief Send the currently selected slice to the connected * observers (renderers) * * Called by Update(). */ virtual void SendSlice(); /** * \brief Send the currently selected time to the connected * observers (renderers) * * Called by Update(). */ virtual void SendTime(); /** * \brief Set the RenderingManager to be used * * If \a NULL, the default RenderingManager will be used. */ itkSetObjectMacro(RenderingManager, RenderingManager); mitk::RenderingManager* GetRenderingManager() const; #pragma GCC visibility push(default) itkEventMacro( UpdateEvent, itk::AnyEvent ); #pragma GCC visibility pop class MITK_CORE_EXPORT TimeSlicedGeometryEvent : public itk::AnyEvent { public: typedef TimeSlicedGeometryEvent Self; typedef itk::AnyEvent Superclass; TimeSlicedGeometryEvent( TimeSlicedGeometry* aTimeSlicedGeometry, unsigned int aPos) : m_TimeSlicedGeometry(aTimeSlicedGeometry), m_Pos(aPos) {} virtual ~TimeSlicedGeometryEvent() {} virtual const char * GetEventName() const { return "TimeSlicedGeometryEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self(m_TimeSlicedGeometry, m_Pos); } TimeSlicedGeometry* GetTimeSlicedGeometry() const { return m_TimeSlicedGeometry; } unsigned int GetPos() const { return m_Pos; } private: TimeSlicedGeometry::Pointer m_TimeSlicedGeometry; unsigned int m_Pos; // TimeSlicedGeometryEvent(const Self&); void operator=(const Self&); //just hide }; mitkTimeSlicedGeometryEventMacro( GeometrySendEvent,TimeSlicedGeometryEvent ); mitkTimeSlicedGeometryEventMacro( GeometryUpdateEvent, TimeSlicedGeometryEvent ); mitkTimeSlicedGeometryEventMacro( GeometryTimeEvent, TimeSlicedGeometryEvent ); mitkTimeSlicedGeometryEventMacro( GeometrySliceEvent, TimeSlicedGeometryEvent ); template void ConnectGeometrySendEvent(T* receiver) { typedef typename itk::ReceptorMemberCommand::Pointer ReceptorMemberCommandPointer; ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand::New(); eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometry); AddObserver(GeometrySendEvent(NULL,0), eventReceptorCommand); } template void ConnectGeometryUpdateEvent(T* receiver) { typedef typename itk::ReceptorMemberCommand::Pointer ReceptorMemberCommandPointer; ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand::New(); eventReceptorCommand->SetCallbackFunction(receiver, &T::UpdateGeometry); AddObserver(GeometryUpdateEvent(NULL,0), eventReceptorCommand); } template void ConnectGeometrySliceEvent(T* receiver, bool connectSendEvent=true) { typedef typename itk::ReceptorMemberCommand::Pointer ReceptorMemberCommandPointer; ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand::New(); eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometrySlice); AddObserver(GeometrySliceEvent(NULL,0), eventReceptorCommand); if(connectSendEvent) ConnectGeometrySendEvent(receiver); } template void ConnectGeometryTimeEvent(T* receiver, bool connectSendEvent=true) { typedef typename itk::ReceptorMemberCommand::Pointer ReceptorMemberCommandPointer; ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand::New(); eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometryTime); AddObserver(GeometryTimeEvent(NULL,0), eventReceptorCommand); if(connectSendEvent) ConnectGeometrySendEvent(receiver); } template void ConnectGeometryEvents(T* receiver) { //connect sendEvent only once ConnectGeometrySliceEvent(receiver, false); ConnectGeometryTimeEvent(receiver); } Message<> crosshairPositionEvent; /** * \brief To connect multiple SliceNavigationController, we can * act as an observer ourselves: implemented interface * \warning not implemented */ virtual void SetGeometry(const itk::EventObject & geometrySliceEvent); /** * \brief To connect multiple SliceNavigationController, we can * act as an observer ourselves: implemented interface */ virtual void SetGeometrySlice(const itk::EventObject & geometrySliceEvent); /** * \brief To connect multiple SliceNavigationController, we can * act as an observer ourselves: implemented interface */ virtual void SetGeometryTime(const itk::EventObject & geometryTimeEvent); /** \brief Positions the SNC according to the specified point */ void SelectSliceByPoint( const mitk::Point3D &point ); /** \brief Returns the TimeSlicedGeometry created by the SNC. */ const mitk::TimeSlicedGeometry *GetCreatedWorldGeometry(); /** \brief Returns the Geometry3D of the currently selected time step. */ const mitk::Geometry3D *GetCurrentGeometry3D(); /** \brief Returns the currently selected Plane in the current * Geometry3D (if existent). */ const mitk::PlaneGeometry *GetCurrentPlaneGeometry(); /** \brief Sets the BaseRenderer associated with this SNC (if any). While * the BaseRenderer is not directly used by SNC, this is a convenience * method to enable BaseRenderer access via the SNC. */ void SetRenderer( BaseRenderer *renderer ); /** \brief Gets the BaseRenderer associated with this SNC (if any). While * the BaseRenderer is not directly used by SNC, this is a convenience * method to enable BaseRenderer access via the SNC. Returns NULL if no * BaseRenderer has been specified*/ BaseRenderer *GetRenderer() const; /** \brief Re-orients the slice stack to include the plane specified by * the given point an normal vector. */ void ReorientSlices( const mitk::Point3D &point, const mitk::Vector3D &normal ); virtual bool ExecuteAction( Action* action, mitk::StateEvent const* stateEvent); void ExecuteOperation(Operation* operation); /** * \brief Feature option to lock planes during mouse interaction. * This option flag disables the mouse event which causes the center * cross to move near by. */ itkSetMacro(SliceLocked, bool); itkGetMacro(SliceLocked, bool); itkBooleanMacro(SliceLocked); /** * \brief Feature option to lock slice rotation. * * This option flag disables separately the rotation of a slice which is * implemented in mitkSliceRotator. */ itkSetMacro(SliceRotationLocked, bool); itkGetMacro(SliceRotationLocked, bool); itkBooleanMacro(SliceRotationLocked); /** * \brief Adjusts the numerical range of the slice stepper according to * the current geometry orientation of this SNC's SlicedGeometry. */ void AdjustSliceStepperRange(); protected: SliceNavigationController(const char * type = NULL); virtual ~SliceNavigationController(); template static void buildstring( mitkIpPicDescriptor *pic, itk::Point p, std::string &s, T = 0) { std::string value; std::stringstream stream; stream.imbue(std::locale::classic()); stream<=0 && p[1] >=0 && p[2]>=0) && (unsigned int)p[0] < pic->n[0] && (unsigned int)p[1] < pic->n[1] && (unsigned int)p[2] < pic->n[2] ) { if(pic->bpe!=24) { stream<<(((T*) pic->data)[ p[0] + p[1]*pic->n[0] + p[2]*pic->n[0]*pic->n[1] ]); } else { stream<<(((T*) pic->data)[p[0]*3 + 0 + p[1]*pic->n[0]*3 + p[2]*pic->n[0]*pic->n[1]*3 ]); stream<<(((T*) pic->data)[p[0]*3 + 1 + p[1]*pic->n[0]*3 + p[2]*pic->n[0]*pic->n[1]*3 ]); stream<<(((T*) pic->data)[p[0]*3 + 2 + p[1]*pic->n[0]*3 + p[2]*pic->n[0]*pic->n[1]*3 ]); } s = stream.str(); } else { s+= "point out of data"; } }; mitk::Geometry3D::ConstPointer m_InputWorldGeometry; mitk::Geometry3D::Pointer m_ExtendedInputWorldGeometry; mitk::TimeSlicedGeometry::Pointer m_CreatedWorldGeometry; ViewDirection m_ViewDirection; ViewDirection m_DefaultViewDirection; mitk::RenderingManager::Pointer m_RenderingManager; mitk::BaseRenderer *m_Renderer; itkSetMacro(Top, bool); itkGetMacro(Top, bool); itkBooleanMacro(Top); itkSetMacro(FrontSide, bool); itkGetMacro(FrontSide, bool); itkBooleanMacro(FrontSide); itkSetMacro(Rotated, bool); itkGetMacro(Rotated, bool); itkBooleanMacro(Rotated); bool m_Top; bool m_FrontSide; bool m_Rotated; bool m_BlockUpdate; bool m_SliceLocked; bool m_SliceRotationLocked; unsigned int m_OldPos; }; } // namespace mitk #endif /* SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F */ diff --git a/Core/Code/Controllers/mitkSlicesRotator.h b/Core/Code/Controllers/mitkSlicesRotator.h index 25586ec26b..a707ebdf8b 100644 --- a/Core/Code/Controllers/mitkSlicesRotator.h +++ b/Core/Code/Controllers/mitkSlicesRotator.h @@ -1,109 +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 SLICESROTATOR_H_HEADER_INCLUDED_C1C55A2F #define SLICESROTATOR_H_HEADER_INCLUDED_C1C55A2F #include +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include namespace mitk { /** * \brief Enables rotation of visible slices (for sliced geometries). * \ingroup NavigationControl * * This class takes care of several SliceNavigationControllers and handles * slice selection / slice rotation. It is added as listener to * GlobalInteraction by QmitkStdMultiWidget. * * The SlicesRotator class adds the possibility of slice rotation to the * "normal" behaviour of SliceNavigationControllers. This additional class * is needed, because one has to be aware of several "visible slices" * (selected Geometry2Ds of some SliceNavigationControllers) in order to * choose between rotation and slice selection. * * Rotation is achieved by modifying (rotating) the generated * TimeSlicedGeometry of the corresponding SliceNavigationController. * * With SlicesRotator, the rule to choose between slice rotation and * selection is simple: For a mouse down event, count the number of visible * planes, which are "near" the cursor. If this number equals 2 (one for the * window, which currently holds the cursor, one for the intersection line of * another visible slice), then initiate rotation, else select slices near * the cursor. If "LinkPlanes" is set to true, the rotation is applied to the * planes of all registered SNCs, not only of the one associated with the * directly selected plane. * * In contrast to the situation without the SlicesRotator, the * SliceNavigationControllers are now not directly registered as listeners to * GlobalInteraction. SlicesRotator is registered as a listener and decides * whether something should be rotated or whether another slice should be * selected. In the latter case, a PositionEvent is just forwarded to the * SliceNavigationController. * * \sa SlicesSwiveller */ class MITK_CORE_EXPORT SlicesRotator : public SlicesCoordinator { public: mitkClassMacro(SlicesRotator, SlicesCoordinator); static Pointer New(); /** * @brief New Macro with one parameter for creating this object with static New(..) method **/ mitkNewMacro1Param(Self, const char*); virtual void SetGeometry(const itk::EventObject& EventObject); virtual void RotateToPoint( SliceNavigationController *rotationPlaneSNC, SliceNavigationController *rotatedPlaneSNC, const Point3D &point, bool linked = false ); protected: SlicesRotator(const char* machine); // clear list of controllers virtual ~SlicesRotator(); // check if the slices of this SliceNavigationController can be rotated (???) Possible virtual void OnSliceControllerAdded(SliceNavigationController* snc); virtual void OnSliceControllerRemoved(SliceNavigationController* snc); virtual void UpdateRelevantSNCs(); virtual bool ExecuteAction(Action * action, StateEvent const* stateEvent); SNCVector m_RelevantSNCs; /// all SNCs that currently have CreatedWorldGeometries, that can be rotated. SNCVector m_SNCsToBeRotated; /// all SNCs that will be rotated Point3D m_LastCursorPosition; Point3D m_CenterOfRotation; }; } // namespace #endif diff --git a/Core/Code/Controllers/mitkSlicesSwiveller.h b/Core/Code/Controllers/mitkSlicesSwiveller.h index d005e16792..08f4e983f5 100644 --- a/Core/Code/Controllers/mitkSlicesSwiveller.h +++ b/Core/Code/Controllers/mitkSlicesSwiveller.h @@ -1,118 +1,120 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 7707 $ 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 SLICESSWIVELLER_H_HEADER_INCLUDED #define SLICESSWIVELLER_H_HEADER_INCLUDED #include #include +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop namespace mitk { /** * \brief Enables arbitrary rotation of visible slices around a swivel point * (for sliced geometries). * \ingroup NavigationControl * * This class takes care of several SliceNavigationControllers and handles * slice selection / slice rotation. It is added as listener to * GlobalInteraction by QmitkStdMultiWidget. * * The SlicesSwiveller class adds the possibility of slice rotation to the * "normal" behaviour of SliceNavigationControllers. This additional class * is needed, because one has to be aware of several "visible slices" * (selected Geometry2Ds of some SliceNavigationControllers) in order to * choose between rotation and slice selection. * * Rotation is achieved by modifying (rotating) the generated * TimeSlicedGeometry of the corresponding SliceNavigationController. * * With SlicesSwiveller, slice rotation works as follows: the user clicks onto * a 2D view (2D plane) and drags the mouse; the relative direction and angle * of the dragged mouse movement directly effects the rotation axis and * angle. If "LinkPlanes" is set to true, the rotation is applied to the * planes of all registered SNCs, not only of the one associated with the * plane clicked on. * * In contrast to the situation without the SlicesRotator, the * SliceNavigationControllers are now not directly registered as listeners to * GlobalInteraction. SlicesRotator is registered as a listener and decides * whether something should be rotated or whether another slice should be * selected. In the latter case, a PositionEvent is just forwarded to the * SliceNavigationController. * * \sa SlicesRotator */ class MITK_CORE_EXPORT SlicesSwiveller : public SlicesCoordinator { public: mitkClassMacro(SlicesSwiveller, SlicesCoordinator); static Pointer New(); /** * @brief New Macro with one parameter for creating this object with static New(..) method **/ mitkNewMacro1Param(Self, const char*); virtual void SetGeometry(const itk::EventObject& EventObject); protected: SlicesSwiveller(const char* machine); // clear list of controllers virtual ~SlicesSwiveller(); // check if the slices of this SliceNavigationController can be rotated (???) Possible virtual void OnSliceControllerAdded(SliceNavigationController* snc); virtual void OnSliceControllerRemoved(SliceNavigationController* snc); virtual void UpdateRelevantSNCs(); virtual bool ExecuteAction(Action * action, StateEvent const* stateEvent); /** All SNCs that currently have CreatedWorldGeometries, that can be rotated */ SNCVector m_RelevantSNCs; /** SNCs that will be rotated (clicked plane + all relevant others, if linked) */ SNCVector m_SNCsToBeRotated; Point3D m_LastCursorPosition; Point3D m_CenterOfRotation; Point2D m_ReferenceCursor; Vector3D m_RotationPlaneNormal; Vector3D m_RotationPlaneXVector; Vector3D m_RotationPlaneYVector; Vector3D m_PreviousRotationAxis; ScalarType m_PreviousRotationAngle; }; } // namespace #endif 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/Modules/MitkExt/IO/mitkPACSPluginEvents.h b/Core/Code/DataManagement/mitkExportMacros.h similarity index 51% copy from Modules/MitkExt/IO/mitkPACSPluginEvents.h copy to Core/Code/DataManagement/mitkExportMacros.h index 61fb2b4949..4362165767 100644 --- a/Modules/MitkExt/IO/mitkPACSPluginEvents.h +++ b/Core/Code/DataManagement/mitkExportMacros.h @@ -1,35 +1,41 @@ /*========================================================================= - + Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ -Version: $Revision: 14120 $ - +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 mitkPACSPluginEventshincluded -#define mitkPACSPluginEventshincluded +=========================================================================*/ -#include -#include -namespace mitk -{ - #pragma GCC visibility push(default) - itkEventMacro( PluginEvent, itk::AnyEvent ); - itkEventMacro( PluginStudySelected, PluginEvent ); - itkEventMacro( PluginLightBoxCountChanged, PluginEvent ); - itkEventMacro( PluginAbortPACSImport, PluginEvent ); - #pragma GCC visibility pop -} +#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/mitkOperation.h b/Core/Code/IO/mitkOperation.h index ef1964f188..a8c085e34d 100644 --- a/Core/Code/IO/mitkOperation.h +++ b/Core/Code/IO/mitkOperation.h @@ -1,67 +1,70 @@ /*========================================================================= 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 OPERATION_H_HEADER_INCLUDED_C16E7D9E #define OPERATION_H_HEADER_INCLUDED_C16E7D9E #include +#pragma GCC visibility push(default) +#include +#pragma GCC visibility pop namespace mitk { typedef int OperationType ; //##Documentation //## @brief Base class of all Operation-classes //## //## @ingroup Undo class MITK_CORE_EXPORT Operation { public: //##Documentation //## Constructor Operation(OperationType operationType); virtual ~Operation(); OperationType GetOperationType(); protected: OperationType m_OperationType; }; class MITK_CORE_EXPORT OperationEndEvent : public itk::EndEvent { public: typedef OperationEndEvent Self; typedef itk::EndEvent Superclass; OperationEndEvent(Operation* operation = NULL) : m_Operation(operation) {} virtual ~OperationEndEvent() {} virtual const char * GetEventName() const { return "OperationEndEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self(m_Operation); } Operation* GetOperation() const { return m_Operation; } private: Operation* m_Operation; OperationEndEvent(const Self&); void operator=(const Self&); }; }//namespace mitk #endif /* OPERATION_H_HEADER_INCLUDED_C16E7D9E */ 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/Rendering/mitkImageMapperGL2D.h b/Core/Code/Rendering/mitkImageMapperGL2D.h index b659b55515..20a79905df 100644 --- a/Core/Code/Rendering/mitkImageMapperGL2D.h +++ b/Core/Code/Rendering/mitkImageMapperGL2D.h @@ -1,298 +1,300 @@ /*========================================================================= 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 MITKIMAGEMAPPER2D_H_HEADER_INCLUDED_C10E906E #define MITKIMAGEMAPPER2D_H_HEADER_INCLUDED_C10E906E #include #include "mitkGLMapper2D.h" #include "mitkBaseRenderer.h" #include #include #include +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include class iil4mitkPicImage; class Vtk2itk; class vtkImageReslice; class vtkLookupTable; class vtkGeneralTransform; class vtkImageChangeInformation; class vtkPoints; class vtkMitkThickSlicesFilter; namespace mitk { /** \brief Mapper to resample and display 2D slices of a 3D image. * * Currently implemented for mapping on PlaneGeometry and * AbstractTransformGeometry. The resulting 2D image (by reslicing the * underlying 3D input image appropriately) can either be directly rendered * in a 2D view or just be calculated to be used later on by another * rendering entity, e.g. in texture mapping in a 3D view. * * This results in a flipped version when used for texture mapping. Furthermore, * not the complete rectangular area described by the Geometry2D from the renderer * is resampled, @em if the Geometry2D is larger than the image dimension in the * requested direction. This results in a stretched version when used for texture * mapping. * * Properties that can be set for images and influence the imageMapper2D are: * * - \b "modality": (mitkModalityProperty) Modality of the image * - \b "opacity": (FloatProperty) Opacity of the image * - \b "color": (ColorProperty) Color of the image * - \b "use color": (BoolProperty) Use the color of the image or not * - \b "binary": (BoolProperty) is the image a binary image or not * - \b "outline binary": (BoolProperty) show outline of the image or not * - \b "texture interpolation": (BoolProperty) texture interpolation of the image * - \b "reslice interpolation": (VtkResliceInterpolationProperty) reslice interpolation of the image * - \b "in plane resample extent by geometry": (BoolProperty) Do it or not * - \b "bounding box": (BoolProperty) Is the Bounding Box of the image shown or not * - \b "layer": (IntProperty) Layer of the image * - \b "volume annotation color": (ColorProperty) color of the volume annotation * - \b "volume annotation unit": (StringProperty) annotation unit as string (does not implicit convert the unit!) unit is ml/cm3 * The default properties are: * - \b "opacity", mitk::FloatProperty::New(0.3f), renderer, overwrite ) * - \b "color", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ) * - \b "use color", mitk::BoolProperty::New( true ), renderer, overwrite ) * - \b "binary", mitk::BoolProperty::New( true ), renderer, overwrite ) * - \b "outline binary", mitk::BoolProperty::New( false ), renderer, overwrite ) * - \b "texture interpolation", mitk::BoolProperty::New( mitk::DataNodeFactory::m_TextureInterpolationActive ) ) * - \b "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() ) * - \b "in plane resample extent by geometry", mitk::BoolProperty::New( false ) ) * - \b "bounding box", mitk::BoolProperty::New( false ) ) * - \b "layer", mitk::IntProperty::New(10), renderer, overwrite) * If the modality-property is set for an image, the mapper uses modality-specific default properties, * e.g. color maps, if they are defined. * \ingroup Mapper */ class MITK_CORE_EXPORT ImageMapperGL2D : public GLMapper2D { public: /** Standard class typedefs. */ mitkClassMacro( ImageMapperGL2D,GLMapper2D ); /** Method for creation through the object factory. */ itkNewMacro(Self); /** Some convenient typedefs. */ typedef mitk::Image InputImageType; typedef InputImageType::Pointer InputImagePointer; typedef InputImageType::ConstPointer InputImageConstPointer; typedef SlicedData::RegionType InputImageRegionType; /** \brief Get the Image to map */ const InputImageType *GetInput(void); /** \brief Calls Update() for all associated renderers. */ virtual void GenerateAllData(); /** \brief Renders the (priorly) resampled image onto the screen. */ virtual void Paint( mitk::BaseRenderer *renderer ); /** \brief Checks whether this mapper needs to update itself and generate * data. */ virtual void Update(mitk::BaseRenderer * renderer); virtual void ApplyProperties(mitk::BaseRenderer* renderer); /** \brief Internal storage class for data needed for rendering into a * renderer */ class MITK_CORE_EXPORT RendererInfo { /** \brief internal id of the renderer the data is stored for */ int m_RendererID; /** \brief stored iil4mitkPicImage containing the texture to display for * 2D rendering (cf. m_Image) */ iil4mitkPicImage* m_iil4mitkImage; mitk::BaseRenderer* m_Renderer; public: /** \brief timestamp of last update of stored data */ itk::TimeStamp m_LastUpdateTime; /** \brief stored data as a mitkIpPicDescriptor */ mitkIpPicDescriptor *m_Pic; /** \brief number of pixels per mm in x- and y-direction of the resampled */ Vector2D m_PixelsPerMM; /** \brief Extent (in pixels) of the image */ Vector2D m_Extent; /** \brief Overlap (in pixels) to ensure coverage of rotated images also */ Vector2D m_Overlap; /** \brief Using unit spacing for resampling makes life easier */ vtkImageChangeInformation *m_UnitSpacingImageFilter; /** \brief The actual reslicer (one per renderer) */ vtkImageReslice *m_Reslicer; /** \brief Thickslices post filtering */ vtkMitkThickSlicesFilter *m_TSFilter; /** \brief Extracted image for 3D rendering (cf. m_iil4mitkImage) */ vtkImageData *m_Image; /** \brief Reference geometry associated with the world geometry */ const Geometry3D *m_ReferenceGeometry; bool m_TextureInterpolation; /** \brief stores the id of the observer for delete event of renderer */ unsigned long m_ObserverID; RendererInfo(); ~RendererInfo(); inline bool IsInitialized() const { return m_RendererID >= 0; } void Initialize( int rendererID, mitk::BaseRenderer *renderer, unsigned long observerID ); void Set_iil4mitkImage(iil4mitkPicImage* iil4mitkImage); inline iil4mitkPicImage* Get_iil4mitkImage() const { return m_iil4mitkImage; } inline int GetRendererID() const { return m_RendererID; } void RemoveObserver(); void Squeeze(); }; // RendererInfo /** \brief Get the internal id of the renderer * \sa RendererInfo */ virtual int GetAssociatedChannelNr( mitk::BaseRenderer *renderer ); /** \brief Get the RendererInfo for \a renderer */ const RendererInfo *GetRendererInfo( mitk::BaseRenderer *renderer ) { return &this->AccessRendererInfo(renderer); } /** \brief Release memory allocated for buffering */ virtual void Clear(); static void SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer = NULL, bool overwrite = false); protected: ImageMapperGL2D(); virtual ~ImageMapperGL2D(); /** Does the actual resampling, without rendering the image yet. */ virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer); /** \brief Get the RendererInfo for @a renderer */ inline RendererInfo & AccessRendererInfo( mitk::BaseRenderer* renderer ) { RendererInfo& rendererInfo = m_RendererInfo[renderer]; if(rendererInfo.IsInitialized()==false) { // Add observer for renderer reset events (RendererInfo will // automatically be removed from list when a Renderer is deleted) // // Note: observer ID is passed to rendererInfo, which will take // responsiblity to remove the observer upon its destruction typedef itk::MemberCommand< ImageMapperGL2D > MemberCommandType; MemberCommandType::Pointer deleteRendererCommand = MemberCommandType::New(); deleteRendererCommand->SetCallbackFunction( this, &ImageMapperGL2D::DeleteRendererCallback ); unsigned long observerID = renderer->AddObserver( BaseRenderer::RendererResetEvent(), deleteRendererCommand ); // Initialize RendererInfo rendererInfo.Initialize( ImageMapperGL2D::numRenderer++, renderer, observerID ); } return rendererInfo; } void DeleteRendererCallback( itk::Object *object, const itk::EventObject & ); double CalculateSpacing( const mitk::Geometry3D *geometry, const mitk::Vector3D &d ) const; bool LineIntersectZero( vtkPoints *points, int p1, int p2, vtkFloatingPointType *bounds ); bool CalculateClippedPlaneBounds( const Geometry3D *boundingGeometry, const PlaneGeometry *planeGeometry, vtkFloatingPointType *bounds ); /** \brief Number of renderers data is stored for * \todo General concept for keeping data for rendering required * \todo static? */ static int numRenderer; protected: typedef std::map RendererInfoMap; /** \brief Map of instances of RendererInfo * \sa RendererInfo */ RendererInfoMap m_RendererInfo; vtkGeneralTransform *m_ComposedResliceTransform; private: int m_iil4mitkMode; }; } // namespace mitk #endif /* MITKIMAGEMAPPER2D_H_HEADER_INCLUDED_C10E906E */ 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/DiffusionImaging/Tractography/itkGlobalTractographyFilter.cpp b/Modules/DiffusionImaging/Tractography/itkGlobalTractographyFilter.cpp index ac150a6dfa..9f13de5ccb 100644 --- a/Modules/DiffusionImaging/Tractography/itkGlobalTractographyFilter.cpp +++ b/Modules/DiffusionImaging/Tractography/itkGlobalTractographyFilter.cpp @@ -1,473 +1,475 @@ #include "itkGlobalTractographyFilter.h" #include #include #include "itkPointShell.h" #include "GlobalTracking/BuildFibres.cpp" +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include #include #include #include #include #include #include "GlobalTracking/reparametrize_arclen2.cpp" #include struct LessDereference { template bool operator()(const T * lhs, const T * rhs) const { return *lhs < *rhs; } }; namespace itk{ template< class TInputOdfImage, class TInputROIImage > GlobalTractographyFilter< TInputOdfImage, TInputROIImage > ::GlobalTractographyFilter(): m_TempStart(0.1), m_TempEnd(0.001), m_NumIt(500000), m_ParticleWeight(0), m_ParticleWidth(0), m_ParticleLength(0), m_ChempotConnection(10), m_ChempotParticle(0), m_InexBalance(0), m_Chempot2(0.2), m_FiberLength(10), m_AbortTracking(false), m_NumConnections(0), m_NumParticles(0), m_NumAcceptedFibers(0), m_CurrentStep(0), m_SubtractMean(true), m_BuildFibers(false), m_Sampler(NULL), m_Steps(10), m_Memory(0), m_ProposalAcceptance(0) { //this->m_MeasurementFrame.set_identity(); this->SetNumberOfRequiredInputs(2); //Filter needs a DWI image + a Mask Image } template< class TInputOdfImage, class TInputROIImage > GlobalTractographyFilter< TInputOdfImage, TInputROIImage > ::~GlobalTractographyFilter(){ delete BESSEL_APPROXCOEFF; if (m_Sampler!=NULL) delete m_Sampler; } template< class TInputOdfImage, class TInputROIImage > void GlobalTractographyFilter< TInputOdfImage, TInputROIImage > ::ComputeFiberCorrelation(){ // float bD = 15; // vnl_matrix_fixed bDir = // *itk::PointShell >::DistributePointShell(); // const int N = QBALL_ODFSIZE; // vnl_matrix_fixed temp = bDir.transpose(); // vnl_matrix_fixed C = temp*bDir; // vnl_matrix_fixed Q = C; // vnl_vector_fixed mean; // for(int i=0; i repMean; // for (int i=0; i P = Q*Q; // std::vector pointer; // pointer.reserve(N*N); // double * start = C.data_block(); // double * end = start + N*N; // for (double * iter = start; iter != end; ++iter) // { // pointer.push_back(iter); // } // std::sort(pointer.begin(), pointer.end(), LessDereference()); // vnl_vector_fixed alpha; // vnl_vector_fixed beta; // for (int i=0; im_Meanval_sq = (sum*sum)/N; // vnl_vector_fixed alpha_0; // vnl_vector_fixed alpha_2; // vnl_vector_fixed alpha_4; // vnl_vector_fixed alpha_6; // for(int i=0; i T; // T.set_column(0,alpha_0); // T.set_column(1,alpha_2); // T.set_column(2,alpha_4); // T.set_column(3,alpha_6); // vnl_vector_fixed coeff = vnl_matrix_inverse(T).pinverse()*beta; // MITK_INFO << "Bessel oefficients: " << coeff; BESSEL_APPROXCOEFF = new float[4]; // BESSEL_APPROXCOEFF[0] = coeff(0); // BESSEL_APPROXCOEFF[1] = coeff(1); // BESSEL_APPROXCOEFF[2] = coeff(2); // BESSEL_APPROXCOEFF[3] = coeff(3); BESSEL_APPROXCOEFF[0] = -0.1714; BESSEL_APPROXCOEFF[1] = 0.5332; BESSEL_APPROXCOEFF[2] = -1.4889; BESSEL_APPROXCOEFF[3] = 2.0389; } // build fibers from tracking result template< class TInputOdfImage, class TInputROIImage > void GlobalTractographyFilter< TInputOdfImage, TInputROIImage > ::BuildFibers(float* points, int numPoints) { MITK_INFO << "Building fibers ..."; typename InputQBallImageType::Pointer odfImage = dynamic_cast(this->GetInput(0)); double spacing[3]; spacing[0] = odfImage->GetSpacing().GetElement(0); spacing[1] = odfImage->GetSpacing().GetElement(1); spacing[2] = odfImage->GetSpacing().GetElement(2); // initialize array of particles CCAnalysis ccana(points, numPoints, spacing); // label the particles according to fiber affiliation and return number of fibers int numFibers = ccana.iterate(m_FiberLength); if (numFibers<=0){ MITK_INFO << "0 fibers accepted"; return; } // fill output datastructure m_FiberBundle.clear(); for (int i = 0; i < numFibers; i++) { vector< Particle* >* particleContainer = ccana.m_FiberContainer->at(i); // resample fibers std::vector< Particle* >* pCon = ResampleFibers(particleContainer, 0.9*spacing[0]); FiberTractType tract; for (int j=0; jsize(); j++) { Particle* particle = pCon->at(j); pVector p = particle->R; itk::Point point; point[0] = p[0]-0.5; point[1] = p[1]-0.5; point[2] = p[2]-0.5; tract.push_back(point); delete(particle); } m_FiberBundle.push_back(tract); delete(pCon); } m_NumAcceptedFibers = numFibers; MITK_INFO << "itkGlobalTractographyFilter: " << numFibers << " fibers accepted"; } // fill output fiber bundle datastructure template< class TInputOdfImage, class TInputROIImage > typename GlobalTractographyFilter< TInputOdfImage, TInputROIImage >::FiberBundleType* GlobalTractographyFilter< TInputOdfImage, TInputROIImage > ::GetFiberBundle() { if (!m_AbortTracking) { m_BuildFibers = true; while (m_BuildFibers){} } return &m_FiberBundle; } // get memory allocated for particle grid template< class TInputOdfImage, class TInputROIImage > float GlobalTractographyFilter< TInputOdfImage, TInputROIImage > ::GetMemoryUsage() { if (m_Sampler!=NULL) return m_Sampler->m_ParticleGrid.GetMemoryUsage(); return 0; } // perform global tracking template< class TInputOdfImage, class TInputROIImage > void GlobalTractographyFilter< TInputOdfImage, TInputROIImage > ::GenerateData(){ // input qball image m_ItkQBallImage = dynamic_cast(this->GetInput(0)); // approximationscoeffizienten der // teilchenkorrelationen im orientierungsraum // 4er vektor ComputeFiberCorrelation(); // image sizes and spacing int qBallImageSize[4] = {QBALL_ODFSIZE, m_ItkQBallImage->GetLargestPossibleRegion().GetSize().GetElement(0), m_ItkQBallImage->GetLargestPossibleRegion().GetSize().GetElement(1), m_ItkQBallImage->GetLargestPossibleRegion().GetSize().GetElement(2)}; double qBallImageSpacing[3] = {m_ItkQBallImage->GetSpacing().GetElement(0),m_ItkQBallImage->GetSpacing().GetElement(1),m_ItkQBallImage->GetSpacing().GetElement(2)}; // make sure image has enough slices if (qBallImageSize[1]<3 || qBallImageSize[2]<3 || qBallImageSize[3]<3) { MITK_INFO << "image size < 3 not supported"; return; } // calculate rotation matrix vnl_matrix_fixed directionMatrix = m_ItkQBallImage->GetDirection().GetVnlMatrix(); vnl_vector_fixed d0 = directionMatrix.get_column(0); d0.normalize(); vnl_vector_fixed d1 = directionMatrix.get_column(1); d1.normalize(); vnl_vector_fixed d2 = directionMatrix.get_column(2); d2.normalize(); directionMatrix.set_column(0, d0); directionMatrix.set_column(1, d1); directionMatrix.set_column(2, d2); vnl_matrix_fixed I = directionMatrix*directionMatrix.transpose(); if(!I.is_identity(mitk::eps)){ MITK_INFO << "Image direction is not a rotation matrix. Tracking not possible!"; return; } // generate local working copy of image buffer int bufferSize = qBallImageSize[0]*qBallImageSize[1]*qBallImageSize[2]*qBallImageSize[3]; float* qBallImageBuffer = (float*) m_ItkQBallImage->GetBufferPointer(); float* workingQballImage = new float[bufferSize]; for (int i=0; i0 && i%qBallImageSize[0] == 0 && i>0) { sum /= qBallImageSize[0]; for (int j=i-qBallImageSize[0]; jGetBufferPointer(); maskImageSize[0] = m_MaskImage->GetLargestPossibleRegion().GetSize().GetElement(0); maskImageSize[1] = m_MaskImage->GetLargestPossibleRegion().GetSize().GetElement(1); maskImageSize[2] = m_MaskImage->GetLargestPossibleRegion().GetSize().GetElement(2); } else { mask = 0; maskImageSize[0] = qBallImageSize[1]; maskImageSize[1] = qBallImageSize[2]; maskImageSize[2] = qBallImageSize[3]; } int mask_oversamp_mult = maskImageSize[0]/qBallImageSize[1]; // load lookuptable ifstream BaryCoords; BaryCoords.open("FiberTrackingLUTBaryCoords.bin", ios::in | ios::binary); float* coords; if (BaryCoords.is_open()) { float tmp; coords = new float [1630818]; BaryCoords.seekg (0, ios::beg); for (int i=0; i<1630818; i++) { BaryCoords.read((char *)&tmp, sizeof(tmp)); coords[i] = tmp; } BaryCoords.close(); } else { MITK_INFO << "Unable to open barycoords file"; return; } ifstream Indices; Indices.open("FiberTrackingLUTIndices.bin", ios::in | ios::binary); int* ind; if (Indices.is_open()) { int tmp; ind = new int [1630818]; Indices.seekg (0, ios::beg); for (int i=0; i<1630818; i++) { Indices.read((char *)&tmp, 4); ind[i] = tmp; } Indices.close(); } else { MITK_INFO << "Unable to open indices file"; return; } // initialize sphere interpolator with lookuptables SphereInterpolator *sinterp = new SphereInterpolator(coords, ind, QBALL_ODFSIZE, 301, 0.5); // get paramters float minSpacing; if(qBallImageSpacing[0]m_NumIt) { MITK_INFO << "not enough iterations!"; return; } unsigned long singleIts = (unsigned long)((1.0*m_NumIt) / (1.0*m_Steps)); // setup metropolis hastings sampler MITK_INFO << "itkGlobalTractographyFilter: setting up MH-sampler"; if (m_Sampler!=NULL) delete m_Sampler; m_Sampler = new RJMCMC(NULL, 0, workingQballImage, qBallImageSize, qBallImageSpacing, cellsize); // setup energy computer MITK_INFO << "itkGlobalTractographyFilter: setting up Energy-computer"; EnergyComputer encomp(workingQballImage,qBallImageSize,qBallImageSpacing,sinterp,&(m_Sampler->m_ParticleGrid),mask,mask_oversamp_mult, directionMatrix); encomp.setParameters(m_ParticleWeight,m_ParticleWidth,m_ChempotConnection*m_ParticleLength*m_ParticleLength,m_ParticleLength,curvatureHardThreshold,m_InexBalance,m_Chempot2); m_Sampler->SetEnergyComputer(&encomp); m_Sampler->SetParameters(m_TempStart,singleIts,m_ParticleLength,curvatureHardThreshold,m_ChempotParticle); // main loop for( int step = 0; step < m_Steps; step++ ) { if (m_AbortTracking) break; m_CurrentStep = step+1; float temperature = m_TempStart * exp(alpha*(((1.0)*step)/((1.0)*m_Steps))); MITK_INFO << "iterating step " << m_CurrentStep; m_Sampler->SetTemperature(temperature); m_Sampler->Iterate(&m_ProposalAcceptance, &m_NumConnections, &m_NumParticles, &m_AbortTracking); MITK_INFO << "proposal acceptance: " << 100*m_ProposalAcceptance << "%"; MITK_INFO << "particles: " << m_NumParticles; MITK_INFO << "connections: " << m_NumConnections; MITK_INFO << "progress: " << 100*(float)step/m_Steps << "%"; if (m_BuildFibers) { int numPoints = m_Sampler->m_ParticleGrid.pcnt; float* points = new float[numPoints*m_Sampler->m_NumAttributes]; m_Sampler->WriteOutParticles(points); BuildFibers(points, numPoints); delete points; m_BuildFibers = false; } } int numPoints = m_Sampler->m_ParticleGrid.pcnt; float* points = new float[numPoints*m_Sampler->m_NumAttributes]; m_Sampler->WriteOutParticles(points); BuildFibers(points, numPoints); delete points; delete sinterp; delete coords; delete ind; delete workingQballImage; m_AbortTracking = true; m_BuildFibers = false; MITK_INFO << "done generate data"; } } 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_ */ diff --git a/Modules/MitkExt/Algorithms/mitkNonBlockingAlgorithmEvents.h b/Modules/MitkExt/Algorithms/mitkNonBlockingAlgorithmEvents.h index fe7aa80f2b..e90c3b807d 100644 --- a/Modules/MitkExt/Algorithms/mitkNonBlockingAlgorithmEvents.h +++ b/Modules/MitkExt/Algorithms/mitkNonBlockingAlgorithmEvents.h @@ -1,104 +1,106 @@ /*========================================================================= 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_NON_BLOCKING_ALGORHITHMS_ENVETS_H_INCLDUED #define MITK_NON_BLOCKING_ALGORHITHMS_ENVETS_H_INCLDUED +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include "MitkExtExports.h" namespace mitk { class NonBlockingAlgorithm; class MitkExt_EXPORT NonBlockingAlgorithmEvent : public itk::AnyEvent { public: typedef NonBlockingAlgorithmEvent Self; typedef itk::AnyEvent Superclass; NonBlockingAlgorithmEvent( const NonBlockingAlgorithm* algorithm = NULL ) : m_Algorithm(algorithm) {} virtual ~NonBlockingAlgorithmEvent() {} virtual const char * GetEventName() const { return "NonBlockingAlgorithmEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_Algorithm ); } const mitk::NonBlockingAlgorithm* GetAlgorithm() const { return m_Algorithm.GetPointer(); } NonBlockingAlgorithmEvent(const Self& s) : itk::AnyEvent(s), m_Algorithm(s.m_Algorithm) {}; protected: mitk::NonBlockingAlgorithm::ConstPointer m_Algorithm; private: void operator=(const Self&); }; class MitkExt_EXPORT ResultAvailable : public NonBlockingAlgorithmEvent { public: ResultAvailable( const NonBlockingAlgorithm* algorithm = NULL ) : NonBlockingAlgorithmEvent(algorithm) { } virtual ~ResultAvailable() { } }; class MitkExt_EXPORT ProcessingError : public NonBlockingAlgorithmEvent { public: ProcessingError( const NonBlockingAlgorithm* algorithm = NULL ) : NonBlockingAlgorithmEvent(algorithm) { } virtual ~ProcessingError() { } }; } #endif diff --git a/Modules/MitkExt/Controllers/mitkToolManager.h b/Modules/MitkExt/Controllers/mitkToolManager.h index 7e5c4bdae8..d0d5ffeedb 100644 --- a/Modules/MitkExt/Controllers/mitkToolManager.h +++ b/Modules/MitkExt/Controllers/mitkToolManager.h @@ -1,285 +1,287 @@ /*========================================================================= 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 mitkToolManager_h_Included #define mitkToolManager_h_Included #include "mitkTool.h" #include "MitkExtExports.h" #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkWeakPointer.h" +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include #include namespace mitk { class Image; class PlaneGeometry; /** \brief Manages and coordinates instances of mitk::Tool. \sa QmitkToolSelectionBox \sa QmitkToolReferenceDataSelectionBox \sa QmitkToolWorkingDataSelectionBox \sa Tool \sa QmitkSegmentationView \ingroup Interaction \ingroup ToolManagerEtAl There is a separate page describing the general design of QmitkSegmentationView: \ref QmitkSegmentationTechnicalPage This class creates and manages several instances of mitk::Tool. \li ToolManager creates instances of mitk::Tool by asking the itk::ObjectFactory to list all known implementations of mitk::Tool. As a result, one has to implement both a subclass of mitk::Tool and a matching subclass of itk::ObjectFactoryBase that is registered to the top-level itk::ObjectFactory. For an example, see mitkContourToolFactory.h. (this limitiation of one-class-one-factory is due to the implementation of itk::ObjectFactory). In MITK, the right place to register the factories to itk::ObjectFactory is the mitk::QMCoreObjectFactory or mitk::SBCoreObjectFactory. \li One (and only one - or none at all) of the registered tools can be activated using ActivateTool. This tool is registered to mitk::GlobalInteraction as a listener and will receive all mouse clicks and keyboard strokes that get into the MITK event mechanism. Tools are automatically unregistered from GlobalInteraction when no clients are registered to ToolManager (see RegisterClient()). \li ToolManager knows a set of "reference" DataNodes and a set of "working" DataNodes. The first application are segmentation tools, where the reference is the original image and the working data the (kind of) binary segmentation. However, ToolManager is implemented more generally, so that there could be other tools that work, e.g., with surfaces. \li Any "user/client" of ToolManager, i.e. every functionality that wants to use a tool, should call RegisterClient when the tools should be active. ToolManager keeps track of how many clients want it to be used, and when this count reaches zero, it unregistes the active Tool from GlobalInteraction. In "normal" settings, the functionality does not need to care about that if it uses a QmitkToolSelectionBox, which does exactly that when it is enabled/disabled. \li There is a set of events that are sent by ToolManager. At the moment these are TODO update documentation: - mitk::ToolReferenceDataChangedEvent whenever somebody calls SetReferenceData. Most of the time this actually means that the data has changed, but there might be cases where the same data is passed to SetReferenceData a second time, so don't rely on the assumption that something actually changed. - mitk::ToolSelectedEvent is sent when a (truly) different tool was activated. In reaction to this event you can ask for the active Tool using GetActiveTool or GetActiveToolID (where NULL or -1 indicate that NO tool is active at the moment). Design descisions: \li Not a singleton, because there could be two functionalities using tools, each one with different reference/working data. $Author$ */ class MitkExt_EXPORT ToolManager : public itk::Object { public: typedef std::vector ToolVectorType; typedef std::vector ToolVectorTypeConst; typedef std::vector DataVectorType; // has to be observed for delete events! typedef std::map NodeTagMapType; Message<> NodePropertiesChanged; Message<> NewNodesGenerated; Message1 NewNodeObjectsGenerated; Message<> ActiveToolChanged; Message<> ReferenceDataChanged; Message<> WorkingDataChanged; Message<> RoiDataChanged; Message1 ToolErrorMessage; Message1 GeneralToolMessage; mitkClassMacro(ToolManager, itk::Object); mitkNewMacro1Param(ToolManager, DataStorage*); /** \brief Gives you a list of all tools. This is const on purpose. */ const ToolVectorTypeConst GetTools(); int GetToolID( const Tool* tool ); /* \param id The tool of interest. Counting starts with 0. */ Tool* GetToolById(int id); /** \param id The tool to activate. Provide -1 for disabling any tools. Counting starts with 0. */ bool ActivateTool(int id); template int GetToolIdByToolType() { int id = 0; for ( ToolVectorType::iterator iter = m_Tools.begin(); iter != m_Tools.end(); ++iter, ++id ) { if ( dynamic_cast(iter->GetPointer()) ) { return id; } } return -1; } /** \return -1 for "No tool is active" */ int GetActiveToolID(); /** \return NULL for "No tool is active" */ Tool* GetActiveTool(); /* \brief Set a list of data/images as reference objects. */ void SetReferenceData(DataVectorType); /* \brief Set single data item/image as reference object. */ void SetReferenceData(DataNode*); /* \brief Set a list of data/images as working objects. */ void SetWorkingData(DataVectorType); /* \brief Set single data item/image as working object. */ void SetWorkingData(DataNode*); /* \brief Set a list of data/images as roi objects. */ void SetRoiData(DataVectorType); /* \brief Set a single data item/image as roi object. */ void SetRoiData(DataNode*); /* \brief Get the list of reference data. */ DataVectorType GetReferenceData(); /* \brief Get the current reference data. \warning If there is a list of items, this method will only return the first list item. */ DataNode* GetReferenceData(int); /* \brief Get the list of working data. */ DataVectorType GetWorkingData(); /* \brief Get the current working data. \warning If there is a list of items, this method will only return the first list item. */ DataNode* GetWorkingData(int); /* \brief Get the current roi data */ DataVectorType GetRoiData(); /* \brief Get the roi data at position idx */ DataNode* GetRoiData(int idx); DataStorage* GetDataStorage(); void SetDataStorage(DataStorage& storage); /* \brief Tell that someone is using tools. GUI elements should call this when they become active. This method increases an internal "client count". Tools are only registered to GlobalInteraction when this count is greater than 0. This is useful to automatically deactivate tools when you hide their GUI elements. */ void RegisterClient(); /* \brief Tell that someone is NOT using tools. GUI elements should call this when they become active. This method increases an internal "client count". Tools are only registered to GlobalInteraction when this count is greater than 0. This is useful to automatically deactivate tools when you hide their GUI elements. */ void UnregisterClient(); void OnOneOfTheReferenceDataDeletedConst(const itk::Object* caller, const itk::EventObject& e); void OnOneOfTheReferenceDataDeleted (itk::Object* caller, const itk::EventObject& e); void OnOneOfTheWorkingDataDeletedConst(const itk::Object* caller, const itk::EventObject& e); void OnOneOfTheWorkingDataDeleted (itk::Object* caller, const itk::EventObject& e); void OnOneOfTheRoiDataDeletedConst(const itk::Object* caller, const itk::EventObject& e); void OnOneOfTheRoiDataDeleted (itk::Object* caller, const itk::EventObject& e); /* \brief Connected to tool's messages This method just resends error messages coming from any of the tools. This way clients (GUIs) only have to observe one message. */ void OnToolErrorMessage(std::string s); void OnGeneralToolMessage(std::string s); protected: /** You may specify a list of tool "groups" that should be available for this ToolManager. Every Tool can report its group as a string. This constructor will try to find the tool's group inside the supplied string. If there is a match, the tool is accepted. Effectively, you can provide a human readable list like "default, lymphnodevolumetry, oldERISstuff". */ ToolManager(DataStorage* storage); // purposely hidden virtual ~ToolManager(); ToolVectorType m_Tools; Tool* m_ActiveTool; int m_ActiveToolID; DataVectorType m_ReferenceData; NodeTagMapType m_ReferenceDataObserverTags; DataVectorType m_WorkingData; NodeTagMapType m_WorkingDataObserverTags; DataVectorType m_RoiData; NodeTagMapType m_RoiDataObserverTags; int m_RegisteredClients; WeakPointer m_DataStorage; }; } // namespace #endif diff --git a/Modules/MitkExt/DataManagement/mitkDataStorageSelection.h b/Modules/MitkExt/DataManagement/mitkDataStorageSelection.h index 4612e71090..daf3b94c54 100644 --- a/Modules/MitkExt/DataManagement/mitkDataStorageSelection.h +++ b/Modules/MitkExt/DataManagement/mitkDataStorageSelection.h @@ -1,191 +1,193 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ Version: $Revision: 18127 $ 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 mitkDataStorageSelection_h #define mitkDataStorageSelection_h #include #include "MitkExtExports.h" #include +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include #include namespace mitk { class BaseProperty; class PropertyList; class MitkExt_EXPORT DataStorageSelection: public itk::Object { public: typedef std::vector Nodes; typedef Message1 DataNodeEvent; DataNodeEvent NodeChanged; DataNodeEvent NodeAdded; DataNodeEvent NodeRemoved; Message2 PropertyChanged; mitkClassMacro(DataStorageSelection, itk::Object); mitkNewMacro2Param(DataStorageSelection, DataStorage*, bool); mitkNewMacro3Param(DataStorageSelection, DataStorage*, NodePredicateBase*, bool); protected: DataStorageSelection(mitk::DataStorage* _DataStorage, bool _AutoAddNodes); DataStorageSelection(mitk::DataStorage* _DataStorage , mitk::NodePredicateBase* _Predicate, bool _AutoAddNodes); public: virtual ~DataStorageSelection(); /// /// Get the DataStorage. /// mitk::DataStorage::Pointer GetDataStorage() const; /// /// Get the predicate. /// mitk::NodePredicateBase::Pointer GetPredicate() const; /// /// Returns the size of this selection /// unsigned int GetSize() const; /// /// Get node at a specific model index. /// mitk::DataNode::Pointer GetNode(unsigned int index) const; /// /// Returns the first node, same as calling GetNode(0) /// mitk::DataNode::Pointer GetNode() const; /// /// Returns a copy of the node-vector /// std::vector GetNodes() const; /// /// \see m_AutoAddNodes /// bool DoesAutoAddNodes() const; public: /// /// Removes all nodes, sets node as new first element /// DataStorageSelection& operator=(mitk::DataNode* node); /// /// Removes all nodes, sets node as new first element /// DataStorageSelection& operator=(mitk::DataNode::Pointer node); /// /// Sets the DataStorage. /// virtual void SetDataStorage(mitk::DataStorage* _DataStorage); /// /// Sets the predicate. QmitkDataStorageTableModel is owner of the predicate! /// virtual void SetPredicate(mitk::NodePredicateBase* _Predicate); /// /// Add a node (if not already there) /// virtual void AddNode(const mitk::DataNode* node); /// /// Removes a node /// virtual void RemoveNode(const mitk::DataNode* node); /// /// Removes a node /// virtual void RemoveAllNodes(); /// /// Called whenever an itk Object this class holds gets deleted or modified /// virtual void ObjectChanged(const itk::Object *caller, const itk::EventObject &event); protected: /// /// Find a node in the list by the given prop /// mitk::DataNode::Pointer FindNode(const mitk::BaseProperty* prop) const; /// /// Find a node in the list by the given proplist /// mitk::DataNode::Pointer FindNode(const mitk::PropertyList* propList) const; /// /// Removes all nodes and fill the vector again /// void Reset(); /// /// If a node is already in this list, all listeners will be removed /// void RemoveListener(mitk::DataNode* node); /// /// Adds listeners for modified/delete event, for the propertylists /// modified/delete and for the modified/delete event of each property /// and stores listener tags /// void AddListener(mitk::DataNode* node); protected: /// /// Pointer to the DataStorage from which the nodes are selected /// mitk::DataStorage* m_DataStorage; /// /// DeleteTag for the DataStorage /// unsigned int m_DataStorageDeletedTag; /// /// Holds the predicate that defines this SubSet of Nodes. If m_Predicate /// is NULL all Nodes will be selected. /// mitk::NodePredicateBase::Pointer m_Predicate; /// /// Holds all selected Nodes. /// std::vector m_Nodes; /// /// \brief Maps a node to a modified observer tag. /// std::map m_NodeModifiedObserverTags; /// /// \brief Maps a propertylist to a modified observer tag. /// std::map m_PropertyListModifiedObserverTags; /// /// \brief Maps a propertylist to a delete observer tag. /// std::map m_PropertyListDeletedObserverTags; /// /// \brief Maps a property to a modified observer tag. /// std::map m_PropertyModifiedObserverTags; /// /// \brief Maps a property to a delete observer tag. /// std::map m_PropertyDeletedObserverTags; /// /// If set to true no event processing will be performed /// bool m_SelfCall; /// /// Saves if new nodes are automatically added to this selection /// bool m_AutoAddNodes; }; } #endif // mitkDataStorageSelection_h diff --git a/Modules/MitkExt/DataManagement/mitkDataTreeFilterEvents.h b/Modules/MitkExt/DataManagement/mitkDataTreeFilterEvents.h index 0c046ffbe5..cf69d3ac87 100644 --- a/Modules/MitkExt/DataManagement/mitkDataTreeFilterEvents.h +++ b/Modules/MitkExt/DataManagement/mitkDataTreeFilterEvents.h @@ -1,289 +1,291 @@ /*========================================================================= 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_DATATREEFILTEREVENTS_H_INCLUDED #define MITK_DATATREEFILTEREVENTS_H_INCLUDED +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include "MitkExtExports.h" namespace mitk { //------ TreeFilterUpdateAllEvent -------------------------------------------------------- #pragma GCC visibility push(default) itkEventMacro( TreeFilterUpdateAllEvent, itk::ModifiedEvent ); itkEventMacro( TreeFilterRemoveAllEvent, itk::ModifiedEvent ); #pragma GCC visibility pop //------ TreeFilterItemEvent ------------------------------------------------------------- class MitkExt_EXPORT TreeFilterItemEvent : public itk::ModifiedEvent { public: typedef TreeFilterItemEvent Self; typedef itk::ModifiedEvent Superclass; TreeFilterItemEvent() : m_ChangedItem( NULL ){} TreeFilterItemEvent( const mitk::DataTreeFilter::Item* item ) : m_ChangedItem(item) {} virtual ~TreeFilterItemEvent() {} virtual const char * GetEventName() const { return "TreeFilterItemEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_ChangedItem ); } const mitk::DataTreeFilter::Item* GetChangedItem() const { return m_ChangedItem; } TreeFilterItemEvent(const Self& s) : itk::ModifiedEvent(s), m_ChangedItem(s.m_ChangedItem) {}; protected: const mitk::DataTreeFilter::Item* m_ChangedItem; private: void operator=(const Self&); }; //------ TreeFilterEvent -------------------------------------------------------- class MitkExt_EXPORT TreeFilterNewItemEvent : public TreeFilterItemEvent { public: typedef TreeFilterNewItemEvent Self; typedef TreeFilterItemEvent Superclass; TreeFilterNewItemEvent() : TreeFilterItemEvent() {} TreeFilterNewItemEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} virtual ~TreeFilterNewItemEvent() {} virtual const char * GetEventName() const { return "TreeFilterNewItemEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_ChangedItem ); } TreeFilterNewItemEvent(const Self& s) : TreeFilterItemEvent(s) {}; private: void operator=(const Self&); }; //------ TreeFilterItemAddedEvent -------------------------------------------------------- class MitkExt_EXPORT TreeFilterItemAddedEvent : public TreeFilterItemEvent { public: typedef TreeFilterItemAddedEvent Self; typedef TreeFilterItemEvent Superclass; TreeFilterItemAddedEvent() : TreeFilterItemEvent() {} TreeFilterItemAddedEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} virtual ~TreeFilterItemAddedEvent() {} virtual const char * GetEventName() const { return "TreeFilterItemAddedEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_ChangedItem ); } TreeFilterItemAddedEvent(const Self& s) : TreeFilterItemEvent(s) {}; private: void operator=(const Self&); }; //------ TreeFilterSelectionChangedEvent ------------------------------------------------- class MitkExt_EXPORT TreeFilterSelectionChangedEvent : public TreeFilterItemEvent { public: typedef TreeFilterSelectionChangedEvent Self; typedef TreeFilterItemEvent Superclass; TreeFilterSelectionChangedEvent() : TreeFilterItemEvent() {} TreeFilterSelectionChangedEvent(const mitk::DataTreeFilter::Item* item, bool selected) : TreeFilterItemEvent(item), m_Selected(selected) {} virtual ~TreeFilterSelectionChangedEvent() {} virtual const char * GetEventName() const { return "TreeFilterSelectionChangedEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_ChangedItem, m_Selected ); } virtual bool IsSelected() const { return m_Selected; } TreeFilterSelectionChangedEvent(const Self&s) : TreeFilterItemEvent(s) {}; private: void operator=(const Self&); bool m_Selected; }; //------ TreeFilterItemChangedEvent ------------------------------------------------------ class MitkExt_EXPORT TreeFilterItemChangedEvent : public TreeFilterItemEvent { public: typedef TreeFilterItemChangedEvent Self; typedef TreeFilterItemEvent Superclass; TreeFilterItemChangedEvent() : TreeFilterItemEvent() {} TreeFilterItemChangedEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} virtual ~TreeFilterItemChangedEvent() {} virtual const char * GetEventName() const { return "TreeFilterItemChangedEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_ChangedItem ); } TreeFilterItemChangedEvent(const Self&s) : TreeFilterItemEvent(s) {}; private: void operator=(const Self&); }; //------ TreeFilterRemoveItemEvent ------------------------------------------------------- class MitkExt_EXPORT TreeFilterRemoveItemEvent : public TreeFilterItemEvent { public: typedef TreeFilterRemoveItemEvent Self; typedef TreeFilterItemEvent Superclass; TreeFilterRemoveItemEvent() : TreeFilterItemEvent() {} TreeFilterRemoveItemEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} virtual ~TreeFilterRemoveItemEvent() {} virtual const char * GetEventName() const { return "TreeFilterRemoveItemEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_ChangedItem ); } TreeFilterRemoveItemEvent(const Self&s) : TreeFilterItemEvent(s) {}; private: void operator=(const Self&); }; //------ TreeFilterRemoveChildrenEvent ------------------------------------------------------- class MitkExt_EXPORT TreeFilterRemoveChildrenEvent : public TreeFilterItemEvent { public: typedef TreeFilterRemoveChildrenEvent Self; typedef TreeFilterItemEvent Superclass; TreeFilterRemoveChildrenEvent() : TreeFilterItemEvent() {} TreeFilterRemoveChildrenEvent(const mitk::DataTreeFilter::Item* item) : TreeFilterItemEvent(item) {} virtual ~TreeFilterRemoveChildrenEvent() {} virtual const char * GetEventName() const { return "TreeFilterRemoveChildrenEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_ChangedItem ); } TreeFilterRemoveChildrenEvent(const Self&s) : TreeFilterItemEvent(s) {}; private: void operator=(const Self&); }; } #endif diff --git a/Modules/MitkExt/DataManagement/mitkPropertyObserver.h b/Modules/MitkExt/DataManagement/mitkPropertyObserver.h index 11e2192c1f..9734a61f22 100644 --- a/Modules/MitkExt/DataManagement/mitkPropertyObserver.h +++ b/Modules/MitkExt/DataManagement/mitkPropertyObserver.h @@ -1,95 +1,97 @@ /*========================================================================= 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_BASEPROPERTYOBSERVER_H_INCLUDED #define MITK_BASEPROPERTYOBSERVER_H_INCLUDED +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include "MitkExtExports.h" #include "mitkCommon.h" namespace mitk { /** \brief Convenience class to observe changes of a mitk::BaseProperty. This class registers itself as an ITK observer to a BaseProperty and gets informed of changes to the property. Whenever such a change occurrs, the virtual method PropertyChanged() or PropertyRemoved() is called. This way, derived classes can implement behaviour for more specific properties (e.g. ColorProperty) without the need to reimplement the Subject-Observer handling. */ class BaseProperty; class MitkExt_EXPORT PropertyObserver { public: PropertyObserver(); virtual ~PropertyObserver(); virtual void PropertyChanged() = 0; virtual void PropertyRemoved() = 0; protected: void BeginModifyProperty(); void EndModifyProperty(); unsigned long m_ModifiedTag; unsigned long m_DeleteTag; bool m_SelfCall; }; class MitkExt_EXPORT PropertyView : public PropertyObserver { public: PropertyView( const mitk::BaseProperty* ); virtual ~PropertyView(); void OnModified(const itk::EventObject& e); void OnDelete(const itk::EventObject& e); protected: const mitk::BaseProperty* m_Property; }; class MitkExt_EXPORT PropertyEditor : public PropertyObserver { public: PropertyEditor( mitk::BaseProperty* ); virtual ~PropertyEditor(); void OnModified(const itk::EventObject& e); void OnDelete(const itk::EventObject& e); protected: mitk::BaseProperty* m_Property; }; } #endif diff --git a/Modules/MitkExt/IO/mitkPACSPluginEvents.h b/Modules/MitkExt/IO/mitkPACSPluginEvents.h index 61fb2b4949..6abd8e6dc0 100644 --- a/Modules/MitkExt/IO/mitkPACSPluginEvents.h +++ b/Modules/MitkExt/IO/mitkPACSPluginEvents.h @@ -1,35 +1,37 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 14120 $ 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 mitkPACSPluginEventshincluded #define mitkPACSPluginEventshincluded #include +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop namespace mitk { #pragma GCC visibility push(default) itkEventMacro( PluginEvent, itk::AnyEvent ); itkEventMacro( PluginStudySelected, PluginEvent ); itkEventMacro( PluginLightBoxCountChanged, PluginEvent ); itkEventMacro( PluginAbortPACSImport, PluginEvent ); #pragma GCC visibility pop } #endif diff --git a/Modules/MitkExt/Interactions/mitkToolEvents.h b/Modules/MitkExt/Interactions/mitkToolEvents.h index 1958025aef..7ac6a41b84 100644 --- a/Modules/MitkExt/Interactions/mitkToolEvents.h +++ b/Modules/MitkExt/Interactions/mitkToolEvents.h @@ -1,293 +1,295 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 1.12 $ 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_TOOL_EVENTS_H #define MITK_TOOL_EVENTS_H +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop namespace mitk { /** \brief Basic tool event without any parameters Can simply be inherited using the itkEventMacro, e.g. \code namespace mitk { class MyTool : public Tool { public: itkEventMacro(MySpecialEvent, ToolEvent); [...] protected: // Invoke your event like this void YourExampleMethod() { InvokeEvent( MySpecialEvent() ); } }; } \endcode */ #pragma GCC visibility push(default) itkEventMacro( ToolEvent, itk::ModifiedEvent ); #pragma GCC visibility pop /** \brief Tool event with 1 parameter Can store one parameter for use within an observer. To derive your own special events, use the mitkToolEventMacro1Param macro. \code namespace mitk { class MyTool : public Tool { public: mitkToolEventMacro1Param(FooToolEvent, int); [...] protected: // Invoke your event like this void YourExampleMethod() { InvokeEvent( FooToolEvent(32) ); } }; } \endcode */ template class ParameterToolEvent : public ToolEvent { public: typedef ParameterToolEvent Self; typedef ToolEvent Superclass; ParameterToolEvent( const T parameter ) : m_Parameter(parameter) { } ParameterToolEvent(const Self& s) : ToolEvent(s), m_Parameter(s.m_Parameter) { } virtual ~ParameterToolEvent() { } virtual const char * GetEventName() const { return "ParameterToolEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_Parameter ); } const T GetParameter() const { return m_Parameter; } protected: const T m_Parameter; private: ParameterToolEvent(); void operator=(const Self&); }; /** \brief Tool event with 1 parameter Can store one parameter for use within an observer. To derive your own special events, use the mitkToolEventMacro1Param macro. \code namespace mitk { class MyTool : public Tool { public: mitkToolEventMacro1Param(FooToolEvent, int); [...] protected: // Invoke your event like this void YourExampleMethod() { InvokeEvent( BarToolEvent(32, false) ); } }; } \endcode */ template class TwoParameterToolEvent : public ToolEvent { public: typedef TwoParameterToolEvent Self; typedef ToolEvent Superclass; TwoParameterToolEvent( const T parameter1, const U parameter2 ) : m_Parameter1(parameter1), m_Parameter2(parameter2) { } TwoParameterToolEvent(const Self& s) : ToolEvent(s), m_Parameter1(s.m_Parameter1), m_Parameter2(s.m_Parameter2) { } virtual ~TwoParameterToolEvent() { } virtual const char * GetEventName() const { return "TwoParameterToolEvent"; } virtual bool CheckEvent(const ::itk::EventObject* e) const { return dynamic_cast(e); } virtual ::itk::EventObject* MakeObject() const { return new Self( m_Parameter1, m_Parameter2 ); } const T GetParameter1() const { return m_Parameter1; } const T GetParameter2() const { return m_Parameter2; } protected: const T m_Parameter1; const U m_Parameter2; private: TwoParameterToolEvent(); void operator=(const Self&); }; typedef ParameterToolEvent IntegerToolEvent; typedef ParameterToolEvent FloatToolEvent; typedef ParameterToolEvent BoolToolEvent; } // namespace // some macros to let tools define their own event classes as inner classes (should then inherit from something like FloatToolEvent // inheritance, because it allows observers to distinguish events #define mitkToolEventMacro( eventname, baseevent ) \ class eventname : public baseevent \ { \ virtual const char * GetEventName() const \ { \ return #eventname ; \ } \ }; #define mitkToolEventMacro1Param( eventname, paramtype1 ) \ class eventname : public ParameterToolEvent \ { \ public: \ virtual const char * GetEventName() const \ { \ return #eventname "(" #paramtype1 ")" ; \ } \ \ eventname( const paramtype1 parameter ) \ : ParameterToolEvent(parameter) \ { \ } \ \ private: \ \ eventname();\ }; #define mitkToolEventMacro2Param( eventname, paramtype1, paramtype2 ) \ class eventname : public TwoParameterToolEvent \ { \ public: \ virtual const char * GetEventName() const \ { \ return #eventname "(" #paramtype1 "," #paramtype2 ")" ; \ } \ \ eventname( const paramtype1 parameter1, const paramtype2 parameter2 ) \ : TwoParameterToolEvent(parameter1, parameter2) \ { \ } \ \ private: \ \ eventname();\ }; #endif diff --git a/Modules/PlanarFigure/Interactions/mitkPlanarFigureInteractor.h b/Modules/PlanarFigure/Interactions/mitkPlanarFigureInteractor.h index 95d6ccdbe6..eba9581e2a 100644 --- a/Modules/PlanarFigure/Interactions/mitkPlanarFigureInteractor.h +++ b/Modules/PlanarFigure/Interactions/mitkPlanarFigureInteractor.h @@ -1,150 +1,152 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-04-18 20:20:25 +0200 (Sa, 18 Apr 2009) $ Version: $Revision: 13129 $ 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 MITKPLANARFIGUREINTERACTOR_H_HEADER_INCLUDED #define MITKPLANARFIGUREINTERACTOR_H_HEADER_INCLUDED #include "PlanarFigureExports.h" #include "mitkCommon.h" #include "mitkVector.h" #include "mitkInteractor.h" #include "mitkBaseRenderer.h" +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop namespace mitk { class DataNode; class Geometry2D; class DisplayGeometry; class PlanarFigure; class PositionEvent; #pragma GCC visibility push(default) // Define events for PlanarFigure interaction notifications itkEventMacro( PlanarFigureEvent, itk::AnyEvent ); itkEventMacro( StartPlacementPlanarFigureEvent, PlanarFigureEvent ); itkEventMacro( EndPlacementPlanarFigureEvent, PlanarFigureEvent ); itkEventMacro( SelectPlanarFigureEvent, PlanarFigureEvent ); itkEventMacro( StartInteractionPlanarFigureEvent, PlanarFigureEvent ); itkEventMacro( EndInteractionPlanarFigureEvent, PlanarFigureEvent ); itkEventMacro( StartHoverPlanarFigureEvent, PlanarFigureEvent ); itkEventMacro( EndHoverPlanarFigureEvent, PlanarFigureEvent ); #pragma GCC visibility pop /** * \brief Interaction with mitk::PlanarFigure objects via control-points * * \ingroup Interaction */ class PlanarFigure_EXPORT PlanarFigureInteractor : public Interactor { public: mitkClassMacro(PlanarFigureInteractor, Interactor); mitkNewMacro3Param(Self, const char *, DataNode *, int); mitkNewMacro2Param(Self, const char *, DataNode *); /** \brief Sets the amount of precision */ void SetPrecision( ScalarType precision ); /** * \brief calculates how good the data, this statemachine handles, is hit * by the event. * * overwritten, cause we don't look at the boundingbox, we look at each point */ virtual float CanHandleEvent(StateEvent const *stateEvent) const; protected: /** * \brief Constructor with Param n for limited Set of Points * * if no n is set, then the number of points is unlimited* */ PlanarFigureInteractor(const char *type, DataNode *dataNode, int n = -1); /** * \brief Default Destructor **/ virtual ~PlanarFigureInteractor(); virtual bool ExecuteAction( Action *action, mitk::StateEvent const *stateEvent ); /** \brief Used when clicking to determine if a point is too close to the previous point. */ bool IsMousePositionAcceptableAsNewControlPoint( const PositionEvent*, const PlanarFigure* ); bool TransformPositionEventToPoint2D( const StateEvent *stateEvent, Point2D &point2D, const Geometry2D *planarFigureGeometry ); bool TransformObjectToDisplay( const mitk::Point2D &point2D, mitk::Point2D &displayPoint, const mitk::Geometry2D *objectGeometry, const mitk::Geometry2D *rendererGeometry, const mitk::DisplayGeometry *displayGeometry ) const; /** \brief Returns true if the first specified point is in proximity of the line defined * the other two point; false otherwise. * * Proximity is defined as the rectangle around the line with pre-defined distance * from the line. */ bool IsPointNearLine( const mitk::Point2D& point, const mitk::Point2D& startPoint, const mitk::Point2D& endPoint, mitk::Point2D& projectedPoint ) const; /** \brief Returns true if the point contained in the passed event (in display coordinates) * is over the planar figure (with a pre-defined tolerance range); false otherwise. */ int IsPositionOverFigure( const StateEvent *StateEvent, PlanarFigure *planarFigure, const Geometry2D *planarFigureGeometry, const Geometry2D *rendererGeometry, const DisplayGeometry *displayGeometry, Point2D& pointProjectedOntoLine) const; /** \brief Returns the index of the marker (control point) over which the point contained * in the passed event (in display coordinates) currently is; -1 if the point is not over * a marker. */ int IsPositionInsideMarker( const StateEvent *StateEvent, const PlanarFigure *planarFigure, const Geometry2D *planarFigureGeometry, const Geometry2D *rendererGeometry, const DisplayGeometry *displayGeometry ) const; void LogPrintPlanarFigureQuantities( const PlanarFigure *planarFigure ); private: /** \brief to store the value of precision to pick a point */ ScalarType m_Precision; /** \brief True if the mouse is currently hovering over the image. */ bool m_IsHovering; }; } #endif // MITKPLANARFIGUREINTERACTOR_H_HEADER_INCLUDED diff --git a/Modules/ToFHardware/mitkToFImageRecorder.cpp b/Modules/ToFHardware/mitkToFImageRecorder.cpp index ce18e6f73d..8a9c424d50 100644 --- a/Modules/ToFHardware/mitkToFImageRecorder.cpp +++ b/Modules/ToFHardware/mitkToFImageRecorder.cpp @@ -1,235 +1,237 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2010-05-27 16:06:53 +0200 (Do, 27 Mai 2010) $ 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 "mitkToFImageRecorder.h" #include "mitkRealTimeClock.h" #include "itkMultiThreader.h" #include +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop namespace mitk { ToFImageRecorder::ToFImageRecorder() { this->m_ToFCameraDevice = NULL; this->m_MultiThreader = itk::MultiThreader::New(); this->m_AbortMutex = itk::FastMutexLock::New(); this->m_ThreadID = 0; this->m_NumOfFrames = 0; this->m_ToFImageWriter = NULL; this->m_DistanceImageSelected = true; this->m_AmplitudeImageSelected = true; this->m_IntensityImageSelected = true; this->m_Abort = true; this->m_CaptureWidth = 0; this->m_CaptureHeight = 0; this->m_FileFormat = ""; this->m_PixelNumber = 0; this->m_SourceDataSize = 0; this->m_ToFImageType = ToFImageWriter::ToFImageType3D; this->m_RecordMode = ToFImageRecorder::PerFrames; this->m_DistanceImageFileName = ""; this->m_AmplitudeImageFileName = ""; this->m_IntensityImageFileName = ""; this->m_ImageSequence = 0; this->m_DistanceArray = NULL; this->m_AmplitudeArray = NULL; this->m_IntensityArray = NULL; this->m_SourceDataArray = NULL; } ToFImageRecorder::~ToFImageRecorder() { delete[] m_DistanceArray; delete[] m_AmplitudeArray; delete[] m_IntensityArray; delete[] m_SourceDataArray; } void ToFImageRecorder::StopRecording() { this->m_AbortMutex->Lock(); this->m_Abort = true; this->m_AbortMutex->Unlock(); } void ToFImageRecorder::StartRecording() { if (this->m_ToFCameraDevice.IsNull()) { throw std::invalid_argument("ToFCameraDevice is NULL."); return; } if (this->m_FileFormat.compare("csv") == 0) { this->m_ToFImageWriter = ToFImageCsvWriter::New(); } else { this->m_ToFImageWriter = ToFImageWriter::New(); } this->m_CaptureWidth = this->m_ToFCameraDevice->GetCaptureWidth(); this->m_CaptureHeight = this->m_ToFCameraDevice->GetCaptureHeight(); this->m_PixelNumber = this->m_CaptureWidth * this->m_CaptureHeight; this->m_SourceDataSize = this->m_ToFCameraDevice->GetSourceDataSize(); // allocate buffer if(m_IntensityArray == NULL) { this->m_IntensityArray = new float[m_PixelNumber]; } if(this->m_DistanceArray == NULL) { this->m_DistanceArray = new float[m_PixelNumber]; } if(this->m_AmplitudeArray == NULL) { this->m_AmplitudeArray = new float[m_PixelNumber]; } if(this->m_SourceDataArray == NULL) { this->m_SourceDataArray = new char[m_SourceDataSize]; } this->m_ToFImageWriter->SetDistanceImageFileName(this->m_DistanceImageFileName); this->m_ToFImageWriter->SetAmplitudeImageFileName(this->m_AmplitudeImageFileName); this->m_ToFImageWriter->SetIntensityImageFileName(this->m_IntensityImageFileName); this->m_ToFImageWriter->SetCaptureWidth(this->m_CaptureWidth); this->m_ToFImageWriter->SetCaptureHeight(this->m_CaptureHeight); this->m_ToFImageWriter->SetToFImageType(this->m_ToFImageType); this->m_ToFImageWriter->SetDistanceImageSelected(this->m_DistanceImageSelected); this->m_ToFImageWriter->SetAmplitudeImageSelected(this->m_AmplitudeImageSelected); this->m_ToFImageWriter->SetIntensityImageSelected(this->m_IntensityImageSelected); this->m_ToFImageWriter->Open(); this->m_AbortMutex->Lock(); this->m_Abort = false; this->m_AbortMutex->Unlock(); this->m_ThreadID = this->m_MultiThreader->SpawnThread(this->RecordData, this); } ITK_THREAD_RETURN_TYPE ToFImageRecorder::RecordData(void* pInfoStruct) { struct itk::MultiThreader::ThreadInfoStruct * pInfo = (struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct; if (pInfo == NULL) { return ITK_THREAD_RETURN_VALUE; } if (pInfo->UserData == NULL) { return ITK_THREAD_RETURN_VALUE; } ToFImageRecorder* toFImageRecorder = (ToFImageRecorder*)pInfo->UserData; if (toFImageRecorder!=NULL) { ToFCameraDevice::Pointer toFCameraDevice = toFImageRecorder->GetCameraDevice(); mitk::RealTimeClock::Pointer realTimeClock; realTimeClock = mitk::RealTimeClock::New(); int n = 100; double t1 = 0; double t2 = 0; t1 = realTimeClock->GetCurrentStamp(); bool overflow = false; bool printStatus = false; int requiredImageSequence = 0; int numOfFramesRecorded = 0; bool abort = false; toFImageRecorder->m_AbortMutex->Lock(); abort = toFImageRecorder->m_Abort; toFImageRecorder->m_AbortMutex->Unlock(); while ( !abort ) { if ( ((toFImageRecorder->m_RecordMode == ToFImageRecorder::PerFrames) && (numOfFramesRecorded < toFImageRecorder->m_NumOfFrames)) || (toFImageRecorder->m_RecordMode == ToFImageRecorder::Infinite) ) { toFCameraDevice->GetAllImages(toFImageRecorder->m_DistanceArray, toFImageRecorder->m_AmplitudeArray, toFImageRecorder->m_IntensityArray, toFImageRecorder->m_SourceDataArray, requiredImageSequence, toFImageRecorder->m_ImageSequence ); if (toFImageRecorder->m_ImageSequence >= requiredImageSequence) { if (toFImageRecorder->m_ImageSequence > requiredImageSequence) { MITK_INFO << "Problem! required: " << requiredImageSequence << " captured: " << toFImageRecorder->m_ImageSequence; } requiredImageSequence = toFImageRecorder->m_ImageSequence + 1; toFImageRecorder->m_ToFImageWriter->Add( toFImageRecorder->m_DistanceArray, toFImageRecorder->m_AmplitudeArray, toFImageRecorder->m_IntensityArray ); numOfFramesRecorded++; if (numOfFramesRecorded % n == 0) { printStatus = true; } if (printStatus) { t2 = realTimeClock->GetCurrentStamp() - t1; MITK_INFO << " Framerate (fps): " << n / (t2/1000) << " Sequence: " << toFImageRecorder->m_ImageSequence; t1 = realTimeClock->GetCurrentStamp(); printStatus = false; } } toFImageRecorder->m_AbortMutex->Lock(); abort = toFImageRecorder->m_Abort; toFImageRecorder->m_AbortMutex->Unlock(); } else { abort = true; } } // end of while loop toFImageRecorder->InvokeEvent(itk::AbortEvent()); toFImageRecorder->m_ToFImageWriter->Close(); } return ITK_THREAD_RETURN_VALUE; } void ToFImageRecorder::SetCameraDevice(ToFCameraDevice* aToFCameraDevice) { this->m_ToFCameraDevice = aToFCameraDevice; } ToFCameraDevice* ToFImageRecorder::GetCameraDevice() { return this->m_ToFCameraDevice; } ToFImageWriter::ToFImageType ToFImageRecorder::GetToFImageType() { return this->m_ToFImageType; } void ToFImageRecorder::SetToFImageType(ToFImageWriter::ToFImageType toFImageType) { this->m_ToFImageType = toFImageType; } ToFImageRecorder::RecordMode ToFImageRecorder::GetRecordMode() { return this->m_RecordMode; } void ToFImageRecorder::SetRecordMode(ToFImageRecorder::RecordMode recordMode) { this->m_RecordMode = recordMode; } } diff --git a/Modules/ToFUI/Qmitk/QmitkToFRecorderWidget.cpp b/Modules/ToFUI/Qmitk/QmitkToFRecorderWidget.cpp index d394238e61..e6a0dfe2f6 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFRecorderWidget.cpp +++ b/Modules/ToFUI/Qmitk/QmitkToFRecorderWidget.cpp @@ -1,379 +1,381 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2009-05-20 13:35:09 +0200 (Mi, 20 Mai 2009) $ Version: $Revision: 17332 $ 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. =========================================================================*/ #define _USE_MATH_DEFINES #include "QmitkToFRecorderWidget.h" //QT headers #include #include #include #include #include #include //mitk headers #include //itk headers +#pragma GCC visibility push(default) #include +#pragma GCC visibility pop #include struct QFileDialogArgs; class QFileDialogPrivate; const std::string QmitkToFRecorderWidget::VIEW_ID = "org.mitk.views.qmitktofrecorderwidget"; QmitkToFRecorderWidget::QmitkToFRecorderWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) { this->m_ToFImageRecorder = NULL; this->m_ToFImageGrabber = NULL; this->m_RecordMode = mitk::ToFImageRecorder::PerFrames; this-> m_Controls = NULL; CreateQtPartControl(this); } QmitkToFRecorderWidget::~QmitkToFRecorderWidget() { } void QmitkToFRecorderWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets this->m_Controls = new Ui::QmitkToFRecorderWidgetControls; this->m_Controls->setupUi(parent); this->CreateConnections(); } } void QmitkToFRecorderWidget::CreateConnections() { if ( m_Controls ) { connect( (QObject*)(m_Controls->m_PlayButton), SIGNAL(clicked()),(QObject*) this, SLOT(OnPlay()) ); connect( (QObject*)(m_Controls->m_StopButton), SIGNAL(clicked()),(QObject*) this, SLOT(OnStop()) ); connect( (QObject*)(m_Controls->m_StartRecordingButton), SIGNAL(clicked()),(QObject*) this, SLOT(OnStartRecorder()) ); connect( (QObject*)(m_Controls->m_RecordModeComboBox), SIGNAL(currentIndexChanged(int)),(QObject*) this, SLOT(OnChangeRecordModeComboBox(int)) ); connect(this, SIGNAL(RecordingStopped()), this, SLOT(OnRecordingStopped()), Qt::BlockingQueuedConnection); } } void QmitkToFRecorderWidget::SetParameter(mitk::ToFImageGrabber* ToFImageGrabber, mitk::ToFImageRecorder* toFImageRecorder) { this->m_ToFImageGrabber = ToFImageGrabber; this->m_ToFImageRecorder = toFImageRecorder; this->m_StopRecordingCommand = CommandType::New(); this->m_StopRecordingCommand->SetCallbackFunction(this, &QmitkToFRecorderWidget::StopRecordingCallback); this->m_ToFImageRecorder->RemoveAllObservers(); this->m_ToFImageRecorder->AddObserver(itk::AbortEvent(), this->m_StopRecordingCommand); m_Controls->m_PlayButton->setChecked(false); m_Controls->m_PlayButton->setEnabled(true); m_Controls->m_StartRecordingButton->setChecked(false); m_Controls->m_RecorderGroupBox->setEnabled(true); } void QmitkToFRecorderWidget::StopRecordingCallback() { emit RecordingStopped(); } void QmitkToFRecorderWidget::ResetGUIToInitial() { m_Controls->m_PlayButton->setChecked(false); m_Controls->m_PlayButton->setEnabled(true); m_Controls->m_RecorderGroupBox->setEnabled(false); } void QmitkToFRecorderWidget::OnRecordingStopped() { m_Controls->m_StartRecordingButton->setChecked(false); m_Controls->m_RecorderGroupBox->setEnabled(true); } void QmitkToFRecorderWidget::OnStop() { StopCamera(); StopRecorder(); ResetGUIToInitial(); emit ToFCameraStopped(); } void QmitkToFRecorderWidget::OnPlay() { m_Controls->m_PlayButton->setChecked(true); m_Controls->m_PlayButton->setEnabled(false); m_Controls->m_RecorderGroupBox->setEnabled(true); this->repaint(); StartCamera(); emit ToFCameraStarted(); } void QmitkToFRecorderWidget::StartCamera() { bool ok = false; if (!m_ToFImageGrabber->IsCameraActive()) { m_ToFImageGrabber->StartCamera(); } } void QmitkToFRecorderWidget::StopCamera() { m_ToFImageGrabber->StopCamera(); } void QmitkToFRecorderWidget::StopRecorder() { this->m_ToFImageRecorder->StopRecording(); } void QmitkToFRecorderWidget::OnStartRecorder() { m_Controls->m_StartRecordingButton->setChecked(true); m_Controls->m_RecorderGroupBox->setEnabled(false); this->repaint(); int numOfFrames = m_Controls->m_NumOfFramesSpinBox->value(); try { bool fileOK = true; bool distanceImageSelected = true; bool amplitudeImageSelected = true; bool intensityImageSelected = true; bool rawDataSelected = false; QString tmpFileName(""); QString selectedFilter(""); QString imageFileName(""); mitk::ToFImageWriter::ToFImageType tofImageType; tmpFileName = QmitkToFRecorderWidget::getSaveFileName(tofImageType, distanceImageSelected, amplitudeImageSelected, intensityImageSelected, rawDataSelected, NULL, "Save Image To...", imageFileName, "MITK Images (*.pic);;Text (*.csv)", &selectedFilter); if (tmpFileName.isEmpty()) { fileOK = false; } else { imageFileName = tmpFileName; } if (fileOK) { std::string dir = itksys::SystemTools::GetFilenamePath( imageFileName.toStdString() ); std::string baseFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( imageFileName.toStdString() ); std::string extension = itksys::SystemTools::GetFilenameLastExtension( imageFileName.toStdString() ); int integrationTime = this->m_ToFImageGrabber->GetIntegrationTime(); int modulationFreq = this->m_ToFImageGrabber->GetModulationFrequency(); QString integrationTimeStr; integrationTimeStr.setNum(integrationTime); QString modulationFreqStr; modulationFreqStr.setNum(modulationFreq); QString numOfFramesStr(""); if (this->m_RecordMode == mitk::ToFImageRecorder::PerFrames) { numOfFramesStr.setNum(numOfFrames); } std::string distImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(), integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_DistanceImage"); MITK_INFO << "Save distance data to: " << distImageFileName; std::string amplImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(), integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_AmplitudeImage"); MITK_INFO << "Save amplitude data to: " << amplImageFileName; std::string intenImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(), integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_IntensityImage"); MITK_INFO << "Save intensity data to: " << intenImageFileName; if (selectedFilter.compare("Text (*.csv)") == 0) { this->m_ToFImageRecorder->SetFileFormat("csv"); } else { //default this->m_ToFImageRecorder->SetFileFormat("pic"); } numOfFrames = m_Controls->m_NumOfFramesSpinBox->value(); this->m_ToFImageRecorder->SetDistanceImageFileName(distImageFileName); this->m_ToFImageRecorder->SetAmplitudeImageFileName(amplImageFileName); this->m_ToFImageRecorder->SetIntensityImageFileName(intenImageFileName); this->m_ToFImageRecorder->SetToFImageType(tofImageType); this->m_ToFImageRecorder->SetDistanceImageSelected(distanceImageSelected); this->m_ToFImageRecorder->SetAmplitudeImageSelected(amplitudeImageSelected); this->m_ToFImageRecorder->SetIntensityImageSelected(intensityImageSelected); this->m_ToFImageRecorder->SetRecordMode(this->m_RecordMode); this->m_ToFImageRecorder->SetNumOfFrames(numOfFrames); this->m_ToFImageRecorder->StartRecording(); } else { OnRecordingStopped(); } } catch(std::exception& e) { QMessageBox::critical(NULL, "Error", QString(e.what())); OnRecordingStopped(); } } QString QmitkToFRecorderWidget::getSaveFileName(mitk::ToFImageWriter::ToFImageType& tofImageType, bool& distanceImageSelected, bool& amplitudeImageSelected, bool& intensityImageSelected, bool& rawDataSelected, QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options ) { QString selectedFileName = ""; QComboBox* combo = new QComboBox; combo->addItem("3D"); combo->addItem("2D + t"); QHBoxLayout* checkBoxGroup = new QHBoxLayout(); QCheckBox* distanceImageCheckBox = new QCheckBox; distanceImageCheckBox->setText("Distance image"); distanceImageCheckBox->setChecked(true); QCheckBox* amplitudeImageCheckBox = new QCheckBox; amplitudeImageCheckBox->setText("Amplitude image"); amplitudeImageCheckBox->setChecked(true); QCheckBox* intensityImageCheckBox = new QCheckBox; intensityImageCheckBox->setText("Intensity image"); intensityImageCheckBox->setChecked(true); QCheckBox* rawDataCheckBox = new QCheckBox; rawDataCheckBox->setText("Raw data"); rawDataCheckBox->setChecked(false); rawDataCheckBox->setEnabled(false); checkBoxGroup->addWidget(distanceImageCheckBox); checkBoxGroup->addWidget(amplitudeImageCheckBox); checkBoxGroup->addWidget(intensityImageCheckBox); checkBoxGroup->addWidget(rawDataCheckBox); QFileDialog* fileDialog = new QFileDialog(parent, caption, dir, filter); QLayout* layout = fileDialog->layout(); QGridLayout* gridbox = qobject_cast(layout); if (gridbox) { gridbox->addWidget(new QLabel("ToF-Image type:")); gridbox->addWidget(combo); int lastRow = gridbox->rowCount(); gridbox->addLayout(checkBoxGroup, lastRow, 0, 1, -1); } fileDialog->setLayout(gridbox); fileDialog->setAcceptMode(QFileDialog::AcceptSave); if (selectedFilter) { fileDialog->selectNameFilter(*selectedFilter); } if (fileDialog->exec() == QDialog::Accepted) { if (selectedFilter) { *selectedFilter = fileDialog->selectedFilter(); } if (combo->currentIndex() == 0) { tofImageType = mitk::ToFImageWriter::ToFImageType3D; } else { tofImageType = mitk::ToFImageWriter::ToFImageType2DPlusT; } distanceImageSelected = distanceImageCheckBox->isChecked(); amplitudeImageSelected = amplitudeImageCheckBox->isChecked(); intensityImageSelected = intensityImageCheckBox->isChecked(); rawDataSelected = rawDataCheckBox->isChecked(); selectedFileName = fileDialog->selectedFiles().value(0); } delete fileDialog; return selectedFileName; } std::string QmitkToFRecorderWidget::prepareFilename(std::string dir, std::string baseFilename, std::string modulationFreq, std::string integrationTime, std::string numOfFrames, std::string extension, std::string imageType) { std::string filenName(""); filenName.append(dir); filenName.append("/"); filenName.append(baseFilename); filenName.append("_MF"); filenName.append(modulationFreq); filenName.append("_IT"); filenName.append(integrationTime); filenName.append("_"); filenName.append(numOfFrames); filenName.append("Images"); filenName.append(imageType); filenName.append(extension); return filenName; } void QmitkToFRecorderWidget::OnChangeRecordModeComboBox(int index) { if (index == 0) { this->m_RecordMode = mitk::ToFImageRecorder::PerFrames; m_Controls->m_NumOfFramesSpinBox->setEnabled(true); } else { this->m_RecordMode = mitk::ToFImageRecorder::Infinite; m_Controls->m_NumOfFramesSpinBox->setEnabled(false); } } diff --git a/Wrapping/CSwig/Core/wrap_mitkCommonSuperclasses.cxx b/Wrapping/CSwig/Core/wrap_mitkCommonSuperclasses.cxx index 22cec6b759..6396822453 100644 --- a/Wrapping/CSwig/Core/wrap_mitkCommonSuperclasses.cxx +++ b/Wrapping/CSwig/Core/wrap_mitkCommonSuperclasses.cxx @@ -1,37 +1,39 @@ #include "mitkCommon.h" #include "mitkBaseProcess.h" #include "mitkCSwigMacros.h" #include "mbilog.h" #include "itkObject.h" #include "itkDataObject.h" #include "itkProcessObject.h" #include "itkLightObject.h" #include "itkObjectFactoryBase.h" -#include "itkEventObject.h" +#pragma GCC visibility push(default) +#include +#pragma GCC visibility pop #include "itkSmartPointerForwardReference.h" #include "itkAffineTransform.h" #include "itkMatrixOffsetTransformBase.h" #ifdef CABLE_CONFIGURATION namespace _cable_ { const char* const group="CommonSuperclasses"; namespace wrappers { ITK_WRAP_OBJECT(Object) ITK_WRAP_OBJECT(DataObject) ITK_WRAP_OBJECT(ProcessObject) ITK_WRAP_OBJECT(LightObject) ITK_WRAP_OBJECT(ObjectFactoryBase) typedef itk::EndEvent::EndEvent EndEvent; typedef mbilog::AbstractBackend::AbstractBackend AbstractBackend; typedef itk::AffineTransform::AffineTransform AffineTransform_F3U; typedef itk::AffineTransform::Pointer::SmartPointer AffineTransform_F3U_Pointer; typedef itk::MatrixOffsetTransformBase::MatrixOffsetTransformBase MatrixOffsetTransformBase_F3U3U; typedef itk::MatrixOffsetTransformBase::Pointer::SmartPointer MatrixOffsetTransformBase_F3U3U_Pointer; } } #endif