VTK  9.3.0
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
24 #ifndef vtkImageCanvasSource2D_h
25 #define vtkImageCanvasSource2D_h
26 
27 #include "vtkImageAlgorithm.h"
28 #include "vtkImagingSourcesModule.h" // For export macro
29 
30 VTK_ABI_NAMESPACE_BEGIN
31 class VTKIMAGINGSOURCES_EXPORT vtkImageCanvasSource2D : public vtkImageAlgorithm
32 {
33 public:
38 
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
43 
47  vtkSetVector4Macro(DrawColor, double);
48  vtkGetVector4Macro(DrawColor, double);
50 
54  void SetDrawColor(double a) { this->SetDrawColor(a, 0.0, 0.0, 0.0); }
55 
59  void SetDrawColor(double a, double b) { this->SetDrawColor(a, b, 0.0, 0.0); }
60 
64  void SetDrawColor(double a, double b, double c) { this->SetDrawColor(a, b, c, 0.0); }
65 
70 
72 
76  void FillBox(int min0, int max0, int min1, int max1);
77  void FillTube(int x0, int y0, int x1, int y1, double radius);
78  void FillTriangle(int x0, int y0, int x1, int y1, int x2, int y2);
79  void DrawCircle(int c0, int c1, double radius);
80  void DrawPoint(int p0, int p1);
81  void DrawSegment(int x0, int y0, int x1, int y1);
82  void DrawSegment3D(double* p0, double* p1);
83  void DrawSegment3D(double x1, double y1, double z1, double x2, double y2, double z2)
84  {
85  double p1[3], p2[3];
86  p1[0] = x1;
87  p1[1] = y1;
88  p1[2] = z1;
89  p2[0] = x2;
90  p2[1] = y2;
91  p2[2] = z2;
92  this->DrawSegment3D(p1, p2);
93  }
95 
100  void DrawImage(int x0, int y0, vtkImageData* i) { this->DrawImage(x0, y0, i, -1, -1, -1, -1); }
101  void DrawImage(int x0, int y0, vtkImageData*, int sx, int sy, int width, int height);
102 
108  void FillPixel(int x, int y);
109 
111 
116  void SetExtent(int* extent);
117  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
119 
121 
126  vtkSetMacro(DefaultZ, int);
127  vtkGetMacro(DefaultZ, int);
129 
131 
136  vtkSetVector3Macro(Ratio, double);
137  vtkGetVector3Macro(Ratio, double);
139 
141 
144  virtual void SetNumberOfScalarComponents(int i);
145  virtual int GetNumberOfScalarComponents() const;
147 
149 
156  void SetScalarTypeToFloat() { this->SetScalarType(VTK_FLOAT); }
157  void SetScalarTypeToDouble() { this->SetScalarType(VTK_DOUBLE); }
158  void SetScalarTypeToInt() { this->SetScalarType(VTK_INT); }
159  void SetScalarTypeToUnsignedInt() { this->SetScalarType(VTK_UNSIGNED_INT); }
160  void SetScalarTypeToLong() { this->SetScalarType(VTK_LONG); }
161  void SetScalarTypeToUnsignedLong() { this->SetScalarType(VTK_UNSIGNED_LONG); }
162  void SetScalarTypeToShort() { this->SetScalarType(VTK_SHORT); }
163  void SetScalarTypeToUnsignedShort() { this->SetScalarType(VTK_UNSIGNED_SHORT); }
164  void SetScalarTypeToUnsignedChar() { this->SetScalarType(VTK_UNSIGNED_CHAR); }
165  void SetScalarTypeToChar() { this->SetScalarType(VTK_CHAR); }
166  void SetScalarType(int);
167  int GetScalarType() const;
169 
170 protected:
172  // Destructor: Deleting a vtkImageCanvasSource2D automatically deletes the
173  // associated vtkImageData. However, since the data is reference counted,
174  // it may not actually be deleted.
176 
178  int WholeExtent[6];
179  double DrawColor[4];
180  int DefaultZ;
181  double Ratio[3];
182 
183  int ClipSegment(int& a0, int& a1, int& b0, int& b1);
184 
187 
188 private:
190  void operator=(const vtkImageCanvasSource2D&) = delete;
191 };
192 
193 VTK_ABI_NAMESPACE_END
194 #endif
Generic algorithm superclass for image algs.
void SetScalarTypeToUnsignedShort()
Set/Get the data scalar type (i.e VTK_DOUBLE).
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void DrawImage(int x0, int y0, vtkImageData *i)
Draw subimage of the input image in the canvas at position x0 and y0.
void SetDrawColor(double a, double b)
Set DrawColor to (a, b, 0, 0)
void SetScalarTypeToShort()
Set/Get the data scalar type (i.e VTK_DOUBLE).
virtual void SetNumberOfScalarComponents(int i)
Set the number of scalar components.
void SetDrawColor(double a)
Set DrawColor to (a, 0, 0, 0)
~vtkImageCanvasSource2D() override
void SetDrawColor(double a, double b, double c)
Set DrawColor to (a, b, c, 0)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
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).
void SetScalarTypeToLong()
Set/Get the data scalar type (i.e VTK_DOUBLE).
void SetScalarTypeToUnsignedChar()
Set/Get the data scalar type (i.e VTK_DOUBLE).
void SetScalarTypeToDouble()
Set/Get the data scalar type (i.e VTK_DOUBLE).
void FillBox(int min0, int max0, int min1, int max1)
Set the pixels inside the box (min0, max0, min1, max1) to the current DrawColor.
void DrawSegment3D(double *p0, double *p1)
Set the pixels inside the box (min0, max0, min1, max1) to the current DrawColor.
static vtkImageCanvasSource2D * New()
Construct an instance of vtkImageCanvasSource2D with no data.
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.
void FillTriangle(int x0, int y0, int x1, int y1, int x2, int y2)
Set the pixels inside the box (min0, max0, min1, max1) to the current DrawColor.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetExtent(int *extent)
These methods set the WholeExtent of the output It sets the size of the canvas.
int ClipSegment(int &a0, int &a1, int &b0, int &b1)
int GetScalarType() const
Set/Get the data scalar type (i.e VTK_DOUBLE).
void FillPixel(int x, int y)
Fill a colored area with another color.
void DrawSegment(int x0, int y0, int x1, int y1)
Set the pixels inside the box (min0, max0, min1, max1) to the current DrawColor.
void InitializeCanvasVolume(vtkImageData *volume)
Initialize the canvas with a given volume.
void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2)
These methods set the WholeExtent of the output It sets the size of the canvas.
void DrawPoint(int p0, int p1)
Set the pixels inside the box (min0, max0, min1, max1) to the current DrawColor.
void FillTube(int x0, int y0, int x1, int y1, double radius)
Set the pixels inside the box (min0, max0, min1, max1) to the current DrawColor.
void SetScalarTypeToUnsignedInt()
Set/Get the data scalar type (i.e VTK_DOUBLE).
virtual int GetNumberOfScalarComponents() const
Set the number of scalar components.
void SetScalarTypeToInt()
Set/Get the data scalar type (i.e VTK_DOUBLE).
void SetScalarTypeToChar()
Set/Get the data scalar type (i.e VTK_DOUBLE).
void DrawImage(int x0, int y0, vtkImageData *, int sx, int sy, int width, int height)
void DrawCircle(int c0, int c1, double radius)
Set the pixels inside the box (min0, max0, min1, max1) to the current DrawColor.
void SetScalarTypeToUnsignedLong()
Set/Get the data scalar type (i.e VTK_DOUBLE).
void SetScalarType(int)
Set/Get the data scalar type (i.e VTK_DOUBLE).
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
a simple class to control print indentation
Definition: vtkIndent.h:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
@ extent
Definition: vtkX3D.h:345
@ height
Definition: vtkX3D.h:254
@ radius
Definition: vtkX3D.h:252
#define VTK_SHORT
Definition: vtkType.h:36
#define VTK_UNSIGNED_INT
Definition: vtkType.h:39
#define VTK_DOUBLE
Definition: vtkType.h:43
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:35
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:37
#define VTK_INT
Definition: vtkType.h:38
#define VTK_FLOAT
Definition: vtkType.h:42
#define VTK_CHAR
Definition: vtkType.h:33
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:41
#define VTK_LONG
Definition: vtkType.h:40