MCPcopy Create free account
hub / github.com/Geant4/geant4 / FindOrInsertTouchable

Method FindOrInsertTouchable

source/visualization/management/src/G4VViewer.cc:468–550  ·  view source on GitHub ↗

clang-format off

Source from the content-addressed store, hash-verified

466
467// clang-format off
468std::list<G4SceneTreeItem>::iterator G4VViewer::SceneTreeScene::FindOrInsertTouchable
469 (const G4String& modelID, G4SceneTreeItem& mother,
470 G4int depth, const G4String& partialPathString, const G4String& fullPathString)
471{
472 auto& children = mother.AccessChildren();
473 auto childIter = children.begin();
474 for (; childIter != children.end(); ++childIter) {
475 if (childIter->GetPVPath() == partialPathString) break;
476 }
477 if (childIter != children.end()) {
478
479 // Item already exists
480
481 if (childIter->GetType() == G4SceneTreeItem::ghost) {
482
483 // Previously it was a ghost - but maybe this time it's real
484
485 if (partialPathString == fullPathString) {
486 // Partial path string refers to the actual volume so it's a touchable
487 childIter->SetType(G4SceneTreeItem::touchable);
488 // Populate with information
489 childIter->SetDescription(fpPVModel->GetCurrentTag());
490 childIter->SetModelType(fpPVModel->GetType());
491 childIter->SetModelDescription(modelID);
492 childIter->SetPVPath(partialPathString);
493 if (fpVisAttributes) childIter->SetVisAttributes(*fpVisAttributes);
494 childIter->SetAttDefs(fpPVModel->GetAttDefs());
495 childIter->SetAttValues(fpPVModel->CreateCurrentAttValues());
496 } // Partial path string refers to an ancester - do nothing
497
498 } else {
499
500 // Already a pre-existing full touchable
501
502 if (partialPathString == fullPathString) {
503 // Partial path string refers to the actual volume
504 // Replace vis attributes (if any) - they might have changed
505 if (fpVisAttributes) childIter->SetVisAttributes(*fpVisAttributes);
506 } // Partial path string refers to an ancester - do nothing
507
508 }
509
510 } else {
511
512 // Item does not yet exist
513
514 if (partialPathString == fullPathString) {
515
516 // Partial path string refers to the actual volume
517 // Insert new touchable item
518 G4SceneTreeItem touchable(G4SceneTreeItem::touchable);
519 touchable.SetExpanded(depth > fMaximumExpandedDepth? false: true);
520 touchable.SetDescription(fpPVModel->GetCurrentTag());
521 touchable.SetModelType(fpPVModel->GetType());
522 touchable.SetModelDescription(modelID);
523 touchable.SetPVPath(partialPathString);
524 if (fpVisAttributes) touchable.SetVisAttributes(*fpVisAttributes);
525 touchable.SetAttDefs(fpPVModel->GetAttDefs());

Callers

nothing calls this directly

Calls 15

SetDescriptionMethod · 0.80
SetModelDescriptionMethod · 0.80
SetPVPathMethod · 0.80
SetAttDefsMethod · 0.80
SetAttValuesMethod · 0.80
SetExpandedMethod · 0.80
InsertChildMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
GetTypeMethod · 0.45
SetTypeMethod · 0.45
GetCurrentTagMethod · 0.45

Tested by

no test coverage detected