Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // Guy Barrand 12 October 2021 27 // 28 29 #include "G4PlotterManager.hh" 30 #include "G4ios.hh" 31 32 #include <tools/forit> 33 #include <tools/tokenize> 34 35 G4PlotterManager& G4PlotterManager::GetInstanc 36 static G4PlotterManager s_instance; 37 return s_instance; 38 } 39 40 G4PlotterManager::G4PlotterManager():fMessenge 41 fMessenger = new Messenger(*this); 42 } 43 44 G4PlotterManager::~G4PlotterManager() { 45 delete fMessenger; 46 } 47 48 G4Plotter& G4PlotterManager::GetPlotter(const 49 tools_vforit(NamedPlotter,fPlotters,it) { 50 if((*it).first==a_name) { 51 return (*it).second; 52 } 53 } 54 fPlotters.push_back(NamedPlotter(a_name,G4Pl 55 return fPlotters.back().second; 56 } 57 58 void G4PlotterManager::List() const { 59 tools_vforcit(NamedPlotter,fPlotters,it) { 60 G4cout << (*it).first << G4endl; 61 } 62 } 63 64 ////////////////////////////////////////////// 65 /// styles: ////////////////////////////////// 66 ////////////////////////////////////////////// 67 68 void G4PlotterManager::ListStyles() const { 69 tools_vforcit(NamedStyle,fStyles,it) { 70 G4cout << (*it).first << G4endl; 71 } 72 } 73 74 G4PlotterManager::Style* G4PlotterManager::Fin 75 tools_vforit(NamedStyle,fStyles,it){ 76 if((*it).first==a_name) return &((*it).sec 77 } 78 return 0; 79 } 80 81 void G4PlotterManager::SelectStyle(const G4Str 82 if(!FindStyle(a_name)) { 83 fStyles.push_back(NamedStyle(a_name,Style( 84 } 85 fCurrentStyle = a_name; 86 } 87 88 void G4PlotterManager::RemoveStyle(const G4Str 89 tools_vforit(NamedStyle,fStyles,it) { 90 if((*it).first==a_name) { 91 fStyles.erase(it); 92 if(fCurrentStyle==a_name) fCurrentStyle. 93 return; 94 } 95 } 96 } 97 98 void G4PlotterManager::PrintStyle(const G4Stri 99 tools_vforcit(NamedStyle,fStyles,it) { 100 if((*it).first==a_name) { 101 G4cout << (*it).first << ":" << G4endl; 102 tools_vforcit(StyleItem,(*it).second,its 103 G4cout << " " << (*its).first << " " < 104 } 105 } 106 } 107 } 108 109 void G4PlotterManager::AddStyleParameter(const 110 Style* _style = FindStyle(fCurrentStyle); 111 if(!_style) { 112 G4cout << "G4PlotterManager::AddStyleParam 113 return; 114 } 115 tools_vforit(StyleItem,(*_style),it) { 116 if((*it).first==a_parameter) { 117 (*it).second = a_value; 118 return; 119 } 120 } 121 _style->push_back(StyleItem(a_parameter,a_va 122 } 123 124 void G4PlotterManager::Messenger::SetNewValue( 125 std::vector<std::string> args; 126 tools::double_quotes_tokenize(a_value,args); 127 if(args.size()!=a_cmd->GetParameterEntries() 128 if(a_cmd==select_style) { 129 fPlotterManager.SelectStyle(args[0]); 130 } else if(a_cmd==add_style_parameter) { 131 fPlotterManager.AddStyleParameter(args[0], 132 } else if(a_cmd==remove_style) { 133 fPlotterManager.RemoveStyle(args[0]); 134 } else if(a_cmd==list_styles) { 135 G4cout << "default (embedded)." << G4endl; 136 G4cout << "ROOT_default (embedded)." << G4 137 G4cout << "hippodraw (embedded)." << G4end 138 fPlotterManager.ListStyles(); 139 } else if(a_cmd==print_style) { 140 fPlotterManager.PrintStyle(args[0]); 141 } 142 } 143