Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 // /vis/plotter commands - Guy Barrand October 27 // /vis/plotter commands - Guy Barrand October 2021. 28 28 29 #include "G4VisCommandsPlotter.hh" 29 #include "G4VisCommandsPlotter.hh" 30 30 31 #include "G4PlotterManager.hh" 31 #include "G4PlotterManager.hh" 32 32 33 #include <tools/tokenize> 33 #include <tools/tokenize> 34 34 35 #include <sstream> 35 #include <sstream> 36 36 37 #define G4warn G4cout 37 #define G4warn G4cout 38 38 39 ////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////////// 40 ////////////// /vis/plotter/create /////////// 40 ////////////// /vis/plotter/create ////////////////////////////////////////// 41 ////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////////// 42 G4VisCommandPlotterCreate::G4VisCommandPlotter 42 G4VisCommandPlotterCreate::G4VisCommandPlotterCreate () { 43 fpCommand = new G4UIcommand("/vis/plotter/cr 43 fpCommand = new G4UIcommand("/vis/plotter/create", this); 44 fpCommand->SetGuidance("Create a named G4Plo 44 fpCommand->SetGuidance("Create a named G4Plotter."); 45 45 46 G4UIparameter* parameter; 46 G4UIparameter* parameter; 47 parameter = new G4UIparameter("name",'s',fal 47 parameter = new G4UIparameter("name",'s',false); 48 fpCommand->SetParameter (parameter); 48 fpCommand->SetParameter (parameter); 49 } 49 } 50 50 51 G4VisCommandPlotterCreate::~G4VisCommandPlotte 51 G4VisCommandPlotterCreate::~G4VisCommandPlotterCreate () {delete fpCommand;} 52 52 53 void G4VisCommandPlotterCreate::SetNewValue (G 53 void G4VisCommandPlotterCreate::SetNewValue (G4UIcommand*, G4String newValue) 54 { 54 { 55 G4Plotter& _plotter = G4PlotterManager::GetI 55 G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(newValue); 56 _plotter.Reset(); 56 _plotter.Reset(); 57 G4Scene* pScene = fpVisManager->GetCurrentSc 57 G4Scene* pScene = fpVisManager->GetCurrentScene(); 58 if(pScene) CheckSceneAndNotifyHandlers (pSce 58 if(pScene) CheckSceneAndNotifyHandlers (pScene); 59 } 59 } 60 60 61 ////////////////////////////////////////////// 61 ///////////////////////////////////////////////////////////////////////////// 62 ////////////// /vis/plotter/setLayout //////// 62 ////////////// /vis/plotter/setLayout /////////////////////////////////////// 63 ////////////////////////////////////////////// 63 ///////////////////////////////////////////////////////////////////////////// 64 G4VisCommandPlotterSetLayout::G4VisCommandPlot 64 G4VisCommandPlotterSetLayout::G4VisCommandPlotterSetLayout () { 65 fpCommand = new G4UIcommand("/vis/plotter/se 65 fpCommand = new G4UIcommand("/vis/plotter/setLayout", this); 66 fpCommand->SetGuidance("Set plotter grid lay 66 fpCommand->SetGuidance("Set plotter grid layout."); 67 67 68 G4UIparameter* parameter; 68 G4UIparameter* parameter; 69 parameter = new G4UIparameter("plotter",'s', 69 parameter = new G4UIparameter("plotter",'s',false); 70 fpCommand->SetParameter (parameter); 70 fpCommand->SetParameter (parameter); 71 71 72 parameter = new G4UIparameter("columns",'i', 72 parameter = new G4UIparameter("columns",'i',true); 73 parameter->SetDefaultValue(1); 73 parameter->SetDefaultValue(1); 74 fpCommand->SetParameter (parameter); 74 fpCommand->SetParameter (parameter); 75 75 76 parameter = new G4UIparameter("rows",'i',tru 76 parameter = new G4UIparameter("rows",'i',true); 77 parameter->SetDefaultValue(1); 77 parameter->SetDefaultValue(1); 78 fpCommand->SetParameter (parameter); 78 fpCommand->SetParameter (parameter); 79 } 79 } 80 80 81 G4VisCommandPlotterSetLayout::~G4VisCommandPlo 81 G4VisCommandPlotterSetLayout::~G4VisCommandPlotterSetLayout () {delete fpCommand;} 82 82 83 void G4VisCommandPlotterSetLayout::SetNewValue 83 void G4VisCommandPlotterSetLayout::SetNewValue (G4UIcommand*, G4String newValue) 84 { 84 { 85 G4String plotter; 85 G4String plotter; 86 G4int cols,rows; 86 G4int cols,rows; 87 std::istringstream is(newValue); 87 std::istringstream is(newValue); 88 is >> plotter >> cols >> rows; 88 is >> plotter >> cols >> rows; 89 89 90 G4Plotter& _plotter = G4PlotterManager::GetI 90 G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter); 91 _plotter.SetLayout(cols,rows); 91 _plotter.SetLayout(cols,rows); 92 92 93 G4Scene* pScene = fpVisManager->GetCurrentSc 93 G4Scene* pScene = fpVisManager->GetCurrentScene(); 94 if(pScene) CheckSceneAndNotifyHandlers (pSce 94 if(pScene) CheckSceneAndNotifyHandlers (pScene); 95 } 95 } 96 96 97 ////////////////////////////////////////////// 97 ///////////////////////////////////////////////////////////////////////////// 98 ////////////// /vis/plotter/addStyle ///////// 98 ////////////// /vis/plotter/addStyle //////////////////////////////////////// 99 ////////////////////////////////////////////// 99 ///////////////////////////////////////////////////////////////////////////// 100 G4VisCommandPlotterAddStyle::G4VisCommandPlott 100 G4VisCommandPlotterAddStyle::G4VisCommandPlotterAddStyle () { 101 fpCommand = new G4UIcommand("/vis/plotter/ad 101 fpCommand = new G4UIcommand("/vis/plotter/addStyle", this); 102 fpCommand->SetGuidance("Add a style for a pl 102 fpCommand->SetGuidance("Add a style for a plotter."); 103 fpCommand->SetGuidance("It is applied on all 103 fpCommand->SetGuidance("It is applied on all regions/plots of the plotter."); 104 fpCommand->SetGuidance("default, ROOT_defaul 104 fpCommand->SetGuidance("default, ROOT_default, hippodraw are known embedded styles."); 105 fpCommand->SetGuidance("reset is a keyword u 105 fpCommand->SetGuidance("reset is a keyword used to reset regions style."); 106 106 107 G4UIparameter* parameter; 107 G4UIparameter* parameter; 108 parameter = new G4UIparameter("plotter",'s', 108 parameter = new G4UIparameter("plotter",'s',false); 109 fpCommand->SetParameter (parameter); 109 fpCommand->SetParameter (parameter); 110 110 111 parameter = new G4UIparameter("style",'s',tr 111 parameter = new G4UIparameter("style",'s',true); 112 parameter->SetDefaultValue("default"); 112 parameter->SetDefaultValue("default"); 113 fpCommand->SetParameter (parameter); 113 fpCommand->SetParameter (parameter); 114 } 114 } 115 115 116 G4VisCommandPlotterAddStyle::~G4VisCommandPlot 116 G4VisCommandPlotterAddStyle::~G4VisCommandPlotterAddStyle () {delete fpCommand;} 117 117 118 void G4VisCommandPlotterAddStyle::SetNewValue 118 void G4VisCommandPlotterAddStyle::SetNewValue (G4UIcommand*, G4String newValue) 119 { 119 { 120 G4String plotter; 120 G4String plotter; 121 G4String style; 121 G4String style; 122 std::istringstream is(newValue); 122 std::istringstream is(newValue); 123 is >> plotter >> style; 123 is >> plotter >> style; 124 124 125 G4Plotter& _plotter = G4PlotterManager::GetI 125 G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter); 126 _plotter.AddStyle(style); 126 _plotter.AddStyle(style); 127 127 128 G4Scene* pScene = fpVisManager->GetCurrentSc 128 G4Scene* pScene = fpVisManager->GetCurrentScene(); 129 if(pScene) CheckSceneAndNotifyHandlers (pSce 129 if(pScene) CheckSceneAndNotifyHandlers (pScene); 130 } 130 } 131 131 132 ////////////////////////////////////////////// 132 ///////////////////////////////////////////////////////////////////////////// 133 ////////////// /vis/plotter/addRegionStyle /// 133 ////////////// /vis/plotter/addRegionStyle ////////////////////////////////// 134 ////////////////////////////////////////////// 134 ///////////////////////////////////////////////////////////////////////////// 135 G4VisCommandPlotterAddRegionStyle::G4VisComman 135 G4VisCommandPlotterAddRegionStyle::G4VisCommandPlotterAddRegionStyle () { 136 fpCommand = new G4UIcommand("/vis/plotter/ad 136 fpCommand = new G4UIcommand("/vis/plotter/addRegionStyle", this); 137 fpCommand->SetGuidance("Add a style to be ap 137 fpCommand->SetGuidance("Add a style to be applied on a region."); 138 fpCommand->SetGuidance("default, ROOT_defaul 138 fpCommand->SetGuidance("default, ROOT_default, hippodraw are known embedded styles."); 139 fpCommand->SetGuidance("reset is a keyword u 139 fpCommand->SetGuidance("reset is a keyword used to reset a region style."); 140 140 141 G4UIparameter* parameter; 141 G4UIparameter* parameter; 142 parameter = new G4UIparameter("plotter",'s', 142 parameter = new G4UIparameter("plotter",'s',false); 143 fpCommand->SetParameter (parameter); 143 fpCommand->SetParameter (parameter); 144 144 145 parameter = new G4UIparameter("region",'i',f 145 parameter = new G4UIparameter("region",'i',false); 146 //parameter->SetDefaultValue(0); 146 //parameter->SetDefaultValue(0); 147 fpCommand->SetParameter (parameter); 147 fpCommand->SetParameter (parameter); 148 148 149 parameter = new G4UIparameter("style",'s',tr 149 parameter = new G4UIparameter("style",'s',true); 150 parameter->SetDefaultValue("default"); 150 parameter->SetDefaultValue("default"); 151 fpCommand->SetParameter (parameter); 151 fpCommand->SetParameter (parameter); 152 } 152 } 153 153 154 G4VisCommandPlotterAddRegionStyle::~G4VisComma 154 G4VisCommandPlotterAddRegionStyle::~G4VisCommandPlotterAddRegionStyle () {delete fpCommand;} 155 155 156 void G4VisCommandPlotterAddRegionStyle::SetNew 156 void G4VisCommandPlotterAddRegionStyle::SetNewValue (G4UIcommand*, G4String newValue) 157 { 157 { 158 G4VisManager::Verbosity verbosity = fpVisMan 158 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 159 159 160 G4String plotter; 160 G4String plotter; 161 int region; 161 int region; 162 G4String style; 162 G4String style; 163 std::istringstream is(newValue); 163 std::istringstream is(newValue); 164 is >> plotter >> region >> style; 164 is >> plotter >> region >> style; 165 if(region<0) { 165 if(region<0) { 166 if (verbosity >= G4VisManager::errors) { 166 if (verbosity >= G4VisManager::errors) { 167 G4warn << "ERROR: bad region index " << 167 G4warn << "ERROR: bad region index " << region << "." << G4endl; 168 } 168 } 169 return; 169 return; 170 } 170 } 171 171 172 G4Plotter& _plotter = G4PlotterManager::GetI 172 G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter); 173 _plotter.AddRegionStyle(region,style); 173 _plotter.AddRegionStyle(region,style); 174 174 175 G4Scene* pScene = fpVisManager->GetCurrentSc 175 G4Scene* pScene = fpVisManager->GetCurrentScene(); 176 if(pScene) CheckSceneAndNotifyHandlers (pSce 176 if(pScene) CheckSceneAndNotifyHandlers (pScene); 177 } 177 } 178 178 179 ////////////////////////////////////////////// 179 ///////////////////////////////////////////////////////////////////////////// 180 ////////////// /vis/plotter/addRegionParameter 180 ////////////// /vis/plotter/addRegionParameter ////////////////////////////// 181 ////////////////////////////////////////////// 181 ///////////////////////////////////////////////////////////////////////////// 182 G4VisCommandPlotterAddRegionParameter::G4VisCo 182 G4VisCommandPlotterAddRegionParameter::G4VisCommandPlotterAddRegionParameter () { 183 fpCommand = new G4UIcommand("/vis/plotter/ad 183 fpCommand = new G4UIcommand("/vis/plotter/addRegionParameter", this); 184 fpCommand->SetGuidance("Add a parameter to b 184 fpCommand->SetGuidance("Add a parameter to be set on a region."); 185 185 186 G4UIparameter* parameter; 186 G4UIparameter* parameter; 187 parameter = new G4UIparameter("plotter",'s', 187 parameter = new G4UIparameter("plotter",'s',false); 188 fpCommand->SetParameter (parameter); 188 fpCommand->SetParameter (parameter); 189 189 190 parameter = new G4UIparameter("region",'i',f 190 parameter = new G4UIparameter("region",'i',false); 191 fpCommand->SetParameter (parameter); 191 fpCommand->SetParameter (parameter); 192 192 193 parameter = new G4UIparameter("parameter",'s 193 parameter = new G4UIparameter("parameter",'s',false); 194 fpCommand->SetParameter (parameter); 194 fpCommand->SetParameter (parameter); 195 195 196 parameter = new G4UIparameter("value",'s',fa 196 parameter = new G4UIparameter("value",'s',false); 197 fpCommand->SetParameter (parameter); 197 fpCommand->SetParameter (parameter); 198 } 198 } 199 199 200 G4VisCommandPlotterAddRegionParameter::~G4VisC 200 G4VisCommandPlotterAddRegionParameter::~G4VisCommandPlotterAddRegionParameter () {delete fpCommand;} 201 201 202 void G4VisCommandPlotterAddRegionParameter::Se 202 void G4VisCommandPlotterAddRegionParameter::SetNewValue (G4UIcommand* command, G4String newValue) 203 { 203 { 204 G4VisManager::Verbosity verbosity = fpVisMan 204 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 205 205 206 std::vector<std::string> args; 206 std::vector<std::string> args; 207 tools::double_quotes_tokenize(newValue, args 207 tools::double_quotes_tokenize(newValue, args); 208 if ( args.size() != command->GetParameterEnt 208 if ( args.size() != command->GetParameterEntries() ) { // check consistency. 209 if (verbosity >= G4VisManager::errors) { 209 if (verbosity >= G4VisManager::errors) { 210 G4warn << "ERROR: tokenize value problem 210 G4warn << "ERROR: tokenize value problem." << G4endl; 211 } 211 } 212 return; 212 return; 213 } 213 } 214 214 215 std::string plotter = args[0]; 215 std::string plotter = args[0]; 216 int region = G4UIcommand::ConvertToInt(args[ 216 int region = G4UIcommand::ConvertToInt(args[1].c_str()); 217 std::string parameter = args[2]; 217 std::string parameter = args[2]; 218 std::string value = args[3]; 218 std::string value = args[3]; 219 if(region<0) { 219 if(region<0) { 220 if (verbosity >= G4VisManager::errors) { 220 if (verbosity >= G4VisManager::errors) { 221 G4warn << "ERROR: bad region index " << 221 G4warn << "ERROR: bad region index " << region << "." << G4endl; 222 } 222 } 223 return; 223 return; 224 } 224 } 225 225 226 G4Plotter& _plotter = G4PlotterManager::GetI 226 G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter); 227 _plotter.AddRegionParameter(region,parameter 227 _plotter.AddRegionParameter(region,parameter,value); 228 228 229 G4Scene* pScene = fpVisManager->GetCurrentSc 229 G4Scene* pScene = fpVisManager->GetCurrentScene(); 230 if(pScene) CheckSceneAndNotifyHandlers (pSce 230 if(pScene) CheckSceneAndNotifyHandlers (pScene); 231 } 231 } 232 232 233 ////////////////////////////////////////////// 233 ///////////////////////////////////////////////////////////////////////////// 234 ////////////// /vis/plotter/clear //////////// 234 ////////////// /vis/plotter/clear /////////////////////////////////////////// 235 ////////////////////////////////////////////// 235 ///////////////////////////////////////////////////////////////////////////// 236 G4VisCommandPlotterClear::G4VisCommandPlotterC 236 G4VisCommandPlotterClear::G4VisCommandPlotterClear () { 237 fpCommand = new G4UIcommand("/vis/plotter/cl 237 fpCommand = new G4UIcommand("/vis/plotter/clear", this); 238 fpCommand->SetGuidance("Remove plottables fr 238 fpCommand->SetGuidance("Remove plottables from all regions."); 239 239 240 G4UIparameter* parameter; 240 G4UIparameter* parameter; 241 parameter = new G4UIparameter("plotter",'s', 241 parameter = new G4UIparameter("plotter",'s',false); 242 fpCommand->SetParameter (parameter); 242 fpCommand->SetParameter (parameter); 243 } 243 } 244 244 245 G4VisCommandPlotterClear::~G4VisCommandPlotter 245 G4VisCommandPlotterClear::~G4VisCommandPlotterClear () {delete fpCommand;} 246 246 247 void G4VisCommandPlotterClear::SetNewValue (G4 247 void G4VisCommandPlotterClear::SetNewValue (G4UIcommand*, G4String newValue) 248 { 248 { 249 G4Plotter& _plotter = G4PlotterManager::GetI 249 G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(newValue); 250 _plotter.Clear(); 250 _plotter.Clear(); 251 251 252 G4Scene* pScene = fpVisManager->GetCurrentSc 252 G4Scene* pScene = fpVisManager->GetCurrentScene(); 253 if(pScene) CheckSceneAndNotifyHandlers (pSce 253 if(pScene) CheckSceneAndNotifyHandlers (pScene); 254 } 254 } 255 255 256 ////////////////////////////////////////////// 256 ///////////////////////////////////////////////////////////////////////////// 257 ////////////// /vis/plotter/clearRegion ////// 257 ////////////// /vis/plotter/clearRegion ///////////////////////////////////// 258 ////////////////////////////////////////////// 258 ///////////////////////////////////////////////////////////////////////////// 259 G4VisCommandPlotterClearRegion::G4VisCommandPl 259 G4VisCommandPlotterClearRegion::G4VisCommandPlotterClearRegion () { 260 fpCommand = new G4UIcommand("/vis/plotter/cl 260 fpCommand = new G4UIcommand("/vis/plotter/clearRegion", this); 261 fpCommand->SetGuidance("Remove plottables a 261 fpCommand->SetGuidance("Remove plottables a region."); 262 262 263 G4UIparameter* parameter; 263 G4UIparameter* parameter; 264 parameter = new G4UIparameter("plotter",'s', 264 parameter = new G4UIparameter("plotter",'s',false); 265 fpCommand->SetParameter (parameter); 265 fpCommand->SetParameter (parameter); 266 266 267 parameter = new G4UIparameter("region",'i',f 267 parameter = new G4UIparameter("region",'i',false); 268 //parameter->SetDefaultValue(0); 268 //parameter->SetDefaultValue(0); 269 fpCommand->SetParameter (parameter); 269 fpCommand->SetParameter (parameter); 270 } 270 } 271 271 272 G4VisCommandPlotterClearRegion::~G4VisCommandP 272 G4VisCommandPlotterClearRegion::~G4VisCommandPlotterClearRegion () {delete fpCommand;} 273 273 274 void G4VisCommandPlotterClearRegion::SetNewVal 274 void G4VisCommandPlotterClearRegion::SetNewValue (G4UIcommand*, G4String newValue) 275 { 275 { 276 G4VisManager::Verbosity verbosity = fpVisMan 276 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 277 277 278 G4String plotter; 278 G4String plotter; 279 int region; 279 int region; 280 std::istringstream is(newValue); 280 std::istringstream is(newValue); 281 is >> plotter >> region; 281 is >> plotter >> region; 282 if(region<0) { 282 if(region<0) { 283 if (verbosity >= G4VisManager::errors) { 283 if (verbosity >= G4VisManager::errors) { 284 G4warn << "ERROR: bad region index " << 284 G4warn << "ERROR: bad region index " << region << "." << G4endl; 285 } 285 } 286 return; 286 return; 287 } 287 } 288 288 289 G4Plotter& _plotter = G4PlotterManager::GetI 289 G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter); 290 _plotter.ClearRegion(region); 290 _plotter.ClearRegion(region); 291 291 292 G4Scene* pScene = fpVisManager->GetCurrentSc 292 G4Scene* pScene = fpVisManager->GetCurrentScene(); 293 if(pScene) CheckSceneAndNotifyHandlers (pSce 293 if(pScene) CheckSceneAndNotifyHandlers (pScene); 294 } 294 } 295 295 296 ////////////////////////////////////////////// 296 ///////////////////////////////////////////////////////////////////////////// 297 ////////////// /vis/plotter/list ///////////// 297 ////////////// /vis/plotter/list //////////////////////////////////////////// 298 ////////////////////////////////////////////// 298 ///////////////////////////////////////////////////////////////////////////// 299 G4VisCommandPlotterList::G4VisCommandPlotterLi 299 G4VisCommandPlotterList::G4VisCommandPlotterList () { 300 fpCommand = new G4UIcommand("/vis/plotter/li 300 fpCommand = new G4UIcommand("/vis/plotter/list", this); 301 fpCommand->SetGuidance("List plotters in the 301 fpCommand->SetGuidance("List plotters in the scene."); 302 } 302 } 303 303 304 G4VisCommandPlotterList::~G4VisCommandPlotterL 304 G4VisCommandPlotterList::~G4VisCommandPlotterList () {delete fpCommand;} 305 305 306 void G4VisCommandPlotterList::SetNewValue (G4U 306 void G4VisCommandPlotterList::SetNewValue (G4UIcommand*, G4String) 307 { 307 { 308 G4PlotterManager::GetInstance().List(); 308 G4PlotterManager::GetInstance().List(); 309 } 309 } 310 310 311 ////////////////////////////////////////////// 311 ///////////////////////////////////////////////////////////////////////////// 312 ////////////// /vis/plotter/add/h1 /////////// 312 ////////////// /vis/plotter/add/h1 ////////////////////////////////////////// 313 ////////////////////////////////////////////// 313 ///////////////////////////////////////////////////////////////////////////// 314 G4VisCommandPlotterAddRegionH1::G4VisCommandPl 314 G4VisCommandPlotterAddRegionH1::G4VisCommandPlotterAddRegionH1 () { 315 fpCommand = new G4UIcommand("/vis/plotter/ad 315 fpCommand = new G4UIcommand("/vis/plotter/add/h1", this); 316 fpCommand->SetGuidance("Attach a 1D histogra 316 fpCommand->SetGuidance("Attach a 1D histogram to a plotter region."); 317 317 318 G4UIparameter* parameter; 318 G4UIparameter* parameter; 319 parameter = new G4UIparameter("histo",'i',fa 319 parameter = new G4UIparameter("histo",'i',false); 320 fpCommand->SetParameter (parameter); 320 fpCommand->SetParameter (parameter); 321 321 322 parameter = new G4UIparameter("plotter",'s', 322 parameter = new G4UIparameter("plotter",'s',false); 323 fpCommand->SetParameter (parameter); 323 fpCommand->SetParameter (parameter); 324 324 325 parameter = new G4UIparameter("region",'i',t 325 parameter = new G4UIparameter("region",'i',true); 326 parameter->SetDefaultValue(0); 326 parameter->SetDefaultValue(0); 327 fpCommand->SetParameter (parameter); 327 fpCommand->SetParameter (parameter); 328 } 328 } 329 329 330 G4VisCommandPlotterAddRegionH1::~G4VisCommandP 330 G4VisCommandPlotterAddRegionH1::~G4VisCommandPlotterAddRegionH1 () {delete fpCommand;} 331 331 332 void G4VisCommandPlotterAddRegionH1::SetNewVal 332 void G4VisCommandPlotterAddRegionH1::SetNewValue (G4UIcommand*, G4String newValue) 333 { 333 { 334 G4VisManager::Verbosity verbosity = fpVisMan 334 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 335 335 336 int hid; 336 int hid; 337 G4String plotter; 337 G4String plotter; 338 int region; 338 int region; 339 std::istringstream is(newValue); 339 std::istringstream is(newValue); 340 is >> hid >> plotter >> region; 340 is >> hid >> plotter >> region; 341 341 342 if(region<0) { 342 if(region<0) { 343 if (verbosity >= G4VisManager::errors) { 343 if (verbosity >= G4VisManager::errors) { 344 G4warn << "ERROR: bad region index " << 344 G4warn << "ERROR: bad region index " << region << "." << G4endl; 345 } 345 } 346 return; 346 return; 347 } 347 } 348 348 349 G4Plotter& _plotter = G4PlotterManager::GetI 349 G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter); 350 _plotter.AddRegionH1(region,hid); 350 _plotter.AddRegionH1(region,hid); 351 351 352 G4Scene* pScene = fpVisManager->GetCurrentSc 352 G4Scene* pScene = fpVisManager->GetCurrentScene(); 353 if(pScene) CheckSceneAndNotifyHandlers (pSce 353 if(pScene) CheckSceneAndNotifyHandlers (pScene); 354 } 354 } 355 355 356 ////////////////////////////////////////////// 356 ///////////////////////////////////////////////////////////////////////////// 357 ////////////// /vis/plotter/add/h2 /////////// 357 ////////////// /vis/plotter/add/h2 ////////////////////////////////////////// 358 ////////////////////////////////////////////// 358 ///////////////////////////////////////////////////////////////////////////// 359 G4VisCommandPlotterAddRegionH2::G4VisCommandPl 359 G4VisCommandPlotterAddRegionH2::G4VisCommandPlotterAddRegionH2 () { 360 fpCommand = new G4UIcommand("/vis/plotter/ad 360 fpCommand = new G4UIcommand("/vis/plotter/add/h2", this); 361 fpCommand->SetGuidance("Attach a 2D histogra 361 fpCommand->SetGuidance("Attach a 2D histogram to a plotter region."); 362 362 363 G4UIparameter* parameter; 363 G4UIparameter* parameter; 364 parameter = new G4UIparameter("histo",'i',fa 364 parameter = new G4UIparameter("histo",'i',false); 365 fpCommand->SetParameter (parameter); 365 fpCommand->SetParameter (parameter); 366 366 367 parameter = new G4UIparameter("plotter",'s', 367 parameter = new G4UIparameter("plotter",'s',false); 368 fpCommand->SetParameter (parameter); 368 fpCommand->SetParameter (parameter); 369 369 370 parameter = new G4UIparameter("region",'i',t 370 parameter = new G4UIparameter("region",'i',true); 371 parameter->SetDefaultValue(0); 371 parameter->SetDefaultValue(0); 372 fpCommand->SetParameter (parameter); 372 fpCommand->SetParameter (parameter); 373 } 373 } 374 374 375 G4VisCommandPlotterAddRegionH2::~G4VisCommandP 375 G4VisCommandPlotterAddRegionH2::~G4VisCommandPlotterAddRegionH2 () {delete fpCommand;} 376 376 377 void G4VisCommandPlotterAddRegionH2::SetNewVal 377 void G4VisCommandPlotterAddRegionH2::SetNewValue (G4UIcommand*, G4String newValue) 378 { 378 { 379 G4VisManager::Verbosity verbosity = fpVisMan 379 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 380 380 381 int hid; 381 int hid; 382 G4String plotter; 382 G4String plotter; 383 int region; 383 int region; 384 std::istringstream is(newValue); 384 std::istringstream is(newValue); 385 is >> hid >> plotter >> region; 385 is >> hid >> plotter >> region; 386 386 387 if(region<0) { 387 if(region<0) { 388 if (verbosity >= G4VisManager::errors) { 388 if (verbosity >= G4VisManager::errors) { 389 G4warn << "ERROR: bad region index " << 389 G4warn << "ERROR: bad region index " << region << "." << G4endl; 390 } 390 } 391 return; 391 return; 392 } 392 } 393 393 394 G4Plotter& _plotter = G4PlotterManager::GetI 394 G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter); 395 _plotter.AddRegionH2(region,hid); 395 _plotter.AddRegionH2(region,hid); 396 396 397 G4Scene* pScene = fpVisManager->GetCurrentSc 397 G4Scene* pScene = fpVisManager->GetCurrentScene(); 398 if(pScene) CheckSceneAndNotifyHandlers (pSce 398 if(pScene) CheckSceneAndNotifyHandlers (pScene); 399 } 399 } 400 400 401 401