CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Fireworks/Core/src/FW3DViewBase.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FW3DViewBase
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Thu Feb 21 11:22:41 EST 2008
00011 // $Id: FW3DViewBase.cc,v 1.21 2011/02/22 18:37:31 amraktad Exp $
00012 //
00013 #include <boost/bind.hpp>
00014 
00015 // user include files
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 // constants, enums and typedefs
00034 //
00035 
00036 //
00037 // static data member definitions
00038 //
00039 //double FW3DViewBase::m_scale = 1;
00040 
00041 //
00042 // constructors and destructor
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    // take care of parameters
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    // take care of parameters
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       // transparency moved to common preferences in FWEveView version 5
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