Geant4 examples
extended/common/detectorConstruction/src/ExG4DetectorConstruction01Messenger.cc
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: ExG4DetectorConstruction01Messenger.cc,v 1.2 2006-06-29 16:46:49 gunter Exp $
00027 //
00030 
00031 #include "ExG4DetectorConstruction01Messenger.hh"
00032 #include "ExG4DetectorConstruction01.hh"
00033 
00034 #include "G4UIdirectory.hh"
00035 #include "G4UIcmdWithAString.hh"
00036 #include "G4UIcmdWith3VectorAndUnit.hh"
00037 #include "G4UIcmdWithADouble.hh"
00038 
00039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00040 
00041 ExG4DetectorConstruction01Messenger::ExG4DetectorConstruction01Messenger(
00042                            ExG4DetectorConstruction01* detectorConstruction)
00043  : G4UImessenger(),
00044    fDetectorConstruction(detectorConstruction),
00045    fTopDirectory(0),
00046    fDirectory(0),
00047    fSetMaterialCmd(0),
00048    fSetDimensionsCmd(0)
00049    
00050 { 
00051   fTopDirectory = new G4UIdirectory("/ExG4/");
00052   fTopDirectory->SetGuidance("UI commands of common example classes");
00053   
00054   fDirectory = new G4UIdirectory("/ExG4/det/");
00055   fDirectory->SetGuidance("Detector control");
00056        
00057   fSetMaterialCmd 
00058     = new G4UIcmdWithAString("/ExG4/det/setBoxMaterial",this);
00059   fSetMaterialCmd->SetGuidance("Select material of the box.");
00060   fSetMaterialCmd->SetParameterName("BoxMaterial", false);
00061   fSetMaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00062 
00063   fSetDimensionsCmd 
00064     = new G4UIcmdWith3VectorAndUnit("/ExG4/det/setBoxDimensions",this);
00065   fSetDimensionsCmd->SetGuidance("Set box dimensions (in half lentgh).");
00066   fSetDimensionsCmd->SetParameterName(
00067                           "BoxDimensionsHx", "BoxDimensionsHy","BoxDimensionsHz", 
00068                           false);
00069   //fSetDimensionsCmd->SetUnitCategory("Length");  
00070   fSetDimensionsCmd->AvailableForStates(G4State_PreInit);
00071 }
00072 
00073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00074 
00075 ExG4DetectorConstruction01Messenger::~ExG4DetectorConstruction01Messenger()
00076 {
00077   delete fTopDirectory;
00078   delete fDirectory;
00079   delete fSetMaterialCmd;
00080   delete fSetDimensionsCmd;
00081 }
00082 
00083 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00084 
00085 void ExG4DetectorConstruction01Messenger::SetNewValue(G4UIcommand* command, 
00086                                                      G4String newValue)
00087 { 
00088   if( command == fSetMaterialCmd ) { 
00089     fDetectorConstruction->SetMaterial(newValue);
00090   }
00091   else if( command == fSetDimensionsCmd ) { 
00092     G4ThreeVector newDimensions 
00093       = fSetDimensionsCmd->GetNew3VectorValue(newValue);
00094     fDetectorConstruction
00095       ->SetDimensions(
00096           newDimensions.x(), newDimensions.y(), newDimensions.z());
00097   }
00098 }
00099 
00100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines