Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:23

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // Jane Tinslay, John Allison, Joseph Perl October 2005
0028 //
0029 // Class Description:
0030 // Templated list manager commands which control list manager listing and
0031 // selection.
0032 // Class Description - End:
0033 
0034 #ifndef G4VISCOMMANDLISTMANAGER_HH
0035 #define G4VISCOMMANDLISTMANAGER_HH
0036 
0037 #include "G4UImessenger.hh"
0038 #include "G4String.hh"
0039 #include "G4UIcmdWithAString.hh"
0040 #include "G4UIcommand.hh"
0041 
0042 template <typename Manager>
0043 class G4VisCommandListManagerList : public G4UImessenger {
0044 
0045 public: // With description
0046 
0047   G4VisCommandListManagerList(Manager*, const G4String& placement);
0048   // Input list manager and command placement
0049 
0050   virtual ~G4VisCommandListManagerList();
0051 
0052   G4String GetCurrentValue(G4UIcommand*);
0053   void SetNewValue(G4UIcommand* command, G4String newValue);
0054 
0055   G4String Placement() const;
0056 
0057 private:
0058 
0059   // Data members
0060   Manager* fpManager;
0061   G4String fPlacement;
0062 
0063   G4UIcmdWithAString* fpCommand;
0064 
0065 };
0066 
0067 // List command
0068 template <typename Manager>
0069 G4VisCommandListManagerList<Manager>::G4VisCommandListManagerList(Manager* manager, const G4String& placement)
0070   :fpManager(manager)
0071   ,fPlacement(placement)
0072 {  
0073   G4String command = Placement()+"/list";
0074   
0075   fpCommand = new G4UIcmdWithAString(command, this);      
0076   fpCommand->SetGuidance("List objects registered with list manager");
0077   fpCommand->SetParameterName("name", true);       
0078 }
0079 
0080 template <typename Manager>
0081 G4VisCommandListManagerList<Manager>::~G4VisCommandListManagerList()
0082 {
0083   delete fpCommand;
0084 }
0085 
0086 template <typename Manager>
0087 G4String
0088 G4VisCommandListManagerList<Manager>::Placement() const
0089 {
0090   return fPlacement;
0091 }
0092 
0093 template <typename Manager>
0094 G4String 
0095 G4VisCommandListManagerList<Manager>::GetCurrentValue(G4UIcommand*) 
0096 {
0097   return "";
0098 }
0099 
0100 template <typename Manager>
0101 void G4VisCommandListManagerList<Manager>::SetNewValue(G4UIcommand*, G4String name) 
0102 {
0103   G4cout<<"Listing models available in "<<Placement()<<G4endl;
0104 
0105   assert (0 != fpManager);
0106   fpManager->Print(G4cout, name);
0107 }    
0108 
0109 //Select command
0110 template <typename Manager>
0111 class G4VisCommandListManagerSelect : public G4UImessenger {
0112 
0113 public: // With description
0114 
0115   G4VisCommandListManagerSelect(Manager*, const G4String& placement);
0116   // Input list manager and command placement
0117 
0118   virtual ~G4VisCommandListManagerSelect();
0119 
0120   G4String GetCurrentValue(G4UIcommand*);
0121   void SetNewValue (G4UIcommand* command, G4String newValue);
0122 
0123 private:
0124 
0125   Manager* fpManager;
0126   G4String fPlacement;
0127 
0128   G4UIcmdWithAString* fpCommand;
0129 
0130 };
0131 
0132 template <typename Manager>
0133 G4VisCommandListManagerSelect<Manager>::G4VisCommandListManagerSelect(Manager* manager, const G4String& placement)
0134   :fpManager(manager)
0135   ,fPlacement(placement)
0136 {  
0137   G4String command = placement+"/select";
0138   G4String guidance = "Select created object";
0139  
0140   fpCommand = new G4UIcmdWithAString(command, this);      
0141   fpCommand->SetGuidance(guidance);
0142   fpCommand->SetParameterName("name", false);       
0143 }
0144 
0145 template <typename Manager>
0146 G4VisCommandListManagerSelect<Manager>::~G4VisCommandListManagerSelect()
0147 {
0148   delete fpCommand;
0149 }
0150 
0151 template <typename Manager>
0152 G4String 
0153 G4VisCommandListManagerSelect<Manager>::GetCurrentValue(G4UIcommand*) 
0154 {
0155   return "";
0156 }
0157 
0158 template <typename Manager>
0159 void G4VisCommandListManagerSelect<Manager>::SetNewValue(G4UIcommand*, G4String name) 
0160 {
0161   assert (0 != fpManager);
0162   fpManager->SetCurrent(name);
0163 }    
0164 
0165 // Mode command
0166 template <typename Manager>
0167 class G4VisCommandManagerMode : public G4UImessenger {
0168 
0169 public: // With description
0170 
0171   G4VisCommandManagerMode(Manager*, const G4String& placement);
0172 
0173   virtual ~G4VisCommandManagerMode();
0174 
0175   G4String GetCurrentValue(G4UIcommand*);
0176   void SetNewValue (G4UIcommand* command, G4String newValue);
0177 
0178 private:
0179 
0180   Manager* fpManager;
0181   G4String fPlacement;
0182 
0183   G4UIcmdWithAString* fpCommand;
0184 
0185 };
0186 template <typename Manager>
0187 G4VisCommandManagerMode<Manager>::G4VisCommandManagerMode(Manager* manager, const G4String& placement)
0188   :fpManager(manager)
0189   ,fPlacement(placement)
0190 {  
0191   G4String command = fPlacement+"/mode";
0192   
0193   fpCommand = new G4UIcmdWithAString(command, this);      
0194   fpCommand->SetGuidance("Set mode of operation");
0195   fpCommand->SetParameterName("mode", false);       
0196   fpCommand->SetCandidates("soft hard");       
0197 }
0198 
0199 template <typename Manager>
0200 G4VisCommandManagerMode<Manager>::~G4VisCommandManagerMode()
0201 {
0202   delete fpCommand;
0203 }
0204 
0205 template <typename Manager>
0206 G4String 
0207 G4VisCommandManagerMode<Manager>::GetCurrentValue(G4UIcommand*) 
0208 {
0209   return "";
0210 }
0211 
0212 template <typename Manager>
0213 void G4VisCommandManagerMode<Manager>::SetNewValue(G4UIcommand*, G4String name) 
0214 {
0215   assert (0 != fpManager);
0216   fpManager->SetMode(name);
0217   G4VVisManager* visManager = G4VVisManager::GetConcreteInstance();
0218   if (visManager) visManager->NotifyHandlers();
0219 }    
0220 
0221 #endif