LBNFWormPlotMessenger.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4WormPlotMessenger.cc 86973 2014-11-21 11:57:27Z gcosmo $
28 //
29 //
30 //
31 
32 #include "LBNFWormPlotMessenger.hh"
33 
34 #include "G4UIdirectory.hh"
35 
36 #include "G4UIcmdWith3Vector.hh"
37 #include "G4UIcmdWithADoubleAndUnit.hh"
38 #include "G4UIcmdWithAString.hh"
39 #include "G4ThreeVector.hh"
40 
41 #include "LBNFWormPlotter.hh"
42 
44 
46 
47  if (!fpInstance) fpInstance = new LBNFWormPlotMessenger(wPlot);
48  return fpInstance;
49 
50 }
51 
53 
54  theWorm = wPlot;
55 
56  wormDir = new G4UIdirectory("/vis/wormPlot/");
57  wormDir->SetGuidance("WormPlot commands.");
58 
59  xAxisCmd = new G4UIcmdWith3Vector("/vis/wormPlot/xAxis",this);
60  xAxisCmd->SetGuidance("Define the xAxis direction vector");
61  xAxisCmd->SetParameterName("x", "y", "z", true);
62  xAxisCmd->SetDefaultValue(G4ThreeVector(0.0, 0.0, 1.0)); // global z axis
63 
64  xNameCmd = new G4UIcmdWithAString("/vis/wormPlot/xName",this);
65  xNameCmd->SetGuidance("Define the name of the plot xAxis");
66  xNameCmd->SetParameterName("xName", true);
67  xNameCmd->SetDefaultValue("z");
68 
69  yAxisCmd = new G4UIcmdWith3Vector("/vis/wormPlot/yAxis",this);
70  yAxisCmd->SetGuidance("Define the yAxis direction vector");
71  yAxisCmd->SetParameterName("x", "y", "z", true);
72  yAxisCmd->SetDefaultValue(G4ThreeVector(0.0, 1.0, 0.0)); // global y axis
73 
74  yNameCmd = new G4UIcmdWithAString("/vis/wormPlot/yName",this);
75  yNameCmd->SetGuidance("Define the name of the plot yAxis");
76  yNameCmd->SetParameterName("yName", true);
77  yNameCmd->SetDefaultValue("y");
78 
79  xMinCmd = new G4UIcmdWithADoubleAndUnit("/vis/wormPlot/xMin",this);
80  xMinCmd->SetGuidance("Set the minimum co-ordinate for the plot's x axis");
81  xMinCmd->SetParameterName("x", true);
82  xMinCmd->SetDefaultUnit("m");
83  xMinCmd->SetDefaultValue(-1.0); // -1 m
84 
85  xMaxCmd = new G4UIcmdWithADoubleAndUnit("/vis/wormPlot/xMax",this);
86  xMaxCmd->SetGuidance("Set the maximum co-ordinate for the plot's x axis");
87  xMaxCmd->SetParameterName("x", true);
88  xMaxCmd->SetDefaultUnit("m");
89  xMaxCmd->SetDefaultValue(1.0); // 1 m
90 
91  yMinCmd = new G4UIcmdWithADoubleAndUnit("/vis/wormPlot/yMin",this);
92  yMinCmd->SetGuidance("Set the minimum co-ordinate for the plot's y axis");
93  yMinCmd->SetParameterName("y", true);
94  yMinCmd->SetDefaultUnit("m");
95  yMinCmd->SetDefaultValue(-1.0); // -1 m
96 
97  yMaxCmd = new G4UIcmdWithADoubleAndUnit("/vis/wormPlot/yMax",this);
98  yMaxCmd->SetGuidance("Set the maximum co-ordinate for the plot's y axis");
99  yMaxCmd->SetParameterName("y", true);
100  yMaxCmd->SetDefaultUnit("m");
101  yMaxCmd->SetDefaultValue(1.0); // 1 m
102 
103  z0Cmd = new G4UIcmdWithADoubleAndUnit("/vis/wormPlot/z0",this);
104  z0Cmd->SetGuidance("Set the z (third axis) co-ordinate of the plot's x-y plane position");
105  z0Cmd->SetParameterName("z", true);
106  z0Cmd->SetDefaultUnit("m");
107  z0Cmd->SetDefaultValue(0.0);
108 
109  fileCmd = new G4UIcmdWithAString("/vis/wormPlot/createPlot",this);
110  fileCmd->SetGuidance("Create the worm plot; specify the name of the output file");
111  fileCmd->SetParameterName("fileName",true);
112  fileCmd->SetDefaultValue("wormPlot.png");
113  fileCmd->AvailableForStates(G4State_Idle);
114 
115 }
116 
118 {
119  delete fileCmd;
120  delete z0Cmd;
121  delete yMaxCmd;
122  delete yMinCmd;
123  delete xMaxCmd;
124  delete xMinCmd;
125  delete yNameCmd;
126  delete yAxisCmd;
127  delete xNameCmd;
128  delete xAxisCmd;
129  delete wormDir;
130 }
131 
133 {
134 
135  G4String currentValue("");
136 
137  if (command == xAxisCmd) {
138  currentValue = xAxisCmd->ConvertToString(theWorm->GetXAxis());
139  } else if (command == yAxisCmd) {
140  currentValue = yAxisCmd->ConvertToString(theWorm->GetYAxis());
141  } else if (command == xMinCmd) {
142  currentValue = xMinCmd->ConvertToString(theWorm->GetXMin());
143  } else if (command == xMaxCmd) {
144  currentValue = xMaxCmd->ConvertToString(theWorm->GetXMax());
145  } else if (command == yMinCmd) {
146  currentValue = yMinCmd->ConvertToString(theWorm->GetYMin());
147  } else if (command == yMaxCmd) {
148  currentValue = yMaxCmd->ConvertToString(theWorm->GetYMax());
149  }
150 
151  return currentValue;
152 
153 }
154 
155 void LBNFWormPlotMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
156 {
157 
158  if (command == xAxisCmd) {
159  theWorm->SetXAxis(xAxisCmd->GetNew3VectorValue(newValue));
160  } else if (command == xNameCmd) {
161  theWorm->SetXName(newValue);
162  } else if (command == yAxisCmd) {
163  theWorm->SetYAxis(yAxisCmd->GetNew3VectorValue(newValue));
164  } else if (command == yNameCmd) {
165  theWorm->SetYName(newValue);
166  } else if (command == xMinCmd) {
167  theWorm->SetXMin(xMinCmd->GetNewDoubleValue(newValue));
168  } else if (command == xMaxCmd) {
169  theWorm->SetXMax(xMaxCmd->GetNewDoubleValue(newValue));
170  } else if (command == yMinCmd) {
171  theWorm->SetYMin(yMinCmd->GetNewDoubleValue(newValue));
172  } else if (command == yMaxCmd) {
173  theWorm->SetYMax(yMaxCmd->GetNewDoubleValue(newValue));
174  } else if (command == z0Cmd) {
175  theWorm->SetZ0(z0Cmd->GetNewDoubleValue(newValue));
176  } else if (command == fileCmd) {
177  theWorm->CreatePlot(newValue);
178  }
179 
180 }
181 
182 
183 
184 
185 
void SetYMax(const G4double &val)
LBNFWormPlotMessenger(LBNFWormPlotter *wPlot)
void SetYAxis(const G4ThreeVector &vect)
G4UIcmdWithAString * yNameCmd
void SetYMin(const G4double &val)
void CreatePlot(const G4String &fileName)
int command
G4double GetYMax() const
G4UIcmdWithADoubleAndUnit * yMaxCmd
G4ThreeVector GetXAxis() const
void SetXMax(const G4double &val)
G4double GetXMin() const
G4double GetYMin() const
G4UIcmdWith3Vector * yAxisCmd
virtual G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithAString * fileCmd
void SetXAxis(const G4ThreeVector &vect)
G4double GetXMax() const
static LBNFWormPlotMessenger * fpInstance
G4UIcmdWithADoubleAndUnit * xMaxCmd
void SetYName(const G4String &word)
G4UIcmdWithAString * xNameCmd
G4UIcmdWith3Vector * xAxisCmd
G4UIcmdWithADoubleAndUnit * yMinCmd
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
void SetXName(const G4String &word)
G4UIcmdWithADoubleAndUnit * z0Cmd
void SetXMin(const G4double &val)
void SetZ0(const G4double &val)
G4ThreeVector GetYAxis() const
G4UIcmdWithADoubleAndUnit * xMinCmd
static LBNFWormPlotMessenger * GetInstance(LBNFWormPlotter *wPlot)