#include void MakeGeometry() { TGeoManager *geom = new TGeoManager("simple1", "Simple geometry"); //--- define some materials TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0); TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7); //--- define some media TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum); TGeoMedium *Al = new TGeoMedium("Root Material", 2, matAl); TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 270., 270., 120.); geom->SetTopVolume(top); TGeoVolume *box = geom->MakeBox("Box", Al, 10., 10., 10.); top->AddNode(box, 1, new TGeoTranslation(-15, 0, 0)); top->AddNode(box, 2, new TGeoTranslation(15, 0, 0)); //--- close the geometry geom->CloseGeometry(); gGeoManager = geom; } void FillElements(TString projection, TEveElement *scene, std::vector &elements) { TString toBeRemoved; if (projection == "YZ") return; else if (projection == "XZ") toBeRemoved = "Box_1"; else if (projection == "XY") toBeRemoved = "Box_2"; for (TEveElement::List_i it = scene->BeginChildren(); it != scene->EndChildren(); it++) { if ((*it)->GetElementName() == toBeRemoved) { elements.push_back(*it); } else { FillElements(projection, *it, elements); } } } void CleanScene(TString projection, TEveScene *scene) { std::vector elements; FillElements(projection, scene, elements); for(const auto element : elements){ std::cout << projection << " " << element->GetElementName() << '\n'; // according to doxygen this should be what I'm looking for // but it doesn't work scene->DestroyElementRenderers(element); // every type of SetRnr* removes the element from all scenes // so it's now what I need // element->SetRnrState(false); // this apparently does nothing // scene->RemoveElement(element); // also the transparency setting seems to be global so no joy // here as well // element->SetMainTransparency(100); } } void test() { gEve = new TEveManager(1200, 600, true, ""); auto _slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); auto _pack = _slot->MakePack(); _pack->SetElementName("Multi View"); _pack->SetHorizontal(); _pack->SetShowTitleBar(kFALSE); auto _XZGeomScene = gEve->SpawnNewScene("XOZG", "XOZ Geometry Scene"); auto _YZGeomScene = gEve->SpawnNewScene("YOZG", "YOZ Geometry Scene"); auto _XYGeomScene = gEve->SpawnNewScene("XOYG", "XOY Geometry Scene"); _pack->NewSlot()->MakeCurrent(); auto _XZView = gEve->SpawnNewViewer("XZ View", ""); _XZView->AddScene(_XZGeomScene); _XZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoZOX); _pack->NewSlot()->MakeCurrent(); auto _YZView = gEve->SpawnNewViewer("YZ View", ""); _YZView->AddScene(_YZGeomScene); _YZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoZnOY); _pack->NewSlot()->MakeCurrent(); auto _XYView = gEve->SpawnNewViewer("XY View", ""); _XYView->AddScene(_XYGeomScene); _XYView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY); gEve->GetBrowser()->HideBottomTab(); gEve->GetBrowser()->GetTabRight()->SetTab(1); //MakeGeometry(); TEveScene *scenes[] = {_XZGeomScene, _YZGeomScene, _XYGeomScene }; const char *names[] = { "XZ", "YZ", "XY" }; for (int i = 0; i < 3; ++i) { // NOTE: created by: gGeoManager->Export("testgeo.root", "TestGeo") gEve->RegisterGeometryAlias(names[i], "testgeo.root"); TEveGeoManagerHolder gmgr(gEve->GetGeometryByAlias(names[i])); TGeoNode *_wnode = (TGeoNode *)gGeoManager->GetListOfNodes()->At(0); while (_wnode != gGeoManager->GetTopNode()) { gGeoManager->CdUp(); _wnode = gGeoManager->GetCurrentNode(); } gGeoManager->DefaultColors(); TEveGeoTopNode *_node = new TEveGeoTopNode(gGeoManager, _wnode); //gEve->AddGlobalElement(_node); //_node->ExpandIntoListTreesRecursively(); //_XZGeomScene->AddElement(_node); //_YZGeomScene->AddElement(_node); // _XYGeomScene->AddElement(_node); scenes[i]->AddElement(_node); _node->ExpandIntoListTreesRecursively(); CleanScene(names[i], scenes[i]); //CleanScene("XZ", _XZGeomScene); //CleanScene("YZ", _YZGeomScene); //CleanScene("XY", _XYGeomScene); } gEve->FullRedraw3D(); }