CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkMaterialPropertyPreviewLabel.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Library: CTK
4
5 Copyright (c) Kitware Inc.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0.txt
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19=========================================================================*/
20// Freely inspired from KWWidgets: vtkKWMaterialPropertyWidget
21
22#ifndef __ctkMaterialPropertyPreviewLabel_h
23#define __ctkMaterialPropertyPreviewLabel_h
24
25// Qt includes
26#include <QFrame>
27
28// CTK includes
29#include "ctkWidgetsExport.h"
30
31class ctkMaterialPropertyPreviewLabelPrivate;
32
34class CTK_WIDGETS_EXPORT ctkMaterialPropertyPreviewLabel : public QFrame
35{
36 Q_OBJECT
37 Q_PROPERTY(double ambient READ ambient WRITE setAmbient)
38 Q_PROPERTY(double diffuse READ diffuse WRITE setDiffuse)
39 Q_PROPERTY(double specular READ specular WRITE setSpecular)
40 Q_PROPERTY(double specularPower READ specularPower WRITE setSpecularPower)
41
42 Q_PROPERTY(QColor color READ color WRITE setColor)
43 Q_PROPERTY(double opacity READ opacity WRITE setOpacity)
44 Q_PROPERTY(double gridOpacity READ gridOpacity WRITE setGridOpacity)
45public :
46
47 ctkMaterialPropertyPreviewLabel(QWidget *parent = 0);
48 ctkMaterialPropertyPreviewLabel(const QColor& color, double opacity,
49 double ambient, double diffuse, double specular, double specularPower,
50 QWidget *parent = 0);
52
53 double ambient()const;
54 double diffuse()const;
55 double specular()const;
56 double specularPower()const;
57
58 QColor color()const;
59 double opacity()const;
60 double gridOpacity()const;
61
63 virtual int heightForWidth(int w)const;
64
65 virtual QSize sizeHint()const;
66public Q_SLOTS:
68 void setAmbient(double newAbient);
70 void setDiffuse(double newDiffuse);
72 void setSpecular(double newSpecular);
74 void setSpecularPower(double newSpecularPower);
75
76 void setColor(const QColor& newColor);
78 void setOpacity(double newOpacity);
79 void setGridOpacity(double newGridOpacity);
80
81protected:
82 void paintEvent(QPaintEvent *);
83 void draw(QImage& image);
84
85 QScopedPointer<ctkMaterialPropertyPreviewLabelPrivate> d_ptr;
86private :
87 Q_DECLARE_PRIVATE(ctkMaterialPropertyPreviewLabel);
88 Q_DISABLE_COPY(ctkMaterialPropertyPreviewLabel);
89};
90
91#endif
92
void paintEvent(QPaintEvent *)
void setGridOpacity(double newGridOpacity)
void setAmbient(double newAbient)
Valid range: [0,1].
void setDiffuse(double newDiffuse)
Valid range: [0,1].
void setSpecularPower(double newSpecularPower)
Valid range: [1,inf[.
virtual QSize sizeHint() const
ctkMaterialPropertyPreviewLabel(QWidget *parent=0)
ctkMaterialPropertyPreviewLabel(const QColor &color, double opacity, double ambient, double diffuse, double specular, double specularPower, QWidget *parent=0)
void setColor(const QColor &newColor)
virtual int heightForWidth(int w) const
Reimplemented to make it square.
QScopedPointer< ctkMaterialPropertyPreviewLabelPrivate > d_ptr
void setOpacity(double newOpacity)
Valid range: [0, 1].
void setSpecular(double newSpecular)
Valid range: [0,1].