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 // 27 // /vis/plotter commands - Guy Barrand October 28 29 #include "G4VisCommandsPlotter.hh" 30 31 #include "G4PlotterManager.hh" 32 33 #include <tools/tokenize> 34 35 #include <sstream> 36 37 #define G4warn G4cout 38 39 ////////////////////////////////////////////// 40 ////////////// /vis/plotter/create /////////// 41 ////////////////////////////////////////////// 42 G4VisCommandPlotterCreate::G4VisCommandPlotter 43 fpCommand = new G4UIcommand("/vis/plotter/cr 44 fpCommand->SetGuidance("Create a named G4Plo 45 46 G4UIparameter* parameter; 47 parameter = new G4UIparameter("name",'s',fal 48 fpCommand->SetParameter (parameter); 49 } 50 51 G4VisCommandPlotterCreate::~G4VisCommandPlotte 52 53 void G4VisCommandPlotterCreate::SetNewValue (G 54 { 55 G4Plotter& _plotter = G4PlotterManager::GetI 56 _plotter.Reset(); 57 G4Scene* pScene = fpVisManager->GetCurrentSc 58 if(pScene) CheckSceneAndNotifyHandlers (pSce 59 } 60 61 ////////////////////////////////////////////// 62 ////////////// /vis/plotter/setLayout //////// 63 ////////////////////////////////////////////// 64 G4VisCommandPlotterSetLayout::G4VisCommandPlot 65 fpCommand = new G4UIcommand("/vis/plotter/se 66 fpCommand->SetGuidance("Set plotter grid lay 67 68 G4UIparameter* parameter; 69 parameter = new G4UIparameter("plotter",'s', 70 fpCommand->SetParameter (parameter); 71 72 parameter = new G4UIparameter("columns",'i', 73 parameter->SetDefaultValue(1); 74 fpCommand->SetParameter (parameter); 75 76 parameter = new G4UIparameter("rows",'i',tru 77 parameter->SetDefaultValue(1); 78 fpCommand->SetParameter (parameter); 79 } 80 81 G4VisCommandPlotterSetLayout::~G4VisCommandPlo 82 83 void G4VisCommandPlotterSetLayout::SetNewValue 84 { 85 G4String plotter; 86 G4int cols,rows; 87 std::istringstream is(newValue); 88 is >> plotter >> cols >> rows; 89 90 G4Plotter& _plotter = G4PlotterManager::GetI 91 _plotter.SetLayout(cols,rows); 92 93 G4Scene* pScene = fpVisManager->GetCurrentSc 94 if(pScene) CheckSceneAndNotifyHandlers (pSce 95 } 96 97 ////////////////////////////////////////////// 98 ////////////// /vis/plotter/addStyle ///////// 99 ////////////////////////////////////////////// 100 G4VisCommandPlotterAddStyle::G4VisCommandPlott 101 fpCommand = new G4UIcommand("/vis/plotter/ad 102 fpCommand->SetGuidance("Add a style for a pl 103 fpCommand->SetGuidance("It is applied on all 104 fpCommand->SetGuidance("default, ROOT_defaul 105 fpCommand->SetGuidance("reset is a keyword u 106 107 G4UIparameter* parameter; 108 parameter = new G4UIparameter("plotter",'s', 109 fpCommand->SetParameter (parameter); 110 111 parameter = new G4UIparameter("style",'s',tr 112 parameter->SetDefaultValue("default"); 113 fpCommand->SetParameter (parameter); 114 } 115 116 G4VisCommandPlotterAddStyle::~G4VisCommandPlot 117 118 void G4VisCommandPlotterAddStyle::SetNewValue 119 { 120 G4String plotter; 121 G4String style; 122 std::istringstream is(newValue); 123 is >> plotter >> style; 124 125 G4Plotter& _plotter = G4PlotterManager::GetI 126 _plotter.AddStyle(style); 127 128 G4Scene* pScene = fpVisManager->GetCurrentSc 129 if(pScene) CheckSceneAndNotifyHandlers (pSce 130 } 131 132 ////////////////////////////////////////////// 133 ////////////// /vis/plotter/addRegionStyle /// 134 ////////////////////////////////////////////// 135 G4VisCommandPlotterAddRegionStyle::G4VisComman 136 fpCommand = new G4UIcommand("/vis/plotter/ad 137 fpCommand->SetGuidance("Add a style to be ap 138 fpCommand->SetGuidance("default, ROOT_defaul 139 fpCommand->SetGuidance("reset is a keyword u 140 141 G4UIparameter* parameter; 142 parameter = new G4UIparameter("plotter",'s', 143 fpCommand->SetParameter (parameter); 144 145 parameter = new G4UIparameter("region",'i',f 146 //parameter->SetDefaultValue(0); 147 fpCommand->SetParameter (parameter); 148 149 parameter = new G4UIparameter("style",'s',tr 150 parameter->SetDefaultValue("default"); 151 fpCommand->SetParameter (parameter); 152 } 153 154 G4VisCommandPlotterAddRegionStyle::~G4VisComma 155 156 void G4VisCommandPlotterAddRegionStyle::SetNew 157 { 158 G4VisManager::Verbosity verbosity = fpVisMan 159 160 G4String plotter; 161 int region; 162 G4String style; 163 std::istringstream is(newValue); 164 is >> plotter >> region >> style; 165 if(region<0) { 166 if (verbosity >= G4VisManager::errors) { 167 G4warn << "ERROR: bad region index " << 168 } 169 return; 170 } 171 172 G4Plotter& _plotter = G4PlotterManager::GetI 173 _plotter.AddRegionStyle(region,style); 174 175 G4Scene* pScene = fpVisManager->GetCurrentSc 176 if(pScene) CheckSceneAndNotifyHandlers (pSce 177 } 178 179 ////////////////////////////////////////////// 180 ////////////// /vis/plotter/addRegionParameter 181 ////////////////////////////////////////////// 182 G4VisCommandPlotterAddRegionParameter::G4VisCo 183 fpCommand = new G4UIcommand("/vis/plotter/ad 184 fpCommand->SetGuidance("Add a parameter to b 185 186 G4UIparameter* parameter; 187 parameter = new G4UIparameter("plotter",'s', 188 fpCommand->SetParameter (parameter); 189 190 parameter = new G4UIparameter("region",'i',f 191 fpCommand->SetParameter (parameter); 192 193 parameter = new G4UIparameter("parameter",'s 194 fpCommand->SetParameter (parameter); 195 196 parameter = new G4UIparameter("value",'s',fa 197 fpCommand->SetParameter (parameter); 198 } 199 200 G4VisCommandPlotterAddRegionParameter::~G4VisC 201 202 void G4VisCommandPlotterAddRegionParameter::Se 203 { 204 G4VisManager::Verbosity verbosity = fpVisMan 205 206 std::vector<std::string> args; 207 tools::double_quotes_tokenize(newValue, args 208 if ( args.size() != command->GetParameterEnt 209 if (verbosity >= G4VisManager::errors) { 210 G4warn << "ERROR: tokenize value problem 211 } 212 return; 213 } 214 215 std::string plotter = args[0]; 216 int region = G4UIcommand::ConvertToInt(args[ 217 std::string parameter = args[2]; 218 std::string value = args[3]; 219 if(region<0) { 220 if (verbosity >= G4VisManager::errors) { 221 G4warn << "ERROR: bad region index " << 222 } 223 return; 224 } 225 226 G4Plotter& _plotter = G4PlotterManager::GetI 227 _plotter.AddRegionParameter(region,parameter 228 229 G4Scene* pScene = fpVisManager->GetCurrentSc 230 if(pScene) CheckSceneAndNotifyHandlers (pSce 231 } 232 233 ////////////////////////////////////////////// 234 ////////////// /vis/plotter/clear //////////// 235 ////////////////////////////////////////////// 236 G4VisCommandPlotterClear::G4VisCommandPlotterC 237 fpCommand = new G4UIcommand("/vis/plotter/cl 238 fpCommand->SetGuidance("Remove plottables fr 239 240 G4UIparameter* parameter; 241 parameter = new G4UIparameter("plotter",'s', 242 fpCommand->SetParameter (parameter); 243 } 244 245 G4VisCommandPlotterClear::~G4VisCommandPlotter 246 247 void G4VisCommandPlotterClear::SetNewValue (G4 248 { 249 G4Plotter& _plotter = G4PlotterManager::GetI 250 _plotter.Clear(); 251 252 G4Scene* pScene = fpVisManager->GetCurrentSc 253 if(pScene) CheckSceneAndNotifyHandlers (pSce 254 } 255 256 ////////////////////////////////////////////// 257 ////////////// /vis/plotter/clearRegion ////// 258 ////////////////////////////////////////////// 259 G4VisCommandPlotterClearRegion::G4VisCommandPl 260 fpCommand = new G4UIcommand("/vis/plotter/cl 261 fpCommand->SetGuidance("Remove plottables a 262 263 G4UIparameter* parameter; 264 parameter = new G4UIparameter("plotter",'s', 265 fpCommand->SetParameter (parameter); 266 267 parameter = new G4UIparameter("region",'i',f 268 //parameter->SetDefaultValue(0); 269 fpCommand->SetParameter (parameter); 270 } 271 272 G4VisCommandPlotterClearRegion::~G4VisCommandP 273 274 void G4VisCommandPlotterClearRegion::SetNewVal 275 { 276 G4VisManager::Verbosity verbosity = fpVisMan 277 278 G4String plotter; 279 int region; 280 std::istringstream is(newValue); 281 is >> plotter >> region; 282 if(region<0) { 283 if (verbosity >= G4VisManager::errors) { 284 G4warn << "ERROR: bad region index " << 285 } 286 return; 287 } 288 289 G4Plotter& _plotter = G4PlotterManager::GetI 290 _plotter.ClearRegion(region); 291 292 G4Scene* pScene = fpVisManager->GetCurrentSc 293 if(pScene) CheckSceneAndNotifyHandlers (pSce 294 } 295 296 ////////////////////////////////////////////// 297 ////////////// /vis/plotter/list ///////////// 298 ////////////////////////////////////////////// 299 G4VisCommandPlotterList::G4VisCommandPlotterLi 300 fpCommand = new G4UIcommand("/vis/plotter/li 301 fpCommand->SetGuidance("List plotters in the 302 } 303 304 G4VisCommandPlotterList::~G4VisCommandPlotterL 305 306 void G4VisCommandPlotterList::SetNewValue (G4U 307 { 308 G4PlotterManager::GetInstance().List(); 309 } 310 311 ////////////////////////////////////////////// 312 ////////////// /vis/plotter/add/h1 /////////// 313 ////////////////////////////////////////////// 314 G4VisCommandPlotterAddRegionH1::G4VisCommandPl 315 fpCommand = new G4UIcommand("/vis/plotter/ad 316 fpCommand->SetGuidance("Attach a 1D histogra 317 318 G4UIparameter* parameter; 319 parameter = new G4UIparameter("histo",'i',fa 320 fpCommand->SetParameter (parameter); 321 322 parameter = new G4UIparameter("plotter",'s', 323 fpCommand->SetParameter (parameter); 324 325 parameter = new G4UIparameter("region",'i',t 326 parameter->SetDefaultValue(0); 327 fpCommand->SetParameter (parameter); 328 } 329 330 G4VisCommandPlotterAddRegionH1::~G4VisCommandP 331 332 void G4VisCommandPlotterAddRegionH1::SetNewVal 333 { 334 G4VisManager::Verbosity verbosity = fpVisMan 335 336 int hid; 337 G4String plotter; 338 int region; 339 std::istringstream is(newValue); 340 is >> hid >> plotter >> region; 341 342 if(region<0) { 343 if (verbosity >= G4VisManager::errors) { 344 G4warn << "ERROR: bad region index " << 345 } 346 return; 347 } 348 349 G4Plotter& _plotter = G4PlotterManager::GetI 350 _plotter.AddRegionH1(region,hid); 351 352 G4Scene* pScene = fpVisManager->GetCurrentSc 353 if(pScene) CheckSceneAndNotifyHandlers (pSce 354 } 355 356 ////////////////////////////////////////////// 357 ////////////// /vis/plotter/add/h2 /////////// 358 ////////////////////////////////////////////// 359 G4VisCommandPlotterAddRegionH2::G4VisCommandPl 360 fpCommand = new G4UIcommand("/vis/plotter/ad 361 fpCommand->SetGuidance("Attach a 2D histogra 362 363 G4UIparameter* parameter; 364 parameter = new G4UIparameter("histo",'i',fa 365 fpCommand->SetParameter (parameter); 366 367 parameter = new G4UIparameter("plotter",'s', 368 fpCommand->SetParameter (parameter); 369 370 parameter = new G4UIparameter("region",'i',t 371 parameter->SetDefaultValue(0); 372 fpCommand->SetParameter (parameter); 373 } 374 375 G4VisCommandPlotterAddRegionH2::~G4VisCommandP 376 377 void G4VisCommandPlotterAddRegionH2::SetNewVal 378 { 379 G4VisManager::Verbosity verbosity = fpVisMan 380 381 int hid; 382 G4String plotter; 383 int region; 384 std::istringstream is(newValue); 385 is >> hid >> plotter >> region; 386 387 if(region<0) { 388 if (verbosity >= G4VisManager::errors) { 389 G4warn << "ERROR: bad region index " << 390 } 391 return; 392 } 393 394 G4Plotter& _plotter = G4PlotterManager::GetI 395 _plotter.AddRegionH2(region,hid); 396 397 G4Scene* pScene = fpVisManager->GetCurrentSc 398 if(pScene) CheckSceneAndNotifyHandlers (pSce 399 } 400 401