Geant4  10.02.p03
G4PlotMessenger Class Reference

#include <G4PlotMessenger.hh>

Inheritance diagram for G4PlotMessenger:
Collaboration diagram for G4PlotMessenger:

Public Member Functions

 G4PlotMessenger (G4PlotParameters *plotParameters)
 
virtual ~G4PlotMessenger ()
 
virtual void SetNewValue (G4UIcommand *command, G4String value) final
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Private Member Functions

void SetStyleCmd ()
 
void SetLayoutCmd ()
 
void SetDimensionsCmd ()
 

Private Attributes

G4PlotParametersfPlotParameters
 Associated class. More...
 
std::unique_ptr< G4AnalysisMessengerHelperfHelper
 
std::unique_ptr< G4UIdirectoryfDirectory
 
std::unique_ptr< G4UIcommandfSetLayoutCmd
 
std::unique_ptr< G4UIcommandfSetDimensionsCmd
 
std::unique_ptr< G4UIcmdWithAStringfSetStyleCmd
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 
G4bool commandsShouldBeInMaster
 

Detailed Description

Definition at line 47 of file G4PlotMessenger.hh.

Constructor & Destructor Documentation

◆ G4PlotMessenger()

G4PlotMessenger::G4PlotMessenger ( G4PlotParameters plotParameters)
explicit

Definition at line 48 of file G4PlotMessenger.cc.

49  : G4UImessenger(),
50  fPlotParameters(plotParameters),
51  fHelper(nullptr),
52  fDirectory(nullptr),
53  fSetLayoutCmd(nullptr),
54  fSetDimensionsCmd(nullptr),
55  fSetStyleCmd(nullptr)
56 {
57  fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("plot");
58 
59  fDirectory = fHelper->CreateHnDirectory();
60 
61  SetStyleCmd();
62  SetLayoutCmd();
64 }
std::unique_ptr< G4UIcmdWithAString > fSetStyleCmd
std::unique_ptr< G4UIcommand > fSetLayoutCmd
G4PlotParameters * fPlotParameters
Associated class.
std::unique_ptr< G4AnalysisMessengerHelper > fHelper
std::unique_ptr< G4UIcommand > fSetDimensionsCmd
std::unique_ptr< G4UIdirectory > fDirectory
Here is the call graph for this function:

◆ ~G4PlotMessenger()

G4PlotMessenger::~G4PlotMessenger ( )
virtual

Definition at line 67 of file G4PlotMessenger.cc.

68 {}

Member Function Documentation

◆ SetDimensionsCmd()

void G4PlotMessenger::SetDimensionsCmd ( )
private

Definition at line 134 of file G4PlotMessenger.cc.

135 {
136  auto width = new G4UIparameter("width", 'i', false);
137  width->SetGuidance("The page width.");
138 
139  auto height = new G4UIparameter("height", 'i', false);
140  height->SetGuidance("The page height.");
141 
142  fSetDimensionsCmd = G4Analysis::make_unique<G4UIcommand>("/analysis/plot/setDimensions", this);
143  fSetDimensionsCmd->SetGuidance("Set the plotter window size (width and height) in pixels.");
144  fSetDimensionsCmd->SetParameter(width);
145  fSetDimensionsCmd->SetParameter(height);
146  fSetDimensionsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
147 }
#define width
std::unique_ptr< G4UIcommand > fSetDimensionsCmd
Here is the caller graph for this function:

◆ SetLayoutCmd()

void G4PlotMessenger::SetLayoutCmd ( )
private

Definition at line 95 of file G4PlotMessenger.cc.

96 {
97  auto columns = new G4UIparameter("columns", 'i', false);
98  columns->SetGuidance("The number of columns in the page layout.");
99  G4String range = "columns>=1 && columns<=";
100  std::ostringstream osMaxColumns;
101  osMaxColumns << fPlotParameters->GetMaxColumns();
102  range.append(osMaxColumns.str());
103  columns->SetParameterRange(range);
104 
105  auto rows = new G4UIparameter("rows", 'i', false);
106  rows->SetGuidance("The number of rows in the page layout.");
107  range = "rows>=1 && rows<=";
108  std::ostringstream osMaxRows;
109  osMaxRows << fPlotParameters->GetMaxRows();
110  range.append(osMaxRows.str());
111  rows->SetParameterRange(range);
112 
113  fSetLayoutCmd = G4Analysis::make_unique<G4UIcommand>("/analysis/plot/setLayout", this);
114  // Guidance text:
115  // Set page layout (number of columns and rows per page).
116  // Suported layouts:
117  // columns = 1 .. maxValueAllowed
118  // rows = 1 .. maxValueAllowed, and >= columns
119  fSetLayoutCmd->SetGuidance("Set page layout (number of columns and rows per page).");
120  fSetLayoutCmd->SetGuidance(" Suported layouts: ");
121  G4String guidance = " columns = 1 .. ";
122  guidance.append(osMaxColumns.str());
123  fSetLayoutCmd->SetGuidance(guidance);
124  guidance = " rows = 1 .. ";
125  guidance.append(osMaxRows.str());
126  guidance.append(" and >= columns");
127  fSetLayoutCmd->SetGuidance(guidance);
128  fSetLayoutCmd->SetParameter(columns);
129  fSetLayoutCmd->SetParameter(rows);
130  fSetLayoutCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
131 }
std::unique_ptr< G4UIcommand > fSetLayoutCmd
G4PlotParameters * fPlotParameters
Associated class.
G4String & append(const G4String &)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetNewValue()

void G4PlotMessenger::SetNewValue ( G4UIcommand command,
G4String  value 
)
finalvirtual

Reimplemented from G4UImessenger.

Definition at line 154 of file G4PlotMessenger.cc.

155 {
156  // tokenize parameters in a vector
157  std::vector<G4String> parameters;
158  G4Analysis::Tokenize(newValues, parameters);
159  // check consistency
160  if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
161  // Should never happen but let's check anyway for consistency
162  fHelper->WarnAboutParameters(command, parameters.size());
163  return;
164  }
165 
166  if ( command == fSetLayoutCmd.get() ) {
167  auto counter = 0;
168  auto columns = G4UIcommand::ConvertToInt(parameters[counter++]);
169  auto rows = G4UIcommand::ConvertToInt(parameters[counter++]);
170  fPlotParameters->SetLayout(columns, rows);
171  }
172  else if ( command == fSetDimensionsCmd.get() ) {
173  auto counter = 0;
174  auto width = G4UIcommand::ConvertToInt(parameters[counter++]);
175  auto height = G4UIcommand::ConvertToInt(parameters[counter++]);
177  }
178 #if defined(TOOLS_USE_FREETYPE)
179  else if ( command == fSetStyleCmd.get() ) {
180  fPlotParameters->SetStyle(newValues);
181  }
182 #endif
183 }
std::unique_ptr< G4UIcmdWithAString > fSetStyleCmd
std::unique_ptr< G4UIcommand > fSetLayoutCmd
#define width
G4PlotParameters * fPlotParameters
Associated class.
std::unique_ptr< G4AnalysisMessengerHelper > fHelper
int G4int
Definition: G4Types.hh:78
std::unique_ptr< G4UIcommand > fSetDimensionsCmd
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
void SetLayout(G4int columns, G4int rows)
void SetDimensions(G4int width, G4int height)
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
void SetStyle(const G4String &style)
Here is the call graph for this function:

◆ SetStyleCmd()

void G4PlotMessenger::SetStyleCmd ( )
private

Definition at line 75 of file G4PlotMessenger.cc.

76 {
77  fSetStyleCmd = G4Analysis::make_unique<G4UIcmdWithAString>("/analysis/plot/setStyle",this);
78 #if defined(TOOLS_USE_FREETYPE)
79  fSetStyleCmd->SetGuidance("Set plotting style from: ");
80  fSetStyleCmd->SetGuidance(" ROOT_default: ROOT style with high resolution fonts");
81  fSetStyleCmd->SetGuidance(" hippodraw: hippodraw style with high resolution fonts");
82  fSetStyleCmd->SetGuidance(" inlib_default: PAW style with low resolution fonts");
83  fSetStyleCmd->SetParameterName("Style", false);
84 #else
85  fSetStyleCmd->SetGuidance("Only one plotting style is available in low resolution: ");
86  fSetStyleCmd->SetGuidance(" inlib_default: PAW style with low resolution fonts");
87  fSetStyleCmd->SetParameterName("Style", false);
88  fSetStyleCmd->SetCandidates("inlib_default");
89 #endif
91  fSetStyleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
92 }
G4String GetAvailableStyles()
std::unique_ptr< G4UIcmdWithAString > fSetStyleCmd
G4PlotParameters * fPlotParameters
Associated class.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fDirectory

std::unique_ptr<G4UIdirectory> G4PlotMessenger::fDirectory
private

Definition at line 63 of file G4PlotMessenger.hh.

◆ fHelper

std::unique_ptr<G4AnalysisMessengerHelper> G4PlotMessenger::fHelper
private

Definition at line 62 of file G4PlotMessenger.hh.

◆ fPlotParameters

G4PlotParameters* G4PlotMessenger::fPlotParameters
private

Associated class.

Definition at line 61 of file G4PlotMessenger.hh.

◆ fSetDimensionsCmd

std::unique_ptr<G4UIcommand> G4PlotMessenger::fSetDimensionsCmd
private

Definition at line 66 of file G4PlotMessenger.hh.

◆ fSetLayoutCmd

std::unique_ptr<G4UIcommand> G4PlotMessenger::fSetLayoutCmd
private

Definition at line 65 of file G4PlotMessenger.hh.

◆ fSetStyleCmd

std::unique_ptr<G4UIcmdWithAString> G4PlotMessenger::fSetStyleCmd
private

Definition at line 67 of file G4PlotMessenger.hh.


The documentation for this class was generated from the following files: