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

Last change on this file since 1337 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

  • Property svn:mime-type set to text/cpp
File size: 4.7 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.26 2009/11/17 14:37:06 lgarnier Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
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  fSceneHandler.RemoveViewerFromList(this);
67}
68
69void G4VViewer::SetName (const G4String& name) {
70  fName = name;
71  fShortName = fName (0, fName.find (' '));
72  fShortName.strip ();
73}
74
75const G4VisAttributes* G4VViewer::GetApplicableVisAttributes
76(const G4VisAttributes* pVisAttribs) const {
77  // If pVisAttribs is zero, pick up the default vis attributes from
78  // the view parameters.
79  if (!pVisAttribs)
80    pVisAttribs = GetViewParameters ().GetDefaultVisAttributes ();
81  return pVisAttribs;
82}
83
84void G4VViewer::NeedKernelVisit () {
85
86  fNeedKernelVisit = true;
87
88  // At one time I thought we'd better notify all viewers.  But I guess
89  // each viewer can take care of itself, so the following code is
90  // redundant (but keep it commented out for now).   (John Allison)
91  // Notify all viewers that a kernel visit is required.
92  // const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
93  // G4ViewerListConstIterator i;
94  // for (i = viewerList.begin(); i != viewerList.end(); i++) {
95  //   (*i) -> SetNeedKernelVisit ();
96  // }
97  // ??...but, there's a problem in OpenGL Stored which seems to
98  // require *all* viewers to revisit the kernel, so...
99  /*
100  const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
101  G4ViewerListConstIterator i;
102  for (i = viewerList.begin(); i != viewerList.end(); i++) {
103    (*i) -> SetNeedKernelVisit (true);
104  }
105  */
106  // Feb 2005 - commented out.  Let's fix OpenGL if necessary.
107}
108
109void G4VViewer::FinishView () {}
110
111void G4VViewer::ShowView () {}
112
113void G4VViewer::ProcessView ()
114{
115  // If ClearStore has been requested, e.g., if the scene has changed,
116  // or if the concrete viewer has decided that it necessary to visit
117  // the kernel, perhaps because the view parameters have changed
118  // significantly (this should be done in the concrete viewer's
119  // DrawView)...
120  if (fNeedKernelVisit) {
121    // Reset flag.  This must be done before ProcessScene to prevent
122    // recursive calls when recomputing transients...
123    fNeedKernelVisit = false;
124    fSceneHandler.ProcessScene (*this);
125  }
126}
127
128void G4VViewer::SetViewParameters (const G4ViewParameters& vp) {
129  fVP = vp;
130}
131
132std::ostream& operator << (std::ostream& os, const G4VViewer& v) {
133  os << "View " << v.fName << ":\n";
134  os << v.fVP;
135  return os;
136}
Note: See TracBrowser for help on using the repository browser.