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