42 Bool_t TGLOutput::Capture(TGLViewer & viewer, EFormat format,
const char * filePath)
49 return CapturePostscript(viewer, format, filePath);
68 Bool_t TGLOutput::CapturePostscript(TGLViewer & viewer, EFormat format,
const char * filePath)
70 if (!filePath || !filePath[0]) {
71 if (format == kEPS_SIMPLE || format == kEPS_BSP) {
72 filePath =
"viewer.eps";
73 }
else if (format == kPDF_SIMPLE || format == kPDF_BSP) {
74 filePath =
"viewer.pdf";
77 Info(
"TGLOutput::Postscript()",
"Start creating %s.", filePath);
78 std::cout <<
"Please wait.";
80 if (FILE *output = fopen (filePath,
"w+b"))
87 gl2psFormat = GL2PS_EPS;
88 gl2psSort = GL2PS_SIMPLE_SORT;
91 gl2psFormat = GL2PS_EPS;
92 gl2psSort = GL2PS_BSP_SORT;
95 gl2psFormat = GL2PS_PDF;
96 gl2psSort = GL2PS_SIMPLE_SORT;
99 gl2psFormat = GL2PS_PDF;
100 gl2psSort = GL2PS_BSP_SORT;
106 Int_t buffsize = 0, state = GL2PS_OVERFLOW;
108 viewer.fIsPrinting = kTRUE;
109 while (state == GL2PS_OVERFLOW) {
110 buffsize += 1024*1024;
111 gl2psBeginPage (
"ROOT Scene Graph",
"ROOT", NULL,
112 gl2psFormat, gl2psSort, GL2PS_USE_CURRENT_VIEWPORT
113 | GL2PS_SILENT | GL2PS_BEST_ROOT | GL2PS_OCCLUSION_CULL | 0,
114 GL_RGBA, 0, NULL,0, 0, 0,
115 buffsize, output, NULL);
117 state = gl2psEndPage();
120 std::cout << std::endl;
122 viewer.fIsPrinting = kFALSE;
123 if (!gSystem->AccessPathName(filePath)) {
124 Info(
"TGLOutput::Postscript",
"Finished creating %s.", filePath);
128 Error(
"TGLOutput::Postscript",
"Failed to create %s. ", filePath);
137 void TGLOutput::StartEmbeddedPS()
139 Info(
"TGLOutput::StartEmbeddedPS",
"PS output started ...");
141 gVirtualPS->PrintStr(
"@");
142 gVirtualPS->PrintStr(
"% Start gl2ps EPS@");
143 gVirtualPS->PrintStr(
"newpath gsave save@");
144 Double_t xx[2] = {0.}, yy[2] = {0.};
145 xx[0] = gPad->GetUxmin();
146 yy[0] = gPad->GetUymin();
147 xx[1] = gPad->GetUxmax();
148 yy[1] = gPad->GetUymax();
149 gVirtualPS->PrintStr(
"@");
152 glGetIntegerv(GL_VIEWPORT,vp);
153 gVirtualPS->DrawPS(0, xx, yy);
154 gVirtualPS->PrintStr(
" exch");
157 gVirtualPS->DrawPS(0, xx, yy);
158 gVirtualPS->PrintStr(
" 4 1 roll exch sub 3 1 roll sub");
159 gVirtualPS->WriteInteger(2*4*gPad->GetBorderSize());
160 gVirtualPS->PrintStr(
" sub exch");
161 gVirtualPS->WriteInteger(2*4*gPad->GetBorderSize());
162 gVirtualPS->PrintStr(
" sub exch");
163 gVirtualPS->WriteInteger((Int_t)(vp[3]));
164 gVirtualPS->WriteInteger((Int_t)(vp[2]));
165 gVirtualPS->PrintStr(
" 4 1 roll div 3 1 roll exch div exch scale@");
166 gVirtualPS->PrintStr(
"@");
167 gVirtualPS->PrintStr(
"countdictstack@");
168 gVirtualPS->PrintStr(
"mark@");
169 gVirtualPS->PrintStr(
"/showpage {} def@");
172 std::ofstream *fs = (std::ofstream*)gVirtualPS->GetStream();
181 void TGLOutput::CloseEmbeddedPS()
183 std::ofstream *fs =
new std::ofstream(gVirtualPS->GetName(),std::ios::app);
184 gVirtualPS->SetStream(fs);
185 gVirtualPS->PrintStr(
"@");
186 gVirtualPS->PrintStr(
"cleartomark@");
187 gVirtualPS->PrintStr(
"countdictstack exch sub { end } repeat@");
188 gVirtualPS->PrintStr(
"restore grestore@");
189 gVirtualPS->PrintStr(
"% End gl2ps EPS@");
191 Info(
"TGLOutput::CloseEmbeddedPS",
"PS output finished");
197 void TGLOutput::Capture(TGLViewer & viewer)
201 FILE *output = fopen (gVirtualPS->GetName(),
"a");
205 Error(
"TGLOutput::Capture",
"can not open file for embedding ps");
210 Int_t gl2psFormat = GL2PS_EPS;
211 Int_t gl2psSort = GL2PS_BSP_SORT;
212 Int_t buffsize = 0, state = GL2PS_OVERFLOW;
214 viewer.fIsPrinting = kTRUE;
216 while (state == GL2PS_OVERFLOW) {
217 buffsize += 1024*1024;
218 gl2psBeginPage (
"ROOT Scene Graph",
"ROOT", NULL,
219 gl2psFormat, gl2psSort, GL2PS_USE_CURRENT_VIEWPORT
220 | GL2PS_SILENT | GL2PS_BEST_ROOT | GL2PS_OCCLUSION_CULL | 0,
221 GL_RGBA, 0, NULL,0, 0, 0,
222 buffsize, output, NULL);
224 state = gl2psEndPage();
228 std::cout << std::endl;
230 viewer.fIsPrinting = kFALSE;