[531] | 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,v 1.3 2006/06/29 21:28:38 gunter Exp $ |
---|
| 27 | // GEANT4 tag $Name: geant4-08-01-patch-01 $ |
---|
| 28 | // |
---|
| 29 | // Jane Tinslay, John Allison, Joseph Perl October 2005 |
---|
| 30 | // |
---|
| 31 | // Class Description: |
---|
| 32 | // Templated list manager commands which control list manager listing and |
---|
| 33 | // selection. |
---|
| 34 | // Class Description - End: |
---|
| 35 | |
---|
| 36 | #ifndef G4VISCOMMANDLISTMANAGER_HH |
---|
| 37 | #define G4VISCOMMANDLISTMANAGER_HH |
---|
| 38 | |
---|
| 39 | #include "G4UImessenger.hh" |
---|
| 40 | #include "G4String.hh" |
---|
| 41 | #include "G4UIcmdWithAString.hh" |
---|
| 42 | #include "G4UIcommand.hh" |
---|
| 43 | |
---|
| 44 | template <typename Manager> |
---|
| 45 | class G4VisCommandListManagerList : public G4UImessenger { |
---|
| 46 | |
---|
| 47 | public: // With description |
---|
| 48 | |
---|
| 49 | G4VisCommandListManagerList(Manager*, const G4String& placement); |
---|
| 50 | // Input list manager and command placement |
---|
| 51 | |
---|
| 52 | virtual ~G4VisCommandListManagerList(); |
---|
| 53 | |
---|
| 54 | G4String GetCurrentValue(G4UIcommand*); |
---|
| 55 | void SetNewValue(G4UIcommand* command, G4String newValue); |
---|
| 56 | |
---|
| 57 | G4String Placement() const; |
---|
| 58 | |
---|
| 59 | private: |
---|
| 60 | |
---|
| 61 | // Data members |
---|
| 62 | Manager* fpManager; |
---|
| 63 | G4String fPlacement; |
---|
| 64 | |
---|
| 65 | G4UIcmdWithAString* fpCommand; |
---|
| 66 | |
---|
| 67 | }; |
---|
| 68 | |
---|
| 69 | // List command |
---|
| 70 | template <typename Manager> |
---|
| 71 | G4VisCommandListManagerList<Manager>::G4VisCommandListManagerList(Manager* manager, const G4String& placement) |
---|
| 72 | :fpManager(manager) |
---|
| 73 | ,fPlacement(placement) |
---|
| 74 | { |
---|
| 75 | G4String command = Placement()+"/list"; |
---|
| 76 | |
---|
| 77 | fpCommand = new G4UIcmdWithAString(command, this); |
---|
| 78 | fpCommand->SetGuidance("List objects registered with list manager"); |
---|
| 79 | fpCommand->SetParameterName("name", true); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | template <typename Manager> |
---|
| 83 | G4VisCommandListManagerList<Manager>::~G4VisCommandListManagerList() |
---|
| 84 | { |
---|
| 85 | delete fpCommand; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | template <typename Manager> |
---|
| 89 | G4String |
---|
| 90 | G4VisCommandListManagerList<Manager>::Placement() const |
---|
| 91 | { |
---|
| 92 | return fPlacement; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | template <typename Manager> |
---|
| 96 | G4String |
---|
| 97 | G4VisCommandListManagerList<Manager>::GetCurrentValue(G4UIcommand*) |
---|
| 98 | { |
---|
| 99 | return ""; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | template <typename Manager> |
---|
| 103 | void G4VisCommandListManagerList<Manager>::SetNewValue(G4UIcommand*, G4String name) |
---|
| 104 | { |
---|
| 105 | G4cout<<"Listing models available in "<<Placement()<<G4endl; |
---|
| 106 | |
---|
| 107 | assert (0 != fpManager); |
---|
| 108 | fpManager->Print(G4cout, name); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | //Select command |
---|
| 112 | template <typename Manager> |
---|
| 113 | class G4VisCommandListManagerSelect : public G4UImessenger { |
---|
| 114 | |
---|
| 115 | public: // With description |
---|
| 116 | |
---|
| 117 | G4VisCommandListManagerSelect(Manager*, const G4String& placement); |
---|
| 118 | // Input list manager and command placement |
---|
| 119 | |
---|
| 120 | virtual ~G4VisCommandListManagerSelect(); |
---|
| 121 | |
---|
| 122 | G4String GetCurrentValue(G4UIcommand*); |
---|
| 123 | void SetNewValue (G4UIcommand* command, G4String newValue); |
---|
| 124 | |
---|
| 125 | private: |
---|
| 126 | |
---|
| 127 | Manager* fpManager; |
---|
| 128 | G4String fPlacement; |
---|
| 129 | |
---|
| 130 | G4UIcmdWithAString* fpCommand; |
---|
| 131 | |
---|
| 132 | }; |
---|
| 133 | |
---|
| 134 | template <typename Manager> |
---|
| 135 | G4VisCommandListManagerSelect<Manager>::G4VisCommandListManagerSelect(Manager* manager, const G4String& placement) |
---|
| 136 | :fpManager(manager) |
---|
| 137 | ,fPlacement(placement) |
---|
| 138 | { |
---|
| 139 | G4String command = placement+"/select"; |
---|
| 140 | G4String guidance = "Select created object"; |
---|
| 141 | |
---|
| 142 | fpCommand = new G4UIcmdWithAString(command, this); |
---|
| 143 | fpCommand->SetGuidance(guidance); |
---|
| 144 | fpCommand->SetParameterName("name", false); |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | template <typename Manager> |
---|
| 148 | G4VisCommandListManagerSelect<Manager>::~G4VisCommandListManagerSelect() |
---|
| 149 | { |
---|
| 150 | delete fpCommand; |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | template <typename Manager> |
---|
| 154 | G4String |
---|
| 155 | G4VisCommandListManagerSelect<Manager>::GetCurrentValue(G4UIcommand*) |
---|
| 156 | { |
---|
| 157 | return ""; |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | template <typename Manager> |
---|
| 161 | void G4VisCommandListManagerSelect<Manager>::SetNewValue(G4UIcommand*, G4String name) |
---|
| 162 | { |
---|
| 163 | assert (0 != fpManager); |
---|
| 164 | fpManager->SetCurrent(name); |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | // Mode command |
---|
| 168 | template <typename Manager> |
---|
| 169 | class G4VisCommandManagerMode : public G4UImessenger { |
---|
| 170 | |
---|
| 171 | public: // With description |
---|
| 172 | |
---|
| 173 | G4VisCommandManagerMode(Manager*, const G4String& placement); |
---|
| 174 | |
---|
| 175 | virtual ~G4VisCommandManagerMode(); |
---|
| 176 | |
---|
| 177 | G4String GetCurrentValue(G4UIcommand*); |
---|
| 178 | void SetNewValue (G4UIcommand* command, G4String newValue); |
---|
| 179 | |
---|
| 180 | private: |
---|
| 181 | |
---|
| 182 | Manager* fpManager; |
---|
| 183 | G4String fPlacement; |
---|
| 184 | |
---|
| 185 | G4UIcmdWithAString* fpCommand; |
---|
| 186 | |
---|
| 187 | }; |
---|
| 188 | template <typename Manager> |
---|
| 189 | G4VisCommandManagerMode<Manager>::G4VisCommandManagerMode(Manager* manager, const G4String& placement) |
---|
| 190 | :fpManager(manager) |
---|
| 191 | ,fPlacement(placement) |
---|
| 192 | { |
---|
| 193 | G4String command = fPlacement+"/mode"; |
---|
| 194 | |
---|
| 195 | fpCommand = new G4UIcmdWithAString(command, this); |
---|
| 196 | fpCommand->SetGuidance("Set mode of operation"); |
---|
| 197 | fpCommand->SetParameterName("mode", false); |
---|
| 198 | fpCommand->SetCandidates("soft hard"); |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | template <typename Manager> |
---|
| 202 | G4VisCommandManagerMode<Manager>::~G4VisCommandManagerMode() |
---|
| 203 | { |
---|
| 204 | delete fpCommand; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | template <typename Manager> |
---|
| 208 | G4String |
---|
| 209 | G4VisCommandManagerMode<Manager>::GetCurrentValue(G4UIcommand*) |
---|
| 210 | { |
---|
| 211 | return ""; |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | template <typename Manager> |
---|
| 215 | void G4VisCommandManagerMode<Manager>::SetNewValue(G4UIcommand*, G4String name) |
---|
| 216 | { |
---|
| 217 | assert (0 != fpManager); |
---|
| 218 | fpManager->SetMode(name); |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | #endif |
---|