diff --git a/Modules/Overlays/QmitkCustomWidgetOverlay.cpp b/Modules/Overlays/QmitkCustomWidgetOverlay.cpp new file mode 100644 index 0000000000..fa233291dd --- /dev/null +++ b/Modules/Overlays/QmitkCustomWidgetOverlay.cpp @@ -0,0 +1,41 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2010-01-14 14:20:26 +0100 (Thu, 14 Jan 2010) $ +Version: $Revision: 21047 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkCustomWidgetOverlay.h" + + +QmitkCustomWidgetOverlay::QmitkCustomWidgetOverlay( const char* id ) +: QmitkOverlay(id) +{ + QmitkOverlay::AddDropShadow( m_Widget ); +} + +QmitkCustomWidgetOverlay::~QmitkCustomWidgetOverlay() +{ +} + +void QmitkCustomWidgetOverlay::SetWidget( QWidget* widget ) +{ + if ( widget != NULL ) + { + m_Widget = widget; + m_WidgetIsCustom = true; + } +} + + + diff --git a/Modules/Overlays/QmitkCustomWidgetOverlay.h b/Modules/Overlays/QmitkCustomWidgetOverlay.h new file mode 100644 index 0000000000..e9c50220e3 --- /dev/null +++ b/Modules/Overlays/QmitkCustomWidgetOverlay.h @@ -0,0 +1,65 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-05-28 17:19:30 +0200 (Thu, 28 May 2009) $ +Version: $Revision: 17495 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QmitkCustomWidgetOverlay_H_HEADER_INCLUDED_C10DC4EB +#define QmitkCustomWidgetOverlay_H_HEADER_INCLUDED_C10DC4EB + +// MITK +#include "QmitkOverlay.h" + +#include "OverlaysExports.h" + + +/** \class QmitkCustomWidgetOverlay +* \brief object representing a custom widget that is handled and positioned +* as an overlay. +* +* A QmitkCustomWidgetOverlay is a generic sub-class of QmitkOverlay. It +* offers the possibility to set the internal m_Widget from the outside. +* +* This offers the possibility to position custom widgets 'on top of' other +* widgets using the positioning mechanism of all overlays. +* +* \warn The custom widgets need to be configured and connected manually. +* Properties cannot be set. +* +* \ingroup Overlays +*/ + + + class Overlays_EXPORT QmitkCustomWidgetOverlay : public QmitkOverlay + { + public: + + /** + * @brief Default Constructor + **/ + QmitkCustomWidgetOverlay( const char* id ); + + /** + * @brief Default Destructor + **/ + virtual ~QmitkCustomWidgetOverlay(); + + void SetWidget( QWidget* widget ); + + }; + + +#endif /* QmitkCustomWidgetOverlay_H_HEADER_INCLUDED_C10DC4EB */ + diff --git a/Modules/Overlays/QmitkOverlay.cpp b/Modules/Overlays/QmitkOverlay.cpp index 27c054f2b6..c1b356ff34 100644 --- a/Modules/Overlays/QmitkOverlay.cpp +++ b/Modules/Overlays/QmitkOverlay.cpp @@ -1,78 +1,82 @@ /*=================================================================== 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 "QmitkOverlay.h" #include #include QmitkOverlay::QmitkOverlay( const char* id ) :QObject() , m_Id(id) , m_Position(top_Left) , m_Layer(-1) , m_Widget(NULL) +, m_WidgetIsCustom(false) { } QmitkOverlay::~QmitkOverlay() { - if (m_Widget) + if ( m_Widget && !m_WidgetIsCustom ) { m_Widget->deleteLater(); m_Widget = NULL; } } QmitkOverlay::DisplayPosition QmitkOverlay::GetPosition() { return m_Position; } void QmitkOverlay::SetPosition( DisplayPosition pos ) { m_Position = pos; } unsigned int QmitkOverlay::GetLayer() { return m_Layer; } void QmitkOverlay::SetLayer( unsigned int layer ) { m_Layer = layer; } QWidget* QmitkOverlay::GetWidget() { return m_Widget; } void QmitkOverlay::AddDropShadow( QWidget* widget ) { - QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(widget); - effect->setOffset( QPointF( 1.0, 1.0 ) ); - effect->setBlurRadius( 0 ); - effect->setColor( Qt::black ); - - widget->setGraphicsEffect( effect ); + if (m_Widget) + { + QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(widget); + effect->setOffset( QPointF( 1.0, 1.0 ) ); + effect->setBlurRadius( 0 ); + effect->setColor( Qt::black ); + + widget->setGraphicsEffect( effect ); + } } diff --git a/Modules/Overlays/QmitkOverlay.h b/Modules/Overlays/QmitkOverlay.h index 5824163472..503a17f7a3 100644 --- a/Modules/Overlays/QmitkOverlay.h +++ b/Modules/Overlays/QmitkOverlay.h @@ -1,129 +1,131 @@ /*=================================================================== 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 MITKOVERLAY_H_HEADER_INCLUDED_C10DC4EB #define MITKOVERLAY_H_HEADER_INCLUDED_C10DC4EB // MITK #include "mitkCommon.h" #include "mitkPropertyList.h" // Qt #include #include "OverlaysExports.h" /** \brief Abstract base class for all overlay-objects in MITK This class is the basis for all classes representing objects that can be visualized as overlays in MITK. It encapsulates an ID, as well as a display-position and a layer. The ID is used to access mitkProperties in a PropertyList that holds information that is needed for the visualization, e.g. text for TextOverlays or scaleFactor for ScalarBarOverlays ... The display-position encodes where on the screen the overlay will be positioned at (see and USE the constants defined by DisplayPosition): \verbatim 0 - 1 - 2 | | | 3 - - 4 | | | 5 - 6 - 7 \endverbatim The layer is needed if several overlays shall be put in the same position. In this case the layer defines the order in which the objects are layouted. \ingroup Qmitk */ class Overlays_EXPORT QmitkOverlay : public QObject { Q_OBJECT public: /** \brief enumeration of all possible display positions */ enum DisplayPosition { top_Left = 0, top_Center = 1, top_Right = 2, middle_Left = 3, middle_Right = 4, bottom_Left = 5, bottom_Center = 6, bottom_Right = 7 }; /** * @brief Constructor with string ID **/ QmitkOverlay(const char* id); /** * @brief Default Destructor **/ virtual ~QmitkOverlay(); /** \brief setter for the display-position */ virtual void SetPosition( DisplayPosition ); /** \brief getter for the display-position */ virtual DisplayPosition GetPosition(); /** \brief setter for the layer */ virtual void SetLayer( unsigned int ); /** \brief getter for the layer */ virtual unsigned int GetLayer(); /** * \brief abstract method to internally setup the overlay */ virtual void GenerateData( mitk::PropertyList::Pointer /*pl*/ ) {}; /** * \brief returns the internally handled QWidget */ virtual QWidget* GetWidget(); protected: /** \brief Add drop shadow effect via QGraphicsEffect */ void AddDropShadow( QWidget* widget ); /** \brief ID of the overlay */ const char* m_Id; /** \brief position of the overlay */ DisplayPosition m_Position; /** \brief layer of the overlay */ unsigned int m_Layer; /** \brief internal QWidget representing the overlay */ QWidget* m_Widget; + + bool m_WidgetIsCustom; }; #endif /* MITKOVERLAY_H_HEADER_INCLUDED_C10DC4EB */ diff --git a/Modules/Overlays/files.cmake b/Modules/Overlays/files.cmake index 1d3b3feef8..6ef55033a8 100644 --- a/Modules/Overlays/files.cmake +++ b/Modules/Overlays/files.cmake @@ -1,14 +1,16 @@ -set(CPP_FILES +SET(CPP_FILES + QmitkCustomWidgetOverlay.cpp QmitkOverlay.cpp QmitkOverlayController.cpp QmitkScalarBar.cpp QmitkScalarBarOverlay.cpp QmitkTextOverlay.cpp ) -set(MOC_H_FILES + +SET(MOC_H_FILES QmitkOverlay.h QmitkOverlayController.h QmitkScalarBar.h QmitkScalarBarOverlay.h ) \ No newline at end of file