source: trunk/source/visualization/gMocren/src/G4GMocrenMessenger.cc @ 1347

Last change on this file since 1347 was 1347, checked in by garnier, 13 years ago

geant4 tag 9.4

File size: 12.6 KB
Line 
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: G4GMocrenMessenger.cc,v 1.2 2009/10/12 10:04:35 akimura Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
29//
30//
31// Created:  Mar. 31, 2009  Akinori Kimura 
32//
33#include "G4GMocrenMessenger.hh"
34
35#include "G4UIdirectory.hh"
36#include "G4UIcmdWithABool.hh"
37#include "G4UIcmdWithAString.hh"
38#include "G4UIcmdWithoutParameter.hh"
39#include "G4UIcommand.hh"
40#include "G4Tokenizer.hh"
41
42G4GMocrenMessenger::G4GMocrenMessenger()
43  : suffix (""), geometry(true), solids(true), invisibles(true),
44    kgMocrenVolumeName("gMocrenVolume"),
45    kgMocrenScoringMeshName("gMocrenScoringMesh"),
46    kDrawVolumeGrid(false) {
47
48  kgMocrenDirectory = new G4UIdirectory("/vis/gMocren/");
49  kgMocrenDirectory->SetGuidance("gMocren commands.");
50
51  setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/gMocren/setEventNumberSuffix", this);
52  setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix.");
53  setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'.");
54  setEventNumberSuffixCommand->SetParameterName("suffix",false);
55  setEventNumberSuffixCommand->SetDefaultValue("");
56  setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
57   
58  appendGeometryCommand = new G4UIcmdWithABool("/vis/gMocren/appendGeometry", this);
59  appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
60  appendGeometryCommand->SetParameterName("flag",false);
61  appendGeometryCommand->SetDefaultValue(true);
62  appendGeometryCommand->AvailableForStates(G4State_Idle);
63
64  addPointAttributesCommand = new G4UIcmdWithABool("/vis/gMocren/addPointAttributes", this);
65  addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
66  addPointAttributesCommand->SetParameterName("flag",false);
67  addPointAttributesCommand->SetDefaultValue(false);
68  addPointAttributesCommand->AvailableForStates(G4State_Idle);
69
70  useSolidsCommand = new G4UIcmdWithABool("/vis/gMocren/useSolids", this);
71  useSolidsCommand->SetGuidance("Use GMocren Solids, rather than Geant4 Primitives.");
72  useSolidsCommand->SetParameterName("flag",false);
73  useSolidsCommand->SetDefaultValue(true);
74  useSolidsCommand->AvailableForStates(G4State_Idle);
75
76  /* Not Enabled Yet
77     writeInvisiblesCommand = new G4UIcmdWithABool("/vis/gMocren/writeInvisibles", this);
78     writeInvisiblesCommand->SetGuidance("Write invisible objects.");
79     writeInvisiblesCommand->SetParameterName("flag",false);
80     writeInvisiblesCommand->SetDefaultValue(true);
81     writeInvisiblesCommand->AvailableForStates(G4State_Idle);
82  */
83
84  kSetgMocrenVolumeNameCommand = new G4UIcmdWithAString("/vis/gMocren/setVolumeName", this);
85  kSetgMocrenVolumeNameCommand->SetGuidance("detector name for a volume data in gMocren data.");
86  kSetgMocrenVolumeNameCommand->SetParameterName("kgMocrenVolumeName",false);
87  kSetgMocrenVolumeNameCommand->SetDefaultValue("gMocrenVolume");
88  kSetgMocrenVolumeNameCommand->AvailableForStates(G4State_Idle);
89
90  kAddgMocrenHitNameCommand = new G4UIcmdWithAString("/vis/gMocren/addHitName", this);
91  kAddgMocrenHitNameCommand->SetGuidance("hit name for a dose distribution in gMocren data.");
92  kAddgMocrenHitNameCommand->SetParameterName("kgMocrenHitName",false);
93  kAddgMocrenHitNameCommand->AvailableForStates(G4State_Idle);
94
95  kResetgMocrenHitNameCommand = new G4UIcmdWithoutParameter("/vis/gMocren/resetHitNames", this);
96  kResetgMocrenHitNameCommand->SetGuidance("reset all hit names.");
97  kResetgMocrenHitNameCommand->AvailableForStates(G4State_Idle);
98
99  kSetgMocrenScoringMeshNameCommand = new G4UIcmdWithAString("/vis/gMocren/setScoringMeshName", this);
100  kSetgMocrenScoringMeshNameCommand->SetGuidance("scoring mesh name for a dose distribution in gMocren data.");
101  kSetgMocrenScoringMeshNameCommand->SetParameterName("kgMocrenScoringMeshName",false);
102  kSetgMocrenScoringMeshNameCommand->SetDefaultValue("gMocrenScoringMesh");
103  kSetgMocrenScoringMeshNameCommand->AvailableForStates(G4State_Idle);
104
105  kAddgMocrenHitScorerNameCommand = new G4UIcmdWithAString("/vis/gMocren/addHitScorerName", this);
106  kAddgMocrenHitScorerNameCommand->SetGuidance("hit scorer name for a dose distribution in gMocren data.");
107  kAddgMocrenHitScorerNameCommand->SetParameterName("kgMocrenHitScorerNames",false);
108  kAddgMocrenHitScorerNameCommand->AvailableForStates(G4State_Idle);
109
110  kResetgMocrenHitScorerNameCommand = new G4UIcmdWithoutParameter("/vis/gMocren/resetHitScorerName", this);
111  kResetgMocrenHitScorerNameCommand->SetGuidance("reset all hit scorer names.");
112  kResetgMocrenHitScorerNameCommand->AvailableForStates(G4State_Idle);
113
114  kSetgMocrenNoVoxelsCommand = new G4UIcommand("/vis/gMocren/setNumberOfVoxels", this);
115  kSetgMocrenNoVoxelsCommand->SetGuidance("set number of voxels.");
116  kSetgMocrenNoVoxelsCommand->AvailableForStates(G4State_Idle);
117  G4UIparameter * param = new G4UIparameter("nX", 'i', false);
118  param->SetDefaultValue("1");
119  param->SetParameterRange("nX>0");
120  kSetgMocrenNoVoxelsCommand->SetParameter(param);
121  param = new G4UIparameter("nY", 'i', false);
122  param->SetDefaultValue("1");
123  param->SetParameterRange("nY>0");
124  kSetgMocrenNoVoxelsCommand->SetParameter(param);
125  param = new G4UIparameter("nZ", 'i', false);
126  param->SetDefaultValue("1");
127  param->SetParameterRange("nZ>0");
128  kSetgMocrenNoVoxelsCommand->SetParameter(param);
129
130  kListgMocrenCommand = new G4UIcmdWithoutParameter("/vis/gMocren/list", this);
131  kListgMocrenCommand->SetGuidance("list gMocren command parameters.");
132  kListgMocrenCommand->AvailableForStates(G4State_Idle);
133
134  kDrawVolumeGridCommand = new G4UIcmdWithABool("/vis/gMocren/drawVolumeGrid", this);
135  kDrawVolumeGridCommand->SetGuidance("Add grid of the volume.");
136  kDrawVolumeGridCommand->SetParameterName("kDrawVolumeGrid",false);
137  kDrawVolumeGridCommand->SetDefaultValue(false);
138  kDrawVolumeGridCommand->AvailableForStates(G4State_Idle);
139
140}
141
142G4GMocrenMessenger::~G4GMocrenMessenger() {
143  delete setEventNumberSuffixCommand;
144  delete appendGeometryCommand;
145  delete addPointAttributesCommand;
146  delete useSolidsCommand;
147  //    delete writeInvisiblesCommand;
148  delete kSetgMocrenVolumeNameCommand;
149  delete kAddgMocrenHitNameCommand;
150  delete kResetgMocrenHitNameCommand;
151  //
152  delete kSetgMocrenScoringMeshNameCommand;
153  delete kAddgMocrenHitScorerNameCommand;
154  delete kResetgMocrenHitScorerNameCommand;
155  //
156  delete kSetgMocrenNoVoxelsCommand;
157  //
158  delete kgMocrenDirectory;
159  //
160  delete kDrawVolumeGridCommand;
161}
162
163G4String G4GMocrenMessenger::GetCurrentValue(G4UIcommand * command) {
164  if (command==setEventNumberSuffixCommand) {
165    return suffix;
166  } else if (command==appendGeometryCommand) {
167    return appendGeometryCommand->ConvertToString(geometry); 
168  } else if (command==addPointAttributesCommand) {
169    return addPointAttributesCommand->ConvertToString(pointAttributes); 
170  } else if (command==useSolidsCommand) {
171    return useSolidsCommand->ConvertToString(solids);
172    //    } else if (command==writeInvisiblesCommand) {
173    //        return writeInvisiblesCommand->ConvertToString(invisibles);
174  } else if (command == kSetgMocrenVolumeNameCommand) {
175    return kgMocrenVolumeName;
176  } else if (command == kAddgMocrenHitNameCommand) {
177    G4String strval;
178    std::vector<G4String>::iterator itr = kgMocrenHitNames.begin();
179    for(; itr != kgMocrenHitNames.end(); itr++) {
180      strval += *itr;
181      strval += " ";
182    }
183    return strval;
184  } else if (command == kSetgMocrenScoringMeshNameCommand) {
185    return kgMocrenScoringMeshName;
186  } else if (command == kAddgMocrenHitScorerNameCommand) {
187    G4String strval;
188    std::vector<G4String>::iterator itr = kgMocrenHitScorerNames.begin();
189    for(; itr != kgMocrenHitNames.end(); itr++) {
190      strval += *itr;
191      strval += " ";
192    }
193    return strval;
194  } else if (command==kDrawVolumeGridCommand) {
195    return kDrawVolumeGridCommand->ConvertToString(kDrawVolumeGrid);
196  } else {
197    return "";
198  }
199}
200
201void G4GMocrenMessenger::SetNewValue(G4UIcommand * command, G4String newValue) {
202  if (command==setEventNumberSuffixCommand) {
203    suffix = newValue;
204  } else if (command==appendGeometryCommand) {
205    geometry = appendGeometryCommand->GetNewBoolValue(newValue);
206  } else if (command==addPointAttributesCommand) {
207    pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
208  } else if (command==useSolidsCommand) {
209    solids = useSolidsCommand->GetNewBoolValue(newValue);
210    //    } else if (command==writeInvisiblesCommand) {
211    //        invisibles = writeInvisiblesCommand->GetNewBoolValue(newValue);
212  } else if (command == kSetgMocrenVolumeNameCommand) {
213    kgMocrenVolumeName = newValue;
214  } else if (command == kAddgMocrenHitNameCommand) {
215    kgMocrenHitNames.push_back(newValue);
216  } else if (command == kResetgMocrenHitNameCommand) {
217    kgMocrenHitNames.clear();
218  } else if (command == kSetgMocrenScoringMeshNameCommand) {
219    kgMocrenScoringMeshName = newValue;
220  } else if (command == kAddgMocrenHitScorerNameCommand) {
221    kgMocrenHitScorerNames.push_back(newValue);
222  } else if (command == kResetgMocrenHitScorerNameCommand) {
223    kgMocrenHitScorerNames.clear();
224  } else if (command == kListgMocrenCommand) {
225    list();
226  } else if (command == kSetgMocrenNoVoxelsCommand) {
227    G4Tokenizer next(newValue);
228    for(int i = 0; i < 3; i++) {
229      kgMocrenNoVoxels[i] = StoI(next());
230    }
231  } else if (command==kDrawVolumeGridCommand) {
232    kDrawVolumeGrid = kDrawVolumeGridCommand->GetNewBoolValue(newValue);
233  } 
234}
235
236G4String G4GMocrenMessenger::getEventNumberSuffix() {
237  return suffix;
238}
239
240G4bool G4GMocrenMessenger::appendGeometry() {
241  return geometry;
242}
243
244G4bool G4GMocrenMessenger::addPointAttributes() {
245  return pointAttributes;
246}
247
248G4bool G4GMocrenMessenger::useSolids() {
249  return solids;
250}
251
252G4bool G4GMocrenMessenger::writeInvisibles() {
253  return invisibles;
254}
255
256G4String G4GMocrenMessenger::getVolumeName() {
257  return kgMocrenVolumeName;
258}
259
260std::vector<G4String> G4GMocrenMessenger::getHitNames() {
261  return kgMocrenHitNames;
262}
263
264G4String G4GMocrenMessenger::getScoringMeshName() {
265  return kgMocrenScoringMeshName;
266}
267
268std::vector<G4String> G4GMocrenMessenger::getHitScorerNames() {
269  return kgMocrenHitScorerNames;
270}
271
272void G4GMocrenMessenger::list() {
273  G4cout << "  Current valuess of gMocren command parameters:" << G4endl;
274  //
275  G4cout << "    volume name:        " << kgMocrenVolumeName << G4endl;
276  //
277  G4cout << "    hit names:          ";
278  if(kgMocrenHitNames.size() > 0) {
279    std::vector<G4String>::iterator itr = kgMocrenHitNames.begin();
280    for(; itr != kgMocrenHitNames.end(); itr++)
281      G4cout << *itr << "  " << G4endl;
282  } else {
283    G4cout << G4endl;
284  }
285  //
286  G4cout << "    scoring mesh name:  " << kgMocrenScoringMeshName << G4endl;
287  //
288  G4cout << "    scorer names:       ";
289  if(kgMocrenHitScorerNames.size() > 0) {
290    std::vector<G4String>::iterator itr = kgMocrenHitScorerNames.begin();
291    for(; itr != kgMocrenHitScorerNames.end(); itr++)
292      G4cout << *itr << "  " << G4endl;
293  } else {
294    G4cout << G4endl;
295  }
296  G4cout << G4endl;
297}
298
299void G4GMocrenMessenger::getNoVoxels(G4int & nx, G4int & ny, G4int & nz) const {
300  nx = kgMocrenNoVoxels[0];
301  ny = kgMocrenNoVoxels[1];
302  nz = kgMocrenNoVoxels[2];
303}
Note: See TracBrowser for help on using the repository browser.