49 #include <G4String.hh>
55 CexmcHistoManagerMessenger::CexmcHistoManagerMessenger(
56 CexmcHistoManager * histoManager_ ) :
57 histoManager( histoManager_ ), setVerboseLevel( NULL ), listHistos( NULL ),
59 #ifdef CEXMC_USE_ROOTQT
60 , drawHisto( NULL ), addHistoMenu( NULL ), drawHistoOptions1D( NULL ),
61 drawHistoOptions2D( NULL ), drawHistoOptions3D( NULL )
65 ( CexmcMessenger::histoDirName +
"verbose" ).c_str(),
this );
66 setVerboseLevel->SetGuidance(
"0 - basic set of histograms created, "
67 "1 - extra histograms created" );
68 setVerboseLevel->SetParameterName(
"Verbose",
true );
69 setVerboseLevel->SetDefaultValue( 0 );
73 ( CexmcMessenger::histoDirName +
"list" ).c_str(),
this );
74 listHistos->SetGuidance(
"List available histograms" );
78 ( CexmcMessenger::histoDirName +
"print" ).c_str(),
this );
79 printHisto->SetGuidance(
"Print specified histogram" );
80 printHisto->SetParameterName(
"PrintHisto",
false );
83 #ifdef CEXMC_USE_ROOTQT
85 ( CexmcMessenger::histoDirName +
"draw" ).c_str(),
this );
86 drawHisto->SetGuidance(
"Draw specified histogram. The first parameter is\n"
87 " the histogram name, the rest is draw "
88 "options.\n Available only if the program was "
89 "launched\n in graphical mode" );
90 drawHisto->SetParameterName(
"DrawHisto",
false );
94 ( CexmcMessenger::histoDirName +
"addHistoMenu" ).c_str(),
this );
95 addHistoMenu->SetGuidance(
"Add histogram menu in GUI menu bar. The first "
96 "parameter is\n the menu handle, the rest is "
97 "the menu label.\n The menu cannot be added "
98 "or disabled in runtime" );
99 addHistoMenu->SetParameterName(
"AddHistoMenu",
true );
103 ( CexmcMessenger::histoDirName +
"drawOptions1D" ).c_str(),
this );
104 drawHistoOptions1D->SetGuidance(
"Set draw options for 1D histograms drawn "
105 "from the menu.\n The options cannot "
106 "be changed after the menu was built");
107 drawHistoOptions1D->SetParameterName(
"DrawOptions1D",
false );
111 ( CexmcMessenger::histoDirName +
"drawOptions2D" ).c_str(),
this );
112 drawHistoOptions2D->SetGuidance(
"Set draw options for 2D histograms drawn "
113 "from the menu.\n The options cannot "
114 "be changed after the menu was built");
115 drawHistoOptions2D->SetParameterName(
"DrawOptions2D",
false );
119 ( CexmcMessenger::histoDirName +
"drawOptions3D" ).c_str(),
this );
120 drawHistoOptions3D->SetGuidance(
"Set draw options for 3D histograms drawn "
121 "from the menu.\n The options cannot "
122 "be changed after the menu was built");
123 drawHistoOptions3D->SetParameterName(
"DrawOptions3D",
false );
129 CexmcHistoManagerMessenger::~CexmcHistoManagerMessenger()
131 delete setVerboseLevel;
134 #ifdef CEXMC_USE_ROOTQT
137 delete drawHistoOptions1D;
138 delete drawHistoOptions2D;
139 delete drawHistoOptions3D;
144 void CexmcHistoManagerMessenger::SetNewValue(
G4UIcommand * cmd,
149 if ( cmd == setVerboseLevel )
151 histoManager->SetVerboseLevel(
155 if ( cmd == listHistos )
157 histoManager->List();
160 if ( cmd == printHisto )
162 histoManager->Print( value );
165 #ifdef CEXMC_USE_ROOTQT
166 if ( cmd == drawHisto )
168 size_t delimPos( value.find_first_of(
" \t" ) );
169 size_t delimPosEnd( G4String::npos );
170 if ( delimPos != G4String::npos )
171 delimPosEnd = value.find_first_not_of(
" \t", delimPos );
172 histoManager->Draw( std::string( value, 0, delimPos ),
173 delimPosEnd == G4String::npos ?
"" :
174 value.c_str() + delimPosEnd );
177 if ( cmd == addHistoMenu )
179 size_t delimPos( value.find_first_of(
" \t" ) );
180 size_t delimPosEnd( G4String::npos );
181 if ( delimPos != G4String::npos )
182 delimPosEnd = value.find_first_not_of(
" \t", delimPos );
183 histoManager->AddHistoMenu( std::string( value, 0, delimPos ),
184 delimPosEnd == G4String::npos ?
"" :
185 value.c_str() + delimPosEnd );
188 if ( cmd == drawHistoOptions1D )
190 histoManager->SetDrawOptions1D( value );
193 if ( cmd == drawHistoOptions2D )
195 histoManager->SetDrawOptions2D( value );
198 if ( cmd == drawHistoOptions3D )
200 histoManager->SetDrawOptions3D( value );