Warning, file /DD4hep/DDEve/root7/WebDisplay.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <DD4hep/Detector.h>
0014 #include <DD4hep/Factories.h>
0015 #include <DD4hep/Printout.h>
0016 #include <DD4hep/DetectorTools.h>
0017
0018
0019
0020 #if ROOT_VERSION_CODE <= ROOT_VERSION(3,35,00)
0021
0022 #include "ROOT/RDirectory.hxx"
0023 #endif
0024 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,27,00)
0025 #include "ROOT/RGeomViewer.hxx"
0026 # if ROOT_VERSION_CODE >= ROOT_VERSION(6,29,00)
0027 using GEOM_VIEWER = ROOT::RGeomViewer;
0028 # else
0029 using GEOM_VIEWER = ROOT::Experimental::RGeomViewer;
0030 # endif
0031 #else
0032 #include "ROOT/REveGeomViewer.hxx"
0033 using GEOM_VIEWER = ROOT::Experimental::REveGeomViewer;
0034 #endif
0035
0036
0037 #include <cerrno>
0038 #include <cstdlib>
0039 #include <fstream>
0040 #include <sstream>
0041
0042 using namespace std;
0043 using namespace dd4hep;
0044 using namespace dd4hep::detail;
0045
0046
0047
0048
0049
0050
0051
0052 static long webdisplay(Detector& description, int argc, char** argv) {
0053 TGeoManager& mgr = description.manager();
0054 int vislevel = 6, visopt = 1;
0055 string detector = "/world";
0056 const char* opt = "";
0057 for(int i = 0; i < argc && argv[i]; ++i) {
0058 if ( 0 == ::strncmp("-option",argv[i],4) )
0059 opt = argv[++i];
0060 else if ( 0 == ::strncmp("-level",argv[i],4) )
0061 vislevel = ::atol(argv[++i]);
0062 else if ( 0 == ::strncmp("-visopt",argv[i],4) )
0063 visopt = ::atol(argv[++i]);
0064 else if ( 0 == ::strncmp("-detector",argv[i],4) )
0065 detector = argv[++i];
0066 else {
0067 cout <<
0068 "Usage: -plugin <name> -arg [-arg] \n"
0069 " -detector <string> Top level DetElement path. Default: '/world' \n"
0070 " -option <string> ROOT Draw option. Default: '' \n"
0071 " -level <number> Visualization level [TGeoManager::SetVisLevel] Default: 4 \n"
0072 " -visopt <number> Visualization option [TGeoManager::SetVisOption] Default: 1 \n"
0073 "\tArguments given: " << arguments(argc,argv) << endl << flush;
0074 ::exit(EINVAL);
0075 }
0076 }
0077 mgr.SetVisLevel(vislevel);
0078 mgr.SetVisOption(visopt);
0079 TGeoVolume* vol = mgr.GetTopVolume();
0080 if ( detector != "/world" ) {
0081 DetElement elt = detail::tools::findElement(description,detector);
0082 if ( !elt.isValid() ) {
0083 except("DD4hep_GeometryWebDisplay","+++ Invalid DetElement path: %s",detector.c_str());
0084 }
0085 if ( !elt.placement().isValid() ) {
0086 except("DD4hep_GeometryWebDisplay","+++ Invalid DetElement placement: %s",detector.c_str());
0087 }
0088 vol = elt.placement().volume();
0089 }
0090
0091 if (vol) {
0092 #if ROOT_VERSION_CODE <= ROOT_VERSION(3,35,00)
0093 auto viewer = std::make_shared<GEOM_VIEWER>(&mgr);
0094
0095 ROOT::Experimental::RDirectory::Heap().Add( "geom_viewer", viewer );
0096 #else
0097
0098 auto viewer = new GEOM_VIEWER(&mgr);
0099 #endif
0100 viewer->SelectVolume(vol->GetName());
0101 viewer->SetLimits();
0102 viewer->SetDrawOptions(opt);
0103 viewer->Show();
0104 return 1;
0105 }
0106 return 0;
0107 }
0108 DECLARE_APPLY(DD4hep_GeometryWebDisplay,webdisplay)
0109