Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
#include "TGLViewer.h"
#include "TEveManager.h"

#include "Fireworks/Core/interface/FWEventAnnotation.h"
#include "Fireworks/Core/interface/FWGUIManager.h"
#include "Fireworks/Core/interface/BuilderUtils.h"
#include "Fireworks/Core/interface/FWConfiguration.h"

#include "DataFormats/FWLite/interface/Event.h"

FWEventAnnotation::FWEventAnnotation(TGLViewerBase* view) : TGLAnnotation(view, "Event Info", 0.05, 0.95), m_level(1) {
  SetRole(TGLOverlayElement::kViewer);
  SetUseColorSet(true);
  fAllowClose = false;
}

FWEventAnnotation::~FWEventAnnotation() {}

//______________________________________________________________________________

void FWEventAnnotation::setLevel(long x) {
  if (x != m_level) {
    m_level = x;
    fParent->Changed();
    gEve->Redraw3D();
  }
  updateOverlayText();
}

void FWEventAnnotation::setEvent() { updateOverlayText(); }

void FWEventAnnotation::updateOverlayText() {
  fText = "CMS Experiment at LHC, CERN";

  const edm::EventBase* event = FWGUIManager::getGUIManager()->getCurrentEvent();

  if (event && m_level) {
    fText += "\nData recorded: ";
    fText += fireworks::getLocalTime(*event);
    fText += "\nRun/Event: ";
    fText += event->id().run();
    fText += " / ";
    fText += event->id().event();
    if (m_level > 1) {
      fText += "\nLumi section: ";
      fText += event->luminosityBlock();
    }
    if (m_level > 2) {
      fText += "\nOrbit/Crossing: ";
      fText += event->orbitNumber();
      fText += " / ";
      fText += event->bunchCrossing();
    }
  }

  if (m_level) {
    fParent->Changed();
    gEve->Redraw3D();
  }
}

void FWEventAnnotation::Render(TGLRnrCtx& rnrCtx) {
  if (m_level)
    TGLAnnotation::Render(rnrCtx);
}

//______________________________________________________________________________

void FWEventAnnotation::addTo(FWConfiguration& iTo) const {
  std::stringstream s;
  s << fTextSize;
  iTo.addKeyValue("EventInfoTextSize", FWConfiguration(s.str()));

  std::stringstream x;
  x << fPosX;
  iTo.addKeyValue("EventInfoPosX", FWConfiguration(x.str()));

  std::stringstream y;
  y << fPosY;
  iTo.addKeyValue("EventInfoPosY", FWConfiguration(y.str()));
}

void FWEventAnnotation::setFrom(const FWConfiguration& iFrom) {
  const FWConfiguration* value;

  value = iFrom.valueForKey("EventInfoTextSize");
  if (value)
    fTextSize = atof(value->value().c_str());

  value = iFrom.valueForKey("EventInfoPosX");
  if (value)
    fPosX = atof(value->value().c_str());

  value = iFrom.valueForKey("EventInfoPosY");
  if (value)
    fPosY = atof(value->value().c_str());
}