Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "QmitkOverlay.h"
14 
15 #include <QBoxLayout>
16 
17 #include <QGraphicsDropShadowEffect>
18 
20  : QObject(), m_Id(id), m_Position(top_Left), m_Layer(-1), m_Widget(nullptr), m_WidgetIsCustom(false)
21 {
22 }
23 
25 {
26  if (m_Widget && !m_WidgetIsCustom)
27  {
28  m_Widget->deleteLater();
29  m_Widget = nullptr;
30  }
31 }
32 
34 {
35  return m_Position;
36 }
37 
39 {
40  m_Position = pos;
41 }
42 
43 unsigned int QmitkOverlay::GetLayer()
44 {
45  return m_Layer;
46 }
47 
48 void QmitkOverlay::SetLayer(unsigned int layer)
49 {
50  m_Layer = layer;
51 }
52 
54 {
55  return m_Widget;
56 }
57 
58 void QmitkOverlay::AddDropShadow(QWidget *widget)
59 {
60  if (m_Widget)
61  {
62  auto effect = new QGraphicsDropShadowEffect(widget);
63  effect->setOffset(QPointF(1.0, 1.0));
64  effect->setBlurRadius(0);
65  effect->setColor(Qt::black);
66 
67  widget->setGraphicsEffect(effect);
68  }
69 }
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:118
DisplayPosition
enumeration of all possible display positions
Definition: QmitkOverlay.h:55
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:116
QmitkOverlay(const char *id)
Constructor with string ID.
unsigned int m_Layer
layer of the overlay
Definition: QmitkOverlay.h:113
~QmitkOverlay() override
Default Destructor.
DisplayPosition m_Position
position of the overlay
Definition: QmitkOverlay.h:110