ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ModelCommandsT.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ModelCommandsT.hh
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 
40 // Set parameter colour
41 template <typename 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 
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 
61 // Set default colour
62 template <typename 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 
72 
73 protected:
74 
75  virtual void Apply(const G4Colour& colour) {
76  G4VModelCommand<M>::Model()->SetDefault(colour);
77  }
78 
79 };
80 
82 // Add string command
83 template <typename 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  {
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 
106 //Add integer command
107 template <typename 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  {
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 
130 // Invert command
131 template <typename 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 
154 // Active command
155 template <typename 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 
178 // Verbose command
179 template <typename 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 
202 // Reset command
203 template <typename 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 
226 // Set auxiliary points colour command
227 template <typename M>
229 
230 public:
231 
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 
245 // Set set points colour command
246 template <typename M>
248 
249 public:
250 
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 
264 // Set draw line command
265 template <typename 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 
286 // Set line visibility command
287 template <typename M>
289 
290 public:
291 
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 
308 // Set draw auxiliary points command
309 template <typename 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 
330 // Set auxiliary points visibility
331 template <typename M>
333 
334 public:
335 
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 
352 // Set draw step points command
353 template <typename M>
355 
356 public:
357 
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 
374 // Set step points visible command
375 template <typename M>
377 
378 public:
379 
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 
396 // Set auxiliary points size command
397 template <typename 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  {
419  G4VModelCommand<M>::Model()->SetAuxPtsSize(myDouble);
420  }
421  else // none or screen
422  {
423  G4VModelCommand<M>::Model()->SetAuxPtsSize(size);
424  }
425  }
426 
427 };
428 
430 // Set step points size command
431 template <typename M>
433 
434 public:
435 
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  {
453  G4VModelCommand<M>::Model()->SetStepPtsSize(myDouble);
454  }
455  else // none or screen
456  {
457  G4VModelCommand<M>::Model()->SetStepPtsSize(size);
458  }
459  }
460 
461 };
462 
464 // Set step points type command
465 template <typename M>
467 
468 public:
469 
471  const G4String& cmdName="setStepPtsType")
472  :G4ModelCmdApplyString<M>(model, placement, cmdName)
473  {
475  cmd->SetGuidance("Set step points type.");
476  cmd->SetCandidates("dots circles squares");
477  }
478 
479 protected:
480 
481  void Apply(const G4String& type) {
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 {
489  ed << "Invalid argument. See command guidance for options.";
491  ("G4ModelCmdSetStepPtsType::Apply",
492  "modeling0109", JustWarning, ed);
493  return;
494  }
495  G4VModelCommand<M>::Model()->SetStepPtsType(myType);
496  }
497 
498 };
499 
501 // Set auxiliary points type command
502 template <typename M>
504 
505 public:
506 
507  G4ModelCmdSetAuxPtsType(M* model, const G4String& placement,
508  const G4String& cmdName="setAuxPtsType")
509  :G4ModelCmdApplyString<M>(model, placement, cmdName)
510  {
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) {
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 {
527  ed << "Invalid argument. See command guidance for options.";
529  ("G4ModelCmdSetAuxPtsType::Apply",
530  "modeling0110", JustWarning, ed);
531  return;
532  }
533 
534  G4VModelCommand<M>::Model()->SetAuxPtsType(myType);
535  }
536 
537 };
538 
540 // Set step points size type command
541 template <typename M>
543 
544 public:
545 
547  const G4String& cmdName="setStepPtsSizeType")
548  :G4ModelCmdApplyString<M>(model, placement, cmdName)
549  {
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 {
565  ed << "Invalid argument. See command guidance for options.";
567  ("G4ModelCmdSetStepPtsSizeType::Apply",
568  "modeling0111", JustWarning, ed);
569  return;
570  }
571  G4VModelCommand<M>::Model()->SetStepPtsSizeType(mySizeType);
572  }
573 
574 };
575 
577 // Set auxiliary points size type command
578 template <typename M>
580 
581 public:
582 
584  const G4String& cmdName="setAuxPtsSizeType")
585  :G4ModelCmdApplyString<M>(model, placement, cmdName)
586  {
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 {
602  ed << "Invalid argument. See command guidance for options.";
604  ("G4ModelCmdSetAuxPtsSizeType::Apply",
605  "modeling0112", JustWarning, ed);
606  return;
607  }
608  G4VModelCommand<M>::Model()->SetAuxPtsSizeType(mySizeType);
609  }
610 
611 };
612 
614 // Set step points fill style command
615 template <typename M>
617 
618 public:
619 
621  const G4String& cmdName="setStepPtsFillStyle")
622  :G4ModelCmdApplyString<M>(model, placement, cmdName)
623  {
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 {
639  ed << "Invalid argument. See command guidance for options.";
641  ("G4ModelCmdSetStepPtsFillStyle::Apply",
642  "modeling0113", JustWarning, ed);
643  return;
644  }
645  G4VModelCommand<M>::Model()->SetStepPtsFillStyle(myFillStyle);
646  }
647 
648 };
649 
651 // Set auxiliary points fill style command
652 template <typename M>
654 
655 public:
656 
658  const G4String& cmdName="setAuxPtsFillStyle")
659  :G4ModelCmdApplyString<M>(model, placement, cmdName)
660  {
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 {
676  ed << "Invalid argument. See command guidance for options.";
678  ("G4ModelCmdSetAuxPtsFillStyle::Apply",
679  "modeling0114", JustWarning, ed);
680  return;
681  }
682  G4VModelCommand<M>::Model()->SetAuxPtsFillStyle(myFillStyle);
683  }
684 
685 };
686 
688 // SetLineWidth command
689 template <typename 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 
707 // SetLineColour command
708 template <typename 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 
726 // Set time slice interval command
727 template <typename M>
729 
730 public:
731 
733  const G4String& cmdName = "setTimeSliceInterval")
734  :G4ModelCmdApplyDoubleAndUnit<M>(model, placement, cmdName)
735  {
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 
751 // Create context directory command
752 template <typename M>
754 
755 public:
756 
758  {
759  G4String title = placement+"/"+model->Name()+"/";
760  cmd = new G4UIdirectory(title);
761 
762  cmd->SetGuidance("Commands for default configuration");
763  }
764 
766  delete cmd;
767  }
768 
769 protected:
770 
772 
773 };
774 
776 // Draw command
777 template <typename 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 
800 // Set interval
801 template <typename 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  {
811  cmd->SetGuidance("Set interval.");
812  }
813 
815 
816 protected:
817 
818  virtual void Apply(const G4String& param) {
819  G4VModelCommand<M>::Model()->AddInterval(param);
820 
821  }
822 };
823 
825 // Set value
826 template <typename 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  {
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 
849 // Set string command
850 template <typename M>
852 
853 public: // With description
854 
855  G4ModelCmdSetString(M* model, const G4String& placement,
856  const G4String& cmdName="set")
857  :G4ModelCmdApplyString<M>(model, placement, cmdName)
858  {
860  }
861 
862  virtual ~G4ModelCmdSetString() {}
863 
864 protected:
865 
866  virtual void Apply(const G4String& newValue) {
867  G4VModelCommand<M>::Model()->Set(newValue);
868  }
869 
870 };
871 
872 #endif