diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt index 405c39dd60d465372cc554d296d8df43ac33c360..6a4f9b73e2484f7fab1c1f1661006646544ad451 100644 --- a/DDCore/CMakeLists.txt +++ b/DDCore/CMakeLists.txt @@ -89,7 +89,7 @@ target_include_directories(DDCore target_link_libraries(DDCore PUBLIC DD4hep::DDParsers - ROOT::Core ROOT::Rint ROOT::Tree ROOT::Physics ROOT::Geom ROOT::GenVector ROOT::ROOTEve + ROOT::Core ROOT::Rint ROOT::Tree ROOT::Physics ROOT::Geom ROOT::GenVector ${XML_LIBRARIES} ${CMAKE_DL_LIBS} ) @@ -115,7 +115,7 @@ IF(TARGET ROOT::Gdml) ELSE() dd4hep_print("ROOT does not include GDML, not building DDCore GDML Plugins") ENDIF() - + #--------------------------- Specialized PYTHON plugin ---------------------------- IF(TARGET ${DD4HEP_ROOT_PYTHON}) dd4hep_add_plugin(DDPythonPlugins diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 43a2cb195b998d87891f05a97f2f099229f5a6ee..0c5ce8619f5c3ad8dd6615adfeb217909dbd12f4 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -40,8 +40,6 @@ #if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) #include <TGDMLMatrix.h> #endif -#include "ROOT/RDirectory.hxx" -#include "ROOT/REveGeomViewer.hxx" // C/C++ include files @@ -167,65 +165,6 @@ static long display(Detector& description, int argc, char** argv) { } DECLARE_APPLY(DD4hep_GeometryDisplay,display) -/// Basic entry point to display the currently loaded geometry using the ROOT7 jsroot viewer -/** - * Factory: DD4hep_GeometryWebDisplay - * - */ -static long webdisplay(Detector& description, int argc, char** argv) { - TGeoManager& mgr = description.manager(); - int vislevel = 6, visopt = 1; - string detector = "/world"; - const char* opt = ""; - for(int i = 0; i < argc && argv[i]; ++i) { - if ( 0 == ::strncmp("-option",argv[i],4) ) - opt = argv[++i]; - else if ( 0 == ::strncmp("-level",argv[i],4) ) - vislevel = ::atol(argv[++i]); - else if ( 0 == ::strncmp("-visopt",argv[i],4) ) - visopt = ::atol(argv[++i]); - else if ( 0 == ::strncmp("-detector",argv[i],4) ) - detector = argv[++i]; - else { - cout << - "Usage: -plugin <name> -arg [-arg] \n" - " -detector <string> Top level DetElement path. Default: '/world' \n" - " -option <string> ROOT Draw option. Default: 'ogl' \n" - " -level <number> Visualization level [TGeoManager::SetVisLevel] Default: 4 \n" - " -visopt <number> Visualization option [TGeoManager::SetVisOption] Default: 1 \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; - ::exit(EINVAL); - } - } - mgr.SetVisLevel(vislevel); - mgr.SetVisOption(visopt); - TGeoVolume* vol = mgr.GetTopVolume(); - if ( detector != "/world" ) { - DetElement elt = detail::tools::findElement(description,detector); - if ( !elt.isValid() ) { - except("DD4hep_GeometryWebDisplay","+++ Invalid DetElement path: %s",detector.c_str()); - } - if ( !elt.placement().isValid() ) { - except("DD4hep_GeometryWebDisplay","+++ Invalid DetElement placement: %s",detector.c_str()); - } - vol = elt.placement().volume(); - } - - if (vol) { - auto viewer = std::make_shared<ROOT::Experimental::REveGeomViewer>(&mgr); - viewer->SelectVolume(vol->GetName()); - viewer->SetLimits(); - viewer->SetDrawOptions(opt); - viewer->Show(); - // add to global heap to avoid immediate destroy of RGeomViewer - ROOT::Experimental::RDirectory::Heap().Add( "geom_viewer", viewer ); - return 1; - } - return 0; -} -DECLARE_APPLY(DD4hep_GeometryWebDisplay,webdisplay) - - /// Basic entry point to execute a public function from a library /** * Factory: DD4hep_Function diff --git a/DDEve/CMakeLists.txt b/DDEve/CMakeLists.txt index e0cbca66fc586f0e87dd914709d986446f8c305d..255e350d8dad68ae3f9289cc44080c5b3c5926e5 100644 --- a/DDEve/CMakeLists.txt +++ b/DDEve/CMakeLists.txt @@ -17,7 +17,7 @@ target_include_directories(DDEve_Interface $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> ) -target_link_libraries(DDEve_Interface INTERFACE ROOT::Core ROOT::Rint ROOT::Eve ROOT::Gui ROOT::Graf3d ROOT::RGL ROOT::EG) +target_link_libraries(DDEve_Interface INTERFACE ROOT::Core ROOT::Rint ROOT::Eve ROOT::Gui ROOT::Graf3d ROOT::RGL ROOT::EG ROOT::ROOTEve) dd4hep_add_dictionary(G__DDEve SOURCES ../DDCore/include/ROOT/Warnings.h include/DDEve/*.h diff --git a/DDEve/src/WebDisplay.cpp b/DDEve/src/WebDisplay.cpp new file mode 100644 index 0000000000000000000000000000000000000000..51d95ea4d21f7ac2b038bc14b23444f3ecd717d8 --- /dev/null +++ b/DDEve/src/WebDisplay.cpp @@ -0,0 +1,91 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// +//========================================================================== + +#include <DD4hep/Detector.h> +#include <DD4hep/Factories.h> +#include <DD4hep/Printout.h> +#include <DD4hep/DetectorTools.h> + +// ROOT includes +#include "ROOT/RDirectory.hxx" +#include "ROOT/REveGeomViewer.hxx" + + +// C/C++ include files +#include <cerrno> +#include <cstdlib> +#include <fstream> +#include <sstream> + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::detail; + + +/// Basic entry point to display the currently loaded geometry using the ROOT7 jsroot viewer +/** + * Factory: DD4hep_GeometryWebDisplay + * + */ +static long webdisplay(Detector& description, int argc, char** argv) { + TGeoManager& mgr = description.manager(); + int vislevel = 6, visopt = 1; + string detector = "/world"; + const char* opt = ""; + for(int i = 0; i < argc && argv[i]; ++i) { + if ( 0 == ::strncmp("-option",argv[i],4) ) + opt = argv[++i]; + else if ( 0 == ::strncmp("-level",argv[i],4) ) + vislevel = ::atol(argv[++i]); + else if ( 0 == ::strncmp("-visopt",argv[i],4) ) + visopt = ::atol(argv[++i]); + else if ( 0 == ::strncmp("-detector",argv[i],4) ) + detector = argv[++i]; + else { + cout << + "Usage: -plugin <name> -arg [-arg] \n" + " -detector <string> Top level DetElement path. Default: '/world' \n" + " -option <string> ROOT Draw option. Default: 'ogl' \n" + " -level <number> Visualization level [TGeoManager::SetVisLevel] Default: 4 \n" + " -visopt <number> Visualization option [TGeoManager::SetVisOption] Default: 1 \n" + "\tArguments given: " << arguments(argc,argv) << endl << flush; + ::exit(EINVAL); + } + } + mgr.SetVisLevel(vislevel); + mgr.SetVisOption(visopt); + TGeoVolume* vol = mgr.GetTopVolume(); + if ( detector != "/world" ) { + DetElement elt = detail::tools::findElement(description,detector); + if ( !elt.isValid() ) { + except("DD4hep_GeometryWebDisplay","+++ Invalid DetElement path: %s",detector.c_str()); + } + if ( !elt.placement().isValid() ) { + except("DD4hep_GeometryWebDisplay","+++ Invalid DetElement placement: %s",detector.c_str()); + } + vol = elt.placement().volume(); + } + + if (vol) { + auto viewer = std::make_shared<ROOT::Experimental::REveGeomViewer>(&mgr); + viewer->SelectVolume(vol->GetName()); + viewer->SetLimits(); + viewer->SetDrawOptions(opt); + viewer->Show(); + // add to global heap to avoid immediate destroy of RGeomViewer + ROOT::Experimental::RDirectory::Heap().Add( "geom_viewer", viewer ); + return 1; + } + return 0; +} +DECLARE_APPLY(DD4hep_GeometryWebDisplay,webdisplay) +