Skip to content
Snippets Groups Projects
Commit b04fbd95 authored by Rene Brun's avatar Rene Brun
Browse files

From Olivier:

- TViewerOpenGL now uses the tool "gl2ps" from Christophe Geuzaine
  <geuz@geuz.org> to produce vector PostScript and PDF outputs. Jeff
  Kallenbach did the interface to this tool.


git-svn-id: http://root.cern.ch/svn/root/trunk@10973 27541ba8-7e3a-0410-8455-c3a389f83636
parent f4fd4536
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ GLH1 := $(MODDIRI)/TViewerOpenGL.h $(MODDIRI)/TGLRenderArea.h \ ...@@ -23,6 +23,7 @@ GLH1 := $(MODDIRI)/TViewerOpenGL.h $(MODDIRI)/TGLRenderArea.h \
$(MODDIRI)/TGLCamera.h $(MODDIRI)/TGLSceneObject.h $(MODDIRI)/TGLCamera.h $(MODDIRI)/TGLSceneObject.h
GLS := TGLKernel.cxx TViewerOpenGL.cxx TArcBall.cxx TGLRenderArea.cxx \ GLS := TGLKernel.cxx TViewerOpenGL.cxx TArcBall.cxx TGLRenderArea.cxx \
TGLSceneObject.cxx TGLRender.cxx TGLCamera.cxx TGLEditor.cxx TGLFrustum.cxx TGLSceneObject.cxx TGLRender.cxx TGLCamera.cxx TGLEditor.cxx TGLFrustum.cxx
GLS1 := $(wildcard $(MODDIRS)/*.c)
ifneq ($(ARCH),win32) ifneq ($(ARCH),win32)
GLS += TX11GL.cxx GLS += TX11GL.cxx
GLH1 += $(MODDIRI)/TX11GL.h GLH1 += $(MODDIRI)/TX11GL.h
...@@ -38,8 +39,9 @@ endif ...@@ -38,8 +39,9 @@ endif
GLS := $(patsubst %,$(MODDIRS)/%,$(GLS)) GLS := $(patsubst %,$(MODDIRS)/%,$(GLS))
GLO := $(GLS:.cxx=.o) GLO := $(GLS:.cxx=.o)
GLO1 := $(GLS1:.c=.o)
GLDEP := $(GLO:.o=.d) GLDEP := $(GLO:.o=.d) $(GLDO:.o=.d) $(GLO1:.o=.d)
GLLIB := $(LPATH)/libRGL.$(SOEXT) GLLIB := $(LPATH)/libRGL.$(SOEXT)
...@@ -54,9 +56,9 @@ INCLUDEFILES += $(GLDEP) ...@@ -54,9 +56,9 @@ INCLUDEFILES += $(GLDEP)
include/%.h: $(GLDIRI)/%.h include/%.h: $(GLDIRI)/%.h
cp $< $@ cp $< $@
$(GLLIB): $(GLO) $(GLDO) $(MAINLIBS) $(GLLIBDEP) $(GLLIB): $(GLO) $(GLO1) $(GLDO) $(MAINLIBS) $(GLLIBDEP)
@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" \ @$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" \
"$(SOFLAGS)" libRGL.$(SOEXT) $@ "$(GLO) $(GLDO)" \ "$(SOFLAGS)" libRGL.$(SOEXT) $@ "$(GLO) $(GLO1) $(GLDO)" \
"$(GLLIBEXTRA) $(GLLIBS) $(IVLIBS)" "$(GLLIBEXTRA) $(GLLIBS) $(IVLIBS)"
$(GLDS): $(GLH1) $(GLL) $(ROOTCINTTMP) $(GLDS): $(GLH1) $(GLL) $(ROOTCINTTMP)
...@@ -100,3 +102,5 @@ $(GLO): %.o: %.cxx ...@@ -100,3 +102,5 @@ $(GLO): %.o: %.cxx
$(CXX) $(OPT) $(CXXFLAGS) -I$(OPENGLINCDIR) $(IVFLAGS) -o $@ -c $< $(CXX) $(OPT) $(CXXFLAGS) -I$(OPENGLINCDIR) $(IVFLAGS) -o $@ -c $<
endif endif
$(GLDIRS)/gl2ps.o: $(GLDIRS)/gl2ps.c
$(CC) $(OPT) -I$(GLDIRI) -o $@ -c $<
// @(#)root/gl:$Name: $:$Id: TViewerOpenGL.h,v 1.22 2004/11/23 21:42:55 brun Exp $ // @(#)root/gl:$Name: v4-02-00 $:$Id: TViewerOpenGL.h,v 1.23 2004/12/01 16:57:19 brun Exp $
// Author: Timur Pocheptsov 03/08/2004 // Author: Timur Pocheptsov 03/08/2004
/************************************************************************* /*************************************************************************
...@@ -114,6 +114,7 @@ public: ...@@ -114,6 +114,7 @@ public:
private: private:
void CreateViewer(); void CreateViewer();
void DrawObjects()const; void DrawObjects()const;
void PrintObjects()const;
void MakeCurrent()const; void MakeCurrent()const;
void SwapBuffers()const; void SwapBuffers()const;
void Show(); void Show();
......
/* $Id: gl2ps.h,v 1.94 2004/12/19 01:59:30 geuzaine Exp $ */
/*
* GL2PS, an OpenGL to PostScript Printing Library
* Copyright (C) 1999-2004 Christophe Geuzaine <geuz@geuz.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of either:
*
* a) the GNU Library General Public License as published by the Free
* Software Foundation, either version 2 of the License, or (at your
* option) any later version; or
*
* b) the GL2PS License as published by Christophe Geuzaine, either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either
* the GNU Library General Public License or the GL2PS License for
* more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library in the file named "COPYING.LGPL";
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
* Cambridge, MA 02139, USA.
*
* You should have received a copy of the GL2PS License with this
* library in the file named "COPYING.GL2PS"; if not, I will be glad
* to provide one.
*
* For the latest info about gl2ps, see http://www.geuz.org/gl2ps/.
* Please report all bugs and problems to <gl2ps@geuz.org>.
*/
#ifndef __GL2PS_H__
#define __GL2PS_H__
#include <stdio.h>
#include <stdlib.h>
/* Define GL2PSDLL at compile time to build a Windows dll */
#if defined (WIN32) || defined(_WIN32)
# if defined(_MSC_VER)
# pragma warning(disable:4115)
# endif
# include <windows.h>
# if defined(GL2PSDLL)
# if defined(GL2PSDLL_EXPORTS)
# define GL2PSDLL_API __declspec(dllexport)
# else
# define GL2PSDLL_API __declspec(dllimport)
# endif
# else
# define GL2PSDLL_API
# endif
#else
# define GL2PSDLL_API
#endif
#if defined(__APPLE__)
# include <OpenGL/gl.h>
#else
# include <GL/gl.h>
#endif
/* Support for compressed PostScript/PDF */
#if defined(HAVE_ZLIB) || defined(HAVE_LIBZ) || defined(GL2PS_HAVE_ZLIB)
# include <zlib.h>
# if !defined(GL2PS_HAVE_ZLIB)
# define GL2PS_HAVE_ZLIB
# endif
#endif
/* Version number */
#define GL2PS_MAJOR_VERSION 1
#define GL2PS_MINOR_VERSION 2
#define GL2PS_PATCH_VERSION 3
#define GL2PS_VERSION (GL2PS_MAJOR_VERSION + \
0.01 * GL2PS_MINOR_VERSION + \
0.0001 * GL2PS_PATCH_VERSION)
/* Output file format */
#define GL2PS_PS 1
#define GL2PS_EPS 2
#define GL2PS_TEX 3
#define GL2PS_PDF 4
/* Sorting algorithms */
#define GL2PS_NO_SORT 1
#define GL2PS_SIMPLE_SORT 2
#define GL2PS_BSP_SORT 3
/* Message levels and error codes */
#define GL2PS_SUCCESS 0
#define GL2PS_INFO 1
#define GL2PS_WARNING 2
#define GL2PS_ERROR 3
#define GL2PS_NO_FEEDBACK 4
#define GL2PS_OVERFLOW 5
#define GL2PS_UNINITIALIZED 6
/* Options for gl2psBeginPage */
#define GL2PS_NONE 0
#define GL2PS_DRAW_BACKGROUND (1<<0)
#define GL2PS_SIMPLE_LINE_OFFSET (1<<1)
#define GL2PS_SILENT (1<<2)
#define GL2PS_BEST_ROOT (1<<3)
#define GL2PS_OCCLUSION_CULL (1<<4)
#define GL2PS_NO_TEXT (1<<5)
#define GL2PS_LANDSCAPE (1<<6)
#define GL2PS_NO_PS3_SHADING (1<<7)
#define GL2PS_NO_PIXMAP (1<<8)
#define GL2PS_USE_CURRENT_VIEWPORT (1<<9)
#define GL2PS_COMPRESS (1<<10)
#define GL2PS_NO_BLENDING (1<<11)
/* Arguments for gl2psEnable/gl2psDisable */
#define GL2PS_POLYGON_OFFSET_FILL 1
#define GL2PS_POLYGON_BOUNDARY 2
#define GL2PS_LINE_STIPPLE 3
#define GL2PS_BLEND 4
/* Text alignment (o=raster position; default mode is BL):
+---+ +---+ +---+ +---+ +---+ +---+ +-o-+ o---+ +---o
| o | o | | o | | | | | | | | | | | |
+---+ +---+ +---+ +-o-+ o---+ +---o +---+ +---+ +---+
C CL CR B BL BR T TL TR */
#define GL2PS_TEXT_C 1
#define GL2PS_TEXT_CL 2
#define GL2PS_TEXT_CR 3
#define GL2PS_TEXT_B 4
#define GL2PS_TEXT_BL 5
#define GL2PS_TEXT_BR 6
#define GL2PS_TEXT_T 7
#define GL2PS_TEXT_TL 8
#define GL2PS_TEXT_TR 9
typedef GLfloat GL2PSrgba[4];
#if defined(__cplusplus)
extern "C" {
#endif
GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer,
GLint viewport[4], GLint format, GLint sort,
GLint options, GLint colormode,
GLint colorsize, GL2PSrgba *colormap,
GLint nr, GLint ng, GLint nb, GLint buffersize,
FILE *stream, const char *filename);
GL2PSDLL_API GLint gl2psEndPage(void);
GL2PSDLL_API GLint gl2psBeginViewport(GLint viewport[4]);
GL2PSDLL_API GLint gl2psEndViewport(void);
GL2PSDLL_API GLint gl2psText(const char *str, const char *fontname,
GLshort fontsize);
GL2PSDLL_API GLint gl2psTextOpt(const char *str, const char *fontname,
GLshort fontsize, GLint align, GLfloat angle);
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height,
GLint xorig, GLint yorig,
GLenum format, GLenum type, const void *pixels);
GL2PSDLL_API GLint gl2psEnable(GLint mode);
GL2PSDLL_API GLint gl2psDisable(GLint mode);
GL2PSDLL_API GLint gl2psPointSize(GLfloat value);
GL2PSDLL_API GLint gl2psLineWidth(GLfloat value);
GL2PSDLL_API GLint gl2psBlendFunc(GLenum sfactor, GLenum dfactor);
/* undocumented */
GL2PSDLL_API GLint gl2psDrawImageMap(GLsizei width, GLsizei height,
const GLfloat position[3],
const unsigned char *imagemap);
#if defined(__cplusplus)
}
#endif
#endif /* __GL2PS_H__ */
// @(#)root/gl:$Name: $:$Id: TViewerOpenGL.cxx,v 1.46 2005/01/04 14:38:50 brun Exp $ // @(#)root/gl:$Name: $:$Id: TViewerOpenGL.cxx,v 1.47 2005/01/19 13:19:34 brun Exp $
// Author: Timur Pocheptsov 03/08/2004 // Author: Timur Pocheptsov 03/08/2004
/************************************************************************* /*************************************************************************
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
#include "TPluginManager.h" #include "TPluginManager.h"
#include "TRootHelpDialog.h" #include "TRootHelpDialog.h"
#include "TContextMenu.h" #include "TContextMenu.h"
#include "TVirtualPad.h"
#include "TVirtualGL.h"
#include "KeySymbols.h" #include "KeySymbols.h"
#include "TGShutter.h" #include "TGShutter.h"
#include "TVirtualX.h"
#include "TBuffer3D.h" #include "TBuffer3D.h"
#include "TGLKernel.h" #include "TGLKernel.h"
#include "TGButton.h" #include "TGButton.h"
...@@ -25,11 +22,9 @@ ...@@ -25,11 +22,9 @@
#include "Buttons.h" #include "Buttons.h"
#include "TAtt3D.h" #include "TAtt3D.h"
#include "TGMenu.h" #include "TGMenu.h"
#include "TPoint.h"
#include "TColor.h" #include "TColor.h"
#include "TTimer.h"
#include "TROOT.h"
#include "TMath.h" #include "TMath.h"
#include "TSystem.h"
#include "TGLSceneObject.h" #include "TGLSceneObject.h"
#include "TViewerOpenGL.h" #include "TViewerOpenGL.h"
...@@ -39,6 +34,8 @@ ...@@ -39,6 +34,8 @@
#include "TGLCamera.h" #include "TGLCamera.h"
#include "TArcBall.h" #include "TArcBall.h"
#include "gl2ps.h"
const char gHelpViewerOpenGL[] = "\ const char gHelpViewerOpenGL[] = "\
PRESS \n\ PRESS \n\
\tw\t--- wireframe mode\n\ \tw\t--- wireframe mode\n\
...@@ -119,6 +116,8 @@ enum EGLViewerCommands { ...@@ -119,6 +116,8 @@ enum EGLViewerCommands {
kGLXOZ, kGLXOZ,
kGLYOZ, kGLYOZ,
kGLPersp, kGLPersp,
kGLPrintEPS,
kGLPrintPDF,
kGLExit kGLExit
}; };
...@@ -129,6 +128,8 @@ const Int_t TViewerOpenGL::fgInitY = 0; ...@@ -129,6 +128,8 @@ const Int_t TViewerOpenGL::fgInitY = 0;
const Int_t TViewerOpenGL::fgInitW = 780; const Int_t TViewerOpenGL::fgInitW = 780;
const Int_t TViewerOpenGL::fgInitH = 670; const Int_t TViewerOpenGL::fgInitH = 670;
int format = GL2PS_EPS;
//______________________________________________________________________________ //______________________________________________________________________________
TViewerOpenGL::TViewerOpenGL(TVirtualPad * vp) TViewerOpenGL::TViewerOpenGL(TVirtualPad * vp)
:TVirtualViewer3D(vp), :TVirtualViewer3D(vp),
...@@ -184,6 +185,8 @@ void TViewerOpenGL::CreateViewer() ...@@ -184,6 +185,8 @@ void TViewerOpenGL::CreateViewer()
{ {
// Menus creation // Menus creation
fFileMenu = new TGPopupMenu(fClient->GetRoot()); fFileMenu = new TGPopupMenu(fClient->GetRoot());
fFileMenu->AddEntry("&Print EPS", kGLPrintEPS);
fFileMenu->AddEntry("&Print PDF", kGLPrintPDF);
fFileMenu->AddEntry("&Exit", kGLExit); fFileMenu->AddEntry("&Exit", kGLExit);
fFileMenu->Associate(this); fFileMenu->Associate(this);
...@@ -471,8 +474,8 @@ Bool_t TViewerOpenGL::HandleContainerMotion(Event_t *event) ...@@ -471,8 +474,8 @@ Bool_t TViewerOpenGL::HandleContainerMotion(Event_t *event)
case kYOZ: case kYOZ:
fSelectedObj->Shift(0., -yshift, xshift); fSelectedObj->Shift(0., -yshift, xshift);
break; break;
default: default:
break; break;
} }
} else { } else {
const Double_t *rotM = fArcBall->GetRotMatrix(); const Double_t *rotM = fArcBall->GetRotMatrix();
...@@ -628,6 +631,51 @@ void TViewerOpenGL::DrawObjects()const ...@@ -628,6 +631,51 @@ void TViewerOpenGL::DrawObjects()const
SwapBuffers(); SwapBuffers();
} }
//______________________________________________________________________________
void TViewerOpenGL::PrintObjects()const
{
// Generates a PostScript or PDF output of the OpenGL scene. They are vector
// graphics files and can be huge and long to generate.
char *pFileName = "viewer.eps";
if (format == GL2PS_PDF) pFileName = "viewer.pdf";
Info("Print", "Start creating %s. Please wait ...", pFileName);
if (FILE *output = fopen (pFileName, "w+"))
{
int buffsize = 0, state = GL2PS_OVERFLOW;
while (state == GL2PS_OVERFLOW) {
MakeCurrent();
buffsize += 1024*1024;
gl2psBeginPage ("ROOT Scene Graph", "ROOT", NULL,
format, GL2PS_BSP_SORT,
GL2PS_USE_CURRENT_VIEWPORT
| GL2PS_SIMPLE_LINE_OFFSET | GL2PS_SILENT
| GL2PS_BEST_ROOT | GL2PS_OCCLUSION_CULL
| 0,
GL_RGBA, 0, NULL,0, 0, 0,
buffsize, output, NULL);
gVirtualGL->NewMVGL();
Float_t pos[] = {0.f, 0.f, 0.f, 1.f};
Float_t lig_prop1[] = {.5f, .5f, .5f, 1.f};
gVirtualGL->GLLight(kLIGHT0, kPOSITION, pos);
gVirtualGL->PushGLMatrix();
gVirtualGL->TranslateGL(0., fRad + fYc, -fRad - fZc);
gVirtualGL->GLLight(kLIGHT1, kPOSITION, pos);
gVirtualGL->GLLight(kLIGHT1, kDIFFUSE, lig_prop1);
gVirtualGL->PopGLMatrix();
gVirtualGL->TraverseGraph((TGLRender *)fRender);
SwapBuffers();
state = gl2psEndPage();
}
fclose (output);
if (!gSystem->AccessPathName(pFileName))
Info("Print", "ROOT file %s has been created", pFileName);
}
}
//______________________________________________________________________________ //______________________________________________________________________________
void TViewerOpenGL::UpdateRange(const TGLSelection *box) void TViewerOpenGL::UpdateRange(const TGLSelection *box)
{ {
...@@ -679,6 +727,14 @@ Bool_t TViewerOpenGL::ProcessMessage(Long_t msg, Long_t parm1, Long_t) ...@@ -679,6 +727,14 @@ Bool_t TViewerOpenGL::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
hd->Popup(); hd->Popup();
break; break;
} }
case kGLPrintEPS:
format = GL2PS_EPS;
PrintObjects();
break;
case kGLPrintPDF:
format = GL2PS_PDF;
PrintObjects();
break;
case kGLXOY: case kGLXOY:
if (fConf != kXOY) { if (fConf != kXOY) {
//set active camera //set active camera
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment