CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Core/src/FWEventAnnotation.cc

Go to the documentation of this file.
00001 #include "TGLViewer.h"
00002 #include "TEveManager.h"
00003 
00004 #include "Fireworks/Core/interface/FWEventAnnotation.h"
00005 #include "Fireworks/Core/interface/FWGUIManager.h"
00006 #include "Fireworks/Core/interface/BuilderUtils.h"
00007 #include "Fireworks/Core/interface/FWConfiguration.h"
00008 
00009 #include "DataFormats/FWLite/interface/Event.h"
00010 
00011 FWEventAnnotation::FWEventAnnotation(TGLViewerBase *view):
00012    TGLAnnotation(view, "Event Info", 0.05, 0.95),
00013    m_level(1)
00014 {
00015    SetRole(TGLOverlayElement::kViewer);
00016    SetUseColorSet(true);
00017    fAllowClose = false;
00018 }
00019 
00020 FWEventAnnotation::~FWEventAnnotation()
00021 {
00022 }
00023 
00024 //______________________________________________________________________________
00025 
00026 void
00027 FWEventAnnotation::setLevel(long x)
00028 { 
00029    if (x != m_level)
00030    {
00031       m_level = x;
00032       fParent->Changed();
00033       gEve->Redraw3D();
00034    }
00035    updateOverlayText();
00036 }
00037 
00038 
00039 void
00040 FWEventAnnotation::setEvent()
00041 {
00042    updateOverlayText();
00043 }
00044 
00045 void
00046 FWEventAnnotation::updateOverlayText()
00047 {
00048    fText = "CMS Experiment at LHC, CERN";
00049 
00050    const edm::EventBase* event = FWGUIManager::getGUIManager()->getCurrentEvent();
00051 
00052    if (event && m_level)
00053    {
00054       fText += "\nData recorded: ";
00055       fText += fireworks::getLocalTime( *event );
00056       fText += "\nRun/Event: ";
00057       fText += event->id().run();
00058       fText += " / ";
00059       fText += event->id().event();
00060       if ( m_level > 1)
00061       {
00062          fText += "\nLumi section: ";
00063          fText += event->luminosityBlock();
00064       }
00065       if ( m_level > 2)
00066       {
00067          fText += "\nOrbit/Crossing: ";
00068          fText += event->orbitNumber();
00069          fText += " / ";
00070          fText += event->bunchCrossing();
00071       }
00072    }
00073 
00074    if (m_level)
00075    {
00076       fParent->Changed();
00077       gEve->Redraw3D();
00078    }
00079 }
00080 
00081 void
00082 FWEventAnnotation::Render(TGLRnrCtx& rnrCtx)
00083 {
00084    if (m_level)
00085       TGLAnnotation::Render(rnrCtx);
00086 }
00087 
00088 //______________________________________________________________________________
00089 
00090 void
00091 FWEventAnnotation::addTo(FWConfiguration& iTo) const
00092 {
00093    std::stringstream s;
00094    s<<fTextSize;
00095    iTo.addKeyValue("EventInfoTextSize",FWConfiguration(s.str()));
00096 
00097    std::stringstream x;
00098    x<<fPosX;
00099    iTo.addKeyValue("EventInfoPosX",FWConfiguration(x.str()));
00100 
00101    std::stringstream y;
00102    y<<fPosY;
00103    iTo.addKeyValue("EventInfoPosY",FWConfiguration(y.str()));
00104 }
00105 
00106 void
00107 FWEventAnnotation::setFrom(const FWConfiguration& iFrom) 
00108 {
00109    const FWConfiguration* value;
00110 
00111    value = iFrom.valueForKey("EventInfoTextSize");
00112    if (value) fTextSize = atof(value->value().c_str());
00113 
00114    value = iFrom.valueForKey("EventInfoPosX");
00115    if (value) fPosX = atof(value->value().c_str());
00116 
00117    value = iFrom.valueForKey("EventInfoPosY");
00118    if (value) fPosY = atof(value->value().c_str());
00119 
00120 }
00121