vtkPen.h 4.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPen.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

// .NAME vtkPen - provides a pen that draws the outlines of shapes drawn
// by vtkContext2D.
//
// .SECTION Description
// The vtkPen defines the outline of shapes that are drawn by vtkContext2D.
// The color is stored as four unsigned chars (RGBA), where the
// opacity defaults to 255, but can be modified separately to the other
// components. Ideally we would use a lightweight color class to store and pass
// around colors.

#ifndef __vtkPen_h
#define __vtkPen_h

#include "vtkObject.h"
30
#include "vtkColor.h" // Needed for vtkColor4ub
31

32
33
34
class VTK_CHARTS_EXPORT vtkPen : public vtkObject
{
public:
35
  vtkTypeMacro(vtkPen, vtkObject);
36
37
38
39
  virtual void PrintSelf(ostream &os, vtkIndent indent);

  static vtkPen *New();

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//BTX
  // Description:
  // Enum of the available line types.
  enum {
    NO_PEN,
    SOLID_LINE,
    DASH_LINE,
    DOT_LINE,
    DASH_DOT_LINE,
    DASH_DOT_DOT_LINE};
//ETX

  // Description:
  // Set the type of line that the pen should draw. The default is solid (1).
  void SetLineType(int type);

  // Description:
  // Get the type of line that the pen will draw.
  int GetLineType();

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  // Description:
  // Set the color of the brush with three component doubles (RGB), ranging from
  // 0.0 to 1.0.
  void SetColorF(double color[3]);

  // Description:
  // Set the color of the brush with three component doubles (RGB), ranging from
  // 0.0 to 1.0.
  void SetColorF(double r, double g, double b);

  // Description:
  // Set the color of the brush with four component doubles (RGBA), ranging from
  // 0.0 to 1.0.
  void SetColorF(double r, double g, double b, double a);

  // Description:
  // Set the opacity with a double, ranging from 0.0 (transparent) to 1.0
  // (opaque).
  void SetOpacityF(double a);

  // Description:
  // Set the color of the brush with three component unsigned chars (RGB),
  // ranging from 0 to 255.
  void SetColor(unsigned char color[3]);

  // Description:
  // Set the color of the brush with three component unsigned chars (RGB),
  // ranging from 0 to 255.
  void SetColor(unsigned char r, unsigned char g, unsigned char b);

  // Description:
  // Set the color of the brush with four component unsigned chars (RGBA),
  // ranging from 0 to 255.
  void SetColor(unsigned char r, unsigned char g, unsigned char b,
                unsigned char a);

  // Description:
  // Set the opacity with an unsigned char, ranging from 0 (transparent) to 255
  // (opaque).
  void SetOpacity(unsigned char a);

  // Description:
102
103
104
105
106
107
  // Get the color of the brush - expects a double of length 3 to copy into.
  void GetColorF(double color[3]);

  // Description:
  // Get the color of the brush - expects an unsigned char of length 3.
  void GetColor(unsigned char color[3]);
108
109

  // Description:
110
111
112
  // Get the opacity (unsigned char), ranging from 0 (transparent) to 255
  // (opaque).
  unsigned char GetOpacity();
113
114
115

  // Description:
  // Get the color of the brush - gives a pointer to the underlying data.
116
  unsigned char * GetColor() { return this->Color; }
117
118
119
120
121
122

  // Description:
  // Set/Get the width of the pen.
  vtkSetMacro(Width, float);
  vtkGetMacro(Width, float);

123
124
125
126
  // Description:
  // Make a deep copy of the supplied pen.
  void DeepCopy(vtkPen *pen);

127
128
129
130
131
//BTX
protected:
  vtkPen();
  ~vtkPen();

132
  // Description:
133
  // Storage of the color in RGBA format (0-255 per channel).
134
  unsigned char* Color;
135
  vtkColor4ub PenColor;
136

137
138
  // Description:
  // Store the width of the pen in pixels.
139
140
  float Width;

141
142
143
144
  // Description:
  // The type of line to be drawn with this pen.
  int LineType;

145
146
147
148
149
150
151
private:
  vtkPen(const vtkPen &); // Not implemented.
  void operator=(const vtkPen &);   // Not implemented.
//ETX
};

#endif //__vtkPen_h