VTK
vtkGL2PSUtilities.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGL2PSUtilities.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 =========================================================================*/
24 #ifndef vtkGL2PSUtilities_h
25 #define vtkGL2PSUtilities_h
26 
27 #include "vtkObject.h"
28 #include "vtkRenderingGL2PSModule.h" // For export macro
29 
30 class vtkImageData;
31 class vtkMatrix4x4;
32 class vtkPath;
33 class vtkPoints;
34 class vtkRenderWindow;
35 class vtkTextProperty;
36 
37 class VTKRENDERINGGL2PS_EXPORT vtkGL2PSUtilities : public vtkObject
38 {
39 public:
42  void PrintSelf(ostream& os, vtkIndent indent)
43  {
44  this->Superclass::PrintSelf(os, indent);
45  }
46 
51  static void DrawString(const char *str, vtkTextProperty *tprop, double pos[3],
52  double backgroundDepth);
53 
57  static const char * TextPropertyToPSFontName(vtkTextProperty *tprop);
58 
63 
68  {
69  return vtkGL2PSUtilities::RenderWindow;
70  }
71 
77  static void Draw3DPath(vtkPath *path, vtkMatrix4x4 *actorMatrix,
78  double rasterPos[3], unsigned char actorColor[4],
79  const char *label = NULL);
91  static void DrawPath(vtkPath *path, double rasterPos[3], double windowPos[2],
92  unsigned char rgba[4], double scale[2] = NULL,
93  double rotateAngle = 0.0, float strokeWidth = -1,
94  const char *label = NULL);
95 
99  static bool GetTextAsPath()
100  {
101  return vtkGL2PSUtilities::TextAsPath;
102  }
103 
108  static float GetPointSizeFactor()
109  { return vtkGL2PSUtilities::PointSizeFactor; }
110  static float GetLineWidthFactor()
111  { return vtkGL2PSUtilities::LineWidthFactor; }
112 
113 protected:
115 
116  static void StartExport();
117  static void FinishExport();
118 
119  static void SetPointSizeFactor(float f)
120  { vtkGL2PSUtilities::PointSizeFactor = f; }
121 
122  static void SetLineWidthFactor(float f)
123  { vtkGL2PSUtilities::LineWidthFactor = f; }
124 
125  static void SetTextAsPath(bool b)
126  {
127  vtkGL2PSUtilities::TextAsPath = b;
128  }
129 
130  static void SetRenderWindow(vtkRenderWindow *renWin)
131  {
132  vtkGL2PSUtilities::RenderWindow = renWin;
133  }
134 
135  static void DrawPathPS(vtkPath *path, double rasterPos[3],
136  double windowPos[2], unsigned char rgba[4],
137  double scale[2] = NULL, double rotateAngle = 0.0,
138  float strokeWidth = -1, const char *label = NULL);
139  static void DrawPathPDF(vtkPath *path, double rasterPos[3],
140  double windowPos[2], unsigned char rgba[4],
141  double scale[2] = NULL, double rotateAngle = 0.0,
142  float strokeWidth = -1, const char *label = NULL);
143  static void DrawPathSVG(vtkPath *path, double rasterPos[3],
144  double windowPos[2], unsigned char rgba[4],
145  double scale[2] = NULL, double rotateAngle = 0.0,
146  float strokeWidth = -1, const char *label = NULL);
147 
150 
151 private:
152  vtkGL2PSUtilities(const vtkGL2PSUtilities &) VTK_DELETE_FUNCTION;
153  void operator=(const vtkGL2PSUtilities&) VTK_DELETE_FUNCTION;
154 
156  static bool TextAsPath;
157  static float PointSizeFactor;
158  static float LineWidthFactor;
159 
161 
164  static void ProjectPoint(double point[4], vtkMatrix4x4 *actorMatrix = NULL);
165  static void ProjectPoint(double point[4], vtkMatrix4x4 * transformMatrix,
166  double viewportOrigin[2], double halfWidth,
167  double halfHeight, double zfact1, double zfact2);
168  static void ProjectPoints(vtkPoints *points,
169  vtkMatrix4x4 *actorMatrix = NULL);
171 
173 
177  static void UnprojectPoint(double point[4], vtkMatrix4x4 *invTransformMatrix,
178  double viewportOrigin[2], double halfWidth,
179  double halfHeight, double zfact1, double zfact2);
180  static void UnprojectPoints(double *points3D, vtkIdType numPoints,
181  vtkMatrix4x4 *actorMatrix = NULL);
182 };
184 
185 #endif
vtkRenderWindow * RenderWindow
Definition: vtkExporter.h:111
Helper functions for using GL2PS within VTK.
static void SetTextAsPath(bool b)
static vtkRenderWindow * GetRenderWindow()
Get the current RenderWindow that is being exported.
static vtkGL2PSUtilities * New()
static bool GetTextAsPath()
Get whether all text will be exported as paths.
static void Draw3DPath(vtkPath *path, vtkMatrix4x4 *actorMatrix, double rasterPos[3], unsigned char actorColor[4], const char *label=NULL)
Transform the path using the actor's matrix and current GL state, then draw it to GL2PS.
static void DrawPathPDF(vtkPath *path, double rasterPos[3], double windowPos[2], unsigned char rgba[4], double scale[2]=NULL, double rotateAngle=0.0, float strokeWidth=-1, const char *label=NULL)
static int TextPropertyToGL2PSAlignment(vtkTextProperty *tprop)
Convert the alignment hint in tprop to a GL2PS text alignment constant.
static const char * TextPropertyToPSFontName(vtkTextProperty *tprop)
Translate the tprop's fontname into a Postscript font name.
static void SetLineWidthFactor(float f)
static float GetPointSizeFactor()
Get a scaling factor for the point size or line width used by GL2PS.
static void DrawPathPS(vtkPath *path, double rasterPos[3], double windowPos[2], unsigned char rgba[4], double scale[2]=NULL, double rotateAngle=0.0, float strokeWidth=-1, const char *label=NULL)
static void SetPointSizeFactor(float f)
static void FinishExport()
static void SetRenderWindow(vtkRenderWindow *renWin)
static void DrawPath(vtkPath *path, double rasterPos[3], double windowPos[2], unsigned char rgba[4], double scale[2]=NULL, double rotateAngle=0.0, float strokeWidth=-1, const char *label=NULL)
Generate PS, EPS, or SVG markup from a vtkPath object, and then inject it into the output using the g...
static void DrawPathSVG(vtkPath *path, double rasterPos[3], double windowPos[2], unsigned char rgba[4], double scale[2]=NULL, double rotateAngle=0.0, float strokeWidth=-1, const char *label=NULL)
static void DrawString(const char *str, vtkTextProperty *tprop, double pos[3], double backgroundDepth)
Format the text in str according to tprop and instruct GL2PS to draw it at world coordinate pos.
static void StartExport()
static float GetLineWidthFactor()
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
a simple class to control print indentation
Definition: vtkIndent.h:40
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
abstract base class for most VTK objects
Definition: vtkObject.h:60
OpenGL2 implementation of GL2PS exporter.
concrete dataset representing a path defined by Bezier curves.
Definition: vtkPath.h:36
represent and manipulate 3D points
Definition: vtkPoints.h:40
create a window for renderers to draw into
represent text properties.
@ point
Definition: vtkX3D.h:236
@ points
Definition: vtkX3D.h:446
@ scale
Definition: vtkX3D.h:229
int vtkIdType
Definition: vtkType.h:287