Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4PlotMessenger Class Reference

#include <G4PlotMessenger.hh>

Inheritance diagram for G4PlotMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4PlotMessenger ()=delete
 
 G4PlotMessenger (G4PlotParameters *plotParameters)
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool operator== (const G4UImessenger &messenger) const
 
virtual void SetNewValue (G4UIcommand *command, G4String value) final
 
virtual ~G4PlotMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 46 of file G4PlotMessenger.hh.

Constructor & Destructor Documentation

◆ G4PlotMessenger() [1/2]

G4PlotMessenger::G4PlotMessenger ( G4PlotParameters plotParameters)
explicit

Definition at line 46 of file G4PlotMessenger.cc.

47 : G4UImessenger(),
48 fPlotParameters(plotParameters)
49{
50 fHelper = std::make_unique<G4AnalysisMessengerHelper>("plot");
51
52 fDirectory = fHelper->CreateHnDirectory();
53
57}
std::unique_ptr< G4AnalysisMessengerHelper > fHelper
G4PlotParameters * fPlotParameters
Associated class.
std::unique_ptr< G4UIdirectory > fDirectory

References fDirectory, fHelper, SetDimensionsCmd(), SetLayoutCmd(), and SetStyleCmd().

◆ G4PlotMessenger() [2/2]

G4PlotMessenger::G4PlotMessenger ( )
delete

◆ ~G4PlotMessenger()

G4PlotMessenger::~G4PlotMessenger ( )
virtualdefault

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger::G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4UImessenger::GetCurrentValue ( G4UIcommand command)
virtualinherited

Reimplemented in G4ScoreQuantityMessenger, G4VisCommandModelCreate< Factory >, G4VisCommandListManagerList< Manager >, G4VisCommandListManagerSelect< Manager >, G4VisCommandManagerMode< Manager >, G4ToolsAnalysisMessenger, G4ScoringMessenger, G4EvManMessenger, G4GeneralParticleSourceMessenger, G4ParticleGunMessenger, G4GeometryMessenger, G4GenericMessenger, G4UIcontrolMessenger, GFlashShowerModelMessenger, G4DecayTableMessenger, G4ParticleMessenger, G4ParticlePropertyMessenger, G4tgrMessenger, G4PersistencyCenterMessenger, G4ProductionCutsTableMessenger, G4SchedulerMessenger, G4VITSteppingVerbose, G4MoleculeShootMessenger, G4MoleculeGunMessenger, G4ProcessManagerMessenger, G4ProcessTableMessenger, G4MatScanMessenger, G4RunMessenger, G4UserPhysicsListMessenger, G4TrackingMessenger, G4GMocrenMessenger, G4HepRepMessenger, G4VisCommandAbortReviewKeptEvents, G4VisCommandDrawOnlyToBeKeptEvents, G4VisCommandEnable, G4VisCommandList, G4VisCommandReviewKeptEvents, G4VisCommandVerbose, G4VisCommandGeometryList, G4VisCommandGeometryRestore, G4VisCommandGeometrySetColour, G4VisCommandGeometrySetDaughtersInvisible, G4VisCommandGeometrySetForceAuxEdgeVisible, G4VisCommandGeometrySetForceCloud, G4VisCommandGeometrySetForceSolid, G4VisCommandGeometrySetForceLineSegmentsPerCircle, G4VisCommandGeometrySetForceWireframe, G4VisCommandGeometrySetLineStyle, G4VisCommandGeometrySetLineWidth, G4VisCommandGeometrySetVisibility, G4VisCommandSceneActivateModel, G4VisCommandSceneCreate, G4VisCommandSceneEndOfEventAction, G4VisCommandSceneEndOfRunAction, G4VisCommandSceneList, G4VisCommandSceneNotifyHandlers, G4VisCommandSceneRemoveModel, G4VisCommandSceneSelect, G4VisCommandSceneShowExtents, G4VisCommandSceneAddArrow, G4VisCommandSceneAddArrow2D, G4VisCommandSceneAddAxes, G4VisCommandSceneAddDate, G4VisCommandSceneAddDigis, G4VisCommandSceneAddEventID, G4VisCommandSceneAddExtent, G4VisCommandSceneAddElectricField, G4VisCommandSceneAddFrame, G4VisCommandSceneAddGPS, G4VisCommandSceneAddGhosts, G4VisCommandSceneAddHits, G4VisCommandSceneAddLine, G4VisCommandSceneAddLine2D, G4VisCommandSceneAddLocalAxes, G4VisCommandSceneAddLogicalVolume, G4VisCommandSceneAddLogo, G4VisCommandSceneAddLogo2D, G4VisCommandSceneAddMagneticField, G4VisCommandSceneAddPSHits, G4VisCommandSceneAddScale, G4VisCommandSceneAddText, G4VisCommandSceneAddText2D, G4VisCommandSceneAddTrajectories, G4VisCommandSceneAddUserAction, G4VisCommandSceneAddVolume, G4VisCommandSceneAddPlotter, G4VisCommandSceneHandlerAttach, G4VisCommandSceneHandlerCreate, G4VisCommandSceneHandlerList, G4VisCommandSceneHandlerSelect, G4VisCommandSetArrow3DLineSegmentsPerCircle, G4VisCommandSetColour, G4VisCommandSetExtentForField, G4VisCommandSetLineWidth, G4VisCommandSetTextColour, G4VisCommandSetTextLayout, G4VisCommandSetTextSize, G4VisCommandSetTouchable, G4VisCommandSetVolumeForField, G4VisCommandsTouchable, G4VisCommandsTouchableSet, G4VisCommandViewerAddCutawayPlane, G4VisCommandViewerCentreOn, G4VisCommandViewerChangeCutawayPlane, G4VisCommandViewerClear, G4VisCommandViewerClearCutawayPlanes, G4VisCommandViewerClearTransients, G4VisCommandViewerClearVisAttributesModifiers, G4VisCommandViewerClone, G4VisCommandViewerColourByDensity, G4VisCommandViewerCopyViewFrom, G4VisCommandViewerCreate, G4VisCommandViewerDolly, G4VisCommandViewerFlush, G4VisCommandViewerInterpolate, G4VisCommandViewerList, G4VisCommandViewerPan, G4VisCommandViewerReset, G4VisCommandViewerRefresh, G4VisCommandViewerRebuild, G4VisCommandViewerSave, G4VisCommandViewerScale, G4VisCommandViewerSelect, G4VisCommandViewerUpdate, G4VisCommandViewerZoom, G4VisCommandViewerDefaultHiddenEdge, G4VisCommandViewerDefaultStyle, G4VisCommandsViewerSet, G4VModelCommand< T >, G4VModelCommand< M >, G4RTMessenger, G4ASCIITreeMessenger, G4VtkMessenger, G4PolarizationMessenger, and G4DNAChemistryManager.

Definition at line 58 of file G4UImessenger.cc.

59{
60 G4String nullString;
61 return nullString;
62}

Referenced by G4UIcommand::DoIt(), and G4UIcommand::GetCurrentValue().

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and G4ParticleGunMessenger::GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ SetDimensionsCmd()

void G4PlotMessenger::SetDimensionsCmd ( )
private

Definition at line 124 of file G4PlotMessenger.cc.

125{
126 auto width = new G4UIparameter("width", 'i', false);
127 width->SetGuidance("The page width.");
128
129 auto height = new G4UIparameter("height", 'i', false);
130 height->SetGuidance("The page height.");
131
132 fSetDimensionsCmd = std::make_unique<G4UIcommand>("/analysis/plot/setDimensions", this);
133 fSetDimensionsCmd->SetGuidance("Set the plotter window size (width and height) in pixels.");
134 fSetDimensionsCmd->SetParameter(width);
135 fSetDimensionsCmd->SetParameter(height);
136 fSetDimensionsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
137}
@ G4State_Idle
@ G4State_PreInit
std::unique_ptr< G4UIcommand > fSetDimensionsCmd

References fSetDimensionsCmd, G4State_Idle, and G4State_PreInit.

Referenced by G4PlotMessenger().

◆ SetLayoutCmd()

void G4PlotMessenger::SetLayoutCmd ( )
private

Definition at line 87 of file G4PlotMessenger.cc.

88{
89 auto columns = new G4UIparameter("columns", 'i', false);
90 columns->SetGuidance("The number of columns in the page layout.");
91 G4String range = "columns>=1 && columns<=";
92 auto maxColumns = fPlotParameters->GetMaxColumns();
93 range.append(to_string(maxColumns));
94 columns->SetParameterRange(range);
95
96 auto rows = new G4UIparameter("rows", 'i', false);
97 rows->SetGuidance("The number of rows in the page layout.");
98 range = "rows>=1 && rows<=";
99 auto maxRows = fPlotParameters->GetMaxRows();
100 range.append(to_string(maxRows));
101 rows->SetParameterRange(range);
102
103 fSetLayoutCmd = std::make_unique<G4UIcommand>("/analysis/plot/setLayout", this);
104 // Guidance text:
105 // Set page layout (number of columns and rows per page).
106 // Supported layouts:
107 // columns = 1 .. maxValueAllowed
108 // rows = 1 .. maxValueAllowed, and >= columns
109 fSetLayoutCmd->SetGuidance("Set page layout (number of columns and rows per page).");
110 fSetLayoutCmd->SetGuidance(" Supported layouts: ");
111 G4String guidance = " columns = 1 .. ";
112 guidance.append(to_string(maxColumns));
113 fSetLayoutCmd->SetGuidance(guidance);
114 guidance = " rows = 1 .. ";
115 guidance.append(to_string(maxRows));
116 guidance.append(" and >= columns");
117 fSetLayoutCmd->SetGuidance(guidance);
118 fSetLayoutCmd->SetParameter(columns);
119 fSetLayoutCmd->SetParameter(rows);
120 fSetLayoutCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
121}
std::unique_ptr< G4UIcommand > fSetLayoutCmd

References fPlotParameters, fSetLayoutCmd, G4State_Idle, G4State_PreInit, G4PlotParameters::GetMaxColumns(), and G4PlotParameters::GetMaxRows().

Referenced by G4PlotMessenger().

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 144 of file G4PlotMessenger.cc.

145{
146 // tokenize parameters in a vector
147 std::vector<G4String> parameters;
148 G4Analysis::Tokenize(newValues, parameters);
149 // check consistency
150 if ( parameters.size() != command->GetParameterEntries() ) {
151 // Should never happen but let's check anyway for consistency
152 fHelper->WarnAboutParameters(command, parameters.size());
153 return;
154 }
155
156 if ( command == fSetLayoutCmd.get() ) {
157 auto counter = 0;
158 auto columns = G4UIcommand::ConvertToInt(parameters[counter++]);
159 auto rows = G4UIcommand::ConvertToInt(parameters[counter++]);
160 fPlotParameters->SetLayout(columns, rows);
161 }
162 else if ( command == fSetDimensionsCmd.get() ) {
163 auto counter = 0;
164 auto width = G4UIcommand::ConvertToInt(parameters[counter++]);
165 auto height = G4UIcommand::ConvertToInt(parameters[counter++]);
166 fPlotParameters->SetDimensions(width, height);
167 }
168#if defined(TOOLS_USE_FREETYPE)
169 else if ( command == fSetStyleCmd.get() ) {
170 fPlotParameters->SetStyle(newValues);
171 }
172#endif
173}
std::unique_ptr< G4UIcmdWithAString > fSetStyleCmd
void SetLayout(G4int columns, G4int rows)
void SetDimensions(G4int width, G4int height)
void SetStyle(const G4String &style)
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:138
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:557
void Tokenize(const G4String &line, std::vector< G4String > &tokens)

References G4UIcommand::ConvertToInt(), fHelper, fPlotParameters, fSetDimensionsCmd, fSetLayoutCmd, fSetStyleCmd, G4UIcommand::GetParameterEntries(), G4PlotParameters::SetDimensions(), G4PlotParameters::SetLayout(), G4PlotParameters::SetStyle(), and G4Analysis::Tokenize().

◆ SetStyleCmd()

void G4PlotMessenger::SetStyleCmd ( )
private

Definition at line 67 of file G4PlotMessenger.cc.

68{
69 fSetStyleCmd = std::make_unique<G4UIcmdWithAString>("/analysis/plot/setStyle",this);
70#if defined(TOOLS_USE_FREETYPE)
71 fSetStyleCmd->SetGuidance("Set plotting style from: ");
72 fSetStyleCmd->SetGuidance(" ROOT_default: ROOT style with high resolution fonts");
73 fSetStyleCmd->SetGuidance(" hippodraw: hippodraw style with high resolution fonts");
74 fSetStyleCmd->SetGuidance(" inlib_default: PAW style with low resolution fonts");
75 fSetStyleCmd->SetParameterName("Style", false);
76#else
77 fSetStyleCmd->SetGuidance("Only one plotting style is available in low resolution: ");
78 fSetStyleCmd->SetGuidance(" inlib_default: PAW style with low resolution fonts");
79 fSetStyleCmd->SetParameterName("Style", false);
80 fSetStyleCmd->SetCandidates("inlib_default");
81#endif
83 fSetStyleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
84}
G4String GetAvailableStyles()

References fPlotParameters, fSetStyleCmd, G4State_Idle, G4State_PreInit, and G4PlotParameters::GetAvailableStyles().

Referenced by G4PlotMessenger().

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
bool G4bool
Definition: G4Types.hh:86
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by G4LocalThreadCoutMessenger::SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ fDirectory

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

Definition at line 63 of file G4PlotMessenger.hh.

Referenced by G4PlotMessenger().

◆ fHelper

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

Definition at line 62 of file G4PlotMessenger.hh.

Referenced by G4PlotMessenger(), and SetNewValue().

◆ fPlotParameters

G4PlotParameters* G4PlotMessenger::fPlotParameters { nullptr }
private

Associated class.

Definition at line 61 of file G4PlotMessenger.hh.

Referenced by SetLayoutCmd(), SetNewValue(), and SetStyleCmd().

◆ fSetDimensionsCmd

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

Definition at line 66 of file G4PlotMessenger.hh.

Referenced by SetDimensionsCmd(), and SetNewValue().

◆ fSetLayoutCmd

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

Definition at line 65 of file G4PlotMessenger.hh.

Referenced by SetLayoutCmd(), and SetNewValue().

◆ fSetStyleCmd

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

Definition at line 67 of file G4PlotMessenger.hh.

Referenced by SetNewValue(), and SetStyleCmd().


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