source: trunk/source/visualization/modeling/include/G4ModelCommandsT.hh@ 1310

Last change on this file since 1310 was 944, checked in by garnier, 17 years ago

mise a jour des tags

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