diff --git a/Modules/Overlays/QmitkCustomWidgetOverlay.cpp b/Modules/Overlays/QmitkCustomWidgetOverlay.cpp index ebfe2feb5b..fa233291dd 100644 --- a/Modules/Overlays/QmitkCustomWidgetOverlay.cpp +++ b/Modules/Overlays/QmitkCustomWidgetOverlay.cpp @@ -1,40 +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/QmitkOverlay.cpp b/Modules/Overlays/QmitkOverlay.cpp index 6738671cc5..c1b356ff34 100644 --- a/Modules/Overlays/QmitkOverlay.cpp +++ b/Modules/Overlays/QmitkOverlay.cpp @@ -1,81 +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 ) { 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 */