Geant4_10
G4VisCommandsListManager.hh
Go to the documentation of this file.
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: G4VisCommandsListManager.hh 66373 2012-12-18 09:41:34Z gcosmo $
27 //
28 // Jane Tinslay, John Allison, Joseph Perl October 2005
29 //
30 // Class Description:
31 // Templated list manager commands which control list manager listing and
32 // selection.
33 // Class Description - End:
34 
35 #ifndef G4VISCOMMANDLISTMANAGER_HH
36 #define G4VISCOMMANDLISTMANAGER_HH
37 
38 #include "G4UImessenger.hh"
39 #include "G4String.hh"
40 #include "G4UIcmdWithAString.hh"
41 #include "G4UIcommand.hh"
42 
43 template <typename Manager>
45 
46 public: // With description
47 
48  G4VisCommandListManagerList(Manager*, const G4String& placement);
49  // Input list manager and command placement
50 
52 
54  void SetNewValue(G4UIcommand* command, G4String newValue);
55 
56  G4String Placement() const;
57 
58 private:
59 
60  // Data members
61  Manager* fpManager;
62  G4String fPlacement;
63 
64  G4UIcmdWithAString* fpCommand;
65 
66 };
67 
68 // List command
69 template <typename Manager>
71  :fpManager(manager)
72  ,fPlacement(placement)
73 {
74  G4String command = Placement()+"/list";
75 
76  fpCommand = new G4UIcmdWithAString(command, this);
77  fpCommand->SetGuidance("List objects registered with list manager");
78  fpCommand->SetParameterName("name", true);
79 }
80 
81 template <typename Manager>
83 {
84  delete fpCommand;
85 }
86 
87 template <typename Manager>
90 {
91  return fPlacement;
92 }
93 
94 template <typename Manager>
95 G4String
97 {
98  return "";
99 }
100 
101 template <typename Manager>
103 {
104  G4cout<<"Listing models available in "<<Placement()<<G4endl;
105 
106  assert (0 != fpManager);
107  fpManager->Print(G4cout, name);
108 }
109 
110 //Select command
111 template <typename Manager>
113 
114 public: // With description
115 
116  G4VisCommandListManagerSelect(Manager*, const G4String& placement);
117  // Input list manager and command placement
118 
120 
122  void SetNewValue (G4UIcommand* command, G4String newValue);
123 
124 private:
125 
126  Manager* fpManager;
127  G4String fPlacement;
128 
129  G4UIcmdWithAString* fpCommand;
130 
131 };
132 
133 template <typename Manager>
135  :fpManager(manager)
136  ,fPlacement(placement)
137 {
138  G4String command = placement+"/select";
139  G4String guidance = "Select created object";
140 
141  fpCommand = new G4UIcmdWithAString(command, this);
142  fpCommand->SetGuidance(guidance);
143  fpCommand->SetParameterName("name", false);
144 }
145 
146 template <typename Manager>
148 {
149  delete fpCommand;
150 }
151 
152 template <typename Manager>
153 G4String
155 {
156  return "";
157 }
158 
159 template <typename Manager>
161 {
162  assert (0 != fpManager);
163  fpManager->SetCurrent(name);
164 }
165 
166 // Mode command
167 template <typename Manager>
169 
170 public: // With description
171 
172  G4VisCommandManagerMode(Manager*, const G4String& placement);
173 
174  virtual ~G4VisCommandManagerMode();
175 
177  void SetNewValue (G4UIcommand* command, G4String newValue);
178 
179 private:
180 
181  Manager* fpManager;
182  G4String fPlacement;
183 
184  G4UIcmdWithAString* fpCommand;
185 
186 };
187 template <typename Manager>
189  :fpManager(manager)
190  ,fPlacement(placement)
191 {
192  G4String command = fPlacement+"/mode";
193 
194  fpCommand = new G4UIcmdWithAString(command, this);
195  fpCommand->SetGuidance("Set mode of operation");
196  fpCommand->SetParameterName("mode", false);
197  fpCommand->SetCandidates("soft hard");
198 }
199 
200 template <typename Manager>
202 {
203  delete fpCommand;
204 }
205 
206 template <typename Manager>
207 G4String
209 {
210  return "";
211 }
212 
213 template <typename Manager>
215 {
216  assert (0 != fpManager);
217  fpManager->SetMode(name);
218 }
219 
220 #endif
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
#define assert(x)
Definition: mymalloc.cc:1309
G4VisCommandManagerMode(Manager *, const G4String &placement)
const XML_Char * name
Definition: expat.h:151
G4String GetCurrentValue(G4UIcommand *)
G4GLOB_DLL std::ostream G4cout
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *)
G4VisCommandListManagerSelect(Manager *, const G4String &placement)
void SetCandidates(const char *candidateList)
#define G4endl
Definition: G4ios.hh:61
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandListManagerList(Manager *, const G4String &placement)