Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /* 26 /* 27 * =========================================== 27 * ============================================================================ 28 * 28 * 29 * Filename: CexmcHistoManagerMessenger 29 * Filename: CexmcHistoManagerMessenger.cc 30 * 30 * 31 * Description: commands to list and show 31 * Description: commands to list and show histograms 32 * 32 * 33 * Version: 1.0 33 * Version: 1.0 34 * Created: 17.12.2009 21:39:02 34 * Created: 17.12.2009 21:39:02 35 * Revision: none 35 * Revision: none 36 * Compiler: gcc 36 * Compiler: gcc 37 * 37 * 38 * Author: Alexey Radkov (), 38 * Author: Alexey Radkov (), 39 * Company: PNPI 39 * Company: PNPI 40 * 40 * 41 * =========================================== 41 * ============================================================================ 42 */ 42 */ 43 43 44 #ifdef CEXMC_USE_ROOT 44 #ifdef CEXMC_USE_ROOT 45 45 46 #include <G4UIcmdWithoutParameter.hh> 46 #include <G4UIcmdWithoutParameter.hh> 47 #include <G4UIcmdWithAnInteger.hh> 47 #include <G4UIcmdWithAnInteger.hh> 48 #include <G4UIcmdWithAString.hh> 48 #include <G4UIcmdWithAString.hh> 49 #include <G4String.hh> 49 #include <G4String.hh> 50 #include "CexmcHistoManagerMessenger.hh" 50 #include "CexmcHistoManagerMessenger.hh" 51 #include "CexmcHistoManager.hh" 51 #include "CexmcHistoManager.hh" 52 #include "CexmcMessenger.hh" 52 #include "CexmcMessenger.hh" 53 53 54 54 55 CexmcHistoManagerMessenger::CexmcHistoManagerM 55 CexmcHistoManagerMessenger::CexmcHistoManagerMessenger( 56 CexmcH << 56 CexmcHistoManager * histoManager ) : 57 histoManager( histoManager_ ), setVerboseL << 57 histoManager( histoManager ), setVerboseLevel( NULL ), listHistos( NULL ), 58 printHisto( NULL ) 58 printHisto( NULL ) 59 #ifdef CEXMC_USE_ROOTQT 59 #ifdef CEXMC_USE_ROOTQT 60 , drawHisto( NULL ), addHistoMenu( NULL ), 60 , drawHisto( NULL ), addHistoMenu( NULL ), drawHistoOptions1D( NULL ), 61 drawHistoOptions2D( NULL ), drawHistoOptio 61 drawHistoOptions2D( NULL ), drawHistoOptions3D( NULL ) 62 #endif 62 #endif 63 { 63 { 64 setVerboseLevel = new G4UIcmdWithAnInteger 64 setVerboseLevel = new G4UIcmdWithAnInteger( 65 ( CexmcMessenger::histoDirName + "verb 65 ( CexmcMessenger::histoDirName + "verbose" ).c_str(), this ); 66 setVerboseLevel->SetGuidance( "0 - basic s 66 setVerboseLevel->SetGuidance( "0 - basic set of histograms created, " 67 "1 - extra h 67 "1 - extra histograms created" ); 68 setVerboseLevel->SetParameterName( "Verbos 68 setVerboseLevel->SetParameterName( "Verbose", true ); 69 setVerboseLevel->SetDefaultValue( 0 ); 69 setVerboseLevel->SetDefaultValue( 0 ); 70 setVerboseLevel->AvailableForStates( G4Sta 70 setVerboseLevel->AvailableForStates( G4State_PreInit ); 71 71 72 listHistos = new G4UIcmdWithoutParameter( 72 listHistos = new G4UIcmdWithoutParameter( 73 ( CexmcMessenger::histoDirName + "list 73 ( CexmcMessenger::histoDirName + "list" ).c_str(), this ); 74 listHistos->SetGuidance( "List available h 74 listHistos->SetGuidance( "List available histograms" ); 75 listHistos->AvailableForStates( G4State_Pr 75 listHistos->AvailableForStates( G4State_PreInit, G4State_Idle ); 76 76 77 printHisto = new G4UIcmdWithAString( 77 printHisto = new G4UIcmdWithAString( 78 ( CexmcMessenger::histoDirName + "prin 78 ( CexmcMessenger::histoDirName + "print" ).c_str(), this ); 79 printHisto->SetGuidance( "Print specified 79 printHisto->SetGuidance( "Print specified histogram" ); 80 printHisto->SetParameterName( "PrintHisto" 80 printHisto->SetParameterName( "PrintHisto", false ); 81 printHisto->AvailableForStates( G4State_Id 81 printHisto->AvailableForStates( G4State_Idle ); 82 82 83 #ifdef CEXMC_USE_ROOTQT 83 #ifdef CEXMC_USE_ROOTQT 84 drawHisto = new G4UIcmdWithAString( 84 drawHisto = new G4UIcmdWithAString( 85 ( CexmcMessenger::histoDirName + "draw 85 ( CexmcMessenger::histoDirName + "draw" ).c_str(), this ); 86 drawHisto->SetGuidance( "Draw specified hi 86 drawHisto->SetGuidance( "Draw specified histogram. The first parameter is\n" 87 " the histogram 87 " the histogram name, the rest is draw " 88 "options.\n Ava 88 "options.\n Available only if the program was " 89 "launched\n in 89 "launched\n in graphical mode" ); 90 drawHisto->SetParameterName( "DrawHisto", 90 drawHisto->SetParameterName( "DrawHisto", false ); 91 drawHisto->AvailableForStates( G4State_Idl 91 drawHisto->AvailableForStates( G4State_Idle ); 92 92 93 addHistoMenu = new G4UIcmdWithAString( 93 addHistoMenu = new G4UIcmdWithAString( 94 ( CexmcMessenger::histoDirName + "addH 94 ( CexmcMessenger::histoDirName + "addHistoMenu" ).c_str(), this ); 95 addHistoMenu->SetGuidance( "Add histogram 95 addHistoMenu->SetGuidance( "Add histogram menu in GUI menu bar. The first " 96 "parameter is\n 96 "parameter is\n the menu handle, the rest is " 97 "the menu label 97 "the menu label.\n The menu cannot be added " 98 "or disabled in 98 "or disabled in runtime" ); 99 addHistoMenu->SetParameterName( "AddHistoM 99 addHistoMenu->SetParameterName( "AddHistoMenu", true ); 100 addHistoMenu->AvailableForStates( G4State_ 100 addHistoMenu->AvailableForStates( G4State_Idle ); 101 101 102 drawHistoOptions1D = new G4UIcmdWithAStrin 102 drawHistoOptions1D = new G4UIcmdWithAString( 103 ( CexmcMessenger::histoDirName + "draw 103 ( CexmcMessenger::histoDirName + "drawOptions1D" ).c_str(), this ); 104 drawHistoOptions1D->SetGuidance( "Set draw 104 drawHistoOptions1D->SetGuidance( "Set draw options for 1D histograms drawn " 105 "from the 105 "from the menu.\n The options cannot " 106 "be chang 106 "be changed after the menu was built"); 107 drawHistoOptions1D->SetParameterName( "Dra 107 drawHistoOptions1D->SetParameterName( "DrawOptions1D", false ); 108 drawHistoOptions1D->AvailableForStates( G4 108 drawHistoOptions1D->AvailableForStates( G4State_Idle ); 109 109 110 drawHistoOptions2D = new G4UIcmdWithAStrin 110 drawHistoOptions2D = new G4UIcmdWithAString( 111 ( CexmcMessenger::histoDirName + "draw 111 ( CexmcMessenger::histoDirName + "drawOptions2D" ).c_str(), this ); 112 drawHistoOptions2D->SetGuidance( "Set draw 112 drawHistoOptions2D->SetGuidance( "Set draw options for 2D histograms drawn " 113 "from the 113 "from the menu.\n The options cannot " 114 "be chang 114 "be changed after the menu was built"); 115 drawHistoOptions2D->SetParameterName( "Dra 115 drawHistoOptions2D->SetParameterName( "DrawOptions2D", false ); 116 drawHistoOptions2D->AvailableForStates( G4 116 drawHistoOptions2D->AvailableForStates( G4State_Idle ); 117 117 118 drawHistoOptions3D = new G4UIcmdWithAStrin 118 drawHistoOptions3D = new G4UIcmdWithAString( 119 ( CexmcMessenger::histoDirName + "draw 119 ( CexmcMessenger::histoDirName + "drawOptions3D" ).c_str(), this ); 120 drawHistoOptions3D->SetGuidance( "Set draw 120 drawHistoOptions3D->SetGuidance( "Set draw options for 3D histograms drawn " 121 "from the 121 "from the menu.\n The options cannot " 122 "be chang 122 "be changed after the menu was built"); 123 drawHistoOptions3D->SetParameterName( "Dra 123 drawHistoOptions3D->SetParameterName( "DrawOptions3D", false ); 124 drawHistoOptions3D->AvailableForStates( G4 124 drawHistoOptions3D->AvailableForStates( G4State_Idle ); 125 #endif 125 #endif 126 } 126 } 127 127 128 128 129 CexmcHistoManagerMessenger::~CexmcHistoManager 129 CexmcHistoManagerMessenger::~CexmcHistoManagerMessenger() 130 { 130 { 131 delete setVerboseLevel; 131 delete setVerboseLevel; 132 delete listHistos; 132 delete listHistos; 133 delete printHisto; 133 delete printHisto; 134 #ifdef CEXMC_USE_ROOTQT 134 #ifdef CEXMC_USE_ROOTQT 135 delete drawHisto; 135 delete drawHisto; 136 delete addHistoMenu; 136 delete addHistoMenu; 137 delete drawHistoOptions1D; 137 delete drawHistoOptions1D; 138 delete drawHistoOptions2D; 138 delete drawHistoOptions2D; 139 delete drawHistoOptions3D; 139 delete drawHistoOptions3D; 140 #endif 140 #endif 141 } 141 } 142 142 143 143 144 void CexmcHistoManagerMessenger::SetNewValue( 144 void CexmcHistoManagerMessenger::SetNewValue( G4UIcommand * cmd, 145 145 G4String value ) 146 { 146 { 147 do 147 do 148 { 148 { 149 if ( cmd == setVerboseLevel ) 149 if ( cmd == setVerboseLevel ) 150 { 150 { 151 histoManager->SetVerboseLevel( 151 histoManager->SetVerboseLevel( 152 G4UIcmdWithAnI 152 G4UIcmdWithAnInteger::GetNewIntValue( value ) ); 153 break; 153 break; 154 } 154 } 155 if ( cmd == listHistos ) 155 if ( cmd == listHistos ) 156 { 156 { 157 histoManager->List(); 157 histoManager->List(); 158 break; 158 break; 159 } 159 } 160 if ( cmd == printHisto ) 160 if ( cmd == printHisto ) 161 { 161 { 162 histoManager->Print( value ); 162 histoManager->Print( value ); 163 break; 163 break; 164 } 164 } 165 #ifdef CEXMC_USE_ROOTQT 165 #ifdef CEXMC_USE_ROOTQT 166 if ( cmd == drawHisto ) 166 if ( cmd == drawHisto ) 167 { 167 { 168 size_t delimPos( value.find_first 168 size_t delimPos( value.find_first_of( " \t" ) ); 169 size_t delimPosEnd( G4String::npo 169 size_t delimPosEnd( G4String::npos ); 170 if ( delimPos != G4String::npos ) 170 if ( delimPos != G4String::npos ) 171 delimPosEnd = value.find_first 171 delimPosEnd = value.find_first_not_of( " \t", delimPos ); 172 histoManager->Draw( std::string( v 172 histoManager->Draw( std::string( value, 0, delimPos ), 173 delimPosEnd == 173 delimPosEnd == G4String::npos ? "" : 174 174 value.c_str() + delimPosEnd ); 175 break; 175 break; 176 } 176 } 177 if ( cmd == addHistoMenu ) 177 if ( cmd == addHistoMenu ) 178 { 178 { 179 size_t delimPos( value.find_first 179 size_t delimPos( value.find_first_of( " \t" ) ); 180 size_t delimPosEnd( G4String::npo 180 size_t delimPosEnd( G4String::npos ); 181 if ( delimPos != G4String::npos ) 181 if ( delimPos != G4String::npos ) 182 delimPosEnd = value.find_first 182 delimPosEnd = value.find_first_not_of( " \t", delimPos ); 183 histoManager->AddHistoMenu( std::s 183 histoManager->AddHistoMenu( std::string( value, 0, delimPos ), 184 delimP 184 delimPosEnd == G4String::npos ? "" : 185 185 value.c_str() + delimPosEnd ); 186 break; 186 break; 187 } 187 } 188 if ( cmd == drawHistoOptions1D ) 188 if ( cmd == drawHistoOptions1D ) 189 { 189 { 190 histoManager->SetDrawOptions1D( va 190 histoManager->SetDrawOptions1D( value ); 191 break; 191 break; 192 } 192 } 193 if ( cmd == drawHistoOptions2D ) 193 if ( cmd == drawHistoOptions2D ) 194 { 194 { 195 histoManager->SetDrawOptions2D( va 195 histoManager->SetDrawOptions2D( value ); 196 break; 196 break; 197 } 197 } 198 if ( cmd == drawHistoOptions3D ) 198 if ( cmd == drawHistoOptions3D ) 199 { 199 { 200 histoManager->SetDrawOptions3D( va 200 histoManager->SetDrawOptions3D( value ); 201 break; 201 break; 202 } 202 } 203 #endif 203 #endif 204 } while ( false ); 204 } while ( false ); 205 } 205 } 206 206 207 #endif 207 #endif 208 208 209 209