VTK
vtkQtLabelRenderStrategyInternals.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtLabelRenderStrategy.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 // .NAME vtkQtLabelRenderStrategyInternals - Internals to render labels with Qt
16 //
17 // .SECTION Description
18 // This class is an implementation detail of vtkQtLabelRenderStrategy
19 //
20 // This should only be included in the source file of a class derived from
21 // vtkQtLabelRenderStrategy.
22 
23 #ifndef vtkQtLabelRenderStrategyInternals_h
24 #define vtkQtLabelRenderStrategyInternals_h
25 
26 #include "vtkTextProperty.h"
27 
28 #include <QColor>
29 #include <QFont>
30 #include <QImage>
31 #include <QMap>
32 #include <QString>
33 
34 class QPainter;
35 
37 {
38  QString Text;
39  QColor Color;
40  QFont Font;
41 };
42 
44 {
45  QImage Image;
46  QRectF Bounds;
47 };
48 
49 bool operator <(const vtkQtLabelMapEntry& a, const vtkQtLabelMapEntry& other);
50 
52 {
53 public:
54  QImage* Image;
55  QPainter* Painter;
56  QMap<vtkQtLabelMapEntry, vtkQtLabelMapValue> Cache;
57 
59  {
60  QFont fontSpec(tprop->GetFontFamilyAsString());
61  fontSpec.setBold(tprop->GetBold());
62  fontSpec.setItalic(tprop->GetItalic());
63  fontSpec.setPixelSize(tprop->GetFontSize());
64  return fontSpec;
65  }
66 
67  QColor TextPropertyToColor(double* fc, double opacity)
68  {
69  QColor textColor(
70  static_cast<int>(fc[0]*255),
71  static_cast<int>(fc[1]*255),
72  static_cast<int>(fc[2]*255),
73  static_cast<int>(opacity*255));
74  return textColor;
75  }
76 };
77 
78 #endif // vtkQtLabelRenderStrategyInternals_h
79 // VTK-HeaderTest-Exclude: vtkQtLabelRenderStrategyInternals.h
bool operator<(const vtkQtLabelMapEntry &a, const vtkQtLabelMapEntry &other)
QMap< vtkQtLabelMapEntry, vtkQtLabelMapValue > Cache
QColor TextPropertyToColor(double *fc, double opacity)
virtual vtkTypeBool GetBold()
Enable/disable text bolding.
represent text properties.
virtual vtkTypeBool GetItalic()
Enable/disable text italic.
virtual char * GetFontFamilyAsString()
Set/Get the font family.
virtual int GetFontSize()
Set/Get the font size (in points).