Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set visualization depth to teveDisplay #1187

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions UtilityApps/src/run_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ namespace {
std::cout << "]" << std::endl << std::flush;
}
if ( name && name[0] ) {
result = run_plugin(description, name, a.first, a.second);
return result;
result = run_plugin(description, name, a.first, a.second);
return result;
}
std::cout << "WARNING: run_plugin: No plugin name supplied. "
<< "Implicitly assuming execution steered by XML." << std::endl;
<< "Implicitly assuming execution steered by XML." << std::endl;
return ENOENT;
}
};
Expand Down Expand Up @@ -279,7 +279,7 @@ namespace dd4hep {
}
else {
result = args.run(description, name);
}
}
if ( result == EINVAL ) usage_default(name);
}
else {
Expand Down Expand Up @@ -329,7 +329,7 @@ namespace dd4hep {
!arguments.ui &&
!arguments.interpreter &&
arguments.plugins.empty() &&
arguments.geo_files.empty() )
arguments.geo_files.empty() )
{
usage_plugin_runner();
}
Expand Down
56 changes: 38 additions & 18 deletions UtilityApps/src/teve_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,32 @@ TEveStraightLineSet* getSurfaceVectors(bool addO=true, bool addU= true, bool add

//=====================================================================================

static long teve_display(Detector& description, int /* argc */, char** /* argv */) {
static long teve_display(Detector& description, int argc, char** argv) {
int level = 4, visopt = 0, help = 0;

for( int i=0; i<argc; ++i ) {
if ( strncmp(argv[i],"-visopt",4) == 0 ) visopt = ::atol(argv[++i]);
else if ( strncmp(argv[i],"-level", 4) == 0 ) level = ::atol(argv[++i]);
else help = 1;
}
if ( help ) {
std::cout <<
"Usage: teveDisplay -arg [-arg] \n\n"
" Invoke TEve display using the factory mechanism. \n\n"
" -level <number> Visualization level [TGeoManager::SetVisLevel] Default: 4 \n"
" -visopt <number> Visualization option [TGeoManager::SetVisOption] Default: 0 \n"
" -help Print this help output" << std::endl << std::flush;
::exit(EINVAL);
}

TGeoManager* mgr = &description.manager();
mgr->SetNsegments(100); // Increase the visualization resolution.
TEveManager::Create();

// mgr->SetVisOption(1) ;
// mgr->SetVisLevel(4) ;

// gEve->fGeometries->Add(new TObjString("DefaultGeometry"),mgr);

TEveGeoTopNode* tn = new TEveGeoTopNode(mgr, mgr->GetTopNode());
// option 0 in TEve seems to correspond to option 1 in TGeo ( used in geoDisplay ...)
tn->SetVisOption(0) ;
tn->SetVisLevel(4);
tn->SetVisOption(visopt) ;
tn->SetVisLevel(level);

// // ---- try to set transparency - does not seem to work ...
// TGeoNode* node1 = gGeoManager->GetTopNode();
Expand Down Expand Up @@ -130,13 +141,9 @@ static long teve_display(Detector& description, int /* argc */, char** /* argv *
MultiView::instance()->ImportGeomRPhi( helperSurfaces );
MultiView::instance()->ImportGeomRhoZ( helperSurfaces ) ;


make_gui();

next_event();

gEve->FullRedraw3D(kTRUE);

return 1;
}
DECLARE_APPLY(DD4hepTEveDisplay,teve_display)
Expand All @@ -145,18 +152,31 @@ DECLARE_APPLY(DD4hepTEveDisplay,teve_display)
//=====================================================================================================================

int main(int argc,char** argv) {
return dd4hep::execute::main_default("DD4hepTEveDisplay",argc,argv);
std::vector<const char*> av;
std::string level, visopt, opt;
bool help = false;
for( int i=0; i<argc; ++i ) {
if ( i==1 && argv[i][0] != '-' ) av.emplace_back("-input");
else if ( strncmp(argv[i],"-help",4) == 0 ) help = true, av.emplace_back(argv[i]);
else if ( strncmp(argv[i],"-visopt",4) == 0 ) visopt = argv[++i];
else if ( strncmp(argv[i],"-level", 4) == 0 ) level = argv[++i];
else if ( strncmp(argv[i],"-option",4) == 0 ) opt = argv[++i];
else av.emplace_back(argv[i]);
}
av.emplace_back("-interactive");
av.emplace_back("-plugin");
av.emplace_back("DD4hepTEveDisplay");
if ( help ) av.emplace_back("-help");
if ( !opt.empty() ) av.emplace_back("-opt"), av.emplace_back(opt.c_str());
if ( !level.empty() ) av.emplace_back("-level"), av.emplace_back(level.c_str());
if ( !visopt.empty() ) av.emplace_back("-visopt"), av.emplace_back(visopt.c_str());
return dd4hep::execute::main_plugins("DD4hepTEveDisplay", av.size(), (char**)&av[0]);
}

//=====================================================================================================================


TEveStraightLineSet* getSurfaceVectors(bool addO, bool addU, bool addV, bool addN, TString name,int color) {

TEveStraightLineSet* ls = new TEveStraightLineSet(name);

Detector& description = Detector::getInstance();

DetElement world = description.world() ;

// create a list of all surfaces in the detector:
Expand Down
Loading