G4VisCommandsListManager.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id$
00027 //
00028 // Jane Tinslay, John Allison, Joseph Perl October 2005
00029 //
00030 // Class Description:
00031 // Templated list manager commands which control list manager listing and
00032 // selection.
00033 // Class Description - End:
00034 
00035 #ifndef G4VISCOMMANDLISTMANAGER_HH
00036 #define G4VISCOMMANDLISTMANAGER_HH
00037 
00038 #include "G4UImessenger.hh"
00039 #include "G4String.hh"
00040 #include "G4UIcmdWithAString.hh"
00041 #include "G4UIcommand.hh"
00042 
00043 template <typename Manager>
00044 class G4VisCommandListManagerList : public G4UImessenger {
00045 
00046 public: // With description
00047 
00048   G4VisCommandListManagerList(Manager*, const G4String& placement);
00049   // Input list manager and command placement
00050 
00051   virtual ~G4VisCommandListManagerList();
00052 
00053   G4String GetCurrentValue(G4UIcommand*);
00054   void SetNewValue(G4UIcommand* command, G4String newValue);
00055 
00056   G4String Placement() const;
00057 
00058 private:
00059 
00060   // Data members
00061   Manager* fpManager;
00062   G4String fPlacement;
00063 
00064   G4UIcmdWithAString* fpCommand;
00065 
00066 };
00067 
00068 // List command
00069 template <typename Manager>
00070 G4VisCommandListManagerList<Manager>::G4VisCommandListManagerList(Manager* manager, const G4String& placement)
00071   :fpManager(manager)
00072   ,fPlacement(placement)
00073 {  
00074   G4String command = Placement()+"/list";
00075   
00076   fpCommand = new G4UIcmdWithAString(command, this);      
00077   fpCommand->SetGuidance("List objects registered with list manager");
00078   fpCommand->SetParameterName("name", true);       
00079 }
00080 
00081 template <typename Manager>
00082 G4VisCommandListManagerList<Manager>::~G4VisCommandListManagerList()
00083 {
00084   delete fpCommand;
00085 }
00086 
00087 template <typename Manager>
00088 G4String
00089 G4VisCommandListManagerList<Manager>::Placement() const
00090 {
00091   return fPlacement;
00092 }
00093 
00094 template <typename Manager>
00095 G4String 
00096 G4VisCommandListManagerList<Manager>::GetCurrentValue(G4UIcommand*) 
00097 {
00098   return "";
00099 }
00100 
00101 template <typename Manager>
00102 void G4VisCommandListManagerList<Manager>::SetNewValue(G4UIcommand*, G4String name) 
00103 {
00104   G4cout<<"Listing models available in "<<Placement()<<G4endl;
00105 
00106   assert (0 != fpManager);
00107   fpManager->Print(G4cout, name);
00108 }    
00109 
00110 //Select command
00111 template <typename Manager>
00112 class G4VisCommandListManagerSelect : public G4UImessenger {
00113 
00114 public: // With description
00115 
00116   G4VisCommandListManagerSelect(Manager*, const G4String& placement);
00117   // Input list manager and command placement
00118 
00119   virtual ~G4VisCommandListManagerSelect();
00120 
00121   G4String GetCurrentValue(G4UIcommand*);
00122   void SetNewValue (G4UIcommand* command, G4String newValue);
00123 
00124 private:
00125 
00126   Manager* fpManager;
00127   G4String fPlacement;
00128 
00129   G4UIcmdWithAString* fpCommand;
00130 
00131 };
00132 
00133 template <typename Manager>
00134 G4VisCommandListManagerSelect<Manager>::G4VisCommandListManagerSelect(Manager* manager, const G4String& placement)
00135   :fpManager(manager)
00136   ,fPlacement(placement)
00137 {  
00138   G4String command = placement+"/select";
00139   G4String guidance = "Select created object";
00140  
00141   fpCommand = new G4UIcmdWithAString(command, this);      
00142   fpCommand->SetGuidance(guidance);
00143   fpCommand->SetParameterName("name", false);       
00144 }
00145 
00146 template <typename Manager>
00147 G4VisCommandListManagerSelect<Manager>::~G4VisCommandListManagerSelect()
00148 {
00149   delete fpCommand;
00150 }
00151 
00152 template <typename Manager>
00153 G4String 
00154 G4VisCommandListManagerSelect<Manager>::GetCurrentValue(G4UIcommand*) 
00155 {
00156   return "";
00157 }
00158 
00159 template <typename Manager>
00160 void G4VisCommandListManagerSelect<Manager>::SetNewValue(G4UIcommand*, G4String name) 
00161 {
00162   assert (0 != fpManager);
00163   fpManager->SetCurrent(name);
00164 }    
00165 
00166 // Mode command
00167 template <typename Manager>
00168 class G4VisCommandManagerMode : public G4UImessenger {
00169 
00170 public: // With description
00171 
00172   G4VisCommandManagerMode(Manager*, const G4String& placement);
00173 
00174   virtual ~G4VisCommandManagerMode();
00175 
00176   G4String GetCurrentValue(G4UIcommand*);
00177   void SetNewValue (G4UIcommand* command, G4String newValue);
00178 
00179 private:
00180 
00181   Manager* fpManager;
00182   G4String fPlacement;
00183 
00184   G4UIcmdWithAString* fpCommand;
00185 
00186 };
00187 template <typename Manager>
00188 G4VisCommandManagerMode<Manager>::G4VisCommandManagerMode(Manager* manager, const G4String& placement)
00189   :fpManager(manager)
00190   ,fPlacement(placement)
00191 {  
00192   G4String command = fPlacement+"/mode";
00193   
00194   fpCommand = new G4UIcmdWithAString(command, this);      
00195   fpCommand->SetGuidance("Set mode of operation");
00196   fpCommand->SetParameterName("mode", false);       
00197   fpCommand->SetCandidates("soft hard");       
00198 }
00199 
00200 template <typename Manager>
00201 G4VisCommandManagerMode<Manager>::~G4VisCommandManagerMode()
00202 {
00203   delete fpCommand;
00204 }
00205 
00206 template <typename Manager>
00207 G4String 
00208 G4VisCommandManagerMode<Manager>::GetCurrentValue(G4UIcommand*) 
00209 {
00210   return "";
00211 }
00212 
00213 template <typename Manager>
00214 void G4VisCommandManagerMode<Manager>::SetNewValue(G4UIcommand*, G4String name) 
00215 {
00216   assert (0 != fpManager);
00217   fpManager->SetMode(name);
00218 }    
00219 
00220 #endif

Generated on Mon May 27 17:50:15 2013 for Geant4 by  doxygen 1.4.7