156{
159
161
164
165 size_t nWorlds = transportationManager->
GetNoWorlds();
166
168 if (!world) {
171 "ERROR: G4VisCommandsTouchable::SetNewValue:"
172 "\n No world. Maybe the geometry has not yet been defined."
173 "\n Try \"/run/initialize\""
175 }
176 return;
177 }
178
180 if (!currentViewer) {
183 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
185 }
186 return;
187 }
188
190 if (!currentScene) {
193 "ERROR: No current scene - \"/vis/scene/list\" to see possibilities."
195 }
196 return;
197 }
198
199 if (command == fpCommandCentreOn || command == fpCommandCentreAndZoomInOn) {
200
201
202 std::vector<std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>> touchables;
203
207
213 nullptr,
214 true,
217
218 G4Scene tempScene(
"Centre Scene");
219 G4bool successful = tempScene.AddRunDurationModel(&tempPVModel,warn);
220 if (!successful) return;
224 << ",\n has been added to temporary scene \"" << tempScene.GetName() << "\"."
226 }
227
228 const G4VisExtent& newExtent = tempScene.GetExtent();
232 if (command == fpCommandCentreAndZoomInOn) {
233
237 }
238
241
242
246
247 Twinkle(currentViewer,newVP,touchables);
249
252 <<
"Viewer \"" << currentViewer->
GetName()
253 << "\" centred ";
254 if (fpCommandCentreAndZoomInOn) {
255 G4cout <<
"and zoomed in";
256 }
259 }
261 } else {
263 }
264 return;
265
266 } else if (command == fpCommandDraw) {
267
271
277 nullptr,
278 true,
280
285
286 if (successful) {
288 const auto& extent = pvModel->
GetExtent();
289 const G4double halfX = (extent.GetXmax()-extent.GetXmin())/2.;
290 const G4double halfY = (extent.GetYmax()-extent.GetYmin())/2.;
291 const G4double halfZ = (extent.GetZmax()-extent.GetZmin())/2.;
292 G4Box extentBox(
"extent",halfX,halfY,halfZ);
296 }
299 <<
"\", copy no. " << properties.
fCopyNo <<
" drawn";
301 G4cout <<
" with extent box";
302 }
304 }
305 } else {
307 }
308 } else {
310 }
311 return;
312
313 } else if (command == fpCommandDump) {
314
318
324 nullptr,
325 true,
327 const std::map<G4String,G4AttDef>* attDefs = tempPVModel.GetAttDefs();
328 std::vector<G4AttValue>* attValues = tempPVModel.CreateCurrentAttValues();
330 delete attValues;
334 G4cout <<
"\nLocal polyhedron coordinates:\n" << *polyhedron;
335 const G4Transform3D& transform = tempPVModel.GetCurrentTransform();
336 polyhedron->Transform(transform);
337 G4cout <<
"\nGlobal polyhedron coordinates:\n" << *polyhedron;
338 } else {
340 }
341 return;
342
343 } else if (command == fpCommandExtentForField) {
344
354 G4cout <<
"Extent for field set to " << extent
355 << "\nVolume for field has been cleared."
357 }
360 }
361 } else {
363 }
364 return;
365
366 } else if (command == fpCommandFindPath) {
367
370 std::istringstream iss(newValue);
371 iss >> pvName >> copyNo;
372 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
373 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
375 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
378 searchModel.SetModelingParameters (&mp);
379
381 searchModel.DescribeYourselfTo (searchScene);
382 for (const auto& findings: searchScene.GetFindings()) {
383 findingsVector.push_back(findings);
384 }
385 }
386 for (const auto& findings: findingsVector) {
388 << findings.fFoundBasePVPath
389 << ' ' << findings.fpFoundPV->GetName()
390 << ' ' << findings.fFoundPVCopyNo
391 << " (mother logical volume: "
392 << findings.fpFoundPV->GetMotherLogical()->GetName()
393 << ')'
395 }
396 if (findingsVector.size()) {
398 << "Use this to set a particular touchable with \"/vis/set/touchable <path>\""
399 << "\nor to see overlaps: \"/vis/drawLogicalVolume <mother-logical-volume-name>\""
401 } else {
403 if (copyNo >= 0)
G4warn <<
':' << copyNo;
405 }
406 return;
407
408 } else if (command == fpCommandLocalAxes) {
409
416 const G4double intLog10LengthMax = std::floor(std::log10(lengthMax));
417 G4double length = std::pow(10,intLog10LengthMax);
418 if (5.*length < lengthMax) length *= 5.;
419 else if (2.*length < lengthMax) length *= 2.;
421 axesModel.SetGlobalTag("LocalAxesModel");
424 } else {
426 }
427 return;
428
429 } else if (command == fpCommandShowExtent) {
430
439 } else {
441 }
442 return;
443
444 } else if (command == fpCommandTwinkle) {
445
449 std::vector<std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>> touchables;
457 } else {
459 }
460 return;
461
462 } else if (command == fpCommandVolumeForField) {
463
480 }
483 }
484 } else {
486 }
487 return;
488
489 } else {
490
493 "ERROR: G4VisCommandsTouchable::SetNewValue: unrecognised command."
495 }
496 return;
497 }
498}
G4GLOB_DLL std::ostream G4cout
G4VSolid * GetSolid() const
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
const G4VisExtent & GetExtent() const
const G4Point3D & GetStandardTargetPoint() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
std::size_t GetNoWorlds() const
static G4bool GetNewBoolValue(const char *paramString)
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
const G4VisExtent & GetExtent() const
virtual void SetCopyNo(G4int CopyNo)=0
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
virtual G4VisExtent GetExtent() const
virtual G4Polyhedron * GetPolyhedron() const
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
static std::vector< G4PhysicalVolumesSearchScene::Findings > fCurrrentPVFindingsForField
static G4VisManager * fpVisManager
static G4VisExtent fCurrentExtentForField
void DrawExtent(const G4VisExtent &)
void InterpolateToNewView(G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
void SetViewParameters(G4VViewer *viewer, const G4ViewParameters &viewParams)
static G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties
void Twinkle(G4VViewer *currentViewer, const G4ViewParameters &baseVP, const std::vector< std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > > &paths)
void SetCurrentTargetPoint(const G4Point3D ¤tTargetPoint)
void SetZoomFactor(G4double zoomFactor)
void SetForceWireframe(G4bool=true)
G4double GetExtentRadius() const
G4VisExtent & Transform(const G4Transform3D &)
const G4Point3D & GetExtentCentre() const
void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
G4Scene * GetCurrentScene() const
G4VSceneHandler * GetCurrentSceneHandler() const
static Verbosity GetVerbosity()
void SetVerboseLevel(G4int)
void SetVisAttributes(const G4VisAttributes *)
G4PhysicalVolumeModel::TouchableProperties FindTouchableProperties(G4ModelingParameters::PVNameCopyNoPath path)
G4ModelingParameters::PVNameCopyNoPath fTouchablePath
G4VPhysicalVolume * fpTouchablePV
std::vector< G4PhysicalVolumeNodeID > fTouchableFullPVPath
std::vector< G4PhysicalVolumeNodeID > fTouchableBaseFullPVPath
G4Transform3D fTouchableGlobalTransform