source: trunk/source/visualization/gMocren/src/G4GMocrenFileViewer.cc @ 1347

Last change on this file since 1347 was 1347, checked in by garnier, 13 years ago

geant4 tag 9.4

File size: 5.3 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//
27// $Id: G4GMocrenFileViewer.cc,v 1.4 2010/11/10 23:53:23 akimura Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
29//
30//
31// Created:  Mar. 31, 2009  Akinori Kimura 
32//
33
34
35#define __G_ANSI_C__
36#define G4GMocrenFile_STRUCTURE_PRIORITY  1.
37
38#include "G4ios.hh"
39#include <cstdio>
40#include <cstring>
41#include <cassert>
42
43#include "G4VisManager.hh"
44#include "G4Scene.hh"
45#include "G4Vector3D.hh"
46#include "G4VisExtent.hh"
47#include "G4LogicalVolume.hh"
48#include "G4VSolid.hh"
49
50#include "G4GMocrenFile.hh"
51#include "G4GMocrenFileSceneHandler.hh"
52#include "G4GMocrenFileViewer.hh"
53#include "G4GMocrenMessenger.hh"
54
55
56//----- constants
57
58//-- for a debugging
59const bool GFDEBUG = false;
60
61//----- G4GMocrenFileViewer, constructor
62G4GMocrenFileViewer::G4GMocrenFileViewer (G4GMocrenFileSceneHandler& sceneHandler,
63                                          G4GMocrenMessenger & messenger,
64                                          const G4String& name)
65  : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
66    kSceneHandler (sceneHandler),
67    kMessenger(messenger)
68{
69  // Set a g4.gdd-file viewer
70  std::strcpy( kG4GddViewer, "gMocren" ); 
71  if( getenv( "G4GMocrenFile_VIEWER" ) != NULL ) {
72    std::strcpy( kG4GddViewer, getenv( "G4GMocrenFile_VIEWER" ) ) ;                     
73  } 
74
75  // string for viewer invocation
76  if ( !std::strcmp( kG4GddViewer, "NONE" ) ) {
77               
78    std::strcpy( kG4GddViewerInvocation, "" );
79  } else {
80
81    std::strcpy( kG4GddViewerInvocation, kG4GddViewer );
82    std::strcat( kG4GddViewerInvocation, " ");
83    std::strcat( kG4GddViewerInvocation, kSceneHandler.GetGddFileName() );
84  }
85
86}
87
88//----- G4GMocrenFileViewer, destructor
89G4GMocrenFileViewer::~G4GMocrenFileViewer () 
90{}
91
92//----- G4GMocrenFileViewer::SetView ()
93void G4GMocrenFileViewer::SetView () 
94{
95  if(GFDEBUG)
96    if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
97      G4cout << "***** G4GMocrenFileViewer::SetView(): No effects" << G4endl;
98
99  // Do nothing, since DAWN is running as a different process.
100  // SendViewParameters () will do this job instead.
101}
102
103
104//----- G4GMocrenFileViewer::ClearView()
105void
106G4GMocrenFileViewer::ClearView( void )
107{
108  if(GFDEBUG)
109    if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
110      G4cout << "***** G4GMocrenFileViewer::ClearView (): No effects " << G4endl;
111
112  //if(kSceneHandler.kGddDest) {
113    //kSceneHandler.kGddDest.close();
114    // Re-open with same filename...
115    //kSceneHandler.kGddDest.open(kSceneHandler.kGddFileName);
116    kSceneHandler.kFlagInModeling = false;
117    kSceneHandler.GFBeginModeling();
118    //}
119}
120
121
122//----- G4GMocrenFileViewer::DrawView ()
123void G4GMocrenFileViewer::DrawView () 
124{
125  if(GFDEBUG)
126    if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
127      G4cout << "***** G4GMocrenFileViewer::DrawView () " << G4endl;
128
129  //-----
130  kSceneHandler.GFBeginModeling() ;
131
132  //----- Always visit G4 kernel
133  NeedKernelVisit ();
134                                   
135  //----- Draw
136  G4VViewer::ProcessView () ;
137
138} // G4GMocrenFileViewer::DrawView ()
139
140
141
142//----- G4GMocrenFileViewer::ShowView()
143void G4GMocrenFileViewer::ShowView( void )
144{
145  if(GFDEBUG)
146    if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
147      G4cout << "***** G4GMocrenFileViewer::ShowView () " << G4endl;
148
149  if( kSceneHandler.GFIsInModeling() ) 
150    {
151      //----- End of modeling
152      // !EndModeling, !DrawAll, !CloseDevice,
153      // close g4.gdd
154      kSceneHandler.GFEndModeling();
155
156      //----- Output DAWN GUI file
157      //SendViewParameters();
158
159      //----- string for viewer invocation
160      if ( !strcmp( kG4GddViewer, "NONE" ) ) {
161               
162        std::strcpy( kG4GddViewerInvocation, "" );
163      } else {
164
165        std::strcpy( kG4GddViewerInvocation, kG4GddViewer );
166        std::strcat( kG4GddViewerInvocation, " ");
167        std::strcat( kG4GddViewerInvocation, kSceneHandler.GetGddFileName() );
168      }
169
170    }
171
172} // G4GMocrenFileViewer::ShowView()
173
Note: See TracBrowser for help on using the repository browser.