26 #include <TEveGeoNode.h>
27 #include <TEveBrowser.h>
28 #include <TGNumberEntry.h>
32 #include <TGComboBox.h>
33 #include <TEveManager.h>
35 #include <TGLViewer.h>
36 #include <TEveViewer.h>
37 #include <TGLPerspectiveCamera.h>
38 #include <TGLCamera.h>
39 #include <TEveStraightLineSet.h>
40 #include <TSysEvtHandler.h>
41 #include <TEveScene.h>
42 #include <TEveProjectionManager.h>
43 #include <TEveProjectionAxes.h>
44 #include <TEveWindow.h>
46 #include <TGeoManager.h>
49 #include <TObjString.h>
50 #include <TGeoShape.h>
51 #include <TGLScenePad.h>
56 using namespace detail ;
64 TEveStraightLineSet*
getSurfaceVectors(
bool addO=
true,
bool addU=
true,
bool addV=
true,
bool addN=
true,TString name=
"SurfaceVectors",
int color=kGreen) ;
67 static void print_teve_help() {
69 "Usage: teveDisplay -arg [-arg] \n\n"
70 " Invoke TEve display using the factory mechanism. \n\n"
71 " -input <file> [OPTIONAL] Specify geometry input file. \n";
72 print_default_args() << std::endl <<
73 " -level <number> Visualization level [TGeoManager::SetVisLevel] Default: 4 \n"
74 " -visopt <number> Visualization option [TGeoManager::SetVisOption] Default: 0 \n"
75 " -help Print this help output" << std::endl << std::flush;
81 static long teve_display(
Detector& description,
int argc,
char** argv) {
82 int level = 4, visopt = 0,
help = 0;
83 for(
int i=0; i<argc; ++i ) {
84 if ( strncmp(argv[i],
"-visopt",4) == 0 ) visopt = ::atol(argv[++i]);
85 else if ( strncmp(argv[i],
"-level", 4) == 0 ) level = ::atol(argv[++i]);
92 TGeoManager* mgr = &description.
manager();
93 mgr->SetNsegments(100);
94 TEveManager::Create();
96 TEveGeoTopNode* tn =
new TEveGeoTopNode(mgr, mgr->GetTopNode());
98 tn->SetVisOption(visopt) ;
99 tn->SetVisLevel(level);
115 gEve->AddGlobalElement( tn );
119 TEveElement* surfaceVectors =
getSurfaceVectors(1,0,0,1,
"SurfaceVectorsN",kGreen) ;
121 gEve->AddGlobalElement( surfaces ) ;
122 gEve->AddGlobalElement( helperSurfaces ) ;
123 gEve->AddGlobalElement( surfaceVectors ) ;
126 TEveElement* surfaceVectors_u =
getSurfaceVectors(0,1,0,0,
"SurfaceVectorsU",kMagenta) ;
128 gEve->AddGlobalElement( surfaceVectors_u ) ;
130 TEveElement* surfaceVectors_v =
getSurfaceVectors(0,0,1,0,
"SurfaceVectorsV",kBlack) ;
132 gEve->AddGlobalElement( surfaceVectors_v ) ;
134 TGLViewer *
v = gEve->GetDefaultGLViewer();
137 v->ColorSet().Background().SetColor(kWhite);
138 v->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0);
139 v->RefreshPadEditor(
v);
142 gEve->GetGlobalScene()->GetGLScene()->SetSelectable(kFALSE) ;
152 gEve->FullRedraw3D(kTRUE);
158 int
main(
int argc,
char** argv) {
159 std::vector<const char*> av;
160 std::string level, visopt, opt;
161 bool help = (argc == 1);
163 for(
int i=0; i < argc; ++i ) {
164 if ( i == 1 && argv[i][0] !=
'-' ) av.emplace_back(
"-input");
165 else if ( strncmp(argv[i],
"-help", 4) == 0 )
help =
true;
166 else if ( strncmp(argv[i],
"--help", 5) == 0 )
help =
true;
167 else if ( strncmp(argv[i],
"-visopt", 4) == 0 ) visopt = argv[++i];
168 else if ( strncmp(argv[i],
"--visopt",5) == 0 ) visopt = argv[++i];
169 else if ( strncmp(argv[i],
"-level", 4) == 0 ) level = argv[++i];
170 else if ( strncmp(argv[i],
"--level", 5) == 0 ) level = argv[++i];
171 else if ( strncmp(argv[i],
"-option", 4) == 0 ) opt = argv[++i];
172 else if ( strncmp(argv[i],
"--option",5) == 0 ) opt = argv[++i];
173 else if ( argc > 2 ) av.emplace_back(argv[i]);
175 if ( !
help && argc == 2 ) {
176 av.emplace_back(
"-input");
177 av.emplace_back(argv[1]);
179 av.emplace_back(
"-interactive");
180 av.emplace_back(
"-plugin");
181 av.emplace_back(
"DD4hepTEveDisplay");
182 if (
help ) av.emplace_back(
"-help");
183 if ( !opt.empty() ) av.emplace_back(
"-opt"), av.emplace_back(opt.c_str());
184 if ( !level.empty() ) av.emplace_back(
"-level"), av.emplace_back(level.c_str());
185 if ( !visopt.empty() ) av.emplace_back(
"-visopt"), av.emplace_back(visopt.c_str());
193 TEveStraightLineSet*
getSurfaceVectors(
bool addO,
bool addU,
bool addV,
bool addN, TString name,
int color) {
194 TEveStraightLineSet* ls =
new TEveStraightLineSet(name);
201 for( SurfaceList::const_iterator it = sL.begin() ; it != sL.end() ; ++it ){
212 if (addU) ls->AddLine( o.
x(), o.
y(), o.
z(), ou.
x() , ou.
y() , ou.
z() );
216 if (addV) ls->AddLine( o.
x(), o.
y(), o.
z(), ov.
x() , ov.
y() , ov.
z() );
217 if (addN) ls->AddLine( o.
x(), o.
y(), o.
z(), on.
x() , on.
y() , on.
z() );
218 if (addO) ls->AddMarker( o.
x(), o.
y(), o.
z() );
220 ls->SetLineColor( color ) ;
221 ls->SetMarkerColor( kBlue ) ;
222 ls->SetMarkerSize(1);
223 ls->SetMarkerStyle(4);
232 TEveStraightLineSet* ls =
new TEveStraightLineSet(name);
245 for( SurfaceList::const_iterator it = sL.begin() ; it != sL.end() ; ++it ){
257 const std::vector< std::pair<Vector3D,Vector3D> > lines = surf->
getLines() ;
260 std::cout <<
" **** drawSurfaces() : empty lines vector for surface " << *surf << std::endl ;
262 unsigned nL = lines.size() ;
264 for(
unsigned i=0 ; i<nL ; ++i){
268 ls->AddLine( lines[i].first.x(), lines[i].first.y(), lines[i].first.z(),
269 lines[i].second.x(), lines[i].second.y(), lines[i].second.z() ) ;
272 ls->SetLineColor( col ) ;
273 ls->SetMarkerColor( col ) ;
274 ls->SetMarkerSize(.1);
275 ls->SetMarkerStyle(4);
288 TEveBrowser* browser = gEve->GetBrowser();
289 browser->StartEmbedding(TRootBrowser::kLeft);
292 frmMain->SetWindowName(
"dd4hep GUI");
293 frmMain->SetCleanup(kDeepCleanup);
295 TGHorizontalFrame* hf =
new TGHorizontalFrame(frmMain);
297 TString icondir( Form(
"%s/", TROOT::GetIconPath().Data()) );
298 TGPictureButton* b = 0;
299 EvNavHandler *fh =
new EvNavHandler;
301 b =
new TGPictureButton(hf, gClient->GetPicture(icondir+
"GoBack.gif"));
302 b->SetEnabled(kFALSE);
303 b->SetToolTipText(
"Go to previous event - not supported.");
305 b->Connect(
"Clicked()",
"EvNavHandler", fh,
"Bck()");
307 b =
new TGPictureButton(hf, gClient->GetPicture(icondir+
"GoForward.gif"));
308 b->SetToolTipText(
"Generate new event.");
310 b->Connect(
"Clicked()",
"EvNavHandler", fh,
"Fwd()");
312 frmMain->AddFrame(hf);
314 frmMain->MapSubwindows();
316 frmMain->MapWindow();
318 browser->StopEmbedding();
319 browser->SetTabTitle(
"Event Control", 0);