forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkGL2PSExporter.cxx
203 lines (185 loc) · 4.86 KB
/
vtkGL2PSExporter.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGL2PSExporter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkGL2PSExporter.h"
#include "vtkObjectFactory.h"
#include "vtkProp.h"
#include "vtkPropCollection.h"
#include "vtk_gl2ps.h"
#include <vector>
vtkAbstractObjectFactoryNewMacro(vtkGL2PSExporter)
vtkCxxSetObjectMacro(vtkGL2PSExporter, RasterExclusions, vtkPropCollection)
vtkGL2PSExporter::vtkGL2PSExporter()
{
this->RasterExclusions = nullptr;
this->FilePrefix = nullptr;
this->BufferSize = 4194304; // 4MB
this->Title = nullptr;
this->FileFormat = EPS_FILE;
this->Sort = SIMPLE_SORT;
this->Compress = 1;
this->DrawBackground = 1;
this->SimpleLineOffset = 1;
this->Silent = 0;
this->BestRoot = 1;
this->Text = 1;
this->Landscape = 0;
this->PS3Shading = 1;
this->OcclusionCull = 1;
this->Write3DPropsAsRasterImage = 0;
this->TextAsPath = false;
this->PointSizeFactor = 5.f / 7.f;
this->LineWidthFactor = 5.f / 7.f;
}
vtkGL2PSExporter::~vtkGL2PSExporter()
{
this->SetRasterExclusions(nullptr);
delete [] this->FilePrefix;
delete [] this->Title;
}
int vtkGL2PSExporter::GetGL2PSOptions()
{
GLint options = GL2PS_NONE;
if (this->Compress == 1)
{
options = options | GL2PS_COMPRESS;
}
if (this->DrawBackground == 1)
{
options = options | GL2PS_DRAW_BACKGROUND;
}
if (this->SimpleLineOffset == 1)
{
options = options | GL2PS_SIMPLE_LINE_OFFSET;
}
if (this->Silent == 1)
{
options = options | GL2PS_SILENT;
}
if (this->BestRoot == 1)
{
options = options | GL2PS_BEST_ROOT;
}
if (this->Text == 0)
{
options = options | GL2PS_NO_TEXT;
}
if (this->Landscape == 1)
{
options = options | GL2PS_LANDSCAPE;
}
if (this->PS3Shading == 0)
{
options = options | GL2PS_NO_PS3_SHADING;
}
if (this->OcclusionCull == 1)
{
options = options | GL2PS_OCCLUSION_CULL;
}
return static_cast<int>(options);
}
int vtkGL2PSExporter::GetGL2PSSort()
{
switch (this->Sort)
{
default:
vtkDebugMacro(<<"Invalid sort settings, using NO_SORT.");
VTK_FALLTHROUGH;
case NO_SORT:
return GL2PS_NO_SORT;
case SIMPLE_SORT:
return GL2PS_SIMPLE_SORT;
case BSP_SORT:
return GL2PS_BSP_SORT;
}
}
int vtkGL2PSExporter::GetGL2PSFormat()
{
switch (this->FileFormat)
{
default:
vtkDebugMacro(<<"Invalid output format. Using postscript.");
VTK_FALLTHROUGH;
case PS_FILE:
return GL2PS_PS;
case EPS_FILE:
return GL2PS_EPS;
case PDF_FILE:
return GL2PS_PDF;
case TEX_FILE:
return GL2PS_TEX;
case SVG_FILE:
return GL2PS_SVG;
}
}
const char *vtkGL2PSExporter::GetFileExtension()
{
switch (this->FileFormat)
{
default:
vtkDebugMacro(<<"Invalid output format. Using postscript.");
VTK_FALLTHROUGH;
case PS_FILE:
return "ps";
case EPS_FILE:
return "eps";
case PDF_FILE:
return "pdf";
case TEX_FILE:
return "tex";
case SVG_FILE:
return "svg";
}
}
void vtkGL2PSExporter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
if (this->FilePrefix)
{
os << indent << "FilePrefix: " << this->FilePrefix << "\n";
}
else
{
os << indent << "FilePrefix: (null)\n";
}
os << indent << "FileFormat: "
<< this->GetFileFormatAsString() << "\n";
os << indent << "Sort: "
<< this->GetSortAsString() << "\n";
os << indent << "Compress: "
<< (this->Compress ? "On\n" : "Off\n");
os << indent << "DrawBackground: "
<< (this->DrawBackground ? "On\n" : "Off\n");
os << indent << "SimpleLineOffset: "
<< (this->SimpleLineOffset ? "On\n" : "Off\n");
os << indent << "Silent: "
<< (this->Silent ? "On\n" : "Off\n");
os << indent << "BestRoot: "
<< (this->BestRoot ? "On\n" : "Off\n");
os << indent << "Text: "
<< (this->Text ? "On\n" : "Off\n");
os << indent << "Landscape: "
<< (this->Landscape ? "On\n" : "Off\n");
os << indent << "PS3Shading: "
<< (this->PS3Shading ? "On\n" : "Off\n");
os << indent << "OcclusionCull: "
<< (this->OcclusionCull ? "On\n" : "Off\n");
os << indent << "Write3DPropsAsRasterImage: "
<< (this->Write3DPropsAsRasterImage ? "On\n" : "Off\n");
if (this->RasterExclusions)
{
os << indent << "RasterExclusions:\n";
this->RasterExclusions->PrintSelf(os, indent.GetNextIndent());
}
else
{
os << indent << "RasterExclusions: (null)\n";
}
}