Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkColorPropertyView.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 #include "QmitkColorPropertyView.h"
17 #include <QPixmap>
18 #define ROUND_P(x) ((int)((x) + 0.5))
19 
21  : QLabel(parent), PropertyView(property), m_ColorProperty(property)
22 {
23  setText(" "); // two spaces for some minimun height
24  setMinimumSize(15, 15);
26 
27  m_WidgetPalette = QWidget::palette();
28  QWidget::setPalette(m_WidgetPalette);
29  QWidget::setAutoFillBackground(true);
30 }
31 
33 {
34 }
35 
37 {
38  if (m_Property)
39  DisplayColor();
40 }
41 
43 {
44  m_Property = nullptr;
45  m_ColorProperty = nullptr;
46 }
47 
49 {
50  const mitk::Color &tmp_col(m_ColorProperty->GetColor());
51 
52  QColor color(ROUND_P(tmp_col[0] * 255.0), ROUND_P(tmp_col[1] * 255.0), ROUND_P(tmp_col[2] * 255.0));
53 
54  m_WidgetPalette.setColor(QPalette::Background, color);
55 }
#define ROUND_P(x)
The ColorProperty class RGB color property.
QmitkColorPropertyView(const mitk::ColorProperty *, QWidget *parent)
virtual void PropertyChanged() override
const mitk::BaseProperty * m_Property
virtual void PropertyRemoved() override
const mitk::Color & GetColor() const
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
const mitk::ColorProperty * m_ColorProperty