VTK  9.2.6
vtkImageCanvasSource2D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageCanvasSource2D.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 =========================================================================*/
36 #ifndef vtkImageCanvasSource2D_h
37 #define vtkImageCanvasSource2D_h
38 
39 #include "vtkImageAlgorithm.h"
40 #include "vtkImagingSourcesModule.h" // For export macro
41 
42 class VTKIMAGINGSOURCES_EXPORT vtkImageCanvasSource2D : public vtkImageAlgorithm
43 {
44 public:
49 
51  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
54 
58  vtkSetVector4Macro(DrawColor, double);
59  vtkGetVector4Macro(DrawColor, double);
61 
65  void SetDrawColor(double a) { this->SetDrawColor(a, 0.0, 0.0, 0.0); }
66 
70  void SetDrawColor(double a, double b) { this->SetDrawColor(a, b, 0.0, 0.0); }
71 
75  void SetDrawColor(double a, double b, double c) { this->SetDrawColor(a, b, c, 0.0); }
76 
81 
83 
87  void FillBox(int min0, int max0, int min1, int max1);
88  void FillTube(int x0, int y0, int x1, int y1, double radius);
89  void FillTriangle(int x0, int y0, int x1, int y1, int x2, int y2);
90  void DrawCircle(int c0, int c1, double radius);
91  void DrawPoint(int p0, int p1);
92  void DrawSegment(int x0, int y0, int x1, int y1);
93  void DrawSegment3D(double* p0, double* p1);
94  void DrawSegment3D(double x1, double y1, double z1, double x2, double y2, double z2)
95  {
96  double p1[3], p2[3];
97  p1[0] = x1;
98  p1[1] = y1;
99  p1[2] = z1;
100  p2[0] = x2;
101  p2[1] = y2;
102  p2[2] = z2;
103  this->DrawSegment3D(p1, p2);
104  }
106 
111  void DrawImage(int x0, int y0, vtkImageData* i) { this->DrawImage(x0, y0, i, -1, -1, -1, -1); }
112  void DrawImage(int x0, int y0, vtkImageData*, int sx, int sy, int width, int height);
113 
119  void FillPixel(int x, int y);
120 
122 
127  void SetExtent(int* extent);
128  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
130 
132 
137  vtkSetMacro(DefaultZ, int);
138  vtkGetMacro(DefaultZ, int);
140 
142 
147  vtkSetVector3Macro(Ratio, double);
148  vtkGetVector3Macro(Ratio, double);
150 
152 
155  virtual void SetNumberOfScalarComponents(int i);
156  virtual int GetNumberOfScalarComponents() const;
158 
160 
167  void SetScalarTypeToFloat() { this->SetScalarType(VTK_FLOAT); }
168  void SetScalarTypeToDouble() { this->SetScalarType(VTK_DOUBLE); }
169  void SetScalarTypeToInt() { this->SetScalarType(VTK_INT); }
170  void SetScalarTypeToUnsignedInt() { this->SetScalarType(VTK_UNSIGNED_INT); }
171  void SetScalarTypeToLong() { this->SetScalarType(VTK_LONG); }
172  void SetScalarTypeToUnsignedLong() { this->SetScalarType(VTK_UNSIGNED_LONG); }
173  void SetScalarTypeToShort() { this->SetScalarType(VTK_SHORT); }
174  void SetScalarTypeToUnsignedShort() { this->SetScalarType(VTK_UNSIGNED_SHORT); }
175  void SetScalarTypeToUnsignedChar() { this->SetScalarType(VTK_UNSIGNED_CHAR); }
176  void SetScalarTypeToChar() { this->SetScalarType(VTK_CHAR); }
177  void SetScalarType(int);
178  int GetScalarType() const;
180 
181 protected:
183  // Destructor: Deleting a vtkImageCanvasSource2D automatically deletes the
184  // associated vtkImageData. However, since the data is reference counted,
185  // it may not actually be deleted.
187 
189  int WholeExtent[6];
190  double DrawColor[4];
191  int DefaultZ;
192  double Ratio[3];
193 
194  int ClipSegment(int& a0, int& a1, int& b0, int& b1);
195 
198 
199 private:
201  void operator=(const vtkImageCanvasSource2D&) = delete;
202 };
203 
204 #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:63
a simple class to control print indentation
Definition: vtkIndent.h:49
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
@ extent
Definition: vtkX3D.h:351
@ height
Definition: vtkX3D.h:260
@ radius
Definition: vtkX3D.h:258
#define VTK_SHORT
Definition: vtkType.h:48
#define VTK_UNSIGNED_INT
Definition: vtkType.h:51
#define VTK_DOUBLE
Definition: vtkType.h:55
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
#define VTK_INT
Definition: vtkType.h:50
#define VTK_FLOAT
Definition: vtkType.h:54
#define VTK_CHAR
Definition: vtkType.h:45
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:53
#define VTK_LONG
Definition: vtkType.h:52