G4VVisCommand.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 
00029 // Base class for visualization commands - John Allison  9th August 1998
00030 // It is really a messenger - we have one command per messenger.
00031 
00032 #include "G4VVisCommand.hh"
00033 
00034 #include "G4UIcommand.hh"
00035 #include "G4UImanager.hh"
00036 #include "G4UnitsTable.hh"
00037 #include <sstream>
00038 
00039 G4Colour                   G4VVisCommand::fCurrentColour = G4Colour::White();
00040 G4Colour                   G4VVisCommand::fCurrentTextColour = G4Colour::Blue();
00041 G4Text::Layout             G4VVisCommand::fCurrentTextLayout = G4Text::left;
00042 G4double                   G4VVisCommand::fCurrentLineWidth = 1.;
00043 // Not yet used: G4VisAttributes::LineStyle G4VVisCommand::fCurrentLineStyle = G4VisAttributes::unbroken;
00044 // Not yet used: G4VMarker::FillStyle       G4VVisCommand::fCurrentFillStyle = G4VMarker::filled;
00045 // Not yet used: G4VMarker::SizeType        G4VVisCommand::fCurrentSizeType = G4VMarker::screen;
00046 G4ModelingParameters::PVNameCopyNoPath G4VVisCommand::fCurrentTouchablePath;
00047 
00048 G4VVisCommand::G4VVisCommand () {}
00049 
00050 G4VVisCommand::~G4VVisCommand () {}
00051 
00052 G4VisManager* G4VVisCommand::fpVisManager = 0;
00053 
00054 G4String G4VVisCommand::ConvertToString
00055 (G4double x, G4double y, const char * unitName)
00056 {
00057   G4double uv = G4UIcommand::ValueOf(unitName);
00058   
00059   std::ostringstream oss;
00060   oss << x/uv << " " << y/uv << " " << unitName;
00061   return oss.str();
00062 }
00063 
00064 void G4VVisCommand::ConvertToDoublePair(const G4String& paramString,
00065                                         G4double& xval,
00066                                         G4double& yval)
00067 {
00068   G4double x, y;
00069   char unts[30];
00070   
00071   std::istringstream is(paramString);
00072   is >> x >> y >> unts;
00073   G4String unt = unts;
00074 
00075   xval = x*G4UIcommand::ValueOf(unt);
00076   yval = y*G4UIcommand::ValueOf(unt);
00077 
00078   return;
00079 }
00080 
00081 void G4VVisCommand::UpdateVisManagerScene
00082 (const G4String& sceneName) {
00083 
00084   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
00085 
00086   const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
00087 
00088   G4int iScene, nScenes = sceneList.size ();
00089   for (iScene = 0; iScene < nScenes; iScene++) {
00090     if (sceneList [iScene] -> GetName () == sceneName) break;
00091   }
00092 
00093   G4Scene* pScene = 0;  // Zero unless scene has been found...
00094   if (iScene < nScenes) {
00095     pScene = sceneList [iScene];
00096   }
00097 
00098   if (!pScene) {
00099     if (verbosity >= G4VisManager::warnings) {
00100       G4cout << "WARNING: Scene \"" << sceneName << "\" not found."
00101              << G4endl;
00102     }
00103     return;
00104   }
00105 
00106   fpVisManager -> SetCurrentScene (pScene);
00107 
00108   // Scene has changed.  Refresh viewers of all sceneHandlers using
00109   // this scene...
00110   G4VViewer* pViewer = fpVisManager -> GetCurrentViewer();
00111   G4VSceneHandler* sceneHandler = fpVisManager -> GetCurrentSceneHandler();
00112   if (sceneHandler && sceneHandler -> GetScene ()) {
00113     if (pViewer) {
00114       G4UImanager::GetUIpointer () ->
00115         ApplyCommand ("/vis/scene/notifyHandlers");
00116     }
00117   }
00118 }

Generated on Mon May 27 17:50:24 2013 for Geant4 by  doxygen 1.4.7