source: trunk/source/visualization/management/src/G4VViewer.cc@ 1109

Last change on this file since 1109 was 959, checked in by garnier, 17 years ago

after maj on CVS good-HEAD

  • Property svn:mime-type set to text/cpp
File size: 4.8 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: G4VViewer.cc,v 1.25 2009/01/13 09:55:15 lgarnier Exp $
28// GEANT4 tag $Name: $
29//
30//
31// John Allison 27th March 1996
32// Abstract interface class for graphics views.
33
34#include "G4VViewer.hh"
35
36#include "G4ios.hh"
37#include <sstream>
38
39#include "G4VisManager.hh"
40#include "G4VGraphicsSystem.hh"
41#include "G4VSceneHandler.hh"
42#include "G4Scene.hh"
43#include "G4VPhysicalVolume.hh"
44#include "G4Transform3D.hh"
45
46G4VViewer::G4VViewer (G4VSceneHandler& sceneHandler,
47 G4int id, const G4String& name):
48fSceneHandler (sceneHandler),
49fViewId (id),
50//fModified (true),
51fNeedKernelVisit (true)
52{
53 if (name == "") {
54 std::ostringstream ost;
55 ost << fSceneHandler.GetName () << '-' << fViewId;
56 fName = ost.str();
57 }
58 else {
59 fName = name;
60 }
61 fShortName = fName (0, fName.find (' '));
62 fShortName.strip ();
63}
64
65G4VViewer::~G4VViewer () {}
66
67void G4VViewer::SetName (const G4String& name) {
68 fName = name;
69 fShortName = fName (0, fName.find (' '));
70 fShortName.strip ();
71}
72
73const G4VisAttributes* G4VViewer::GetApplicableVisAttributes
74(const G4VisAttributes* pVisAttribs) const {
75 // If pVisAttribs is zero, pick up the default vis attributes from
76 // the view parameters.
77 if (!pVisAttribs)
78 pVisAttribs = GetViewParameters ().GetDefaultVisAttributes ();
79 return pVisAttribs;
80}
81
82void G4VViewer::NeedKernelVisit () {
83
84 fNeedKernelVisit = true;
85
86 // At one time I thought we'd better notify all viewers. But I guess
87 // each viewer can take care of itself, so the following code is
88 // redundant (but keep it commented out for now). (John Allison)
89 // Notify all viewers that a kernel visit is required.
90 // const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
91 // G4ViewerListConstIterator i;
92 // for (i = viewerList.begin(); i != viewerList.end(); i++) {
93 // (*i) -> SetNeedKernelVisit ();
94 // }
95 // ??...but, there's a problem in OpenGL Stored which seems to
96 // require *all* viewers to revisit the kernel, so...
97 /*
98 const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
99 G4ViewerListConstIterator i;
100 for (i = viewerList.begin(); i != viewerList.end(); i++) {
101 (*i) -> SetNeedKernelVisit (true);
102 }
103 */
104 // Feb 2005 - commented out. Let's fix OpenGL if necessary.
105}
106
107void G4VViewer::FinishView () {}
108
109void G4VViewer::ShowView () {}
110
111void G4VViewer::ProcessView ()
112{
113#ifdef G4DEBUG_VIS_MANAGEMENT
114 printf("G4VViewer::ProcessView\n");
115#endif
116
117 // If ClearStore has been requested, e.g., if the scene has changed,
118 // or if the concrete viewer has decided that it necessary to visit
119 // the kernel, perhaps because the view parameters have changed
120 // significantly (this should be done in the concrete viewer's
121 // DrawView)...
122 if (fNeedKernelVisit) {
123#ifdef G4DEBUG_VIS_MANAGEMENT
124 printf("G4VViewer::ProcessView : NeedKernelVisit\n");
125#endif
126 // Reset flag. This must be done before ProcessScene to prevent
127 // recursive calls when recomputing transients...
128 fNeedKernelVisit = false;
129 fSceneHandler.ProcessScene (*this);
130 }
131}
132
133void G4VViewer::SetViewParameters (const G4ViewParameters& vp) {
134 fVP = vp;
135}
136
137std::ostream& operator << (std::ostream& os, const G4VViewer& v) {
138 os << "View " << v.fName << ":\n";
139 os << v.fVP;
140 return os;
141}
Note: See TracBrowser for help on using the repository browser.