CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkCrosshairLabel.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 
21 #ifndef __ctkCrosshairLabel_h
22 #define __ctkCrosshairLabel_h
23 
24 // QT includes
25 #include <QLabel>
26 #include <QPen>
27 class QColor;
28 class QSize;
29 
30 // CTK includes
31 #include "ctkWidgetsExport.h"
32 
33 class ctkCrosshairLabelPrivate;
34 
42 
43 class CTK_WIDGETS_EXPORT ctkCrosshairLabel : public QLabel
44 {
45  Q_OBJECT
46  Q_FLAGS(CrosshairType CrosshairTypes)
47  Q_PROPERTY(bool showCrosshair READ showCrosshair WRITE setShowCrosshair)
48  // QT designer does not yet support QPen properties, so we provide the
49  // temporary properties crosshairColor and lineWidth.
50  Q_PROPERTY(QPen crosshairPen READ crosshairPen WRITE setCrosshairPen
51  DESIGNABLE false)
52  Q_PROPERTY(QColor crosshairColor READ crosshairColor WRITE setCrosshairColor)
53  Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth)
54  Q_PROPERTY(CrosshairTypes crosshairType READ crosshairType WRITE setCrosshairType)
55  Q_PROPERTY(QColor marginColor READ marginColor WRITE setMarginColor)
56  Q_PROPERTY(int bullsEyeWidth READ bullsEyeWidth WRITE setBullsEyeWidth)
57 
58 public:
60  typedef QLabel Superclass;
61  explicit ctkCrosshairLabel(QWidget* parent = 0);
62  virtual ~ctkCrosshairLabel();
63 
66  SimpleCrosshair = 0,
67  BullsEyeCrosshair
68  };
69  Q_DECLARE_FLAGS(CrosshairTypes, CrosshairType)
70 
71 
72  bool showCrosshair() const;
73  void setShowCrosshair(bool newShow);
74 
80  QPen crosshairPen() const;
81  void setCrosshairPen(const QPen& newPen);
82 
85  QColor crosshairColor() const;
86  void setCrosshairColor(const QColor& newColor);
87 
92  int lineWidth() const;
93  void setLineWidth(int newWidth);
94 
96  CrosshairTypes crosshairType() const;
97  void setCrosshairType(const CrosshairTypes& newType);
98 
103  QColor marginColor() const;
104  void setMarginColor(const QColor& newColor);
105 
111  int bullsEyeWidth() const;
112  void setBullsEyeWidth(int newWidth);
113 
115  virtual QSize minimumSizeHint()const;
116  virtual QSize sizeHint()const;
117  virtual bool hasHeightForWidth()const;
118  virtual int heightForWidth(int width)const;
119 
120 protected:
121  QScopedPointer<ctkCrosshairLabelPrivate> d_ptr;
122 
123  // Draws the crosshair on top of the widget.
124  virtual void paintEvent(QPaintEvent * event);
125 
126 private:
127  Q_DECLARE_PRIVATE(ctkCrosshairLabel)
128  Q_DISABLE_COPY(ctkCrosshairLabel)
129 };
130 
131 #endif
CrosshairType
Enumeration over types of crosshairs.
virtual ~ctkCrosshairLabel()
ctkCrosshairLabel(QWidget *parent=0)
QLabel Superclass
Constructors.