diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index 9db1edf188..155f67d401 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -1,53 +1,53 @@ set(MITK_DEFAULT_SUBPROJECTS MITK-Examples) #----------------------------------------------------------------------------- # Set-up example plugins #----------------------------------------------------------------------------- if(MITK_USE_BLUEBERRY) # Specify which plug-ins belong to this project macro(GetMyTargetLibraries all_target_libraries varname) set(re_ctkplugin_mitk "^org_mitk_example_[a-zA-Z0-9_]+$") set(_tmp_list) list(APPEND _tmp_list ${all_target_libraries}) ctkMacroListFilter(_tmp_list re_ctkplugin_mitk OUTPUT_VARIABLE ${varname}) endmacro() set(MITK_EXAMPLE_PLUGIN_TARGETS ) foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS}) ctkFunctionExtractOptionNameAndValue(${mitk_example_plugin} plugin_name plugin_value) string(REPLACE "." "_" _plugin_target ${plugin_name}) list(APPEND MITK_EXAMPLE_PLUGIN_TARGETS ${_plugin_target}) mark_as_advanced(${${_plugin_target}_option_name}) endforeach() endif() #----------------------------------------------------------------------------- # Add example executables #----------------------------------------------------------------------------- set(MITK_DIR ${PROJECT_BINARY_DIR}) set(MITK_EXPORTS_FILE_INCLUDED 1) set(_example_dirs Dump MbiLog QtFreeRender Tutorial FirstSteps QuickRender -# Overlays# depends on MitkQtWidgetsExt.. +# Annotation# depends on MitkQtWidgetsExt.. ) if(MITK_USE_BLUEBERRY) list(APPEND _example_dirs BlueBerryExampleLauncher ) endif() foreach(_example_dir ${_example_dirs}) add_subdirectory(${_example_dir}) endforeach() diff --git a/Modules/Overlays/CMakeLists.txt b/Modules/Annotation/CMakeLists.txt similarity index 100% rename from Modules/Overlays/CMakeLists.txt rename to Modules/Annotation/CMakeLists.txt diff --git a/Modules/Overlays/doc/doxygen/OverlaysModule.dox b/Modules/Annotation/doc/doxygen/OverlaysModule.dox similarity index 100% rename from Modules/Overlays/doc/doxygen/OverlaysModule.dox rename to Modules/Annotation/doc/doxygen/OverlaysModule.dox diff --git a/Modules/Annotation/files.cmake b/Modules/Annotation/files.cmake new file mode 100644 index 0000000000..22111606ce --- /dev/null +++ b/Modules/Annotation/files.cmake @@ -0,0 +1,17 @@ +file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") + +set(CPP_FILES + mitkManualPlacementAnnotationRenderer.cpp + mitkColorBarAnnotation.cpp + mitkLabelAnnotation3D.cpp + mitkLogoAnnotation.cpp + mitkLayoutAnnotationRenderer.cpp + mitkScaleLegendAnnotation.cpp + mitkTextAnnotation2D.cpp + mitkTextAnnotation3D.cpp + mitkVtkLogoRepresentation.cxx + mitkVtkAnnotation.cpp + mitkVtkAnnotation2D.cpp + mitkVtkAnnotation3D.cpp +) + diff --git a/Modules/Overlays/include/mitkColorBarOverlay.h b/Modules/Annotation/include/mitkColorBarAnnotation.h similarity index 79% rename from Modules/Overlays/include/mitkColorBarOverlay.h rename to Modules/Annotation/include/mitkColorBarAnnotation.h index 10df36efd8..760efe568c 100644 --- a/Modules/Overlays/include/mitkColorBarOverlay.h +++ b/Modules/Annotation/include/mitkColorBarAnnotation.h @@ -1,97 +1,97 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef COLORBAROVERLAY_H -#define COLORBAROVERLAY_H +#ifndef COLORBARAnnotation_H +#define COLORBARAnnotation_H -#include "MitkOverlaysExports.h" +#include "MitkAnnotationExports.h" #include -#include +#include #include #include class vtkScalarBarActor; namespace mitk { /** \brief Displays configurable scales on the renderwindow. The scale is determined by the image spacing. */ - class MITKOVERLAYS_EXPORT ColorBarOverlay : public mitk::VtkOverlay + class MITKANNOTATION_EXPORT ColorBarAnnotation : public mitk::VtkAnnotation { public: - class LocalStorage : public mitk::Overlay::BaseLocalStorage + class LocalStorage : public mitk::Annotation::BaseLocalStorage { public: /** \brief Actor of a 2D render window. */ vtkSmartPointer m_ScalarBarActor; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastUpdateTime; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage(); }; - mitkClassMacro(ColorBarOverlay, mitk::VtkOverlay); + mitkClassMacro(ColorBarAnnotation, mitk::VtkAnnotation); itkFactorylessNewMacro(Self) itkCloneMacro(Self) void SetDrawAnnotations(bool annotations); bool GetDrawAnnotations() const; void SetOrientationToHorizontal(); void SetOrientationToVertical(); void SetOrientation(int orientation); int GetOrientation() const; void SetMaxNumberOfColors(int numberOfColors); int GetMaxNumberOfColors() const; void SetNumberOfLabels(int numberOfLabels); int GetNumberOfLabels() const; void SetLookupTable(vtkSmartPointer table); vtkSmartPointer GetLookupTable() const; void SetDrawTickLabels(bool ticks); bool GetDrawTickLabels() const; void SetAnnotationTextScaling(bool scale); bool GetAnnotationTextScaling() const; protected: /** \brief The LocalStorageHandler holds all LocalStorages for the render windows. */ mutable mitk::LocalStorageHandler m_LSH; virtual vtkProp *GetVtkProp(BaseRenderer *renderer) const override; - virtual void UpdateVtkOverlay(BaseRenderer *renderer) override; + virtual void UpdateVtkAnnotation(BaseRenderer *renderer) override; /** \brief explicit constructor which disallows implicit conversions */ - explicit ColorBarOverlay(); + explicit ColorBarAnnotation(); /** \brief virtual destructor in order to derive from this class */ - virtual ~ColorBarOverlay(); + virtual ~ColorBarAnnotation(); private: /** \brief copy constructor */ - ColorBarOverlay(const ColorBarOverlay &); + ColorBarAnnotation(const ColorBarAnnotation &); /** \brief assignment operator */ - ColorBarOverlay &operator=(const ColorBarOverlay &); + ColorBarAnnotation &operator=(const ColorBarAnnotation &); }; } // namespace mitk -#endif // COLORBAROVERLAY_H +#endif // COLORBARAnnotation_H diff --git a/Modules/Overlays/include/mitkLabelOverlay3D.h b/Modules/Annotation/include/mitkLabelAnnotation3D.h similarity index 84% rename from Modules/Overlays/include/mitkLabelOverlay3D.h rename to Modules/Annotation/include/mitkLabelAnnotation3D.h index 34ce6b7aaf..a059c90a8d 100644 --- a/Modules/Overlays/include/mitkLabelOverlay3D.h +++ b/Modules/Annotation/include/mitkLabelAnnotation3D.h @@ -1,112 +1,112 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef LabelOverlay3D_H -#define LabelOverlay3D_H +#ifndef LabelAnnotation3D_H +#define LabelAnnotation3D_H -#include "MitkOverlaysExports.h" +#include "MitkAnnotationExports.h" #include -#include +#include #include class vtkStringArray; class vtkPolyDataMapper; class vtkPolyData; class vtkActor2D; class vtkProperty2D; class vtkPointSetToLabelHierarchy; class vtkLabelPlacementMapper; class vtkIntArray; namespace mitk { class PointSet; /** \brief Can display a high amount of 3D labels to a PointSet */ - class MITKOVERLAYS_EXPORT LabelOverlay3D : public mitk::VtkOverlay3D + class MITKANNOTATION_EXPORT LabelAnnotation3D : public mitk::VtkAnnotation3D { public: /** \brief Internal class holding the vtkActor, etc. for each of the render windows */ - class LocalStorage : public mitk::Overlay::BaseLocalStorage + class LocalStorage : public mitk::Annotation::BaseLocalStorage { public: vtkSmartPointer m_Points; vtkSmartPointer m_LabelsActor; vtkSmartPointer m_Sizes; vtkSmartPointer m_Labels; vtkSmartPointer m_LabelMapper; vtkSmartPointer m_PointSetToLabelHierarchyFilter; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastUpdateTime; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage(); }; - mitkClassMacro(LabelOverlay3D, mitk::VtkOverlay3D); + mitkClassMacro(LabelAnnotation3D, mitk::VtkAnnotation3D); itkFactorylessNewMacro(Self) itkCloneMacro(Self) /** \brief Set the vector of labels that are shown to each corresponding point3D. The size has to be equal to the provided LabelCoordinates. */ void SetLabelVector(const std::vector &LabelVector); /** \brief Optional: Provide a vector of priorities. The labels with higher priorities will be visible in lower LOD */ void SetPriorityVector(const std::vector &PriorityVector); /** \brief Coordinates of the labels */ void SetLabelCoordinates(itk::SmartPointer LabelCoordinates); void PointSetModified(const itk::Object *, const itk::EventObject &); protected: /** \brief The LocalStorageHandler holds all LocalStorages for the render windows. */ mutable mitk::LocalStorageHandler m_LSH; virtual vtkProp *GetVtkProp(BaseRenderer *renderer) const override; - void UpdateVtkOverlay(mitk::BaseRenderer *renderer) override; + void UpdateVtkAnnotation(mitk::BaseRenderer *renderer) override; /** \brief explicit constructor which disallows implicit conversions */ - explicit LabelOverlay3D(); + explicit LabelAnnotation3D(); /** \brief virtual destructor in order to derive from this class */ - virtual ~LabelOverlay3D(); + virtual ~LabelAnnotation3D(); private: /** \brief The char arrays in this vector are displayed at the corresponding coordinates.*/ std::vector m_LabelVector; /** \brief values in this array set a priority to each label. Higher priority labels are not covert by labels with * lower priority.*/ std::vector m_PriorityVector; /** \brief The coordinates of the labels. Indices must match the labelVector and the priorityVector.*/ itk::SmartPointer m_LabelCoordinates; unsigned long m_PointSetModifiedObserverTag; /** \brief copy constructor */ - LabelOverlay3D(const LabelOverlay3D &); + LabelAnnotation3D(const LabelAnnotation3D &); /** \brief assignment operator */ - LabelOverlay3D &operator=(const LabelOverlay3D &); + LabelAnnotation3D &operator=(const LabelAnnotation3D &); }; } // namespace mitk -#endif // LabelOverlay3D_H +#endif // LabelAnnotation3D_H diff --git a/Modules/Annotation/include/mitkLayoutAnnotationRenderer.h b/Modules/Annotation/include/mitkLayoutAnnotationRenderer.h new file mode 100644 index 0000000000..a7715f4244 --- /dev/null +++ b/Modules/Annotation/include/mitkLayoutAnnotationRenderer.h @@ -0,0 +1,103 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef LayoutAnnotationRenderer_H +#define LayoutAnnotationRenderer_H + +#include "MitkAnnotationExports.h" +#include "mitkAbstractAnnotationRenderer.h" + +namespace mitk +{ + class BaseRenderer; + + /** \brief The LayoutAnnotationRenderer updates and manages Annotation and the respective Layouters. */ + /** An Instance of the LayoutAnnotationRenderer can be registered to several BaseRenderer instances in order to + * call the update method of each Annotation during the rendering phase of the renderer. + * See \ref AnnotationPage for more info. + */ + class MITKANNOTATION_EXPORT LayoutAnnotationRenderer : public AbstractAnnotationRenderer + { + public: + static const std::string PROP_LAYOUT; + static const std::string PROP_LAYOUT_PRIORITY; + static const std::string PROP_LAYOUT_ALIGNMENT; + static const std::string PROP_LAYOUT_MARGIN; + enum Alignment + { + TopLeft, + Top, + TopRight, + BottomLeft, + Bottom, + BottomRight, + Left, + Right + }; + typedef std::multimap AnnotationRankedMap; + typedef std::map AnnotationLayouterContainerMap; + + /** \brief virtual destructor in order to derive from this class */ + virtual ~LayoutAnnotationRenderer(); + + const std::string GetID() const; + + static LayoutAnnotationRenderer *GetAnnotationRenderer(const std::string &rendererID); + + void OnRenderWindowModified(); + + static void AddAnnotation(Annotation *annotation, + const std::string &rendererID, + Alignment alignment = TopLeft, + double marginX = 5, + double marginY = 5, + int priority = -1); + + static void AddAnnotation(Annotation *annotation, + BaseRenderer *renderer, + Alignment alignment = TopLeft, + double marginX = 5, + double marginY = 5, + int priority = -1); + + void PrepareLayout(); + + private: + LayoutAnnotationRenderer(const std::string &rendererId); + + static void AddAlignmentProperty(Annotation *annotation, Alignment activeAlignment, Point2D margin, int priority); + + void PrepareTopLeftLayout(int *displaySize); + void PrepareTopLayout(int *displaySize); + void PrepareTopRightLayout(int *displaySize); + void PrepareBottomLeftLayout(int *displaySize); + void PrepareBottomLayout(int *displaySize); + void PrepareBottomRightLayout(int *displaySize); + void PrepareLeftLayout(int *displaySize); + void PrepareRightLayout(int *displaySize); + + static double GetHeight(AnnotationRankedMap &annotations, BaseRenderer *renderer); + + virtual void OnAnnotationRenderersChanged(); + static const std::string ANNOTATIONRENDERER_ID; + AnnotationLayouterContainerMap m_AnnotationContainerMap; + static void SetMargin2D(Annotation *annotation, const Point2D &OffsetVector); + static Point2D GetMargin2D(Annotation *annotation); + }; + +} // namespace mitk + +#endif // LayoutAnnotationRenderer_H diff --git a/Modules/Overlays/include/mitkLogoOverlay.h b/Modules/Annotation/include/mitkLogoAnnotation.h similarity index 81% rename from Modules/Overlays/include/mitkLogoOverlay.h rename to Modules/Annotation/include/mitkLogoAnnotation.h index e76e657765..b0080ad9ad 100644 --- a/Modules/Overlays/include/mitkLogoOverlay.h +++ b/Modules/Annotation/include/mitkLogoAnnotation.h @@ -1,102 +1,102 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef LOGOOVERLAY_H -#define LOGOOVERLAY_H +#ifndef LOGOAnnotation_H +#define LOGOAnnotation_H -#include "MitkOverlaysExports.h" +#include "MitkAnnotationExports.h" #include -#include +#include #include class mitkVtkLogoRepresentation; class vtkImageData; class vtkImageReader2Factory; class vtkImageImport; namespace mitk { /** \brief Displays a logo on the renderwindow */ - class MITKOVERLAYS_EXPORT LogoOverlay : public mitk::VtkOverlay + class MITKANNOTATION_EXPORT LogoAnnotation : public mitk::VtkAnnotation { public: - class LocalStorage : public mitk::Overlay::BaseLocalStorage + class LocalStorage : public mitk::Annotation::BaseLocalStorage { public: /** \brief Actor of a 2D render window. */ vtkSmartPointer m_LogoImage; vtkSmartPointer m_LogoRep; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastUpdateTime; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage(); }; - mitkClassMacro(LogoOverlay, mitk::VtkOverlay); + mitkClassMacro(LogoAnnotation, mitk::VtkAnnotation); itkFactorylessNewMacro(Self) itkCloneMacro(Self) vtkSmartPointer m_readerFactory; void SetLogoImagePath(std::string text); std::string GetLogoImagePath() const; /** \brief The relative offset to the corner position */ void SetOffsetVector(const Point2D &OffsetVector); Point2D GetOffsetVector() const; /** \brief The corner where the logo is displayed. 0 = Bottom left 1 = Bottom right 2 = Top right 3 = Top left 4 = Center*/ void SetCornerPosition(const int &corner); int GetCornerPosition() const; void SetRelativeSize(const float &size); float GetRelativeSize() const; protected: /** \brief The LocalStorageHandler holds all LocalStorages for the render windows. */ mutable mitk::LocalStorageHandler m_LSH; virtual vtkProp *GetVtkProp(BaseRenderer *renderer) const override; - void UpdateVtkOverlay(mitk::BaseRenderer *renderer) override; + void UpdateVtkAnnotation(mitk::BaseRenderer *renderer) override; vtkImageData *CreateMbiLogo(); /** \brief explicit constructor which disallows implicit conversions */ - explicit LogoOverlay(); + explicit LogoAnnotation(); /** \brief virtual destructor in order to derive from this class */ - virtual ~LogoOverlay(); + virtual ~LogoAnnotation(); private: vtkSmartPointer m_VtkImageImport; /** \brief copy constructor */ - LogoOverlay(const LogoOverlay &); + LogoAnnotation(const LogoAnnotation &); /** \brief assignment operator */ - LogoOverlay &operator=(const LogoOverlay &); + LogoAnnotation &operator=(const LogoAnnotation &); }; } // namespace mitk -#endif // LOGOOVERLAY_H +#endif // LOGOAnnotation_H diff --git a/Modules/Annotation/include/mitkManualPlacementAnnotationRenderer.h b/Modules/Annotation/include/mitkManualPlacementAnnotationRenderer.h new file mode 100644 index 0000000000..a24a6a2f57 --- /dev/null +++ b/Modules/Annotation/include/mitkManualPlacementAnnotationRenderer.h @@ -0,0 +1,54 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef ManualPlacementAnnotationRenderer_H +#define ManualPlacementAnnotationRenderer_H + +#include "MitkAnnotationExports.h" +#include "mitkAbstractAnnotationRenderer.h" +#include "mitkAnnotation.h" + +namespace mitk +{ + class BaseRenderer; + + /** \brief The ManualPlacementAnnotationRenderer updates and manages Annotation and the respective Layouters. */ + /** An Instance of the ManualPlacementAnnotationRenderer can be registered to several BaseRenderer instances in order + * to + * call the update method of each Annotation during the rendering phase of the renderer. + * See \ref AnnotationPage for more info. + */ + class MITKANNOTATION_EXPORT ManualPlacementAnnotationRenderer : public AbstractAnnotationRenderer + { + public: + /** \brief virtual destructor in order to derive from this class */ + virtual ~ManualPlacementAnnotationRenderer(); + + static ManualPlacementAnnotationRenderer *GetAnnotationRenderer(const std::string &rendererID); + + static void AddAnnotation(Annotation *Annotation, const std::string &rendererID); + + static void AddAnnotation(Annotation *Annotation, BaseRenderer *renderer); + + private: + ManualPlacementAnnotationRenderer(const std::string &rendererId); + + static const std::string ANNOTATIONRENDERER_ID; + }; + +} // namespace mitk + +#endif // ManualPlacementAnnotationRenderer_H diff --git a/Modules/Overlays/include/mitkScaleLegendOverlay.h b/Modules/Annotation/include/mitkScaleLegendAnnotation.h similarity index 80% rename from Modules/Overlays/include/mitkScaleLegendOverlay.h rename to Modules/Annotation/include/mitkScaleLegendAnnotation.h index cab47272cd..db3bc511a7 100644 --- a/Modules/Overlays/include/mitkScaleLegendOverlay.h +++ b/Modules/Annotation/include/mitkScaleLegendAnnotation.h @@ -1,106 +1,106 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef SCALELEGENDOVERLAY_H -#define SCALELEGENDOVERLAY_H +#ifndef SCALELEGENDAnnotation_H +#define SCALELEGENDAnnotation_H -#include "MitkOverlaysExports.h" +#include "MitkAnnotationExports.h" #include -#include +#include #include class vtkLegendScaleActor; namespace mitk { /** \brief Displays configurable scales on the renderwindow. The scale is determined by the image spacing. */ - class MITKOVERLAYS_EXPORT ScaleLegendOverlay : public mitk::VtkOverlay + class MITKANNOTATION_EXPORT ScaleLegendAnnotation : public mitk::VtkAnnotation { public: - class LocalStorage : public mitk::Overlay::BaseLocalStorage + class LocalStorage : public mitk::Annotation::BaseLocalStorage { public: /** \brief Actor of a 2D render window. */ vtkSmartPointer m_legendScaleActor; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastUpdateTime; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage(); }; - mitkClassMacro(ScaleLegendOverlay, mitk::VtkOverlay); + mitkClassMacro(ScaleLegendAnnotation, mitk::VtkAnnotation); itkFactorylessNewMacro(Self) itkCloneMacro(Self) void SetRightAxisVisibility(bool visibility); bool GetRightAxisVisibility() const; void SetLeftAxisVisibility(bool visibility); bool GetLeftAxisVisibility() const; void SetTopAxisVisibility(bool visibility); bool GetTopAxisVisibility() const; void SetBottomAxisVisibility(bool visibility); bool GetBottomAxisVisibility() const; void SetLegendVisibility(bool visibility); bool GetLegendVisibility() const; void SetRightBorderOffset(int offset); int GetRightBorderOffset() const; void SetLeftBorderOffset(int offset); int GetLeftBorderOffset() const; void SetTopBorderOffset(int offset); int GetTopBorderOffset() const; void SetBottomBorderOffset(int offset); int GetBottomBorderOffset() const; void SetFontFactor(double fontFactor); double GetFontFactor() const; void SetCornerOffsetFactor(double offsetFactor); double GetCornerOffsetFactor() const; protected: /** \brief The LocalStorageHandler holds all LocalStorages for the render windows. */ mutable mitk::LocalStorageHandler m_LSH; virtual vtkProp *GetVtkProp(BaseRenderer *renderer) const override; - virtual void UpdateVtkOverlay(BaseRenderer *renderer) override; + virtual void UpdateVtkAnnotation(BaseRenderer *renderer) override; /** \brief explicit constructor which disallows implicit conversions */ - explicit ScaleLegendOverlay(); + explicit ScaleLegendAnnotation(); /** \brief virtual destructor in order to derive from this class */ - virtual ~ScaleLegendOverlay(); + virtual ~ScaleLegendAnnotation(); private: /** \brief copy constructor */ - ScaleLegendOverlay(const ScaleLegendOverlay &); + ScaleLegendAnnotation(const ScaleLegendAnnotation &); /** \brief assignment operator */ - ScaleLegendOverlay &operator=(const ScaleLegendOverlay &); + ScaleLegendAnnotation &operator=(const ScaleLegendAnnotation &); }; } // namespace mitk -#endif // SCALELEGENDOVERLAY_H +#endif // SCALELEGENDAnnotation_H diff --git a/Modules/Overlays/include/mitkTextOverlay2D.h b/Modules/Annotation/include/mitkTextAnnotation2D.h similarity index 74% rename from Modules/Overlays/include/mitkTextOverlay2D.h rename to Modules/Annotation/include/mitkTextAnnotation2D.h index c4ccedcfe0..cac8c9ada3 100644 --- a/Modules/Overlays/include/mitkTextOverlay2D.h +++ b/Modules/Annotation/include/mitkTextAnnotation2D.h @@ -1,86 +1,86 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef TEXTOVERLAY2D_H -#define TEXTOVERLAY2D_H +#ifndef TEXTAnnotation2D_H +#define TEXTAnnotation2D_H -#include "MitkOverlaysExports.h" +#include "MitkAnnotationExports.h" #include -#include +#include #include class vtkTextActor; class vtkPropAssembly; namespace mitk { /** \brief Displays text on the renderwindow */ - class MITKOVERLAYS_EXPORT TextOverlay2D : public mitk::VtkOverlay2D + class MITKANNOTATION_EXPORT TextAnnotation2D : public mitk::VtkAnnotation2D { public: - class LocalStorage : public mitk::Overlay::BaseLocalStorage + class LocalStorage : public mitk::Annotation::BaseLocalStorage { public: /** \brief Actor of a 2D render window. */ vtkSmartPointer m_TextActor; vtkSmartPointer m_TextProp; vtkSmartPointer m_STextActor; vtkSmartPointer m_STextProp; vtkSmartPointer m_Assembly; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastUpdateTime; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage(); }; - mitkClassMacro(TextOverlay2D, mitk::VtkOverlay2D); + mitkClassMacro(TextAnnotation2D, mitk::VtkAnnotation2D); itkFactorylessNewMacro(Self) itkCloneMacro(Self) - virtual Overlay::Bounds GetBoundsOnDisplay(BaseRenderer *renderer) const override; + virtual Annotation::Bounds GetBoundsOnDisplay(BaseRenderer *renderer) const override; virtual void SetBoundsOnDisplay(BaseRenderer *renderer, const Bounds &bounds) override; protected: /** \brief The LocalStorageHandler holds all LocalStorages for the render windows. */ mutable mitk::LocalStorageHandler m_LSH; vtkProp *GetVtkProp(BaseRenderer *renderer) const override; virtual vtkActor2D *GetVtkActor2D(BaseRenderer *renderer) const override; - void UpdateVtkOverlay2D(mitk::BaseRenderer *renderer) override; + void UpdateVtkAnnotation2D(mitk::BaseRenderer *renderer) override; /** \brief explicit constructor which disallows implicit conversions */ - explicit TextOverlay2D(); + explicit TextAnnotation2D(); /** \brief virtual destructor in order to derive from this class */ - virtual ~TextOverlay2D(); + virtual ~TextAnnotation2D(); private: /** \brief copy constructor */ - TextOverlay2D(const TextOverlay2D &); + TextAnnotation2D(const TextAnnotation2D &); /** \brief assignment operator */ - TextOverlay2D &operator=(const TextOverlay2D &); + TextAnnotation2D &operator=(const TextAnnotation2D &); }; } // namespace mitk -#endif // TEXTOVERLAY2D_H +#endif // TEXTAnnotation2D_H diff --git a/Modules/Overlays/include/mitkTextOverlay3D.h b/Modules/Annotation/include/mitkTextAnnotation3D.h similarity index 72% rename from Modules/Overlays/include/mitkTextOverlay3D.h rename to Modules/Annotation/include/mitkTextAnnotation3D.h index 7f4d4aa32f..832f7b6f60 100644 --- a/Modules/Overlays/include/mitkTextOverlay3D.h +++ b/Modules/Annotation/include/mitkTextAnnotation3D.h @@ -1,84 +1,84 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef TextOverlay3D_H -#define TextOverlay3D_H +#ifndef TextAnnotation3D_H +#define TextAnnotation3D_H -#include "MitkOverlaysExports.h" +#include "MitkAnnotationExports.h" #include -#include +#include class vtkFollower; class vtkVectorText; class vtkTextActor3D; namespace mitk { /** \brief Displays at 3D position, always facing the camera */ - class MITKOVERLAYS_EXPORT TextOverlay3D : public mitk::VtkOverlay3D + class MITKANNOTATION_EXPORT TextAnnotation3D : public mitk::VtkAnnotation3D { public: /** \brief Internal class holding the mapper, actor, etc. for each of the render windows */ /** - * To render the Overlay on transveral, coronal, and sagittal, the update method + * To render the Annotation on transveral, coronal, and sagittal, the update method * is called for each renderwindow. For performance reasons, the corresponding data * for each view is saved in the internal helper class LocalStorage. - * This allows rendering n views with just 1 mitkOverlay using n vtkMapper. + * This allows rendering n views with just 1 mitkAnnotation using n vtkMapper. * */ - class LocalStorage : public mitk::Overlay::BaseLocalStorage + class LocalStorage : public mitk::Annotation::BaseLocalStorage { public: /** \brief Actor of a 2D render window. */ vtkSmartPointer m_follower; vtkSmartPointer m_textSource; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastUpdateTime; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage(); }; - mitkClassMacro(TextOverlay3D, mitk::VtkOverlay3D); + mitkClassMacro(TextAnnotation3D, mitk::VtkAnnotation3D); itkFactorylessNewMacro(Self) itkCloneMacro(Self) protected : /** \brief The LocalStorageHandler holds all LocalStorages for the render windows. */ mutable mitk::LocalStorageHandler m_LSH; virtual vtkProp *GetVtkProp(BaseRenderer *renderer) const override; - void UpdateVtkOverlay(mitk::BaseRenderer *renderer) override; + void UpdateVtkAnnotation(mitk::BaseRenderer *renderer) override; /** \brief explicit constructor which disallows implicit conversions */ - explicit TextOverlay3D(); + explicit TextAnnotation3D(); /** \brief virtual destructor in order to derive from this class */ - virtual ~TextOverlay3D(); + virtual ~TextAnnotation3D(); private: /** \brief copy constructor */ - TextOverlay3D(const TextOverlay3D &); + TextAnnotation3D(const TextAnnotation3D &); /** \brief assignment operator */ - TextOverlay3D &operator=(const TextOverlay3D &); + TextAnnotation3D &operator=(const TextAnnotation3D &); }; } // namespace mitk -#endif // TextOverlay3D_H +#endif // TextAnnotation3D_H diff --git a/Modules/Overlays/include/mitkVtkOverlay.h b/Modules/Annotation/include/mitkVtkAnnotation.h similarity index 62% rename from Modules/Overlays/include/mitkVtkOverlay.h rename to Modules/Annotation/include/mitkVtkAnnotation.h index c16a46b5c3..9543c9449c 100644 --- a/Modules/Overlays/include/mitkVtkOverlay.h +++ b/Modules/Annotation/include/mitkVtkAnnotation.h @@ -1,75 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef VTKOVERLAY_H -#define VTKOVERLAY_H +#ifndef VTKAnnotation_H +#define VTKAnnotation_H -#include "mitkOverlay.h" -#include +#include "mitkAnnotation.h" +#include #include class vtkProp; namespace mitk { /** - * @brief The VtkOverlay class is the base for all Overlays which are using the VTK framework to render + * @brief The VtkAnnotation class is the base for all Annotation which are using the VTK framework to render *the elements. */ - class MITKCORE_EXPORT VtkOverlay : public Overlay + class MITKANNOTATION_EXPORT VtkAnnotation : public Annotation { public: - mitkClassMacro(VtkOverlay, Overlay); + mitkClassMacro(VtkAnnotation, Annotation); void Update(BaseRenderer *renderer) override; void AddToBaseRenderer(BaseRenderer *renderer) override; void AddToRenderer(BaseRenderer *renderer, vtkRenderer *vtkrenderer) override; void RemoveFromRenderer(BaseRenderer *renderer, vtkRenderer *vtkrenderer) override; void RemoveFromBaseRenderer(BaseRenderer *renderer) override; /** - * \brief Paints the overlay. + * \brief Paints the Annotation. * - * This method forces a paint of the overlay as it is configured at the moment. - * \warn Should only be used as alternative to the OverlayManager mechanism + * This method forces a paint of the Annotation as it is configured at the moment. + * \warn Should only be used as alternative to the AnnotationManager mechanism * in GL-Mappers. */ void Paint(BaseRenderer *renderer); protected: /** - * @brief This method is implemented by the specific VTKOverlays in order to create the element as a vtkProp + * @brief This method is implemented by the specific VTKAnnotation in order to create the element as a vtkProp * @param renderer * @return The element that was created by the subclasses as a vtkProp. */ virtual vtkProp *GetVtkProp(BaseRenderer *renderer) const = 0; - virtual void UpdateVtkOverlay(BaseRenderer *renderer) = 0; + virtual void UpdateVtkAnnotation(BaseRenderer *renderer) = 0; /** \brief explicit constructor which disallows implicit conversions */ - explicit VtkOverlay(); + explicit VtkAnnotation(); /** \brief virtual destructor in order to derive from this class */ - virtual ~VtkOverlay(); + virtual ~VtkAnnotation(); private: /** \brief copy constructor */ - VtkOverlay(const VtkOverlay &); + VtkAnnotation(const VtkAnnotation &); /** \brief assignment operator */ - VtkOverlay &operator=(const VtkOverlay &); + VtkAnnotation &operator=(const VtkAnnotation &); }; } // namespace mitk -#endif // OVERLAY_H +#endif // Annotation_H diff --git a/Modules/Overlays/include/mitkVtkOverlay2D.h b/Modules/Annotation/include/mitkVtkAnnotation2D.h similarity index 64% rename from Modules/Overlays/include/mitkVtkOverlay2D.h rename to Modules/Annotation/include/mitkVtkAnnotation2D.h index 4cf4d9ee9e..0d6aa50f3c 100644 --- a/Modules/Overlays/include/mitkVtkOverlay2D.h +++ b/Modules/Annotation/include/mitkVtkAnnotation2D.h @@ -1,69 +1,69 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef VTKOVERLAY2D_H -#define VTKOVERLAY2D_H +#ifndef VTKAnnotation2D_H +#define VTKAnnotation2D_H -#include "mitkVtkOverlay.h" -#include +#include "mitkVtkAnnotation.h" +#include #include class vtkActor2D; class vtkProperty2D; namespace mitk { /** - * @brief The VtkOverlay2D class is the basis for all VTK based Overlays which create + * @brief The VtkAnnotation2D class is the basis for all VTK based Annotation which create * a vtkActor2D element that will be drawn on the renderer. */ - class MITKCORE_EXPORT VtkOverlay2D : public VtkOverlay + class MITKANNOTATION_EXPORT VtkAnnotation2D : public VtkAnnotation { public: - mitkClassMacro(VtkOverlay2D, VtkOverlay); - virtual Overlay::Bounds GetBoundsOnDisplay(BaseRenderer *renderer) const override; + mitkClassMacro(VtkAnnotation2D, VtkAnnotation); + virtual Annotation::Bounds GetBoundsOnDisplay(BaseRenderer *renderer) const override; virtual void SetBoundsOnDisplay(BaseRenderer *renderer, const Bounds &bounds) override; void SetPosition2D(const Point2D &position2D); Point2D GetPosition2D() const; void SetOffsetVector(const Point2D &OffsetVector); Point2D GetOffsetVector() const; protected: virtual vtkProp *GetVtkProp(BaseRenderer *renderer) const override; - virtual void UpdateVtkOverlay(BaseRenderer *renderer) override; - virtual void UpdateVtkOverlay2D(BaseRenderer *renderer) = 0; + virtual void UpdateVtkAnnotation(BaseRenderer *renderer) override; + virtual void UpdateVtkAnnotation2D(BaseRenderer *renderer) = 0; virtual vtkActor2D *GetVtkActor2D(BaseRenderer *renderer) const = 0; /** \brief explicit constructor which disallows implicit conversions */ - explicit VtkOverlay2D(); + explicit VtkAnnotation2D(); /** \brief virtual destructor in order to derive from this class */ - virtual ~VtkOverlay2D(); + virtual ~VtkAnnotation2D(); private: /** \brief copy constructor */ - VtkOverlay2D(const VtkOverlay2D &); + VtkAnnotation2D(const VtkAnnotation2D &); /** \brief assignment operator */ - VtkOverlay2D &operator=(const VtkOverlay2D &); + VtkAnnotation2D &operator=(const VtkAnnotation2D &); }; } // namespace mitk -#endif // VTKOVERLAY2D_H +#endif // VTKAnnotation2D_H diff --git a/Modules/Overlays/include/mitkVtkOverlay3D.h b/Modules/Annotation/include/mitkVtkAnnotation3D.h similarity index 64% rename from Modules/Overlays/include/mitkVtkOverlay3D.h rename to Modules/Annotation/include/mitkVtkAnnotation3D.h index 08e43c0c6b..65a3d8cb4d 100644 --- a/Modules/Overlays/include/mitkVtkOverlay3D.h +++ b/Modules/Annotation/include/mitkVtkAnnotation3D.h @@ -1,61 +1,61 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef VTKOVERLAY3D_H -#define VTKOVERLAY3D_H +#ifndef VTKAnnotation3D_H +#define VTKAnnotation3D_H -#include "mitkVtkOverlay.h" -#include +#include "mitkVtkAnnotation.h" +#include #include namespace mitk { /** - * @brief The VtkOverlay3D class is the basis for all VTK based Overlays which create + * @brief The VtkAnnotation3D class is the basis for all VTK based Annotation which create * any 3D element as a vtkProp that will be drawn on the renderer. */ - class MITKCORE_EXPORT VtkOverlay3D : public VtkOverlay + class MITKANNOTATION_EXPORT VtkAnnotation3D : public VtkAnnotation { public: void SetPosition3D(const Point3D &position3D); Point3D GetPosition3D() const; void SetOffsetVector(const Point3D &OffsetVector); Point3D GetOffsetVector() const; - mitkClassMacro(VtkOverlay3D, VtkOverlay); + mitkClassMacro(VtkAnnotation3D, VtkAnnotation); protected: - virtual void UpdateVtkOverlay(BaseRenderer *renderer) override = 0; + virtual void UpdateVtkAnnotation(BaseRenderer *renderer) override = 0; /** \brief explicit constructor which disallows implicit conversions */ - explicit VtkOverlay3D(); + explicit VtkAnnotation3D(); /** \brief virtual destructor in order to derive from this class */ - virtual ~VtkOverlay3D(); + virtual ~VtkAnnotation3D(); private: /** \brief copy constructor */ - VtkOverlay3D(const VtkOverlay3D &); + VtkAnnotation3D(const VtkAnnotation3D &); /** \brief assignment operator */ - VtkOverlay3D &operator=(const VtkOverlay3D &); + VtkAnnotation3D &operator=(const VtkAnnotation3D &); }; } // namespace mitk -#endif // OVERLAY_H +#endif // Annotation_H diff --git a/Modules/Overlays/include/mitkVtkLogoRepresentation.h b/Modules/Annotation/include/mitkVtkLogoRepresentation.h similarity index 100% rename from Modules/Overlays/include/mitkVtkLogoRepresentation.h rename to Modules/Annotation/include/mitkVtkLogoRepresentation.h diff --git a/Modules/Overlays/src/mitkColorBarOverlay.cpp b/Modules/Annotation/src/mitkColorBarAnnotation.cpp similarity index 53% rename from Modules/Overlays/src/mitkColorBarOverlay.cpp rename to Modules/Annotation/src/mitkColorBarAnnotation.cpp index 20a2cf9653..9798634a5e 100644 --- a/Modules/Overlays/src/mitkColorBarOverlay.cpp +++ b/Modules/Annotation/src/mitkColorBarAnnotation.cpp @@ -1,183 +1,183 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkColorBarOverlay.h" +#include "mitkColorBarAnnotation.h" #include "mitkLookupTable.h" #include "mitkLookupTableProperty.h" #include -mitk::ColorBarOverlay::ColorBarOverlay() +mitk::ColorBarAnnotation::ColorBarAnnotation() { SetDrawAnnotations(true); SetDrawTickLabels(true); SetOrientationToVertical(); SetMaxNumberOfColors(100); SetNumberOfLabels(4); SetAnnotationTextScaling(false); SetLookupTable(NULL); } -mitk::ColorBarOverlay::~ColorBarOverlay() +mitk::ColorBarAnnotation::~ColorBarAnnotation() { } -mitk::ColorBarOverlay::LocalStorage::~LocalStorage() +mitk::ColorBarAnnotation::LocalStorage::~LocalStorage() { } -mitk::ColorBarOverlay::LocalStorage::LocalStorage() +mitk::ColorBarAnnotation::LocalStorage::LocalStorage() { m_ScalarBarActor = vtkSmartPointer::New(); } -void mitk::ColorBarOverlay::UpdateVtkOverlay(mitk::BaseRenderer *renderer) +void mitk::ColorBarAnnotation::UpdateVtkAnnotation(mitk::BaseRenderer *renderer) { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); if (ls->IsGenerateDataRequired(renderer, this)) { ls->m_ScalarBarActor->SetDrawAnnotations(this->GetDrawAnnotations()); ls->m_ScalarBarActor->SetLookupTable(this->GetLookupTable()); ls->m_ScalarBarActor->SetOrientation(this->GetOrientation()); ls->m_ScalarBarActor->SetDrawTickLabels(this->GetDrawTickLabels()); ls->m_ScalarBarActor->SetMaximumNumberOfColors(this->GetMaxNumberOfColors()); ls->m_ScalarBarActor->SetNumberOfLabels(this->GetNumberOfLabels()); ls->m_ScalarBarActor->SetAnnotationTextScaling(this->GetAnnotationTextScaling()); // manually set position so there is no overlap with mitk logo in 3d renderwindow if (this->GetOrientation() == 1) { ls->m_ScalarBarActor->SetPosition(0.80, 0.15); ls->m_ScalarBarActor->SetWidth(0.15); ls->m_ScalarBarActor->SetHeight(0.85); } else { ls->m_ScalarBarActor->SetPosition(0.03, 0.03); ls->m_ScalarBarActor->SetWidth(0.8); ls->m_ScalarBarActor->SetHeight(0.15); } } } -vtkProp *mitk::ColorBarOverlay::GetVtkProp(BaseRenderer *renderer) const +vtkProp *mitk::ColorBarAnnotation::GetVtkProp(BaseRenderer *renderer) const { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); return ls->m_ScalarBarActor; } -void mitk::ColorBarOverlay::SetDrawAnnotations(bool annotations) +void mitk::ColorBarAnnotation::SetDrawAnnotations(bool annotations) { - SetBoolProperty("ColorBarOverlay.DrawAnnotations", annotations); + SetBoolProperty("ColorBarAnnotation.DrawAnnotations", annotations); } -bool mitk::ColorBarOverlay::GetDrawAnnotations() const +bool mitk::ColorBarAnnotation::GetDrawAnnotations() const { bool annotations; - GetPropertyList()->GetBoolProperty("ColorBarOverlay.DrawAnnotations", annotations); + GetPropertyList()->GetBoolProperty("ColorBarAnnotation.DrawAnnotations", annotations); return annotations; } -void mitk::ColorBarOverlay::SetLookupTable(vtkSmartPointer table) +void mitk::ColorBarAnnotation::SetLookupTable(vtkSmartPointer table) { mitk::LookupTable::Pointer lut = mitk::LookupTable::New(); mitk::LookupTableProperty::Pointer prop = mitk::LookupTableProperty::New(lut); lut->SetVtkLookupTable(table); prop->SetLookupTable(lut); - SetProperty("ColorBarOverlay.LookupTable", prop.GetPointer()); + SetProperty("ColorBarAnnotation.LookupTable", prop.GetPointer()); } -vtkSmartPointer mitk::ColorBarOverlay::GetLookupTable() const +vtkSmartPointer mitk::ColorBarAnnotation::GetLookupTable() const { mitk::LookupTable::Pointer lut = mitk::LookupTable::New(); - lut = dynamic_cast(GetPropertyList()->GetProperty("ColorBarOverlay.LookupTable")) + lut = dynamic_cast(GetPropertyList()->GetProperty("ColorBarAnnotation.LookupTable")) ->GetLookupTable(); return lut->GetVtkLookupTable(); } -void mitk::ColorBarOverlay::SetOrientation(int orientation) +void mitk::ColorBarAnnotation::SetOrientation(int orientation) { - SetIntProperty("ColorBarOverlay.Orientation", orientation); + SetIntProperty("ColorBarAnnotation.Orientation", orientation); } -int mitk::ColorBarOverlay::GetOrientation() const +int mitk::ColorBarAnnotation::GetOrientation() const { int orientation; - GetPropertyList()->GetIntProperty("ColorBarOverlay.Orientation", orientation); + GetPropertyList()->GetIntProperty("ColorBarAnnotation.Orientation", orientation); return orientation; } -void mitk::ColorBarOverlay::SetDrawTickLabels(bool ticks) +void mitk::ColorBarAnnotation::SetDrawTickLabels(bool ticks) { - SetBoolProperty("ColorBarOverlay.DrawTicks", ticks); + SetBoolProperty("ColorBarAnnotation.DrawTicks", ticks); } -bool mitk::ColorBarOverlay::GetDrawTickLabels() const +bool mitk::ColorBarAnnotation::GetDrawTickLabels() const { bool ticks; - GetPropertyList()->GetBoolProperty("ColorBarOverlay.DrawTicks", ticks); + GetPropertyList()->GetBoolProperty("ColorBarAnnotation.DrawTicks", ticks); return ticks; } -void mitk::ColorBarOverlay::SetOrientationToHorizontal() +void mitk::ColorBarAnnotation::SetOrientationToHorizontal() { SetOrientation(0); } -void mitk::ColorBarOverlay::SetOrientationToVertical() +void mitk::ColorBarAnnotation::SetOrientationToVertical() { SetOrientation(1); } -void mitk::ColorBarOverlay::SetMaxNumberOfColors(int numberOfColors) +void mitk::ColorBarAnnotation::SetMaxNumberOfColors(int numberOfColors) { - SetIntProperty("ColorBarOverlay.MaximumNumberOfColors", numberOfColors); + SetIntProperty("ColorBarAnnotation.MaximumNumberOfColors", numberOfColors); } -int mitk::ColorBarOverlay::GetMaxNumberOfColors() const +int mitk::ColorBarAnnotation::GetMaxNumberOfColors() const { int numberOfColors; - GetPropertyList()->GetIntProperty("ColorBarOverlay.MaximumNumberOfColors", numberOfColors); + GetPropertyList()->GetIntProperty("ColorBarAnnotation.MaximumNumberOfColors", numberOfColors); return numberOfColors; } -void mitk::ColorBarOverlay::SetNumberOfLabels(int numberOfLabels) +void mitk::ColorBarAnnotation::SetNumberOfLabels(int numberOfLabels) { - SetIntProperty("ColorBarOverlay.NumberOfLabels", numberOfLabels); + SetIntProperty("ColorBarAnnotation.NumberOfLabels", numberOfLabels); } -int mitk::ColorBarOverlay::GetNumberOfLabels() const +int mitk::ColorBarAnnotation::GetNumberOfLabels() const { int numberOfLabels; - GetPropertyList()->GetIntProperty("ColorBarOverlay.NumberOfLabels", numberOfLabels); + GetPropertyList()->GetIntProperty("ColorBarAnnotation.NumberOfLabels", numberOfLabels); return numberOfLabels; } -void mitk::ColorBarOverlay::SetAnnotationTextScaling(bool scale) +void mitk::ColorBarAnnotation::SetAnnotationTextScaling(bool scale) { - SetBoolProperty("ColorBarOverlay.ScaleAnnotationText", scale); + SetBoolProperty("ColorBarAnnotation.ScaleAnnotationText", scale); } -bool mitk::ColorBarOverlay::GetAnnotationTextScaling() const +bool mitk::ColorBarAnnotation::GetAnnotationTextScaling() const { bool scale; - GetPropertyList()->GetBoolProperty("ColorBarOverlay.ScaleAnnotationText", scale); + GetPropertyList()->GetBoolProperty("ColorBarAnnotation.ScaleAnnotationText", scale); return scale; } diff --git a/Modules/Overlays/src/mitkLabelOverlay3D.cpp b/Modules/Annotation/src/mitkLabelAnnotation3D.cpp similarity index 80% rename from Modules/Overlays/src/mitkLabelOverlay3D.cpp rename to Modules/Annotation/src/mitkLabelAnnotation3D.cpp index 53383c63af..f4c9f78392 100644 --- a/Modules/Overlays/src/mitkLabelOverlay3D.cpp +++ b/Modules/Annotation/src/mitkLabelAnnotation3D.cpp @@ -1,163 +1,163 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkLabelOverlay3D.h" +#include "mitkLabelAnnotation3D.h" #include #include #include #include #include #include #include #include #include #include #include -mitk::LabelOverlay3D::LabelOverlay3D() : m_PointSetModifiedObserverTag(0) +mitk::LabelAnnotation3D::LabelAnnotation3D() : m_PointSetModifiedObserverTag(0) { } -mitk::LabelOverlay3D::~LabelOverlay3D() +mitk::LabelAnnotation3D::~LabelAnnotation3D() { if (m_LabelCoordinates.IsNotNull()) m_LabelCoordinates->RemoveObserver(m_PointSetModifiedObserverTag); } -mitk::LabelOverlay3D::LocalStorage::~LocalStorage() +mitk::LabelAnnotation3D::LocalStorage::~LocalStorage() { } -mitk::LabelOverlay3D::LocalStorage::LocalStorage() +mitk::LabelAnnotation3D::LocalStorage::LocalStorage() { m_Points = vtkSmartPointer::New(); // Add label array. m_Labels = vtkSmartPointer::New(); m_Labels->SetNumberOfValues(0); m_Labels->SetName("labels"); // Add priority array. m_Sizes = vtkSmartPointer::New(); m_Sizes->SetNumberOfValues(0); m_Sizes->SetName("sizes"); m_Points->GetPointData()->AddArray(m_Sizes); m_Points->GetPointData()->AddArray(m_Labels); m_PointSetToLabelHierarchyFilter = vtkSmartPointer::New(); m_PointSetToLabelHierarchyFilter->SetInputData(m_Points); m_PointSetToLabelHierarchyFilter->SetLabelArrayName("labels"); m_PointSetToLabelHierarchyFilter->SetPriorityArrayName("sizes"); m_PointSetToLabelHierarchyFilter->Update(); m_LabelMapper = vtkSmartPointer::New(); m_LabelMapper->SetInputConnection(m_PointSetToLabelHierarchyFilter->GetOutputPort()); m_LabelsActor = vtkSmartPointer::New(); m_LabelsActor->SetMapper(m_LabelMapper); } -void mitk::LabelOverlay3D::UpdateVtkOverlay(mitk::BaseRenderer *renderer) +void mitk::LabelAnnotation3D::UpdateVtkAnnotation(mitk::BaseRenderer *renderer) { if (m_LabelCoordinates.IsNull()) { MITK_WARN << "No pointset defined to print labels!"; return; } LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); if (ls->IsGenerateDataRequired(renderer, this)) { vtkSmartPointer points = vtkSmartPointer::New(); size_t pointsetsize = (size_t)m_LabelCoordinates->GetSize(); ls->m_Labels->SetNumberOfValues(pointsetsize); ls->m_Sizes->SetNumberOfValues(pointsetsize); for (size_t i = 0; i < pointsetsize; i++) { mitk::Point3D coordinate = m_LabelCoordinates->GetPoint(i); points->InsertNextPoint(coordinate[0] + GetOffsetVector()[0], coordinate[1] + GetOffsetVector()[1], coordinate[2] + GetOffsetVector()[2]); if (m_LabelVector.size() > i) ls->m_Labels->SetValue(i, m_LabelVector[i]); else ls->m_Labels->SetValue(i, ""); if (m_PriorityVector.size() > i) ls->m_Sizes->SetValue(i, m_PriorityVector[i]); else ls->m_Sizes->SetValue(i, 1); } ls->m_Points->SetPoints(points); ls->m_PointSetToLabelHierarchyFilter->Update(); ls->m_LabelMapper->Update(); float color[3] = {1, 1, 1}; float opacity = 1.0; GetColor(color); GetOpacity(opacity); ls->m_LabelsActor->GetProperty()->SetColor(color[0], color[1], color[2]); ls->m_LabelsActor->GetProperty()->SetOpacity(opacity); ls->UpdateGenerateDataTime(); } } -vtkProp *mitk::LabelOverlay3D::GetVtkProp(BaseRenderer *renderer) const +vtkProp *mitk::LabelAnnotation3D::GetVtkProp(BaseRenderer *renderer) const { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); return ls->m_LabelsActor; } -void mitk::LabelOverlay3D::SetLabelVector(const std::vector &LabelVector) +void mitk::LabelAnnotation3D::SetLabelVector(const std::vector &LabelVector) { m_LabelVector = LabelVector; this->Modified(); } -void mitk::LabelOverlay3D::SetPriorityVector(const std::vector &PriorityVector) +void mitk::LabelAnnotation3D::SetPriorityVector(const std::vector &PriorityVector) { m_PriorityVector = PriorityVector; this->Modified(); } -void mitk::LabelOverlay3D::SetLabelCoordinates(mitk::PointSet::Pointer LabelCoordinates) +void mitk::LabelAnnotation3D::SetLabelCoordinates(mitk::PointSet::Pointer LabelCoordinates) { if (m_LabelCoordinates.IsNotNull()) { m_LabelCoordinates->RemoveObserver(m_PointSetModifiedObserverTag); m_PointSetModifiedObserverTag = 0; m_LabelCoordinates = NULL; } if (LabelCoordinates.IsNull()) { return; } m_LabelCoordinates = LabelCoordinates; - itk::MemberCommand::Pointer _PropertyListModifiedCommand = - itk::MemberCommand::New(); - _PropertyListModifiedCommand->SetCallbackFunction(this, &mitk::LabelOverlay3D::PointSetModified); + itk::MemberCommand::Pointer _PropertyListModifiedCommand = + itk::MemberCommand::New(); + _PropertyListModifiedCommand->SetCallbackFunction(this, &mitk::LabelAnnotation3D::PointSetModified); m_PointSetModifiedObserverTag = m_LabelCoordinates->AddObserver(itk::ModifiedEvent(), _PropertyListModifiedCommand); this->Modified(); } -void mitk::LabelOverlay3D::PointSetModified(const itk::Object * /*caller*/, const itk::EventObject &) +void mitk::LabelAnnotation3D::PointSetModified(const itk::Object * /*caller*/, const itk::EventObject &) { this->Modified(); } diff --git a/Modules/Annotation/src/mitkLayoutAnnotationRenderer.cpp b/Modules/Annotation/src/mitkLayoutAnnotationRenderer.cpp new file mode 100644 index 0000000000..8fa1049f9e --- /dev/null +++ b/Modules/Annotation/src/mitkLayoutAnnotationRenderer.cpp @@ -0,0 +1,346 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkLayoutAnnotationRenderer.h" +#include "mitkBaseRenderer.h" + +#include "mitkAnnotationUtils.h" +#include "mitkEnumerationProperty.h" +#include + +namespace mitk +{ + const std::string LayoutAnnotationRenderer::ANNOTATIONRENDERER_ID = "LayoutAnnotationRenderer"; + + const std::string LayoutAnnotationRenderer::PROP_LAYOUT = "Layout"; + const std::string LayoutAnnotationRenderer::PROP_LAYOUT_PRIORITY = PROP_LAYOUT + ".priority"; + const std::string LayoutAnnotationRenderer::PROP_LAYOUT_ALIGNMENT = PROP_LAYOUT + ".alignment"; + const std::string LayoutAnnotationRenderer::PROP_LAYOUT_MARGIN = PROP_LAYOUT + ".margin"; + + void LayoutAnnotationRenderer::SetMargin2D(Annotation *Annotation, const Point2D &OffsetVector) + { + mitk::Point2dProperty::Pointer OffsetVectorProperty = mitk::Point2dProperty::New(OffsetVector); + Annotation->SetProperty(PROP_LAYOUT_MARGIN, OffsetVectorProperty.GetPointer()); + } + + Point2D LayoutAnnotationRenderer::GetMargin2D(Annotation *Annotation) + { + mitk::Point2D OffsetVector; + OffsetVector.Fill(0); + Annotation->GetPropertyValue(PROP_LAYOUT_MARGIN, OffsetVector); + return OffsetVector; + } + + LayoutAnnotationRenderer::LayoutAnnotationRenderer(const std::string &rendererId) + : AbstractAnnotationRenderer(rendererId, LayoutAnnotationRenderer::ANNOTATIONRENDERER_ID) + { + } + + void LayoutAnnotationRenderer::AddAlignmentProperty(Annotation *Annotation, + Alignment activeAlignment, + Point2D margin, + int priority) + { + EnumerationProperty::Pointer alignmentProperty(mitk::EnumerationProperty::New()); + alignmentProperty->AddEnum("TopLeft", TopLeft); + alignmentProperty->AddEnum("Top", Top); + alignmentProperty->AddEnum("TopRight", TopRight); + alignmentProperty->AddEnum("BottomLeft ", BottomLeft); + alignmentProperty->AddEnum("Bottom", Bottom); + alignmentProperty->AddEnum("BottomRight", BottomRight); + alignmentProperty->AddEnum("Left", Left); + alignmentProperty->AddEnum("Right", Right); + alignmentProperty->SetValue(activeAlignment); + Annotation->AddProperty(PROP_LAYOUT_ALIGNMENT, alignmentProperty.GetPointer()); + Annotation->SetIntProperty(PROP_LAYOUT_PRIORITY, priority); + SetMargin2D(Annotation, margin); + } + + void LayoutAnnotationRenderer::OnAnnotationRenderersChanged() + { + if (!this->GetCurrentBaseRenderer()) + return; + m_AnnotationContainerMap.clear(); + for (Annotation *annotation : this->GetServices()) + { + if (!annotation) + continue; + BaseProperty *prop = annotation->GetProperty(PROP_LAYOUT_ALIGNMENT); + EnumerationProperty *enumProb = dynamic_cast(prop); + Alignment currentAlignment = TopLeft; + Point2D margin; + margin.Fill(5); + int priority = -1; + annotation->GetIntProperty(PROP_LAYOUT_PRIORITY, priority); + if (!enumProb) + { + AddAlignmentProperty(annotation, currentAlignment, margin, priority); + } + else + { // TODO19786 insert + currentAlignment = static_cast(enumProb->GetValueAsId()); + } + AnnotationRankedMap &AnnotationVec = m_AnnotationContainerMap[currentAlignment]; + if (!AnnotationVec.empty() && priority < 0) + { + int max = AnnotationVec.rbegin()->first; + if (max < 100) + priority = 100; + else + priority = max + 1; + } + AnnotationVec.insert(std::pair(priority, annotation)); + } + this->PrepareLayout(); + } + + LayoutAnnotationRenderer::~LayoutAnnotationRenderer() {} + const std::string LayoutAnnotationRenderer::GetID() const { return ANNOTATIONRENDERER_ID; } + LayoutAnnotationRenderer *LayoutAnnotationRenderer::GetAnnotationRenderer(const std::string &rendererID) + { + LayoutAnnotationRenderer *result = nullptr; + AbstractAnnotationRenderer *registeredService = + AnnotationUtils::GetAnnotationRenderer(ANNOTATIONRENDERER_ID, rendererID); + if (registeredService) + result = dynamic_cast(registeredService); + if (!result) + { + result = new LayoutAnnotationRenderer(rendererID); + AnnotationUtils::RegisterAnnotationRenderer(result); + } + return result; + } + + void LayoutAnnotationRenderer::OnRenderWindowModified() { PrepareLayout(); } + void LayoutAnnotationRenderer::AddAnnotation(Annotation *Annotation, + const std::string &rendererID, + Alignment alignment, + double marginX, + double marginY, + int priority) + { + GetAnnotationRenderer(rendererID); + us::ServiceProperties props; + props[Annotation::US_PROPKEY_AR_ID] = ANNOTATIONRENDERER_ID; + props[Annotation::US_PROPKEY_RENDERER_ID] = rendererID; + Annotation->RegisterAsMicroservice(props); + Point2D margin; + margin[0] = marginX; + margin[1] = marginY; + AddAlignmentProperty(Annotation, alignment, margin, priority); + } + + void LayoutAnnotationRenderer::AddAnnotation( + Annotation *Annotation, BaseRenderer *renderer, Alignment alignment, double marginX, double marginY, int priority) + { + AddAnnotation(Annotation, renderer->GetName(), alignment, marginX, marginY, priority); + } + + void LayoutAnnotationRenderer::PrepareLayout() + { + if (!this->GetCurrentBaseRenderer()) + return; + int *size = this->GetCurrentBaseRenderer()->GetVtkRenderer()->GetSize(); + PrepareTopLeftLayout(size); + PrepareTopLayout(size); + PrepareTopRightLayout(size); + PrepareBottomLeftLayout(size); + PrepareBottomLayout(size); + PrepareBottomRightLayout(size); + PrepareLeftLayout(size); + PrepareRightLayout(size); + } + void LayoutAnnotationRenderer::PrepareTopLeftLayout(int *displaySize) + { + double posX, posY; + Point2D margin; + posX = 0; + posY = displaySize[1]; + mitk::Annotation::Bounds bounds; + AnnotationRankedMap &AnnotationMap = m_AnnotationContainerMap[TopLeft]; + for (auto it = AnnotationMap.cbegin(); it != AnnotationMap.cend(); ++it) + { + Annotation *Annotation = it->second; + margin = GetMargin2D(Annotation); + bounds = Annotation->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); + + posY -= bounds.Size[1] + margin[1]; + bounds.Position[0] = posX + margin[0]; + bounds.Position[1] = posY; + Annotation->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); + } + } + void LayoutAnnotationRenderer::PrepareTopLayout(int *displaySize) + { + double posX, posY; + Point2D margin; + posX = 0; + posY = displaySize[1]; + mitk::Annotation::Bounds bounds; + AnnotationRankedMap &AnnotationMap = m_AnnotationContainerMap[Top]; + for (auto it = AnnotationMap.cbegin(); it != AnnotationMap.cend(); ++it) + { + Annotation *Annotation = it->second; + margin = GetMargin2D(Annotation); + bounds = Annotation->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); + + posX = displaySize[0] / 2 - bounds.Size[0] / 2; + posY -= bounds.Size[1] + margin[1]; + bounds.Position[0] = posX; + bounds.Position[1] = posY; + Annotation->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); + } + } + void LayoutAnnotationRenderer::PrepareTopRightLayout(int *displaySize) + { + double posX, posY; + Point2D margin; + posX = 0; + posY = displaySize[1]; + mitk::Annotation::Bounds bounds; + AnnotationRankedMap &AnnotationMap = m_AnnotationContainerMap[TopRight]; + for (auto it = AnnotationMap.cbegin(); it != AnnotationMap.cend(); ++it) + { + Annotation *Annotation = it->second; + margin = GetMargin2D(Annotation); + bounds = Annotation->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); + + posX = displaySize[0] - (bounds.Size[0] + margin[0]); + posY -= bounds.Size[1] + margin[1]; + bounds.Position[0] = posX; + bounds.Position[1] = posY; + Annotation->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); + } + } + + void LayoutAnnotationRenderer::PrepareRightLayout(int *displaySize) + { + double posY; + Point2D margin; + double height = GetHeight(m_AnnotationContainerMap[Right], GetCurrentBaseRenderer()); + posY = (height / 2.0 + displaySize[1]) / 2.0; + mitk::Annotation::Bounds bounds; + AnnotationRankedMap &AnnotationMap = m_AnnotationContainerMap[Right]; + for (auto it = AnnotationMap.cbegin(); it != AnnotationMap.cend(); ++it) + { + Annotation *Annotation = it->second; + margin = GetMargin2D(Annotation); + bounds = Annotation->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); + + posY -= bounds.Size[1] + margin[1]; + bounds.Position[0] = displaySize[0] - (bounds.Size[0] + margin[0]); + bounds.Position[1] = posY + margin[1]; + Annotation->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); + } + } + + void LayoutAnnotationRenderer::PrepareLeftLayout(int *displaySize) + { + double posY; + Point2D margin; + double height = GetHeight(m_AnnotationContainerMap[Left], GetCurrentBaseRenderer()); + posY = (height / 2.0 + displaySize[1]) / 2.0; + mitk::Annotation::Bounds bounds; + AnnotationRankedMap &AnnotationMap = m_AnnotationContainerMap[Left]; + for (auto it = AnnotationMap.cbegin(); it != AnnotationMap.cend(); ++it) + { + Annotation *Annotation = it->second; + margin = GetMargin2D(Annotation); + bounds = Annotation->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); + + posY -= bounds.Size[1] + margin[1]; + bounds.Position[0] = margin[0]; + bounds.Position[1] = posY; + Annotation->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); + } + } + + void LayoutAnnotationRenderer::PrepareBottomLeftLayout(int * /*displaySize*/) + { + double posX, posY; + Point2D margin; + posX = 0; + posY = 0; + mitk::Annotation::Bounds bounds; + AnnotationRankedMap &AnnotationMap = m_AnnotationContainerMap[BottomLeft]; + for (auto it = AnnotationMap.cbegin(); it != AnnotationMap.cend(); ++it) + { + Annotation *Annotation = it->second; + margin = GetMargin2D(Annotation); + bounds = Annotation->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); + + bounds.Position[0] = posX + margin[0]; + bounds.Position[1] = posY + margin[1]; + Annotation->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); + posY += bounds.Size[1] + margin[1]; + } + } + void LayoutAnnotationRenderer::PrepareBottomLayout(int *displaySize) + { + double posX, posY; + Point2D margin; + posX = 0; + posY = 0; + mitk::Annotation::Bounds bounds; + AnnotationRankedMap &AnnotationMap = m_AnnotationContainerMap[Bottom]; + for (auto it = AnnotationMap.cbegin(); it != AnnotationMap.cend(); ++it) + { + Annotation *Annotation = it->second; + margin = GetMargin2D(Annotation); + bounds = Annotation->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); + + posX = displaySize[0] / 2 - bounds.Size[0] / 2; + bounds.Position[0] = posX; + bounds.Position[1] = posY + margin[1]; + Annotation->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); + posY += bounds.Size[1] + margin[1]; + } + } + void LayoutAnnotationRenderer::PrepareBottomRightLayout(int *displaySize) + { + double posX, posY; + Point2D margin; + posX = 0; + posY = 0; + mitk::Annotation::Bounds bounds; + AnnotationRankedMap &AnnotationMap = m_AnnotationContainerMap[BottomRight]; + for (auto it = AnnotationMap.cbegin(); it != AnnotationMap.cend(); ++it) + { + Annotation *Annotation = it->second; + margin = GetMargin2D(Annotation); + bounds = Annotation->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); + + posX = displaySize[0] - (bounds.Size[0] + margin[0]); + bounds.Position[0] = posX; + bounds.Position[1] = posY + margin[1]; + Annotation->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); + posY += bounds.Size[1] + margin[1]; + } + } + + double LayoutAnnotationRenderer::GetHeight(AnnotationRankedMap &annotations, BaseRenderer *renderer) + { + double height = 0; + for (auto it = annotations.cbegin(); it != annotations.cend(); ++it) + { + Annotation *annotation = it->second; + Annotation::Bounds bounds = annotation->GetBoundsOnDisplay(renderer); + height += bounds.Size[0]; + height += GetMargin2D(annotation)[0]; + } + return height; + } +} diff --git a/Modules/Overlays/src/mitkLogoOverlay.cpp b/Modules/Annotation/src/mitkLogoAnnotation.cpp similarity index 74% rename from Modules/Overlays/src/mitkLogoOverlay.cpp rename to Modules/Annotation/src/mitkLogoAnnotation.cpp index 8e2d974fe2..9e77623b62 100644 --- a/Modules/Overlays/src/mitkLogoOverlay.cpp +++ b/Modules/Annotation/src/mitkLogoAnnotation.cpp @@ -1,197 +1,197 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkLogoOverlay.h" +#include "mitkLogoAnnotation.h" #include "vtkUnicodeString.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include -mitk::LogoOverlay::LogoOverlay() +mitk::LogoAnnotation::LogoAnnotation() { m_readerFactory = vtkSmartPointer::New(); mitk::Point2D offset; offset.Fill(0.03); SetOffsetVector(offset); SetRelativeSize(0.2); SetLogoImagePath("mbiLogo"); SetCornerPosition(3); m_VtkImageImport = vtkSmartPointer::New(); } -mitk::LogoOverlay::~LogoOverlay() +mitk::LogoAnnotation::~LogoAnnotation() { } -mitk::LogoOverlay::LocalStorage::~LocalStorage() +mitk::LogoAnnotation::LocalStorage::~LocalStorage() { } -mitk::LogoOverlay::LocalStorage::LocalStorage() +mitk::LogoAnnotation::LocalStorage::LocalStorage() { m_LogoRep = vtkSmartPointer::New(); } -void mitk::LogoOverlay::UpdateVtkOverlay(mitk::BaseRenderer *renderer) +void mitk::LogoAnnotation::UpdateVtkAnnotation(mitk::BaseRenderer *renderer) { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); if (ls->IsGenerateDataRequired(renderer, this)) { if (GetLogoImagePath().empty()) { ls->m_LogoRep->SetVisibility(0); return; } vtkImageReader2 *imageReader = m_readerFactory->CreateImageReader2(GetLogoImagePath().c_str()); if (imageReader) { imageReader->SetFileName(GetLogoImagePath().c_str()); imageReader->Update(); ls->m_LogoImage = imageReader->GetOutput(); imageReader->Delete(); } else { ls->m_LogoImage = CreateMbiLogo(); } ls->m_LogoRep->SetImage(ls->m_LogoImage); ls->m_LogoRep->SetDragable(false); ls->m_LogoRep->SetMoving(false); ls->m_LogoRep->SetPickable(false); ls->m_LogoRep->SetShowBorder(true); ls->m_LogoRep->SetRenderer(renderer->GetVtkRenderer()); float size = GetRelativeSize(); ls->m_LogoRep->SetPosition2(size, size); int corner = GetCornerPosition(); ls->m_LogoRep->SetCornerPosition(corner); mitk::Point2D offset = GetOffsetVector(); ls->m_LogoRep->SetPosition(offset[0], offset[1]); float opacity = 1.0; GetOpacity(opacity); ls->m_LogoRep->GetImageProperty()->SetOpacity(opacity); ls->m_LogoRep->BuildRepresentation(); ls->UpdateGenerateDataTime(); } } -vtkImageData *mitk::LogoOverlay::CreateMbiLogo() +vtkImageData *mitk::LogoAnnotation::CreateMbiLogo() { m_VtkImageImport->SetDataScalarTypeToUnsignedChar(); m_VtkImageImport->SetNumberOfScalarComponents(mbiLogo_NumberOfScalars); m_VtkImageImport->SetWholeExtent(0, mbiLogo_Width - 1, 0, mbiLogo_Height - 1, 0, 1 - 1); m_VtkImageImport->SetDataExtentToWholeExtent(); char *ImageData; // flip mbi logo around y axis and change color order ImageData = new char[mbiLogo_Height * mbiLogo_Width * mbiLogo_NumberOfScalars]; unsigned int column, row; char *dest = ImageData; char *source = (char *)&mbiLogo_Data[0]; ; char r, g, b, a; for (column = 0; column < mbiLogo_Height; column++) for (row = 0; row < mbiLogo_Width; row++) { // change r with b b = *source++; g = *source++; r = *source++; a = *source++; *dest++ = r; *dest++ = g; *dest++ = b; *dest++ = a; } m_VtkImageImport->SetImportVoidPointer(ImageData); m_VtkImageImport->Modified(); m_VtkImageImport->Update(); return m_VtkImageImport->GetOutput(); } -void mitk::LogoOverlay::SetLogoImagePath(std::string path) +void mitk::LogoAnnotation::SetLogoImagePath(std::string path) { - SetStringProperty("Overlay.LogoImagePath", path.c_str()); + SetStringProperty("Annotation.LogoImagePath", path.c_str()); Modified(); } -std::string mitk::LogoOverlay::GetLogoImagePath() const +std::string mitk::LogoAnnotation::GetLogoImagePath() const { std::string path; - GetPropertyList()->GetStringProperty("Overlay.LogoImagePath", path); + GetPropertyList()->GetStringProperty("Annotation.LogoImagePath", path); return path; } -void mitk::LogoOverlay::SetOffsetVector(const Point2D &OffsetVector) +void mitk::LogoAnnotation::SetOffsetVector(const Point2D &OffsetVector) { mitk::Point2dProperty::Pointer OffsetVectorProperty = mitk::Point2dProperty::New(OffsetVector); - SetProperty("Overlay.OffsetVector", OffsetVectorProperty.GetPointer()); + SetProperty("Annotation.OffsetVector", OffsetVectorProperty.GetPointer()); Modified(); } -mitk::Point2D mitk::LogoOverlay::GetOffsetVector() const +mitk::Point2D mitk::LogoAnnotation::GetOffsetVector() const { mitk::Point2D OffsetVector; OffsetVector.Fill(0); - GetPropertyValue("Overlay.OffsetVector", OffsetVector); + GetPropertyValue("Annotation.OffsetVector", OffsetVector); return OffsetVector; } -void mitk::LogoOverlay::SetCornerPosition(const int &corner) +void mitk::LogoAnnotation::SetCornerPosition(const int &corner) { - SetIntProperty("Overlay.CornerPosition", corner); + SetIntProperty("Annotation.CornerPosition", corner); Modified(); } -int mitk::LogoOverlay::GetCornerPosition() const +int mitk::LogoAnnotation::GetCornerPosition() const { int corner = 0; - GetIntProperty("Overlay.CornerPosition", corner); + GetIntProperty("Annotation.CornerPosition", corner); return corner; } -void mitk::LogoOverlay::SetRelativeSize(const float &size) +void mitk::LogoAnnotation::SetRelativeSize(const float &size) { - SetFloatProperty("Overlay.RelativeSize", size); + SetFloatProperty("Annotation.RelativeSize", size); Modified(); } -float mitk::LogoOverlay::GetRelativeSize() const +float mitk::LogoAnnotation::GetRelativeSize() const { float size = 0; - GetFloatProperty("Overlay.RelativeSize", size); + GetFloatProperty("Annotation.RelativeSize", size); return size; } -vtkProp *mitk::LogoOverlay::GetVtkProp(BaseRenderer *renderer) const +vtkProp *mitk::LogoAnnotation::GetVtkProp(BaseRenderer *renderer) const { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); return ls->m_LogoRep; } diff --git a/Modules/Annotation/src/mitkManualPlacementAnnotationRenderer.cpp b/Modules/Annotation/src/mitkManualPlacementAnnotationRenderer.cpp new file mode 100644 index 0000000000..14926d0e7d --- /dev/null +++ b/Modules/Annotation/src/mitkManualPlacementAnnotationRenderer.cpp @@ -0,0 +1,60 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkManualPlacementAnnotationRenderer.h" +#include "mitkBaseRenderer.h" + +#include "mitkAnnotationUtils.h" +#include + +namespace mitk +{ + const std::string ManualPlacementAnnotationRenderer::ANNOTATIONRENDERER_ID = "ManualPlacementAnnotationRenderer"; + + ManualPlacementAnnotationRenderer::ManualPlacementAnnotationRenderer(const std::string &rendererId) + : AbstractAnnotationRenderer(rendererId, ManualPlacementAnnotationRenderer::ANNOTATIONRENDERER_ID) + { + } + ManualPlacementAnnotationRenderer::~ManualPlacementAnnotationRenderer() {} + ManualPlacementAnnotationRenderer *ManualPlacementAnnotationRenderer::GetAnnotationRenderer(const std::string &rendererID) + { + ManualPlacementAnnotationRenderer *result = nullptr; + AbstractAnnotationRenderer *registeredService = + AnnotationUtils::GetAnnotationRenderer(ANNOTATIONRENDERER_ID, rendererID); + if (registeredService) + result = dynamic_cast(registeredService); + if (!result) + { + result = new ManualPlacementAnnotationRenderer(rendererID); + AnnotationUtils::RegisterAnnotationRenderer(result); + } + return result; + } + + void ManualPlacementAnnotationRenderer::AddAnnotation(Annotation *Annotation, const std::string &rendererID) + { + GetAnnotationRenderer(rendererID); // rename ?? + us::ServiceProperties props; + props[Annotation::US_PROPKEY_AR_ID] = ANNOTATIONRENDERER_ID; + props[Annotation::US_PROPKEY_RENDERER_ID] = rendererID; + Annotation->RegisterAsMicroservice(props); + } + + void ManualPlacementAnnotationRenderer::AddAnnotation(Annotation *Annotation, BaseRenderer *renderer) + { + AddAnnotation(Annotation, renderer->GetName()); + } +} diff --git a/Modules/Annotation/src/mitkScaleLegendAnnotation.cpp b/Modules/Annotation/src/mitkScaleLegendAnnotation.cpp new file mode 100644 index 0000000000..57e9358cb8 --- /dev/null +++ b/Modules/Annotation/src/mitkScaleLegendAnnotation.cpp @@ -0,0 +1,209 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkScaleLegendAnnotation.h" +#include +#include +#include + +mitk::ScaleLegendAnnotation::ScaleLegendAnnotation() +{ + SetRightAxisVisibility(true); + SetLeftAxisVisibility(true); + SetTopAxisVisibility(true); + SetBottomAxisVisibility(true); + SetLegendVisibility(true); + SetRightBorderOffset(50); + SetLeftBorderOffset(50); + SetTopBorderOffset(30); + SetBottomBorderOffset(30); + SetCornerOffsetFactor(2.0); + SetFontFactor(1.0); +} + +mitk::ScaleLegendAnnotation::~ScaleLegendAnnotation() +{ +} + +mitk::ScaleLegendAnnotation::LocalStorage::~LocalStorage() +{ +} + +mitk::ScaleLegendAnnotation::LocalStorage::LocalStorage() +{ + m_legendScaleActor = vtkSmartPointer::New(); +} + +void mitk::ScaleLegendAnnotation::UpdateVtkAnnotation(mitk::BaseRenderer *renderer) +{ + LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); + + if (ls->IsGenerateDataRequired(renderer, this)) + { + ls->m_legendScaleActor->SetRightAxisVisibility(this->GetRightAxisVisibility()); + ls->m_legendScaleActor->SetTopAxisVisibility(this->GetTopAxisVisibility()); + ls->m_legendScaleActor->SetLeftAxisVisibility(this->GetLeftAxisVisibility()); + ls->m_legendScaleActor->SetBottomAxisVisibility(this->GetBottomAxisVisibility()); + ls->m_legendScaleActor->SetLegendVisibility(this->GetLegendVisibility()); + ls->m_legendScaleActor->SetRightBorderOffset(this->GetRightBorderOffset()); + ls->m_legendScaleActor->SetLeftBorderOffset(this->GetLeftBorderOffset()); + ls->m_legendScaleActor->SetTopBorderOffset(this->GetTopBorderOffset()); + ls->m_legendScaleActor->SetBottomBorderOffset(this->GetBottomBorderOffset()); + ls->m_legendScaleActor->SetCornerOffsetFactor(this->GetCornerOffsetFactor()); + ls->m_legendScaleActor->GetLeftAxis()->SetFontFactor(this->GetFontFactor()); + ls->m_legendScaleActor->GetRightAxis()->SetFontFactor(this->GetFontFactor()); + ls->m_legendScaleActor->GetTopAxis()->SetFontFactor(this->GetFontFactor()); + ls->m_legendScaleActor->GetBottomAxis()->SetFontFactor(this->GetFontFactor()); + } +} + +vtkProp *mitk::ScaleLegendAnnotation::GetVtkProp(BaseRenderer *renderer) const +{ + LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); + return ls->m_legendScaleActor; +} + +void mitk::ScaleLegendAnnotation::SetRightAxisVisibility(bool visibility) +{ + SetBoolProperty("ScaleLegendAnnotation.RightAxisVisibility", visibility); +} + +bool mitk::ScaleLegendAnnotation::GetRightAxisVisibility() const +{ + bool visibility; + GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.RightAxisVisibility", visibility); + return visibility; +} + +void mitk::ScaleLegendAnnotation::SetLeftAxisVisibility(bool visibility) +{ + SetBoolProperty("ScaleLegendAnnotation.LeftAxisVisibility", visibility); +} + +bool mitk::ScaleLegendAnnotation::GetLeftAxisVisibility() const +{ + bool visibility; + GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.LeftAxisVisibility", visibility); + return visibility; +} + +void mitk::ScaleLegendAnnotation::SetTopAxisVisibility(bool visibility) +{ + SetBoolProperty("ScaleLegendAnnotation.TopAxisVisibility", visibility); +} + +bool mitk::ScaleLegendAnnotation::GetTopAxisVisibility() const +{ + bool visibility; + GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.TopAxisVisibility", visibility); + return visibility; +} + +void mitk::ScaleLegendAnnotation::SetBottomAxisVisibility(bool visibility) +{ + SetBoolProperty("ScaleLegendAnnotation.BottomAxisVisibility", visibility); +} + +bool mitk::ScaleLegendAnnotation::GetBottomAxisVisibility() const +{ + bool visibility; + GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.BottomAxisVisibility", visibility); + return visibility; +} + +void mitk::ScaleLegendAnnotation::SetLegendVisibility(bool visibility) +{ + SetBoolProperty("ScaleLegendAnnotation.SetLegendVisibility", visibility); +} + +bool mitk::ScaleLegendAnnotation::GetLegendVisibility() const +{ + bool visibility; + GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.SetLegendVisibility", visibility); + return visibility; +} + +void mitk::ScaleLegendAnnotation::SetRightBorderOffset(int offset) +{ + SetIntProperty("ScaleLegendAnnotation.RightBorderOffset", offset); +} + +int mitk::ScaleLegendAnnotation::GetRightBorderOffset() const +{ + int offset; + GetPropertyList()->GetIntProperty("ScaleLegendAnnotation.RightBorderOffset", offset); + return offset; +} + +void mitk::ScaleLegendAnnotation::SetLeftBorderOffset(int offset) +{ + SetIntProperty("ScaleLegendAnnotation.LeftBorderOffset", offset); +} + +int mitk::ScaleLegendAnnotation::GetLeftBorderOffset() const +{ + int offset; + GetPropertyList()->GetIntProperty("ScaleLegendAnnotation.LeftBorderOffset", offset); + return offset; +} + +void mitk::ScaleLegendAnnotation::SetTopBorderOffset(int offset) +{ + SetIntProperty("ScaleLegendAnnotation.TopBorderOffset", offset); +} + +int mitk::ScaleLegendAnnotation::GetTopBorderOffset() const +{ + int offset; + GetPropertyList()->GetIntProperty("ScaleLegendAnnotation.TopBorderOffset", offset); + return offset; +} + +void mitk::ScaleLegendAnnotation::SetBottomBorderOffset(int offset) +{ + SetIntProperty("ScaleLegendAnnotation.BottomBorderOffset", offset); +} + +int mitk::ScaleLegendAnnotation::GetBottomBorderOffset() const +{ + int offset; + GetPropertyList()->GetIntProperty("ScaleLegendAnnotation.BottomBorderOffset", offset); + return offset; +} + +void mitk::ScaleLegendAnnotation::SetCornerOffsetFactor(double offsetFactor) +{ + SetDoubleProperty("ScaleLegendAnnotation.CornerOffsetFactor", offsetFactor); +} + +double mitk::ScaleLegendAnnotation::GetCornerOffsetFactor() const +{ + double offsetFactor; + GetPropertyList()->GetDoubleProperty("ScaleLegendAnnotation.CornerOffsetFactor", offsetFactor); + return offsetFactor; +} + +void mitk::ScaleLegendAnnotation::SetFontFactor(double fontFactor) +{ + SetDoubleProperty("ScaleLegendAnnotation.FontFactor", fontFactor); +} + +double mitk::ScaleLegendAnnotation::GetFontFactor() const +{ + double offsetFactor; + GetPropertyList()->GetDoubleProperty("ScaleLegendAnnotation.FontFactor", offsetFactor); + return offsetFactor; +} diff --git a/Modules/Overlays/src/mitkTextOverlay2D.cpp b/Modules/Annotation/src/mitkTextAnnotation2D.cpp similarity index 84% rename from Modules/Overlays/src/mitkTextOverlay2D.cpp rename to Modules/Annotation/src/mitkTextAnnotation2D.cpp index dab6ddf232..ed7c547aa9 100644 --- a/Modules/Overlays/src/mitkTextOverlay2D.cpp +++ b/Modules/Annotation/src/mitkTextAnnotation2D.cpp @@ -1,152 +1,152 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkTextOverlay2D.h" +#include "mitkTextAnnotation2D.h" #include "vtkUnicodeString.h" #include #include #include -mitk::TextOverlay2D::TextOverlay2D() +mitk::TextAnnotation2D::TextAnnotation2D() { mitk::Point2D position; position[0] = position[1] = 0; this->SetPosition2D(position); this->SetOffsetVector(position); this->SetText(""); this->SetFontSize(20); this->SetColor(1.0, 1.0, 1.0); this->SetStringProperty("font.family", "Arial"); this->SetBoolProperty("font.bold", false); this->SetBoolProperty("font.italic", false); this->SetBoolProperty("drawShadow", false); } -mitk::TextOverlay2D::~TextOverlay2D() +mitk::TextAnnotation2D::~TextAnnotation2D() { } -mitk::Overlay::Bounds mitk::TextOverlay2D::GetBoundsOnDisplay(mitk::BaseRenderer *renderer) const +mitk::Annotation::Bounds mitk::TextAnnotation2D::GetBoundsOnDisplay(mitk::BaseRenderer *renderer) const { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); - mitk::Overlay::Bounds bounds; + mitk::Annotation::Bounds bounds; bounds.Position = ls->m_TextActor->GetPosition(); double size[2]; ls->m_TextActor->GetSize(renderer->GetVtkRenderer(), size); bounds.Size[0] = size[0]; bounds.Size[1] = size[1]; return bounds; } -void mitk::TextOverlay2D::SetBoundsOnDisplay(mitk::BaseRenderer *renderer, const mitk::Overlay::Bounds &bounds) +void mitk::TextAnnotation2D::SetBoundsOnDisplay(mitk::BaseRenderer *renderer, const mitk::Annotation::Bounds &bounds) { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); mitk::Point2D posT, posS; posT[0] = bounds.Position[0]; posT[1] = bounds.Position[1]; posS[0] = posT[0] + 1; posS[1] = posT[1] - 1; ls->m_TextActor->SetDisplayPosition(posT[0], posT[1]); ls->m_STextActor->SetDisplayPosition(posS[0], posS[1]); } -mitk::TextOverlay2D::LocalStorage::~LocalStorage() +mitk::TextAnnotation2D::LocalStorage::~LocalStorage() { } -mitk::TextOverlay2D::LocalStorage::LocalStorage() +mitk::TextAnnotation2D::LocalStorage::LocalStorage() { m_TextActor = vtkSmartPointer::New(); m_TextProp = vtkSmartPointer::New(); m_STextActor = vtkSmartPointer::New(); m_STextProp = vtkSmartPointer::New(); m_TextActor->SetTextProperty(m_TextProp); m_STextActor->SetTextProperty(m_STextProp); m_Assembly = vtkSmartPointer::New(); m_Assembly->AddPart(m_STextActor); m_Assembly->AddPart(m_TextActor); } -void mitk::TextOverlay2D::UpdateVtkOverlay2D(mitk::BaseRenderer *renderer) +void mitk::TextAnnotation2D::UpdateVtkAnnotation2D(mitk::BaseRenderer *renderer) { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); if (ls->IsGenerateDataRequired(renderer, this)) { float color[3] = {0.0, 1.0, 0.0}; float opacity = 1.0; GetColor(color); GetOpacity(opacity); ls->m_TextProp->SetColor(color[0], color[1], color[2]); ls->m_STextProp->SetColor(0, 0, 0); ls->m_TextProp->SetFontSize(GetFontSize()); ls->m_TextProp->SetOpacity(opacity); ls->m_STextProp->SetFontSize(GetFontSize()); ls->m_STextProp->SetOpacity(opacity); std::string fontFamilyAsString; if (GetStringProperty("font.family", fontFamilyAsString) == false) { fontFamilyAsString = "Arial"; } ls->m_TextProp->SetFontFamilyAsString(fontFamilyAsString.c_str()); ls->m_STextProp->SetFontFamilyAsString(fontFamilyAsString.c_str()); bool boldFont(false); GetBoolProperty("font.bold", boldFont); ls->m_TextProp->SetBold(boldFont); ls->m_STextProp->SetBold(boldFont); bool italicFont(false); GetBoolProperty("font.italic", italicFont); ls->m_TextProp->SetBold(italicFont); ls->m_STextProp->SetBold(italicFont); bool drawShadow; GetBoolProperty("drawShadow", drawShadow); ls->m_TextProp->SetShadow(false); ls->m_STextProp->SetShadow(false); ls->m_STextActor->SetVisibility(drawShadow); ls->m_TextActor->SetInput(GetText().c_str()); ls->m_STextActor->SetInput(GetText().c_str()); mitk::Point2D posT, posS; posT[0] = GetPosition2D()[0] + GetOffsetVector()[0]; posT[1] = GetPosition2D()[1] + GetOffsetVector()[1]; posS[0] = posT[0] + 1; posS[1] = posT[1] - 1; ls->m_TextActor->SetDisplayPosition(posT[0], posT[1]); ls->m_STextActor->SetDisplayPosition(posS[0], posS[1]); ls->UpdateGenerateDataTime(); } } -vtkProp *mitk::TextOverlay2D::GetVtkProp(mitk::BaseRenderer *renderer) const +vtkProp *mitk::TextAnnotation2D::GetVtkProp(mitk::BaseRenderer *renderer) const { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); return ls->m_Assembly; } -vtkActor2D *mitk::TextOverlay2D::GetVtkActor2D(BaseRenderer *renderer) const +vtkActor2D *mitk::TextAnnotation2D::GetVtkActor2D(BaseRenderer *renderer) const { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); return ls->m_TextActor; } diff --git a/Modules/Overlays/src/mitkTextOverlay3D.cpp b/Modules/Annotation/src/mitkTextAnnotation3D.cpp similarity index 88% rename from Modules/Overlays/src/mitkTextOverlay3D.cpp rename to Modules/Annotation/src/mitkTextAnnotation3D.cpp index 7598f58857..3847141c02 100644 --- a/Modules/Overlays/src/mitkTextOverlay3D.cpp +++ b/Modules/Annotation/src/mitkTextAnnotation3D.cpp @@ -1,105 +1,105 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkTextOverlay3D.h" +#include "mitkTextAnnotation3D.h" #include #include #include #include #include #include #include #include -mitk::TextOverlay3D::TextOverlay3D() +mitk::TextAnnotation3D::TextAnnotation3D() { mitk::Point3D position; position.Fill(0); this->SetPosition3D(position); this->SetOffsetVector(position); this->SetText(""); this->SetFontSize(20); this->SetColor(1.0, 1.0, 1.0); } -mitk::TextOverlay3D::~TextOverlay3D() +mitk::TextAnnotation3D::~TextAnnotation3D() { } -mitk::TextOverlay3D::LocalStorage::~LocalStorage() +mitk::TextAnnotation3D::LocalStorage::~LocalStorage() { } -mitk::TextOverlay3D::LocalStorage::LocalStorage() +mitk::TextAnnotation3D::LocalStorage::LocalStorage() { // Create some text m_textSource = vtkSmartPointer::New(); // Create a mapper vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInputConnection(m_textSource->GetOutputPort()); // Create a subclass of vtkActor: a vtkFollower that remains facing the camera m_follower = vtkSmartPointer::New(); m_follower->SetMapper(mapper); m_follower->GetProperty()->SetColor(1, 0, 0); // red m_follower->SetScale(1); } -void mitk::TextOverlay3D::UpdateVtkOverlay(mitk::BaseRenderer *renderer) +void mitk::TextAnnotation3D::UpdateVtkAnnotation(mitk::BaseRenderer *renderer) { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); if (ls->IsGenerateDataRequired(renderer, this)) { Point3D pos3d = GetPosition3D(); vtkRenderer *vtkRender = renderer->GetVtkRenderer(); if (vtkRender) { vtkCamera *camera = vtkRender->GetActiveCamera(); ls->m_follower->SetCamera(camera); if (camera != nullptr) { // calculate the offset relative to the camera's view direction Point3D offset = GetOffsetVector(); Vector3D viewUp; camera->GetViewUp(viewUp.GetDataPointer()); Vector3D cameraDirection; camera->GetDirectionOfProjection(cameraDirection.GetDataPointer()); Vector3D viewRight; vtkMath::Cross(cameraDirection.GetDataPointer(), viewUp.GetDataPointer(), viewRight.GetDataPointer()); pos3d = pos3d + viewRight * offset[0] + viewUp * offset[1] + cameraDirection * offset[2]; } } ls->m_follower->SetPosition(pos3d.GetDataPointer()); ls->m_textSource->SetText(GetText().c_str()); float color[3] = {1, 1, 1}; float opacity = 1.0; GetColor(color); GetOpacity(opacity); ls->m_follower->GetProperty()->SetColor(color[0], color[1], color[2]); ls->m_follower->GetProperty()->SetOpacity(opacity); ls->m_follower->SetScale(this->GetFontSize()); ls->UpdateGenerateDataTime(); } } -vtkProp *mitk::TextOverlay3D::GetVtkProp(BaseRenderer *renderer) const +vtkProp *mitk::TextAnnotation3D::GetVtkProp(BaseRenderer *renderer) const { LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); return ls->m_follower; } diff --git a/Modules/Overlays/src/mitkVtkOverlay.cpp b/Modules/Annotation/src/mitkVtkAnnotation.cpp similarity index 73% rename from Modules/Overlays/src/mitkVtkOverlay.cpp rename to Modules/Annotation/src/mitkVtkAnnotation.cpp index 9ceede2f84..07b7ce68ea 100644 --- a/Modules/Overlays/src/mitkVtkOverlay.cpp +++ b/Modules/Annotation/src/mitkVtkAnnotation.cpp @@ -1,87 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkVtkOverlay.h" +#include "mitkVtkAnnotation.h" #include #include -mitk::VtkOverlay::VtkOverlay() +mitk::VtkAnnotation::VtkAnnotation() { } -mitk::VtkOverlay::~VtkOverlay() +mitk::VtkAnnotation::~VtkAnnotation() { } -void mitk::VtkOverlay::Update(mitk::BaseRenderer *renderer) +void mitk::VtkAnnotation::Update(mitk::BaseRenderer *renderer) { vtkSmartPointer prop = GetVtkProp(renderer); if (!IsVisible()) { prop->SetVisibility(false); return; } else { prop->SetVisibility(true); - UpdateVtkOverlay(renderer); + UpdateVtkAnnotation(renderer); } } -void mitk::VtkOverlay::AddToBaseRenderer(mitk::BaseRenderer *renderer) +void mitk::VtkAnnotation::AddToBaseRenderer(mitk::BaseRenderer *renderer) { if (!renderer) return; AddToRenderer(renderer, renderer->GetVtkRenderer()); } -void mitk::VtkOverlay::AddToRenderer(mitk::BaseRenderer *renderer, vtkRenderer *vtkrenderer) +void mitk::VtkAnnotation::AddToRenderer(mitk::BaseRenderer *renderer, vtkRenderer *vtkrenderer) { if (!renderer || !vtkrenderer) return; Update(renderer); vtkSmartPointer vtkProp = GetVtkProp(renderer); if (renderer && vtkrenderer && !vtkrenderer->HasViewProp(vtkProp)) { vtkrenderer->AddViewProp(vtkProp); mitk::RenderingManager::GetInstance()->RequestUpdate(vtkrenderer->GetRenderWindow()); } } -void mitk::VtkOverlay::RemoveFromBaseRenderer(mitk::BaseRenderer *renderer) +void mitk::VtkAnnotation::RemoveFromBaseRenderer(mitk::BaseRenderer *renderer) { if (!renderer) return; RemoveFromRenderer(renderer, renderer->GetVtkRenderer()); } -void mitk::VtkOverlay::RemoveFromRenderer(mitk::BaseRenderer *renderer, vtkRenderer *vtkrenderer) +void mitk::VtkAnnotation::RemoveFromRenderer(mitk::BaseRenderer *renderer, vtkRenderer *vtkrenderer) { if (!renderer || !vtkrenderer) return; vtkSmartPointer vtkProp = GetVtkProp(renderer); if (vtkrenderer->HasViewProp(vtkProp)) { vtkrenderer->RemoveViewProp(vtkProp); mitk::RenderingManager::GetInstance()->RequestUpdate(vtkrenderer->GetRenderWindow()); } } -void mitk::VtkOverlay::Paint(BaseRenderer *renderer) +void mitk::VtkAnnotation::Paint(BaseRenderer *renderer) { GetVtkProp(renderer)->RenderOpaqueGeometry(renderer->GetVtkRenderer()); GetVtkProp(renderer)->RenderOverlay(renderer->GetVtkRenderer()); } diff --git a/Modules/Overlays/src/mitkVtkOverlay2D.cpp b/Modules/Annotation/src/mitkVtkAnnotation2D.cpp similarity index 58% rename from Modules/Overlays/src/mitkVtkOverlay2D.cpp rename to Modules/Annotation/src/mitkVtkAnnotation2D.cpp index 8bf43bb83c..ebbdc2b12e 100644 --- a/Modules/Overlays/src/mitkVtkOverlay2D.cpp +++ b/Modules/Annotation/src/mitkVtkAnnotation2D.cpp @@ -1,90 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkVtkOverlay2D.h" +#include "mitkVtkAnnotation2D.h" #include #include #include -mitk::VtkOverlay2D::VtkOverlay2D() +mitk::VtkAnnotation2D::VtkAnnotation2D() { } -mitk::VtkOverlay2D::~VtkOverlay2D() +mitk::VtkAnnotation2D::~VtkAnnotation2D() { } -mitk::Overlay::Bounds mitk::VtkOverlay2D::GetBoundsOnDisplay(mitk::BaseRenderer *renderer) const +mitk::Annotation::Bounds mitk::VtkAnnotation2D::GetBoundsOnDisplay(mitk::BaseRenderer *renderer) const { - mitk::Overlay::Bounds bounds; + mitk::Annotation::Bounds bounds; vtkSmartPointer actor = GetVtkActor2D(renderer); bounds.Position = actor->GetPosition(); bounds.Size = actor->GetPosition2(); return bounds; } -void mitk::VtkOverlay2D::SetBoundsOnDisplay(mitk::BaseRenderer *renderer, const mitk::Overlay::Bounds &bounds) +void mitk::VtkAnnotation2D::SetBoundsOnDisplay(mitk::BaseRenderer *renderer, const mitk::Annotation::Bounds &bounds) { vtkSmartPointer actor = GetVtkActor2D(renderer); actor->SetDisplayPosition(bounds.Position[0], bounds.Position[1]); actor->SetWidth(bounds.Size[0]); actor->SetHeight(bounds.Size[1]); } -void mitk::VtkOverlay2D::UpdateVtkOverlay(mitk::BaseRenderer *renderer) +void mitk::VtkAnnotation2D::UpdateVtkAnnotation(mitk::BaseRenderer *renderer) { vtkActor2D *prop = GetVtkActor2D(renderer); float color[3] = {1, 1, 1}; float opacity = 1.0; GetColor(color); GetOpacity(opacity); prop->GetProperty()->SetColor(color[0], color[1], color[2]); prop->GetProperty()->SetOpacity(opacity); - UpdateVtkOverlay2D(renderer); + UpdateVtkAnnotation2D(renderer); } -void mitk::VtkOverlay2D::SetPosition2D(const Point2D &position2D) +void mitk::VtkAnnotation2D::SetPosition2D(const Point2D &position2D) { mitk::Point2dProperty::Pointer position2dProperty = mitk::Point2dProperty::New(position2D); - SetProperty("VtkOverlay2D.Position2D", position2dProperty.GetPointer()); + SetProperty("VtkAnnotation2D.Position2D", position2dProperty.GetPointer()); } -mitk::Point2D mitk::VtkOverlay2D::GetPosition2D() const +mitk::Point2D mitk::VtkAnnotation2D::GetPosition2D() const { mitk::Point2D position2D; position2D.Fill(0); - GetPropertyValue("VtkOverlay2D.Position2D", position2D); + GetPropertyValue("VtkAnnotation2D.Position2D", position2D); return position2D; } -void mitk::VtkOverlay2D::SetOffsetVector(const Point2D &OffsetVector) +void mitk::VtkAnnotation2D::SetOffsetVector(const Point2D &OffsetVector) { mitk::Point2dProperty::Pointer OffsetVectorProperty = mitk::Point2dProperty::New(OffsetVector); - SetProperty("VtkOverlay2D.OffsetVector", OffsetVectorProperty.GetPointer()); + SetProperty("VtkAnnotation2D.OffsetVector", OffsetVectorProperty.GetPointer()); } -mitk::Point2D mitk::VtkOverlay2D::GetOffsetVector() const +mitk::Point2D mitk::VtkAnnotation2D::GetOffsetVector() const { mitk::Point2D OffsetVector; OffsetVector.Fill(0); - GetPropertyValue("VtkOverlay2D.OffsetVector", OffsetVector); + GetPropertyValue("VtkAnnotation2D.OffsetVector", OffsetVector); return OffsetVector; } -vtkProp *mitk::VtkOverlay2D::GetVtkProp(mitk::BaseRenderer *renderer) const +vtkProp *mitk::VtkAnnotation2D::GetVtkProp(mitk::BaseRenderer *renderer) const { return GetVtkActor2D(renderer); } diff --git a/Modules/Overlays/src/mitkVtkOverlay3D.cpp b/Modules/Annotation/src/mitkVtkAnnotation3D.cpp similarity index 57% rename from Modules/Overlays/src/mitkVtkOverlay3D.cpp rename to Modules/Annotation/src/mitkVtkAnnotation3D.cpp index 08f581272e..d6fc4d25a2 100644 --- a/Modules/Overlays/src/mitkVtkOverlay3D.cpp +++ b/Modules/Annotation/src/mitkVtkAnnotation3D.cpp @@ -1,56 +1,56 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkVtkOverlay3D.h" +#include "mitkVtkAnnotation3D.h" -mitk::VtkOverlay3D::VtkOverlay3D() +mitk::VtkAnnotation3D::VtkAnnotation3D() { mitk::Point3D offsetVector; offsetVector.Fill(0); SetOffsetVector(offsetVector); } -mitk::VtkOverlay3D::~VtkOverlay3D() +mitk::VtkAnnotation3D::~VtkAnnotation3D() { } -void mitk::VtkOverlay3D::SetPosition3D(const Point3D &position3D) +void mitk::VtkAnnotation3D::SetPosition3D(const Point3D &position3D) { mitk::Point3dProperty::Pointer position3dProperty = mitk::Point3dProperty::New(position3D); - SetProperty("VtkOverlay3D.Position3D", position3dProperty.GetPointer()); + SetProperty("VtkAnnotation3D.Position3D", position3dProperty.GetPointer()); } -mitk::Point3D mitk::VtkOverlay3D::GetPosition3D() const +mitk::Point3D mitk::VtkAnnotation3D::GetPosition3D() const { mitk::Point3D position3D; position3D.Fill(0); - GetPropertyValue("VtkOverlay3D.Position3D", position3D); + GetPropertyValue("VtkAnnotation3D.Position3D", position3D); return position3D; } -void mitk::VtkOverlay3D::SetOffsetVector(const Point3D &OffsetVector) +void mitk::VtkAnnotation3D::SetOffsetVector(const Point3D &OffsetVector) { mitk::Point3dProperty::Pointer OffsetVectorProperty = mitk::Point3dProperty::New(OffsetVector); - SetProperty("VtkOverlay3D.OffsetVector", OffsetVectorProperty.GetPointer()); + SetProperty("VtkAnnotation3D.OffsetVector", OffsetVectorProperty.GetPointer()); } -mitk::Point3D mitk::VtkOverlay3D::GetOffsetVector() const +mitk::Point3D mitk::VtkAnnotation3D::GetOffsetVector() const { mitk::Point3D OffsetVector; OffsetVector.Fill(0); - GetPropertyValue("VtkOverlay3D.OffsetVector", OffsetVector); + GetPropertyValue("VtkAnnotation3D.OffsetVector", OffsetVector); return OffsetVector; } diff --git a/Modules/Overlays/src/mitkVtkLogoRepresentation.cxx b/Modules/Annotation/src/mitkVtkLogoRepresentation.cxx similarity index 100% rename from Modules/Overlays/src/mitkVtkLogoRepresentation.cxx rename to Modules/Annotation/src/mitkVtkLogoRepresentation.cxx diff --git a/Modules/Overlays/test/CMakeLists.txt b/Modules/Annotation/test/CMakeLists.txt similarity index 100% rename from Modules/Overlays/test/CMakeLists.txt rename to Modules/Annotation/test/CMakeLists.txt diff --git a/Modules/Annotation/test/files.cmake b/Modules/Annotation/test/files.cmake new file mode 100644 index 0000000000..8b6efdd163 --- /dev/null +++ b/Modules/Annotation/test/files.cmake @@ -0,0 +1,18 @@ + +set(MODULE_TESTS + mitkAnnotationTest.cpp +) + +if(MITK_ENABLE_RENDERING_TESTING) +set(MODULE_TESTS + ${MODULE_TESTS} + mitkManualPlacementAnnotationRendererTest.cpp + mitkColorBarAnnotationTest.cpp + mitkLabelAnnotation3DTest.cpp + mitkLogoAnnotationTest.cpp + mitkLayoutAnnotationRendererTest.cpp + mitkScaleLegendAnnotationTest.cpp + mitkTextAnnotation2DTest.cpp + mitkTextAnnotation3DTest.cpp +) +endif() diff --git a/Modules/Annotation/test/mitkAnnotationTest.cpp b/Modules/Annotation/test/mitkAnnotationTest.cpp new file mode 100644 index 0000000000..d59b7e2296 --- /dev/null +++ b/Modules/Annotation/test/mitkAnnotationTest.cpp @@ -0,0 +1,59 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ +#include +#include +#include +#include +#include +#include +#include + +#include "mitkManualPlacementAnnotationRenderer.h" +#include "mitkLayoutAnnotationRenderer.h" + +class mitkAnnotationTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkAnnotationTestSuite); + MITK_TEST(AnnotationUtilsTest); + CPPUNIT_TEST_SUITE_END(); + +private: +public: + void setUp() override {} + void AnnotationUtilsTest() + { + mitk::ManualPlacementAnnotationRenderer *ap1_test1 = mitk::ManualPlacementAnnotationRenderer::GetAnnotationRenderer("test1"); + CPPUNIT_ASSERT_MESSAGE("Testing availability of ManualPlacementAnnotationRenderer service", ap1_test1); + mitk::ManualPlacementAnnotationRenderer *ap2_test1 = mitk::ManualPlacementAnnotationRenderer::GetAnnotationRenderer("test1"); + CPPUNIT_ASSERT_MESSAGE("Testing if ManualPlacementAnnotationRenderer of same kind stays avaliable", ap1_test1 == ap2_test1); + mitk::ManualPlacementAnnotationRenderer *ap1_test2 = mitk::ManualPlacementAnnotationRenderer::GetAnnotationRenderer("test2"); + CPPUNIT_ASSERT_MESSAGE("Testing if new instance can be created by using different ID", ap1_test2 != ap1_test1); + + mitk::LayoutAnnotationRenderer *ol1_test1 = mitk::LayoutAnnotationRenderer::GetAnnotationRenderer("test1"); + CPPUNIT_ASSERT_MESSAGE("Testing availability of LayoutAnnotationRenderer service", ol1_test1); + mitk::LayoutAnnotationRenderer *ol2_test1 = mitk::LayoutAnnotationRenderer::GetAnnotationRenderer("test1"); + CPPUNIT_ASSERT_MESSAGE("Testing if LayoutAnnotationRenderer of same kind stays avaliable", ol2_test1 == ol1_test1); + mitk::LayoutAnnotationRenderer *ol1_test2 = mitk::LayoutAnnotationRenderer::GetAnnotationRenderer("test2"); + CPPUNIT_ASSERT_MESSAGE("Testing if new instance can be created by using different ID", ol1_test2 != ol1_test1); + + CPPUNIT_ASSERT_MESSAGE( + "Testing if LayoutAnnotationRenderer and ManualPlacementAnnotationRenderer services are different", + (mitk::AbstractAnnotationRenderer *)ol1_test1 != (mitk::AbstractAnnotationRenderer *)ap1_test1); + } + + void AnnotationTest() {} +}; +MITK_TEST_SUITE_REGISTRATION(mitkAnnotation) diff --git a/Modules/Overlays/test/mitkScaleLegendOverlayTest.cpp b/Modules/Annotation/test/mitkColorBarAnnotationTest.cpp similarity index 80% rename from Modules/Overlays/test/mitkScaleLegendOverlayTest.cpp rename to Modules/Annotation/test/mitkColorBarAnnotationTest.cpp index 5ce28727ca..4c3ed07466 100644 --- a/Modules/Overlays/test/mitkScaleLegendOverlayTest.cpp +++ b/Modules/Annotation/test/mitkColorBarAnnotationTest.cpp @@ -1,99 +1,99 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // MITK #include -#include +#include +#include #include -#include #include #include -class mitkScaleLegendOverlayTestSuite : public mitk::TestFixture +class mitkColorBarAnnotationTestSuite : public mitk::TestFixture { - CPPUNIT_TEST_SUITE(mitkScaleLegendOverlayTestSuite); - MITK_TEST(RenderScaleLegendOverlay); + CPPUNIT_TEST_SUITE(mitkColorBarAnnotationTestSuite); + MITK_TEST(RenderColorBarAnnotation); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::RenderingTestHelper m_RenderingTestHelper; std::vector m_CommandlineArgs; std::string m_PathToBall; std::string m_PathToImage; std::string m_ReferenceImagePath; public: /** - * @brief mitkAnnotationPlacerTestSuite Because the RenderingTestHelper does not have an + * @brief mitkManualPlacementAnnotationRendererTestSuite Because the RenderingTestHelper does not have an * empty default constructor, we need this constructor to initialize the helper with a * resolution. */ - mitkScaleLegendOverlayTestSuite() : m_RenderingTestHelper(300, 300) {} + mitkColorBarAnnotationTestSuite() : m_RenderingTestHelper(300, 300) {} /** * @brief Setup Initialize a fresh rendering test helper and a vector of strings * to simulate commandline arguments for vtkTesting::Test. */ void setUp() { m_RenderingTestHelper = mitk::RenderingTestHelper(300, 300); m_PathToBall = GetTestDataFilePath("ball.stl"); m_PathToImage = GetTestDataFilePath("Pic3D.nrrd"); - m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Overlay/"; + m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Annotation/"; // Build a command line for the vtkTesting::Test method. // See VTK documentation and RenderingTestHelper for more information. // Use the following command line option to save the difference image // and the test image in some tmp folder // m_CommandlineArgs.push_back("-T"); // m_CommandlineArgs.push_back("/path/to/save/tmp/difference/images/"); m_CommandlineArgs.push_back("-V"); } void tearDown() {} - void RenderScaleLegendOverlay() + void RenderColorBarAnnotation() { mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); m_RenderingTestHelper.AddNodeToStorage(ballnode); mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); m_RenderingTestHelper.AddNodeToStorage(imagenode); - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "mitkScaleLegendOverlay.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "mitkColorBarAnnotation.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); - mitk::ScaleLegendOverlay::Pointer colorbar = mitk::ScaleLegendOverlay::New(); + mitk::ColorBarAnnotation::Pointer colorbar = mitk::ColorBarAnnotation::New(); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(colorbar.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(colorbar.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } }; -MITK_TEST_SUITE_REGISTRATION(mitkScaleLegendOverlay) +MITK_TEST_SUITE_REGISTRATION(mitkColorBarAnnotation) diff --git a/Modules/Overlays/test/mitkLabelOverlay3DTest.cpp b/Modules/Annotation/test/mitkLabelAnnotation3DTest.cpp similarity index 83% rename from Modules/Overlays/test/mitkLabelOverlay3DTest.cpp rename to Modules/Annotation/test/mitkLabelAnnotation3DTest.cpp index d6093c9bbf..7efcd56cf6 100644 --- a/Modules/Overlays/test/mitkLabelOverlay3DTest.cpp +++ b/Modules/Annotation/test/mitkLabelAnnotation3DTest.cpp @@ -1,169 +1,169 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // MITK #include -#include -#include +#include +#include #include #include #include -class mitkLabelOverlay3DTestSuite : public mitk::TestFixture +class mitkLabelAnnotation3DTestSuite : public mitk::TestFixture { - CPPUNIT_TEST_SUITE(mitkLabelOverlay3DTestSuite); - MITK_TEST(Render2DOverlays); - MITK_TEST(Render3DOverlays); + CPPUNIT_TEST_SUITE(mitkLabelAnnotation3DTestSuite); + MITK_TEST(Render2DAnnotation); + MITK_TEST(Render3DAnnotation); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::RenderingTestHelper m_RenderingTestHelper; std::vector m_CommandlineArgs; std::string m_PathToBall; std::string m_PathToImage; std::string m_ReferenceImagePath; public: /** - * @brief mitkAnnotationPlacerTestSuite Because the RenderingTestHelper does not have an + * @brief mitkManualPlacementAnnotationRendererTestSuite Because the RenderingTestHelper does not have an * empty default constructor, we need this constructor to initialize the helper with a * resolution. */ - mitkLabelOverlay3DTestSuite() : m_RenderingTestHelper(300, 300) {} + mitkLabelAnnotation3DTestSuite() : m_RenderingTestHelper(300, 300) {} /** * @brief Setup Initialize a fresh rendering test helper and a vector of strings * to simulate commandline arguments for vtkTesting::Test. */ void setUp() { m_RenderingTestHelper = mitk::RenderingTestHelper(300, 300); m_PathToBall = GetTestDataFilePath("ball.stl"); m_PathToImage = GetTestDataFilePath("Pic3D.nrrd"); - m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Overlay/"; + m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Annotation/"; // Build a command line for the vtkTesting::Test method. // See VTK documentation and RenderingTestHelper for more information. // Use the following command line option to save the difference image // and the test image in some tmp folder // m_CommandlineArgs.push_back("-T"); // m_CommandlineArgs.push_back("/path/to/save/tmp/difference/images/"); m_CommandlineArgs.push_back("-V"); } void tearDown() {} - void Render2DOverlays() + void Render2DAnnotation() { - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "mitkLabelOverlay3D.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "mitkLabelAnnotation3D.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); mitk::PointSet::Pointer pointset = mitk::PointSet::New(); - mitk::LabelOverlay3D::Pointer label3d = mitk::LabelOverlay3D::New(); + mitk::LabelAnnotation3D::Pointer label3d = mitk::LabelAnnotation3D::New(); mitk::Point3D offset; offset[0] = .5; offset[1] = .5; offset[2] = .5; std::vector labels; unsigned long idx = 0; for (int i = -10; i < 10; i += 4) { for (int j = -10; j < 10; j += 4) { mitk::Point3D point; point[0] = i; point[1] = j; point[2] = (i * j) / 10; pointset->InsertPoint(idx++, point); labels.push_back("test"); } } label3d->SetLabelCoordinates(pointset); label3d->SetLabelVector(labels); label3d->SetOffsetVector(offset); mitk::DataNode::Pointer datanode = mitk::DataNode::New(); datanode->SetData(pointset); datanode->SetName("pointSet"); m_RenderingTestHelper.AddNodeToStorage(datanode); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(label3d.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(label3d.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } - void Render3DOverlays() + void Render3DAnnotation() { - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "mitkLabelOverlay3D.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "mitkLabelAnnotation3D.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetMapperIDToRender3D(); mitk::PointSet::Pointer pointset = mitk::PointSet::New(); - mitk::LabelOverlay3D::Pointer label3d = mitk::LabelOverlay3D::New(); + mitk::LabelAnnotation3D::Pointer label3d = mitk::LabelAnnotation3D::New(); mitk::Point3D offset; offset[0] = .5; offset[1] = .5; offset[2] = .5; std::vector labels; unsigned long idx = 0; for (int i = -10; i < 10; i += 4) { for (int j = -10; j < 10; j += 4) { mitk::Point3D point; point[0] = i; point[1] = j; point[2] = (i * j) / 10; pointset->InsertPoint(idx++, point); labels.push_back("test"); } } label3d->SetLabelCoordinates(pointset); label3d->SetLabelVector(labels); label3d->SetOffsetVector(offset); mitk::DataNode::Pointer datanode = mitk::DataNode::New(); datanode->SetData(pointset); datanode->SetName("pointSet"); m_RenderingTestHelper.AddNodeToStorage(datanode); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(label3d.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(label3d.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } }; -MITK_TEST_SUITE_REGISTRATION(mitkLabelOverlay3D) +MITK_TEST_SUITE_REGISTRATION(mitkLabelAnnotation3D) diff --git a/Modules/Annotation/test/mitkLayoutAnnotationRendererTest.cpp b/Modules/Annotation/test/mitkLayoutAnnotationRendererTest.cpp new file mode 100644 index 0000000000..68ff4bceb7 --- /dev/null +++ b/Modules/Annotation/test/mitkLayoutAnnotationRendererTest.cpp @@ -0,0 +1,162 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +// MITK +#include + +#include +#include +#include +#include +#include + +void createTextAnnotationWithLayouter(std::vector &Annotation, + mitk::LayoutAnnotationRenderer::Alignment align, + mitk::BaseRenderer *renderer, + int fontsize, + float red, + float green, + float blue, + int prio, + std::string text) +{ + // Create a textAnnotation2D + mitk::TextAnnotation2D::Pointer textAnnotation = mitk::TextAnnotation2D::New(); + + textAnnotation->SetText(text); + textAnnotation->SetFontSize(fontsize); + textAnnotation->SetColor(red, green, blue); + textAnnotation->SetOpacity(1); + + mitk::LayoutAnnotationRenderer::AddAnnotation(textAnnotation, renderer, align, 5, 5, prio); + Annotation.push_back(textAnnotation); +} + +class mitkLayoutAnnotationRendererTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkLayoutAnnotationRendererTestSuite); + MITK_TEST(Render2DAnnotation); + + CPPUNIT_TEST_SUITE_END(); + +private: + /** Members used inside the different test methods. All members are initialized via setUp().*/ + mitk::RenderingTestHelper m_RenderingTestHelper; + std::vector m_CommandlineArgs; + std::string m_PathToBall; + std::string m_PathToImage; + std::string m_ReferenceImagePath; + +public: + /** + * @brief mitkManualPlacementAnnotationRendererTestSuite Because the RenderingTestHelper does not have an + * empty default constructor, we need this constructor to initialize the helper with a + * resolution. + */ + mitkLayoutAnnotationRendererTestSuite() : m_RenderingTestHelper(500, 500) {} + /** + * @brief Setup Initialize a fresh rendering test helper and a vector of strings + * to simulate commandline arguments for vtkTesting::Test. + */ + void setUp() + { + m_RenderingTestHelper = mitk::RenderingTestHelper(500, 500); + + m_PathToBall = GetTestDataFilePath("ball.stl"); + m_PathToImage = GetTestDataFilePath("Pic3D.nrrd"); + m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Annotation/"; + + // Build a command line for the vtkTesting::Test method. + // See VTK documentation and RenderingTestHelper for more information. + // Use the following command line option to save the difference image + // and the test image in some tmp folder + // m_CommandlineArgs.push_back("-T"); + // m_CommandlineArgs.push_back("/path/to/save/tmp/difference/images/"); + m_CommandlineArgs.push_back("-V"); + } + + void tearDown() {} + void Render2DAnnotation() + { + mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); + ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); + m_RenderingTestHelper.AddNodeToStorage(ballnode); + + mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); + imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); + m_RenderingTestHelper.AddNodeToStorage(imagenode); + + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "LayoutAnnotationRenderer.png"); + // reference screenshot for this test + m_CommandlineArgs.push_back(refImagePath); + // Convert vector of strings to argc/argv + mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); + m_RenderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); + + std::vector Annotation; + mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); + + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::TopLeft, renderer, 20, 1.0, 1.0, 1.0, 1, "TopLeft1"); + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::TopLeft, renderer, 15, 1.0, 1.0, 1.0, 3, "TopLeft3"); + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::TopLeft, renderer, 25, 1.0, 0.0, 1.0, 2, "TopLeft2"); + + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Top, renderer, 15, 1.0, 1.0, 1.0, 3, "Top3"); + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Top, renderer, 20, 1.0, 1.0, 1.0, 1, "Top1"); + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Top, renderer, 25, 1.0, 0.0, 1.0, 2, "Top2"); + + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::TopRight, renderer, 20, 1.0, 1.0, 1.0, 1, "TopRight1"); + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::TopRight, renderer, 15, 1.0, 1.0, 1.0, 3, "TopRight3"); + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::TopRight, renderer, 25, 1.0, 0.0, 1.0, 2, "TopRight2"); + + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Left, renderer, 20, 1.0, 1.0, 1.0, 1, "Left1"); + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Left, renderer, 15, 1.0, 1.0, 1.0, 3, "Left3"); + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Left, renderer, 25, 1.0, 0.0, 1.0, 2, "Left2"); + + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Right, renderer, 25, 1.0, 0.0, 1.0, 2, "Right2"); + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Right, renderer, 20, 1.0, 1.0, 1.0, 1, "Right1"); + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Right, renderer, 15, 1.0, 1.0, 1.0, 3, "Right3"); + + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::BottomLeft, renderer, 25, 1.0, 0.0, 1.0, 2, "BottomLeft2"); + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::BottomLeft, renderer, 20, 1.0, 1.0, 1.0, 1, "BottomLeft1"); + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::BottomLeft, renderer, 15, 1.0, 1.0, 1.0, 3, "BottomLeft3"); + + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Bottom, renderer, 15, 1.0, 1.0, 1.0, 3, "Bottom3"); + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Bottom, renderer, 20, 1.0, 1.0, 1.0, 1, "Bottom1"); + createTextAnnotationWithLayouter(Annotation, mitk::LayoutAnnotationRenderer::Bottom, renderer, 25, 1.0, 0.0, 1.0, 2, "Bottom2"); + + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::BottomRight, renderer, 25, 1.0, 0.0, 1.0, 2, "BottomRight2"); + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::BottomRight, renderer, 20, 1.0, 1.0, 1.0, 1, "BottomRight1"); + createTextAnnotationWithLayouter( + Annotation, mitk::LayoutAnnotationRenderer::BottomRight, renderer, 15, 1.0, 1.0, 1.0, 3, "BottomRight3"); + + m_RenderingTestHelper.Render(); + m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); + m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); + CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); + } +}; +MITK_TEST_SUITE_REGISTRATION(mitkLayoutAnnotationRenderer) diff --git a/Modules/Overlays/test/mitkLogoOverlayTest.cpp b/Modules/Annotation/test/mitkLogoAnnotationTest.cpp similarity index 81% rename from Modules/Overlays/test/mitkLogoOverlayTest.cpp rename to Modules/Annotation/test/mitkLogoAnnotationTest.cpp index 228c18c68a..c5c9c56581 100644 --- a/Modules/Overlays/test/mitkLogoOverlayTest.cpp +++ b/Modules/Annotation/test/mitkLogoAnnotationTest.cpp @@ -1,136 +1,136 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // MITK #include -#include -#include +#include +#include #include #include #include -class mitkLogoOverlayTestSuite : public mitk::TestFixture +class mitkLogoAnnotationTestSuite : public mitk::TestFixture { - CPPUNIT_TEST_SUITE(mitkLogoOverlayTestSuite); + CPPUNIT_TEST_SUITE(mitkLogoAnnotationTestSuite); MITK_TEST(RenderMbiLogo); MITK_TEST(RenderLogo); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::RenderingTestHelper m_RenderingTestHelper; std::vector m_CommandlineArgs; std::string m_PathToBall; std::string m_PathToImage; std::string m_PathToLogo; std::string m_ReferenceImagePath; public: /** - * @brief mitkAnnotationPlacerTestSuite Because the RenderingTestHelper does not have an + * @brief mitkManualPlacementAnnotationRendererTestSuite Because the RenderingTestHelper does not have an * empty default constructor, we need this constructor to initialize the helper with a * resolution. */ - mitkLogoOverlayTestSuite() : m_RenderingTestHelper(300, 300) {} + mitkLogoAnnotationTestSuite() : m_RenderingTestHelper(300, 300) {} /** * @brief Setup Initialize a fresh rendering test helper and a vector of strings * to simulate commandline arguments for vtkTesting::Test. */ void setUp() { m_RenderingTestHelper = mitk::RenderingTestHelper(300, 300); m_PathToBall = GetTestDataFilePath("ball.stl"); m_PathToImage = GetTestDataFilePath("Pic3D.nrrd"); m_PathToLogo = GetTestDataFilePath("RenderingTestData/rgbaImage.png"); - m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Overlay/"; + m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Annotation/"; // Build a command line for the vtkTesting::Test method. // See VTK documentation and RenderingTestHelper for more information. // Use the following command line option to save the difference image // and the test image in some tmp folder // m_CommandlineArgs.push_back("-T"); // m_CommandlineArgs.push_back("/path/to/save/tmp/difference/images/"); m_CommandlineArgs.push_back("-V"); } void tearDown() {} void RenderMbiLogo() { mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); m_RenderingTestHelper.AddNodeToStorage(ballnode); mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); m_RenderingTestHelper.AddNodeToStorage(imagenode); - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "LogoOverlay_mbiLogo.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "LogoAnnotation_mbiLogo.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); - mitk::LogoOverlay::Pointer logoOverlay = mitk::LogoOverlay::New(); + mitk::LogoAnnotation::Pointer logoAnnotation = mitk::LogoAnnotation::New(); - logoOverlay->SetLogoImagePath("mbilogo"); + logoAnnotation->SetLogoImagePath("mbilogo"); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(logoOverlay.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(logoAnnotation.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } void RenderLogo() { mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); m_RenderingTestHelper.AddNodeToStorage(ballnode); mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); m_RenderingTestHelper.AddNodeToStorage(imagenode); - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "LogoOverlay.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "LogoAnnotation.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); - mitk::LogoOverlay::Pointer logoOverlay = mitk::LogoOverlay::New(); + mitk::LogoAnnotation::Pointer logoAnnotation = mitk::LogoAnnotation::New(); - logoOverlay->SetLogoImagePath(m_PathToLogo); + logoAnnotation->SetLogoImagePath(m_PathToLogo); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(logoOverlay.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(logoAnnotation.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } }; -MITK_TEST_SUITE_REGISTRATION(mitkLogoOverlay) +MITK_TEST_SUITE_REGISTRATION(mitkLogoAnnotation) diff --git a/Modules/Overlays/test/mitkAnnotationPlacerTest.cpp b/Modules/Annotation/test/mitkManualPlacementAnnotationRendererTest.cpp similarity index 74% rename from Modules/Overlays/test/mitkAnnotationPlacerTest.cpp rename to Modules/Annotation/test/mitkManualPlacementAnnotationRendererTest.cpp index fd8355efbc..5bb1bfe995 100644 --- a/Modules/Overlays/test/mitkAnnotationPlacerTest.cpp +++ b/Modules/Annotation/test/mitkManualPlacementAnnotationRendererTest.cpp @@ -1,142 +1,142 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // MITK #include -#include +#include #include #include #include -#include -#include +#include +#include -class mitkAnnotationPlacerTestSuite : public mitk::TestFixture +class mitkManualPlacementAnnotationRendererTestSuite : public mitk::TestFixture { - CPPUNIT_TEST_SUITE(mitkAnnotationPlacerTestSuite); - MITK_TEST(Render2DOverlays); - MITK_TEST(Render3DOverlays); + CPPUNIT_TEST_SUITE(mitkManualPlacementAnnotationRendererTestSuite); + MITK_TEST(Render2DAnnotation); + MITK_TEST(Render3DAnnotation); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::RenderingTestHelper m_RenderingTestHelper; std::vector m_CommandlineArgs; std::string m_PathToBall; std::string m_PathToImage; std::string m_ReferenceImagePath; public: /** - * @brief mitkAnnotationPlacerTestSuite Because the RenderingTestHelper does not have an + * @brief mitkManualPlacementAnnotationRendererTestSuite Because the RenderingTestHelper does not have an * empty default constructor, we need this constructor to initialize the helper with a * resolution. */ - mitkAnnotationPlacerTestSuite() : m_RenderingTestHelper(300, 300) {} + mitkManualPlacementAnnotationRendererTestSuite() : m_RenderingTestHelper(300, 300) {} /** * @brief Setup Initialize a fresh rendering test helper and a vector of strings * to simulate commandline arguments for vtkTesting::Test. */ void setUp() { m_RenderingTestHelper = mitk::RenderingTestHelper(300, 300); m_PathToBall = GetTestDataFilePath("ball.stl"); m_PathToImage = GetTestDataFilePath("Pic3D.nrrd"); - m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Overlay/"; + m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Annotation/"; // Build a command line for the vtkTesting::Test method. // See VTK documentation and RenderingTestHelper for more information. // Use the following command line option to save the difference image // and the test image in some tmp folder // m_CommandlineArgs.push_back("-T"); // m_CommandlineArgs.push_back("/path/to/save/tmp/difference/images/"); m_CommandlineArgs.push_back("-V"); } void tearDown() {} - void Render2DOverlays() + void Render2DAnnotation() { mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); m_RenderingTestHelper.AddNodeToStorage(ballnode); mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); m_RenderingTestHelper.AddNodeToStorage(imagenode); - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "AnnotationPlacer2DOverlays.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "ManualPlacementAnnotationRenderer2DAnnotation.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); - mitk::TextOverlay2D::Pointer textOverlay2D = mitk::TextOverlay2D::New(); + mitk::TextAnnotation2D::Pointer textAnnotation2D = mitk::TextAnnotation2D::New(); - textOverlay2D->SetText("TEST AnnotationPlacer2DOverlays"); + textAnnotation2D->SetText("TEST ManualPlacementAnnotationRenderer2DAnnotation"); mitk::Point2D pos; pos[0] = 0; pos[1] = 0; - textOverlay2D->SetPosition2D(pos); + textAnnotation2D->SetPosition2D(pos); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(textOverlay2D.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(textAnnotation2D.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } - void Render3DOverlays() + void Render3DAnnotation() { mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); m_RenderingTestHelper.AddNodeToStorage(ballnode); mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); m_RenderingTestHelper.AddNodeToStorage(imagenode); - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "AnnotationPlacer3DOverlays.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "ManualPlacementAnnotationRenderer3DAnnotation.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetMapperIDToRender3D(); - mitk::TextOverlay3D::Pointer textOverlay3D = mitk::TextOverlay3D::New(); + mitk::TextAnnotation3D::Pointer textAnnotation3D = mitk::TextAnnotation3D::New(); - textOverlay3D->SetText("TEST AnnotationPlacer3DOverlays"); + textAnnotation3D->SetText("TEST ManualPlacementAnnotationRenderer3DAnnotation"); mitk::Point3D pos; pos[0] = 10; pos[1] = 10; pos[2] = 10; - textOverlay3D->SetPosition3D(pos); + textAnnotation3D->SetPosition3D(pos); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(textOverlay3D.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(textAnnotation3D.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } }; -MITK_TEST_SUITE_REGISTRATION(mitkAnnotationPlacer) +MITK_TEST_SUITE_REGISTRATION(mitkManualPlacementAnnotationRenderer) diff --git a/Modules/Overlays/test/mitkColorBarOverlayTest.cpp b/Modules/Annotation/test/mitkScaleLegendAnnotationTest.cpp similarity index 79% rename from Modules/Overlays/test/mitkColorBarOverlayTest.cpp rename to Modules/Annotation/test/mitkScaleLegendAnnotationTest.cpp index 4682cade49..87df330b17 100644 --- a/Modules/Overlays/test/mitkColorBarOverlayTest.cpp +++ b/Modules/Annotation/test/mitkScaleLegendAnnotationTest.cpp @@ -1,99 +1,99 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // MITK #include -#include -#include +#include #include +#include #include #include -class mitkColorBarOverlayTestSuite : public mitk::TestFixture +class mitkScaleLegendAnnotationTestSuite : public mitk::TestFixture { - CPPUNIT_TEST_SUITE(mitkColorBarOverlayTestSuite); - MITK_TEST(RenderColorBarOverlay); + CPPUNIT_TEST_SUITE(mitkScaleLegendAnnotationTestSuite); + MITK_TEST(RenderScaleLegendAnnotation); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::RenderingTestHelper m_RenderingTestHelper; std::vector m_CommandlineArgs; std::string m_PathToBall; std::string m_PathToImage; std::string m_ReferenceImagePath; public: /** - * @brief mitkAnnotationPlacerTestSuite Because the RenderingTestHelper does not have an + * @brief mitkManualPlacementAnnotationRendererTestSuite Because the RenderingTestHelper does not have an * empty default constructor, we need this constructor to initialize the helper with a * resolution. */ - mitkColorBarOverlayTestSuite() : m_RenderingTestHelper(300, 300) {} + mitkScaleLegendAnnotationTestSuite() : m_RenderingTestHelper(300, 300) {} /** * @brief Setup Initialize a fresh rendering test helper and a vector of strings * to simulate commandline arguments for vtkTesting::Test. */ void setUp() { m_RenderingTestHelper = mitk::RenderingTestHelper(300, 300); m_PathToBall = GetTestDataFilePath("ball.stl"); m_PathToImage = GetTestDataFilePath("Pic3D.nrrd"); - m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Overlay/"; + m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Annotation/"; // Build a command line for the vtkTesting::Test method. // See VTK documentation and RenderingTestHelper for more information. // Use the following command line option to save the difference image // and the test image in some tmp folder // m_CommandlineArgs.push_back("-T"); // m_CommandlineArgs.push_back("/path/to/save/tmp/difference/images/"); m_CommandlineArgs.push_back("-V"); } void tearDown() {} - void RenderColorBarOverlay() + void RenderScaleLegendAnnotation() { mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); m_RenderingTestHelper.AddNodeToStorage(ballnode); mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); m_RenderingTestHelper.AddNodeToStorage(imagenode); - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "mitkColorBarOverlay.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "mitkScaleLegendAnnotation.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); - mitk::ColorBarOverlay::Pointer colorbar = mitk::ColorBarOverlay::New(); + mitk::ScaleLegendAnnotation::Pointer colorbar = mitk::ScaleLegendAnnotation::New(); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(colorbar.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(colorbar.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } }; -MITK_TEST_SUITE_REGISTRATION(mitkColorBarOverlay) +MITK_TEST_SUITE_REGISTRATION(mitkScaleLegendAnnotation) diff --git a/Modules/Overlays/test/mitkTextOverlay2DTest.cpp b/Modules/Annotation/test/mitkTextAnnotation2DTest.cpp similarity index 79% rename from Modules/Overlays/test/mitkTextOverlay2DTest.cpp rename to Modules/Annotation/test/mitkTextAnnotation2DTest.cpp index 33626c98d9..9ec55990c2 100644 --- a/Modules/Overlays/test/mitkTextOverlay2DTest.cpp +++ b/Modules/Annotation/test/mitkTextAnnotation2DTest.cpp @@ -1,105 +1,105 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // MITK #include -#include +#include #include #include #include -#include +#include -class mitkTextOverlay2DTestSuite : public mitk::TestFixture +class mitkTextAnnotation2DTestSuite : public mitk::TestFixture { - CPPUNIT_TEST_SUITE(mitkTextOverlay2DTestSuite); - MITK_TEST(Render2DOverlays); + CPPUNIT_TEST_SUITE(mitkTextAnnotation2DTestSuite); + MITK_TEST(Render2DAnnotation); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::RenderingTestHelper m_RenderingTestHelper; std::vector m_CommandlineArgs; std::string m_PathToBall; std::string m_PathToImage; std::string m_ReferenceImagePath; public: /** - * @brief mitkTextOverlay2DTestSuite Because the RenderingTestHelper does not have an + * @brief mitkTextAnnotation2DTestSuite Because the RenderingTestHelper does not have an * empty default constructor, we need this constructor to initialize the helper with a * resolution. */ - mitkTextOverlay2DTestSuite() : m_RenderingTestHelper(300, 300) {} + mitkTextAnnotation2DTestSuite() : m_RenderingTestHelper(300, 300) {} /** * @brief Setup Initialize a fresh rendering test helper and a vector of strings * to simulate commandline arguments for vtkTesting::Test. */ void setUp() { m_RenderingTestHelper = mitk::RenderingTestHelper(300, 300); m_PathToBall = GetTestDataFilePath("ball.stl"); m_PathToImage = GetTestDataFilePath("Pic3D.nrrd"); - m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Overlay/"; + m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Annotation/"; // Build a command line for the vtkTesting::Test method. // See VTK documentation and RenderingTestHelper for more information. // Use the following command line option to save the difference image // and the test image in some tmp folder // m_CommandlineArgs.push_back("-T"); // m_CommandlineArgs.push_back("/path/to/save/tmp/difference/images/"); m_CommandlineArgs.push_back("-V"); } void tearDown() {} - void Render2DOverlays() + void Render2DAnnotation() { mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); m_RenderingTestHelper.AddNodeToStorage(ballnode); mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); m_RenderingTestHelper.AddNodeToStorage(imagenode); - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "TextOverlay2D.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "TextAnnotation2D.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); - mitk::TextOverlay2D::Pointer textOverlay2D = mitk::TextOverlay2D::New(); + mitk::TextAnnotation2D::Pointer textAnnotation2D = mitk::TextAnnotation2D::New(); - textOverlay2D->SetText("TEST TextOverlay2D2DOverlays"); + textAnnotation2D->SetText("TEST TextAnnotation2D2DAnnotation"); mitk::Point2D pos; pos[0] = 0; pos[1] = 0; - textOverlay2D->SetPosition2D(pos); + textAnnotation2D->SetPosition2D(pos); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(textOverlay2D.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(textAnnotation2D.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } }; -MITK_TEST_SUITE_REGISTRATION(mitkTextOverlay2D) +MITK_TEST_SUITE_REGISTRATION(mitkTextAnnotation2D) diff --git a/Modules/Overlays/test/mitkTextOverlay3DTest.cpp b/Modules/Annotation/test/mitkTextAnnotation3DTest.cpp similarity index 78% rename from Modules/Overlays/test/mitkTextOverlay3DTest.cpp rename to Modules/Annotation/test/mitkTextAnnotation3DTest.cpp index d920717bb8..2f0a969216 100644 --- a/Modules/Overlays/test/mitkTextOverlay3DTest.cpp +++ b/Modules/Annotation/test/mitkTextAnnotation3DTest.cpp @@ -1,105 +1,105 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // MITK #include -#include +#include #include #include #include -#include +#include -class mitkTextOverlay3DTestSuite : public mitk::TestFixture +class mitkTextAnnotation3DTestSuite : public mitk::TestFixture { - CPPUNIT_TEST_SUITE(mitkTextOverlay3DTestSuite); - MITK_TEST(Render3DOverlays); + CPPUNIT_TEST_SUITE(mitkTextAnnotation3DTestSuite); + MITK_TEST(Render3DAnnotation); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::RenderingTestHelper m_RenderingTestHelper; std::vector m_CommandlineArgs; std::string m_PathToBall; std::string m_PathToImage; std::string m_ReferenceImagePath; public: /** - * @brief mitkTextOverlay3DTestSuite Because the RenderingTestHelper does not have an + * @brief mitkTextAnnotation3DTestSuite Because the RenderingTestHelper does not have an * empty default constructor, we need this constructor to initialize the helper with a * resolution. */ - mitkTextOverlay3DTestSuite() : m_RenderingTestHelper(300, 300) {} + mitkTextAnnotation3DTestSuite() : m_RenderingTestHelper(300, 300) {} /** * @brief Setup Initialize a fresh rendering test helper and a vector of strings * to simulate commandline arguments for vtkTesting::Test. */ void setUp() { m_RenderingTestHelper = mitk::RenderingTestHelper(300, 300); m_PathToBall = GetTestDataFilePath("ball.stl"); m_PathToImage = GetTestDataFilePath("Pic3D.nrrd"); - m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Overlay/"; + m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Annotation/"; // Build a command line for the vtkTesting::Test method. // See VTK documentation and RenderingTestHelper for more information. // Use the following command line option to save the difference image // and the test image in some tmp folder // m_CommandlineArgs.push_back("-T"); // m_CommandlineArgs.push_back("/path/to/save/tmp/difference/images/"); m_CommandlineArgs.push_back("-V"); } void tearDown() {} - void Render3DOverlays() + void Render3DAnnotation() { mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); m_RenderingTestHelper.AddNodeToStorage(ballnode); mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); m_RenderingTestHelper.AddNodeToStorage(imagenode); - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "TextOverlay3D.png"); + std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "TextAnnotation3D.png"); // reference screenshot for this test m_CommandlineArgs.push_back(refImagePath); // Convert vector of strings to argc/argv mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); m_RenderingTestHelper.SetMapperIDToRender3D(); - mitk::TextOverlay3D::Pointer textOverlay3D = mitk::TextOverlay3D::New(); + mitk::TextAnnotation3D::Pointer textAnnotation3D = mitk::TextAnnotation3D::New(); - textOverlay3D->SetText("TESTAnnotationPlacer3DOverlays"); + textAnnotation3D->SetText("TESTManualPlacementAnnotationRenderer3DAnnotation"); mitk::Point3D pos; pos[0] = 10; pos[1] = 10; pos[2] = 10; - textOverlay3D->SetPosition3D(pos); + textAnnotation3D->SetPosition3D(pos); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - mitk::AnnotationPlacer::AddOverlay(textOverlay3D.GetPointer(), renderer); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(textAnnotation3D.GetPointer(), renderer); m_RenderingTestHelper.Render(); m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); } }; -MITK_TEST_SUITE_REGISTRATION(mitkTextOverlay3D) +MITK_TEST_SUITE_REGISTRATION(mitkTextAnnotation3D) diff --git a/Modules/ContourModel/CMakeLists.txt b/Modules/ContourModel/CMakeLists.txt index 82cdb04801..dd431cf295 100644 --- a/Modules/ContourModel/CMakeLists.txt +++ b/Modules/ContourModel/CMakeLists.txt @@ -1,9 +1,9 @@ MITK_CREATE_MODULE( INCLUDE_DIRS Algorithms DataManagement IO Rendering - DEPENDS MitkCore MitkSceneSerializationBase MitkLegacyGL MitkOverlays MitkMultilabel + DEPENDS MitkCore MitkSceneSerializationBase MitkLegacyGL MitkAnnotation MitkMultilabel PACKAGE_DEPENDS ITK|ITKReview # AUTOLOAD_WITH MitkCore TODO: Create IO Submodule and autoload that one instead. WARNINGS_AS_ERRORS ) add_subdirectory(Testing) diff --git a/Modules/ContourModel/Rendering/mitkContourModelGLMapper2DBase.cpp b/Modules/ContourModel/Rendering/mitkContourModelGLMapper2DBase.cpp index a3bd0060b7..912e0806d8 100644 --- a/Modules/ContourModel/Rendering/mitkContourModelGLMapper2DBase.cpp +++ b/Modules/ContourModel/Rendering/mitkContourModelGLMapper2DBase.cpp @@ -1,370 +1,370 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkContourModelSetGLMapper2D.h" #include "mitkColorProperty.h" #include "mitkContourModelSet.h" #include "mitkPlaneGeometry.h" #include "mitkProperties.h" #include -#include "mitkAnnotationPlacer.h" +#include "mitkManualPlacementAnnotationRenderer.h" #include "mitkBaseRenderer.h" #include "mitkContourModel.h" -#include "mitkTextOverlay2D.h" +#include "mitkTextAnnotation2D.h" #include "mitkGL.h" mitk::ContourModelGLMapper2DBase::ContourModelGLMapper2DBase() { - m_PointNumbersOverlay = mitk::TextOverlay2D::New(); - m_ControlPointNumbersOverlay = mitk::TextOverlay2D::New(); + m_PointNumbersAnnotation = mitk::TextAnnotation2D::New(); + m_ControlPointNumbersAnnotation = mitk::TextAnnotation2D::New(); } mitk::ContourModelGLMapper2DBase::~ContourModelGLMapper2DBase() { } void mitk::ContourModelGLMapper2DBase::DrawContour(mitk::ContourModel *renderingContour, mitk::BaseRenderer *renderer) { if (std::find(m_RendererList.begin(), m_RendererList.end(), renderer) == m_RendererList.end()) { m_RendererList.push_back(renderer); } - mitk::AnnotationPlacer::AddOverlay(m_PointNumbersOverlay.GetPointer(), renderer); - m_PointNumbersOverlay->SetVisibility(false); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(m_PointNumbersAnnotation.GetPointer(), renderer); + m_PointNumbersAnnotation->SetVisibility(false); - mitk::AnnotationPlacer::AddOverlay(m_ControlPointNumbersOverlay.GetPointer(), renderer); - m_ControlPointNumbersOverlay->SetVisibility(false); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(m_ControlPointNumbersAnnotation.GetPointer(), renderer); + m_ControlPointNumbersAnnotation->SetVisibility(false); InternalDrawContour(renderingContour, renderer); } void mitk::ContourModelGLMapper2DBase::InternalDrawContour(mitk::ContourModel *renderingContour, mitk::BaseRenderer *renderer) { if (!renderingContour) return; mitk::DataNode *dataNode = this->GetDataNode(); renderingContour->UpdateOutputInformation(); unsigned int timestep = renderer->GetTimeStep(); if (!renderingContour->IsEmptyTimeStep(timestep)) { // apply color and opacity read from the PropertyList ApplyColorAndOpacityProperties(renderer); mitk::ColorProperty::Pointer colorprop = dynamic_cast(dataNode->GetProperty("contour.color", renderer)); float opacity = 0.5; dataNode->GetFloatProperty("opacity", opacity, renderer); if (colorprop) { // set the color of the contour double red = colorprop->GetColor().GetRed(); double green = colorprop->GetColor().GetGreen(); double blue = colorprop->GetColor().GetBlue(); glColor4f(red, green, blue, opacity); } mitk::ColorProperty::Pointer selectedcolor = dynamic_cast(dataNode->GetProperty("contour.points.color", renderer)); if (!selectedcolor) { selectedcolor = mitk::ColorProperty::New(1.0, 0.0, 0.1); } vtkLinearTransform *transform = dataNode->GetVtkTransform(); // ContourModel::OutputType point; mitk::Point3D point; mitk::Point3D p; float vtkp[3]; float lineWidth = 3.0; bool drawit = false; bool isHovering = false; dataNode->GetBoolProperty("contour.hovering", isHovering); if (isHovering) dataNode->GetFloatProperty("contour.hovering.width", lineWidth); else dataNode->GetFloatProperty("contour.width", lineWidth); bool showSegments = false; dataNode->GetBoolProperty("contour.segments.show", showSegments); bool showControlPoints = false; dataNode->GetBoolProperty("contour.controlpoints.show", showControlPoints); bool showPoints = false; dataNode->GetBoolProperty("contour.points.show", showPoints); bool showPointsNumbers = false; dataNode->GetBoolProperty("contour.points.text", showPointsNumbers); bool showControlPointsNumbers = false; dataNode->GetBoolProperty("contour.controlpoints.text", showControlPointsNumbers); bool projectmode = false; dataNode->GetVisibility(projectmode, renderer, "contour.project-onto-plane"); mitk::ContourModel::VertexIterator pointsIt = renderingContour->IteratorBegin(timestep); Point2D pt2d; // projected_p in display coordinates Point2D lastPt2d; int index = 0; mitk::ScalarType maxDiff = 0.25; while (pointsIt != renderingContour->IteratorEnd(timestep)) { lastPt2d = pt2d; point = (*pointsIt)->Coordinates; itk2vtk(point, vtkp); transform->TransformPoint(vtkp, vtkp); vtk2itk(vtkp, p); renderer->WorldToDisplay(p, pt2d); ScalarType scalardiff = fabs(renderer->GetCurrentWorldPlaneGeometry()->SignedDistance(p)); // project to plane if (projectmode) { drawit = true; } else if (scalardiff < maxDiff) // point is close enough to be drawn { drawit = true; } else { drawit = false; } // draw line if (drawit) { if (showSegments) { // lastPt2d is not valid in first step if (!(pointsIt == renderingContour->IteratorBegin(timestep))) { glLineWidth(lineWidth); glBegin(GL_LINES); glVertex2f(pt2d[0], pt2d[1]); glVertex2f(lastPt2d[0], lastPt2d[1]); glEnd(); glLineWidth(1); } } if (showControlPoints) { // draw ontrol points if ((*pointsIt)->IsControlPoint) { float pointsize = 4; Point2D tmp; Vector2D horz, vert; horz[1] = 0; vert[0] = 0; horz[0] = pointsize; vert[1] = pointsize; glColor3f(selectedcolor->GetColor().GetRed(), selectedcolor->GetColor().GetBlue(), selectedcolor->GetColor().GetGreen()); glLineWidth(1); // a rectangle around the point with the selected color glBegin(GL_LINE_LOOP); tmp = pt2d - horz; glVertex2dv(&tmp[0]); tmp = pt2d + vert; glVertex2dv(&tmp[0]); tmp = pt2d + horz; glVertex2dv(&tmp[0]); tmp = pt2d - vert; glVertex2dv(&tmp[0]); glEnd(); glLineWidth(1); // the actual point in the specified color to see the usual color of the point glColor3f( colorprop->GetColor().GetRed(), colorprop->GetColor().GetGreen(), colorprop->GetColor().GetBlue()); glPointSize(1); glBegin(GL_POINTS); tmp = pt2d; glVertex2dv(&tmp[0]); glEnd(); } } if (showPoints) { float pointsize = 3; Point2D tmp; Vector2D horz, vert; horz[1] = 0; vert[0] = 0; horz[0] = pointsize; vert[1] = pointsize; glColor3f(0.0, 0.0, 0.0); glLineWidth(1); // a rectangle around the point with the selected color glBegin(GL_LINE_LOOP); tmp = pt2d - horz; glVertex2dv(&tmp[0]); tmp = pt2d + vert; glVertex2dv(&tmp[0]); tmp = pt2d + horz; glVertex2dv(&tmp[0]); tmp = pt2d - vert; glVertex2dv(&tmp[0]); glEnd(); glLineWidth(1); // the actual point in the specified color to see the usual color of the point glColor3f(colorprop->GetColor().GetRed(), colorprop->GetColor().GetGreen(), colorprop->GetColor().GetBlue()); glPointSize(1); glBegin(GL_POINTS); tmp = pt2d; glVertex2dv(&tmp[0]); glEnd(); } if (showPointsNumbers) { std::string l; std::stringstream ss; ss << index; l.append(ss.str()); float rgb[3]; rgb[0] = 0.0; rgb[1] = 0.0; rgb[2] = 0.0; - WriteTextWithOverlay(m_PointNumbersOverlay, l.c_str(), rgb, pt2d, renderer); + WriteTextWithAnnotation(m_PointNumbersAnnotation, l.c_str(), rgb, pt2d, renderer); } if (showControlPointsNumbers && (*pointsIt)->IsControlPoint) { std::string l; std::stringstream ss; ss << index; l.append(ss.str()); float rgb[3]; rgb[0] = 1.0; rgb[1] = 1.0; rgb[2] = 0.0; - WriteTextWithOverlay(m_ControlPointNumbersOverlay, l.c_str(), rgb, pt2d, renderer); + WriteTextWithAnnotation(m_ControlPointNumbersAnnotation, l.c_str(), rgb, pt2d, renderer); } index++; } pointsIt++; } // end while iterate over controlpoints // close contour if necessary if (renderingContour->IsClosed(timestep) && drawit && showSegments) { lastPt2d = pt2d; point = renderingContour->GetVertexAt(0, timestep)->Coordinates; itk2vtk(point, vtkp); transform->TransformPoint(vtkp, vtkp); vtk2itk(vtkp, p); renderer->WorldToDisplay(p, pt2d); glLineWidth(lineWidth); glBegin(GL_LINES); glVertex2f(lastPt2d[0], lastPt2d[1]); glVertex2f(pt2d[0], pt2d[1]); glEnd(); glLineWidth(1); } // draw selected vertex if exists if (renderingContour->GetSelectedVertex()) { // transform selected vertex point = renderingContour->GetSelectedVertex()->Coordinates; itk2vtk(point, vtkp); transform->TransformPoint(vtkp, vtkp); vtk2itk(vtkp, p); renderer->WorldToDisplay(p, pt2d); ScalarType scalardiff = fabs(renderer->GetCurrentWorldPlaneGeometry()->SignedDistance(p)); //---------------------------------- // draw point if close to plane if (scalardiff < maxDiff) { float pointsize = 5; Point2D tmp; glColor3f(0.0, 1.0, 0.0); glLineWidth(1); // a diamond around the point glBegin(GL_LINE_LOOP); // begin from upper left corner and paint clockwise tmp[0] = pt2d[0] - pointsize; tmp[1] = pt2d[1] + pointsize; glVertex2dv(&tmp[0]); tmp[0] = pt2d[0] + pointsize; tmp[1] = pt2d[1] + pointsize; glVertex2dv(&tmp[0]); tmp[0] = pt2d[0] + pointsize; tmp[1] = pt2d[1] - pointsize; glVertex2dv(&tmp[0]); tmp[0] = pt2d[0] - pointsize; tmp[1] = pt2d[1] - pointsize; glVertex2dv(&tmp[0]); glEnd(); } //------------------------------------ } } } -void mitk::ContourModelGLMapper2DBase::WriteTextWithOverlay(TextOverlayPointerType textOverlay, +void mitk::ContourModelGLMapper2DBase::WriteTextWithAnnotation(TextAnnotationPointerType textAnnotation, const char *text, float rgb[3], Point2D /*pt2d*/, mitk::BaseRenderer * /*renderer*/) { - textOverlay->SetText(text); - textOverlay->SetColor(rgb); - textOverlay->SetOpacity(1); - textOverlay->SetFontSize(16); - textOverlay->SetBoolProperty("drawShadow", false); - textOverlay->SetVisibility(true); + textAnnotation->SetText(text); + textAnnotation->SetColor(rgb); + textAnnotation->SetOpacity(1); + textAnnotation->SetFontSize(16); + textAnnotation->SetBoolProperty("drawShadow", false); + textAnnotation->SetVisibility(true); } diff --git a/Modules/ContourModel/Rendering/mitkContourModelGLMapper2DBase.h b/Modules/ContourModel/Rendering/mitkContourModelGLMapper2DBase.h index a53ad1ae07..05688ae45b 100644 --- a/Modules/ContourModel/Rendering/mitkContourModelGLMapper2DBase.h +++ b/Modules/ContourModel/Rendering/mitkContourModelGLMapper2DBase.h @@ -1,64 +1,64 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITK_ContourModelGLMapper2DBase_H_ #define MITK_ContourModelGLMapper2DBase_H_ #include "mitkCommon.h" #include "mitkGLMapper.h" -#include "mitkTextOverlay2D.h" +#include "mitkTextAnnotation2D.h" #include namespace mitk { class BaseRenderer; class ContourModel; /** * @brief Base class for OpenGL based 2D mappers. * Provides functionality to draw a contour. * * @ingroup MitkContourModelModule */ class MITKCONTOURMODEL_EXPORT ContourModelGLMapper2DBase : public GLMapper { public: mitkClassMacro(ContourModelGLMapper2DBase, GLMapper); protected: - typedef TextOverlay2D::Pointer TextOverlayPointerType; + typedef TextAnnotation2D::Pointer TextAnnotationPointerType; ContourModelGLMapper2DBase(); virtual ~ContourModelGLMapper2DBase(); void DrawContour(mitk::ContourModel *contour, mitk::BaseRenderer *renderer); - void WriteTextWithOverlay( - TextOverlayPointerType textOverlay, const char *text, float rgb[3], Point2D pt2d, mitk::BaseRenderer *); + void WriteTextWithAnnotation( + TextAnnotationPointerType textAnnotation, const char *text, float rgb[3], Point2D pt2d, mitk::BaseRenderer *); virtual void InternalDrawContour(mitk::ContourModel *renderingContour, mitk::BaseRenderer *renderer); - TextOverlayPointerType m_PointNumbersOverlay; - TextOverlayPointerType m_ControlPointNumbersOverlay; + TextAnnotationPointerType m_PointNumbersAnnotation; + TextAnnotationPointerType m_ControlPointNumbersAnnotation; typedef std::vector RendererListType; RendererListType m_RendererList; }; } // namespace mitk #endif diff --git a/Modules/ContourModel/Rendering/mitkContourModelSetGLMapper2D.cpp b/Modules/ContourModel/Rendering/mitkContourModelSetGLMapper2D.cpp index 5a2ca84385..bb03f3dd64 100644 --- a/Modules/ContourModel/Rendering/mitkContourModelSetGLMapper2D.cpp +++ b/Modules/ContourModel/Rendering/mitkContourModelSetGLMapper2D.cpp @@ -1,389 +1,389 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkContourModelSetGLMapper2D.h" #include "mitkColorProperty.h" #include "mitkContourModelSet.h" #include "mitkPlaneGeometry.h" #include "mitkProperties.h" #include #include "mitkGL.h" mitk::ContourModelSetGLMapper2D::ContourModelSetGLMapper2D() { } mitk::ContourModelSetGLMapper2D::~ContourModelSetGLMapper2D() { } void mitk::ContourModelSetGLMapper2D::Paint(mitk::BaseRenderer *renderer) { BaseLocalStorage *ls = m_LSH.GetLocalStorage(renderer); mitk::DataNode *dataNode = this->GetDataNode(); bool visible = true; dataNode->GetVisibility(visible, renderer, "visible"); if (!visible) return; mitk::ContourModelSet *input = this->GetInput(); mitk::ContourModelSet::ContourModelSetIterator it = input->Begin(); mitk::ContourModelSet::ContourModelSetIterator end = input->End(); while (it != end) { this->DrawContour(it->GetPointer(), renderer); ++it; } if (input->GetSize() < 1) return; ls->UpdateGenerateDataTime(); } mitk::ContourModelSet *mitk::ContourModelSetGLMapper2D::GetInput(void) { return const_cast(static_cast(GetDataNode()->GetData())); } void mitk::ContourModelSetGLMapper2D::InternalDrawContour(mitk::ContourModel *renderingContour, mitk::BaseRenderer *renderer) { if (!renderingContour) return; mitk::DataNode *dataNode = this->GetDataNode(); renderingContour->UpdateOutputInformation(); unsigned int timestep = renderer->GetTimeStep(); if (!renderingContour->IsEmptyTimeStep(timestep)) { // apply color and opacity read from the PropertyList ApplyColorAndOpacityProperties(renderer); mitk::ColorProperty::Pointer colorprop = dynamic_cast(dataNode->GetProperty("contour.color", renderer)); float opacity = 0.5; dataNode->GetFloatProperty("opacity", opacity, renderer); if (colorprop) { // set the color of the contour double red = colorprop->GetColor().GetRed(); double green = colorprop->GetColor().GetGreen(); double blue = colorprop->GetColor().GetBlue(); glColor4f(red, green, blue, opacity); } mitk::ColorProperty::Pointer selectedcolor = dynamic_cast(dataNode->GetProperty("contour.points.color", renderer)); if (!selectedcolor) { selectedcolor = mitk::ColorProperty::New(1.0, 0.0, 0.1); } vtkLinearTransform *transform = dataNode->GetVtkTransform(); // ContourModel::OutputType point; mitk::Point3D point; mitk::Point3D p; float vtkp[3]; float lineWidth = 3.0; bool drawit = false; bool isHovering = false; dataNode->GetBoolProperty("contour.hovering", isHovering); if (isHovering) dataNode->GetFloatProperty("contour.hovering.width", lineWidth); else dataNode->GetFloatProperty("contour.width", lineWidth); bool showSegments = false; dataNode->GetBoolProperty("contour.segments.show", showSegments); bool showControlPoints = false; dataNode->GetBoolProperty("contour.controlpoints.show", showControlPoints); bool showPoints = false; dataNode->GetBoolProperty("contour.points.show", showPoints); bool showPointsNumbers = false; dataNode->GetBoolProperty("contour.points.text", showPointsNumbers); bool showControlPointsNumbers = false; dataNode->GetBoolProperty("contour.controlpoints.text", showControlPointsNumbers); bool projectmode = false; dataNode->GetVisibility(projectmode, renderer, "contour.project-onto-plane"); mitk::ContourModel::VertexIterator pointsIt = renderingContour->IteratorBegin(timestep); Point2D pt2d; // projected_p in display coordinates Point2D lastPt2d; int index = 0; mitk::ScalarType maxDiff = 0.25; while (pointsIt != renderingContour->IteratorEnd(timestep)) { lastPt2d = pt2d; point = (*pointsIt)->Coordinates; itk2vtk(point, vtkp); transform->TransformPoint(vtkp, vtkp); vtk2itk(vtkp, p); renderer->WorldToDisplay(p, pt2d); ScalarType scalardiff = fabs(renderer->GetCurrentWorldPlaneGeometry()->SignedDistance(p)); // project to plane if (projectmode) { drawit = true; } else if (scalardiff < maxDiff) // point is close enough to be drawn { drawit = true; } else { drawit = false; } // draw line if (drawit) { if (showSegments) { // lastPt2d is not valid in first step if (!(pointsIt == renderingContour->IteratorBegin(timestep))) { glLineWidth(lineWidth); glBegin(GL_LINES); glVertex2f(pt2d[0], pt2d[1]); glVertex2f(lastPt2d[0], lastPt2d[1]); glEnd(); glLineWidth(1); } } if (showControlPoints) { // draw ontrol points if ((*pointsIt)->IsControlPoint) { float pointsize = 4; Point2D tmp; Vector2D horz, vert; horz[1] = 0; vert[0] = 0; horz[0] = pointsize; vert[1] = pointsize; glColor3f(selectedcolor->GetColor().GetRed(), selectedcolor->GetColor().GetBlue(), selectedcolor->GetColor().GetGreen()); glLineWidth(1); // a rectangle around the point with the selected color glBegin(GL_LINE_LOOP); tmp = pt2d - horz; glVertex2dv(&tmp[0]); tmp = pt2d + vert; glVertex2dv(&tmp[0]); tmp = pt2d + horz; glVertex2dv(&tmp[0]); tmp = pt2d - vert; glVertex2dv(&tmp[0]); glEnd(); glLineWidth(1); // the actual point in the specified color to see the usual color of the point glColor3f( colorprop->GetColor().GetRed(), colorprop->GetColor().GetGreen(), colorprop->GetColor().GetBlue()); glPointSize(1); glBegin(GL_POINTS); tmp = pt2d; glVertex2dv(&tmp[0]); glEnd(); } } if (showPoints) { float pointsize = 3; Point2D tmp; Vector2D horz, vert; horz[1] = 0; vert[0] = 0; horz[0] = pointsize; vert[1] = pointsize; glColor3f(0.0, 0.0, 0.0); glLineWidth(1); // a rectangle around the point with the selected color glBegin(GL_LINE_LOOP); tmp = pt2d - horz; glVertex2dv(&tmp[0]); tmp = pt2d + vert; glVertex2dv(&tmp[0]); tmp = pt2d + horz; glVertex2dv(&tmp[0]); tmp = pt2d - vert; glVertex2dv(&tmp[0]); glEnd(); glLineWidth(1); // the actual point in the specified color to see the usual color of the point glColor3f(colorprop->GetColor().GetRed(), colorprop->GetColor().GetGreen(), colorprop->GetColor().GetBlue()); glPointSize(1); glBegin(GL_POINTS); tmp = pt2d; glVertex2dv(&tmp[0]); glEnd(); } if (showPointsNumbers) { std::string l; std::stringstream ss; ss << index; l.append(ss.str()); float rgb[3]; rgb[0] = 0.0; rgb[1] = 0.0; rgb[2] = 0.0; - WriteTextWithOverlay(m_PointNumbersOverlay, l.c_str(), rgb, pt2d, renderer); + WriteTextWithAnnotation(m_PointNumbersAnnotation, l.c_str(), rgb, pt2d, renderer); } if (showControlPointsNumbers && (*pointsIt)->IsControlPoint) { std::string l; std::stringstream ss; ss << index; l.append(ss.str()); float rgb[3]; rgb[0] = 1.0; rgb[1] = 1.0; rgb[2] = 0.0; - WriteTextWithOverlay(m_ControlPointNumbersOverlay, l.c_str(), rgb, pt2d, renderer); + WriteTextWithAnnotation(m_ControlPointNumbersAnnotation, l.c_str(), rgb, pt2d, renderer); } index++; } pointsIt++; } // end while iterate over controlpoints // close contour if necessary if (renderingContour->IsClosed(timestep) && drawit && showSegments) { lastPt2d = pt2d; point = renderingContour->GetVertexAt(0, timestep)->Coordinates; itk2vtk(point, vtkp); transform->TransformPoint(vtkp, vtkp); vtk2itk(vtkp, p); renderer->WorldToDisplay(p, pt2d); glLineWidth(lineWidth); glBegin(GL_LINES); glVertex2f(lastPt2d[0], lastPt2d[1]); glVertex2f(pt2d[0], pt2d[1]); glEnd(); glLineWidth(1); } // draw selected vertex if exists if (renderingContour->GetSelectedVertex()) { // transform selected vertex point = renderingContour->GetSelectedVertex()->Coordinates; itk2vtk(point, vtkp); transform->TransformPoint(vtkp, vtkp); vtk2itk(vtkp, p); renderer->WorldToDisplay(p, pt2d); ScalarType scalardiff = fabs(renderer->GetCurrentWorldPlaneGeometry()->SignedDistance(p)); //---------------------------------- // draw point if close to plane if (scalardiff < maxDiff) { float pointsize = 5; Point2D tmp; glColor3f(0.0, 1.0, 0.0); glLineWidth(1); // a diamond around the point glBegin(GL_LINE_LOOP); // begin from upper left corner and paint clockwise tmp[0] = pt2d[0] - pointsize; tmp[1] = pt2d[1] + pointsize; glVertex2dv(&tmp[0]); tmp[0] = pt2d[0] + pointsize; tmp[1] = pt2d[1] + pointsize; glVertex2dv(&tmp[0]); tmp[0] = pt2d[0] + pointsize; tmp[1] = pt2d[1] - pointsize; glVertex2dv(&tmp[0]); tmp[0] = pt2d[0] - pointsize; tmp[1] = pt2d[1] - pointsize; glVertex2dv(&tmp[0]); glEnd(); } //------------------------------------ } } } void mitk::ContourModelSetGLMapper2D::SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite) { node->AddProperty("contour.color", ColorProperty::New(0.9, 1.0, 0.1), renderer, overwrite); node->AddProperty("contour.points.color", ColorProperty::New(1.0, 0.0, 0.1), renderer, overwrite); node->AddProperty("contour.points.show", mitk::BoolProperty::New(false), renderer, overwrite); node->AddProperty("contour.segments.show", mitk::BoolProperty::New(true), renderer, overwrite); node->AddProperty("contour.controlpoints.show", mitk::BoolProperty::New(false), renderer, overwrite); node->AddProperty("contour.width", mitk::FloatProperty::New(1.0), renderer, overwrite); node->AddProperty("contour.hovering.width", mitk::FloatProperty::New(3.0), renderer, overwrite); node->AddProperty("contour.hovering", mitk::BoolProperty::New(false), renderer, overwrite); node->AddProperty("contour.points.text", mitk::BoolProperty::New(false), renderer, overwrite); node->AddProperty("contour.controlpoints.text", mitk::BoolProperty::New(false), renderer, overwrite); node->AddProperty("contour.project-onto-plane", mitk::BoolProperty::New(false), renderer, overwrite); node->AddProperty("opacity", mitk::FloatProperty::New(1.0f), renderer, overwrite); Superclass::SetDefaultProperties(node, renderer, overwrite); } diff --git a/Modules/Core/files.cmake b/Modules/Core/files.cmake index f1940a1653..c8ee1d2186 100644 --- a/Modules/Core/files.cmake +++ b/Modules/Core/files.cmake @@ -1,311 +1,311 @@ file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") set(CPP_FILES mitkCoreActivator.cpp mitkCoreObjectFactoryBase.cpp mitkCoreObjectFactory.cpp mitkCoreServices.cpp mitkException.cpp Algorithms/mitkBaseDataSource.cpp Algorithms/mitkClippedSurfaceBoundsCalculator.cpp Algorithms/mitkCompareImageDataFilter.cpp Algorithms/mitkCompositePixelValueToString.cpp Algorithms/mitkConvert2Dto3DImageFilter.cpp Algorithms/mitkDataNodeSource.cpp Algorithms/mitkExtractSliceFilter.cpp Algorithms/mitkHistogramGenerator.cpp Algorithms/mitkImageChannelSelector.cpp Algorithms/mitkImageSliceSelector.cpp Algorithms/mitkImageSource.cpp Algorithms/mitkImageTimeSelector.cpp Algorithms/mitkImageToImageFilter.cpp Algorithms/mitkImageToSurfaceFilter.cpp Algorithms/mitkMultiComponentImageDataComparisonFilter.cpp Algorithms/mitkPlaneGeometryDataToSurfaceFilter.cpp Algorithms/mitkPointSetSource.cpp Algorithms/mitkPointSetToPointSetFilter.cpp Algorithms/mitkRGBToRGBACastImageFilter.cpp Algorithms/mitkSubImageSelector.cpp Algorithms/mitkSurfaceSource.cpp Algorithms/mitkSurfaceToImageFilter.cpp Algorithms/mitkSurfaceToSurfaceFilter.cpp Algorithms/mitkUIDGenerator.cpp Algorithms/mitkVolumeCalculator.cpp Controllers/mitkBaseController.cpp Controllers/mitkCallbackFromGUIThread.cpp Controllers/mitkCameraController.cpp Controllers/mitkCameraRotationController.cpp Controllers/mitkLimitedLinearUndo.cpp Controllers/mitkOperationEvent.cpp Controllers/mitkPlanePositionManager.cpp Controllers/mitkProgressBar.cpp Controllers/mitkRenderingManager.cpp Controllers/mitkSliceNavigationController.cpp Controllers/mitkSlicesCoordinator.cpp Controllers/mitkStatusBar.cpp Controllers/mitkStepper.cpp Controllers/mitkTestManager.cpp Controllers/mitkUndoController.cpp Controllers/mitkVerboseLimitedLinearUndo.cpp Controllers/mitkVtkLayerController.cpp DataManagement/mitkAnatomicalStructureColorPresets.cpp DataManagement/mitkArbitraryTimeGeometry.cpp DataManagement/mitkAbstractTransformGeometry.cpp DataManagement/mitkAnnotationProperty.cpp DataManagement/mitkApplicationCursor.cpp DataManagement/mitkApplyTransformMatrixOperation.cpp DataManagement/mitkBaseData.cpp DataManagement/mitkBaseGeometry.cpp DataManagement/mitkBaseProperty.cpp DataManagement/mitkChannelDescriptor.cpp DataManagement/mitkClippingProperty.cpp DataManagement/mitkColorProperty.cpp DataManagement/mitkDataNode.cpp DataManagement/mitkDataStorage.cpp DataManagement/mitkEnumerationProperty.cpp DataManagement/mitkFloatPropertyExtension.cpp DataManagement/mitkGeometry3D.cpp DataManagement/mitkGeometryData.cpp DataManagement/mitkGeometryTransformHolder.cpp DataManagement/mitkGroupTagProperty.cpp DataManagement/mitkImageAccessorBase.cpp DataManagement/mitkImageCaster.cpp DataManagement/mitkImageCastPart1.cpp DataManagement/mitkImageCastPart2.cpp DataManagement/mitkImageCastPart3.cpp DataManagement/mitkImageCastPart4.cpp DataManagement/mitkImage.cpp DataManagement/mitkImageDataItem.cpp DataManagement/mitkImageDescriptor.cpp DataManagement/mitkImageReadAccessor.cpp DataManagement/mitkImageStatisticsHolder.cpp DataManagement/mitkImageVtkAccessor.cpp DataManagement/mitkImageVtkReadAccessor.cpp DataManagement/mitkImageVtkWriteAccessor.cpp DataManagement/mitkImageWriteAccessor.cpp DataManagement/mitkIntPropertyExtension.cpp DataManagement/mitkIPersistenceService.cpp DataManagement/mitkIPropertyAliases.cpp DataManagement/mitkIPropertyDescriptions.cpp DataManagement/mitkIPropertyExtensions.cpp DataManagement/mitkIPropertyFilters.cpp DataManagement/mitkIPropertyPersistence.cpp DataManagement/mitkLandmarkProjectorBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjector.cpp DataManagement/mitkLevelWindow.cpp DataManagement/mitkLevelWindowManager.cpp DataManagement/mitkLevelWindowPreset.cpp DataManagement/mitkLevelWindowProperty.cpp DataManagement/mitkLine.cpp DataManagement/mitkLookupTable.cpp DataManagement/mitkLookupTableProperty.cpp DataManagement/mitkLookupTables.cpp # specializations of GenericLookupTable DataManagement/mitkMaterial.cpp DataManagement/mitkMemoryUtilities.cpp DataManagement/mitkModalityProperty.cpp DataManagement/mitkModifiedLock.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp DataManagement/mitkNodePredicateDimension.cpp DataManagement/mitkNodePredicateFirstLevel.cpp DataManagement/mitkNodePredicateNot.cpp DataManagement/mitkNodePredicateOr.cpp DataManagement/mitkNodePredicateProperty.cpp DataManagement/mitkNodePredicateSource.cpp DataManagement/mitkNumericConstants.cpp DataManagement/mitkPlaneGeometry.cpp DataManagement/mitkPlaneGeometryData.cpp DataManagement/mitkPlaneOperation.cpp DataManagement/mitkPlaneOrientationProperty.cpp DataManagement/mitkPointOperation.cpp DataManagement/mitkPointSet.cpp DataManagement/mitkPointSetShapeProperty.cpp DataManagement/mitkProperties.cpp DataManagement/mitkPropertyAliases.cpp DataManagement/mitkPropertyDescriptions.cpp DataManagement/mitkPropertyExtension.cpp DataManagement/mitkPropertyExtensions.cpp DataManagement/mitkPropertyFilter.cpp DataManagement/mitkPropertyFilters.cpp DataManagement/mitkPropertyList.cpp DataManagement/mitkPropertyListReplacedObserver.cpp DataManagement/mitkPropertyNameHelper.cpp DataManagement/mitkPropertyObserver.cpp DataManagement/mitkPropertyPersistence.cpp DataManagement/mitkPropertyPersistenceInfo.cpp DataManagement/mitkProportionalTimeGeometry.cpp DataManagement/mitkRenderingModeProperty.cpp DataManagement/mitkResliceMethodProperty.cpp DataManagement/mitkRestorePlanePositionOperation.cpp DataManagement/mitkRotationOperation.cpp DataManagement/mitkScaleOperation.cpp DataManagement/mitkShaderProperty.cpp DataManagement/mitkSlicedData.cpp DataManagement/mitkSlicedGeometry3D.cpp DataManagement/mitkSmartPointerProperty.cpp DataManagement/mitkStandaloneDataStorage.cpp DataManagement/mitkStringProperty.cpp DataManagement/mitkSurface.cpp DataManagement/mitkSurfaceOperation.cpp DataManagement/mitkThinPlateSplineCurvedGeometry.cpp DataManagement/mitkTimeGeometry.cpp DataManagement/mitkTransferFunction.cpp DataManagement/mitkTransferFunctionInitializer.cpp DataManagement/mitkTransferFunctionProperty.cpp DataManagement/mitkTemporoSpatialStringProperty.cpp DataManagement/mitkVector.cpp DataManagement/mitkVectorProperty.cpp DataManagement/mitkVtkInterpolationProperty.cpp DataManagement/mitkVtkRepresentationProperty.cpp DataManagement/mitkVtkResliceInterpolationProperty.cpp DataManagement/mitkVtkScalarModeProperty.cpp DataManagement/mitkVtkVolumeRenderingProperty.cpp DataManagement/mitkWeakPointerProperty.cpp Interactions/mitkAction.cpp Interactions/mitkBindDispatcherInteractor.cpp Interactions/mitkCrosshairPositionEvent.cpp Interactions/mitkDataInteractor.cpp Interactions/mitkDispatcher.cpp Interactions/mitkDisplayCoordinateOperation.cpp Interactions/mitkDisplayInteractor.cpp Interactions/mitkEventConfig.cpp Interactions/mitkEventFactory.cpp Interactions/mitkEventRecorder.cpp Interactions/mitkEventStateMachine.cpp Interactions/mitkInteractionEventConst.cpp Interactions/mitkInteractionEvent.cpp Interactions/mitkInteractionEventHandler.cpp Interactions/mitkInteractionEventObserver.cpp Interactions/mitkInteractionKeyEvent.cpp Interactions/mitkInteractionPositionEvent.cpp Interactions/mitkInternalEvent.cpp Interactions/mitkMouseDoubleClickEvent.cpp Interactions/mitkMouseModeSwitcher.cpp Interactions/mitkMouseMoveEvent.cpp Interactions/mitkMousePressEvent.cpp Interactions/mitkMouseReleaseEvent.cpp Interactions/mitkMouseWheelEvent.cpp Interactions/mitkPointSetDataInteractor.cpp Interactions/mitkSinglePointDataInteractor.cpp Interactions/mitkStateMachineAction.cpp Interactions/mitkStateMachineCondition.cpp Interactions/mitkStateMachineContainer.cpp Interactions/mitkStateMachineState.cpp Interactions/mitkStateMachineTransition.cpp Interactions/mitkVtkEventAdapter.cpp Interactions/mitkVtkInteractorStyle.cxx Interactions/mitkXML2EventParser.cpp IO/mitkAbstractFileIO.cpp IO/mitkAbstractFileReader.cpp IO/mitkAbstractFileWriter.cpp IO/mitkCustomMimeType.cpp IO/mitkDicomSeriesReader.cpp IO/mitkDicomSeriesReaderService.cpp IO/mitkDicomSR_GantryTiltInformation.cpp IO/mitkDicomSR_ImageBlockDescriptor.cpp IO/mitkDicomSR_LoadDICOMRGBPixel4D.cpp IO/mitkDicomSR_LoadDICOMRGBPixel.cpp IO/mitkDicomSR_LoadDICOMScalar4D.cpp IO/mitkDicomSR_LoadDICOMScalar.cpp IO/mitkDicomSR_SliceGroupingResult.cpp IO/mitkFileReader.cpp IO/mitkFileReaderRegistry.cpp IO/mitkFileReaderSelector.cpp IO/mitkFileReaderWriterBase.cpp IO/mitkFileWriter.cpp IO/mitkFileWriterRegistry.cpp IO/mitkFileWriterSelector.cpp IO/mitkGeometry3DToXML.cpp IO/mitkIFileIO.cpp IO/mitkIFileReader.cpp IO/mitkIFileWriter.cpp IO/mitkGeometryDataReaderService.cpp IO/mitkGeometryDataWriterService.cpp IO/mitkImageGenerator.cpp IO/mitkImageVtkLegacyIO.cpp IO/mitkImageVtkXmlIO.cpp IO/mitkIMimeTypeProvider.cpp IO/mitkIOConstants.cpp IO/mitkIOMimeTypes.cpp IO/mitkIOUtil.cpp IO/mitkItkImageIO.cpp IO/mitkItkLoggingAdapter.cpp IO/mitkLegacyFileReaderService.cpp IO/mitkLegacyFileWriterService.cpp IO/mitkLocaleSwitch.cpp IO/mitkLog.cpp IO/mitkMimeType.cpp IO/mitkMimeTypeProvider.cpp IO/mitkOperation.cpp IO/mitkPixelType.cpp IO/mitkPointSetReaderService.cpp IO/mitkPointSetWriterService.cpp IO/mitkProportionalTimeGeometryToXML.cpp IO/mitkRawImageFileReader.cpp IO/mitkStandardFileLocations.cpp IO/mitkSurfaceStlIO.cpp IO/mitkSurfaceVtkIO.cpp IO/mitkSurfaceVtkLegacyIO.cpp IO/mitkSurfaceVtkXmlIO.cpp IO/mitkVtkLoggingAdapter.cpp Rendering/mitkAbstractAnnotationRenderer.cpp - Rendering/mitkAnnotationService.cpp + Rendering/mitkAnnotationUtils.cpp Rendering/mitkBaseRenderer.cpp #Rendering/mitkGLMapper.cpp Moved to deprecated LegacyGL Module Rendering/mitkGradientBackground.cpp Rendering/mitkImageVtkMapper2D.cpp Rendering/mitkIShaderRepository.cpp Rendering/mitkMapper.cpp - Rendering/mitkOverlay.cpp + Rendering/mitkAnnotation.cpp Rendering/mitkPlaneGeometryDataMapper2D.cpp Rendering/mitkPlaneGeometryDataVtkMapper3D.cpp Rendering/mitkPointSetVtkMapper2D.cpp Rendering/mitkPointSetVtkMapper3D.cpp Rendering/mitkRenderWindowBase.cpp Rendering/mitkRenderWindow.cpp Rendering/mitkRenderWindowFrame.cpp #Rendering/mitkSurfaceGLMapper2D.cpp Moved to deprecated LegacyGL Module Rendering/mitkSurfaceVtkMapper2D.cpp Rendering/mitkSurfaceVtkMapper3D.cpp Rendering/mitkVtkEventProvider.cpp Rendering/mitkVtkMapper.cpp Rendering/mitkVtkPropRenderer.cpp Rendering/mitkVtkWidgetRendering.cpp Rendering/vtkMitkLevelWindowFilter.cpp Rendering/vtkMitkRectangleProp.cpp Rendering/vtkMitkRenderProp.cpp Rendering/vtkMitkThickSlicesFilter.cpp Rendering/vtkNeverTranslucentTexture.cpp ) set(RESOURCE_FILES Interactions/globalConfig.xml Interactions/DisplayInteraction.xml Interactions/DisplayConfig.xml Interactions/DisplayConfigPACS.xml Interactions/DisplayConfigPACSPan.xml Interactions/DisplayConfigPACSScroll.xml Interactions/DisplayConfigPACSZoom.xml Interactions/DisplayConfigPACSLevelWindow.xml Interactions/DisplayConfigMITK.xml Interactions/DisplayConfigMITKNoCrosshair.xml Interactions/DisplayConfigMITKRotation.xml Interactions/DisplayConfigMITKRotationUnCoupled.xml Interactions/DisplayConfigMITKSwivel.xml Interactions/DisplayConfigMITKLimited.xml Interactions/PointSet.xml Interactions/Legacy/StateMachine.xml Interactions/Legacy/DisplayConfigMITKTools.xml Interactions/PointSetConfig.xml mitkLevelWindowPresets.xml mitkAnatomicalStructureColorPresets.xml ) diff --git a/Modules/Core/include/mitkAbstractAnnotationRenderer.h b/Modules/Core/include/mitkAbstractAnnotationRenderer.h index a448cd4707..c6fd0ee76d 100644 --- a/Modules/Core/include/mitkAbstractAnnotationRenderer.h +++ b/Modules/Core/include/mitkAbstractAnnotationRenderer.h @@ -1,88 +1,88 @@ /*=================================================================== * The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef ABSTRACTANNOTATIONRENDERER_H #define ABSTRACTANNOTATIONRENDERER_H -#include "mitkOverlay.h" +#include "mitkAnnotation.h" #include "mitkServiceInterface.h" #include "usGetModuleContext.h" #include "usServiceTracker.h" #include #include namespace mitk { class BaseRenderer; - /** @brief Baseclass of Overlay layouters */ + /** @brief Baseclass of Annotation layouters */ /** - *A AbstractAnnotationRenderer can be implemented to control a set of Overlays by means of position and size. + *A AbstractAnnotationRenderer can be implemented to control a set of Annotation by means of position and size. *AbstractAnnotationRenderer::PrepareLayout() should be implemented with a routine to set the position of the internal - *m_ManagedOverlays List. + *m_ManagedAnnotation List. *A layouter is always connected to one BaseRenderer, so there is one instance of the layouter for each BaseRenderer. *One type of layouter should always have a unique identifier. - *@ingroup Overlays + *@ingroup Annotation */ - class MITKCORE_EXPORT AbstractAnnotationRenderer : public us::ServiceTracker + class MITKCORE_EXPORT AbstractAnnotationRenderer : public us::ServiceTracker { public: - typedef us::ServiceTracker Superclass; + typedef us::ServiceTracker Superclass; AbstractAnnotationRenderer(const std::string &rendererID, const std::string &arID); /** \brief virtual destructor in order to derive from this class */ virtual ~AbstractAnnotationRenderer(); const std::string GetID() const; const std::string GetRendererID() const; void CurrentBaseRendererChanged(); virtual void OnRenderWindowModified() {} - void RemoveAllOverlays(); + void RemoveAllAnnotation(); void Update(); static const std::string US_INTERFACE_NAME; static const std::string US_PROPKEY_ID; static const std::string US_PROPKEY_RENDERER_ID; protected: BaseRenderer *GetCurrentBaseRenderer(); private: /** \brief copy constructor */ AbstractAnnotationRenderer(const AbstractAnnotationRenderer &); /** \brief assignment operator */ AbstractAnnotationRenderer &operator=(const AbstractAnnotationRenderer &); TrackedType AddingService(const ServiceReferenceType &reference) override; void ModifiedService(const ServiceReferenceType & /*reference*/, TrackedType tracked) override; void RemovedService(const ServiceReferenceType & /*reference*/, TrackedType tracked) override; virtual void OnAnnotationRenderersChanged() {} const std::string m_RendererID; const std::string m_ID; }; } // namespace mitk MITK_DECLARE_SERVICE_INTERFACE(mitk::AbstractAnnotationRenderer, "org.mitk.services.AbstractAnnotationRenderer") #endif // ABSTRACTANNOTATIONRENDERER_H diff --git a/Modules/Core/include/mitkOverlay.h b/Modules/Core/include/mitkAnnotation.h similarity index 88% rename from Modules/Core/include/mitkOverlay.h rename to Modules/Core/include/mitkAnnotation.h index 865a679d4d..d0415a0e4d 100644 --- a/Modules/Core/include/mitkOverlay.h +++ b/Modules/Core/include/mitkAnnotation.h @@ -1,470 +1,470 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef OVERLAY_H -#define OVERLAY_H +#ifndef Annotation_H +#define Annotation_H #include "mitkServiceInterface.h" #include "usServiceRegistration.h" #include #include #include namespace mitk { - class AbstractOverlayLayouter; + class AbstractAnnotationLayouter; - /** \brief Base class for all overlays */ - /** This class is to be implemented in order to create overlays which are managed by the OverlayManager and can be - placed by a AbstractOverlayLayouter. + /** \brief Base class for all Annotation */ + /** This class is to be implemented in order to create Annotation which are managed by the AnnotationManager and can be + placed by a AbstractAnnotationLayouter. This class contains an internal Propertylist, and another PropertyList for each BaseRenderer. A property that is specified for a specific renderer always overrides the general internal property of the same name. - AddOverlay, RemoveOverlay and UpdateOverlay methods have to be implemented.*/ - class MITKCORE_EXPORT Overlay : public itk::Object + AddAnnotation, RemoveAnnotation and UpdateAnnotation methods have to be implemented.*/ + class MITKCORE_EXPORT Annotation : public itk::Object { - friend class AbstractOverlayLayouter; + friend class AbstractAnnotationLayouter; public: /** \brief Container for position and size on the display.*/ struct Bounds { itk::Point Position; itk::Point Size; }; /** \brief Base class for mapper specific rendering ressources. */ class MITKCORE_EXPORT BaseLocalStorage { public: - bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Overlay *overlay); + bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Annotation *Annotation); inline void UpdateGenerateDataTime() { m_LastGenerateDataTime.Modified(); } inline itk::TimeStamp &GetLastGenerateDataTime() { return m_LastGenerateDataTime; } protected: /** \brief timestamp of last update of stored data */ itk::TimeStamp m_LastGenerateDataTime; }; /** * @brief Set the property (instance of BaseProperty) with key @a propertyKey in the PropertyList * of the @a renderer (if NULL, use BaseRenderer-independent PropertyList). This is set-by-value. * * @warning Change in semantics since Aug 25th 2006. Check your usage of this method if you do * more with properties than just call SetProperty( "key", new SomeProperty("value") ). * * @sa GetProperty * @sa m_PropertyList * @sa m_MapOfPropertyLists */ void SetProperty(const std::string &propertyKey, const BaseProperty::Pointer &property); /** * @brief Replace the property (instance of BaseProperty) with key @a propertyKey in the PropertyList * of the @a renderer (if NULL, use BaseRenderer-independent PropertyList). This is set-by-reference. * * If @a renderer is @a NULL the property is set in the BaseRenderer-independent - * PropertyList of this Overlay. + * PropertyList of this Annotation. * @sa GetProperty * @sa m_PropertyList * @sa m_MapOfPropertyLists */ void ReplaceProperty(const std::string &propertyKey, const BaseProperty::Pointer &property); /** * @brief Add the property (instance of BaseProperty) if it does * not exist (or always if \a overwrite is \a true) * with key @a propertyKey in the PropertyList * of the @a renderer (if NULL, use BaseRenderer-independent * PropertyList). This is set-by-value. * * For \a overwrite == \a false the property is \em not changed * if it already exists. For \a overwrite == \a true the method * is identical to SetProperty. * * @sa SetProperty * @sa GetProperty * @sa m_PropertyList * @sa m_MapOfPropertyLists */ void AddProperty(const std::string &propertyKey, const BaseProperty::Pointer &property, bool overwrite = false); /** * @brief Add values from another PropertyList. * * Overwrites values in m_PropertyList only when possible (i.e. when types are compatible). * If you want to allow for object type changes (replacing a "visible":BoolProperty with "visible":IntProperty, * set the @param replace. * * @param replace true: if @param pList contains a property "visible" of type ColorProperty and our m_PropertyList * also has a "visible" property of a different type (e.g. BoolProperty), change the type, i.e. replace the objects * behind the pointer. * * @sa SetProperty * @sa ReplaceProperty * @sa m_PropertyList */ void ConcatenatePropertyList(PropertyList *pList, bool replace = false); /** * @brief Get the property (instance of BaseProperty) with key @a propertyKey from the PropertyList * of the @a renderer, if available there, otherwise use the BaseRenderer-independent PropertyList. * * If @a renderer is @a NULL or the @a propertyKey cannot be found * in the PropertyList specific to @a renderer or is disabled there, the BaseRenderer-independent - * PropertyList of this Overlay is queried. + * PropertyList of this Annotation is queried. * @sa GetPropertyList * @sa m_PropertyList * @sa m_MapOfPropertyLists */ mitk::BaseProperty *GetProperty(const std::string &propertyKey) const; /** * @brief Get the property of type T with key @a propertyKey from the PropertyList * of the @a renderer, if available there, otherwise use the BaseRenderer-independent PropertyList. * * If @a renderer is @a NULL or the @a propertyKey cannot be found * in the PropertyList specific to @a renderer or is disabled there, the BaseRenderer-independent - * PropertyList of this Overlay is queried. + * PropertyList of this Annotation is queried. * @sa GetPropertyList * @sa m_PropertyList * @sa m_MapOfPropertyLists */ template bool GetProperty(itk::SmartPointer &property, const std::string &propertyKey) const { property = dynamic_cast(GetProperty(propertyKey)); return property.IsNotNull(); } /** * @brief Get the property of type T with key @a propertyKey from the PropertyList * of the @a renderer, if available there, otherwise use the BaseRenderer-independent PropertyList. * * If @a renderer is @a NULL or the @a propertyKey cannot be found * in the PropertyList specific to @a renderer or is disabled there, the BaseRenderer-independent - * PropertyList of this Overlay is queried. + * PropertyList of this Annotation is queried. * @sa GetPropertyList * @sa m_PropertyList * @sa m_MapOfPropertyLists */ template bool GetProperty(T *&property, const std::string &propertyKey) const { property = dynamic_cast(GetProperty(propertyKey)); return property != nullptr; } /** * @brief Convenience access method for GenericProperty properties * (T being the type of the second parameter) * @return @a true property was found */ template bool GetPropertyValue(const std::string &propertyKey, T &value) const { GenericProperty *gp = dynamic_cast *>(GetProperty(propertyKey)); if (gp != nullptr) { value = gp->GetValue(); return true; } return false; } /** * @brief Convenience access method for bool properties (instances of * BoolProperty) * @return @a true property was found */ bool GetBoolProperty(const std::string &propertyKey, bool &boolValue) const; /** * @brief Convenience access method for int properties (instances of * IntProperty) * @return @a true property was found */ bool GetIntProperty(const std::string &propertyKey, int &intValue) const; /** * @brief Convenience access method for float properties (instances of * FloatProperty) * @return @a true property was found */ bool GetFloatProperty(const std::string &propertyKey, float &floatValue) const; /** * @brief Convenience access method for double properties (instances of * DoubleProperty) * @return @a true property was found */ bool GetDoubleProperty(const std::string &propertyKey, double &doubleValue) const; /** * @brief Convenience access method for string properties (instances of * StringProperty) * @return @a true property was found */ bool GetStringProperty(const std::string &propertyKey, std::string &string) const; /** * @brief Convenience method for setting int properties (instances of * IntProperty) */ void SetIntProperty(const std::string &propertyKey, int intValue); /** * @brief Convenience method for setting int properties (instances of * IntProperty) */ void SetBoolProperty(const std::string &propertyKey, bool boolValue); /** * @brief Convenience method for setting int properties (instances of * IntProperty) */ void SetFloatProperty(const std::string &propertyKey, float floatValue); /** * @brief Convenience method for setting int properties (instances of * IntProperty) */ void SetDoubleProperty(const std::string &propertyKey, double doubleValue); /** * @brief Convenience method for setting int properties (instances of * IntProperty) */ void SetStringProperty(const std::string &propertyKey, const std::string &string); /** * @brief Convenience access method for boolean properties (instances * of BoolProperty). Return value is the value of the property. If the property is * not found, the value of @a defaultIsOn is returned. * * Thus, the return value has a different meaning than in the * GetBoolProperty method! * @sa GetBoolProperty */ bool IsOn(const std::string &propertyKey, bool defaultIsOn = true) const { GetBoolProperty(propertyKey, defaultIsOn); return defaultIsOn; } /** * @brief Convenience access method for accessing the name of an object (instance of * StringProperty with property-key "name") * @return @a true property was found */ bool GetName(std::string &nodeName, const std::string &propertyKey = "name") const; /** * @brief Extra convenience access method for accessing the name of an object (instance of * StringProperty with property-key "name"). * * This method does not take the renderer specific * propertylists into account, because the name of an object should never be renderer specific. * @returns a std::string with the name of the object (content of "name" Property). * If there is no "name" Property, an empty string will be returned. */ virtual std::string GetName() const; /** * @brief Extra convenience access method to set the name of an object. * * The name will be stored in the non-renderer-specific PropertyList in a StringProperty named "name". */ virtual void SetName(const std::string &name); /** * @brief Convenience access method for color properties (instances of * ColorProperty) * @return @a true property was found */ bool GetColor(float rgb[], const std::string &propertyKey = "color") const; /** * @brief Convenience method for setting color properties (instances of * ColorProperty) */ void SetColor(const mitk::Color &color, const std::string &propertyKey = "color"); /** * @brief Convenience method for setting color properties (instances of * ColorProperty) */ void SetColor(float red, float green, float blue, const std::string &propertyKey = "color"); /** * @brief Convenience method for setting color properties (instances of * ColorProperty) */ void SetColor(const float rgb[], const std::string &propertyKey = "color"); /** * @brief Convenience access method for opacity properties (instances of * FloatProperty) * @return @a true property was found */ bool GetOpacity(float &opacity, const std::string &propertyKey = "opacity") const; /** * @brief Convenience method for setting opacity properties (instances of * FloatProperty) */ void SetOpacity(float opacity, const std::string &propertyKey = "opacity"); void SetText(std::string text); std::string GetText() const; void SetFontSize(int fontSize); int GetFontSize() const; /** * @brief Convenience access method for visibility properties (instances * of BoolProperty with property-key "visible") * @return @a true property was found * @sa IsVisible */ bool GetVisibility(bool &visible, const std::string &propertyKey = "visible") const; /** * @brief Convenience access method for visibility properties (instances * of BoolProperty). Return value is the visibility. Default is * visible==true, i.e., true is returned even if the property (@a * propertyKey) is not found. * * Thus, the return value has a different meaning than in the * GetVisibility method! * @sa GetVisibility * @sa IsOn */ bool IsVisible(const std::string &propertyKey = "visible", bool defaultIsOn = true) const; /** * @brief Convenience method for setting visibility properties (instances * of BoolProperty) * @param visible If set to true, the data will be rendered. If false, the render will skip this data. * @param renderer Specify a renderer if the visibility shall be specific to a renderer * @param propertykey Can be used to specify a user defined name of the visibility propery. */ void SetVisibility(bool visible, const std::string &propertyKey = "visible"); - /** \brief Adds the overlay to the specified renderer. Update Overlay should be called soon in order to apply all + /** \brief Adds the Annotation to the specified renderer. Update Annotation should be called soon in order to apply all * properties*/ virtual void AddToBaseRenderer(BaseRenderer *renderer) = 0; - /** \brief Adds the overlay to the specified renderer. Update Overlay should be called soon in order to apply all + /** \brief Adds the Annotation to the specified renderer. Update Annotation should be called soon in order to apply all * properties*/ virtual void AddToRenderer(BaseRenderer *renderer, vtkRenderer *vtkrenderer) = 0; - /** \brief Removes the overlay from the specified renderer. It is not visible anymore then.*/ + /** \brief Removes the Annotation from the specified renderer. It is not visible anymore then.*/ virtual void RemoveFromBaseRenderer(BaseRenderer *renderer) = 0; - /** \brief Removes the overlay from the specified renderer. It is not visible anymore then.*/ + /** \brief Removes the Annotation from the specified renderer. It is not visible anymore then.*/ virtual void RemoveFromRenderer(BaseRenderer *renderer, vtkRenderer *vtkrenderer) = 0; /** \brief Applies all properties and should be called before the rendering procedure.*/ virtual void Update(BaseRenderer *renderer) = 0; - /** \brief Returns position and size of the overlay on the display.*/ + /** \brief Returns position and size of the Annotation on the display.*/ virtual Bounds GetBoundsOnDisplay(BaseRenderer *renderer) const; - /** \brief Sets position and size of the overlay on the display.*/ + /** \brief Sets position and size of the Annotation on the display.*/ virtual void SetBoundsOnDisplay(BaseRenderer *renderer, const Bounds &); void SetForceInForeground(bool forceForeground); bool IsForceInForeground() const; PropertyList *GetPropertyList() const; /** *\brief Returns the id that this device is registered with. The id will only be valid, if the - * Overlay has been registered using RegisterAsMicroservice(). + * Annotation has been registered using RegisterAsMicroservice(). */ std::string GetMicroserviceID(); /** *\brief These Constants are used in conjunction with Microservices */ static const std::string US_INTERFACE_NAME; - static const std::string US_PROPKEY_OVERLAYNAME; + static const std::string US_PROPKEY_AnnotationNAME; static const std::string US_PROPKEY_ID; static const std::string US_PROPKEY_MODIFIED; static const std::string US_PROPKEY_RENDERER_ID; static const std::string US_PROPKEY_AR_ID; /** *\brief Registers this object as a Microservice, making it available to every module and/or plugin. * To unregister, call UnregisterMicroservice(). */ virtual void RegisterAsMicroservice(us::ServiceProperties props); /** *\brief Registers this object as a Microservice, making it available to every module and/or plugin. */ virtual void UnRegisterMicroservice(); - void OverlayModified(); + void AnnotationModified(); - mitkClassMacroItkParent(Overlay, itk::Object); + mitkClassMacroItkParent(Annotation, itk::Object); protected: /** \brief explicit constructor which disallows implicit conversions */ - Overlay(); + Annotation(); /** \brief virtual destructor in order to derive from this class */ - virtual ~Overlay(); + virtual ~Annotation(); /** * @brief BaseRenderer-independent PropertyList * * Properties herein can be overwritten specifically for each BaseRenderer * by the BaseRenderer-specific properties defined in m_MapOfPropertyLists. */ PropertyList::Pointer m_PropertyList; /** * @brief Timestamp of the last change of m_Data */ itk::TimeStamp m_DataReferenceChangedTime; void SetUSProperty(const std::string &propertyKey, us::Any value); private: - /** \brief render this overlay on a foreground renderer */ + /** \brief render this Annotation on a foreground renderer */ bool m_ForceInForeground; /** \brief copy constructor */ - Overlay(const Overlay &); + Annotation(const Annotation &); /** \brief assignment operator */ - Overlay &operator=(const Overlay &); + Annotation &operator=(const Annotation &); - /** \brief Reference to the layouter in which this overlay is managed. */ - AbstractOverlayLayouter *m_LayoutedBy; + /** \brief Reference to the layouter in which this Annotation is managed. */ + AbstractAnnotationLayouter *m_LayoutedBy; private: us::ServiceRegistration m_ServiceRegistration; unsigned long m_PropertyListModifiedObserverTag; void PropertyListModified(const itk::Object *, const itk::EventObject &); }; } // namespace mitk -MITK_DECLARE_SERVICE_INTERFACE(mitk::Overlay, "org.mitk.services.Overlay") +MITK_DECLARE_SERVICE_INTERFACE(mitk::Annotation, "org.mitk.services.Annotation") -#endif // OVERLAY_H +#endif // Annotation_H diff --git a/Modules/Core/include/mitkAnnotationService.h b/Modules/Core/include/mitkAnnotationUtils.h similarity index 79% rename from Modules/Core/include/mitkAnnotationService.h rename to Modules/Core/include/mitkAnnotationUtils.h index ff765d313c..9024138a09 100644 --- a/Modules/Core/include/mitkAnnotationService.h +++ b/Modules/Core/include/mitkAnnotationUtils.h @@ -1,60 +1,60 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef mitkAnnotationService_h -#define mitkAnnotationService_h +#ifndef mitkAnnotationUtils_h +#define mitkAnnotationUtils_h #include #include #include class vtkObject; namespace mitk { class AbstractAnnotationRenderer; - class Overlay; + class Annotation; class BaseRenderer; - class MITKCORE_EXPORT AnnotationService + class MITKCORE_EXPORT AnnotationUtils { public: typedef std::vector> AnnotationRendererServices; - AnnotationService(); - ~AnnotationService(); + AnnotationUtils(); + ~AnnotationUtils(); static AbstractAnnotationRenderer *GetAnnotationRenderer(const std::string &arTypeID, const std::string &rendererID); static void RegisterAnnotationRenderer(AbstractAnnotationRenderer *annotationRenderer); static std::vector GetAnnotationRenderer(const std::string &rendererID); static void UpdateAnnotationRenderer(const std::string &rendererID); static void BaseRendererChanged(BaseRenderer *renderer); - static mitk::Overlay *GetOverlay(const std::string &overlayID); + static mitk::Annotation *GetAnnotation(const std::string &AnnotationID); private: - AnnotationService(const AnnotationService &); - AnnotationService &operator=(const AnnotationService &); + AnnotationUtils(const AnnotationUtils &); + AnnotationUtils &operator=(const AnnotationUtils &); static void RenderWindowCallback(vtkObject *caller, unsigned long, void *, void *); }; } #endif diff --git a/Modules/Core/src/Rendering/mitkAbstractAnnotationRenderer.cpp b/Modules/Core/src/Rendering/mitkAbstractAnnotationRenderer.cpp index c6977d05ac..abc7b46d2d 100644 --- a/Modules/Core/src/Rendering/mitkAbstractAnnotationRenderer.cpp +++ b/Modules/Core/src/Rendering/mitkAbstractAnnotationRenderer.cpp @@ -1,111 +1,111 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkAbstractAnnotationRenderer.h" #include "mitkBaseRenderer.h" #include "mitkRenderingManager.h" #include "usGetModuleContext.h" #include namespace mitk { const std::string AbstractAnnotationRenderer::US_INTERFACE_NAME = "org.mitk.services.AbstractAnnotationRenderer"; const std::string AbstractAnnotationRenderer::US_PROPKEY_ID = US_INTERFACE_NAME + ".id"; const std::string AbstractAnnotationRenderer::US_PROPKEY_RENDERER_ID = US_INTERFACE_NAME + ".rendererId"; AbstractAnnotationRenderer::AbstractAnnotationRenderer(const std::string &rendererID, const std::string &arID) : Superclass(us::GetModuleContext(), - us::LDAPFilter("(&(" + Overlay::US_PROPKEY_RENDERER_ID + "=" + rendererID + ")(" + - Overlay::US_PROPKEY_AR_ID + "=" + arID + "))")), + us::LDAPFilter("(&(" + Annotation::US_PROPKEY_RENDERER_ID + "=" + rendererID + ")(" + + Annotation::US_PROPKEY_AR_ID + "=" + arID + "))")), m_RendererID(rendererID), m_ID(arID) { this->Open(); } AbstractAnnotationRenderer::~AbstractAnnotationRenderer() {} const std::string AbstractAnnotationRenderer::GetRendererID() const { return m_RendererID; } void AbstractAnnotationRenderer::CurrentBaseRendererChanged() { BaseRenderer *renderer = GetCurrentBaseRenderer(); if (renderer) { - for (Overlay *o : this->GetServices()) + for (Annotation *o : this->GetServices()) { o->AddToBaseRenderer(renderer); } } } - void AbstractAnnotationRenderer::RemoveAllOverlays() + void AbstractAnnotationRenderer::RemoveAllAnnotation() { BaseRenderer *renderer = GetCurrentBaseRenderer(); if (renderer) { - for (Overlay *o : this->GetServices()) + for (Annotation *o : this->GetServices()) { o->RemoveFromBaseRenderer(renderer); } } } void AbstractAnnotationRenderer::Update() { BaseRenderer *renderer = GetCurrentBaseRenderer(); if (renderer) { - for (Overlay *o : this->GetServices()) + for (Annotation *o : this->GetServices()) { o->Update(renderer); } } } const std::string AbstractAnnotationRenderer::GetID() const { return m_ID; } AbstractAnnotationRenderer::TrackedType AbstractAnnotationRenderer::AddingService( const AbstractAnnotationRenderer::ServiceReferenceType &reference) { - Overlay *overlay = Superclass::AddingService(reference); + Annotation *Annotation = Superclass::AddingService(reference); BaseRenderer *renderer = GetCurrentBaseRenderer(); - if (overlay && renderer) + if (Annotation && renderer) { - overlay->AddToBaseRenderer(renderer); + Annotation->AddToBaseRenderer(renderer); } // OnAnnotationRenderersChanged(); - return overlay; + return Annotation; } void AbstractAnnotationRenderer::ModifiedService(const AbstractAnnotationRenderer::ServiceReferenceType &, AbstractAnnotationRenderer::TrackedType tracked) { BaseRenderer *renderer = GetCurrentBaseRenderer(); if (tracked && renderer) { tracked->Update(renderer); } OnAnnotationRenderersChanged(); } void AbstractAnnotationRenderer::RemovedService(const AbstractAnnotationRenderer::ServiceReferenceType &, AbstractAnnotationRenderer::TrackedType /*tracked*/) { OnAnnotationRenderersChanged(); } BaseRenderer *AbstractAnnotationRenderer::GetCurrentBaseRenderer() { return BaseRenderer::GetByName(this->GetRendererID()); } } diff --git a/Modules/Core/src/Rendering/mitkOverlay.cpp b/Modules/Core/src/Rendering/mitkAnnotation.cpp similarity index 58% rename from Modules/Core/src/Rendering/mitkOverlay.cpp rename to Modules/Core/src/Rendering/mitkAnnotation.cpp index 445a8b14a2..a05287025f 100644 --- a/Modules/Core/src/Rendering/mitkOverlay.cpp +++ b/Modules/Core/src/Rendering/mitkAnnotation.cpp @@ -1,350 +1,350 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkOverlay.h" +#include "mitkAnnotation.h" #include "usGetModuleContext.h" -const std::string mitk::Overlay::US_INTERFACE_NAME = "org.mitk.services.Overlay"; -const std::string mitk::Overlay::US_PROPKEY_OVERLAYNAME = US_INTERFACE_NAME + ".name"; -const std::string mitk::Overlay::US_PROPKEY_ID = US_INTERFACE_NAME + ".id"; -const std::string mitk::Overlay::US_PROPKEY_MODIFIED = US_INTERFACE_NAME + ".modified"; -const std::string mitk::Overlay::US_PROPKEY_RENDERER_ID = US_INTERFACE_NAME + ".rendererId"; -const std::string mitk::Overlay::US_PROPKEY_AR_ID = US_INTERFACE_NAME + ".arId"; +const std::string mitk::Annotation::US_INTERFACE_NAME = "org.mitk.services.Annotation"; +const std::string mitk::Annotation::US_PROPKEY_AnnotationNAME = US_INTERFACE_NAME + ".name"; +const std::string mitk::Annotation::US_PROPKEY_ID = US_INTERFACE_NAME + ".id"; +const std::string mitk::Annotation::US_PROPKEY_MODIFIED = US_INTERFACE_NAME + ".modified"; +const std::string mitk::Annotation::US_PROPKEY_RENDERER_ID = US_INTERFACE_NAME + ".rendererId"; +const std::string mitk::Annotation::US_PROPKEY_AR_ID = US_INTERFACE_NAME + ".arId"; -mitk::Overlay::Overlay() : m_LayoutedBy(nullptr), m_PropertyListModifiedObserverTag(0) +mitk::Annotation::Annotation() : m_LayoutedBy(nullptr), m_PropertyListModifiedObserverTag(0) { m_PropertyList = mitk::PropertyList::New(); - itk::MemberCommand::Pointer _PropertyListModifiedCommand = itk::MemberCommand::New(); - _PropertyListModifiedCommand->SetCallbackFunction(this, &mitk::Overlay::PropertyListModified); + itk::MemberCommand::Pointer _PropertyListModifiedCommand = itk::MemberCommand::New(); + _PropertyListModifiedCommand->SetCallbackFunction(this, &mitk::Annotation::PropertyListModified); m_PropertyListModifiedObserverTag = m_PropertyList->AddObserver(itk::ModifiedEvent(), _PropertyListModifiedCommand); this->SetName(this->GetNameOfClass()); this->SetVisibility(true); this->SetOpacity(1.0); } -void mitk::Overlay::PropertyListModified(const itk::Object * /*caller*/, const itk::EventObject &) +void mitk::Annotation::PropertyListModified(const itk::Object * /*caller*/, const itk::EventObject &) { - OverlayModified(); + AnnotationModified(); } -mitk::Overlay::~Overlay() +mitk::Annotation::~Annotation() { this->UnRegisterMicroservice(); } -void mitk::Overlay::SetUSProperty(const std::string &propertyKey, us::Any value) +void mitk::Annotation::SetUSProperty(const std::string &propertyKey, us::Any value) { if (this->m_ServiceRegistration) { us::ServiceProperties props; std::vector propertyKeys; m_ServiceRegistration.GetReference().GetPropertyKeys(propertyKeys); for (std::string key : propertyKeys) { props[key] = m_ServiceRegistration.GetReference().GetProperty(key); } props[propertyKey] = value; m_ServiceRegistration.SetProperties(props); } } -void mitk::Overlay::SetProperty(const std::string &propertyKey, const BaseProperty::Pointer &propertyValue) +void mitk::Annotation::SetProperty(const std::string &propertyKey, const BaseProperty::Pointer &propertyValue) { this->m_PropertyList->SetProperty(propertyKey, propertyValue); } -void mitk::Overlay::ReplaceProperty(const std::string &propertyKey, const BaseProperty::Pointer &propertyValue) +void mitk::Annotation::ReplaceProperty(const std::string &propertyKey, const BaseProperty::Pointer &propertyValue) { this->m_PropertyList->ReplaceProperty(propertyKey, propertyValue); } -void mitk::Overlay::AddProperty(const std::string &propertyKey, +void mitk::Annotation::AddProperty(const std::string &propertyKey, const BaseProperty::Pointer &propertyValue, bool overwrite) { if ((overwrite) || (GetProperty(propertyKey) == NULL)) { SetProperty(propertyKey, propertyValue); } } -void mitk::Overlay::ConcatenatePropertyList(PropertyList *pList, bool replace) +void mitk::Annotation::ConcatenatePropertyList(PropertyList *pList, bool replace) { m_PropertyList->ConcatenatePropertyList(pList, replace); } -mitk::BaseProperty *mitk::Overlay::GetProperty(const std::string &propertyKey) const +mitk::BaseProperty *mitk::Annotation::GetProperty(const std::string &propertyKey) const { mitk::BaseProperty::Pointer property = m_PropertyList->GetProperty(propertyKey); if (property.IsNotNull()) return property; // only to satisfy compiler! return NULL; } -bool mitk::Overlay::GetBoolProperty(const std::string &propertyKey, bool &boolValue) const +bool mitk::Annotation::GetBoolProperty(const std::string &propertyKey, bool &boolValue) const { mitk::BoolProperty::Pointer boolprop = dynamic_cast(GetProperty(propertyKey)); if (boolprop.IsNull()) return false; boolValue = boolprop->GetValue(); return true; } -bool mitk::Overlay::GetIntProperty(const std::string &propertyKey, int &intValue) const +bool mitk::Annotation::GetIntProperty(const std::string &propertyKey, int &intValue) const { mitk::IntProperty::Pointer intprop = dynamic_cast(GetProperty(propertyKey)); if (intprop.IsNull()) return false; intValue = intprop->GetValue(); return true; } -bool mitk::Overlay::GetFloatProperty(const std::string &propertyKey, float &floatValue) const +bool mitk::Annotation::GetFloatProperty(const std::string &propertyKey, float &floatValue) const { mitk::FloatProperty::Pointer floatprop = dynamic_cast(GetProperty(propertyKey)); if (floatprop.IsNull()) return false; floatValue = floatprop->GetValue(); return true; } -bool mitk::Overlay::GetStringProperty(const std::string &propertyKey, std::string &string) const +bool mitk::Annotation::GetStringProperty(const std::string &propertyKey, std::string &string) const { mitk::StringProperty::Pointer stringProp = dynamic_cast(GetProperty(propertyKey)); if (stringProp.IsNull()) { return false; } else { // memcpy((void*)string, stringProp->GetValue(), strlen(stringProp->GetValue()) + 1 ); // looks dangerous string = stringProp->GetValue(); return true; } } -void mitk::Overlay::SetIntProperty(const std::string &propertyKey, int intValue) +void mitk::Annotation::SetIntProperty(const std::string &propertyKey, int intValue) { this->m_PropertyList->SetProperty(propertyKey, mitk::IntProperty::New(intValue)); Modified(); } -void mitk::Overlay::SetBoolProperty(const std::string &propertyKey, bool boolValue) +void mitk::Annotation::SetBoolProperty(const std::string &propertyKey, bool boolValue) { this->m_PropertyList->SetProperty(propertyKey, mitk::BoolProperty::New(boolValue)); Modified(); } -void mitk::Overlay::SetFloatProperty(const std::string &propertyKey, float floatValue) +void mitk::Annotation::SetFloatProperty(const std::string &propertyKey, float floatValue) { this->m_PropertyList->SetProperty(propertyKey, mitk::FloatProperty::New(floatValue)); Modified(); } -void mitk::Overlay::SetDoubleProperty(const std::string &propertyKey, double doubleValue) +void mitk::Annotation::SetDoubleProperty(const std::string &propertyKey, double doubleValue) { this->m_PropertyList->SetProperty(propertyKey, mitk::DoubleProperty::New(doubleValue)); Modified(); } -void mitk::Overlay::SetStringProperty(const std::string &propertyKey, const std::string &stringValue) +void mitk::Annotation::SetStringProperty(const std::string &propertyKey, const std::string &stringValue) { this->m_PropertyList->SetProperty(propertyKey, mitk::StringProperty::New(stringValue)); Modified(); } -std::string mitk::Overlay::GetName() const +std::string mitk::Annotation::GetName() const { mitk::StringProperty *sp = dynamic_cast(this->GetProperty("name")); if (sp == NULL) return ""; return sp->GetValue(); } -void mitk::Overlay::SetName(const std::string &name) +void mitk::Annotation::SetName(const std::string &name) { this->SetStringProperty("name", name); } -bool mitk::Overlay::GetName(std::string &nodeName, const std::string &propertyKey) const +bool mitk::Annotation::GetName(std::string &nodeName, const std::string &propertyKey) const { return GetStringProperty(propertyKey, nodeName); } -void mitk::Overlay::SetText(std::string text) +void mitk::Annotation::SetText(std::string text) { SetStringProperty("Text", text.c_str()); } -std::string mitk::Overlay::GetText() const +std::string mitk::Annotation::GetText() const { std::string text; GetStringProperty("Text", text); return text; } -void mitk::Overlay::SetFontSize(int fontSize) +void mitk::Annotation::SetFontSize(int fontSize) { SetIntProperty("FontSize", fontSize); } -int mitk::Overlay::GetFontSize() const +int mitk::Annotation::GetFontSize() const { int fontSize = 1; GetIntProperty("FontSize", fontSize); return fontSize; } -bool mitk::Overlay::GetVisibility(bool &visible, const std::string &propertyKey) const +bool mitk::Annotation::GetVisibility(bool &visible, const std::string &propertyKey) const { return GetBoolProperty(propertyKey, visible); } -bool mitk::Overlay::IsVisible(const std::string &propertyKey, bool defaultIsOn) const +bool mitk::Annotation::IsVisible(const std::string &propertyKey, bool defaultIsOn) const { return IsOn(propertyKey, defaultIsOn); } -bool mitk::Overlay::GetColor(float rgb[], const std::string &propertyKey) const +bool mitk::Annotation::GetColor(float rgb[], const std::string &propertyKey) const { mitk::ColorProperty::Pointer colorprop = dynamic_cast(GetProperty(propertyKey)); if (colorprop.IsNull()) return false; memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3 * sizeof(float)); return true; } -void mitk::Overlay::SetColor(const mitk::Color &color, const std::string &propertyKey) +void mitk::Annotation::SetColor(const mitk::Color &color, const std::string &propertyKey) { mitk::ColorProperty::Pointer prop; prop = mitk::ColorProperty::New(color); this->m_PropertyList->SetProperty(propertyKey, prop); } -void mitk::Overlay::SetColor(float red, float green, float blue, const std::string &propertyKey) +void mitk::Annotation::SetColor(float red, float green, float blue, const std::string &propertyKey) { float color[3]; color[0] = red; color[1] = green; color[2] = blue; SetColor(color, propertyKey); } -void mitk::Overlay::SetColor(const float rgb[], const std::string &propertyKey) +void mitk::Annotation::SetColor(const float rgb[], const std::string &propertyKey) { mitk::ColorProperty::Pointer prop; prop = mitk::ColorProperty::New(rgb); this->m_PropertyList->SetProperty(propertyKey, prop); } -bool mitk::Overlay::GetOpacity(float &opacity, const std::string &propertyKey) const +bool mitk::Annotation::GetOpacity(float &opacity, const std::string &propertyKey) const { mitk::FloatProperty::Pointer opacityprop = dynamic_cast(GetProperty(propertyKey)); if (opacityprop.IsNull()) return false; opacity = opacityprop->GetValue(); return true; } -void mitk::Overlay::SetOpacity(float opacity, const std::string &propertyKey) +void mitk::Annotation::SetOpacity(float opacity, const std::string &propertyKey) { mitk::FloatProperty::Pointer prop; prop = mitk::FloatProperty::New(opacity); this->m_PropertyList->SetProperty(propertyKey, prop); } -void mitk::Overlay::SetVisibility(bool visible, const std::string &propertyKey) +void mitk::Annotation::SetVisibility(bool visible, const std::string &propertyKey) { mitk::BoolProperty::Pointer prop; prop = mitk::BoolProperty::New(visible); this->m_PropertyList->SetProperty(propertyKey, prop); Modified(); } -bool mitk::Overlay::BaseLocalStorage::IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Overlay *overlay) +bool mitk::Annotation::BaseLocalStorage::IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Annotation *Annotation) { - if (m_LastGenerateDataTime < overlay->GetMTime()) + if (m_LastGenerateDataTime < Annotation->GetMTime()) return true; - if (m_LastGenerateDataTime < overlay->GetPropertyList()->GetMTime()) + if (m_LastGenerateDataTime < Annotation->GetPropertyList()->GetMTime()) return true; if (renderer && m_LastGenerateDataTime < renderer->GetTimeStepUpdateTime()) return true; return false; } -mitk::Overlay::Bounds mitk::Overlay::GetBoundsOnDisplay(mitk::BaseRenderer *) const +mitk::Annotation::Bounds mitk::Annotation::GetBoundsOnDisplay(mitk::BaseRenderer *) const { - mitk::Overlay::Bounds bounds; + mitk::Annotation::Bounds bounds; bounds.Position[0] = bounds.Position[1] = bounds.Size[0] = bounds.Size[1] = 0; return bounds; } -void mitk::Overlay::SetBoundsOnDisplay(mitk::BaseRenderer *, const mitk::Overlay::Bounds &) +void mitk::Annotation::SetBoundsOnDisplay(mitk::BaseRenderer *, const mitk::Annotation::Bounds &) { } -void mitk::Overlay::SetForceInForeground(bool forceForeground) +void mitk::Annotation::SetForceInForeground(bool forceForeground) { m_ForceInForeground = forceForeground; } -bool mitk::Overlay::IsForceInForeground() const +bool mitk::Annotation::IsForceInForeground() const { return m_ForceInForeground; } -mitk::PropertyList *mitk::Overlay::GetPropertyList() const +mitk::PropertyList *mitk::Annotation::GetPropertyList() const { return m_PropertyList; } -std::string mitk::Overlay::GetMicroserviceID() +std::string mitk::Annotation::GetMicroserviceID() { return this->m_ServiceRegistration.GetReference().GetProperty(US_PROPKEY_ID).ToString(); } -void mitk::Overlay::RegisterAsMicroservice(us::ServiceProperties props) +void mitk::Annotation::RegisterAsMicroservice(us::ServiceProperties props) { if (m_ServiceRegistration != NULL) m_ServiceRegistration.Unregister(); us::ModuleContext *context = us::GetModuleContext(); // Define ServiceProps - mitk::UIDGenerator uidGen = mitk::UIDGenerator("org.mitk.services.Overlay.id_", 16); + mitk::UIDGenerator uidGen = mitk::UIDGenerator("org.mitk.services.Annotation.id_", 16); props[US_PROPKEY_ID] = uidGen.GetUID(); m_ServiceRegistration = context->RegisterService(this, props); } -void mitk::Overlay::UnRegisterMicroservice() +void mitk::Annotation::UnRegisterMicroservice() { if (m_ServiceRegistration != NULL) m_ServiceRegistration.Unregister(); m_ServiceRegistration = 0; } -void mitk::Overlay::OverlayModified() +void mitk::Annotation::AnnotationModified() { Modified(); this->SetUSProperty(US_PROPKEY_MODIFIED, this->GetMTime()); } diff --git a/Modules/Core/src/Rendering/mitkAnnotationService.cpp b/Modules/Core/src/Rendering/mitkAnnotationUtils.cpp similarity index 74% rename from Modules/Core/src/Rendering/mitkAnnotationService.cpp rename to Modules/Core/src/Rendering/mitkAnnotationUtils.cpp index 0479494b5f..ef21056540 100644 --- a/Modules/Core/src/Rendering/mitkAnnotationService.cpp +++ b/Modules/Core/src/Rendering/mitkAnnotationUtils.cpp @@ -1,126 +1,126 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkAnnotationService.h" -#include "mitkOverlay.h" +#include "mitkAnnotationUtils.h" +#include "mitkAnnotation.h" #include "vtkCallbackCommand.h" #include "vtkCommand.h" #include namespace mitk { - AnnotationService::AnnotationService() {} - AnnotationService::~AnnotationService() {} - AbstractAnnotationRenderer *AnnotationService::GetAnnotationRenderer(const std::string &arTypeID, - const std::string &rendererID) + AnnotationUtils::AnnotationUtils() {} + AnnotationUtils::~AnnotationUtils() {} + AbstractAnnotationRenderer *AnnotationUtils::GetAnnotationRenderer(const std::string &arTypeID, + const std::string &rendererID) { // get the context us::ModuleContext *context = us::GetModuleContext(); // specify a filter that defines the requested type std::string filter = "(&(" + AbstractAnnotationRenderer::US_PROPKEY_ID + "=" + arTypeID + ")(" + AbstractAnnotationRenderer::US_PROPKEY_RENDERER_ID + "=" + rendererID + "))"; // find the fitting service std::vector serviceReferences = context->GetServiceReferences(AbstractAnnotationRenderer::US_INTERFACE_NAME, filter); // check if a service reference was found. It is also possible that several // services were found. This is not checked here, just the first one is taken. AbstractAnnotationRenderer *ar = nullptr; if (serviceReferences.size()) { ar = context->GetService(serviceReferences.front()); } // no service reference was found or found service reference has no valid source return ar; } - void AnnotationService::RegisterAnnotationRenderer(AbstractAnnotationRenderer *annotationRenderer) + void AnnotationUtils::RegisterAnnotationRenderer(AbstractAnnotationRenderer *annotationRenderer) { static AnnotationRendererServices AnnotationRendererServices; // Define ServiceProps us::ServiceProperties props; props[AbstractAnnotationRenderer::US_PROPKEY_RENDERER_ID] = annotationRenderer->GetRendererID(); props[AbstractAnnotationRenderer::US_PROPKEY_ID] = annotationRenderer->GetID(); us::GetModuleContext()->RegisterService(annotationRenderer, props); AnnotationRendererServices.push_back(std::unique_ptr(annotationRenderer)); } - void AnnotationService::UpdateAnnotationRenderer(const std::string &rendererID) + void AnnotationUtils::UpdateAnnotationRenderer(const std::string &rendererID) { for (AbstractAnnotationRenderer *annotationRenderer : GetAnnotationRenderer(rendererID)) { annotationRenderer->Update(); } } - void AnnotationService::BaseRendererChanged(BaseRenderer *renderer) + void AnnotationUtils::BaseRendererChanged(BaseRenderer *renderer) { for (AbstractAnnotationRenderer *annotationRenderer : GetAnnotationRenderer(renderer->GetName())) { annotationRenderer->CurrentBaseRendererChanged(); } vtkCallbackCommand *renderCallbackCommand = vtkCallbackCommand::New(); - renderCallbackCommand->SetCallback(AnnotationService::RenderWindowCallback); + renderCallbackCommand->SetCallback(AnnotationUtils::RenderWindowCallback); renderer->GetRenderWindow()->AddObserver(vtkCommand::ModifiedEvent, renderCallbackCommand); renderCallbackCommand->Delete(); } - void AnnotationService::RenderWindowCallback(vtkObject *caller, unsigned long, void *, void *) + void AnnotationUtils::RenderWindowCallback(vtkObject *caller, unsigned long, void *, void *) { vtkRenderWindow *renderWindow = dynamic_cast(caller); if (!renderWindow) return; BaseRenderer *renderer = BaseRenderer::GetInstance(renderWindow); for (AbstractAnnotationRenderer *annotationRenderer : GetAnnotationRenderer(renderer->GetName())) { annotationRenderer->OnRenderWindowModified(); } } - Overlay *AnnotationService::GetOverlay(const std::string &overlayID) + Annotation *AnnotationUtils::GetAnnotation(const std::string &AnnotationID) { - std::string ldapFilter = "(" + Overlay::US_PROPKEY_ID + "=" + overlayID + ")"; + std::string ldapFilter = "(" + Annotation::US_PROPKEY_ID + "=" + AnnotationID + ")"; us::ModuleContext *context = us::GetModuleContext(); - std::vector> overlays = - context->GetServiceReferences(ldapFilter); - Overlay *overlay = nullptr; - if (!overlays.empty()) + std::vector> annotations = + context->GetServiceReferences(ldapFilter); + Annotation *annotation = nullptr; + if (!annotations.empty()) { - overlay = us::GetModuleContext()->GetService(overlays.front()); + annotation = us::GetModuleContext()->GetService(annotations.front()); } - return overlay; + return annotation; } - std::vector AnnotationService::GetAnnotationRenderer(const std::string &rendererID) + std::vector AnnotationUtils::GetAnnotationRenderer(const std::string &rendererID) { us::ModuleContext *context = us::GetModuleContext(); // specify a filter that defines the requested type std::string filter = "(&(" + AbstractAnnotationRenderer::US_PROPKEY_ID + "=*)(" + AbstractAnnotationRenderer::US_PROPKEY_RENDERER_ID + "=" + rendererID + "))"; // find the fitting service std::vector serviceReferences = context->GetServiceReferences(AbstractAnnotationRenderer::US_INTERFACE_NAME, filter); std::vector arList; for (us::ServiceReferenceU service : serviceReferences) { arList.push_back(context->GetService(service)); } return arList; } } diff --git a/Modules/Core/src/Rendering/mitkRenderWindowBase.cpp b/Modules/Core/src/Rendering/mitkRenderWindowBase.cpp index fdc4f18d0f..2b7750ceb1 100644 --- a/Modules/Core/src/Rendering/mitkRenderWindowBase.cpp +++ b/Modules/Core/src/Rendering/mitkRenderWindowBase.cpp @@ -1,121 +1,121 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkRenderWindowBase.h" #include "mitkRenderingManager.h" #include "mitkVtkLayerController.h" #include "vtkRenderer.h" -#include "mitkAnnotationService.h" +#include "mitkAnnotationUtils.h" mitk::RenderWindowBase::RenderWindowBase() : m_RenderProp(NULL), m_InResize(false) { } /* * "Member functions, including virtual functions (10.3), can be called during construction or destruction (12.6.2). When a * virtual function is called directly or indirectly from a constructor (including from the mem-initializer for a data member) or from * a destructor, and the object to which the call applies is the object under construction or destruction, the function called is * the one defined in the constructor or destructor's own class or in one of its bases, but not a function overriding it in a class * derived from the constructor or destructor's class, or overriding it in one of the other base classes of the most derived object[..]" * or short: within constructors and destructors classes are not polymorph. */ void mitk::RenderWindowBase::Initialize(mitk::RenderingManager *renderingManager, const char *name, mitk::BaseRenderer::RenderingMode::Type renderingMode) { if (renderingManager == NULL) { renderingManager = mitk::RenderingManager::GetInstance(); } if (m_Renderer.IsNull()) { m_Renderer = mitk::VtkPropRenderer::New(name, GetVtkRenderWindow(), renderingManager, renderingMode); } m_Renderer->InitRenderer(this->GetVtkRenderWindow()); mitk::BaseRenderer::AddInstance(GetVtkRenderWindow(), m_Renderer); renderingManager->AddRenderWindow(GetVtkRenderWindow()); // Add previously created overlays to new BaseRenderer - mitk::AnnotationService::BaseRendererChanged(m_Renderer); + mitk::AnnotationUtils::BaseRendererChanged(m_Renderer); m_RenderProp = vtkMitkRenderProp::New(); m_RenderProp->SetPropRenderer(m_Renderer); m_Renderer->GetVtkRenderer()->AddViewProp(m_RenderProp); if ((this->GetVtkRenderWindow()->GetSize()[0] > 10) && (this->GetVtkRenderWindow()->GetSize()[1] > 10)) m_Renderer->InitSize(this->GetVtkRenderWindow()->GetSize()[0], this->GetVtkRenderWindow()->GetSize()[1]); m_InResize = false; } bool mitk::RenderWindowBase::HandleEvent(InteractionEvent *interactionEvent) { return m_Renderer->GetDispatcher()->ProcessEvent(interactionEvent); } void mitk::RenderWindowBase::Destroy() { m_Renderer->GetRenderingManager()->RemoveRenderWindow(GetVtkRenderWindow()); mitk::BaseRenderer::RemoveInstance(GetVtkRenderWindow()); m_Renderer->GetVtkRenderer()->RemoveViewProp(m_RenderProp); m_RenderProp->Delete(); } mitk::RenderWindowBase::~RenderWindowBase() { } mitk::SliceNavigationController *mitk::RenderWindowBase::GetSliceNavigationController() { return mitk::BaseRenderer::GetInstance(this->GetVtkRenderWindow())->GetSliceNavigationController(); } mitk::CameraRotationController *mitk::RenderWindowBase::GetCameraRotationController() { return mitk::BaseRenderer::GetInstance(this->GetVtkRenderWindow())->GetCameraRotationController(); } mitk::BaseController *mitk::RenderWindowBase::GetController() { mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(GetVtkRenderWindow()); switch (renderer->GetMapperID()) { case mitk::BaseRenderer::Standard2D: return GetSliceNavigationController(); case mitk::BaseRenderer::Standard3D: return GetCameraRotationController(); default: return GetSliceNavigationController(); } } mitk::VtkPropRenderer *mitk::RenderWindowBase::GetRenderer() { return m_Renderer; } diff --git a/Modules/ModuleList.cmake b/Modules/ModuleList.cmake index 282fbb5391..f3ff10e1a9 100644 --- a/Modules/ModuleList.cmake +++ b/Modules/ModuleList.cmake @@ -1,81 +1,81 @@ # The entries in the mitk_modules list must be # ordered according to their dependencies. set(mitk_modules Core CommandLine AppUtil DCMTesting RDF LegacyIO DataTypesExt - Overlays + Annotation LegacyGL AlgorithmsExt MapperExt DICOMReader DICOMReaderServices DICOMTesting SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction ImageStatistics LegacyAdaptors SceneSerialization Gizmo GraphAlgorithms Multilabel ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation OpenViewCore QtWidgets QtWidgetsExt QtWidgetsWeb QmlItems SegmentationUI DiffusionImaging GPGPU OpenIGTLink IGTBase IGT CameraCalibration RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport QtOverlays ToFHardware ToFProcessing ToFUI US USUI DicomUI Simulation Remeshing Python QtPython Persistence OpenIGTLinkUI IGTUI VtkShaders DicomRT RTUI IOExt XNAT TubeGraph BiophotonicsHardware Classification TumorInvasionAnalysis MatchPointRegistration MatchPointRegistrationUI BoundingShape ) if(MITK_ENABLE_PIC_READER) list(APPEND mitk_modules IpPicSupportIO) endif() diff --git a/Modules/Overlays/files.cmake b/Modules/Overlays/files.cmake deleted file mode 100644 index baea1fef1f..0000000000 --- a/Modules/Overlays/files.cmake +++ /dev/null @@ -1,17 +0,0 @@ -file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") - -set(CPP_FILES - mitkAnnotationPlacer.cpp - mitkColorBarOverlay.cpp - mitkLabelOverlay3D.cpp - mitkLogoOverlay.cpp - mitkOverlayLayouter2D.cpp - mitkScaleLegendOverlay.cpp - mitkTextOverlay2D.cpp - mitkTextOverlay3D.cpp - mitkVtkLogoRepresentation.cxx - mitkVtkOverlay.cpp - mitkVtkOverlay2D.cpp - mitkVtkOverlay3D.cpp -) - diff --git a/Modules/Overlays/include/mitkAnnotationPlacer.h b/Modules/Overlays/include/mitkAnnotationPlacer.h deleted file mode 100644 index 21f0c2354a..0000000000 --- a/Modules/Overlays/include/mitkAnnotationPlacer.h +++ /dev/null @@ -1,53 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef ANNOTATIONPLACER_H -#define ANNOTATIONPLACER_H - -#include "MitkOverlaysExports.h" -#include "mitkAbstractAnnotationRenderer.h" -#include "mitkOverlay.h" - -namespace mitk -{ - class BaseRenderer; - - /** \brief The AnnotationPlacer updates and manages Overlays and the respective Layouters. */ - /** An Instance of the AnnotationPlacer can be registered to several BaseRenderer instances in order to - * call the update method of each Overlay during the rendering phase of the renderer. - * See \ref OverlaysPage for more info. - */ - class MITKOVERLAYS_EXPORT AnnotationPlacer : public AbstractAnnotationRenderer - { - public: - /** \brief virtual destructor in order to derive from this class */ - virtual ~AnnotationPlacer(); - - static AnnotationPlacer *GetAnnotationRenderer(const std::string &rendererID); - - static void AddOverlay(Overlay *overlay, const std::string &rendererID); - - static void AddOverlay(Overlay *overlay, BaseRenderer *renderer); - - private: - AnnotationPlacer(const std::string &rendererId); - - static const std::string ANNOTATIONRENDERER_ID; - }; - -} // namespace mitk - -#endif // ANNOTATIONPLACER_H diff --git a/Modules/Overlays/include/mitkOverlayLayouter2D.h b/Modules/Overlays/include/mitkOverlayLayouter2D.h deleted file mode 100644 index cc37fdf752..0000000000 --- a/Modules/Overlays/include/mitkOverlayLayouter2D.h +++ /dev/null @@ -1,103 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef OVERLAYLAYOUTER2D_H -#define OVERLAYLAYOUTER2D_H - -#include "MitkOverlaysExports.h" -#include "mitkAbstractAnnotationRenderer.h" - -namespace mitk -{ - class BaseRenderer; - - /** \brief The OverlayLayouter2D updates and manages Overlays and the respective Layouters. */ - /** An Instance of the OverlayLayouter2D can be registered to several BaseRenderer instances in order to - * call the update method of each Overlay during the rendering phase of the renderer. - * See \ref OverlaysPage for more info. - */ - class MITKOVERLAYS_EXPORT OverlayLayouter2D : public AbstractAnnotationRenderer - { - public: - static const std::string PROP_LAYOUT; - static const std::string PROP_LAYOUT_PRIORITY; - static const std::string PROP_LAYOUT_ALIGNMENT; - static const std::string PROP_LAYOUT_MARGIN; - enum Alignment - { - TopLeft, - Top, - TopRight, - BottomLeft, - Bottom, - BottomRight, - Left, - Right - }; - typedef std::multimap OverlayRankedMap; - typedef std::map OverlayLayouterContainerMap; - - /** \brief virtual destructor in order to derive from this class */ - virtual ~OverlayLayouter2D(); - - const std::string GetID() const; - - static OverlayLayouter2D *GetAnnotationRenderer(const std::string &rendererID); - - void OnRenderWindowModified(); - - static void AddOverlay(Overlay *overlay, - const std::string &rendererID, - Alignment alignment = TopLeft, - double marginX = 5, - double marginY = 5, - int priority = -1); - - static void AddOverlay(Overlay *overlay, - BaseRenderer *renderer, - Alignment alignment = TopLeft, - double marginX = 5, - double marginY = 5, - int priority = -1); - - void PrepareLayout(); - - private: - OverlayLayouter2D(const std::string &rendererId); - - static void AddAlignmentProperty(Overlay *overlay, Alignment activeAlignment, Point2D margin, int priority); - - void PrepareTopLeftLayout(int *displaySize); - void PrepareTopLayout(int *displaySize); - void PrepareTopRightLayout(int *displaySize); - void PrepareBottomLeftLayout(int *displaySize); - void PrepareBottomLayout(int *displaySize); - void PrepareBottomRightLayout(int *displaySize); - void PrepareLeftLayout(int *displaySize); - void PrepareRightLayout(int *displaySize); - - static double GetHeight(OverlayRankedMap &overlays, BaseRenderer *renderer); - - virtual void OnAnnotationRenderersChanged(); - static const std::string ANNOTATIONRENDERER_ID; - OverlayLayouterContainerMap m_OverlayContainerMap; - static void SetMargin2D(Overlay *overlay, const Point2D &OffsetVector); - static Point2D GetMargin2D(Overlay *overlay); - }; - -} // namespace mitk - -#endif // OVERLAYLAYOUTER2D_H diff --git a/Modules/Overlays/src/mitkAnnotationPlacer.cpp b/Modules/Overlays/src/mitkAnnotationPlacer.cpp deleted file mode 100644 index 4b71a1299d..0000000000 --- a/Modules/Overlays/src/mitkAnnotationPlacer.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkAnnotationPlacer.h" -#include "mitkBaseRenderer.h" - -#include "mitkAnnotationService.h" -#include - -namespace mitk -{ - const std::string AnnotationPlacer::ANNOTATIONRENDERER_ID = "AnnotationPlacer"; - - AnnotationPlacer::AnnotationPlacer(const std::string &rendererId) - : AbstractAnnotationRenderer(rendererId, AnnotationPlacer::ANNOTATIONRENDERER_ID) - { - } - AnnotationPlacer::~AnnotationPlacer() {} - AnnotationPlacer *AnnotationPlacer::GetAnnotationRenderer(const std::string &rendererID) - { - AnnotationPlacer *result = nullptr; - AbstractAnnotationRenderer *registeredService = - AnnotationService::GetAnnotationRenderer(ANNOTATIONRENDERER_ID, rendererID); - if (registeredService) - result = dynamic_cast(registeredService); - if (!result) - { - result = new AnnotationPlacer(rendererID); - AnnotationService::RegisterAnnotationRenderer(result); - } - return result; - } - - void AnnotationPlacer::AddOverlay(Overlay *overlay, const std::string &rendererID) - { - GetAnnotationRenderer(rendererID); // rename ?? - us::ServiceProperties props; - props[Overlay::US_PROPKEY_AR_ID] = ANNOTATIONRENDERER_ID; - props[Overlay::US_PROPKEY_RENDERER_ID] = rendererID; - overlay->RegisterAsMicroservice(props); - } - - void AnnotationPlacer::AddOverlay(Overlay *overlay, BaseRenderer *renderer) - { - AddOverlay(overlay, renderer->GetName()); - } -} diff --git a/Modules/Overlays/src/mitkOverlayLayouter2D.cpp b/Modules/Overlays/src/mitkOverlayLayouter2D.cpp deleted file mode 100644 index a8e311e6c4..0000000000 --- a/Modules/Overlays/src/mitkOverlayLayouter2D.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkOverlayLayouter2D.h" -#include "mitkBaseRenderer.h" - -#include "mitkAnnotationService.h" -#include "mitkEnumerationProperty.h" -#include - -namespace mitk -{ - const std::string OverlayLayouter2D::ANNOTATIONRENDERER_ID = "OverlayLayouter2D"; - - const std::string OverlayLayouter2D::PROP_LAYOUT = "Layout"; - const std::string OverlayLayouter2D::PROP_LAYOUT_PRIORITY = PROP_LAYOUT + ".priority"; - const std::string OverlayLayouter2D::PROP_LAYOUT_ALIGNMENT = PROP_LAYOUT + ".alignment"; - const std::string OverlayLayouter2D::PROP_LAYOUT_MARGIN = PROP_LAYOUT + ".margin"; - - void OverlayLayouter2D::SetMargin2D(Overlay *overlay, const Point2D &OffsetVector) - { - mitk::Point2dProperty::Pointer OffsetVectorProperty = mitk::Point2dProperty::New(OffsetVector); - overlay->SetProperty(PROP_LAYOUT_MARGIN, OffsetVectorProperty.GetPointer()); - } - - Point2D OverlayLayouter2D::GetMargin2D(Overlay *overlay) - { - mitk::Point2D OffsetVector; - OffsetVector.Fill(0); - overlay->GetPropertyValue(PROP_LAYOUT_MARGIN, OffsetVector); - return OffsetVector; - } - - OverlayLayouter2D::OverlayLayouter2D(const std::string &rendererId) - : AbstractAnnotationRenderer(rendererId, OverlayLayouter2D::ANNOTATIONRENDERER_ID) - { - } - - void OverlayLayouter2D::AddAlignmentProperty(Overlay *overlay, - Alignment activeAlignment, - Point2D margin, - int priority) - { - EnumerationProperty::Pointer alignmentProperty(mitk::EnumerationProperty::New()); - alignmentProperty->AddEnum("TopLeft", TopLeft); - alignmentProperty->AddEnum("Top", Top); - alignmentProperty->AddEnum("TopRight", TopRight); - alignmentProperty->AddEnum("BottomLeft ", BottomLeft); - alignmentProperty->AddEnum("Bottom", Bottom); - alignmentProperty->AddEnum("BottomRight", BottomRight); - alignmentProperty->AddEnum("Left", Left); - alignmentProperty->AddEnum("Right", Right); - alignmentProperty->SetValue(activeAlignment); - overlay->AddProperty(PROP_LAYOUT_ALIGNMENT, alignmentProperty.GetPointer()); - overlay->SetIntProperty(PROP_LAYOUT_PRIORITY, priority); - SetMargin2D(overlay, margin); - } - - void OverlayLayouter2D::OnAnnotationRenderersChanged() - { - if (!this->GetCurrentBaseRenderer()) - return; - m_OverlayContainerMap.clear(); - for (Overlay *overlay : this->GetServices()) - { - if (!overlay) - continue; - BaseProperty *prop = overlay->GetProperty(PROP_LAYOUT_ALIGNMENT); - EnumerationProperty *enumProb = dynamic_cast(prop); - Alignment currentAlignment = TopLeft; - Point2D margin; - margin.Fill(5); - int priority = -1; - overlay->GetIntProperty(PROP_LAYOUT_PRIORITY, priority); - if (!enumProb) - { - AddAlignmentProperty(overlay, currentAlignment, margin, priority); - } - else - { // TODO19786 insert - currentAlignment = static_cast(enumProb->GetValueAsId()); - } - OverlayRankedMap &overlayVec = m_OverlayContainerMap[currentAlignment]; - if (!overlayVec.empty() && priority < 0) - { - int max = overlayVec.rbegin()->first; - if (max < 100) - priority = 100; - else - priority = max + 1; - } - overlayVec.insert(std::pair(priority, overlay)); - } - this->PrepareLayout(); - } - - OverlayLayouter2D::~OverlayLayouter2D() {} - const std::string OverlayLayouter2D::GetID() const { return ANNOTATIONRENDERER_ID; } - OverlayLayouter2D *OverlayLayouter2D::GetAnnotationRenderer(const std::string &rendererID) - { - OverlayLayouter2D *result = nullptr; - AbstractAnnotationRenderer *registeredService = - AnnotationService::GetAnnotationRenderer(ANNOTATIONRENDERER_ID, rendererID); - if (registeredService) - result = dynamic_cast(registeredService); - if (!result) - { - result = new OverlayLayouter2D(rendererID); - AnnotationService::RegisterAnnotationRenderer(result); - } - return result; - } - - void OverlayLayouter2D::OnRenderWindowModified() { PrepareLayout(); } - void OverlayLayouter2D::AddOverlay( - Overlay *overlay, const std::string &rendererID, Alignment alignment, double marginX, double marginY, int priority) - { - GetAnnotationRenderer(rendererID); - us::ServiceProperties props; - props[Overlay::US_PROPKEY_AR_ID] = ANNOTATIONRENDERER_ID; - props[Overlay::US_PROPKEY_RENDERER_ID] = rendererID; - overlay->RegisterAsMicroservice(props); - Point2D margin; - margin[0] = marginX; - margin[1] = marginY; - AddAlignmentProperty(overlay, alignment, margin, priority); - } - - void OverlayLayouter2D::AddOverlay( - Overlay *overlay, BaseRenderer *renderer, Alignment alignment, double marginX, double marginY, int priority) - { - AddOverlay(overlay, renderer->GetName(), alignment, marginX, marginY, priority); - } - - void OverlayLayouter2D::PrepareLayout() - { - if (!this->GetCurrentBaseRenderer()) - return; - int *size = this->GetCurrentBaseRenderer()->GetVtkRenderer()->GetSize(); - PrepareTopLeftLayout(size); - PrepareTopLayout(size); - PrepareTopRightLayout(size); - PrepareBottomLeftLayout(size); - PrepareBottomLayout(size); - PrepareBottomRightLayout(size); - PrepareLeftLayout(size); - PrepareRightLayout(size); - } - void OverlayLayouter2D::PrepareTopLeftLayout(int *displaySize) - { - double posX, posY; - Point2D margin; - posX = 0; - posY = displaySize[1]; - mitk::Overlay::Bounds bounds; - OverlayRankedMap &overlayMap = m_OverlayContainerMap[TopLeft]; - for (auto it = overlayMap.cbegin(); it != overlayMap.cend(); ++it) - { - Overlay *overlay = it->second; - margin = GetMargin2D(overlay); - bounds = overlay->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); - - posY -= bounds.Size[1] + margin[1]; - bounds.Position[0] = posX + margin[0]; - bounds.Position[1] = posY; - overlay->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); - } - } - void OverlayLayouter2D::PrepareTopLayout(int *displaySize) - { - double posX, posY; - Point2D margin; - posX = 0; - posY = displaySize[1]; - mitk::Overlay::Bounds bounds; - OverlayRankedMap &overlayMap = m_OverlayContainerMap[Top]; - for (auto it = overlayMap.cbegin(); it != overlayMap.cend(); ++it) - { - Overlay *overlay = it->second; - margin = GetMargin2D(overlay); - bounds = overlay->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); - - posX = displaySize[0] / 2 - bounds.Size[0] / 2; - posY -= bounds.Size[1] + margin[1]; - bounds.Position[0] = posX; - bounds.Position[1] = posY; - overlay->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); - } - } - void OverlayLayouter2D::PrepareTopRightLayout(int *displaySize) - { - double posX, posY; - Point2D margin; - posX = 0; - posY = displaySize[1]; - mitk::Overlay::Bounds bounds; - OverlayRankedMap &overlayMap = m_OverlayContainerMap[TopRight]; - for (auto it = overlayMap.cbegin(); it != overlayMap.cend(); ++it) - { - Overlay *overlay = it->second; - margin = GetMargin2D(overlay); - bounds = overlay->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); - - posX = displaySize[0] - (bounds.Size[0] + margin[0]); - posY -= bounds.Size[1] + margin[1]; - bounds.Position[0] = posX; - bounds.Position[1] = posY; - overlay->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); - } - } - - void OverlayLayouter2D::PrepareRightLayout(int *displaySize) - { - double posY; - Point2D margin; - double height = GetHeight(m_OverlayContainerMap[Right], GetCurrentBaseRenderer()); - posY = (height / 2.0 + displaySize[1]) / 2.0; - mitk::Overlay::Bounds bounds; - OverlayRankedMap &overlayMap = m_OverlayContainerMap[Right]; - for (auto it = overlayMap.cbegin(); it != overlayMap.cend(); ++it) - { - Overlay *overlay = it->second; - margin = GetMargin2D(overlay); - bounds = overlay->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); - - posY -= bounds.Size[1] + margin[1]; - bounds.Position[0] = displaySize[0] - (bounds.Size[0] + margin[0]); - bounds.Position[1] = posY + margin[1]; - overlay->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); - } - } - - void OverlayLayouter2D::PrepareLeftLayout(int *displaySize) - { - double posY; - Point2D margin; - double height = GetHeight(m_OverlayContainerMap[Left], GetCurrentBaseRenderer()); - posY = (height / 2.0 + displaySize[1]) / 2.0; - mitk::Overlay::Bounds bounds; - OverlayRankedMap &overlayMap = m_OverlayContainerMap[Left]; - for (auto it = overlayMap.cbegin(); it != overlayMap.cend(); ++it) - { - Overlay *overlay = it->second; - margin = GetMargin2D(overlay); - bounds = overlay->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); - - posY -= bounds.Size[1] + margin[1]; - bounds.Position[0] = margin[0]; - bounds.Position[1] = posY; - overlay->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); - } - } - - void OverlayLayouter2D::PrepareBottomLeftLayout(int * /*displaySize*/) - { - double posX, posY; - Point2D margin; - posX = 0; - posY = 0; - mitk::Overlay::Bounds bounds; - OverlayRankedMap &overlayMap = m_OverlayContainerMap[BottomLeft]; - for (auto it = overlayMap.cbegin(); it != overlayMap.cend(); ++it) - { - Overlay *overlay = it->second; - margin = GetMargin2D(overlay); - bounds = overlay->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); - - bounds.Position[0] = posX + margin[0]; - bounds.Position[1] = posY + margin[1]; - overlay->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); - posY += bounds.Size[1] + margin[1]; - } - } - void OverlayLayouter2D::PrepareBottomLayout(int *displaySize) - { - double posX, posY; - Point2D margin; - posX = 0; - posY = 0; - mitk::Overlay::Bounds bounds; - OverlayRankedMap &overlayMap = m_OverlayContainerMap[Bottom]; - for (auto it = overlayMap.cbegin(); it != overlayMap.cend(); ++it) - { - Overlay *overlay = it->second; - margin = GetMargin2D(overlay); - bounds = overlay->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); - - posX = displaySize[0] / 2 - bounds.Size[0] / 2; - bounds.Position[0] = posX; - bounds.Position[1] = posY + margin[1]; - overlay->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); - posY += bounds.Size[1] + margin[1]; - } - } - void OverlayLayouter2D::PrepareBottomRightLayout(int *displaySize) - { - double posX, posY; - Point2D margin; - posX = 0; - posY = 0; - mitk::Overlay::Bounds bounds; - OverlayRankedMap &overlayMap = m_OverlayContainerMap[BottomRight]; - for (auto it = overlayMap.cbegin(); it != overlayMap.cend(); ++it) - { - Overlay *overlay = it->second; - margin = GetMargin2D(overlay); - bounds = overlay->GetBoundsOnDisplay(this->GetCurrentBaseRenderer()); - - posX = displaySize[0] - (bounds.Size[0] + margin[0]); - bounds.Position[0] = posX; - bounds.Position[1] = posY + margin[1]; - overlay->SetBoundsOnDisplay(this->GetCurrentBaseRenderer(), bounds); - posY += bounds.Size[1] + margin[1]; - } - } - - double OverlayLayouter2D::GetHeight(OverlayRankedMap &overlays, BaseRenderer *renderer) - { - double height = 0; - for (auto it = overlays.cbegin(); it != overlays.cend(); ++it) - { - Overlay *overlay = it->second; - Overlay::Bounds bounds = overlay->GetBoundsOnDisplay(renderer); - height += bounds.Size[0]; - height += GetMargin2D(overlay)[0]; - } - return height; - } -} diff --git a/Modules/Overlays/src/mitkScaleLegendOverlay.cpp b/Modules/Overlays/src/mitkScaleLegendOverlay.cpp deleted file mode 100644 index 4f853b0114..0000000000 --- a/Modules/Overlays/src/mitkScaleLegendOverlay.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkScaleLegendOverlay.h" -#include -#include -#include - -mitk::ScaleLegendOverlay::ScaleLegendOverlay() -{ - SetRightAxisVisibility(true); - SetLeftAxisVisibility(true); - SetTopAxisVisibility(true); - SetBottomAxisVisibility(true); - SetLegendVisibility(true); - SetRightBorderOffset(50); - SetLeftBorderOffset(50); - SetTopBorderOffset(30); - SetBottomBorderOffset(30); - SetCornerOffsetFactor(2.0); - SetFontFactor(1.0); -} - -mitk::ScaleLegendOverlay::~ScaleLegendOverlay() -{ -} - -mitk::ScaleLegendOverlay::LocalStorage::~LocalStorage() -{ -} - -mitk::ScaleLegendOverlay::LocalStorage::LocalStorage() -{ - m_legendScaleActor = vtkSmartPointer::New(); -} - -void mitk::ScaleLegendOverlay::UpdateVtkOverlay(mitk::BaseRenderer *renderer) -{ - LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); - - if (ls->IsGenerateDataRequired(renderer, this)) - { - ls->m_legendScaleActor->SetRightAxisVisibility(this->GetRightAxisVisibility()); - ls->m_legendScaleActor->SetTopAxisVisibility(this->GetTopAxisVisibility()); - ls->m_legendScaleActor->SetLeftAxisVisibility(this->GetLeftAxisVisibility()); - ls->m_legendScaleActor->SetBottomAxisVisibility(this->GetBottomAxisVisibility()); - ls->m_legendScaleActor->SetLegendVisibility(this->GetLegendVisibility()); - ls->m_legendScaleActor->SetRightBorderOffset(this->GetRightBorderOffset()); - ls->m_legendScaleActor->SetLeftBorderOffset(this->GetLeftBorderOffset()); - ls->m_legendScaleActor->SetTopBorderOffset(this->GetTopBorderOffset()); - ls->m_legendScaleActor->SetBottomBorderOffset(this->GetBottomBorderOffset()); - ls->m_legendScaleActor->SetCornerOffsetFactor(this->GetCornerOffsetFactor()); - ls->m_legendScaleActor->GetLeftAxis()->SetFontFactor(this->GetFontFactor()); - ls->m_legendScaleActor->GetRightAxis()->SetFontFactor(this->GetFontFactor()); - ls->m_legendScaleActor->GetTopAxis()->SetFontFactor(this->GetFontFactor()); - ls->m_legendScaleActor->GetBottomAxis()->SetFontFactor(this->GetFontFactor()); - } -} - -vtkProp *mitk::ScaleLegendOverlay::GetVtkProp(BaseRenderer *renderer) const -{ - LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); - return ls->m_legendScaleActor; -} - -void mitk::ScaleLegendOverlay::SetRightAxisVisibility(bool visibility) -{ - SetBoolProperty("ScaleLegendOverlay.RightAxisVisibility", visibility); -} - -bool mitk::ScaleLegendOverlay::GetRightAxisVisibility() const -{ - bool visibility; - GetPropertyList()->GetBoolProperty("ScaleLegendOverlay.RightAxisVisibility", visibility); - return visibility; -} - -void mitk::ScaleLegendOverlay::SetLeftAxisVisibility(bool visibility) -{ - SetBoolProperty("ScaleLegendOverlay.LeftAxisVisibility", visibility); -} - -bool mitk::ScaleLegendOverlay::GetLeftAxisVisibility() const -{ - bool visibility; - GetPropertyList()->GetBoolProperty("ScaleLegendOverlay.LeftAxisVisibility", visibility); - return visibility; -} - -void mitk::ScaleLegendOverlay::SetTopAxisVisibility(bool visibility) -{ - SetBoolProperty("ScaleLegendOverlay.TopAxisVisibility", visibility); -} - -bool mitk::ScaleLegendOverlay::GetTopAxisVisibility() const -{ - bool visibility; - GetPropertyList()->GetBoolProperty("ScaleLegendOverlay.TopAxisVisibility", visibility); - return visibility; -} - -void mitk::ScaleLegendOverlay::SetBottomAxisVisibility(bool visibility) -{ - SetBoolProperty("ScaleLegendOverlay.BottomAxisVisibility", visibility); -} - -bool mitk::ScaleLegendOverlay::GetBottomAxisVisibility() const -{ - bool visibility; - GetPropertyList()->GetBoolProperty("ScaleLegendOverlay.BottomAxisVisibility", visibility); - return visibility; -} - -void mitk::ScaleLegendOverlay::SetLegendVisibility(bool visibility) -{ - SetBoolProperty("ScaleLegendOverlay.SetLegendVisibility", visibility); -} - -bool mitk::ScaleLegendOverlay::GetLegendVisibility() const -{ - bool visibility; - GetPropertyList()->GetBoolProperty("ScaleLegendOverlay.SetLegendVisibility", visibility); - return visibility; -} - -void mitk::ScaleLegendOverlay::SetRightBorderOffset(int offset) -{ - SetIntProperty("ScaleLegendOverlay.RightBorderOffset", offset); -} - -int mitk::ScaleLegendOverlay::GetRightBorderOffset() const -{ - int offset; - GetPropertyList()->GetIntProperty("ScaleLegendOverlay.RightBorderOffset", offset); - return offset; -} - -void mitk::ScaleLegendOverlay::SetLeftBorderOffset(int offset) -{ - SetIntProperty("ScaleLegendOverlay.LeftBorderOffset", offset); -} - -int mitk::ScaleLegendOverlay::GetLeftBorderOffset() const -{ - int offset; - GetPropertyList()->GetIntProperty("ScaleLegendOverlay.LeftBorderOffset", offset); - return offset; -} - -void mitk::ScaleLegendOverlay::SetTopBorderOffset(int offset) -{ - SetIntProperty("ScaleLegendOverlay.TopBorderOffset", offset); -} - -int mitk::ScaleLegendOverlay::GetTopBorderOffset() const -{ - int offset; - GetPropertyList()->GetIntProperty("ScaleLegendOverlay.TopBorderOffset", offset); - return offset; -} - -void mitk::ScaleLegendOverlay::SetBottomBorderOffset(int offset) -{ - SetIntProperty("ScaleLegendOverlay.BottomBorderOffset", offset); -} - -int mitk::ScaleLegendOverlay::GetBottomBorderOffset() const -{ - int offset; - GetPropertyList()->GetIntProperty("ScaleLegendOverlay.BottomBorderOffset", offset); - return offset; -} - -void mitk::ScaleLegendOverlay::SetCornerOffsetFactor(double offsetFactor) -{ - SetDoubleProperty("ScaleLegendOverlay.CornerOffsetFactor", offsetFactor); -} - -double mitk::ScaleLegendOverlay::GetCornerOffsetFactor() const -{ - double offsetFactor; - GetPropertyList()->GetDoubleProperty("ScaleLegendOverlay.CornerOffsetFactor", offsetFactor); - return offsetFactor; -} - -void mitk::ScaleLegendOverlay::SetFontFactor(double fontFactor) -{ - SetDoubleProperty("ScaleLegendOverlay.FontFactor", fontFactor); -} - -double mitk::ScaleLegendOverlay::GetFontFactor() const -{ - double offsetFactor; - GetPropertyList()->GetDoubleProperty("ScaleLegendOverlay.FontFactor", offsetFactor); - return offsetFactor; -} diff --git a/Modules/Overlays/test/files.cmake b/Modules/Overlays/test/files.cmake deleted file mode 100644 index 4787ba8f43..0000000000 --- a/Modules/Overlays/test/files.cmake +++ /dev/null @@ -1,18 +0,0 @@ - -set(MODULE_TESTS - mitkOverlaysTest.cpp -) - -if(MITK_ENABLE_RENDERING_TESTING) -set(MODULE_TESTS - ${MODULE_TESTS} - mitkAnnotationPlacerTest.cpp - mitkColorBarOverlayTest.cpp - mitkLabelOverlay3DTest.cpp - mitkLogoOverlayTest.cpp - mitkOverlayLayouter2DTest.cpp - mitkScaleLegendOverlayTest.cpp - mitkTextOverlay2DTest.cpp - mitkTextOverlay3DTest.cpp -) -endif() diff --git a/Modules/Overlays/test/mitkOverlayLayouter2DTest.cpp b/Modules/Overlays/test/mitkOverlayLayouter2DTest.cpp deleted file mode 100644 index ff2c02fecb..0000000000 --- a/Modules/Overlays/test/mitkOverlayLayouter2DTest.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -// MITK -#include - -#include -#include -#include -#include -#include - -void createTextOverlayWithLayouter(std::vector &overlays, - mitk::OverlayLayouter2D::Alignment align, - mitk::BaseRenderer *renderer, - int fontsize, - float red, - float green, - float blue, - int prio, - std::string text) -{ - // Create a textOverlay2D - mitk::TextOverlay2D::Pointer textOverlay = mitk::TextOverlay2D::New(); - - textOverlay->SetText(text); - textOverlay->SetFontSize(fontsize); - textOverlay->SetColor(red, green, blue); - textOverlay->SetOpacity(1); - - mitk::OverlayLayouter2D::AddOverlay(textOverlay, renderer, align, 5, 5, prio); - overlays.push_back(textOverlay); -} - -class mitkOverlayLayouter2DTestSuite : public mitk::TestFixture -{ - CPPUNIT_TEST_SUITE(mitkOverlayLayouter2DTestSuite); - MITK_TEST(Render2DOverlays); - - CPPUNIT_TEST_SUITE_END(); - -private: - /** Members used inside the different test methods. All members are initialized via setUp().*/ - mitk::RenderingTestHelper m_RenderingTestHelper; - std::vector m_CommandlineArgs; - std::string m_PathToBall; - std::string m_PathToImage; - std::string m_ReferenceImagePath; - -public: - /** - * @brief mitkAnnotationPlacerTestSuite Because the RenderingTestHelper does not have an - * empty default constructor, we need this constructor to initialize the helper with a - * resolution. - */ - mitkOverlayLayouter2DTestSuite() : m_RenderingTestHelper(500, 500) {} - /** - * @brief Setup Initialize a fresh rendering test helper and a vector of strings - * to simulate commandline arguments for vtkTesting::Test. - */ - void setUp() - { - m_RenderingTestHelper = mitk::RenderingTestHelper(500, 500); - - m_PathToBall = GetTestDataFilePath("ball.stl"); - m_PathToImage = GetTestDataFilePath("Pic3D.nrrd"); - m_ReferenceImagePath = "RenderingTestData/ReferenceScreenshots/Overlay/"; - - // Build a command line for the vtkTesting::Test method. - // See VTK documentation and RenderingTestHelper for more information. - // Use the following command line option to save the difference image - // and the test image in some tmp folder - // m_CommandlineArgs.push_back("-T"); - // m_CommandlineArgs.push_back("/path/to/save/tmp/difference/images/"); - m_CommandlineArgs.push_back("-V"); - } - - void tearDown() {} - void Render2DOverlays() - { - mitk::DataNode::Pointer ballnode = mitk::DataNode::New(); - ballnode->SetData(mitk::IOUtil::Load(m_PathToBall)[0]); - m_RenderingTestHelper.AddNodeToStorage(ballnode); - - mitk::DataNode::Pointer imagenode = mitk::DataNode::New(); - imagenode->SetData(mitk::IOUtil::Load(m_PathToImage)[0]); - m_RenderingTestHelper.AddNodeToStorage(imagenode); - - std::string refImagePath = GetTestDataFilePath(m_ReferenceImagePath + "OverlayLayouter2D.png"); - // reference screenshot for this test - m_CommandlineArgs.push_back(refImagePath); - // Convert vector of strings to argc/argv - mitk::RenderingTestHelper::ArgcHelperClass arg(m_CommandlineArgs); - m_RenderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); - - std::vector overlays; - mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(m_RenderingTestHelper.GetVtkRenderWindow()); - - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::TopLeft, renderer, 20, 1.0, 1.0, 1.0, 1, "TopLeft1"); - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::TopLeft, renderer, 15, 1.0, 1.0, 1.0, 3, "TopLeft3"); - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::TopLeft, renderer, 25, 1.0, 0.0, 1.0, 2, "TopLeft2"); - - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Top, renderer, 15, 1.0, 1.0, 1.0, 3, "Top3"); - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Top, renderer, 20, 1.0, 1.0, 1.0, 1, "Top1"); - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Top, renderer, 25, 1.0, 0.0, 1.0, 2, "Top2"); - - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::TopRight, renderer, 20, 1.0, 1.0, 1.0, 1, "TopRight1"); - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::TopRight, renderer, 15, 1.0, 1.0, 1.0, 3, "TopRight3"); - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::TopRight, renderer, 25, 1.0, 0.0, 1.0, 2, "TopRight2"); - - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Left, renderer, 20, 1.0, 1.0, 1.0, 1, "Left1"); - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Left, renderer, 15, 1.0, 1.0, 1.0, 3, "Left3"); - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Left, renderer, 25, 1.0, 0.0, 1.0, 2, "Left2"); - - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Right, renderer, 25, 1.0, 0.0, 1.0, 2, "Right2"); - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Right, renderer, 20, 1.0, 1.0, 1.0, 1, "Right1"); - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Right, renderer, 15, 1.0, 1.0, 1.0, 3, "Right3"); - - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::BottomLeft, renderer, 25, 1.0, 0.0, 1.0, 2, "BottomLeft2"); - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::BottomLeft, renderer, 20, 1.0, 1.0, 1.0, 1, "BottomLeft1"); - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::BottomLeft, renderer, 15, 1.0, 1.0, 1.0, 3, "BottomLeft3"); - - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Bottom, renderer, 15, 1.0, 1.0, 1.0, 3, "Bottom3"); - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Bottom, renderer, 20, 1.0, 1.0, 1.0, 1, "Bottom1"); - createTextOverlayWithLayouter(overlays, mitk::OverlayLayouter2D::Bottom, renderer, 25, 1.0, 0.0, 1.0, 2, "Bottom2"); - - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::BottomRight, renderer, 25, 1.0, 0.0, 1.0, 2, "BottomRight2"); - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::BottomRight, renderer, 20, 1.0, 1.0, 1.0, 1, "BottomRight1"); - createTextOverlayWithLayouter( - overlays, mitk::OverlayLayouter2D::BottomRight, renderer, 15, 1.0, 1.0, 1.0, 3, "BottomRight3"); - - m_RenderingTestHelper.Render(); - m_RenderingTestHelper.SaveReferenceScreenShot(refImagePath); - m_RenderingTestHelper.SetAutomaticallyCloseRenderWindow(true); - CPPUNIT_ASSERT(m_RenderingTestHelper.CompareRenderWindowAgainstReference(arg.GetArgc(), arg.GetArgv()) == true); - } -}; -MITK_TEST_SUITE_REGISTRATION(mitkOverlayLayouter2D) diff --git a/Modules/Overlays/test/mitkOverlaysTest.cpp b/Modules/Overlays/test/mitkOverlaysTest.cpp deleted file mode 100644 index 7bc0fabec3..0000000000 --- a/Modules/Overlays/test/mitkOverlaysTest.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -#include -#include -#include -#include -#include -#include -#include - -#include "mitkAnnotationPlacer.h" -#include "mitkOverlayLayouter2D.h" - -class mitkOverlaysTestSuite : public mitk::TestFixture -{ - CPPUNIT_TEST_SUITE(mitkOverlaysTestSuite); - MITK_TEST(AnnotationServiceTest); - CPPUNIT_TEST_SUITE_END(); - -private: -public: - void setUp() override {} - void AnnotationServiceTest() - { - mitk::AnnotationPlacer *ap1_test1 = mitk::AnnotationPlacer::GetAnnotationRenderer("test1"); - CPPUNIT_ASSERT_MESSAGE("Testing availability of AnnotationPlacer service", ap1_test1); - mitk::AnnotationPlacer *ap2_test1 = mitk::AnnotationPlacer::GetAnnotationRenderer("test1"); - CPPUNIT_ASSERT_MESSAGE("Testing if AnnotationPlacer of same kind stays avaliable", ap1_test1 == ap2_test1); - mitk::AnnotationPlacer *ap1_test2 = mitk::AnnotationPlacer::GetAnnotationRenderer("test2"); - CPPUNIT_ASSERT_MESSAGE("Testing if new instance can be created by using different ID", ap1_test2 != ap1_test1); - - mitk::OverlayLayouter2D *ol1_test1 = mitk::OverlayLayouter2D::GetAnnotationRenderer("test1"); - CPPUNIT_ASSERT_MESSAGE("Testing availability of OverlayLayouter2D service", ol1_test1); - mitk::OverlayLayouter2D *ol2_test1 = mitk::OverlayLayouter2D::GetAnnotationRenderer("test1"); - CPPUNIT_ASSERT_MESSAGE("Testing if OverlayLayouter2D of same kind stays avaliable", ol2_test1 == ol1_test1); - mitk::OverlayLayouter2D *ol1_test2 = mitk::OverlayLayouter2D::GetAnnotationRenderer("test2"); - CPPUNIT_ASSERT_MESSAGE("Testing if new instance can be created by using different ID", ol1_test2 != ol1_test1); - - CPPUNIT_ASSERT_MESSAGE( - "Testing if OverlayLayouter2D and AnnotationPlacer services are different", - (mitk::AbstractAnnotationRenderer *)ol1_test1 != (mitk::AbstractAnnotationRenderer *)ap1_test1); - } - - void OverlayTest() {} -}; -MITK_TEST_SUITE_REGISTRATION(mitkOverlays) diff --git a/Modules/PlanarFigure/CMakeLists.txt b/Modules/PlanarFigure/CMakeLists.txt index 2f2b359e3c..08415106bf 100644 --- a/Modules/PlanarFigure/CMakeLists.txt +++ b/Modules/PlanarFigure/CMakeLists.txt @@ -1,8 +1,8 @@ MITK_CREATE_MODULE( INCLUDE_DIRS PRIVATE src/Algorithms src/DataManagement src/Interactions src/IO src/Rendering - DEPENDS MitkSceneSerializationBase MitkLegacyGL MitkOverlays + DEPENDS MitkSceneSerializationBase MitkLegacyGL MitkAnnotation WARNINGS_AS_ERRORS ) add_subdirectory(test) diff --git a/Modules/PlanarFigure/include/mitkPlanarFigure.h b/Modules/PlanarFigure/include/mitkPlanarFigure.h index 98e83510a7..146fd106ee 100644 --- a/Modules/PlanarFigure/include/mitkPlanarFigure.h +++ b/Modules/PlanarFigure/include/mitkPlanarFigure.h @@ -1,382 +1,382 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _MITK_PLANAR_FIGURE_H_ #define _MITK_PLANAR_FIGURE_H_ #include "mitkBaseData.h" #include "mitkCommon.h" #include #include namespace mitk { class PlaneGeometry; /** * \brief Base-class for geometric planar (2D) figures, such as * lines, circles, rectangles, polygons, etc. * * \warning Currently does not support time-resolved data handling * * Behavior and appearance of PlanarFigures are controlled by various properties; for a detailed * list of appearance properties see mitk::PlanarFigureMapper2D * * The following properties control general PlanarFigure behavior: * *
    *
  • "selected": true if the planar figure is selected *
  • "planarfigure.ishovering": true if the mouse "hovers" over the planar figure *
  • "planarfigure.iseditable": true if the planar figure can be edited (otherwise, * it can only be picked/selected, but its control points cannot be edited); default is true *
  • "planarfigure.isextendable": true if new control points can be inserted into the list of control points; * default is false *
* * * TODO: Implement local 2D transform (including center of rotation...) * */ class MITKPLANARFIGURE_EXPORT PlanarFigure : public BaseData { public: mitkClassMacro(PlanarFigure, BaseData) itkCloneMacro(Self) typedef Point2D PolyLineElement; typedef itk::VectorContainer BoolContainerType; typedef std::deque ControlPointListType; typedef std::vector PolyLineType; /** \brief Sets the 2D geometry on which this figure will be placed. * * In most cases, this is a Geometry already owned by another object, e.g. * describing the slice of the image on which measurements will be * performed. */ virtual void SetPlaneGeometry(mitk::PlaneGeometry *geometry); /** \brief Returns (previously set) 2D geometry of this figure. */ virtual const PlaneGeometry *GetPlaneGeometry() const; /** \brief True if the planar figure is closed. * * Default is false. The "closed" boolean property must be set in sub-classes. */ virtual bool IsClosed() const; /** \brief True if the planar figure has been placed (and can be * displayed/interacted with). */ virtual bool IsPlaced() const { return m_FigurePlaced; }; /** \brief Place figure at the given point (in 2D index coordinates) onto * the given 2D geometry. * * By default, the first two control points of the figure are set to the * passed point. Further points can be set via AddControlPoint(), if the * current number of control points is below the maximum number of control * points. * * Can be re-implemented in sub-classes as needed. */ virtual void PlaceFigure(const Point2D &point); /** * \brief Adds / inserts new control-points * * This method adds a new control-point with the coordinates defined by point at the given index. * If 'index' == -1 or index is greater than the number of control-points the new point is appended * to the back of the list of control points. * If a control-point already exists for 'index', an additional point is inserted at that position. * It is not possible to add more points if the maximum number of control-points (GetMaximumNumberOfControlPoints()) * has been reached. */ virtual bool AddControlPoint(const Point2D &point, int index = -1); virtual bool SetControlPoint(unsigned int index, const Point2D &point, bool createIfDoesNotExist = false); virtual bool SetCurrentControlPoint(const Point2D &point); /** \brief Returns the current number of 2D control points defining this figure. */ unsigned int GetNumberOfControlPoints() const; /** \brief Returns the minimum number of control points needed to represent * this figure. * * Must be implemented in sub-classes. */ virtual unsigned int GetMinimumNumberOfControlPoints() const = 0; /** \brief Returns the maximum number of control points allowed for * this figure (e.g. 3 for triangles). * * Must be implemented in sub-classes. */ virtual unsigned int GetMaximumNumberOfControlPoints() const = 0; /** \brief Selects currently active control points. */ virtual bool SelectControlPoint(unsigned int index); /** \brief Deselect control point; no control point active. */ virtual bool DeselectControlPoint(); /** \brief Return currently selected control point. */ virtual int GetSelectedControlPoint() const { return m_SelectedControlPoint; } /** \brief Returns specified control point in 2D world coordinates. */ Point2D GetControlPoint(unsigned int index) const; /** * \brief Returns the id of the control-point that corresponds to the given * polyline-point. */ virtual int GetControlPointForPolylinePoint(int indexOfPolylinePoint, int polyLineIndex) const; /** \brief Returns specified control point in world coordinates. */ Point3D GetWorldControlPoint(unsigned int index) const; /** \brief Returns the polyline representing the planar figure * (for rendering, measurements, etc.). */ const PolyLineType GetPolyLine(unsigned int index); /** \brief Returns the polyline representing the planar figure * (for rendering, measurments, etc.). */ const PolyLineType GetPolyLine(unsigned int index) const; /** \brief Returns the polyline that should be drawn the same size at every scale * (for text, angles, etc.). */ const PolyLineType GetHelperPolyLine(unsigned int index, double mmPerDisplayUnit, unsigned int displayHeight); /** \brief Sets the position of the PreviewControlPoint. Automatically sets it visible.*/ void SetPreviewControlPoint(const Point2D &point); /** \brief Marks the PreviewControlPoint as invisible.*/ void ResetPreviewContolPoint(); /** \brief Returns whether or not the PreviewControlPoint is visible.*/ bool IsPreviewControlPointVisible() const; /** \brief Returns the coordinates of the PreviewControlPoint. */ Point2D GetPreviewControlPoint() const; /** \brief Returns the number of features available for this PlanarFigure * (such as, radius, area, ...). */ virtual unsigned int GetNumberOfFeatures() const; /** \brief Returns the name (identifier) of the specified features. */ const char *GetFeatureName(unsigned int index) const; /** \brief Returns the physical unit of the specified features. */ const char *GetFeatureUnit(unsigned int index) const; /** Returns quantity of the specified feature (e.g., length, radius, * area, ... ) */ double GetQuantity(unsigned int index) const; /** \brief Returns true if the feature with the specified index exists and * is active (an inactive feature may e.g. be the area of a non-closed * polygon. */ bool IsFeatureActive(unsigned int index) const; /** \brief Returns true if the feature with the specified index exists and is set visible */ bool IsFeatureVisible(unsigned int index) const; /** \brief Defines if the feature with the specified index will be shown as an - * overlay in the RenderWindow */ + * Annotation in the RenderWindow */ void SetFeatureVisible(unsigned int index, bool visible); /** \brief Calculates quantities of all features of this planar figure. */ virtual void EvaluateFeatures(); /** \brief Intherited from parent */ virtual void UpdateOutputInformation() override; /** \brief Intherited from parent */ virtual void SetRequestedRegionToLargestPossibleRegion() override; /** \brief Intherited from parent */ virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override; /** \brief Intherited from parent */ virtual bool VerifyRequestedRegion() override; /** \brief Intherited from parent */ virtual void SetRequestedRegion(const itk::DataObject *data) override; /** \brief Returns the current number of polylines */ virtual unsigned short GetPolyLinesSize(); /** \brief Returns the current number of helperpolylines */ virtual unsigned short GetHelperPolyLinesSize() const; /** \brief Returns whether a helper polyline should be painted or not */ virtual bool IsHelperToBePainted(unsigned int index) const; /** \brief Returns true if the planar figure is reset to "add points" mode * when a point is selected. * * Default return value is false. Subclasses can overwrite this method and * execute any reset / initialization statements required. */ virtual bool ResetOnPointSelect(); virtual bool ResetOnPointSelectNeeded() const; /** \brief removes the point with the given index from the list of controlpoints. */ virtual void RemoveControlPoint(unsigned int index); /** \brief Removes last control point */ virtual void RemoveLastControlPoint(); /** \brief Allow sub-classes to apply constraints on control points. * * Sub-classes can define spatial constraints to certain control points by * overwriting this method and returning a constrained point. By default, * the points are constrained by the image bounds. */ virtual Point2D ApplyControlPointConstraints(unsigned int /*index*/, const Point2D &point); /** * \brief Compare two PlanarFigure objects * Note: all subclasses have to implement the method on their own. */ virtual bool Equals(const mitk::PlanarFigure &other) const; protected: PlanarFigure(); PlanarFigure(const Self &other); /** \brief Set the initial number of control points of the planar figure */ void ResetNumberOfControlPoints(int numberOfControlPoints); /** Adds feature (e.g., circumference, radius, angle, ...) to feature vector * of a planar figure object and returns integer ID for the feature element. * Should be called in sub-class constructors. */ virtual unsigned int AddFeature(const char *featureName, const char *unitName); /** Sets the name of the specified feature. INTERNAL METHOD. */ void SetFeatureName(unsigned int index, const char *featureName); /** Sets the physical unit of the specified feature. INTERNAL METHOD. */ void SetFeatureUnit(unsigned int index, const char *unitName); /** Sets quantity of the specified feature. INTERNAL METHOD. */ void SetQuantity(unsigned int index, double quantity); /** Sets the specified feature as active. INTERAL METHOD. */ void ActivateFeature(unsigned int index); /** Sets the specified feature as active. INTERAL METHOD. */ void DeactivateFeature(unsigned int index); /** \brief Generates the poly-line representation of the planar figure. * Must be implemented in sub-classes. */ virtual void GeneratePolyLine() = 0; /** \brief Generates the poly-lines that should be drawn the same size regardless of zoom. * Must be implemented in sub-classes. */ virtual void GenerateHelperPolyLine(double mmPerDisplayUnit, unsigned int displayHeight) = 0; /** \brief Calculates quantities of all features of this planar figure. * Must be implemented in sub-classes. */ virtual void EvaluateFeaturesInternal() = 0; /** \brief Initializes the TimeGeometry describing the (time-resolved) * geometry of this figure. Note that each time step holds one PlaneGeometry. */ virtual void InitializeTimeGeometry(unsigned int timeSteps = 1) override; /** \brief defines the number of PolyLines that will be available */ void SetNumberOfPolyLines(unsigned int numberOfPolyLines); /** \brief Append a point to the PolyLine # index */ void AppendPointToPolyLine(unsigned int index, PolyLineElement element); /** \brief clears the list of PolyLines. Call before re-calculating a new Polyline. */ void ClearPolyLines(); /** \brief defines the number of HelperPolyLines that will be available */ void SetNumberOfHelperPolyLines(unsigned int numberOfHelperPolyLines); /** \brief Append a point to the HelperPolyLine # index */ void AppendPointToHelperPolyLine(unsigned int index, PolyLineElement element); /** \brief clears the list of HelperPolyLines. Call before re-calculating a new HelperPolyline. */ void ClearHelperPolyLines(); virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override; ControlPointListType m_ControlPoints; unsigned int m_NumberOfControlPoints; // Currently selected control point; -1 means no point selected int m_SelectedControlPoint; std::vector m_PolyLines; std::vector m_HelperPolyLines; BoolContainerType::Pointer m_HelperPolyLinesToBePainted; // this point is used to store the coordiantes an additional 'ControlPoint' that is rendered // when the mouse cursor is above the figure (and not a control-point) and when the // property 'planarfigure.isextendable' is set to true Point2D m_PreviewControlPoint; bool m_PreviewControlPointVisible; bool m_FigurePlaced; private: // not implemented to prevent PlanarFigure::New() calls which would create an itk::Object. static Pointer New(); struct Feature { Feature(const char *name, const char *unit) : Name(name), Unit(unit), Quantity(0.0), Active(true), Visible(true) { } std::string Name; std::string Unit; double Quantity; bool Active; bool Visible; }; virtual itk::LightObject::Pointer InternalClone() const override = 0; PlaneGeometry *m_PlaneGeometry; bool m_PolyLineUpToDate; bool m_HelperLinesUpToDate; bool m_FeaturesUpToDate; // Vector of features available for this geometric figure typedef std::vector FeatureVectorType; FeatureVectorType m_Features; unsigned long m_FeaturesMTime; // this pair is used to store the mmInDisplayUnits (m_DisplaySize.first) and the displayHeight // (m_DisplaySize.second) // that the helperPolyLines have been calculated for. // It's used to determine whether or not GetHelperPolyLine() needs to recalculate the HelperPolyLines. std::pair m_DisplaySize; }; MITKPLANARFIGURE_EXPORT bool Equal(const mitk::PlanarFigure &leftHandSide, const mitk::PlanarFigure &rightHandSide, ScalarType eps, bool verbose); } // namespace mitk #endif //_MITK_PLANAR_FIGURE_H_ diff --git a/Modules/PlanarFigure/include/mitkPlanarFigureMapper2D.h b/Modules/PlanarFigure/include/mitkPlanarFigureMapper2D.h index 8f0507a381..487a1bfbfc 100644 --- a/Modules/PlanarFigure/include/mitkPlanarFigureMapper2D.h +++ b/Modules/PlanarFigure/include/mitkPlanarFigureMapper2D.h @@ -1,307 +1,307 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITK_PLANAR_FIGURE_MAPPER_2D_H_ #define MITK_PLANAR_FIGURE_MAPPER_2D_H_ #include "mitkCommon.h" #include "mitkGLMapper.h" #include "mitkPlanarFigure.h" #include "mitkPlanarFigureControlPointStyleProperty.h" #include namespace mitk { class BaseRenderer; class Contour; - class TextOverlay2D; + class TextAnnotation2D; /** * \brief OpenGL-based mapper to render display sub-class instances of mitk::PlanarFigure * * The appearance of planar figures can be configured through properties. If no properties are specified, * default values will be used. There are four elements a planar figure consists of: * *
    *
  1. "line": the main line segments of the planar figure (note: text is drawn in the same style) *
  2. "helperline": additional line segments of planar figures, such as arrow tips, arches of angles, etc. *
  3. "outline": background which is drawn behind the lines and helperlines of the planar figure (optional) *
  4. "marker": the markers (control points) of a planar figure *
  5. "markerline": the lines by which markers (control points) are surrounded *
* * In the following, all appearance-related planar figure properties are listed: * *
    *
  1. General properties for the planar figure *
      *
    • "planarfigure.drawoutline": if true, the "outline" lines is drawn *
    • "planarfigure.drawquantities": if true, the quantities (text) associated with the planar figure is drawn *
    • "planarfigure.drawname": if true, the name specified by the dataNode is drawn *
    • "planarfigure.drawshadow": if true, a black shadow is drawn around the planar figure *
    • "planarfigure.controlpointshape": style of the control points (enum) *
    *
  2. Line widths of planar figure elements *
      *
    • "planarfigure.line.width": width of "line" segments (float value, in mm) *
    • "planarfigure.shadow.widthmodifier": the width of the shadow is defined by width of the "line" * this * modifier *
    • "planarfigure.outline.width": width of "outline" segments (float value, in mm) *
    • "planarfigure.helperline.width": width of "helperline" segments (float value, in mm) *
    *
  3. Color/opacity of planar figure elements in normal mode (unselected) *
      *
    • "planarfigure.default.line.color" *
    • "planarfigure.default.line.opacity" *
    • "planarfigure.default.outline.color" *
    • "planarfigure.default.outline.opacity" *
    • "planarfigure.default.helperline.color" *
    • "planarfigure.default.helperline.opacity" *
    • "planarfigure.default.markerline.color" *
    • "planarfigure.default.markerline.opacity" *
    • "planarfigure.default.marker.color" *
    • "planarfigure.default.marker.opacity" *
    *
  4. Color/opacity of planar figure elements in hover mode (mouse-over) *
      *
    • "planarfigure.hover.line.color" *
    • "planarfigure.hover.line.opacity" *
    • "planarfigure.hover.outline.color" *
    • "planarfigure.hover.outline.opacity" *
    • "planarfigure.hover.helperline.color" *
    • "planarfigure.hover.helperline.opacity" *
    • "planarfigure.hover.markerline.color" *
    • "planarfigure.hover.markerline.opacity" *
    • "planarfigure.hover.marker.color" *
    • "planarfigure.hover.marker.opacity" *
    *
  5. Color/opacity of planar figure elements in selected mode *
      *
    • "planarfigure.selected.line.color" *
    • "planarfigure.selected.line.opacity" *
    • "planarfigure.selected.outline.color" *
    • "planarfigure.selected.outline.opacity" *
    • "planarfigure.selected.helperline.color" *
    • "planarfigure.selected.helperline.opacity" *
    • "planarfigure.selected.markerline.color;" *
    • "planarfigure.selected.markerline.opacity" *
    • "planarfigure.selected.marker.color" *
    • "planarfigure.selected.marker.opacity" *
    *
* * @ingroup MitkPlanarFigureModule */ class MITKPLANARFIGURE_EXPORT PlanarFigureMapper2D : public GLMapper { public: mitkClassMacro(PlanarFigureMapper2D, GLMapper); itkFactorylessNewMacro(Self) itkCloneMacro(Self) /** * reimplemented from Baseclass */ virtual void Paint(BaseRenderer *renderer) override; static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer = NULL, bool overwrite = false); protected: enum PlanarFigureDisplayMode { PF_DEFAULT = 0, PF_HOVER = 1, PF_SELECTED = 2, PF_COUNT = 3 // helper variable }; PlanarFigureMapper2D(); virtual ~PlanarFigureMapper2D(); /** * \brief Renders all the lines defined by the PlanarFigure. * * This method renders all the lines that are defined by the PlanarFigure. * That includes the mainlines and helperlines as well as their shadows * and the outlines. * * This method already takes responsibility for the setting of the relevant * openGL attributes to reduce unnecessary setting of these attributes. * (e.g. no need to set color twice if it's the same) */ void RenderLines(const PlanarFigureDisplayMode lineDisplayMode, mitk::PlanarFigure *planarFigure, mitk::Point2D &anchorPoint, const mitk::PlaneGeometry *planarFigurePlaneGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer); /** * \brief Renders the quantities of the figure below the text annotations. */ void RenderQuantities(const mitk::PlanarFigure *planarFigure, mitk::BaseRenderer *renderer, const mitk::Point2D anchorPoint, double &annotationOffset, float globalOpacity, const PlanarFigureDisplayMode lineDisplayMode); /** * \brief Renders the text annotations. */ void RenderAnnotations(mitk::BaseRenderer *renderer, const std::string name, const mitk::Point2D anchorPoint, float globalOpacity, const PlanarFigureDisplayMode lineDisplayMode, double &annotationOffset); /** * \brief Renders the control-points. */ void RenderControlPoints(const mitk::PlanarFigure *planarFigure, const PlanarFigureDisplayMode lineDisplayMode, const mitk::PlaneGeometry *planarFigurePlaneGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, mitk::BaseRenderer *renderer); void TransformObjectToDisplay(const mitk::Point2D &point2D, mitk::Point2D &displayPoint, const mitk::PlaneGeometry *objectGeometry, const mitk::PlaneGeometry *, const mitk::BaseRenderer *renderer); void DrawMarker(const mitk::Point2D &point, float *lineColor, float lineOpacity, float *markerColor, float markerOpacity, float lineWidth, PlanarFigureControlPointStyleProperty::Shape shape, const mitk::PlaneGeometry *objectGeometry, const mitk::PlaneGeometry *rendererGeometry, const mitk::BaseRenderer *renderer); /** * \brief Actually paints the polyline defined by the figure. */ void PaintPolyLine(const mitk::PlanarFigure::PolyLineType vertices, bool closed, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer); /** * \brief Internally used by RenderLines() to draw the mainlines using * PaintPolyLine(). */ void DrawMainLines(mitk::PlanarFigure *figure, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer); /** * \brief Internally used by RenderLines() to draw the helperlines using * PaintPolyLine(). */ void DrawHelperLines(mitk::PlanarFigure *figure, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer); void InitializeDefaultPlanarFigureProperties(); void InitializePlanarFigurePropertiesFromDataNode(const mitk::DataNode *node); void SetColorProperty(float property[3][3], PlanarFigureDisplayMode mode, float red, float green, float blue) { property[mode][0] = red; property[mode][1] = green; property[mode][2] = blue; } void SetFloatProperty(float *property, PlanarFigureDisplayMode mode, float value) { property[mode] = value; } /** * \brief Callback that sets m_NodeModified to true. * * This method set the bool flag m_NodeModified to true. It's a callback * that is executed when a itk::ModifiedEvet is invoked on our * DataNode. */ void OnNodeModified(); private: bool m_IsSelected; bool m_IsHovering; bool m_DrawOutline; bool m_DrawQuantities; bool m_DrawShadow; bool m_DrawControlPoints; bool m_DrawName; bool m_DrawDashed; bool m_DrawHelperDashed; bool m_AnnotationsShadow; std::string m_AnnotationFontFamily; bool m_DrawAnnotationBold; bool m_DrawAnnotationItalic; int m_AnnotationSize; // the width of the shadow is defined as 'm_LineWidth * m_ShadowWidthFactor' float m_LineWidth; float m_ShadowWidthFactor; float m_OutlineWidth; float m_HelperlineWidth; // float m_PointWidth; float m_DevicePixelRatio; PlanarFigureControlPointStyleProperty::Shape m_ControlPointShape; float m_LineColor[3][3]; float m_LineOpacity[3]; float m_OutlineColor[3][3]; float m_OutlineOpacity[3]; float m_HelperlineColor[3][3]; float m_HelperlineOpacity[3]; float m_MarkerlineColor[3][3]; float m_MarkerlineOpacity[3]; float m_MarkerColor[3][3]; float m_MarkerOpacity[3]; float m_AnnotationColor[3][3]; // Bool flag that represents whether or not the DataNode has been modified. bool m_NodeModified; // Observer-tag for listening to itk::ModifiedEvents on the DataNode unsigned long m_NodeModifiedObserverTag; // Bool flag that indicates if a node modified observer was added bool m_NodeModifiedObserverAdded; - itk::SmartPointer m_AnnotationOverlay; - itk::SmartPointer m_QuantityOverlay; + itk::SmartPointer m_AnnotationAnnotation; + itk::SmartPointer m_QuantityAnnotation; }; } // namespace mitk #endif /* MITK_PLANAR_FIGURE_MAPPER_2D_H_ */ diff --git a/Modules/PlanarFigure/src/Rendering/mitkPlanarFigureMapper2D.cpp b/Modules/PlanarFigure/src/Rendering/mitkPlanarFigureMapper2D.cpp index 4cd7eddf56..906104db36 100644 --- a/Modules/PlanarFigure/src/Rendering/mitkPlanarFigureMapper2D.cpp +++ b/Modules/PlanarFigure/src/Rendering/mitkPlanarFigureMapper2D.cpp @@ -1,949 +1,949 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPlanarFigureMapper2D.h" #include "mitkBaseRenderer.h" #include "mitkColorProperty.h" #include "mitkGL.h" #include "mitkPlaneGeometry.h" #include "mitkProperties.h" -#include "mitkTextOverlay2D.h" +#include "mitkTextAnnotation2D.h" #define _USE_MATH_DEFINES #include // offset which moves the planarfigures on top of the other content // the crosshair is rendered into the z = 1 layer. static const float PLANAR_OFFSET = 0.5f; mitk::PlanarFigureMapper2D::PlanarFigureMapper2D() : m_NodeModified(true), m_NodeModifiedObserverTag(0), m_NodeModifiedObserverAdded(false) { - m_AnnotationOverlay = mitk::TextOverlay2D::New(); - m_QuantityOverlay = mitk::TextOverlay2D::New(); + m_AnnotationAnnotation = mitk::TextAnnotation2D::New(); + m_QuantityAnnotation = mitk::TextAnnotation2D::New(); this->InitializeDefaultPlanarFigureProperties(); } mitk::PlanarFigureMapper2D::~PlanarFigureMapper2D() { if (m_NodeModifiedObserverAdded && GetDataNode() != NULL) { GetDataNode()->RemoveObserver(m_NodeModifiedObserverTag); } } void mitk::PlanarFigureMapper2D::Paint(mitk::BaseRenderer *renderer) { bool visible = true; - m_AnnotationOverlay->SetVisibility(false); + m_AnnotationAnnotation->SetVisibility(false); - m_QuantityOverlay->SetVisibility(false); + m_QuantityAnnotation->SetVisibility(false); GetDataNode()->GetVisibility(visible, renderer, "visible"); if (!visible) return; // Get PlanarFigure from input mitk::PlanarFigure *planarFigure = const_cast(static_cast(GetDataNode()->GetData())); // Check if PlanarFigure has already been placed; otherwise, do nothing if (!planarFigure->IsPlaced()) { return; } // Get 2D geometry frame of PlanarFigure const mitk::PlaneGeometry *planarFigurePlaneGeometry = planarFigure->GetPlaneGeometry(); if (planarFigurePlaneGeometry == NULL) { MITK_ERROR << "PlanarFigure does not have valid PlaneGeometry!"; return; } // Get current world 2D geometry from renderer const mitk::PlaneGeometry *rendererPlaneGeometry = renderer->GetCurrentWorldPlaneGeometry(); // If the PlanarFigure geometry is a plane geometry, check if current // world plane is parallel to and within the planar figure geometry bounds // (otherwise, display nothing) if ((planarFigurePlaneGeometry != NULL) && (rendererPlaneGeometry != NULL)) { double planeThickness = planarFigurePlaneGeometry->GetExtentInMM(2); if (!planarFigurePlaneGeometry->IsParallel(rendererPlaneGeometry) || !(planarFigurePlaneGeometry->DistanceFromPlane(rendererPlaneGeometry) < planeThickness / 3.0)) { // Planes are not parallel or renderer plane is not within PlanarFigure // geometry bounds --> exit return; } } else { // Plane is not valid (curved reformations are not possible yet) return; } // Apply visual appearance properties from the PropertyList ApplyColorAndOpacityProperties(renderer); // Enable line antialiasing glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glEnable(GL_DEPTH_TEST); // Get properties from node (if present) const mitk::DataNode *node = this->GetDataNode(); this->InitializePlanarFigurePropertiesFromDataNode(node); PlanarFigureDisplayMode lineDisplayMode = PF_DEFAULT; if (m_IsSelected) { lineDisplayMode = PF_SELECTED; } else if (m_IsHovering) { lineDisplayMode = PF_HOVER; } mitk::Point2D anchorPoint; anchorPoint[0] = 0; anchorPoint[1] = 1; // render the actual lines of the PlanarFigure RenderLines(lineDisplayMode, planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); // position-offset of the annotations, is set in RenderAnnotations() and // used in RenderQuantities() double annotationOffset = 0.0; // Get Global Opacity float globalOpacity = 1.0; node->GetFloatProperty("opacity", globalOpacity); if (m_DrawControlPoints) { // draw the control-points RenderControlPoints(planarFigure, lineDisplayMode, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); } // draw name near the anchor point (point located on the right) const std::string name = node->GetName(); if (m_DrawName && !name.empty()) { RenderAnnotations(renderer, name, anchorPoint, globalOpacity, lineDisplayMode, annotationOffset); } // draw feature quantities (if requested) next to the anchor point, // but under the name (that is where 'annotationOffset' is used) if (m_DrawQuantities) { RenderQuantities(planarFigure, renderer, anchorPoint, annotationOffset, globalOpacity, lineDisplayMode); } glLineWidth(1.0f); } void mitk::PlanarFigureMapper2D::PaintPolyLine(const mitk::PlanarFigure::PolyLineType vertices, bool closed, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer) { mitk::Point2D rightMostPoint; rightMostPoint.Fill(itk::NumericTraits::min()); // transform all vertices into Point2Ds in display-Coordinates and store them in vector std::vector pointlist; for (auto iter = vertices.cbegin(); iter != vertices.cend(); ++iter) { // Draw this 2D point as OpenGL vertex mitk::Point2D displayPoint; this->TransformObjectToDisplay(*iter, displayPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); pointlist.push_back(displayPoint); if (displayPoint[0] > rightMostPoint[0]) rightMostPoint = displayPoint; } // If the planarfigure is closed, we add the first control point again. // Thus we can always use 'GL_LINE_STRIP' and get rid of strange flickering // effect when using the MESA OpenGL library. if (closed) { mitk::Point2D displayPoint; this->TransformObjectToDisplay( vertices.cbegin()[0], displayPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); pointlist.push_back(displayPoint); } // now paint all the points in one run glBegin(GL_LINE_STRIP); for (auto pointIter = pointlist.cbegin(); pointIter != pointlist.cend(); pointIter++) { glVertex3f((*pointIter)[0], (*pointIter)[1], PLANAR_OFFSET); } glEnd(); anchorPoint = rightMostPoint; } void mitk::PlanarFigureMapper2D::DrawMainLines(mitk::PlanarFigure *figure, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer) { const auto numberOfPolyLines = figure->GetPolyLinesSize(); for (auto loop = 0; loop < numberOfPolyLines; ++loop) { const auto polyline = figure->GetPolyLine(loop); this->PaintPolyLine( polyline, figure->IsClosed(), anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); } } void mitk::PlanarFigureMapper2D::DrawHelperLines(mitk::PlanarFigure *figure, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer) { const auto numberOfHelperPolyLines = figure->GetHelperPolyLinesSize(); // Draw helper objects for (unsigned int loop = 0; loop < numberOfHelperPolyLines; ++loop) { const auto helperPolyLine = figure->GetHelperPolyLine(loop, renderer->GetScaleFactorMMPerDisplayUnit(), renderer->GetViewportSize()[1]); // Check if the current helper objects is to be painted if (!figure->IsHelperToBePainted(loop)) { continue; } // ... and once normally above the shadow. this->PaintPolyLine(helperPolyLine, false, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); } } void mitk::PlanarFigureMapper2D::TransformObjectToDisplay(const mitk::Point2D &point2D, mitk::Point2D &displayPoint, const mitk::PlaneGeometry *objectGeometry, const mitk::PlaneGeometry * /*rendererGeometry*/, const mitk::BaseRenderer *renderer) { mitk::Point3D point3D; // Map circle point from local 2D geometry into 3D world space objectGeometry->Map(point2D, point3D); // Project 3D world point onto display geometry renderer->WorldToDisplay(point3D, displayPoint); } void mitk::PlanarFigureMapper2D::DrawMarker(const mitk::Point2D &point, float *lineColor, float lineOpacity, float *markerColor, float markerOpacity, float lineWidth, PlanarFigureControlPointStyleProperty::Shape shape, const mitk::PlaneGeometry *objectGeometry, const mitk::PlaneGeometry *rendererGeometry, const mitk::BaseRenderer *renderer) { if (this->GetDataNode() != nullptr && this->GetDataNode()->GetDataInteractor().IsNull()) return; if (markerOpacity == 0 && lineOpacity == 0) return; mitk::Point2D displayPoint; this->TransformObjectToDisplay(point, displayPoint, objectGeometry, rendererGeometry, renderer); glColor4f(markerColor[0], markerColor[1], markerColor[2], markerOpacity); glLineWidth(lineWidth); switch (shape) { case PlanarFigureControlPointStyleProperty::Square: default: { // Paint filled square // Disable line antialiasing (does not look nice for squares) glDisable(GL_LINE_SMOOTH); if (markerOpacity > 0) { glRectf(displayPoint[0] - 4, displayPoint[1] - 4, displayPoint[0] + 4, displayPoint[1] + 4); } // Paint outline glColor4f(lineColor[0], lineColor[1], lineColor[2], lineOpacity); glBegin(GL_LINE_LOOP); glVertex3f(displayPoint[0] - 4, displayPoint[1] - 4, PLANAR_OFFSET); glVertex3f(displayPoint[0] - 4, displayPoint[1] + 4, PLANAR_OFFSET); glVertex3f(displayPoint[0] + 4, displayPoint[1] + 4, PLANAR_OFFSET); glVertex3f(displayPoint[0] + 4, displayPoint[1] - 4, PLANAR_OFFSET); glEnd(); break; } case PlanarFigureControlPointStyleProperty::Circle: { float radius = 4.0; if (markerOpacity > 0) { // Paint filled circle glBegin(GL_POLYGON); for (int angle = 0; angle < 8; ++angle) { float angleRad = angle * (float)3.14159 / 4.0; float x = displayPoint[0] + radius * (float)cos(angleRad); float y = displayPoint[1] + radius * (float)sin(angleRad); glVertex3f(x, y, PLANAR_OFFSET); } glEnd(); } // Paint outline glColor4f(lineColor[0], lineColor[1], lineColor[2], lineOpacity); glBegin(GL_LINE_LOOP); for (int angle = 0; angle < 8; ++angle) { float angleRad = angle * (float)3.14159 / 4.0; float x = displayPoint[0] + radius * (float)cos(angleRad); float y = displayPoint[1] + radius * (float)sin(angleRad); glVertex3f(x, y, PLANAR_OFFSET); } glEnd(); break; } } // end switch } void mitk::PlanarFigureMapper2D::InitializeDefaultPlanarFigureProperties() { m_IsSelected = false; m_IsHovering = false; m_DrawOutline = false; m_DrawQuantities = false; m_DrawShadow = false; m_DrawControlPoints = false; m_DrawName = true; m_DrawDashed = false; m_DrawHelperDashed = false; m_AnnotationsShadow = false; m_ShadowWidthFactor = 1.2; m_LineWidth = 1.0; m_OutlineWidth = 4.0; m_HelperlineWidth = 2.0; m_DevicePixelRatio = 1.0; m_ControlPointShape = PlanarFigureControlPointStyleProperty::Square; this->SetColorProperty(m_LineColor, PF_DEFAULT, 1.0, 1.0, 1.0); this->SetFloatProperty(m_LineOpacity, PF_DEFAULT, 1.0); this->SetColorProperty(m_OutlineColor, PF_DEFAULT, 0.0, 0.0, 1.0); this->SetFloatProperty(m_OutlineOpacity, PF_DEFAULT, 1.0); this->SetColorProperty(m_HelperlineColor, PF_DEFAULT, 0.4, 0.8, 0.2); this->SetFloatProperty(m_HelperlineOpacity, PF_DEFAULT, 0.4); this->SetColorProperty(m_MarkerlineColor, PF_DEFAULT, 1.0, 1.0, 1.0); this->SetFloatProperty(m_MarkerlineOpacity, PF_DEFAULT, 1.0); this->SetColorProperty(m_MarkerColor, PF_DEFAULT, 1.0, 1.0, 1.0); this->SetFloatProperty(m_MarkerOpacity, PF_DEFAULT, 0.0); this->SetColorProperty(m_AnnotationColor, PF_DEFAULT, 1.0, 1.0, 1.0); this->SetColorProperty(m_LineColor, PF_HOVER, 1.0, 0.7, 0.0); this->SetFloatProperty(m_LineOpacity, PF_HOVER, 1.0); this->SetColorProperty(m_OutlineColor, PF_HOVER, 0.0, 0.0, 1.0); this->SetFloatProperty(m_OutlineOpacity, PF_HOVER, 1.0); this->SetColorProperty(m_HelperlineColor, PF_HOVER, 0.4, 0.8, 0.2); this->SetFloatProperty(m_HelperlineOpacity, PF_HOVER, 0.4); this->SetColorProperty(m_MarkerlineColor, PF_HOVER, 1.0, 1.0, 1.0); this->SetFloatProperty(m_MarkerlineOpacity, PF_HOVER, 1.0); this->SetColorProperty(m_MarkerColor, PF_HOVER, 1.0, 0.6, 0.0); this->SetFloatProperty(m_MarkerOpacity, PF_HOVER, 0.2); this->SetColorProperty(m_AnnotationColor, PF_HOVER, 1.0, 0.7, 0.0); this->SetColorProperty(m_LineColor, PF_SELECTED, 1.0, 0.0, 0.0); this->SetFloatProperty(m_LineOpacity, PF_SELECTED, 1.0); this->SetColorProperty(m_OutlineColor, PF_SELECTED, 0.0, 0.0, 1.0); this->SetFloatProperty(m_OutlineOpacity, PF_SELECTED, 1.0); this->SetColorProperty(m_HelperlineColor, PF_SELECTED, 0.4, 0.8, 0.2); this->SetFloatProperty(m_HelperlineOpacity, PF_SELECTED, 0.4); this->SetColorProperty(m_MarkerlineColor, PF_SELECTED, 1.0, 1.0, 1.0); this->SetFloatProperty(m_MarkerlineOpacity, PF_SELECTED, 1.0); this->SetColorProperty(m_MarkerColor, PF_SELECTED, 1.0, 0.6, 0.0); this->SetFloatProperty(m_MarkerOpacity, PF_SELECTED, 1.0); this->SetColorProperty(m_AnnotationColor, PF_SELECTED, 1.0, 0.0, 0.0); } void mitk::PlanarFigureMapper2D::InitializePlanarFigurePropertiesFromDataNode(const mitk::DataNode *node) { if (node == NULL) { return; } // if we have not added an observer for ModifiedEvents on the DataNode, // we add one now. if (!m_NodeModifiedObserverAdded) { itk::SimpleMemberCommand::Pointer nodeModifiedCommand = itk::SimpleMemberCommand::New(); nodeModifiedCommand->SetCallbackFunction(this, &mitk::PlanarFigureMapper2D::OnNodeModified); m_NodeModifiedObserverTag = node->AddObserver(itk::ModifiedEvent(), nodeModifiedCommand); m_NodeModifiedObserverAdded = true; } // If the DataNode has not been modified since the last execution of // this method, we do not run it now. if (!m_NodeModified) return; // Mark the current properties as unmodified m_NodeModified = false; // Get Global Opacity float globalOpacity = 1.0; node->GetFloatProperty("opacity", globalOpacity); node->GetBoolProperty("selected", m_IsSelected); node->GetBoolProperty("planarfigure.ishovering", m_IsHovering); node->GetBoolProperty("planarfigure.drawoutline", m_DrawOutline); node->GetBoolProperty("planarfigure.drawshadow", m_DrawShadow); node->GetBoolProperty("planarfigure.drawquantities", m_DrawQuantities); node->GetBoolProperty("planarfigure.drawcontrolpoints", m_DrawControlPoints); node->GetBoolProperty("planarfigure.drawname", m_DrawName); node->GetBoolProperty("planarfigure.drawdashed", m_DrawDashed); node->GetBoolProperty("planarfigure.helperline.drawdashed", m_DrawHelperDashed); node->GetFloatProperty("planarfigure.line.width", m_LineWidth); node->GetFloatProperty("planarfigure.shadow.widthmodifier", m_ShadowWidthFactor); node->GetFloatProperty("planarfigure.outline.width", m_OutlineWidth); node->GetFloatProperty("planarfigure.helperline.width", m_HelperlineWidth); node->GetFloatProperty("planarfigure.devicepixelratio", m_DevicePixelRatio); node->GetStringProperty("planarfigure.annotations.font.family", m_AnnotationFontFamily); node->GetBoolProperty("planarfigure.annotations.font.bold", m_DrawAnnotationBold); node->GetBoolProperty("planarfigure.annotations.font.italic", m_DrawAnnotationItalic); node->GetIntProperty("planarfigure.annotations.font.size", m_AnnotationSize); if (!node->GetBoolProperty("planarfigure.annotations.shadow", m_AnnotationsShadow)) { node->GetBoolProperty("planarfigure.drawshadow", m_AnnotationsShadow); } PlanarFigureControlPointStyleProperty::Pointer styleProperty = dynamic_cast(node->GetProperty("planarfigure.controlpointshape")); if (styleProperty.IsNotNull()) { m_ControlPointShape = styleProperty->GetShape(); } // Set default color and opacity // If property "planarfigure.default.*.color" exists, then use that color. Otherwise global "color" property is used. if (!node->GetColor(m_LineColor[PF_DEFAULT], NULL, "planarfigure.default.line.color")) { node->GetColor(m_LineColor[PF_DEFAULT], NULL, "color"); } node->GetFloatProperty("planarfigure.default.line.opacity", m_LineOpacity[PF_DEFAULT]); if (!node->GetColor(m_OutlineColor[PF_DEFAULT], NULL, "planarfigure.default.outline.color")) { node->GetColor(m_OutlineColor[PF_DEFAULT], NULL, "color"); } node->GetFloatProperty("planarfigure.default.outline.opacity", m_OutlineOpacity[PF_DEFAULT]); if (!node->GetColor(m_HelperlineColor[PF_DEFAULT], NULL, "planarfigure.default.helperline.color")) { node->GetColor(m_HelperlineColor[PF_DEFAULT], NULL, "color"); } node->GetFloatProperty("planarfigure.default.helperline.opacity", m_HelperlineOpacity[PF_DEFAULT]); node->GetColor(m_MarkerlineColor[PF_DEFAULT], NULL, "planarfigure.default.markerline.color"); node->GetFloatProperty("planarfigure.default.markerline.opacity", m_MarkerlineOpacity[PF_DEFAULT]); node->GetColor(m_MarkerColor[PF_DEFAULT], NULL, "planarfigure.default.marker.color"); node->GetFloatProperty("planarfigure.default.marker.opacity", m_MarkerOpacity[PF_DEFAULT]); if (!node->GetColor(m_AnnotationColor[PF_DEFAULT], NULL, "planarfigure.default.annotation.color")) { if (!node->GetColor(m_AnnotationColor[PF_DEFAULT], NULL, "planarfigure.default.line.color")) { node->GetColor(m_AnnotationColor[PF_DEFAULT], NULL, "color"); } } // Set hover color and opacity node->GetColor(m_LineColor[PF_HOVER], NULL, "planarfigure.hover.line.color"); node->GetFloatProperty("planarfigure.hover.line.opacity", m_LineOpacity[PF_HOVER]); node->GetColor(m_OutlineColor[PF_HOVER], NULL, "planarfigure.hover.outline.color"); node->GetFloatProperty("planarfigure.hover.outline.opacity", m_OutlineOpacity[PF_HOVER]); node->GetColor(m_HelperlineColor[PF_HOVER], NULL, "planarfigure.hover.helperline.color"); node->GetFloatProperty("planarfigure.hover.helperline.opacity", m_HelperlineOpacity[PF_HOVER]); node->GetColor(m_MarkerlineColor[PF_HOVER], NULL, "planarfigure.hover.markerline.color"); node->GetFloatProperty("planarfigure.hover.markerline.opacity", m_MarkerlineOpacity[PF_HOVER]); node->GetColor(m_MarkerColor[PF_HOVER], NULL, "planarfigure.hover.marker.color"); node->GetFloatProperty("planarfigure.hover.marker.opacity", m_MarkerOpacity[PF_HOVER]); if (!node->GetColor(m_AnnotationColor[PF_HOVER], NULL, "planarfigure.hover.annotation.color")) { if (!node->GetColor(m_AnnotationColor[PF_HOVER], NULL, "planarfigure.hover.line.color")) { node->GetColor(m_AnnotationColor[PF_HOVER], NULL, "color"); } } // Set selected color and opacity node->GetColor(m_LineColor[PF_SELECTED], NULL, "planarfigure.selected.line.color"); node->GetFloatProperty("planarfigure.selected.line.opacity", m_LineOpacity[PF_SELECTED]); node->GetColor(m_OutlineColor[PF_SELECTED], NULL, "planarfigure.selected.outline.color"); node->GetFloatProperty("planarfigure.selected.outline.opacity", m_OutlineOpacity[PF_SELECTED]); node->GetColor(m_HelperlineColor[PF_SELECTED], NULL, "planarfigure.selected.helperline.color"); node->GetFloatProperty("planarfigure.selected.helperline.opacity", m_HelperlineOpacity[PF_SELECTED]); node->GetColor(m_MarkerlineColor[PF_SELECTED], NULL, "planarfigure.selected.markerline.color"); node->GetFloatProperty("planarfigure.selected.markerline.opacity", m_MarkerlineOpacity[PF_SELECTED]); node->GetColor(m_MarkerColor[PF_SELECTED], NULL, "planarfigure.selected.marker.color"); node->GetFloatProperty("planarfigure.selected.marker.opacity", m_MarkerOpacity[PF_SELECTED]); if (!node->GetColor(m_AnnotationColor[PF_SELECTED], NULL, "planarfigure.selected.annotation.color")) { if (!node->GetColor(m_AnnotationColor[PF_SELECTED], NULL, "planarfigure.selected.line.color")) { node->GetColor(m_AnnotationColor[PF_SELECTED], NULL, "color"); } } // adapt opacity values to global "opacity" property for (unsigned int i = 0; i < PF_COUNT; ++i) { m_LineOpacity[i] *= globalOpacity; m_OutlineOpacity[i] *= globalOpacity; m_HelperlineOpacity[i] *= globalOpacity; m_MarkerlineOpacity[i] *= globalOpacity; m_MarkerOpacity[i] *= globalOpacity; } } void mitk::PlanarFigureMapper2D::OnNodeModified() { m_NodeModified = true; } void mitk::PlanarFigureMapper2D::SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite) { node->AddProperty("visible", mitk::BoolProperty::New(true), renderer, overwrite); // node->SetProperty("planarfigure.iseditable",mitk::BoolProperty::New(true)); node->AddProperty("planarfigure.isextendable", mitk::BoolProperty::New(false)); // node->AddProperty( "planarfigure.ishovering", mitk::BoolProperty::New(true) ); node->AddProperty("planarfigure.drawoutline", mitk::BoolProperty::New(false)); // node->AddProperty( "planarfigure.drawquantities", mitk::BoolProperty::New(true) ); node->AddProperty("planarfigure.drawshadow", mitk::BoolProperty::New(true)); node->AddProperty("planarfigure.drawcontrolpoints", mitk::BoolProperty::New(true)); node->AddProperty("planarfigure.drawname", mitk::BoolProperty::New(true)); node->AddProperty("planarfigure.drawdashed", mitk::BoolProperty::New(false)); node->AddProperty("planarfigure.helperline.drawdashed", mitk::BoolProperty::New(false)); node->AddProperty("planarfigure.annotations.font.family", mitk::StringProperty::New("Arial")); node->AddProperty("planarfigure.annotations.font.bold", mitk::BoolProperty::New(false)); node->AddProperty("planarfigure.annotations.font.italic", mitk::BoolProperty::New(false)); node->AddProperty("planarfigure.annotations.font.size", mitk::IntProperty::New(12)); node->AddProperty("planarfigure.line.width", mitk::FloatProperty::New(2.0)); node->AddProperty("planarfigure.shadow.widthmodifier", mitk::FloatProperty::New(2.0)); node->AddProperty("planarfigure.outline.width", mitk::FloatProperty::New(2.0)); node->AddProperty("planarfigure.helperline.width", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.default.line.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.default.outline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.default.helperline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.default.markerline.color", mitk::ColorProperty::New(1.0, 1.0, 1.0)); node->AddProperty("planarfigure.default.markerline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.default.marker.color", mitk::ColorProperty::New(1.0, 1.0, 1.0)); node->AddProperty("planarfigure.default.marker.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.hover.line.color", mitk::ColorProperty::New(0.0, 1.0, 0.0)); node->AddProperty("planarfigure.hover.line.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.hover.outline.color", mitk::ColorProperty::New(0.0, 1.0, 0.0)); node->AddProperty("planarfigure.hover.outline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.hover.helperline.color", mitk::ColorProperty::New(0.0, 1.0, 0.0)); node->AddProperty("planarfigure.hover.helperline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.hover.markerline.color", mitk::ColorProperty::New(0.0, 1.0, 0.0)); node->AddProperty("planarfigure.hover.markerline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.hover.marker.color", mitk::ColorProperty::New(0.0, 1.0, 0.0)); node->AddProperty("planarfigure.hover.marker.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.selected.line.color", mitk::ColorProperty::New(1.0, 0.0, 0.0)); node->AddProperty("planarfigure.selected.line.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.selected.outline.color", mitk::ColorProperty::New(1.0, 0.0, 0.0)); node->AddProperty("planarfigure.selected.outline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.selected.helperline.color", mitk::ColorProperty::New(1.0, 0.0, 0.0)); node->AddProperty("planarfigure.selected.helperline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.selected.markerline.color", mitk::ColorProperty::New(1.0, 0.0, 0.0)); node->AddProperty("planarfigure.selected.markerline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty("planarfigure.selected.marker.color", mitk::ColorProperty::New(1.0, 0.0, 0.0)); node->AddProperty("planarfigure.selected.marker.opacity", mitk::FloatProperty::New(1.0)); } void mitk::PlanarFigureMapper2D::RenderControlPoints(const mitk::PlanarFigure *planarFigure, const PlanarFigureDisplayMode lineDisplayMode, const mitk::PlaneGeometry *planarFigurePlaneGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, mitk::BaseRenderer *renderer) { bool isEditable = true; m_DataNode->GetBoolProperty("planarfigure.iseditable", isEditable); PlanarFigureDisplayMode pointDisplayMode = PF_DEFAULT; const unsigned int selectedControlPointsIdx = (unsigned int)planarFigure->GetSelectedControlPoint(); const unsigned int numberOfControlPoints = planarFigure->GetNumberOfControlPoints(); // Draw markers at control points (selected control point will be colored) for (unsigned int i = 0; i < numberOfControlPoints; ++i) { // Only if planar figure is marked as editable: display markers (control points) in a // different style if mouse is over them or they are selected if (isEditable) { if (i == selectedControlPointsIdx) { pointDisplayMode = PF_SELECTED; } else if (m_IsHovering && isEditable) { pointDisplayMode = PF_HOVER; } } if (m_MarkerOpacity[pointDisplayMode] == 0 && m_MarkerlineOpacity[pointDisplayMode] == 0) { continue; } if (m_DrawOutline) { // draw outlines for markers as well // linewidth for the contour is only half, as full width looks // much too thick! this->DrawMarker(planarFigure->GetControlPoint(i), m_OutlineColor[lineDisplayMode], m_MarkerlineOpacity[pointDisplayMode], m_OutlineColor[lineDisplayMode], m_MarkerOpacity[pointDisplayMode], m_OutlineWidth / 2, m_ControlPointShape, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); } this->DrawMarker(planarFigure->GetControlPoint(i), m_MarkerlineColor[pointDisplayMode], m_MarkerlineOpacity[pointDisplayMode], m_MarkerColor[pointDisplayMode], m_MarkerOpacity[pointDisplayMode], m_LineWidth, m_ControlPointShape, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); } if (planarFigure->IsPreviewControlPointVisible()) { this->DrawMarker(planarFigure->GetPreviewControlPoint(), m_MarkerlineColor[PF_HOVER], m_MarkerlineOpacity[PF_HOVER], m_MarkerColor[PF_HOVER], m_MarkerOpacity[PF_HOVER], m_LineWidth, m_ControlPointShape, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); } } void mitk::PlanarFigureMapper2D::RenderAnnotations(mitk::BaseRenderer *renderer, const std::string name, const mitk::Point2D anchorPoint, float globalOpacity, const PlanarFigureDisplayMode lineDisplayMode, double &annotationOffset) { if (anchorPoint[0] < mitk::eps || anchorPoint[1] < mitk::eps) { return; } - m_AnnotationOverlay->SetText(name); - m_AnnotationOverlay->SetColor(m_AnnotationColor[lineDisplayMode][0], + m_AnnotationAnnotation->SetText(name); + m_AnnotationAnnotation->SetColor(m_AnnotationColor[lineDisplayMode][0], m_AnnotationColor[lineDisplayMode][1], m_AnnotationColor[lineDisplayMode][2]); - m_AnnotationOverlay->SetOpacity(globalOpacity); - m_AnnotationOverlay->SetFontSize(m_AnnotationSize * m_DevicePixelRatio); - m_AnnotationOverlay->SetBoolProperty("drawShadow", m_AnnotationsShadow); - m_AnnotationOverlay->SetVisibility(true); - m_AnnotationOverlay->SetStringProperty("font.family", m_AnnotationFontFamily); - m_AnnotationOverlay->SetBoolProperty("font.bold", m_DrawAnnotationBold); - m_AnnotationOverlay->SetBoolProperty("font.italic", m_DrawAnnotationItalic); + m_AnnotationAnnotation->SetOpacity(globalOpacity); + m_AnnotationAnnotation->SetFontSize(m_AnnotationSize * m_DevicePixelRatio); + m_AnnotationAnnotation->SetBoolProperty("drawShadow", m_AnnotationsShadow); + m_AnnotationAnnotation->SetVisibility(true); + m_AnnotationAnnotation->SetStringProperty("font.family", m_AnnotationFontFamily); + m_AnnotationAnnotation->SetBoolProperty("font.bold", m_DrawAnnotationBold); + m_AnnotationAnnotation->SetBoolProperty("font.italic", m_DrawAnnotationItalic); mitk::Point2D offset; offset.Fill(5); mitk::Point2D scaledAnchorPoint; scaledAnchorPoint[0] = anchorPoint[0] * m_DevicePixelRatio; scaledAnchorPoint[1] = anchorPoint[1] * m_DevicePixelRatio; offset[0] = offset[0] * m_DevicePixelRatio; offset[1] = offset[1] * m_DevicePixelRatio; - m_AnnotationOverlay->SetPosition2D(scaledAnchorPoint); - m_AnnotationOverlay->SetOffsetVector(offset); + m_AnnotationAnnotation->SetPosition2D(scaledAnchorPoint); + m_AnnotationAnnotation->SetOffsetVector(offset); - m_AnnotationOverlay->Update(renderer); - m_AnnotationOverlay->Paint(renderer); + m_AnnotationAnnotation->Update(renderer); + m_AnnotationAnnotation->Paint(renderer); annotationOffset -= 15.0; - // annotationOffset -= m_AnnotationOverlay->GetBoundsOnDisplay( renderer ).Size[1]; + // annotationOffset -= m_AnnotationAnnotation->GetBoundsOnDisplay( renderer ).Size[1]; } void mitk::PlanarFigureMapper2D::RenderQuantities(const mitk::PlanarFigure *planarFigure, mitk::BaseRenderer *renderer, const mitk::Point2D anchorPoint, double &annotationOffset, float globalOpacity, const PlanarFigureDisplayMode lineDisplayMode) { if (anchorPoint[0] < mitk::eps || anchorPoint[1] < mitk::eps) { return; } std::stringstream quantityString; quantityString.setf(ios::fixed, ios::floatfield); quantityString.precision(1); bool firstActiveFeature = true; for (unsigned int i = 0; i < planarFigure->GetNumberOfFeatures(); ++i) { if (planarFigure->IsFeatureActive(i) && planarFigure->IsFeatureVisible(i)) { if (!firstActiveFeature) { quantityString << " x "; } quantityString << planarFigure->GetQuantity(i) << " "; quantityString << planarFigure->GetFeatureUnit(i); firstActiveFeature = false; } } - m_QuantityOverlay->SetColor(m_AnnotationColor[lineDisplayMode][0], + m_QuantityAnnotation->SetColor(m_AnnotationColor[lineDisplayMode][0], m_AnnotationColor[lineDisplayMode][1], m_AnnotationColor[lineDisplayMode][2]); - m_QuantityOverlay->SetOpacity(globalOpacity); - m_QuantityOverlay->SetFontSize(m_AnnotationSize * m_DevicePixelRatio); - m_QuantityOverlay->SetBoolProperty("drawShadow", m_DrawShadow); - m_QuantityOverlay->SetVisibility(true); + m_QuantityAnnotation->SetOpacity(globalOpacity); + m_QuantityAnnotation->SetFontSize(m_AnnotationSize * m_DevicePixelRatio); + m_QuantityAnnotation->SetBoolProperty("drawShadow", m_DrawShadow); + m_QuantityAnnotation->SetVisibility(true); - m_AnnotationOverlay->SetStringProperty("font.family", m_AnnotationFontFamily); - m_AnnotationOverlay->SetBoolProperty("font.bold", m_DrawAnnotationBold); - m_AnnotationOverlay->SetBoolProperty("font.italic", m_DrawAnnotationItalic); + m_AnnotationAnnotation->SetStringProperty("font.family", m_AnnotationFontFamily); + m_AnnotationAnnotation->SetBoolProperty("font.bold", m_DrawAnnotationBold); + m_AnnotationAnnotation->SetBoolProperty("font.italic", m_DrawAnnotationItalic); - m_QuantityOverlay->SetText(quantityString.str().c_str()); + m_QuantityAnnotation->SetText(quantityString.str().c_str()); mitk::Point2D offset; offset.Fill(5); offset[1] += annotationOffset; mitk::Point2D scaledAnchorPoint; scaledAnchorPoint[0] = anchorPoint[0] * m_DevicePixelRatio; scaledAnchorPoint[1] = anchorPoint[1] * m_DevicePixelRatio; offset[0] = offset[0] * m_DevicePixelRatio; offset[1] = offset[1] * m_DevicePixelRatio; - m_QuantityOverlay->SetPosition2D(scaledAnchorPoint); - m_QuantityOverlay->SetOffsetVector(offset); + m_QuantityAnnotation->SetPosition2D(scaledAnchorPoint); + m_QuantityAnnotation->SetOffsetVector(offset); - m_QuantityOverlay->Update(renderer); - m_QuantityOverlay->Paint(renderer); - // annotationOffset -= m_QuantityOverlay->GetBoundsOnDisplay( renderer ).Size[1]; + m_QuantityAnnotation->Update(renderer); + m_QuantityAnnotation->Paint(renderer); + // annotationOffset -= m_QuantityAnnotation->GetBoundsOnDisplay( renderer ).Size[1]; annotationOffset -= 15.0; } void mitk::PlanarFigureMapper2D::RenderLines(const PlanarFigureDisplayMode lineDisplayMode, mitk::PlanarFigure *planarFigure, mitk::Point2D &anchorPoint, const mitk::PlaneGeometry *planarFigurePlaneGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer) { glLineStipple(1, 0x00FF); // If we want to draw an outline, we do it here if (m_DrawOutline) { const float *color = m_OutlineColor[lineDisplayMode]; const float opacity = m_OutlineOpacity[lineDisplayMode]; // convert to a float array that also contains opacity, faster GL float *colorVector = new float[4]; colorVector[0] = color[0]; colorVector[1] = color[1]; colorVector[2] = color[2]; colorVector[3] = opacity; // set the color and opacity here as it is common for all outlines glColor4fv(colorVector); glLineWidth(m_OutlineWidth); if (m_DrawDashed) glEnable(GL_LINE_STIPPLE); else glDisable(GL_LINE_STIPPLE); // Draw the outline for all polylines if requested this->DrawMainLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); glLineWidth(m_HelperlineWidth); if (m_DrawHelperDashed) glEnable(GL_LINE_STIPPLE); else glDisable(GL_LINE_STIPPLE); // Draw the outline for all helper objects if requested this->DrawHelperLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); // cleanup delete[] colorVector; } // If we want to draw a shadow, we do it here if (m_DrawShadow) { // determine the shadow opacity const float opacity = m_OutlineOpacity[lineDisplayMode]; float shadowOpacity = 0.0f; if (opacity > 0.2f) shadowOpacity = opacity - 0.2f; // convert to a float array that also contains opacity, faster GL float *shadow = new float[4]; shadow[0] = 0; shadow[1] = 0; shadow[2] = 0; shadow[3] = shadowOpacity; // set the color and opacity here as it is common for all shadows glColor4fv(shadow); glLineWidth(m_OutlineWidth * m_ShadowWidthFactor); if (m_DrawDashed) glEnable(GL_LINE_STIPPLE); else glDisable(GL_LINE_STIPPLE); // Draw the outline for all polylines if requested this->DrawMainLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); glLineWidth(m_HelperlineWidth); if (m_DrawHelperDashed) glEnable(GL_LINE_STIPPLE); else glDisable(GL_LINE_STIPPLE); // Draw the outline for all helper objects if requested this->DrawHelperLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); // cleanup delete[] shadow; } // set this in brackets to avoid duplicate variables in the same scope { const float *color = m_LineColor[lineDisplayMode]; const float opacity = m_LineOpacity[lineDisplayMode]; // convert to a float array that also contains opacity, faster GL float *colorVector = new float[4]; colorVector[0] = color[0]; colorVector[1] = color[1]; colorVector[2] = color[2]; colorVector[3] = opacity; // set the color and opacity here as it is common for all mainlines glColor4fv(colorVector); glLineWidth(m_LineWidth); if (m_DrawDashed) glEnable(GL_LINE_STIPPLE); else glDisable(GL_LINE_STIPPLE); // Draw the main line for all polylines this->DrawMainLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); const float *helperColor = m_HelperlineColor[lineDisplayMode]; const float helperOpacity = m_HelperlineOpacity[lineDisplayMode]; // convert to a float array that also contains opacity, faster GL float *helperColorVector = new float[4]; helperColorVector[0] = helperColor[0]; helperColorVector[1] = helperColor[1]; helperColorVector[2] = helperColor[2]; helperColorVector[3] = helperOpacity; // we only set the color for the helperlines as the linewidth is unchanged glColor4fv(helperColorVector); glLineWidth(m_HelperlineWidth); if (m_DrawHelperDashed) glEnable(GL_LINE_STIPPLE); else glDisable(GL_LINE_STIPPLE); // Draw helper objects this->DrawHelperLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer); // cleanup delete[] colorVector; delete[] helperColorVector; } if (m_DrawDashed || m_DrawHelperDashed) glDisable(GL_LINE_STIPPLE); } diff --git a/Modules/QmlItems/include/QmlAxisOverlay.h b/Modules/QmlItems/include/QmlAxisOverlay.h index 751249060b..dfd3bac4a4 100644 --- a/Modules/QmlItems/include/QmlAxisOverlay.h +++ b/Modules/QmlItems/include/QmlAxisOverlay.h @@ -1,83 +1,80 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkAxisOverlay_h #define __mitkAxisOverlay_h -#include #include +#include #include #include #include #include -namespace mitk { - class AxisOverlay : public mitk::VtkOverlay { +namespace mitk +{ + class AxisOverlay : public mitk::VtkAnnotation + { public: - class LocalStorage : public mitk::VtkOverlay::BaseLocalStorage + class LocalStorage : public mitk::VtkAnnotation::BaseLocalStorage { public: /** \brief Actor of a 2D render window. */ bool m_initialized = false; vtkSmartPointer m_axesActor; vtkSmartPointer m_widget; vtkSmartPointer m_dummyActor; vtkSmartPointer m_dummyMapper; vtkSmartPointer m_dummySource; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastUpdateTime; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage(); - }; - mitkClassMacro(AxisOverlay, mitk::VtkOverlay); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) + mitkClassMacro(AxisOverlay, mitk::VtkAnnotation); + itkFactorylessNewMacro(Self) itkCloneMacro(Self) - protected: + protected : - /** \brief The LocalStorageHandler holds all LocalStorages for the render windows. */ - mutable mitk::LocalStorageHandler m_LSH; + /** \brief The LocalStorageHandler holds all LocalStorages for the render windows. */ + mutable mitk::LocalStorageHandler m_LSH; - virtual vtkProp* GetVtkProp(BaseRenderer *renderer) const; - void UpdateVtkOverlay(mitk::BaseRenderer *renderer); + virtual vtkProp *GetVtkProp(BaseRenderer *renderer) const; + void UpdateVtkAnnotation(mitk::BaseRenderer *renderer); /** \brief explicit constructor which disallows implicit conversions */ explicit AxisOverlay(); /** \brief virtual destructor in order to derive from this class */ virtual ~AxisOverlay(); private: - /** \brief copy constructor */ AxisOverlay(const AxisOverlay &); /** \brief assignment operator */ AxisOverlay &operator=(const AxisOverlay &); - }; - } #endif diff --git a/Modules/QmlItems/src/QmlAxisOverlay.cpp b/Modules/QmlItems/src/QmlAxisOverlay.cpp index 011b6fb3e3..9a32ecd860 100644 --- a/Modules/QmlItems/src/QmlAxisOverlay.cpp +++ b/Modules/QmlItems/src/QmlAxisOverlay.cpp @@ -1,68 +1,67 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ - #include "QmlAxisOverlay.h" -#include #include #include +#include //#include "Util_Debug.h" #include "mitkPoint.h" mitk::AxisOverlay::AxisOverlay() { } mitk::AxisOverlay::~AxisOverlay() { } mitk::AxisOverlay::LocalStorage::~LocalStorage() { } mitk::AxisOverlay::LocalStorage::LocalStorage() { this->m_axesActor = vtkSmartPointer::New(); this->m_widget = vtkSmartPointer::New(); this->m_dummyActor = vtkSmartPointer::New(); this->m_dummyMapper = vtkSmartPointer::New(); this->m_dummySource = vtkSmartPointer::New(); this->m_dummyMapper->SetInputConnection(m_dummySource->GetOutputPort()); this->m_dummyActor->SetMapper(this->m_dummyMapper); this->m_dummyActor->SetVisibility(false); this->m_dummyActor->GetProperty()->SetOpacity(0.0); } -void mitk::AxisOverlay::UpdateVtkOverlay(mitk::BaseRenderer *renderer) +void mitk::AxisOverlay::UpdateVtkAnnotation(mitk::BaseRenderer *renderer) { - LocalStorage* ls = this->m_LSH.GetLocalStorage(renderer); + LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); if (ls->IsGenerateDataRequired(renderer, this)) { ls->m_widget->SetOrientationMarker(ls->m_axesActor); ls->m_widget->SetInteractor(renderer->GetRenderWindow()->GetInteractor()); ls->m_widget->SetEnabled(true); ls->m_widget->SetOutlineColor(0.3, 0, 0); ls->m_widget->SetInteractive(true); ls->m_initialized = true; } } -vtkProp* mitk::AxisOverlay::GetVtkProp(BaseRenderer *renderer) const +vtkProp *mitk::AxisOverlay::GetVtkProp(BaseRenderer *renderer) const { - LocalStorage* ls = this->m_LSH.GetLocalStorage(renderer); + LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); return ls->m_dummyActor; } diff --git a/Modules/QtWidgets/CMakeLists.txt b/Modules/QtWidgets/CMakeLists.txt index 39683dcb7d..65a44f75f5 100644 --- a/Modules/QtWidgets/CMakeLists.txt +++ b/Modules/QtWidgets/CMakeLists.txt @@ -1,9 +1,9 @@ MITK_CREATE_MODULE( INCLUDE_DIRS PRIVATE resource # for xpm includes - DEPENDS MitkPlanarFigure MitkOverlays + DEPENDS MitkPlanarFigure MitkAnnotation PACKAGE_DEPENDS PUBLIC ITK|ITKIOImageBase VTK|vtkGUISupportQt+vtkGUISupportQtOpenGL Qt5|Widgets+OpenGL+Core SUBPROJECTS MITK-CoreUI ) add_subdirectory(test) diff --git a/Modules/QtWidgets/include/QmitkStdMultiWidget.h b/Modules/QtWidgets/include/QmitkStdMultiWidget.h index b676e35f55..cb7b47fc42 100644 --- a/Modules/QtWidgets/include/QmitkStdMultiWidget.h +++ b/Modules/QtWidgets/include/QmitkStdMultiWidget.h @@ -1,429 +1,429 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkStdMultiWidget_h #define QmitkStdMultiWidget_h #include "MitkQtWidgetsExports.h" #include -#include +#include #include #include #include #include #include #include #include class QHBoxLayout; class QVBoxLayout; class QGridLayout; class QSpacerItem; class QmitkLevelWindowWidget; class QmitkRenderWindow; class vtkCornerAnnotation; class vtkMitkRectangleProp; namespace mitk { class RenderingManager; } /// \ingroup QmitkModule class MITKQTWIDGETS_EXPORT QmitkStdMultiWidget : public QWidget { Q_OBJECT public: QmitkStdMultiWidget( QWidget *parent = 0, Qt::WindowFlags f = 0, mitk::RenderingManager *renderingManager = 0, mitk::BaseRenderer::RenderingMode::Type renderingMode = mitk::BaseRenderer::RenderingMode::Standard, const QString &name = "stdmulti"); virtual ~QmitkStdMultiWidget(); mitk::SliceNavigationController *GetTimeNavigationController(); void RequestUpdate(); void ForceImmediateUpdate(); mitk::MouseModeSwitcher *GetMouseModeSwitcher(); QmitkRenderWindow *GetRenderWindow1() const; QmitkRenderWindow *GetRenderWindow2() const; QmitkRenderWindow *GetRenderWindow3() const; QmitkRenderWindow *GetRenderWindow4() const; const mitk::Point3D GetCrossPosition() const; void EnablePositionTracking(); void DisablePositionTracking(); int GetLayout() const; bool GetGradientBackgroundFlag() const; /*! \brief Access node of widget plane 1 \return DataNode holding widget plane 1 */ mitk::DataNode::Pointer GetWidgetPlane1(); /*! \brief Access node of widget plane 2 \return DataNode holding widget plane 2 */ mitk::DataNode::Pointer GetWidgetPlane2(); /*! \brief Access node of widget plane 3 \return DataNode holding widget plane 3 */ mitk::DataNode::Pointer GetWidgetPlane3(); /*! \brief Convenience method to access node of widget planes \param id number of widget plane to be returned \return DataNode holding widget plane 3 */ mitk::DataNode::Pointer GetWidgetPlane(int id); bool IsColoredRectanglesEnabled() const; bool IsDepartmentLogoEnabled() const; void InitializeWidget(); /// called when the StdMultiWidget is closed to remove the 3 widget planes and the helper node from the DataStorage void RemovePlanesFromDataStorage(); void AddPlanesToDataStorage(); void SetDataStorage(mitk::DataStorage *ds); /** \brief Listener to the CrosshairPositionEvent Ensures the CrosshairPositionEvent is handled only once and at the end of the Qt-Event loop */ void HandleCrosshairPositionEvent(); /// activate Menu Widget. true: activated, false: deactivated void ActivateMenuWidget(bool state); bool IsMenuWidgetEnabled() const; void SetCornerAnnotationVisibility(bool visibility); bool IsCornerAnnotationVisible(void) const; protected: void UpdateAllWidgets(); void HideAllWidgetToolbars(); mitk::DataNode::Pointer GetTopLayerNode(mitk::DataStorage::SetOfObjects::ConstPointer nodes); public slots: /// Receives the signal from HandleCrosshairPositionEvent, executes the StatusBar update void HandleCrosshairPositionEventDelayed(); void changeLayoutTo2DImagesUp(); void changeLayoutTo2DImagesLeft(); void changeLayoutToDefault(); void changeLayoutToBig3D(); void changeLayoutToWidget1(); void changeLayoutToWidget2(); void changeLayoutToWidget3(); void changeLayoutToRowWidget3And4(); void changeLayoutToColumnWidget3And4(); void changeLayoutToRowWidgetSmall3andBig4(); void changeLayoutToSmallUpperWidget2Big3and4(); void changeLayoutTo2x2Dand3DWidget(); void changeLayoutToLeft2Dand3DRight2D(); void changeLayoutTo2DUpAnd3DDown(); void Fit(); void InitPositionTracking(); void AddDisplayPlaneSubTree(); void EnableStandardLevelWindow(); void DisableStandardLevelWindow(); bool InitializeStandardViews(const mitk::Geometry3D *geometry); void wheelEvent(QWheelEvent *e) override; void mousePressEvent(QMouseEvent *e) override; void moveEvent(QMoveEvent *e) override; void EnsureDisplayContainsPoint(mitk::BaseRenderer *renderer, const mitk::Point3D &p); void MoveCrossToPosition(const mitk::Point3D &newPosition); // void EnableNavigationControllerEventListening(); // void DisableNavigationControllerEventListening(); void EnableGradientBackground(); void DisableGradientBackground(); void EnableDepartmentLogo(); void DisableDepartmentLogo(); void EnableColoredRectangles(); void DisableColoredRectangles(); void SetWidgetPlaneVisibility(const char *widgetName, bool visible, mitk::BaseRenderer *renderer = NULL); void SetWidgetPlanesVisibility(bool visible, mitk::BaseRenderer *renderer = NULL); void SetWidgetPlanesLocked(bool locked); void SetWidgetPlanesRotationLocked(bool locked); void SetWidgetPlanesRotationLinked(bool link); void SetWidgetPlaneMode(int mode); void SetGradientBackgroundColors(const mitk::Color &upper, const mitk::Color &lower); void SetDepartmentLogoPath(const char *path); void SetWidgetPlaneModeToSlicing(bool activate); void SetWidgetPlaneModeToRotation(bool activate); void SetWidgetPlaneModeToSwivel(bool activate); void OnLayoutDesignChanged(int layoutDesignIndex); void ResetCrosshair(); signals: void LeftMouseClicked(mitk::Point3D pointValue); void WheelMoved(QWheelEvent *); void WidgetPlanesRotationLinked(bool); void WidgetPlanesRotationEnabled(bool); void ViewsInitialized(); void WidgetPlaneModeSlicing(bool); void WidgetPlaneModeRotation(bool); void WidgetPlaneModeSwivel(bool); void WidgetPlaneModeChange(int); void WidgetNotifyNewCrossHairMode(int); void Moved(); public: /** Define RenderWindow (public)*/ QmitkRenderWindow *mitkWidget1; QmitkRenderWindow *mitkWidget2; QmitkRenderWindow *mitkWidget3; QmitkRenderWindow *mitkWidget4; QmitkLevelWindowWidget *levelWindowWidget; /********************************/ enum { PLANE_MODE_SLICING = 0, PLANE_MODE_ROTATION, PLANE_MODE_SWIVEL }; enum { LAYOUT_DEFAULT = 0, LAYOUT_2D_IMAGES_UP, LAYOUT_2D_IMAGES_LEFT, LAYOUT_BIG_3D, LAYOUT_WIDGET1, LAYOUT_WIDGET2, LAYOUT_WIDGET3, LAYOUT_2X_2D_AND_3D_WIDGET, LAYOUT_ROW_WIDGET_3_AND_4, LAYOUT_COLUMN_WIDGET_3_AND_4, LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4, LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4, LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET, LAYOUT_2D_UP_AND_3D_DOWN }; enum { AXIAL, SAGITTAL, CORONAL, THREE_D }; /** * @brief SetCornerAnnotation Create a corner annotation for a widget. * @param text The text of the annotation. * @param color The color. * @param widgetNumber The widget (0-3). */ void SetDecorationProperties(std::string text, mitk::Color color, int widgetNumber); /** * @brief GetRenderWindow convinience method to get a widget. * @param number of the widget (0-3) * @return The renderwindow widget. */ QmitkRenderWindow *GetRenderWindow(unsigned int number); /** * @brief SetGradientBackgroundColorForRenderWindow background for a widget. * * If two different input colors are, a gradient background is generated. * * @param upper Upper color of the gradient background. * @param lower Lower color of the gradient background. * @param widgetNumber The widget (0-3). */ void SetGradientBackgroundColorForRenderWindow(const mitk::Color &upper, const mitk::Color &lower, unsigned int widgetNumber); /** * @brief GetDecorationColorForWidget Get the color for annotation, crosshair and rectangle. * @param widgetNumber Number of the renderwindow (0-3). * @return Color in mitk format. */ mitk::Color GetDecorationColor(unsigned int widgetNumber); /** * @brief SetDecorationColor Set the color of the decoration of the 4 widgets. * * This is used to color the frame of the renderwindow and the corner annatation. * For the first 3 widgets, this color is a property of the helper object nodes * which contain the respective plane geometry. For widget 4, this is a member, * since there is no data node for this widget. */ void SetDecorationColor(unsigned int widgetNumber, mitk::Color color); /** * @brief GetCornerAnnotationText Getter for corner annotation text. * @param widgetNumber the widget number (0-3). * @return The text in the corner annotation. */ std::string GetCornerAnnotationText(unsigned int widgetNumber); /** * @brief GetGradientColors Getter for gradientbackground colors. * @param widgetNumber the widget number (0-3). * @return A pair of colors. First: upper, second: lower. */ std::pair GetGradientColors(unsigned int widgetNumber); protected: QHBoxLayout *QmitkStdMultiWidgetLayout; int m_Layout; int m_PlaneMode; mitk::RenderingManager *m_RenderingManager; - mitk::LogoOverlay::Pointer m_LogoRendering; + mitk::LogoAnnotation::Pointer m_LogoRendering; bool m_GradientBackgroundFlag; mitk::MouseModeSwitcher::Pointer m_MouseModeSwitcher; mitk::SliceNavigationController *m_TimeNavigationController; mitk::DataStorage::Pointer m_DataStorage; /** * @brief m_PlaneNode1 the 3 helper objects which contain the plane geometry. */ mitk::DataNode::Pointer m_PlaneNode1; mitk::DataNode::Pointer m_PlaneNode2; mitk::DataNode::Pointer m_PlaneNode3; /** * @brief m_ParentNodeForGeometryPlanes This helper object is added to the datastorage * and contains the 3 planes for displaying the image geometry (crosshair and 3D planes). */ mitk::DataNode::Pointer m_ParentNodeForGeometryPlanes; /** * @brief m_DecorationColorWidget4 color for annotation and rectangle of widget 4. * * For other widgets1-3, the color is a property of the respective data node. * There is no node for widget 4, hence, we need an extra member. */ mitk::Color m_DecorationColorWidget4; /** * @brief m_GradientBackgroundColors Contains the colors of the gradient background. * */ std::pair m_GradientBackgroundColors[4]; QSplitter *m_MainSplit; QSplitter *m_LayoutSplit; QSplitter *m_SubSplit1; QSplitter *m_SubSplit2; QWidget *mitkWidget1Container; QWidget *mitkWidget2Container; QWidget *mitkWidget3Container; QWidget *mitkWidget4Container; vtkSmartPointer m_CornerAnnotations[4]; vtkSmartPointer m_RectangleProps[4]; bool m_PendingCrosshairPositionEvent; bool m_CrosshairNavigationEnabled; /** * @brief CreateCornerAnnotation helper method to create a corner annotation. * @param text of the annotation. * @param color of the annotation. * @return the complete CornerAnnotation. */ vtkSmartPointer CreateCornerAnnotation(std::string text, mitk::Color color); /** * @brief FillGradientBackgroundWithBlack Internal helper method to initialize the * gradient background colors with black. */ void FillGradientBackgroundWithBlack(); }; #endif /*QmitkStdMultiWidget_h*/ diff --git a/Modules/QtWidgets/src/QmitkStdMultiWidget.cpp b/Modules/QtWidgets/src/QmitkStdMultiWidget.cpp index 99adc3ea26..500968e857 100644 --- a/Modules/QtWidgets/src/QmitkStdMultiWidget.cpp +++ b/Modules/QtWidgets/src/QmitkStdMultiWidget.cpp @@ -1,2021 +1,2021 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #define SMW_INFO MITK_INFO("widget.stdmulti") #include "QmitkStdMultiWidget.h" #include #include #include #include #include #include #include #include "mitkImagePixelReadAccessor.h" #include "mitkPixelTypeMultiplex.h" -#include +#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include QmitkStdMultiWidget::QmitkStdMultiWidget(QWidget *parent, Qt::WindowFlags f, mitk::RenderingManager *renderingManager, mitk::BaseRenderer::RenderingMode::Type renderingMode, const QString &name) : QWidget(parent, f), mitkWidget1(NULL), mitkWidget2(NULL), mitkWidget3(NULL), mitkWidget4(NULL), levelWindowWidget(NULL), QmitkStdMultiWidgetLayout(NULL), m_Layout(LAYOUT_DEFAULT), m_PlaneMode(PLANE_MODE_SLICING), m_RenderingManager(renderingManager), m_GradientBackgroundFlag(true), m_TimeNavigationController(NULL), m_MainSplit(NULL), m_LayoutSplit(NULL), m_SubSplit1(NULL), m_SubSplit2(NULL), mitkWidget1Container(NULL), mitkWidget2Container(NULL), mitkWidget3Container(NULL), mitkWidget4Container(NULL), m_PendingCrosshairPositionEvent(false), m_CrosshairNavigationEnabled(false) { /****************************************************** * Use the global RenderingManager if none was specified * ****************************************************/ if (m_RenderingManager == NULL) { m_RenderingManager = mitk::RenderingManager::GetInstance(); } m_TimeNavigationController = m_RenderingManager->GetTimeNavigationController(); /*******************************/ // Create Widget manually /*******************************/ // create Layouts QmitkStdMultiWidgetLayout = new QHBoxLayout(this); QmitkStdMultiWidgetLayout->setContentsMargins(0, 0, 0, 0); // Set Layout to widget this->setLayout(QmitkStdMultiWidgetLayout); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(Qt::Vertical, m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // create m_SubSplit1 and m_SubSplit2 m_SubSplit1 = new QSplitter(m_LayoutSplit); m_SubSplit2 = new QSplitter(m_LayoutSplit); // creae Widget Container mitkWidget1Container = new QWidget(m_SubSplit1); mitkWidget2Container = new QWidget(m_SubSplit1); mitkWidget3Container = new QWidget(m_SubSplit2); mitkWidget4Container = new QWidget(m_SubSplit2); mitkWidget1Container->setContentsMargins(0, 0, 0, 0); mitkWidget2Container->setContentsMargins(0, 0, 0, 0); mitkWidget3Container->setContentsMargins(0, 0, 0, 0); mitkWidget4Container->setContentsMargins(0, 0, 0, 0); // create Widget Layout QHBoxLayout *mitkWidgetLayout1 = new QHBoxLayout(mitkWidget1Container); QHBoxLayout *mitkWidgetLayout2 = new QHBoxLayout(mitkWidget2Container); QHBoxLayout *mitkWidgetLayout3 = new QHBoxLayout(mitkWidget3Container); QHBoxLayout *mitkWidgetLayout4 = new QHBoxLayout(mitkWidget4Container); m_CornerAnnotations[0] = vtkSmartPointer::New(); m_CornerAnnotations[1] = vtkSmartPointer::New(); m_CornerAnnotations[2] = vtkSmartPointer::New(); m_CornerAnnotations[3] = vtkSmartPointer::New(); m_RectangleProps[0] = vtkSmartPointer::New(); m_RectangleProps[1] = vtkSmartPointer::New(); m_RectangleProps[2] = vtkSmartPointer::New(); m_RectangleProps[3] = vtkSmartPointer::New(); mitkWidgetLayout1->setMargin(0); mitkWidgetLayout2->setMargin(0); mitkWidgetLayout3->setMargin(0); mitkWidgetLayout4->setMargin(0); // set Layout to Widget Container mitkWidget1Container->setLayout(mitkWidgetLayout1); mitkWidget2Container->setLayout(mitkWidgetLayout2); mitkWidget3Container->setLayout(mitkWidgetLayout3); mitkWidget4Container->setLayout(mitkWidgetLayout4); // set SizePolicy mitkWidget1Container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mitkWidget2Container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mitkWidget3Container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mitkWidget4Container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // insert Widget Container into the splitters m_SubSplit1->addWidget(mitkWidget1Container); m_SubSplit1->addWidget(mitkWidget2Container); m_SubSplit2->addWidget(mitkWidget3Container); m_SubSplit2->addWidget(mitkWidget4Container); // Create RenderWindows 1 mitkWidget1 = new QmitkRenderWindow(mitkWidget1Container, name + ".widget1", NULL, m_RenderingManager, renderingMode); mitkWidget1->SetLayoutIndex(AXIAL); mitkWidgetLayout1->addWidget(mitkWidget1); // Create RenderWindows 2 mitkWidget2 = new QmitkRenderWindow(mitkWidget2Container, name + ".widget2", NULL, m_RenderingManager, renderingMode); mitkWidget2->setEnabled(true); mitkWidget2->SetLayoutIndex(SAGITTAL); mitkWidgetLayout2->addWidget(mitkWidget2); // Create RenderWindows 3 mitkWidget3 = new QmitkRenderWindow(mitkWidget3Container, name + ".widget3", NULL, m_RenderingManager, renderingMode); mitkWidget3->SetLayoutIndex(CORONAL); mitkWidgetLayout3->addWidget(mitkWidget3); // Create RenderWindows 4 mitkWidget4 = new QmitkRenderWindow(mitkWidget4Container, name + ".widget4", NULL, m_RenderingManager, renderingMode); mitkWidget4->SetLayoutIndex(THREE_D); mitkWidgetLayout4->addWidget(mitkWidget4); // create SignalSlot Connection connect(mitkWidget1, SIGNAL(SignalLayoutDesignChanged(int)), this, SLOT(OnLayoutDesignChanged(int))); connect(mitkWidget1, SIGNAL(ResetView()), this, SLOT(ResetCrosshair())); connect(mitkWidget1, SIGNAL(ChangeCrosshairRotationMode(int)), this, SLOT(SetWidgetPlaneMode(int))); connect(this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget1, SLOT(OnWidgetPlaneModeChanged(int))); connect(mitkWidget2, SIGNAL(SignalLayoutDesignChanged(int)), this, SLOT(OnLayoutDesignChanged(int))); connect(mitkWidget2, SIGNAL(ResetView()), this, SLOT(ResetCrosshair())); connect(mitkWidget2, SIGNAL(ChangeCrosshairRotationMode(int)), this, SLOT(SetWidgetPlaneMode(int))); connect(this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget2, SLOT(OnWidgetPlaneModeChanged(int))); connect(mitkWidget3, SIGNAL(SignalLayoutDesignChanged(int)), this, SLOT(OnLayoutDesignChanged(int))); connect(mitkWidget3, SIGNAL(ResetView()), this, SLOT(ResetCrosshair())); connect(mitkWidget3, SIGNAL(ChangeCrosshairRotationMode(int)), this, SLOT(SetWidgetPlaneMode(int))); connect(this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget3, SLOT(OnWidgetPlaneModeChanged(int))); connect(mitkWidget4, SIGNAL(SignalLayoutDesignChanged(int)), this, SLOT(OnLayoutDesignChanged(int))); connect(mitkWidget4, SIGNAL(ResetView()), this, SLOT(ResetCrosshair())); connect(mitkWidget4, SIGNAL(ChangeCrosshairRotationMode(int)), this, SLOT(SetWidgetPlaneMode(int))); connect(this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget4, SLOT(OnWidgetPlaneModeChanged(int))); // Create Level Window Widget levelWindowWidget = new QmitkLevelWindowWidget(m_MainSplit); // this levelWindowWidget->setObjectName(QString::fromUtf8("levelWindowWidget")); QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(levelWindowWidget->sizePolicy().hasHeightForWidth()); levelWindowWidget->setSizePolicy(sizePolicy); levelWindowWidget->setMaximumWidth(50); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // show mainSplitt and add to Layout m_MainSplit->show(); // resize Image. this->resize(QSize(364, 477).expandedTo(minimumSizeHint())); // Initialize the widgets. this->InitializeWidget(); // Activate Widget Menu this->ActivateMenuWidget(true); } void QmitkStdMultiWidget::InitializeWidget() { // Make all black and overwrite renderwindow 4 this->FillGradientBackgroundWithBlack(); // This is #191919 in hex float tmp1[3] = {0.098f, 0.098f, 0.098f}; // This is #7F7F7F in hex float tmp2[3] = {0.498f, 0.498f, 0.498f}; m_GradientBackgroundColors[3] = std::make_pair(mitk::Color(tmp1), mitk::Color(tmp2)); // Yellow is default color for widget4 m_DecorationColorWidget4[0] = 1.0f; m_DecorationColorWidget4[1] = 1.0f; m_DecorationColorWidget4[2] = 0.0f; // transfer colors in WorldGeometry-Nodes of the associated Renderer mitk::IntProperty::Pointer layer; // of widget 1 m_PlaneNode1 = mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetCurrentWorldPlaneGeometryNode(); m_PlaneNode1->SetColor(GetDecorationColor(0)); layer = mitk::IntProperty::New(1000); m_PlaneNode1->SetProperty("layer", layer); // ... of widget 2 m_PlaneNode2 = mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->GetCurrentWorldPlaneGeometryNode(); m_PlaneNode2->SetColor(GetDecorationColor(1)); layer = mitk::IntProperty::New(1000); m_PlaneNode2->SetProperty("layer", layer); // ... of widget 3 m_PlaneNode3 = mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->GetCurrentWorldPlaneGeometryNode(); m_PlaneNode3->SetColor(GetDecorationColor(2)); layer = mitk::IntProperty::New(1000); m_PlaneNode3->SetProperty("layer", layer); // The parent node m_ParentNodeForGeometryPlanes = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->GetCurrentWorldPlaneGeometryNode(); layer = mitk::IntProperty::New(1000); m_ParentNodeForGeometryPlanes->SetProperty("layer", layer); mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->SetMapperID(mitk::BaseRenderer::Standard3D); // Set plane mode (slicing/rotation behavior) to slicing (default) m_PlaneMode = PLANE_MODE_SLICING; // Set default view directions for SNCs mitkWidget1->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Axial); mitkWidget2->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Sagittal); mitkWidget3->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Frontal); mitkWidget4->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Original); SetDecorationProperties("Axial", GetDecorationColor(0), 0); SetDecorationProperties("Sagittal", GetDecorationColor(1), 1); SetDecorationProperties("Coronal", GetDecorationColor(2), 2); SetDecorationProperties("3D", GetDecorationColor(3), 3); // connect to the "time navigation controller": send time via sliceNavigationControllers m_TimeNavigationController->ConnectGeometryTimeEvent(mitkWidget1->GetSliceNavigationController(), false); m_TimeNavigationController->ConnectGeometryTimeEvent(mitkWidget2->GetSliceNavigationController(), false); m_TimeNavigationController->ConnectGeometryTimeEvent(mitkWidget3->GetSliceNavigationController(), false); m_TimeNavigationController->ConnectGeometryTimeEvent(mitkWidget4->GetSliceNavigationController(), false); mitkWidget1->GetSliceNavigationController()->ConnectGeometrySendEvent( mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())); // reverse connection between sliceNavigationControllers and m_TimeNavigationController mitkWidget1->GetSliceNavigationController()->ConnectGeometryTimeEvent(m_TimeNavigationController, false); mitkWidget2->GetSliceNavigationController()->ConnectGeometryTimeEvent(m_TimeNavigationController, false); mitkWidget3->GetSliceNavigationController()->ConnectGeometryTimeEvent(m_TimeNavigationController, false); // mitkWidget4->GetSliceNavigationController() // ->ConnectGeometryTimeEvent(m_TimeNavigationController, false); m_MouseModeSwitcher = mitk::MouseModeSwitcher::New(); // setup the department logo rendering - m_LogoRendering = mitk::LogoOverlay::New(); + m_LogoRendering = mitk::LogoAnnotation::New(); mitk::BaseRenderer::Pointer renderer4 = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow()); m_LogoRendering->SetOpacity(0.5); mitk::Point2D offset; offset.Fill(0.03); m_LogoRendering->SetOffsetVector(offset); m_LogoRendering->SetRelativeSize(0.15); m_LogoRendering->SetCornerPosition(1); m_LogoRendering->SetLogoImagePath("DefaultLogo"); - mitk::AnnotationPlacer::AddOverlay(m_LogoRendering.GetPointer(), renderer4); + mitk::ManualPlacementAnnotationRenderer::AddAnnotation(m_LogoRendering.GetPointer(), renderer4); } void QmitkStdMultiWidget::FillGradientBackgroundWithBlack() { // We have 4 widgets and ... for (unsigned int i = 0; i < 4; ++i) { float black[3] = {0.0f, 0.0f, 0.0f}; m_GradientBackgroundColors[i] = std::make_pair(mitk::Color(black), mitk::Color(black)); } } std::pair QmitkStdMultiWidget::GetGradientColors(unsigned int widgetNumber) { if (widgetNumber > 3) { MITK_ERROR << "Decoration color for unknown widget!"; float black[3] = {0.0f, 0.0f, 0.0f}; return std::make_pair(mitk::Color(black), mitk::Color(black)); } return m_GradientBackgroundColors[widgetNumber]; } mitk::Color QmitkStdMultiWidget::GetDecorationColor(unsigned int widgetNumber) { // The implementation looks a bit messy here, but it avoids // synchronization of the color of the geometry nodes and an // internal member here. // Default colors were chosen for decent visibitliy. // Feel free to change your preferences in the workbench. float tmp[3] = {0.0f, 0.0f, 0.0f}; switch (widgetNumber) { case 0: { if (m_PlaneNode1.IsNotNull()) { if (m_PlaneNode1->GetColor(tmp)) { return dynamic_cast(m_PlaneNode1->GetProperty("color"))->GetColor(); } } float red[3] = {0.753f, 0.0f, 0.0f}; // This is #C00000 in hex return mitk::Color(red); } case 1: { if (m_PlaneNode2.IsNotNull()) { if (m_PlaneNode2->GetColor(tmp)) { return dynamic_cast(m_PlaneNode2->GetProperty("color"))->GetColor(); } } float green[3] = {0.0f, 0.69f, 0.0f}; // This is #00B000 in hex return mitk::Color(green); } case 2: { if (m_PlaneNode3.IsNotNull()) { if (m_PlaneNode3->GetColor(tmp)) { return dynamic_cast(m_PlaneNode3->GetProperty("color"))->GetColor(); } } float blue[3] = {0.0, 0.502f, 1.0f}; // This is #0080FF in hex return mitk::Color(blue); } case 3: { return m_DecorationColorWidget4; } default: MITK_ERROR << "Decoration color for unknown widget!"; float black[3] = {0.0f, 0.0f, 0.0f}; return mitk::Color(black); } } std::string QmitkStdMultiWidget::GetCornerAnnotationText(unsigned int widgetNumber) { if (widgetNumber > 3) { MITK_ERROR << "Decoration color for unknown widget!"; return std::string(""); } return std::string(m_CornerAnnotations[widgetNumber]->GetText(0)); } QmitkStdMultiWidget::~QmitkStdMultiWidget() { DisablePositionTracking(); // DisableNavigationControllerEventListening(); m_TimeNavigationController->Disconnect(mitkWidget1->GetSliceNavigationController()); m_TimeNavigationController->Disconnect(mitkWidget2->GetSliceNavigationController()); m_TimeNavigationController->Disconnect(mitkWidget3->GetSliceNavigationController()); m_TimeNavigationController->Disconnect(mitkWidget4->GetSliceNavigationController()); } void QmitkStdMultiWidget::RemovePlanesFromDataStorage() { if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull() && m_PlaneNode3.IsNotNull() && m_ParentNodeForGeometryPlanes.IsNotNull()) { if (m_DataStorage.IsNotNull()) { m_DataStorage->Remove(m_PlaneNode1); m_DataStorage->Remove(m_PlaneNode2); m_DataStorage->Remove(m_PlaneNode3); m_DataStorage->Remove(m_ParentNodeForGeometryPlanes); } } } void QmitkStdMultiWidget::AddPlanesToDataStorage() { if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull() && m_PlaneNode3.IsNotNull() && m_ParentNodeForGeometryPlanes.IsNotNull()) { if (m_DataStorage.IsNotNull()) { m_DataStorage->Add(m_ParentNodeForGeometryPlanes); m_DataStorage->Add(m_PlaneNode1, m_ParentNodeForGeometryPlanes); m_DataStorage->Add(m_PlaneNode2, m_ParentNodeForGeometryPlanes); m_DataStorage->Add(m_PlaneNode3, m_ParentNodeForGeometryPlanes); } } } void QmitkStdMultiWidget::changeLayoutTo2DImagesUp() { SMW_INFO << "changing layout to 2D images up... " << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // Set Layout to widget this->setLayout(QmitkStdMultiWidgetLayout); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(Qt::Vertical, m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // create m_SubSplit1 and m_SubSplit2 m_SubSplit1 = new QSplitter(m_LayoutSplit); m_SubSplit2 = new QSplitter(m_LayoutSplit); // insert Widget Container into splitter top m_SubSplit1->addWidget(mitkWidget1Container); m_SubSplit1->addWidget(mitkWidget2Container); m_SubSplit1->addWidget(mitkWidget3Container); // set SplitterSize for splitter top QList splitterSize; splitterSize.push_back(1000); splitterSize.push_back(1000); splitterSize.push_back(1000); m_SubSplit1->setSizes(splitterSize); // insert Widget Container into splitter bottom m_SubSplit2->addWidget(mitkWidget4Container); // set SplitterSize for splitter m_LayoutSplit splitterSize.clear(); splitterSize.push_back(400); splitterSize.push_back(1000); m_LayoutSplit->setSizes(splitterSize); // show mainSplitt m_MainSplit->show(); // show Widget if hidden if (mitkWidget1->isHidden()) mitkWidget1->show(); if (mitkWidget2->isHidden()) mitkWidget2->show(); if (mitkWidget3->isHidden()) mitkWidget3->show(); if (mitkWidget4->isHidden()) mitkWidget4->show(); // Change Layout Name m_Layout = LAYOUT_2D_IMAGES_UP; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_2D_IMAGES_UP); mitkWidget2->LayoutDesignListChanged(LAYOUT_2D_IMAGES_UP); mitkWidget3->LayoutDesignListChanged(LAYOUT_2D_IMAGES_UP); mitkWidget4->LayoutDesignListChanged(LAYOUT_2D_IMAGES_UP); // update Alle Widgets this->UpdateAllWidgets(); } void QmitkStdMultiWidget::changeLayoutTo2DImagesLeft() { SMW_INFO << "changing layout to 2D images left... " << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // create m_SubSplit1 and m_SubSplit2 m_SubSplit1 = new QSplitter(Qt::Vertical, m_LayoutSplit); m_SubSplit2 = new QSplitter(m_LayoutSplit); // insert Widget into the splitters m_SubSplit1->addWidget(mitkWidget1Container); m_SubSplit1->addWidget(mitkWidget2Container); m_SubSplit1->addWidget(mitkWidget3Container); // set splitterSize of SubSplit1 QList splitterSize; splitterSize.push_back(1000); splitterSize.push_back(1000); splitterSize.push_back(1000); m_SubSplit1->setSizes(splitterSize); m_SubSplit2->addWidget(mitkWidget4Container); // set splitterSize of Layout Split splitterSize.clear(); splitterSize.push_back(400); splitterSize.push_back(1000); m_LayoutSplit->setSizes(splitterSize); // show mainSplitt and add to Layout m_MainSplit->show(); // show Widget if hidden if (mitkWidget1->isHidden()) mitkWidget1->show(); if (mitkWidget2->isHidden()) mitkWidget2->show(); if (mitkWidget3->isHidden()) mitkWidget3->show(); if (mitkWidget4->isHidden()) mitkWidget4->show(); // update Layout Name m_Layout = LAYOUT_2D_IMAGES_LEFT; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_2D_IMAGES_LEFT); mitkWidget2->LayoutDesignListChanged(LAYOUT_2D_IMAGES_LEFT); mitkWidget3->LayoutDesignListChanged(LAYOUT_2D_IMAGES_LEFT); mitkWidget4->LayoutDesignListChanged(LAYOUT_2D_IMAGES_LEFT); // update Alle Widgets this->UpdateAllWidgets(); } void QmitkStdMultiWidget::SetDecorationProperties(std::string text, mitk::Color color, int widgetNumber) { if (widgetNumber > 3) { MITK_ERROR << "Unknown render window for annotation."; return; } vtkRenderer *renderer = this->GetRenderWindow(widgetNumber)->GetRenderer()->GetVtkRenderer(); if (!renderer) return; vtkSmartPointer annotation = m_CornerAnnotations[widgetNumber]; annotation->SetText(0, text.c_str()); annotation->SetMaximumFontSize(12); annotation->GetTextProperty()->SetColor(color[0], color[1], color[2]); if (!renderer->HasViewProp(annotation)) { renderer->AddViewProp(annotation); } vtkSmartPointer frame = m_RectangleProps[widgetNumber]; frame->SetColor(color[0], color[1], color[2]); if (!renderer->HasViewProp(frame)) { renderer->AddViewProp(frame); } } void QmitkStdMultiWidget::SetCornerAnnotationVisibility(bool visibility) { for (int i = 0; i < 4; ++i) { m_CornerAnnotations[i]->SetVisibility(visibility); } } bool QmitkStdMultiWidget::IsCornerAnnotationVisible(void) const { return m_CornerAnnotations[0]->GetVisibility() > 0; } QmitkRenderWindow *QmitkStdMultiWidget::GetRenderWindow(unsigned int number) { switch (number) { case 0: return this->GetRenderWindow1(); case 1: return this->GetRenderWindow2(); case 2: return this->GetRenderWindow3(); case 3: return this->GetRenderWindow4(); default: MITK_ERROR << "Requested unknown render window"; break; } return NULL; } void QmitkStdMultiWidget::changeLayoutToDefault() { SMW_INFO << "changing layout to default... " << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(Qt::Vertical, m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // create m_SubSplit1 and m_SubSplit2 m_SubSplit1 = new QSplitter(m_LayoutSplit); m_SubSplit2 = new QSplitter(m_LayoutSplit); // insert Widget container into the splitters m_SubSplit1->addWidget(mitkWidget1Container); m_SubSplit1->addWidget(mitkWidget2Container); m_SubSplit2->addWidget(mitkWidget3Container); m_SubSplit2->addWidget(mitkWidget4Container); // set splitter Size QList splitterSize; splitterSize.push_back(1000); splitterSize.push_back(1000); m_SubSplit1->setSizes(splitterSize); m_SubSplit2->setSizes(splitterSize); m_LayoutSplit->setSizes(splitterSize); // show mainSplitt and add to Layout m_MainSplit->show(); // show Widget if hidden if (mitkWidget1->isHidden()) mitkWidget1->show(); if (mitkWidget2->isHidden()) mitkWidget2->show(); if (mitkWidget3->isHidden()) mitkWidget3->show(); if (mitkWidget4->isHidden()) mitkWidget4->show(); m_Layout = LAYOUT_DEFAULT; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_DEFAULT); mitkWidget2->LayoutDesignListChanged(LAYOUT_DEFAULT); mitkWidget3->LayoutDesignListChanged(LAYOUT_DEFAULT); mitkWidget4->LayoutDesignListChanged(LAYOUT_DEFAULT); // update Alle Widgets this->UpdateAllWidgets(); } void QmitkStdMultiWidget::changeLayoutToBig3D() { SMW_INFO << "changing layout to big 3D ..." << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // add widget Splitter to main Splitter m_MainSplit->addWidget(mitkWidget4Container); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // show mainSplitt and add to Layout m_MainSplit->show(); // show/hide Widgets mitkWidget1->hide(); mitkWidget2->hide(); mitkWidget3->hide(); if (mitkWidget4->isHidden()) mitkWidget4->show(); m_Layout = LAYOUT_BIG_3D; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_BIG_3D); mitkWidget2->LayoutDesignListChanged(LAYOUT_BIG_3D); mitkWidget3->LayoutDesignListChanged(LAYOUT_BIG_3D); mitkWidget4->LayoutDesignListChanged(LAYOUT_BIG_3D); // update Alle Widgets this->UpdateAllWidgets(); mitk::RenderingManager::GetInstance()->SetRenderWindowFocus(mitkWidget4->GetVtkRenderWindow()); } void QmitkStdMultiWidget::changeLayoutToWidget1() { SMW_INFO << "changing layout to big Widget1 ..." << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // add widget Splitter to main Splitter m_MainSplit->addWidget(mitkWidget1Container); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // show mainSplitt and add to Layout m_MainSplit->show(); // show/hide Widgets if (mitkWidget1->isHidden()) mitkWidget1->show(); mitkWidget2->hide(); mitkWidget3->hide(); mitkWidget4->hide(); m_Layout = LAYOUT_WIDGET1; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_WIDGET1); mitkWidget2->LayoutDesignListChanged(LAYOUT_WIDGET1); mitkWidget3->LayoutDesignListChanged(LAYOUT_WIDGET1); mitkWidget4->LayoutDesignListChanged(LAYOUT_WIDGET1); // update Alle Widgets this->UpdateAllWidgets(); mitk::RenderingManager::GetInstance()->SetRenderWindowFocus(mitkWidget1->GetVtkRenderWindow()); } void QmitkStdMultiWidget::changeLayoutToWidget2() { SMW_INFO << "changing layout to big Widget2 ..." << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // add widget Splitter to main Splitter m_MainSplit->addWidget(mitkWidget2Container); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // show mainSplitt and add to Layout m_MainSplit->show(); // show/hide Widgets mitkWidget1->hide(); if (mitkWidget2->isHidden()) mitkWidget2->show(); mitkWidget3->hide(); mitkWidget4->hide(); m_Layout = LAYOUT_WIDGET2; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_WIDGET2); mitkWidget2->LayoutDesignListChanged(LAYOUT_WIDGET2); mitkWidget3->LayoutDesignListChanged(LAYOUT_WIDGET2); mitkWidget4->LayoutDesignListChanged(LAYOUT_WIDGET2); // update Alle Widgets this->UpdateAllWidgets(); mitk::RenderingManager::GetInstance()->SetRenderWindowFocus(mitkWidget2->GetVtkRenderWindow()); } void QmitkStdMultiWidget::changeLayoutToWidget3() { SMW_INFO << "changing layout to big Widget3 ..." << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // add widget Splitter to main Splitter m_MainSplit->addWidget(mitkWidget3Container); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // show mainSplitt and add to Layout m_MainSplit->show(); // show/hide Widgets mitkWidget1->hide(); mitkWidget2->hide(); if (mitkWidget3->isHidden()) mitkWidget3->show(); mitkWidget4->hide(); m_Layout = LAYOUT_WIDGET3; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_WIDGET3); mitkWidget2->LayoutDesignListChanged(LAYOUT_WIDGET3); mitkWidget3->LayoutDesignListChanged(LAYOUT_WIDGET3); mitkWidget4->LayoutDesignListChanged(LAYOUT_WIDGET3); // update Alle Widgets this->UpdateAllWidgets(); mitk::RenderingManager::GetInstance()->SetRenderWindowFocus(mitkWidget3->GetVtkRenderWindow()); } void QmitkStdMultiWidget::changeLayoutToRowWidget3And4() { SMW_INFO << "changing layout to Widget3 and 4 in a Row..." << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(Qt::Vertical, m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // add Widgets to splitter m_LayoutSplit->addWidget(mitkWidget3Container); m_LayoutSplit->addWidget(mitkWidget4Container); // set Splitter Size QList splitterSize; splitterSize.push_back(1000); splitterSize.push_back(1000); m_LayoutSplit->setSizes(splitterSize); // show mainSplitt and add to Layout m_MainSplit->show(); // show/hide Widgets mitkWidget1->hide(); mitkWidget2->hide(); if (mitkWidget3->isHidden()) mitkWidget3->show(); if (mitkWidget4->isHidden()) mitkWidget4->show(); m_Layout = LAYOUT_ROW_WIDGET_3_AND_4; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_ROW_WIDGET_3_AND_4); mitkWidget2->LayoutDesignListChanged(LAYOUT_ROW_WIDGET_3_AND_4); mitkWidget3->LayoutDesignListChanged(LAYOUT_ROW_WIDGET_3_AND_4); mitkWidget4->LayoutDesignListChanged(LAYOUT_ROW_WIDGET_3_AND_4); // update Alle Widgets this->UpdateAllWidgets(); } void QmitkStdMultiWidget::changeLayoutToColumnWidget3And4() { SMW_INFO << "changing layout to Widget3 and 4 in one Column..." << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // add Widgets to splitter m_LayoutSplit->addWidget(mitkWidget3Container); m_LayoutSplit->addWidget(mitkWidget4Container); // set SplitterSize QList splitterSize; splitterSize.push_back(1000); splitterSize.push_back(1000); m_LayoutSplit->setSizes(splitterSize); // show mainSplitt and add to Layout m_MainSplit->show(); // show/hide Widgets mitkWidget1->hide(); mitkWidget2->hide(); if (mitkWidget3->isHidden()) mitkWidget3->show(); if (mitkWidget4->isHidden()) mitkWidget4->show(); m_Layout = LAYOUT_COLUMN_WIDGET_3_AND_4; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_COLUMN_WIDGET_3_AND_4); mitkWidget2->LayoutDesignListChanged(LAYOUT_COLUMN_WIDGET_3_AND_4); mitkWidget3->LayoutDesignListChanged(LAYOUT_COLUMN_WIDGET_3_AND_4); mitkWidget4->LayoutDesignListChanged(LAYOUT_COLUMN_WIDGET_3_AND_4); // update Alle Widgets this->UpdateAllWidgets(); } void QmitkStdMultiWidget::changeLayoutToRowWidgetSmall3andBig4() { SMW_INFO << "changing layout to Widget3 and 4 in a Row..." << std::endl; this->changeLayoutToRowWidget3And4(); m_Layout = LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4; } void QmitkStdMultiWidget::changeLayoutToSmallUpperWidget2Big3and4() { SMW_INFO << "changing layout to Widget3 and 4 in a Row..." << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(Qt::Vertical, m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // create m_SubSplit1 and m_SubSplit2 m_SubSplit1 = new QSplitter(Qt::Vertical, m_LayoutSplit); m_SubSplit2 = new QSplitter(m_LayoutSplit); // insert Widget into the splitters m_SubSplit1->addWidget(mitkWidget2Container); m_SubSplit2->addWidget(mitkWidget3Container); m_SubSplit2->addWidget(mitkWidget4Container); // set Splitter Size QList splitterSize; splitterSize.push_back(1000); splitterSize.push_back(1000); m_SubSplit2->setSizes(splitterSize); splitterSize.clear(); splitterSize.push_back(500); splitterSize.push_back(1000); m_LayoutSplit->setSizes(splitterSize); // show mainSplitt m_MainSplit->show(); // show Widget if hidden mitkWidget1->hide(); if (mitkWidget2->isHidden()) mitkWidget2->show(); if (mitkWidget3->isHidden()) mitkWidget3->show(); if (mitkWidget4->isHidden()) mitkWidget4->show(); m_Layout = LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4); mitkWidget2->LayoutDesignListChanged(LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4); mitkWidget3->LayoutDesignListChanged(LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4); mitkWidget4->LayoutDesignListChanged(LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4); // update Alle Widgets this->UpdateAllWidgets(); } void QmitkStdMultiWidget::changeLayoutTo2x2Dand3DWidget() { SMW_INFO << "changing layout to 2 x 2D and 3D Widget" << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // create m_SubSplit1 and m_SubSplit2 m_SubSplit1 = new QSplitter(Qt::Vertical, m_LayoutSplit); m_SubSplit2 = new QSplitter(m_LayoutSplit); // add Widgets to splitter m_SubSplit1->addWidget(mitkWidget1Container); m_SubSplit1->addWidget(mitkWidget2Container); m_SubSplit2->addWidget(mitkWidget4Container); // set Splitter Size QList splitterSize; splitterSize.push_back(1000); splitterSize.push_back(1000); m_SubSplit1->setSizes(splitterSize); m_LayoutSplit->setSizes(splitterSize); // show mainSplitt and add to Layout m_MainSplit->show(); // show/hide Widgets if (mitkWidget1->isHidden()) mitkWidget1->show(); if (mitkWidget2->isHidden()) mitkWidget2->show(); mitkWidget3->hide(); if (mitkWidget4->isHidden()) mitkWidget4->show(); m_Layout = LAYOUT_2X_2D_AND_3D_WIDGET; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_2X_2D_AND_3D_WIDGET); mitkWidget2->LayoutDesignListChanged(LAYOUT_2X_2D_AND_3D_WIDGET); mitkWidget3->LayoutDesignListChanged(LAYOUT_2X_2D_AND_3D_WIDGET); mitkWidget4->LayoutDesignListChanged(LAYOUT_2X_2D_AND_3D_WIDGET); // update Alle Widgets this->UpdateAllWidgets(); } void QmitkStdMultiWidget::changeLayoutToLeft2Dand3DRight2D() { SMW_INFO << "changing layout to 2D and 3D left, 2D right Widget" << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // create m_SubSplit1 and m_SubSplit2 m_SubSplit1 = new QSplitter(Qt::Vertical, m_LayoutSplit); m_SubSplit2 = new QSplitter(m_LayoutSplit); // add Widgets to splitter m_SubSplit1->addWidget(mitkWidget1Container); m_SubSplit1->addWidget(mitkWidget4Container); m_SubSplit2->addWidget(mitkWidget2Container); // set Splitter Size QList splitterSize; splitterSize.push_back(1000); splitterSize.push_back(1000); m_SubSplit1->setSizes(splitterSize); m_LayoutSplit->setSizes(splitterSize); // show mainSplitt and add to Layout m_MainSplit->show(); // show/hide Widgets if (mitkWidget1->isHidden()) mitkWidget1->show(); if (mitkWidget2->isHidden()) mitkWidget2->show(); mitkWidget3->hide(); if (mitkWidget4->isHidden()) mitkWidget4->show(); m_Layout = LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET); mitkWidget2->LayoutDesignListChanged(LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET); mitkWidget3->LayoutDesignListChanged(LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET); mitkWidget4->LayoutDesignListChanged(LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET); // update Alle Widgets this->UpdateAllWidgets(); } void QmitkStdMultiWidget::changeLayoutTo2DUpAnd3DDown() { SMW_INFO << "changing layout to 2D up and 3D down" << std::endl; // Hide all Menu Widgets this->HideAllWidgetToolbars(); delete QmitkStdMultiWidgetLayout; // create Main Layout QmitkStdMultiWidgetLayout = new QHBoxLayout(this); // Set Layout to widget this->setLayout(QmitkStdMultiWidgetLayout); // create main splitter m_MainSplit = new QSplitter(this); QmitkStdMultiWidgetLayout->addWidget(m_MainSplit); // create m_LayoutSplit and add to the mainSplit m_LayoutSplit = new QSplitter(Qt::Vertical, m_MainSplit); m_MainSplit->addWidget(m_LayoutSplit); // add LevelWindow Widget to mainSplitter m_MainSplit->addWidget(levelWindowWidget); // create m_SubSplit1 and m_SubSplit2 m_SubSplit1 = new QSplitter(m_LayoutSplit); m_SubSplit2 = new QSplitter(m_LayoutSplit); // insert Widget Container into splitter top m_SubSplit1->addWidget(mitkWidget1Container); // set SplitterSize for splitter top QList splitterSize; // insert Widget Container into splitter bottom m_SubSplit2->addWidget(mitkWidget4Container); // set SplitterSize for splitter m_LayoutSplit splitterSize.clear(); splitterSize.push_back(700); splitterSize.push_back(700); m_LayoutSplit->setSizes(splitterSize); // show mainSplitt m_MainSplit->show(); // show/hide Widgets if (mitkWidget1->isHidden()) mitkWidget1->show(); mitkWidget2->hide(); mitkWidget3->hide(); if (mitkWidget4->isHidden()) mitkWidget4->show(); m_Layout = LAYOUT_2D_UP_AND_3D_DOWN; // update Layout Design List mitkWidget1->LayoutDesignListChanged(LAYOUT_2D_UP_AND_3D_DOWN); mitkWidget2->LayoutDesignListChanged(LAYOUT_2D_UP_AND_3D_DOWN); mitkWidget3->LayoutDesignListChanged(LAYOUT_2D_UP_AND_3D_DOWN); mitkWidget4->LayoutDesignListChanged(LAYOUT_2D_UP_AND_3D_DOWN); // update all Widgets this->UpdateAllWidgets(); } void QmitkStdMultiWidget::SetDataStorage(mitk::DataStorage *ds) { if (ds == m_DataStorage) { return; } mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->SetDataStorage(ds); mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->SetDataStorage(ds); mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->SetDataStorage(ds); mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->SetDataStorage(ds); m_DataStorage = ds; } void QmitkStdMultiWidget::Fit() { vtkSmartPointer vtkrenderer; vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetVtkRenderer(); if (vtkrenderer != NULL) vtkrenderer->ResetCamera(); vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->GetVtkRenderer(); if (vtkrenderer != NULL) vtkrenderer->ResetCamera(); vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->GetVtkRenderer(); if (vtkrenderer != NULL) vtkrenderer->ResetCamera(); vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->GetVtkRenderer(); if (vtkrenderer != NULL) vtkrenderer->ResetCamera(); mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetCameraController()->Fit(); mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->GetCameraController()->Fit(); mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->GetCameraController()->Fit(); mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->GetCameraController()->Fit(); int w = vtkObject::GetGlobalWarningDisplay(); vtkObject::GlobalWarningDisplayOff(); vtkObject::SetGlobalWarningDisplay(w); } void QmitkStdMultiWidget::InitPositionTracking() { // TODO POSITIONTRACKER } void QmitkStdMultiWidget::AddDisplayPlaneSubTree() { // add the displayed planes of the multiwidget to a node to which the subtree // @a planesSubTree points ... mitk::PlaneGeometryDataMapper2D::Pointer mapper; // ... of widget 1 mitk::BaseRenderer *renderer1 = mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow()); m_PlaneNode1 = renderer1->GetCurrentWorldPlaneGeometryNode(); m_PlaneNode1->SetProperty("visible", mitk::BoolProperty::New(true)); m_PlaneNode1->SetProperty("name", mitk::StringProperty::New(std::string(renderer1->GetName()) + ".plane")); m_PlaneNode1->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); m_PlaneNode1->SetProperty("helper object", mitk::BoolProperty::New(true)); mapper = mitk::PlaneGeometryDataMapper2D::New(); m_PlaneNode1->SetMapper(mitk::BaseRenderer::Standard2D, mapper); // ... of widget 2 mitk::BaseRenderer *renderer2 = mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow()); m_PlaneNode2 = renderer2->GetCurrentWorldPlaneGeometryNode(); m_PlaneNode2->SetProperty("visible", mitk::BoolProperty::New(true)); m_PlaneNode2->SetProperty("name", mitk::StringProperty::New(std::string(renderer2->GetName()) + ".plane")); m_PlaneNode2->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); m_PlaneNode2->SetProperty("helper object", mitk::BoolProperty::New(true)); mapper = mitk::PlaneGeometryDataMapper2D::New(); m_PlaneNode2->SetMapper(mitk::BaseRenderer::Standard2D, mapper); // ... of widget 3 mitk::BaseRenderer *renderer3 = mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow()); m_PlaneNode3 = renderer3->GetCurrentWorldPlaneGeometryNode(); m_PlaneNode3->SetProperty("visible", mitk::BoolProperty::New(true)); m_PlaneNode3->SetProperty("name", mitk::StringProperty::New(std::string(renderer3->GetName()) + ".plane")); m_PlaneNode3->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); m_PlaneNode3->SetProperty("helper object", mitk::BoolProperty::New(true)); mapper = mitk::PlaneGeometryDataMapper2D::New(); m_PlaneNode3->SetMapper(mitk::BaseRenderer::Standard2D, mapper); m_ParentNodeForGeometryPlanes = mitk::DataNode::New(); m_ParentNodeForGeometryPlanes->SetProperty("name", mitk::StringProperty::New("Widgets")); m_ParentNodeForGeometryPlanes->SetProperty("helper object", mitk::BoolProperty::New(true)); } mitk::SliceNavigationController *QmitkStdMultiWidget::GetTimeNavigationController() { return m_TimeNavigationController; } void QmitkStdMultiWidget::EnableStandardLevelWindow() { levelWindowWidget->disconnect(this); levelWindowWidget->SetDataStorage(mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetDataStorage()); levelWindowWidget->show(); } void QmitkStdMultiWidget::DisableStandardLevelWindow() { levelWindowWidget->disconnect(this); levelWindowWidget->hide(); } // CAUTION: Legacy code for enabling Qt-signal-controlled view initialization. // Use RenderingManager::InitializeViews() instead. bool QmitkStdMultiWidget::InitializeStandardViews(const mitk::Geometry3D *geometry) { return m_RenderingManager->InitializeViews(geometry); } void QmitkStdMultiWidget::RequestUpdate() { m_RenderingManager->RequestUpdate(mitkWidget1->GetRenderWindow()); m_RenderingManager->RequestUpdate(mitkWidget2->GetRenderWindow()); m_RenderingManager->RequestUpdate(mitkWidget3->GetRenderWindow()); m_RenderingManager->RequestUpdate(mitkWidget4->GetRenderWindow()); } void QmitkStdMultiWidget::ForceImmediateUpdate() { m_RenderingManager->ForceImmediateUpdate(mitkWidget1->GetRenderWindow()); m_RenderingManager->ForceImmediateUpdate(mitkWidget2->GetRenderWindow()); m_RenderingManager->ForceImmediateUpdate(mitkWidget3->GetRenderWindow()); m_RenderingManager->ForceImmediateUpdate(mitkWidget4->GetRenderWindow()); } void QmitkStdMultiWidget::wheelEvent(QWheelEvent *e) { emit WheelMoved(e); } void QmitkStdMultiWidget::mousePressEvent(QMouseEvent *e) { } void QmitkStdMultiWidget::moveEvent(QMoveEvent *e) { QWidget::moveEvent(e); - // it is necessary to readjust the position of the overlays as the StdMultiWidget has moved + // it is necessary to readjust the position of the Annotation as the StdMultiWidget has moved // unfortunately it's not done by QmitkRenderWindow::moveEvent -> must be done here emit Moved(); } QmitkRenderWindow *QmitkStdMultiWidget::GetRenderWindow1() const { return mitkWidget1; } QmitkRenderWindow *QmitkStdMultiWidget::GetRenderWindow2() const { return mitkWidget2; } QmitkRenderWindow *QmitkStdMultiWidget::GetRenderWindow3() const { return mitkWidget3; } QmitkRenderWindow *QmitkStdMultiWidget::GetRenderWindow4() const { return mitkWidget4; } const mitk::Point3D QmitkStdMultiWidget::GetCrossPosition() const { const mitk::PlaneGeometry *plane1 = mitkWidget1->GetSliceNavigationController()->GetCurrentPlaneGeometry(); const mitk::PlaneGeometry *plane2 = mitkWidget2->GetSliceNavigationController()->GetCurrentPlaneGeometry(); const mitk::PlaneGeometry *plane3 = mitkWidget3->GetSliceNavigationController()->GetCurrentPlaneGeometry(); mitk::Line3D line; if ((plane1 != NULL) && (plane2 != NULL) && (plane1->IntersectionLine(plane2, line))) { mitk::Point3D point; if ((plane3 != NULL) && (plane3->IntersectionPoint(line, point))) { return point; } } // TODO BUG POSITIONTRACKER; mitk::Point3D p; return p; // return m_LastLeftClickPositionSupplier->GetCurrentPoint(); } void QmitkStdMultiWidget::EnablePositionTracking() { } void QmitkStdMultiWidget::DisablePositionTracking() { } void QmitkStdMultiWidget::EnsureDisplayContainsPoint(mitk::BaseRenderer *renderer, const mitk::Point3D &p) { mitk::Point2D pointOnDisplay; renderer->WorldToDisplay(p, pointOnDisplay); if (pointOnDisplay[0] < renderer->GetVtkRenderer()->GetOrigin()[0] || pointOnDisplay[1] < renderer->GetVtkRenderer()->GetOrigin()[1] || pointOnDisplay[0] > renderer->GetVtkRenderer()->GetOrigin()[0] + renderer->GetViewportSize()[0] || pointOnDisplay[1] > renderer->GetVtkRenderer()->GetOrigin()[1] + renderer->GetViewportSize()[1]) { mitk::Point2D pointOnPlane; renderer->GetCurrentWorldPlaneGeometry()->Map(p, pointOnPlane); renderer->GetCameraController()->MoveCameraToPoint(pointOnPlane); } } void QmitkStdMultiWidget::MoveCrossToPosition(const mitk::Point3D &newPosition) { mitkWidget1->GetSliceNavigationController()->SelectSliceByPoint(newPosition); mitkWidget2->GetSliceNavigationController()->SelectSliceByPoint(newPosition); mitkWidget3->GetSliceNavigationController()->SelectSliceByPoint(newPosition); m_RenderingManager->RequestUpdateAll(); } void QmitkStdMultiWidget::HandleCrosshairPositionEvent() { if (!m_PendingCrosshairPositionEvent) { m_PendingCrosshairPositionEvent = true; QTimer::singleShot(0, this, SLOT(HandleCrosshairPositionEventDelayed())); } } mitk::DataNode::Pointer QmitkStdMultiWidget::GetTopLayerNode(mitk::DataStorage::SetOfObjects::ConstPointer nodes) { mitk::Point3D crosshairPos = this->GetCrossPosition(); mitk::DataNode::Pointer node; int maxlayer = -32768; if (nodes.IsNotNull()) { mitk::BaseRenderer *baseRenderer = this->mitkWidget1->GetSliceNavigationController()->GetRenderer(); // find node with largest layer, that is the node shown on top in the render window for (unsigned int x = 0; x < nodes->size(); x++) { if ((nodes->at(x)->GetData()->GetGeometry() != NULL) && nodes->at(x)->GetData()->GetGeometry()->IsInside(crosshairPos)) { int layer = 0; if (!(nodes->at(x)->GetIntProperty("layer", layer))) continue; if (layer > maxlayer) { if (static_cast(nodes->at(x))->IsVisible(baseRenderer)) { node = nodes->at(x); maxlayer = layer; } } } } } return node; } void QmitkStdMultiWidget::HandleCrosshairPositionEventDelayed() { m_PendingCrosshairPositionEvent = false; // find image with highest layer mitk::TNodePredicateDataType::Pointer isImageData = mitk::TNodePredicateDataType::New(); mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->m_DataStorage->GetSubset(isImageData).GetPointer(); mitk::DataNode::Pointer node; mitk::DataNode::Pointer topSourceNode; mitk::Image::Pointer image; bool isBinary = false; node = this->GetTopLayerNode(nodes); int component = 0; if (node.IsNotNull()) { node->GetBoolProperty("binary", isBinary); if (isBinary) { mitk::DataStorage::SetOfObjects::ConstPointer sourcenodes = m_DataStorage->GetSources(node, NULL, true); if (!sourcenodes->empty()) { topSourceNode = this->GetTopLayerNode(sourcenodes); } if (topSourceNode.IsNotNull()) { image = dynamic_cast(topSourceNode->GetData()); topSourceNode->GetIntProperty("Image.Displayed Component", component); } else { image = dynamic_cast(node->GetData()); node->GetIntProperty("Image.Displayed Component", component); } } else { image = dynamic_cast(node->GetData()); node->GetIntProperty("Image.Displayed Component", component); } } mitk::Point3D crosshairPos = this->GetCrossPosition(); std::string statusText; std::stringstream stream; itk::Index<3> p; mitk::BaseRenderer *baseRenderer = this->mitkWidget1->GetSliceNavigationController()->GetRenderer(); unsigned int timestep = baseRenderer->GetTimeStep(); if (image.IsNotNull() && (image->GetTimeSteps() > timestep)) { image->GetGeometry()->WorldToIndex(crosshairPos, p); stream.precision(2); stream << "Position: <" << std::fixed << crosshairPos[0] << ", " << std::fixed << crosshairPos[1] << ", " << std::fixed << crosshairPos[2] << "> mm"; stream << "; Index: <" << p[0] << ", " << p[1] << ", " << p[2] << "> "; mitk::ScalarType pixelValue; mitkPixelTypeMultiplex5(mitk::FastSinglePixelAccess, image->GetChannelDescriptor().GetPixelType(), image, image->GetVolumeData(baseRenderer->GetTimeStep()), p, pixelValue, component); if (fabs(pixelValue) > 1000000 || fabs(pixelValue) < 0.01) { stream << "; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: " << std::scientific << pixelValue << " "; } else { stream << "; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: " << pixelValue << " "; } } else { stream << "No image information at this position!"; } statusText = stream.str(); mitk::StatusBar::GetInstance()->DisplayGreyValueText(statusText.c_str()); } int QmitkStdMultiWidget::GetLayout() const { return m_Layout; } bool QmitkStdMultiWidget::GetGradientBackgroundFlag() const { return m_GradientBackgroundFlag; } void QmitkStdMultiWidget::EnableGradientBackground() { // gradient background is by default only in widget 4, otherwise // interferences between 2D rendering and VTK rendering may occur. for (unsigned int i = 0; i < 4; ++i) { GetRenderWindow(i)->GetRenderer()->GetVtkRenderer()->GradientBackgroundOn(); } m_GradientBackgroundFlag = true; } void QmitkStdMultiWidget::DisableGradientBackground() { for (unsigned int i = 0; i < 4; ++i) { GetRenderWindow(i)->GetRenderer()->GetVtkRenderer()->GradientBackgroundOff(); } m_GradientBackgroundFlag = false; } void QmitkStdMultiWidget::EnableDepartmentLogo() { m_LogoRendering->SetVisibility(true); RequestUpdate(); } void QmitkStdMultiWidget::DisableDepartmentLogo() { m_LogoRendering->SetVisibility(false); RequestUpdate(); } bool QmitkStdMultiWidget::IsDepartmentLogoEnabled() const { return m_LogoRendering->IsVisible(); } void QmitkStdMultiWidget::SetWidgetPlaneVisibility(const char *widgetName, bool visible, mitk::BaseRenderer *renderer) { if (m_DataStorage.IsNotNull()) { mitk::DataNode *n = m_DataStorage->GetNamedNode(widgetName); if (n != NULL) n->SetVisibility(visible, renderer); } } void QmitkStdMultiWidget::SetWidgetPlanesVisibility(bool visible, mitk::BaseRenderer *renderer) { if (m_PlaneNode1.IsNotNull()) { m_PlaneNode1->SetVisibility(visible, renderer); } if (m_PlaneNode2.IsNotNull()) { m_PlaneNode2->SetVisibility(visible, renderer); } if (m_PlaneNode3.IsNotNull()) { m_PlaneNode3->SetVisibility(visible, renderer); } m_RenderingManager->RequestUpdateAll(); } void QmitkStdMultiWidget::SetWidgetPlanesLocked(bool locked) { // do your job and lock or unlock slices. GetRenderWindow1()->GetSliceNavigationController()->SetSliceLocked(locked); GetRenderWindow2()->GetSliceNavigationController()->SetSliceLocked(locked); GetRenderWindow3()->GetSliceNavigationController()->SetSliceLocked(locked); } void QmitkStdMultiWidget::SetWidgetPlanesRotationLocked(bool locked) { // do your job and lock or unlock slices. GetRenderWindow1()->GetSliceNavigationController()->SetSliceRotationLocked(locked); GetRenderWindow2()->GetSliceNavigationController()->SetSliceRotationLocked(locked); GetRenderWindow3()->GetSliceNavigationController()->SetSliceRotationLocked(locked); } void QmitkStdMultiWidget::SetWidgetPlanesRotationLinked(bool link) { emit WidgetPlanesRotationLinked(link); } void QmitkStdMultiWidget::SetWidgetPlaneMode(int userMode) { MITK_DEBUG << "Changing crosshair mode to " << userMode; emit WidgetNotifyNewCrossHairMode(userMode); // Convert user interface mode to actual mode { switch (userMode) { case 0: m_MouseModeSwitcher->SetInteractionScheme(mitk::MouseModeSwitcher::InteractionScheme::MITK); break; case 1: m_MouseModeSwitcher->SetInteractionScheme(mitk::MouseModeSwitcher::InteractionScheme::ROTATION); break; case 2: m_MouseModeSwitcher->SetInteractionScheme(mitk::MouseModeSwitcher::InteractionScheme::ROTATIONLINKED); break; case 3: m_MouseModeSwitcher->SetInteractionScheme(mitk::MouseModeSwitcher::InteractionScheme::SWIVEL); break; } } } void QmitkStdMultiWidget::SetGradientBackgroundColorForRenderWindow(const mitk::Color &upper, const mitk::Color &lower, unsigned int widgetNumber) { if (widgetNumber > 3) { MITK_ERROR << "Gradientbackground for unknown widget!"; return; } m_GradientBackgroundColors[widgetNumber].first = upper; m_GradientBackgroundColors[widgetNumber].second = lower; vtkRenderer *renderer = GetRenderWindow(widgetNumber)->GetRenderer()->GetVtkRenderer(); renderer->SetBackground2(upper[0], upper[1], upper[2]); renderer->SetBackground(lower[0], lower[1], lower[2]); m_GradientBackgroundFlag = true; } void QmitkStdMultiWidget::SetGradientBackgroundColors(const mitk::Color &upper, const mitk::Color &lower) { for (unsigned int i = 0; i < 4; ++i) { vtkRenderer *renderer = GetRenderWindow(i)->GetRenderer()->GetVtkRenderer(); renderer->SetBackground2(upper[0], upper[1], upper[2]); renderer->SetBackground(lower[0], lower[1], lower[2]); } m_GradientBackgroundFlag = true; } void QmitkStdMultiWidget::SetDepartmentLogoPath(const char *path) { m_LogoRendering->SetLogoImagePath(path); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow()); m_LogoRendering->Update(renderer); RequestUpdate(); } void QmitkStdMultiWidget::SetWidgetPlaneModeToSlicing(bool activate) { if (activate) { this->SetWidgetPlaneMode(PLANE_MODE_SLICING); } } void QmitkStdMultiWidget::SetWidgetPlaneModeToRotation(bool activate) { if (activate) { this->SetWidgetPlaneMode(PLANE_MODE_ROTATION); } } void QmitkStdMultiWidget::SetWidgetPlaneModeToSwivel(bool activate) { if (activate) { this->SetWidgetPlaneMode(PLANE_MODE_SWIVEL); } } void QmitkStdMultiWidget::OnLayoutDesignChanged(int layoutDesignIndex) { switch (layoutDesignIndex) { case LAYOUT_DEFAULT: { this->changeLayoutToDefault(); break; } case LAYOUT_2D_IMAGES_UP: { this->changeLayoutTo2DImagesUp(); break; } case LAYOUT_2D_IMAGES_LEFT: { this->changeLayoutTo2DImagesLeft(); break; } case LAYOUT_BIG_3D: { this->changeLayoutToBig3D(); break; } case LAYOUT_WIDGET1: { this->changeLayoutToWidget1(); break; } case LAYOUT_WIDGET2: { this->changeLayoutToWidget2(); break; } case LAYOUT_WIDGET3: { this->changeLayoutToWidget3(); break; } case LAYOUT_2X_2D_AND_3D_WIDGET: { this->changeLayoutTo2x2Dand3DWidget(); break; } case LAYOUT_ROW_WIDGET_3_AND_4: { this->changeLayoutToRowWidget3And4(); break; } case LAYOUT_COLUMN_WIDGET_3_AND_4: { this->changeLayoutToColumnWidget3And4(); break; } case LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4: { this->changeLayoutToRowWidgetSmall3andBig4(); break; } case LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4: { this->changeLayoutToSmallUpperWidget2Big3and4(); break; } case LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET: { this->changeLayoutToLeft2Dand3DRight2D(); break; } }; } void QmitkStdMultiWidget::UpdateAllWidgets() { mitkWidget1->resize(mitkWidget1Container->frameSize().width() - 1, mitkWidget1Container->frameSize().height()); mitkWidget1->resize(mitkWidget1Container->frameSize().width(), mitkWidget1Container->frameSize().height()); mitkWidget2->resize(mitkWidget2Container->frameSize().width() - 1, mitkWidget2Container->frameSize().height()); mitkWidget2->resize(mitkWidget2Container->frameSize().width(), mitkWidget2Container->frameSize().height()); mitkWidget3->resize(mitkWidget3Container->frameSize().width() - 1, mitkWidget3Container->frameSize().height()); mitkWidget3->resize(mitkWidget3Container->frameSize().width(), mitkWidget3Container->frameSize().height()); mitkWidget4->resize(mitkWidget4Container->frameSize().width() - 1, mitkWidget4Container->frameSize().height()); mitkWidget4->resize(mitkWidget4Container->frameSize().width(), mitkWidget4Container->frameSize().height()); } void QmitkStdMultiWidget::HideAllWidgetToolbars() { mitkWidget1->HideRenderWindowMenu(); mitkWidget2->HideRenderWindowMenu(); mitkWidget3->HideRenderWindowMenu(); mitkWidget4->HideRenderWindowMenu(); } void QmitkStdMultiWidget::ActivateMenuWidget(bool state) { mitkWidget1->ActivateMenuWidget(state, this); mitkWidget2->ActivateMenuWidget(state, this); mitkWidget3->ActivateMenuWidget(state, this); mitkWidget4->ActivateMenuWidget(state, this); } bool QmitkStdMultiWidget::IsMenuWidgetEnabled() const { return mitkWidget1->GetActivateMenuWidgetFlag(); } void QmitkStdMultiWidget::SetDecorationColor(unsigned int widgetNumber, mitk::Color color) { switch (widgetNumber) { case 0: if (m_PlaneNode1.IsNotNull()) { m_PlaneNode1->SetColor(color); } break; case 1: if (m_PlaneNode2.IsNotNull()) { m_PlaneNode2->SetColor(color); } break; case 2: if (m_PlaneNode3.IsNotNull()) { m_PlaneNode3->SetColor(color); } break; case 3: m_DecorationColorWidget4 = color; break; default: MITK_ERROR << "Decoration color for unknown widget!"; break; } } void QmitkStdMultiWidget::ResetCrosshair() { if (m_DataStorage.IsNotNull()) { m_RenderingManager->InitializeViewsByBoundingObjects(m_DataStorage); // m_RenderingManager->InitializeViews( m_DataStorage->ComputeVisibleBoundingGeometry3D() ); // reset interactor to normal slicing this->SetWidgetPlaneMode(PLANE_MODE_SLICING); } } void QmitkStdMultiWidget::EnableColoredRectangles() { m_RectangleProps[0]->SetVisibility(1); m_RectangleProps[1]->SetVisibility(1); m_RectangleProps[2]->SetVisibility(1); m_RectangleProps[3]->SetVisibility(1); } void QmitkStdMultiWidget::DisableColoredRectangles() { m_RectangleProps[0]->SetVisibility(0); m_RectangleProps[1]->SetVisibility(0); m_RectangleProps[2]->SetVisibility(0); m_RectangleProps[3]->SetVisibility(0); } bool QmitkStdMultiWidget::IsColoredRectanglesEnabled() const { return m_RectangleProps[0]->GetVisibility() > 0; } mitk::MouseModeSwitcher *QmitkStdMultiWidget::GetMouseModeSwitcher() { return m_MouseModeSwitcher; } mitk::DataNode::Pointer QmitkStdMultiWidget::GetWidgetPlane1() { return this->m_PlaneNode1; } mitk::DataNode::Pointer QmitkStdMultiWidget::GetWidgetPlane2() { return this->m_PlaneNode2; } mitk::DataNode::Pointer QmitkStdMultiWidget::GetWidgetPlane3() { return this->m_PlaneNode3; } mitk::DataNode::Pointer QmitkStdMultiWidget::GetWidgetPlane(int id) { switch (id) { case 1: return this->m_PlaneNode1; break; case 2: return this->m_PlaneNode2; break; case 3: return this->m_PlaneNode3; break; default: return NULL; } } diff --git a/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkAddNewPropertyDialog.cpp b/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkAddNewPropertyDialog.cpp index cd90cd0cd9..523daad284 100644 --- a/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkAddNewPropertyDialog.cpp +++ b/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkAddNewPropertyDialog.cpp @@ -1,179 +1,186 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkAddNewPropertyDialog.h" #include "mitkGetPropertyService.h" -#include -#include #include #include +#include +#include -QmitkAddNewPropertyDialog::QmitkAddNewPropertyDialog(mitk::Overlay::Pointer overlay, mitk::BaseRenderer::Pointer renderer, QWidget* parent) - : QDialog(parent), - m_Overlay(overlay), - m_Renderer(renderer) +QmitkAddNewPropertyDialog::QmitkAddNewPropertyDialog(mitk::Annotation::Pointer overlay, + mitk::BaseRenderer::Pointer renderer, + QWidget *parent) + : QDialog(parent), m_Overlay(overlay), m_Renderer(renderer) { this->Initialize(); } QmitkAddNewPropertyDialog::~QmitkAddNewPropertyDialog() { } void QmitkAddNewPropertyDialog::Initialize() { m_Controls.setupUi(this); QStringList types; - types << "bool" << "double" << "float" << "int" << "string"; + types << "bool" + << "double" + << "float" + << "int" + << "string"; m_Controls.typeComboBox->addItems(types); - connect(m_Controls.typeComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(ShowAdequateValueWidget(const QString&))); + connect(m_Controls.typeComboBox, + SIGNAL(currentIndexChanged(const QString &)), + this, + SLOT(ShowAdequateValueWidget(const QString &))); connect(m_Controls.addButton, SIGNAL(clicked()), this, SLOT(AddNewProperty())); connect(m_Controls.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); this->ShowAdequateValueWidget(types[0]); } void QmitkAddNewPropertyDialog::AddNewProperty() { if (m_Controls.nameLineEdit->text().isEmpty()) { QMessageBox::critical(this, "No name specified", "Enter a property name."); return; } if (!this->ValidateValue()) { QMessageBox::critical(this, "Invalid value", "Enter a valid " + m_Controls.typeComboBox->currentText() + " value."); return; } m_Overlay->SetProperty(m_Controls.nameLineEdit->text().toStdString(), this->CreateProperty()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); this->accept(); } mitk::BaseProperty::Pointer QmitkAddNewPropertyDialog::CreateProperty() const { QString type = m_Controls.typeComboBox->currentText(); if (type == "bool") { return mitk::BoolProperty::New(m_Controls.valueCheckBox->isChecked()).GetPointer(); } else if (type == "double") { return mitk::DoubleProperty::New(m_Controls.valueLineEdit->text().toDouble()).GetPointer(); } else if (type == "float") { return mitk::FloatProperty::New(m_Controls.valueLineEdit->text().toFloat()).GetPointer(); } else if (type == "int") { return mitk::IntProperty::New(m_Controls.valueLineEdit->text().toInt()).GetPointer(); } else if (type == "string") { return mitk::StringProperty::New(m_Controls.valueLineEdit->text().toStdString()).GetPointer(); } else { assert(false && "Property creation for selected type not implemented!"); } return NULL; } bool QmitkAddNewPropertyDialog::ValidateValue() { QString type = m_Controls.typeComboBox->currentText(); if (type == "bool") { return true; } else if (type == "double") { bool ok = false; m_Controls.valueLineEdit->text().toDouble(&ok); return ok; } else if (type == "float") { bool ok = false; m_Controls.valueLineEdit->text().toFloat(&ok); return ok; } else if (type == "int") { bool ok = false; m_Controls.valueLineEdit->text().toInt(&ok); return ok; } else if (type == "string") { return true; } else { assert(false && "Value validation for selected type not implemented!"); } return false; } -void QmitkAddNewPropertyDialog::ShowAdequateValueWidget(const QString& type) +void QmitkAddNewPropertyDialog::ShowAdequateValueWidget(const QString &type) { m_Controls.valueLineEdit->clear(); m_Controls.valueLineEdit->hide(); m_Controls.valueCheckBox->setChecked(false); m_Controls.valueCheckBox->hide(); if (type == "bool") { m_Controls.valueCheckBox->show(); } else if (type == "double") { m_Controls.valueLineEdit->setText("0"); m_Controls.valueLineEdit->show(); } else if (type == "float") { m_Controls.valueLineEdit->setText("0"); m_Controls.valueLineEdit->show(); } else if (type == "int") { m_Controls.valueLineEdit->setText("0"); m_Controls.valueLineEdit->show(); } else if (type == "string") { m_Controls.valueLineEdit->show(); } else { assert(false && "No adequate value widget specified for selected type!"); } } diff --git a/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkAddNewPropertyDialog.h b/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkAddNewPropertyDialog.h index 9a1c0823e7..76cc57a121 100644 --- a/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkAddNewPropertyDialog.h +++ b/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkAddNewPropertyDialog.h @@ -1,48 +1,50 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkAddNewPropertyDialog_h #define QmitkAddNewPropertyDialog_h -#include -#include -#include #include +#include +#include +#include #include class QmitkAddNewPropertyDialog : public QDialog { Q_OBJECT public: - explicit QmitkAddNewPropertyDialog(mitk::Overlay::Pointer overlay, mitk::BaseRenderer::Pointer renderer = NULL, QWidget* parent = NULL); + explicit QmitkAddNewPropertyDialog(mitk::Annotation::Pointer overlay, + mitk::BaseRenderer::Pointer renderer = NULL, + QWidget *parent = NULL); ~QmitkAddNewPropertyDialog(); private slots: void AddNewProperty(); - void ShowAdequateValueWidget(const QString& type); + void ShowAdequateValueWidget(const QString &type); bool ValidateValue(); private: mitk::BaseProperty::Pointer CreateProperty() const; void Initialize(); Ui::QmitkAddNewPropertyDialog m_Controls; - mitk::Overlay::Pointer m_Overlay; + mitk::Annotation::Pointer m_Overlay; mitk::BaseRenderer::Pointer m_Renderer; }; #endif diff --git a/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.cpp b/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.cpp index b23d495759..a85b0fe740 100644 --- a/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.cpp +++ b/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.cpp @@ -1,537 +1,537 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include // Blueberry #include #include #include // Qmitk #include "QmitkAddNewPropertyDialog.h" #include "QmitkOverlayManagerView.h" #include "QmitkPropertyItemDelegate.h" #include "QmitkPropertyItemModel.h" #include // Qt #include #include #include #include "internal/org_mitk_gui_qt_overlaymanager_Activator.h" -#include "mitkAnnotationPlacer.h" -#include "mitkAnnotationService.h" +#include "mitkAnnotationUtils.h" #include "mitkGetPropertyService.h" -#include "mitkOverlayLayouter2D.h" +#include "mitkLayoutAnnotationRenderer.h" +#include "mitkManualPlacementAnnotationRenderer.h" #include "mitkRenderingManager.h" -#include +#include #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include const std::string QmitkOverlayManagerView::VIEW_ID = "org.mitk.views.overlaymanager"; QmitkOverlayManagerView::QmitkOverlayManagerView() : m_Parent(nullptr), m_PropertyNameChangedTag(0), m_OverlayManagerObserverTag(0), m_PropertyAliases(nullptr), m_PropertyDescriptions(nullptr), m_PropertyPersistence(nullptr), m_ProxyModel(nullptr), m_Model(nullptr), m_Delegate(nullptr), m_Renderer(nullptr), m_AddOverlayMenu(nullptr) { } QmitkOverlayManagerView::~QmitkOverlayManagerView() { } void QmitkOverlayManagerView::SetFocus() { } void QmitkOverlayManagerView::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); m_Controls.m_OverlayList->clear(); mitk::IRenderWindowPart *renderWindowPart = this->GetRenderWindowPart(); if (renderWindowPart != NULL) { QHash renderWindows = renderWindowPart->GetQmitkRenderWindows(); Q_FOREACH (QString renderWindow, renderWindows.keys()) { if (!m_Renderer) m_Renderer = renderWindows[renderWindow]->GetRenderer(); m_Controls.m_RendererCB->addItem(renderWindow); } } InitializeAddOverlayMenu(); m_ProxyModel = new QSortFilterProxyModel(m_Controls.m_PropertyTree); m_Model = new QmitkPropertyItemModel(m_ProxyModel); m_ProxyModel->setSourceModel(m_Model); m_ProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_ProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); m_ProxyModel->setDynamicSortFilter(true); m_Delegate = new QmitkPropertyItemDelegate(m_Controls.m_PropertyTree); m_Controls.m_PropertyTree->setItemDelegateForColumn(1, m_Delegate); m_Controls.m_PropertyTree->setModel(m_ProxyModel); m_Controls.m_PropertyTree->setColumnWidth(0, 160); m_Controls.m_PropertyTree->sortByColumn(0, Qt::AscendingOrder); m_Controls.m_PropertyTree->setSelectionBehavior(QAbstractItemView::SelectRows); m_Controls.m_PropertyTree->setSelectionMode(QAbstractItemView::SingleSelection); m_Controls.m_PropertyTree->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::DoubleClicked); connect(m_Controls.m_RendererCB, SIGNAL(currentIndexChanged(int)), this, SLOT(OnPropertyListChanged(int))); connect(m_Controls.newButton, SIGNAL(clicked()), this, SLOT(OnAddNewProperty())); connect(m_Controls.m_PropertyTree->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(OnCurrentRowChanged(const QModelIndex &, const QModelIndex &))); connect(m_Controls.m_OverlayList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(OnOverlaySelectionChanged(QListWidgetItem *, QListWidgetItem *))); connect(m_Controls.m_DeleteOverlay, SIGNAL(clicked()), this, SLOT(OnDelete())); connect(m_Controls.m_AddOverlay, SIGNAL(clicked()), this, SLOT(OnAddOverlay())); itk::MemberCommand::Pointer command = itk::MemberCommand::New(); command->SetCallbackFunction(this, &QmitkOverlayManagerView::OnFocusChanged); m_RenderWindowFocusObserverTag = mitk::RenderingManager::GetInstance()->AddObserver(mitk::FocusChangedEvent(), command); } void QmitkOverlayManagerView::OnFocusChanged(itk::Object * /*caller*/, const itk::EventObject &event) { const mitk::FocusChangedEvent *focusEvent = dynamic_cast(&event); if (focusEvent) { QHash renderWindows = this->GetRenderWindowPart()->GetQmitkRenderWindows(); m_Controls.m_RendererCB->clear(); Q_FOREACH (QString renderWindow, renderWindows.keys()) { m_Controls.m_RendererCB->addItem(renderWindow); if (renderWindows[renderWindow]->GetVtkRenderWindow() == mitk::RenderingManager::GetInstance()->GetFocusedRenderWindow()) { m_Controls.m_RendererCB->setCurrentText(renderWindow); } } this->OnActivateOverlayList(); } } QString QmitkOverlayManagerView::GetPropertyNameOrAlias(const QModelIndex &index) { QString propertyName; if (index.isValid()) { QModelIndex current = index; while (current.isValid()) { QString name = m_ProxyModel->data(m_ProxyModel->index(current.row(), 0, current.parent())).toString(); propertyName.prepend(propertyName.isEmpty() ? name : name.append('.')); current = current.parent(); } } return propertyName; } void QmitkOverlayManagerView::OnCurrentRowChanged(const QModelIndex ¤t, const QModelIndex &) { if (m_PropertyDescriptions != nullptr && current.isValid()) { QString name = this->GetPropertyNameOrAlias(current); if (!name.isEmpty()) { QString alias; bool isTrueName = true; if (m_PropertyAliases != nullptr) { std::string trueName = m_PropertyAliases->GetPropertyName(name.toStdString()); if (trueName.empty() && !m_SelectionClassName.empty()) trueName = m_PropertyAliases->GetPropertyName(name.toStdString(), m_SelectionClassName); if (!trueName.empty()) { alias = name; name = QString::fromStdString(trueName); isTrueName = false; } } QString description = QString::fromStdString(m_PropertyDescriptions->GetDescription(name.toStdString())); std::vector aliases; if (!isTrueName && m_PropertyAliases != nullptr) { aliases = m_PropertyAliases->GetAliases(name.toStdString(), m_SelectionClassName); if (aliases.empty() && !m_SelectionClassName.empty()) aliases = m_PropertyAliases->GetAliases(name.toStdString()); } bool isPersistent = false; // QString persistenceKey; if (m_PropertyPersistence != nullptr) { isPersistent = m_PropertyPersistence->HasInfo(name.toStdString()); /*if (isPersistent) { persistenceKey = QString::fromStdString(m_PropertyPersistence->GetInfo(name.toStdString())->GetKey()); if (persistenceKey.isEmpty()) persistenceKey = name; }*/ } if (!description.isEmpty() || !aliases.empty() || isPersistent) { QString customizedDescription; if (!description.isEmpty()) customizedDescription += "

" + description + "

"; if (!aliases.empty() || isPersistent) { customizedDescription += "
"; if (!aliases.empty()) { customizedDescription += aliases.size() > 1 ? "" : ""; } if (isPersistent) customizedDescription += ""; customizedDescription += "
"; } return; } } } } void QmitkOverlayManagerView::OnPropertyNameChanged(const itk::EventObject &) { mitk::PropertyList *propertyList = m_Model->GetPropertyList(); if (propertyList != NULL) { mitk::BaseProperty *nameProperty = propertyList->GetProperty("name"); if (nameProperty != NULL) { QString partName = "Properties ("; partName.append(QString::fromStdString(nameProperty->GetValueAsString())).append(')'); this->SetPartName(partName); } } } void QmitkOverlayManagerView::OnSelectionChanged(berry::IWorkbenchPart::Pointer, const QList &nodes) { } void QmitkOverlayManagerView::InitializeAddOverlayMenu() { m_AddOverlayMenu = new QMenu(m_Controls.m_AddOverlay); - m_AddOverlayMenu->addAction("TextOverlay2D"); - m_AddOverlayMenu->addAction("TextOverlay3D"); - m_AddOverlayMenu->addAction("LabelOverlay"); - m_AddOverlayMenu->addAction("ColorBarOverlay"); - m_AddOverlayMenu->addAction("ScaleLegendOverlay"); - m_AddOverlayMenu->addAction("LogoOverlay"); + m_AddOverlayMenu->addAction("TextAnnotation2D"); + m_AddOverlayMenu->addAction("TextAnnotation3D"); + m_AddOverlayMenu->addAction("LabelAnnotation"); + m_AddOverlayMenu->addAction("ColorBarAnnotation"); + m_AddOverlayMenu->addAction("ScaleLegendAnnotation"); + m_AddOverlayMenu->addAction("LogoAnnotation"); } void QmitkOverlayManagerView::Activated() { // this->OnActivateOverlayList(); } void QmitkOverlayManagerView::Deactivated() { } void QmitkOverlayManagerView::Visible() { this->OnActivateOverlayList(); } void QmitkOverlayManagerView::Hidden() { } void QmitkOverlayManagerView::OnPropertyListChanged(int index) { if (index == -1) return; QString renderer = m_Controls.m_RendererCB->itemText(index); QmitkRenderWindow *renwin = this->GetRenderWindowPart()->GetQmitkRenderWindow(renderer); m_Renderer = renwin ? renwin->GetRenderer() : nullptr; this->OnOverlaySelectionChanged(m_Controls.m_OverlayList->currentItem(), nullptr); this->OnActivateOverlayList(); } void QmitkOverlayManagerView::OnAddNewProperty() { std::unique_ptr dialog( new QmitkAddNewPropertyDialog(m_SelectedOverlay, m_Renderer, m_Parent)); if (dialog->exec() == QDialog::Accepted) this->m_Model->Update(); } void QmitkOverlayManagerView::OnActivateOverlayList() { if (!m_Renderer) return; std::vector arList = - mitk::AnnotationService::GetAnnotationRenderer(m_Renderer->GetName()); + mitk::AnnotationUtils::GetAnnotationRenderer(m_Renderer->GetName()); m_Controls.m_OverlayList->clear(); for (auto ar : arList) { for (auto overlay : ar->GetServices()) { QListWidgetItem *item = new QListWidgetItem(); item->setData(Qt::UserRole, QVariant(overlay->GetMicroserviceID().c_str())); QString text(overlay->GetName().c_str()); if (text.length() > 0) { text.append(" : "); } text.append(overlay->GetNameOfClass()); item->setText(text); m_Controls.m_OverlayList->addItem(item); } } } void QmitkOverlayManagerView::OnOverlaySelectionChanged(QListWidgetItem *current, QListWidgetItem *) { mitk::PropertyList *propertyList = m_Model->GetPropertyList(); if (propertyList != NULL) { mitk::BaseProperty *nameProperty = propertyList->GetProperty("name"); if (nameProperty != NULL) nameProperty->RemoveObserver(m_PropertyNameChangedTag); m_PropertyNameChangedTag = 0; } - mitk::Overlay *overlay = nullptr; + mitk::Annotation *overlay = nullptr; QString oID; if (current) { oID = current->data(Qt::UserRole).toString(); OverlayMapType::iterator it = m_OverlayMap.find(oID.toStdString()); if (it != m_OverlayMap.end()) overlay = it->second; else { - overlay = mitk::AnnotationService::GetOverlay(oID.toStdString()); + overlay = mitk::AnnotationUtils::GetAnnotation(oID.toStdString()); } } if (!overlay) { m_SelectedOverlay = NULL; this->SetPartName("Overlay Properties"); m_Model->SetPropertyList(NULL); m_Delegate->SetPropertyList(NULL); m_Controls.newButton->setEnabled(false); } else { m_SelectedOverlay = overlay; QString selectionClassName = m_SelectedOverlay->GetNameOfClass(); m_SelectionClassName = selectionClassName.toStdString(); mitk::PropertyList::Pointer propertyList = overlay->GetPropertyList(); m_Model->SetPropertyList(propertyList, selectionClassName); m_Delegate->SetPropertyList(propertyList); OnPropertyNameChanged(itk::ModifiedEvent()); mitk::BaseProperty *nameProperty = m_SelectedOverlay->GetProperty("name"); if (nameProperty != NULL) { itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); command->SetCallbackFunction(this, &QmitkOverlayManagerView::OnPropertyNameChanged); m_PropertyNameChangedTag = nameProperty->AddObserver(itk::ModifiedEvent(), command); } m_Controls.newButton->setEnabled(true); } if (!m_ProxyModel->filterRegExp().isEmpty()) m_Controls.m_PropertyTree->expandAll(); } void QmitkOverlayManagerView::OnDelete() { auto items = m_Controls.m_OverlayList->selectedItems(); if (items.count() < 1) return; - mitk::Overlay *overlay = nullptr; + mitk::Annotation *overlay = nullptr; QListWidgetItem *item = items[0]; if (item) - overlay = reinterpret_cast(item->data(Qt::UserRole).value()); + overlay = reinterpret_cast(item->data(Qt::UserRole).value()); } void QmitkOverlayManagerView::OnAddOverlay() { QAction *action = m_AddOverlayMenu->exec(QCursor::pos()); - mitk::Overlay::Pointer overlay; + mitk::Annotation::Pointer overlay; if (action != NULL) { const QString widgetKey = action->text(); - if (widgetKey == "TextOverlay2D") + if (widgetKey == "TextAnnotation2D") overlay = CreateTextOverlay2D(); - else if (widgetKey == "TextOverlay3D") + else if (widgetKey == "TextAnnotation3D") overlay = CreateTextOverlay3D(); - else if (widgetKey == "LabelOverlay") + else if (widgetKey == "LabelAnnotation") overlay = CreateLabelOverlay(); - else if (widgetKey == "ColorBarOverlay") + else if (widgetKey == "ColorBarAnnotation") overlay = CreateColorBarOverlay(); - else if (widgetKey == "ScaleLegendOverlay") + else if (widgetKey == "ScaleLegendAnnotation") overlay = CreateScaleLegendOverlay(); - else if (widgetKey == "LogoOverlay") + else if (widgetKey == "LogoAnnotation") overlay = CreateLogoOverlay(); mitk::BaseRenderer *renderer = this->GetRenderWindowPart()->GetQmitkRenderWindow(m_Controls.m_RendererCB->currentText())->GetRenderer(); - mitk::OverlayLayouter2D::AddOverlay(overlay, renderer); + mitk::LayoutAnnotationRenderer::AddAnnotation(overlay, renderer); m_OverlayMap[overlay->GetMicroserviceID()] = overlay; } OnActivateOverlayList(); } -mitk::Overlay::Pointer QmitkOverlayManagerView::CreateTextOverlay2D() +mitk::Annotation::Pointer QmitkOverlayManagerView::CreateTextOverlay2D() { - mitk::TextOverlay2D::Pointer to = mitk::TextOverlay2D::New(); + mitk::TextAnnotation2D::Pointer to = mitk::TextAnnotation2D::New(); to->SetText("Test"); return to.GetPointer(); } -mitk::Overlay::Pointer QmitkOverlayManagerView::CreateTextOverlay3D() +mitk::Annotation::Pointer QmitkOverlayManagerView::CreateTextOverlay3D() { - mitk::TextOverlay3D::Pointer to = mitk::TextOverlay3D::New(); + mitk::TextAnnotation3D::Pointer to = mitk::TextAnnotation3D::New(); return to.GetPointer(); } -mitk::Overlay::Pointer QmitkOverlayManagerView::CreateLabelOverlay() +mitk::Annotation::Pointer QmitkOverlayManagerView::CreateLabelOverlay() { - mitk::LabelOverlay3D::Pointer to = mitk::LabelOverlay3D::New(); + mitk::LabelAnnotation3D::Pointer to = mitk::LabelAnnotation3D::New(); return to.GetPointer(); } -mitk::Overlay::Pointer QmitkOverlayManagerView::CreateColorBarOverlay() +mitk::Annotation::Pointer QmitkOverlayManagerView::CreateColorBarOverlay() { - mitk::ColorBarOverlay::Pointer to = mitk::ColorBarOverlay::New(); + mitk::ColorBarAnnotation::Pointer to = mitk::ColorBarAnnotation::New(); return to.GetPointer(); } -mitk::Overlay::Pointer QmitkOverlayManagerView::CreateScaleLegendOverlay() +mitk::Annotation::Pointer QmitkOverlayManagerView::CreateScaleLegendOverlay() { - mitk::ScaleLegendOverlay::Pointer to = mitk::ScaleLegendOverlay::New(); + mitk::ScaleLegendAnnotation::Pointer to = mitk::ScaleLegendAnnotation::New(); return to.GetPointer(); } -mitk::Overlay::Pointer QmitkOverlayManagerView::CreateLogoOverlay() +mitk::Annotation::Pointer QmitkOverlayManagerView::CreateLogoOverlay() { - mitk::LogoOverlay::Pointer to = mitk::LogoOverlay::New(); + mitk::LogoAnnotation::Pointer to = mitk::LogoAnnotation::New(); return to.GetPointer(); } void QmitkOverlayManagerView::RenderWindowPartActivated(mitk::IRenderWindowPart * /*renderWindowPart*/) { if (m_Controls.m_RendererCB->count() == 0) { QHash renderWindows = this->GetRenderWindowPart()->GetQmitkRenderWindows(); Q_FOREACH (QString renderWindow, renderWindows.keys()) { m_Controls.m_RendererCB->addItem(renderWindow); } } OnActivateOverlayList(); } void QmitkOverlayManagerView::RenderWindowPartDeactivated(mitk::IRenderWindowPart *) { if (m_Controls.m_RendererCB->count() > 0) { m_Controls.m_RendererCB->clear(); } m_Controls.m_OverlayList->clear(); } diff --git a/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.h b/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.h index 86fda5a808..46cc49b709 100644 --- a/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.h +++ b/Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.h @@ -1,125 +1,125 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkOverlayManagerView_h #define QmitkOverlayManagerView_h #include +#include "mitkAnnotation.h" #include "mitkILifecycleAwarePart.h" -#include "mitkOverlay.h" #include "ui_QmitkOverlayManagerViewControls.h" #include #include class QmitkPropertyItemDelegate; class QmitkPropertyItemModel; class QSortFilterProxyModel; namespace mitk { class IPropertyAliases; class IPropertyDescriptions; class IPropertyPersistence; } /** \brief QmitkOverlayManagerView allows to view all overlays added to the mitk::OverlayManager. Properties of these overlays can be modified. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class QmitkOverlayManagerView : public QmitkAbstractView, public mitk::IRenderWindowPartListener, public mitk::ILifecycleAwarePart { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: - typedef std::map OverlayMapType; + typedef std::map OverlayMapType; static const std::string VIEW_ID; QmitkOverlayManagerView(); ~QmitkOverlayManagerView(); protected: virtual void CreateQtPartControl(QWidget *parent) override; virtual void SetFocus() override; void RenderWindowPartActivated(mitk::IRenderWindowPart *renderWindowPart) override; void RenderWindowPartDeactivated(mitk::IRenderWindowPart *) override; Ui::QmitkOverlayManagerViewControls m_Controls; void OnFocusChanged(itk::Object *, const itk::EventObject &event); private slots: void OnCurrentRowChanged(const QModelIndex ¤t, const QModelIndex &previous); void OnPropertyListChanged(int index); void OnAddNewProperty(); void OnActivateOverlayList(); void OnOverlaySelectionChanged(QListWidgetItem *current, QListWidgetItem *); void OnDelete(); void OnAddOverlay(); private: - mitk::Overlay::Pointer CreateTextOverlay2D(); - mitk::Overlay::Pointer CreateTextOverlay3D(); - mitk::Overlay::Pointer CreateLabelOverlay(); - mitk::Overlay::Pointer CreateColorBarOverlay(); - mitk::Overlay::Pointer CreateScaleLegendOverlay(); - mitk::Overlay::Pointer CreateLogoOverlay(); + mitk::Annotation::Pointer CreateTextOverlay2D(); + mitk::Annotation::Pointer CreateTextOverlay3D(); + mitk::Annotation::Pointer CreateLabelOverlay(); + mitk::Annotation::Pointer CreateColorBarOverlay(); + mitk::Annotation::Pointer CreateScaleLegendOverlay(); + mitk::Annotation::Pointer CreateLogoOverlay(); QString GetPropertyNameOrAlias(const QModelIndex &index); void OnPropertyNameChanged(const itk::EventObject &event); void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes) override; void InitializeAddOverlayMenu(); /** \see berry::IPartListener::PartActivated */ virtual void Activated(); /** \see berry::IPartListener::PartDeactivated */ virtual void Deactivated(); /** \see berry::IPartListener::PartVisible */ virtual void Visible(); /** \see berry::IPartListener::PartHidden */ virtual void Hidden(); QWidget *m_Parent; unsigned long m_PropertyNameChangedTag; unsigned long m_OverlayManagerObserverTag; std::string m_SelectionClassName; mitk::IPropertyAliases *m_PropertyAliases; mitk::IPropertyDescriptions *m_PropertyDescriptions; mitk::IPropertyPersistence *m_PropertyPersistence; QSortFilterProxyModel *m_ProxyModel; QmitkPropertyItemModel *m_Model; QmitkPropertyItemDelegate *m_Delegate; - mitk::Overlay::Pointer m_SelectedOverlay; + mitk::Annotation::Pointer m_SelectedOverlay; mitk::BaseRenderer *m_Renderer; QMenu *m_AddOverlayMenu; unsigned long m_RenderWindowFocusObserverTag; OverlayMapType m_OverlayMap; }; #endif // QmitkOverlayManagerView_h