51 fpCommandCentreAndZoomInOn->SetGuidance (
"Centre and zoom in on the current touchable.");
52 fpCommandCentreAndZoomInOn->SetGuidance
53 (
"Use \"/vis/set/touchable\" to set current touchable.");
54 fpCommandCentreAndZoomInOn->SetGuidance
55 (
"You may also need \"/vis/touchable/findPath\".");
56 fpCommandCentreAndZoomInOn->SetGuidance
57 (
"Use \"/vis/touchable/set\" to set attributes.");
60 fpCommandCentreOn->SetGuidance (
"Centre the view on the current touchable.");
65 fpCommandDraw->SetGuidance(
"Draw touchable.");
66 fpCommandDraw->SetGuidance
67 (
"If parameter == true, also draw extent as a white wireframe box.");
70 fpCommandDraw->SetParameterName(
"extent", omitable =
true);
71 fpCommandDraw->SetDefaultValue(
false);
74 fpCommandDump->SetGuidance(
"Dump touchable attributes.");
78 fpCommandExtentForField =
new G4UIcmdWithABool(
"/vis/touchable/extentForField",
this);
79 fpCommandExtentForField->SetGuidance(
"Set extent for field.");
80 fpCommandExtentForField->SetGuidance(
"If parameter == true, also draw.");
83 fpCommandExtentForField->SetParameterName(
"draw", omitable =
true);
84 fpCommandExtentForField->SetDefaultValue(
false);
86 fpCommandFindPath =
new G4UIcommand(
"/vis/touchable/findPath",
this);
87 fpCommandFindPath->SetGuidance
88 (
"Prints the path to touchable and its logical volume mother"
89 "\ngiven a physical volume name and copy no.");
90 fpCommandFindPath -> SetGuidance
91 (
"A search of all worlds is made and all physical volume names are"
92 "\nmatched against the argument of this command. If this is of the"
93 "\nform \"/regexp/\", where regexp is a regular expression (see C++ regex),"
94 "\nthe physical volume name is matched against regexp by the usual rules"
95 "\nof regular expression matching. Otherwise an exact match is required."
96 "\nFor example, \"/Shap/\" matches \"Shape1\" and \"Shape2\".");
97 fpCommandFindPath -> SetGuidance
98 (
"It may help to see a textual representation of the geometry hierarchy of"
99 "\nthe worlds. Try \"/vis/drawTree [worlds]\".");
101 parameter =
new G4UIparameter (
"physical-volume-name",
's', omitable =
true);
102 parameter -> SetDefaultValue (
"world");
103 fpCommandFindPath -> SetParameter (parameter);
104 parameter =
new G4UIparameter (
"copy-no",
'i', omitable =
true);
105 parameter -> SetGuidance (
"If negative, matches any copy no.");
106 parameter -> SetDefaultValue (-1);
107 fpCommandFindPath -> SetParameter (parameter);
110 fpCommandLocalAxes->SetGuidance(
"Draw local axes.");
114 fpCommandShowExtent =
new G4UIcmdWithABool(
"/vis/touchable/showExtent",
this);
115 fpCommandShowExtent->SetGuidance(
"Print extent of touchable.");
116 fpCommandShowExtent->SetGuidance(
"If parameter == true, also draw.");
119 fpCommandShowExtent->SetParameterName(
"draw", omitable =
true);
120 fpCommandShowExtent->SetDefaultValue(
false);
123 fpCommandTwinkle->SetGuidance(
"Cause touchable to twinkle.");
127 fpCommandVolumeForField =
new G4UIcmdWithABool(
"/vis/touchable/volumeForField",
this);
128 fpCommandVolumeForField->SetGuidance(
"Set volume for field.");
129 fpCommandVolumeForField->SetGuidance(
"If parameter == true, also draw.");
132 fpCommandVolumeForField->SetParameterName(
"draw", omitable =
true);
133 fpCommandVolumeForField->SetDefaultValue(
false);
164 size_t nWorlds = transportationManager->
GetNoWorlds();
170 "ERROR: G4VisCommandsTouchable::SetNewValue:"
171 "\n No world. Maybe the geometry has not yet been defined."
172 "\n Try \"/run/initialize\""
178 if (command == fpCommandDump) {
192 const std::map<G4String,G4AttDef>* attDefs = tempPVModel.
GetAttDefs();
199 polyhedron->SetVisAttributes(lv->GetVisAttributes());
200 G4cout <<
"\nLocal polyhedron coordinates:\n" << *polyhedron;
202 polyhedron->Transform(transform);
203 G4cout <<
"\nGlobal polyhedron coordinates:\n" << *polyhedron;
210 }
else if (command == fpCommandFindPath) {
214 std::istringstream iss(newValue);
215 iss >> pvName >> copyNo;
216 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
217 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
219 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
226 for (
const auto& findings: searchScene.
GetFindings()) {
227 findingsVector.push_back(findings);
230 for (
const auto& findings: findingsVector) {
232 << findings.fFoundBasePVPath
233 <<
' ' << findings.fpFoundPV->GetName()
234 <<
' ' << findings.fFoundPVCopyNo
235 <<
" (mother logical volume: "
236 << findings.fpFoundPV->GetMotherLogical()->GetName()
240 if (findingsVector.size()) {
242 <<
"Use this to set a particular touchable with \"/vis/set/touchable <path>\""
243 <<
"\nor to see overlaps: \"/vis/drawLogicalVolume <mother-logical-volume-name>\""
247 if (copyNo >= 0)
G4warn <<
':' << copyNo;
254 if (!currentViewer) {
257 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
267 "ERROR: No current scene - \"/vis/scene/list\" to see possibilities."
273 if (command == fpCommandCentreOn || command == fpCommandCentreAndZoomInOn) {
276 std::vector<std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>> touchables;
292 G4Scene tempScene(
"Centre Scene");
294 if (!successful)
return;
298 <<
",\n has been added to temporary scene \"" << tempScene.
GetName() <<
"\"."
306 if (command == fpCommandCentreAndZoomInOn) {
322 Twinkle(currentViewer,newVP,touchables);
328 <<
"Viewer \"" << currentViewer->
GetName()
330 if (fpCommandCentreAndZoomInOn) {
331 G4cout <<
"and zoomed in";
342 }
else if (command == fpCommandDraw) {
363 if (fpCommandDraw->GetNewBoolValue(newValue)) {
364 const auto& extent = pvModel->
GetExtent();
365 const G4double halfX = (extent.GetXmax()-extent.GetXmin())/2.;
366 const G4double halfY = (extent.GetYmax()-extent.GetYmin())/2.;
367 const G4double halfZ = (extent.GetZmax()-extent.GetZmin())/2.;
368 G4Box extentBox(
"extent",halfX,halfY,halfZ);
375 <<
"\", copy no. " << properties.
fCopyNo <<
" drawn";
376 if (fpCommandDraw->GetNewBoolValue(newValue)) {
377 G4cout <<
" with extent box";
389 }
else if (command == fpCommandExtentForField) {
400 G4cout <<
"Extent for field set to " << extent
401 <<
"\nVolume for field has been cleared."
404 if (fpCommandExtentForField->GetNewBoolValue(newValue)) {
412 }
else if (command == fpCommandLocalAxes) {
419 const G4double lengthMax = extent.GetExtentRadius()/2.;
420 const G4double intLog10LengthMax = std::floor(std::log10(lengthMax));
421 G4double length = std::pow(10,intLog10LengthMax);
422 if (5.*length < lengthMax) length *= 5.;
423 else if (2.*length < lengthMax) length *= 2.;
433 }
else if (command == fpCommandShowExtent) {
442 if (fpCommandShowExtent->GetNewBoolValue(newValue))
DrawExtent(extent);
448 }
else if (command == fpCommandTwinkle) {
454 std::vector<std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>> touchables;
466 G4warn <<
"Twinkling not available - image construction time too long." <<
G4endl;
470 }
else if (command == fpCommandVolumeForField) {
489 if (fpCommandVolumeForField->GetNewBoolValue(newValue)) {
501 "ERROR: G4VisCommandsTouchable::SetNewValue: unrecognised command."