G4ASCIITreeMessenger.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 // 
00030 // John Allison  5th April 2001
00031 // A scene handler to dump geometry hierarchy in readable ASCII.
00032 // Based on a provisional G4ASCIITreeGraphicsScene (was in modeling).
00033 
00034 #include "G4ASCIITreeMessenger.hh"
00035 
00036 #include "G4ASCIITree.hh"
00037 #include "G4UIcommand.hh"
00038 #include "G4UIdirectory.hh"
00039 #include "G4UIcmdWithAnInteger.hh"
00040 #include "G4UIcmdWithAString.hh"
00041 
00042 std::vector<G4String> G4ASCIITreeMessenger::fVerbosityGuidance;
00043 
00044 G4ASCIITreeMessenger::G4ASCIITreeMessenger
00045 (G4ASCIITree* ASCIITree):
00046   fpASCIITree(ASCIITree) {
00047 
00048   G4bool omitable;
00049 
00050   fpDirectory = new G4UIdirectory ("/vis/ASCIITree/");
00051   fpDirectory -> SetGuidance ("Commands for ASCIITree control.");
00052 
00053   fpDirectorySet = new G4UIdirectory ("/vis/ASCIITree/set/");
00054   fpDirectorySet -> SetGuidance ("Settings for ASCIITree control.");
00055 
00056   fpCommandVerbose = new G4UIcmdWithAnInteger ("/vis/ASCIITree/verbose", this);
00057   fVerbosityGuidance.push_back
00058     ("  <  10: - does not print daughters of repeated placements,"
00059      " does not repeat replicas.");
00060   fVerbosityGuidance.push_back
00061     ("  >= 10: prints all physical volumes.");
00062   fVerbosityGuidance.push_back
00063     ("The level of detail is given by verbosity%10:");
00064   fVerbosityGuidance.push_back
00065     ("for each volume:");
00066   fVerbosityGuidance.push_back
00067     ("  >=  0: physical volume name.");
00068   fVerbosityGuidance.push_back
00069     ("  >=  1: logical volume name (and names of sensitive detector"
00070      " and readout geometry, if any).");
00071   fVerbosityGuidance.push_back
00072     ("  >=  2: solid name and type.");
00073   fVerbosityGuidance.push_back
00074     ("  >=  3: volume and density.");
00075   fVerbosityGuidance.push_back
00076     ("  >=  5: daughter-subtracted volume and mass.");
00077   fVerbosityGuidance.push_back
00078     ("and in the summary at the end of printing:");
00079   fVerbosityGuidance.push_back
00080     ("  >=  4: daughter-included mass of top physical volume(s) in scene"
00081      " to depth specified.");
00082   fVerbosityGuidance.push_back
00083     ("Note: by default, culling is switched off so all volumes are seen.");
00084   fVerbosityGuidance.push_back
00085     ("Note: the mass calculation takes into account daughters, which can be"
00086      " time consuming.  If you want the mass of a particular subtree to a"
00087      " particular depth:");
00088   fVerbosityGuidance.push_back
00089     ("  /vis/open ATree");
00090   fVerbosityGuidance.push_back
00091     ("  /vis/ASCIITree/verbose 14");
00092   fVerbosityGuidance.push_back
00093     ("  /vis/scene/create");
00094   fVerbosityGuidance.push_back
00095     ("  /vis/scene/add/volume <subtree-physical-volume> ! <depth>");
00096   fVerbosityGuidance.push_back
00097     ("  /vis/sceneHandler/attach");
00098   fVerbosityGuidance.push_back
00099     ("  /vis/viewer/flush");
00100   for (size_t i = 0; i < fVerbosityGuidance.size(); ++i) {
00101     fpCommandVerbose -> SetGuidance(fVerbosityGuidance[i]);
00102   }
00103   fpCommandVerbose -> SetParameterName ("verbosity",omitable = true);
00104   fpCommandVerbose -> SetDefaultValue(0);
00105 
00106   fpCommandSetOutFile = new G4UIcmdWithAString ("/vis/ASCIITree/set/outFile", this
00107 );
00108   fpCommandSetOutFile -> SetGuidance ("Set name of output file.");
00109   fpCommandSetOutFile -> SetParameterName ("out-filename",
00110                                            omitable = true);
00111   fpCommandSetOutFile -> SetDefaultValue ("G4cout");
00112 }
00113 
00114 G4ASCIITreeMessenger::~G4ASCIITreeMessenger() {
00115   delete fpCommandSetOutFile;
00116   delete fpDirectorySet;
00117   delete fpCommandVerbose;
00118   delete fpDirectory;
00119 }
00120 
00121 G4String G4ASCIITreeMessenger::GetCurrentValue(G4UIcommand*) {
00122   return "";
00123 }
00124 
00125 void G4ASCIITreeMessenger::SetNewValue
00126 (G4UIcommand* command,
00127  G4String newValue) {
00128   if (command == fpCommandVerbose)
00129     {
00130       fpASCIITree->SetVerbosity
00131         (fpCommandVerbose->GetNewIntValue(newValue));
00132       G4cout << "G4ASCIITree verbosity now "
00133              << fpASCIITree->GetVerbosity()
00134              << G4endl;
00135     }
00136   else if (command == fpCommandSetOutFile)
00137     {
00138       fpASCIITree -> SetOutFileName (newValue);      
00139       G4cout << "G4ASCIITree out filename now "
00140              << fpASCIITree -> GetOutFileName()
00141              << G4endl;  
00142     }
00143 }

Generated on Mon May 27 17:47:41 2013 for Geant4 by  doxygen 1.4.7