source: trunk/source/visualization/management/src/G4VVisCommand.cc@ 933

Last change on this file since 933 was 850, checked in by garnier, 17 years ago

geant4.8.2 beta

  • Property svn:mime-type set to text/cpp
File size: 3.7 KB
RevLine 
[531]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: G4VVisCommand.cc,v 1.18 2006/06/29 21:29:28 gunter Exp $
[850]28// GEANT4 tag $Name: HEAD $
[531]29
30// Base class for visualization commands - John Allison 9th August 1998
31// It is really a messenger - we have one command per messenger.
32
33#include "G4VVisCommand.hh"
34
35#include "G4UIcommand.hh"
36#include "G4UImanager.hh"
37#include "G4UnitsTable.hh"
38#include <sstream>
39
40G4VVisCommand::~G4VVisCommand () {}
41
42G4VisManager* G4VVisCommand::fpVisManager = 0;
43
44G4String G4VVisCommand::ConvertToString
45(G4double x, G4double y, const char * unitName)
46{
47 G4double uv = G4UIcommand::ValueOf(unitName);
48
49 std::ostringstream oss;
50 oss << x/uv << " " << y/uv << " " << unitName;
51 return oss.str();
52}
53
54void G4VVisCommand::ConvertToDoublePair(const G4String& paramString,
55 G4double& xval,
56 G4double& yval)
57{
58 G4double x, y;
59 char unts[30];
60
61 std::istringstream is(paramString);
62 is >> x >> y >> unts;
63 G4String unt = unts;
64
65 xval = x*G4UIcommand::ValueOf(unt);
66 yval = y*G4UIcommand::ValueOf(unt);
67
68 return;
69}
70
71void G4VVisCommand::UpdateVisManagerScene
72(const G4String& sceneName) {
73
74 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
75
76 const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
77
78 G4int iScene, nScenes = sceneList.size ();
79 for (iScene = 0; iScene < nScenes; iScene++) {
80 if (sceneList [iScene] -> GetName () == sceneName) break;
81 }
82
83 G4Scene* pScene = 0; // Zero unless scene has been found...
84 if (iScene < nScenes) {
85 pScene = sceneList [iScene];
86 }
87
88 if (!pScene) {
89 if (verbosity >= G4VisManager::warnings) {
90 G4cout << "WARNING: Scene \"" << sceneName << "\" not found."
91 << G4endl;
92 }
93 return;
94 }
95
96 fpVisManager -> SetCurrentScene (pScene);
97
98 // Scene has changed. Refresh viewers of all sceneHandlers using
99 // this scene...
100 G4VViewer* pViewer = fpVisManager -> GetCurrentViewer();
101 G4VSceneHandler* sceneHandler = fpVisManager -> GetCurrentSceneHandler();
102 if (sceneHandler && sceneHandler -> GetScene ()) {
103 if (pViewer) {
104 G4UImanager::GetUIpointer () ->
105 ApplyCommand ("/vis/scene/notifyHandlers");
106 }
107 }
108}
Note: See TracBrowser for help on using the repository browser.