Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 // Generic model messenges. 28 // 29 // Jane Tinslay March 2006 30 // 31 #ifndef G4MODELCOMMANDST_HH 32 #define G4MODELCOMMANDST_HH 33 34 #include "G4ModelApplyCommandsT.hh" 35 #include "G4Polymarker.hh" 36 #include "G4UIdirectory.hh" 37 #include <sstream> 38 39 //////////////////////////////////////////////////////////////////////// 40 // Set parameter colour 41 template <typename M> 42 class G4ModelCmdSetStringColour : public G4ModelCmdApplyStringColour<M> { 43 44 public: // With description 45 46 G4ModelCmdSetStringColour(M* model, const G4String& placement, 47 const G4String& cmdName="set") 48 :G4ModelCmdApplyStringColour<M>(model, placement, cmdName) {} 49 50 virtual ~G4ModelCmdSetStringColour() {} 51 52 protected: 53 54 virtual void Apply(const G4String& param, const G4Colour& colour) { 55 G4VModelCommand<M>::Model()->Set(param, colour); 56 } 57 58 }; 59 60 //////////////////////////////////////////////////////////////////////// 61 // Set default colour 62 template <typename M> 63 class G4ModelCmdSetDefaultColour : public G4ModelCmdApplyColour<M> { 64 65 public: // With description 66 67 G4ModelCmdSetDefaultColour(M* model, const G4String& placement, 68 const G4String& cmdName="setDefault") 69 :G4ModelCmdApplyColour<M>(model, placement, cmdName) {} 70 71 virtual ~G4ModelCmdSetDefaultColour() {} 72 73 protected: 74 75 virtual void Apply(const G4Colour& colour) { 76 G4VModelCommand<M>::Model()->SetDefault(colour); 77 } 78 79 }; 80 81 //////////////////////////////////////////////////////////////////////// 82 // Add string command 83 template <typename M> 84 class G4ModelCmdAddString : public G4ModelCmdApplyString<M> { 85 86 public: // With description 87 88 G4ModelCmdAddString(M* model, const G4String& placement, 89 const G4String& cmdName="add") 90 :G4ModelCmdApplyString<M>(model, placement, cmdName) 91 { 92 G4ModelCmdApplyString<M>::Command()->SetGuidance("Add command"); 93 } 94 95 virtual ~G4ModelCmdAddString() {} 96 97 protected: 98 99 virtual void Apply(const G4String& newValue) { 100 G4VModelCommand<M>::Model()->Add(newValue); 101 } 102 103 }; 104 105 //////////////////////////////////////////////////////////////////////// 106 //Add integer command 107 template <typename M> 108 class G4ModelCmdAddInt : public G4ModelCmdApplyInteger<M> { 109 110 public: // With description 111 112 G4ModelCmdAddInt(M* model, const G4String& placement, 113 const G4String& cmdName="add") 114 :G4ModelCmdApplyInteger<M>(model, placement, cmdName) 115 { 116 G4ModelCmdApplyInteger<M>::Command()->SetGuidance("Add command"); 117 } 118 119 virtual ~G4ModelCmdAddInt() {} 120 121 protected: 122 123 virtual void Apply(const G4int& newValue) { 124 G4VModelCommand<M>::Model()->Add(newValue); 125 } 126 127 }; 128 129 //////////////////////////////////////////////////////////////////////// 130 // Invert command 131 template <typename M> 132 class G4ModelCmdInvert : public G4ModelCmdApplyBool<M> { 133 134 public: // With description 135 136 G4ModelCmdInvert(M* model, const G4String& placement, 137 const G4String& cmdName="invert") 138 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 139 { 140 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Invert command"); 141 } 142 143 virtual ~G4ModelCmdInvert() {} 144 145 protected: 146 147 virtual void Apply(const G4bool& newValue) { 148 G4VModelCommand<M>::Model()->SetInvert(newValue); 149 } 150 151 }; 152 153 //////////////////////////////////////////////////////////////////////// 154 // Active command 155 template <typename M> 156 class G4ModelCmdActive : public G4ModelCmdApplyBool<M> { 157 158 public: // With description 159 160 G4ModelCmdActive(M* model, const G4String& placement, 161 const G4String& cmdName="active") 162 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 163 { 164 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Active command"); 165 } 166 167 virtual ~G4ModelCmdActive() {} 168 169 protected: 170 171 virtual void Apply(const G4bool& newValue) { 172 G4VModelCommand<M>::Model()->SetActive(newValue); 173 } 174 175 }; 176 177 //////////////////////////////////////////////////////////////////////// 178 // Verbose command 179 template <typename M> 180 class G4ModelCmdVerbose : public G4ModelCmdApplyBool<M> { 181 182 public: // With description 183 184 G4ModelCmdVerbose(M* model, const G4String& placement, 185 const G4String& cmdName="verbose") 186 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 187 { 188 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Verbose command"); 189 } 190 191 virtual ~G4ModelCmdVerbose() {} 192 193 protected: 194 195 virtual void Apply(const G4bool& newValue) { 196 G4VModelCommand<M>::Model()->SetVerbose(newValue); 197 } 198 199 }; 200 201 //////////////////////////////////////////////////////////////////////// 202 // Reset command 203 template <typename M> 204 class G4ModelCmdReset : public G4ModelCmdApplyNull<M> { 205 206 public: // With description 207 208 G4ModelCmdReset(M* model, const G4String& placement, 209 const G4String& cmdName="reset") 210 :G4ModelCmdApplyNull<M>(model, placement, cmdName) 211 { 212 G4ModelCmdApplyNull<M>::Command()->SetGuidance("Reset command"); 213 } 214 215 virtual ~G4ModelCmdReset() {} 216 217 protected: 218 219 virtual void Apply() { 220 G4VModelCommand<M>::Model()->Reset(); 221 } 222 223 }; 224 225 //////////////////////////////////////////////////////////////////////// 226 // Set auxiliary points colour command 227 template <typename M> 228 class G4ModelCmdSetAuxPtsColour : public G4ModelCmdApplyColour<M> { 229 230 public: 231 232 G4ModelCmdSetAuxPtsColour(M* model, const G4String& placement, 233 const G4String& cmdName="setAuxPtsColour") 234 :G4ModelCmdApplyColour<M>(model, placement, cmdName) {} 235 236 protected: 237 238 void Apply(const G4Colour& colour) { 239 G4VModelCommand<M>::Model()->SetAuxPtsColour(colour); 240 } 241 242 }; 243 244 //////////////////////////////////////////////////////////////////////// 245 // Set set points colour command 246 template <typename M> 247 class G4ModelCmdSetStepPtsColour : public G4ModelCmdApplyColour<M> { 248 249 public: 250 251 G4ModelCmdSetStepPtsColour(M* model, const G4String& placement, 252 const G4String& cmdName="setStepPtsColour") 253 :G4ModelCmdApplyColour<M>(model, placement, cmdName) {} 254 255 protected: 256 257 void Apply(const G4Colour& colour) { 258 G4VModelCommand<M>::Model()->SetStepPtsColour(colour); 259 } 260 261 }; 262 263 //////////////////////////////////////////////////////////////////////// 264 // Set draw line command 265 template <typename M> 266 class G4ModelCmdSetDrawLine : public G4ModelCmdApplyBool<M> { 267 268 public: 269 270 G4ModelCmdSetDrawLine(M* model, const G4String& placement, 271 const G4String& cmdName="setDrawLine") 272 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 273 { 274 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Set draw line command"); 275 } 276 277 protected: 278 279 void Apply(const G4bool& myBool) { 280 G4VModelCommand<M>::Model()->SetDrawLine(myBool); 281 } 282 283 }; 284 285 //////////////////////////////////////////////////////////////////////// 286 // Set line visibility command 287 template <typename M> 288 class G4ModelCmdSetLineVisible : public G4ModelCmdApplyBool<M> { 289 290 public: 291 292 G4ModelCmdSetLineVisible(M* model, const G4String& placement, 293 const G4String& cmdName="setLineVisible") 294 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 295 { 296 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Set line visibility command"); 297 } 298 299 protected: 300 301 void Apply(const G4bool& myBool) { 302 G4VModelCommand<M>::Model()->SetLineVisible(myBool); 303 } 304 305 }; 306 307 //////////////////////////////////////////////////////////////////////// 308 // Set draw auxiliary points command 309 template <typename M> 310 class G4ModelCmdSetDrawAuxPts : public G4ModelCmdApplyBool<M> { 311 312 public: 313 314 G4ModelCmdSetDrawAuxPts(M* model, const G4String& placement, 315 const G4String& cmdName="setDrawAuxPts") 316 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 317 { 318 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Set draw auxiliary points command"); 319 } 320 321 protected: 322 323 void Apply(const G4bool& myBool) { 324 G4VModelCommand<M>::Model()->SetDrawAuxPts(myBool); 325 } 326 327 }; 328 329 //////////////////////////////////////////////////////////////////////// 330 // Set auxiliary points visibility 331 template <typename M> 332 class G4ModelCmdSetAuxPtsVisible : public G4ModelCmdApplyBool<M> { 333 334 public: 335 336 G4ModelCmdSetAuxPtsVisible(M* model, const G4String& placement, 337 const G4String& cmdName="setAuxPtsVisible") 338 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 339 { 340 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Set auxiliary points visibility command"); 341 } 342 343 protected: 344 345 void Apply(const G4bool& myBool) { 346 G4VModelCommand<M>::Model()->SetAuxPtsVisible(myBool); 347 } 348 349 }; 350 351 //////////////////////////////////////////////////////////////////////// 352 // Set draw step points command 353 template <typename M> 354 class G4ModelCmdSetDrawStepPts : public G4ModelCmdApplyBool<M> { 355 356 public: 357 358 G4ModelCmdSetDrawStepPts(M* model, const G4String& placement, 359 const G4String& cmdName="setDrawStepPts") 360 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 361 { 362 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Set draw step points command"); 363 } 364 365 protected: 366 367 void Apply(const G4bool& myBool) { 368 G4VModelCommand<M>::Model()->SetDrawStepPts(myBool); 369 } 370 371 }; 372 373 //////////////////////////////////////////////////////////////////////// 374 // Set step points visible command 375 template <typename M> 376 class G4ModelCmdSetStepPtsVisible : public G4ModelCmdApplyBool<M> { 377 378 public: 379 380 G4ModelCmdSetStepPtsVisible(M* model, const G4String& placement, 381 const G4String& cmdName="setStepPtsVisible") 382 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 383 { 384 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Set step points visible command"); 385 } 386 387 protected: 388 389 void Apply(const G4bool& myBool) { 390 G4VModelCommand<M>::Model()->SetStepPtsVisible(myBool); 391 } 392 393 }; 394 395 //////////////////////////////////////////////////////////////////////// 396 // Set auxiliary points size command 397 template <typename M> 398 class G4ModelCmdSetAuxPtsSize : public G4ModelCmdApplyString<M> { 399 400 public: 401 402 G4ModelCmdSetAuxPtsSize(M* model, const G4String& placement, 403 const G4String& cmdName="setAuxPtsSize") 404 :G4ModelCmdApplyString<M>(model, placement, cmdName) 405 { 406 G4ModelCmdApplyString<M>::Command()->SetGuidance("Set auxiliary points size command"); 407 } 408 409 protected: 410 411 void Apply(const G4String& sizeString) { 412 std::istringstream iss(sizeString); 413 G4double size; 414 G4String unit; 415 iss >> size >> unit; 416 if (G4VModelCommand<M>::Model()->GetAuxPtsSizeType() == G4VMarker::world) 417 { 418 G4double myDouble = G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(sizeString); 419 G4VModelCommand<M>::Model()->SetAuxPtsSize(myDouble); 420 } 421 else // none or screen 422 { 423 G4VModelCommand<M>::Model()->SetAuxPtsSize(size); 424 } 425 } 426 427 }; 428 429 //////////////////////////////////////////////////////////////////////// 430 // Set step points size command 431 template <typename M> 432 class G4ModelCmdSetStepPtsSize : public G4ModelCmdApplyString<M> { 433 434 public: 435 436 G4ModelCmdSetStepPtsSize(M* model, const G4String& placement, 437 const G4String& cmdName="setStepPtsSize") 438 :G4ModelCmdApplyString<M>(model, placement, cmdName) 439 { 440 G4ModelCmdApplyString<M>::Command()->SetGuidance("Set step points size command"); 441 } 442 443 protected: 444 445 void Apply(const G4String& sizeString) { 446 std::istringstream iss(sizeString); 447 G4double size; 448 G4String unit; 449 iss >> size >> unit; 450 if (G4VModelCommand<M>::Model()->GetStepPtsSizeType() == G4VMarker::world) 451 { 452 G4double myDouble = G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(sizeString); 453 G4VModelCommand<M>::Model()->SetStepPtsSize(myDouble); 454 } 455 else // none or screen 456 { 457 G4VModelCommand<M>::Model()->SetStepPtsSize(size); 458 } 459 } 460 461 }; 462 463 //////////////////////////////////////////////////////////////////////// 464 // Set step points type command 465 template <typename M> 466 class G4ModelCmdSetStepPtsType : public G4ModelCmdApplyString<M> { 467 468 public: 469 470 G4ModelCmdSetStepPtsType(M* model, const G4String& placement, 471 const G4String& cmdName="setStepPtsType") 472 :G4ModelCmdApplyString<M>(model, placement, cmdName) 473 { 474 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); 475 cmd->SetGuidance("Set step points type."); 476 cmd->SetCandidates("dots circles squares"); 477 } 478 479 protected: 480 481 void Apply(const G4String& type) { 482 G4Polymarker::MarkerType myType; 483 484 if (type == "dots") {myType = G4Polymarker::dots;} 485 else if (type == "circles") {myType = G4Polymarker::circles;} 486 else if (type == "squares") {myType = G4Polymarker::squares;} 487 else { 488 G4ExceptionDescription ed; 489 ed << "Invalid argument. See command guidance for options."; 490 G4Exception 491 ("G4ModelCmdSetStepPtsType::Apply", 492 "modeling0109", JustWarning, ed); 493 return; 494 } 495 G4VModelCommand<M>::Model()->SetStepPtsType(myType); 496 } 497 498 }; 499 500 //////////////////////////////////////////////////////////////////////// 501 // Set auxiliary points type command 502 template <typename M> 503 class G4ModelCmdSetAuxPtsType : public G4ModelCmdApplyString<M> { 504 505 public: 506 507 G4ModelCmdSetAuxPtsType(M* model, const G4String& placement, 508 const G4String& cmdName="setAuxPtsType") 509 :G4ModelCmdApplyString<M>(model, placement, cmdName) 510 { 511 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); 512 513 cmd->SetGuidance("Set auxiliary points type."); 514 cmd->SetCandidates("dots circles squares"); 515 } 516 517 protected: 518 519 void Apply(const G4String& type) { 520 G4Polymarker::MarkerType myType; 521 522 if (type == "dots") {myType = G4Polymarker::dots;} 523 else if (type == "circles") {myType = G4Polymarker::circles;} 524 else if (type == "squares") {myType = G4Polymarker::squares;} 525 else { 526 G4ExceptionDescription ed; 527 ed << "Invalid argument. See command guidance for options."; 528 G4Exception 529 ("G4ModelCmdSetAuxPtsType::Apply", 530 "modeling0110", JustWarning, ed); 531 return; 532 } 533 534 G4VModelCommand<M>::Model()->SetAuxPtsType(myType); 535 } 536 537 }; 538 539 //////////////////////////////////////////////////////////////////////// 540 // Set step points size type command 541 template <typename M> 542 class G4ModelCmdSetStepPtsSizeType : public G4ModelCmdApplyString<M> { 543 544 public: 545 546 G4ModelCmdSetStepPtsSizeType(M* model, const G4String& placement, 547 const G4String& cmdName="setStepPtsSizeType") 548 :G4ModelCmdApplyString<M>(model, placement, cmdName) 549 { 550 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); 551 cmd->SetGuidance("Set step size type."); 552 cmd->SetCandidates("none world screen"); 553 } 554 555 protected: 556 557 void Apply(const G4String& type) { 558 G4VMarker::SizeType mySizeType; 559 560 if (type == "none") {mySizeType = G4VMarker::none;} 561 else if (type == "world") {mySizeType = G4VMarker::world;} 562 else if (type == "screen") {mySizeType = G4VMarker::screen;} 563 else { 564 G4ExceptionDescription ed; 565 ed << "Invalid argument. See command guidance for options."; 566 G4Exception 567 ("G4ModelCmdSetStepPtsSizeType::Apply", 568 "modeling0111", JustWarning, ed); 569 return; 570 } 571 G4VModelCommand<M>::Model()->SetStepPtsSizeType(mySizeType); 572 } 573 574 }; 575 576 //////////////////////////////////////////////////////////////////////// 577 // Set auxiliary points size type command 578 template <typename M> 579 class G4ModelCmdSetAuxPtsSizeType : public G4ModelCmdApplyString<M> { 580 581 public: 582 583 G4ModelCmdSetAuxPtsSizeType(M* model, const G4String& placement, 584 const G4String& cmdName="setAuxPtsSizeType") 585 :G4ModelCmdApplyString<M>(model, placement, cmdName) 586 { 587 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); 588 cmd->SetGuidance("Set auxiliary size type."); 589 cmd->SetCandidates("none world screen"); 590 } 591 592 protected: 593 594 void Apply(const G4String& type) { 595 G4VMarker::SizeType mySizeType; 596 597 if (type == "none") {mySizeType = G4VMarker::none;} 598 else if (type == "world") {mySizeType = G4VMarker::world;} 599 else if (type == "screen") {mySizeType = G4VMarker::screen;} 600 else { 601 G4ExceptionDescription ed; 602 ed << "Invalid argument. See command guidance for options."; 603 G4Exception 604 ("G4ModelCmdSetAuxPtsSizeType::Apply", 605 "modeling0112", JustWarning, ed); 606 return; 607 } 608 G4VModelCommand<M>::Model()->SetAuxPtsSizeType(mySizeType); 609 } 610 611 }; 612 613 //////////////////////////////////////////////////////////////////////// 614 // Set step points fill style command 615 template <typename M> 616 class G4ModelCmdSetStepPtsFillStyle : public G4ModelCmdApplyString<M> { 617 618 public: 619 620 G4ModelCmdSetStepPtsFillStyle(M* model, const G4String& placement, 621 const G4String& cmdName="setStepPtsFillStyle") 622 :G4ModelCmdApplyString<M>(model, placement, cmdName) 623 { 624 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); 625 cmd->SetGuidance("Set step fill style type."); 626 cmd->SetCandidates("noFill hashed filled"); 627 } 628 629 protected: 630 631 void Apply(const G4String& type) { 632 G4VMarker::FillStyle myFillStyle; 633 634 if (type == "noFill") {myFillStyle = G4VMarker::noFill;} 635 else if (type == "hashed") {myFillStyle = G4VMarker::hashed;} 636 else if (type == "filled") {myFillStyle = G4VMarker::filled;} 637 else { 638 G4ExceptionDescription ed; 639 ed << "Invalid argument. See command guidance for options."; 640 G4Exception 641 ("G4ModelCmdSetStepPtsFillStyle::Apply", 642 "modeling0113", JustWarning, ed); 643 return; 644 } 645 G4VModelCommand<M>::Model()->SetStepPtsFillStyle(myFillStyle); 646 } 647 648 }; 649 650 //////////////////////////////////////////////////////////////////////// 651 // Set auxiliary points fill style command 652 template <typename M> 653 class G4ModelCmdSetAuxPtsFillStyle : public G4ModelCmdApplyString<M> { 654 655 public: 656 657 G4ModelCmdSetAuxPtsFillStyle(M* model, const G4String& placement, 658 const G4String& cmdName="setAuxPtsFillStyle") 659 :G4ModelCmdApplyString<M>(model, placement, cmdName) 660 { 661 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); 662 cmd->SetGuidance("Set auxiliary fill style."); 663 cmd->SetCandidates("noFill hashed filled"); 664 } 665 666 protected: 667 668 void Apply(const G4String& type) { 669 G4VMarker::FillStyle myFillStyle; 670 671 if (type == "noFill") {myFillStyle = G4VMarker::noFill;} 672 else if (type == "hashed") {myFillStyle = G4VMarker::hashed;} 673 else if (type == "filled") {myFillStyle = G4VMarker::filled;} 674 else { 675 G4ExceptionDescription ed; 676 ed << "Invalid argument. See command guidance for options."; 677 G4Exception 678 ("G4ModelCmdSetAuxPtsFillStyle::Apply", 679 "modeling0114", JustWarning, ed); 680 return; 681 } 682 G4VModelCommand<M>::Model()->SetAuxPtsFillStyle(myFillStyle); 683 } 684 685 }; 686 687 //////////////////////////////////////////////////////////////////////// 688 // SetLineWidth command 689 template <typename M> 690 class G4ModelCmdSetLineWidth : public G4ModelCmdApplyDouble<M> { 691 692 public: 693 694 G4ModelCmdSetLineWidth(M* model, const G4String& placement, 695 const G4String& cmdName="""setLineWidth") 696 :G4ModelCmdApplyDouble<M>(model, placement, cmdName){} 697 698 protected: 699 700 void Apply(const G4double& width) { 701 G4VModelCommand<M>::Model()->SetLineWidth(width); 702 } 703 704 }; 705 706 //////////////////////////////////////////////////////////////////////// 707 // SetLineColour command 708 template <typename M> 709 class G4ModelCmdSetLineColour : public G4ModelCmdApplyColour<M> { 710 711 public: 712 713 G4ModelCmdSetLineColour(M* model, const G4String& placement, 714 const G4String& cmdName="""setLineColour") 715 :G4ModelCmdApplyColour<M>(model, placement, cmdName){} 716 717 protected: 718 719 void Apply(const G4Colour& colour) { 720 G4VModelCommand<M>::Model()->SetLineColour(colour); 721 } 722 723 }; 724 725 //////////////////////////////////////////////////////////////////////// 726 // Set time slice interval command 727 template <typename M> 728 class G4ModelCmdSetTimeSliceInterval : public G4ModelCmdApplyDoubleAndUnit<M> { 729 730 public: 731 732 G4ModelCmdSetTimeSliceInterval(M* model, const G4String& placement, 733 const G4String& cmdName = "setTimeSliceInterval") 734 :G4ModelCmdApplyDoubleAndUnit<M>(model, placement, cmdName) 735 { 736 G4UIcmdWithADoubleAndUnit* cmd = G4ModelCmdApplyDoubleAndUnit<M>::Command(); 737 cmd->SetGuidance 738 ("Set time slice interval. Give unit, e.g., \"0.1 ns\""); 739 cmd->SetUnitCategory("Time"); 740 } 741 742 protected: 743 744 void Apply(const G4double& myDouble) { 745 G4VModelCommand<M>::Model()->SetTimeSliceInterval(myDouble); 746 } 747 748 }; 749 750 //////////////////////////////////////////////////////////////////////// 751 // Create context directory command 752 template <typename M> 753 class G4ModelCmdCreateContextDir : public G4UImessenger { 754 755 public: 756 757 G4ModelCmdCreateContextDir(M* model, const G4String& placement) 758 { 759 G4String title = placement+"/"+model->Name()+"/"; 760 cmd = new G4UIdirectory(title); 761 762 cmd->SetGuidance("Commands for default configuration"); 763 } 764 765 virtual ~G4ModelCmdCreateContextDir() { 766 delete cmd; 767 } 768 769 protected: 770 771 G4UIdirectory* cmd; 772 773 }; 774 775 //////////////////////////////////////////////////////////////////////// 776 // Draw command 777 template <typename M> 778 class G4ModelCmdDraw : public G4ModelCmdApplyBool<M> { 779 780 public: // With description 781 782 G4ModelCmdDraw(M* model, const G4String& placement, 783 const G4String& cmdName="draw") 784 :G4ModelCmdApplyBool<M>(model, placement, cmdName) 785 { 786 G4ModelCmdApplyBool<M>::Command()->SetGuidance("Draw command"); 787 } 788 789 virtual ~G4ModelCmdDraw() {} 790 791 protected: 792 793 virtual void Apply(const G4bool& newValue) { 794 if (newValue) G4VModelCommand<M>::Model()->Draw(); 795 } 796 797 }; 798 799 //////////////////////////////////////////////////////////////////////// 800 // Set interval 801 template <typename M> 802 class G4ModelCmdAddInterval : public G4ModelCmdApplyString<M> { 803 804 public: // With description 805 806 G4ModelCmdAddInterval(M* model, const G4String& placement, 807 const G4String& cmdName="addInterval") 808 :G4ModelCmdApplyString<M>(model, placement, cmdName) 809 { 810 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); 811 cmd->SetGuidance("Set interval."); 812 } 813 814 virtual ~G4ModelCmdAddInterval() {} 815 816 protected: 817 818 virtual void Apply(const G4String& param) { 819 G4VModelCommand<M>::Model()->AddInterval(param); 820 821 } 822 }; 823 824 //////////////////////////////////////////////////////////////////////// 825 // Set value 826 template <typename M> 827 class G4ModelCmdAddValue : public G4ModelCmdApplyString<M> { 828 829 public: // With description 830 831 G4ModelCmdAddValue(M* model, const G4String& placement, 832 const G4String& cmdName="addValue") 833 :G4ModelCmdApplyString<M>(model, placement, cmdName) 834 { 835 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); 836 cmd->SetGuidance("Set value."); 837 } 838 839 virtual ~G4ModelCmdAddValue() {} 840 protected: 841 842 virtual void Apply(const G4String& param) { 843 G4VModelCommand<M>::Model()->AddValue(param); 844 } 845 }; 846 847 //////////////////////////////////////////////////////////////////////// 848 // Set string command 849 template <typename M> 850 class G4ModelCmdSetString : public G4ModelCmdApplyString<M> { 851 852 public: // With description 853 854 G4ModelCmdSetString(M* model, const G4String& placement, 855 const G4String& cmdName="set") 856 :G4ModelCmdApplyString<M>(model, placement, cmdName) 857 { 858 G4ModelCmdApplyString<M>::Command()->SetGuidance("Set command"); 859 } 860 861 virtual ~G4ModelCmdSetString() {} 862 863 protected: 864 865 virtual void Apply(const G4String& newValue) { 866 G4VModelCommand<M>::Model()->Set(newValue); 867 } 868 869 }; 870 871 #endif 872