source: trunk/source/visualization/OpenInventor/src/SoGL2PSAction.cc @ 926

Last change on this file since 926 was 926, checked in by garnier, 15 years ago

OI marche, mais en debug

  • Property svn:mime-type set to text/cpp
File size: 5.5 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26#ifdef G4VIS_BUILD_OI_DRIVER
27
28/*----------------------------HEPVis----------------------------------------*/
29/*                                                                          */
30/* Node:             SoGL2PSAction                                          */
31/* Author:           Guy Barrand                                            */
32/*                                                                          */
33/*--------------------------------------------------------------------------*/
34
35#define G4DEBUG_VIS_OGL 1
36
37// this :
38#include <HEPVis/actions/SoGL2PSAction.h>
39
40// Inventor :
41#include <Inventor/elements/SoViewportRegionElement.h>
42#include <Inventor/errors/SoDebugError.h>
43
44#include "Geant4_gl2ps.h"
45
46#include <stdio.h>
47
48SO_ACTION_SOURCE(SoGL2PSAction)
49//////////////////////////////////////////////////////////////////////////////
50void SoGL2PSAction::initClass(
51)
52//////////////////////////////////////////////////////////////////////////////
53//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
54{
55#ifdef G4DEBUG_VIS_OGL
56  printf("SoGL2PSAction::initClass\n");
57#endif
58  SO_ACTION_INIT_CLASS(SoGL2PSAction,SoGLRenderAction);
59}
60//////////////////////////////////////////////////////////////////////////////
61SoGL2PSAction::SoGL2PSAction(
62 const SbViewportRegion& aViewPortRegion
63)
64:SoGLRenderAction(aViewPortRegion)
65,G4OpenGL2PSAction()
66//////////////////////////////////////////////////////////////////////////////
67//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
68{
69#ifdef G4DEBUG_VIS_OGL
70  printf("SoGL2PSAction::SoGL2PSAction\n");
71#endif
72  setFileName("out.ps");
73  SO_ACTION_CONSTRUCTOR(SoGL2PSAction);
74}
75
76void SoGL2PSAction::enableFileWriting(
77)
78//////////////////////////////////////////////////////////////////////////////
79//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
80{
81  fFile = ::fopen(fFileName,"w");
82  if(!fFile) {
83    SoDebugError::post("SoGL2PSAction::enableFileWriting",
84                       "Cannot open file %s",fFileName);
85    return;
86  }
87#ifdef __COIN__
88#else //SGI
89  const SbViewportRegion& vpr = getViewportRegion();
90  SoViewportRegionElement::set(getState(),vpr);
91  gl2psBegin();
92#endif
93}
94
95//////////////////////////////////////////////////////////////////////////////
96void SoGL2PSAction::setViewport(
97)
98//////////////////////////////////////////////////////////////////////////////
99//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
100{
101#ifdef G4DEBUG_VIS_OGL
102  printf("SoGL2PSAction::setViewport\n");
103#endif
104  // Useful ? L.Garnier 02/2009
105
106#ifdef __COIN__
107#else //SGI
108  const SbViewportRegion& vpr = getViewportRegion();
109  SoViewportRegionElement::set(getState(),vpr);
110 
111  const SbVec2s& win = vpr.getWindowSize();
112  fViewport[0] = 0;
113  fViewport[1] = 0;
114  fViewport[2] = win[0];
115  fViewport[3] = win[1];
116#endif
117}
118//////////////////////////////////////////////////////////////////////////////
119void SoGL2PSAction::beginTraversal(
120 SoNode* aNode
121)
122//////////////////////////////////////////////////////////////////////////////
123//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
124{
125#ifdef G4DEBUG_VIS_OGL
126  printf("SoGL2PSAction::beginTraversal\n");
127#endif
128  if(fFile) {
129#ifdef __COIN__
130    const SbViewportRegion& vpr = getViewportRegion();
131    SoViewportRegionElement::set(getState(),vpr);
132#ifdef G4DEBUG_VIS_OGL
133  printf("SoGL2PSAction::beginTraversal 1\n");
134#endif
135    G4gl2psBegin();
136#ifdef G4DEBUG_VIS_OGL
137  printf("SoGL2PSAction::beginTraversal 2\n");
138#endif
139    traverse(aNode);
140#ifdef G4DEBUG_VIS_OGL
141  printf("SoGL2PSAction::beginTraversal 3\n");
142#endif
143    gl2psEndPage();       
144#ifdef G4DEBUG_VIS_OGL
145  printf("SoGL2PSAction::beginTraversal 4\n");
146#endif
147#else //SGI
148    SoGLRenderAction::beginTraversal(aNode);
149#endif
150  } else {
151    SoGLRenderAction::beginTraversal(aNode);
152  }
153#ifdef G4DEBUG_VIS_OGL
154  printf("SoGL2PSAction::beginTraversal 5\n");
155#endif
156}
157
158#endif
Note: See TracBrowser for help on using the repository browser.