VTK  9.3.1
vtkImageCanvasSource2D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
15 #ifndef vtkImageCanvasSource2D_h
16 #define vtkImageCanvasSource2D_h
17 
18 #include "vtkImageAlgorithm.h"
19 #include "vtkImagingSourcesModule.h" // For export macro
20 
21 VTK_ABI_NAMESPACE_BEGIN
22 class VTKIMAGINGSOURCES_EXPORT vtkImageCanvasSource2D : public vtkImageAlgorithm
23 {
24 public:
28  static vtkImageCanvasSource2D* New();
29 
31  void PrintSelf(ostream& os, vtkIndent indent) override;
32 
34 
38  vtkSetVector4Macro(DrawColor, double);
39  vtkGetVector4Macro(DrawColor, double);
41 
45  void SetDrawColor(double a) { this->SetDrawColor(a, 0.0, 0.0, 0.0); }
46 
50  void SetDrawColor(double a, double b) { this->SetDrawColor(a, b, 0.0, 0.0); }
51 
55  void SetDrawColor(double a, double b, double c) { this->SetDrawColor(a, b, c, 0.0); }
56 
60  void InitializeCanvasVolume(vtkImageData* volume);
61 
63 
67  void FillBox(int min0, int max0, int min1, int max1);
68  void FillTube(int x0, int y0, int x1, int y1, double radius);
69  void FillTriangle(int x0, int y0, int x1, int y1, int x2, int y2);
70  void DrawCircle(int c0, int c1, double radius);
71  void DrawPoint(int p0, int p1);
72  void DrawSegment(int x0, int y0, int x1, int y1);
73  void DrawSegment3D(double* p0, double* p1);
74  void DrawSegment3D(double x1, double y1, double z1, double x2, double y2, double z2)
75  {
76  double p1[3], p2[3];
77  p1[0] = x1;
78  p1[1] = y1;
79  p1[2] = z1;
80  p2[0] = x2;
81  p2[1] = y2;
82  p2[2] = z2;
83  this->DrawSegment3D(p1, p2);
84  }
86 
91  void DrawImage(int x0, int y0, vtkImageData* i) { this->DrawImage(x0, y0, i, -1, -1, -1, -1); }
92  void DrawImage(int x0, int y0, vtkImageData*, int sx, int sy, int width, int height);
93 
99  void FillPixel(int x, int y);
100 
102 
107  void SetExtent(int* extent);
108  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
110 
112 
117  vtkSetMacro(DefaultZ, int);
118  vtkGetMacro(DefaultZ, int);
120 
122 
127  vtkSetVector3Macro(Ratio, double);
128  vtkGetVector3Macro(Ratio, double);
130 
132 
135  virtual void SetNumberOfScalarComponents(int i);
136  virtual int GetNumberOfScalarComponents() const;
138 
140 
147  void SetScalarTypeToFloat() { this->SetScalarType(VTK_FLOAT); }
148  void SetScalarTypeToDouble() { this->SetScalarType(VTK_DOUBLE); }
149  void SetScalarTypeToInt() { this->SetScalarType(VTK_INT); }
150  void SetScalarTypeToUnsignedInt() { this->SetScalarType(VTK_UNSIGNED_INT); }
151  void SetScalarTypeToLong() { this->SetScalarType(VTK_LONG); }
152  void SetScalarTypeToUnsignedLong() { this->SetScalarType(VTK_UNSIGNED_LONG); }
153  void SetScalarTypeToShort() { this->SetScalarType(VTK_SHORT); }
154  void SetScalarTypeToUnsignedShort() { this->SetScalarType(VTK_UNSIGNED_SHORT); }
155  void SetScalarTypeToUnsignedChar() { this->SetScalarType(VTK_UNSIGNED_CHAR); }
156  void SetScalarTypeToChar() { this->SetScalarType(VTK_CHAR); }
157  void SetScalarType(int);
158  int GetScalarType() const;
160 
161 protected:
163  // Destructor: Deleting a vtkImageCanvasSource2D automatically deletes the
164  // associated vtkImageData. However, since the data is reference counted,
165  // it may not actually be deleted.
166  ~vtkImageCanvasSource2D() override;
167 
169  int WholeExtent[6];
170  double DrawColor[4];
171  int DefaultZ;
172  double Ratio[3];
173 
174  int ClipSegment(int& a0, int& a1, int& b0, int& b1);
175 
178 
179 private:
181  void operator=(const vtkImageCanvasSource2D&) = delete;
182 };
183 
184 VTK_ABI_NAMESPACE_END
185 #endif
void SetScalarTypeToInt()
Set/Get the data scalar type (i.e VTK_DOUBLE).
void SetScalarTypeToUnsignedInt()
Set/Get the data scalar type (i.e VTK_DOUBLE).
#define VTK_UNSIGNED_INT
Definition: vtkType.h:39
Store vtkAlgorithm input/output information.
void SetScalarTypeToDouble()
Set/Get the data scalar type (i.e VTK_DOUBLE).
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:37
void DrawImage(int x0, int y0, vtkImageData *i)
Draw subimage of the input image in the canvas at position x0 and y0.
void SetScalarTypeToUnsignedShort()
Set/Get the data scalar type (i.e VTK_DOUBLE).
#define VTK_DOUBLE
Definition: vtkType.h:43
#define VTK_FLOAT
Definition: vtkType.h:42
void SetScalarTypeToShort()
Set/Get the data scalar type (i.e VTK_DOUBLE).
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetScalarTypeToUnsignedChar()
Set/Get the data scalar type (i.e VTK_DOUBLE).
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
#define VTK_SHORT
Definition: vtkType.h:36
#define VTK_CHAR
Definition: vtkType.h:33
#define VTK_LONG
Definition: vtkType.h:40
void SetDrawColor(double a, double b, double c)
Set DrawColor to (a, b, c, 0)
void SetScalarTypeToLong()
Set/Get the data scalar type (i.e VTK_DOUBLE).
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:35
void SetDrawColor(double a)
Set DrawColor to (a, 0, 0, 0)
void SetScalarTypeToUnsignedLong()
Set/Get the data scalar type (i.e VTK_DOUBLE).
Generic algorithm superclass for image algs.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void DrawSegment3D(double x1, double y1, double z1, double x2, double y2, double z2)
Set the pixels inside the box (min0, max0, min1, max1) to the current DrawColor.
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:41
void SetDrawColor(double a, double b)
Set DrawColor to (a, b, 0, 0)
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
void SetScalarTypeToFloat()
Set/Get the data scalar type (i.e VTK_DOUBLE).
#define VTK_INT
Definition: vtkType.h:38
void SetScalarTypeToChar()
Set/Get the data scalar type (i.e VTK_DOUBLE).