Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkOverlay.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "QmitkOverlay.h"
18 
19 #include <QBoxLayout>
20 
21 #include <QGraphicsDropShadowEffect>
22 
24  : QObject(), m_Id(id), m_Position(top_Left), m_Layer(-1), m_Widget(nullptr), m_WidgetIsCustom(false)
25 {
26 }
27 
29 {
30  if (m_Widget && !m_WidgetIsCustom)
31  {
32  m_Widget->deleteLater();
33  m_Widget = nullptr;
34  }
35 }
36 
38 {
39  return m_Position;
40 }
41 
43 {
44  m_Position = pos;
45 }
46 
47 unsigned int QmitkOverlay::GetLayer()
48 {
49  return m_Layer;
50 }
51 
52 void QmitkOverlay::SetLayer(unsigned int layer)
53 {
54  m_Layer = layer;
55 }
56 
58 {
59  return m_Widget;
60 }
61 
62 void QmitkOverlay::AddDropShadow(QWidget *widget)
63 {
64  if (m_Widget)
65  {
66  auto effect = new QGraphicsDropShadowEffect(widget);
67  effect->setOffset(QPointF(1.0, 1.0));
68  effect->setBlurRadius(0);
69  effect->setColor(Qt::black);
70 
71  widget->setGraphicsEffect(effect);
72  }
73 }
virtual void SetPosition(DisplayPosition)
setter for the display-position
virtual unsigned int GetLayer()
getter for the layer
void AddDropShadow(QWidget *widget)
Add drop shadow effect via QGraphicsEffect.
virtual DisplayPosition GetPosition()
getter for the display-position
bool m_WidgetIsCustom
Definition: QmitkOverlay.h:122
DisplayPosition
enumeration of all possible display positions
Definition: QmitkOverlay.h:59
virtual void SetLayer(unsigned int)
setter for the layer
virtual QWidget * GetWidget()
returns the internally handled QWidget
QWidget * m_Widget
internal QWidget representing the overlay
Definition: QmitkOverlay.h:120
QmitkOverlay(const char *id)
Constructor with string ID.
virtual ~QmitkOverlay()
Default Destructor.
unsigned int m_Layer
layer of the overlay
Definition: QmitkOverlay.h:117
DisplayPosition m_Position
position of the overlay
Definition: QmitkOverlay.h:114