VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkGL2PSUtilities.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00023 #ifndef vtkGL2PSUtilities_h 00024 #define vtkGL2PSUtilities_h 00025 00026 #include "vtkObject.h" 00027 #include "vtkRenderingGL2PSModule.h" // For export macro 00028 00029 class vtkImageData; 00030 class vtkMatrix4x4; 00031 class vtkPath; 00032 class vtkPoints; 00033 class vtkRenderWindow; 00034 class vtkTextProperty; 00035 00036 class VTKRENDERINGGL2PS_EXPORT vtkGL2PSUtilities : public vtkObject 00037 { 00038 public: 00039 static vtkGL2PSUtilities *New(); 00040 vtkTypeMacro(vtkGL2PSUtilities, vtkObject) 00041 void PrintSelf(ostream& os, vtkIndent indent) 00042 { 00043 this->Superclass::PrintSelf(os, indent); 00044 } 00045 00047 00050 static void DrawString(const char *str, vtkTextProperty *tprop, double pos[3], 00051 double backgroundDepth); 00053 00055 static const char * TextPropertyToPSFontName(vtkTextProperty *tprop); 00056 00059 static int TextPropertyToGL2PSAlignment(vtkTextProperty *tprop); 00060 00062 00063 static vtkRenderWindow *GetRenderWindow() 00064 { 00065 return vtkGL2PSUtilities::RenderWindow; 00066 } 00068 00070 00074 static void Draw3DPath(vtkPath *path, vtkMatrix4x4 *actorMatrix, 00075 double rasterPos[3], unsigned char actorColor[4], 00076 const char *label = NULL); 00078 00079 00089 static void DrawPath(vtkPath *path, double rasterPos[3], double windowPos[2], 00090 unsigned char rgba[4], double scale[2] = NULL, 00091 double rotateAngle = 0.0, float strokeWidth = -1, 00092 const char *label = NULL); 00094 00096 00097 static bool GetTextAsPath() 00098 { 00099 return vtkGL2PSUtilities::TextAsPath; 00100 } 00102 00104 00106 static float GetPointSizeFactor() 00107 { return vtkGL2PSUtilities::PointSizeFactor; } 00108 static float GetLineWidthFactor() 00109 { return vtkGL2PSUtilities::LineWidthFactor; } 00111 00112 protected: 00113 friend class vtkGL2PSExporter; 00114 00115 static void StartExport(); 00116 static void FinishExport(); 00117 00118 static void SetPointSizeFactor(float f) 00119 { vtkGL2PSUtilities::PointSizeFactor = f; } 00120 00121 static void SetLineWidthFactor(float f) 00122 { vtkGL2PSUtilities::LineWidthFactor = f; } 00123 00124 static void SetTextAsPath(bool b) 00125 { 00126 vtkGL2PSUtilities::TextAsPath = b; 00127 } 00128 00129 static void SetRenderWindow(vtkRenderWindow *renWin) 00130 { 00131 vtkGL2PSUtilities::RenderWindow = renWin; 00132 } 00133 00134 static void DrawPathPS(vtkPath *path, double rasterPos[3], 00135 double windowPos[2], unsigned char rgba[4], 00136 double scale[2] = NULL, double rotateAngle = 0.0, 00137 float strokeWidth = -1, const char *label = NULL); 00138 static void DrawPathPDF(vtkPath *path, double rasterPos[3], 00139 double windowPos[2], unsigned char rgba[4], 00140 double scale[2] = NULL, double rotateAngle = 0.0, 00141 float strokeWidth = -1, const char *label = NULL); 00142 static void DrawPathSVG(vtkPath *path, double rasterPos[3], 00143 double windowPos[2], unsigned char rgba[4], 00144 double scale[2] = NULL, double rotateAngle = 0.0, 00145 float strokeWidth = -1, const char *label = NULL); 00146 00147 vtkGL2PSUtilities() {} 00148 ~vtkGL2PSUtilities() {} 00149 00150 private: 00151 vtkGL2PSUtilities(const vtkGL2PSUtilities &); // Not implemented 00152 void operator=(const vtkGL2PSUtilities&); // Not implemented 00153 00154 static vtkRenderWindow *RenderWindow; 00155 static bool TextAsPath; 00156 static float PointSizeFactor; 00157 static float LineWidthFactor; 00158 00160 00161 static void ProjectPoint(double point[3], vtkMatrix4x4 *actorMatrix = NULL); 00162 static void ProjectPoint(double point[4], vtkMatrix4x4 * transformMatrix, 00163 double viewportOrigin[2], double halfWidth, 00164 double halfHeight, double zfact1, double zfact2); 00165 static void ProjectPoints(vtkPoints *points, 00166 vtkMatrix4x4 *actorMatrix = NULL); 00168 00170 00172 static void UnprojectPoint(double point[4], vtkMatrix4x4 *invTransformMatrix, 00173 double viewportOrigin[2], double halfWidth, 00174 double halfHeight, double zfact1, double zfact2); 00175 static void UnprojectPoints(double *points3D, vtkIdType numPoints, 00176 vtkMatrix4x4 *actorMatrix = NULL); 00177 }; 00179 00180 #endif