00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <boost/bind.hpp>
00014
00015
00016
00017 #include "TGButton.h"
00018 #include "TGLScenePad.h"
00019 #include "TGLViewer.h"
00020 #include "TGLPerspectiveCamera.h"
00021 #include "TEveManager.h"
00022 #include "TEveElement.h"
00023 #include "TEveScene.h"
00024
00025 #include "Fireworks/Core/interface/FW3DViewBase.h"
00026 #include "Fireworks/Core/interface/FW3DViewGeometry.h"
00027 #include "Fireworks/Core/interface/Context.h"
00028 #include "Fireworks/Core/interface/FWViewContext.h"
00029 #include "Fireworks/Core/interface/FWViewEnergyScale.h"
00030 #include "Fireworks/Core/interface/CmsShowViewPopup.h"
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 FW3DViewBase::FW3DViewBase(TEveWindowSlot* iParent, FWViewType::EType typeId):
00045 FWEveView(iParent, typeId),
00046 m_geometry(0),
00047 m_showMuonBarrel(this, "Show Muon Barrel", false ),
00048 m_showMuonEndcap(this, "Show Muon Endcap", false),
00049 m_showPixelBarrel(this, "Show Pixel Barrel", false ),
00050 m_showPixelEndcap(this, "Show Pixel Endcap", false),
00051 m_showTrackerBarrel(this, "Show Tracker Barrel", false ),
00052 m_showTrackerEndcap(this, "Show Tracker Endcap", false),
00053 m_showWireFrame(this, "Show Wire Frame", true)
00054 {
00055 viewerGL()->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
00056 }
00057
00058 FW3DViewBase::~FW3DViewBase()
00059 {
00060 delete m_geometry;
00061 }
00062
00063 void FW3DViewBase::setContext(const fireworks::Context& context)
00064 {
00065 FWEveView::setContext(context);
00066
00067 m_geometry = new FW3DViewGeometry(context);
00068 geoScene()->AddElement(m_geometry);
00069
00070 m_showMuonBarrel.changed_.connect(boost::bind(&FW3DViewGeometry::showMuonBarrel,m_geometry,_1));
00071 m_showMuonEndcap.changed_.connect(boost::bind(&FW3DViewGeometry::showMuonEndcap,m_geometry,_1));
00072 m_showPixelBarrel.changed_.connect(boost::bind(&FW3DViewGeometry::showPixelBarrel,m_geometry,_1));
00073 m_showPixelEndcap.changed_.connect(boost::bind(&FW3DViewGeometry::showPixelEndcap,m_geometry,_1));
00074 m_showTrackerBarrel.changed_.connect(boost::bind(&FW3DViewGeometry::showTrackerBarrel,m_geometry,_1));
00075 m_showTrackerEndcap.changed_.connect(boost::bind(&FW3DViewGeometry::showTrackerEndcap,m_geometry,_1));
00076 m_showWireFrame.changed_.connect(boost::bind(&FW3DViewBase::showWireFrame,this, _1));
00077 }
00078
00079 void
00080 FW3DViewBase::showWireFrame( bool x)
00081 {
00082 geoScene()->GetGLScene()->SetStyle(x ? TGLRnrCtx::kWireFrame : TGLRnrCtx::kFill);
00083 viewerGL()->Changed();
00084 gEve->Redraw3D();
00085 }
00086
00087
00088 void
00089 FW3DViewBase::addTo(FWConfiguration& iTo) const
00090 {
00091
00092 FWEveView::addTo(iTo);
00093 TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
00094 if (camera)
00095 addToPerspectiveCamera(camera, "Plain3D", iTo);
00096 }
00097
00098
00099 void
00100 FW3DViewBase::setFrom(const FWConfiguration& iFrom)
00101 {
00102
00103 FWEveView::setFrom(iFrom);
00104
00105 TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->CurrentCamera()));
00106 if (camera)
00107 setFromPerspectiveCamera(camera, "Plain3D", iFrom);
00108
00109 if (iFrom.version() < 5)
00110 {
00111
00112 std::string tName("Detector Transparency");
00113 std::istringstream s(iFrom.valueForKey(tName)->value());
00114 int transp;
00115 s>> transp;
00116 context().colorManager()->setGeomTransparency(transp, false);
00117 }
00118 }
00119
00120
00121 void
00122 FW3DViewBase::populateController(ViewerParameterGUI& gui) const
00123 {
00124 FWEveView::populateController(gui);
00125
00126 gui.requestTab("Detector").
00127 addParam(&m_showPixelBarrel).
00128 addParam(&m_showPixelEndcap).
00129 addParam(&m_showTrackerBarrel).
00130 addParam(&m_showTrackerEndcap).
00131 addParam(&m_showMuonBarrel).
00132 addParam(&m_showMuonEndcap).
00133 addParam(&m_showWireFrame);
00134
00135 gui.requestTab("Style").separator();
00136 gui.getTabContainer()->AddFrame(new TGTextButton(gui.getTabContainer(), "Root controls",
00137 Form("TEveGedEditor::SpawnNewEditor((TGLViewer*)0x%lx)", (unsigned long)viewerGL())));
00138 }
00139
00140
00141