CMS 3D CMS Logo

Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes

FWLegoViewBase Class Reference

#include <Fireworks/Core/interface/FWLegoViewBase.h>

Inheritance diagram for FWLegoViewBase:
FWEveView FWViewBase FWConfigurableParameterizable FWParameterizable FWConfigurable FWEveLegoView FWHFView

List of all members.

Public Member Functions

virtual void addTo (FWConfiguration &) const
 FWLegoViewBase (TEveWindowSlot *, FWViewType::EType)
virtual TEveCaloViz * getEveCalo () const
virtual void populateController (ViewerParameterGUI &) const
virtual void setContext (const fireworks::Context &)
virtual void setFrom (const FWConfiguration &)
virtual ~FWLegoViewBase ()

Protected Attributes

TEveCaloLego * m_lego
TEveCaloLegoOverlay * m_overlay

Private Member Functions

void autoScale ()
 FWLegoViewBase (const FWLegoViewBase &)
const FWLegoViewBaseoperator= (const FWLegoViewBase &)
void setAutoRebin ()
void setCameras ()
void setCell2DMode ()
void setFontSizein2D ()
void setPixelsPerBin ()
void setProjectionMode ()
void showOverlay ()

Private Attributes

FWBoolParameter m_autoRebin
FWEnumParameter m_cell2DMode
FWLongParameter m_drawValuesIn2D
FWDoubleParameter m_pixelsPerBin
FWEnumParameter m_projectionMode
FWBoolParameter m_showOverlay

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 40 of file FWLegoViewBase.h.


Constructor & Destructor Documentation

FWLegoViewBase::FWLegoViewBase ( TEveWindowSlot *  iParent,
FWViewType::EType  typeId 
)

Definition at line 53 of file FWLegoViewBase.cc.

References FWEnumParameter::addEntry(), FWGenericParameter< T >::changed_, FWViewType::kLegoHF, m_autoRebin, m_cell2DMode, m_drawValuesIn2D, m_pixelsPerBin, m_projectionMode, m_showOverlay, FWGenericParameter< T >::set(), setAutoRebin(), setCell2DMode(), setFontSizein2D(), setPixelsPerBin(), setProjectionMode(), showOverlay(), and FWEveView::viewerGL().

                                                                              :
   FWEveView(iParent, typeId),
   m_lego(0),
   m_overlay(0),
   m_autoRebin(this,"Auto rebin on zoom-out",false),
   m_pixelsPerBin(this, "Pixels per bin", 10., 1., 20.),
   m_projectionMode(this, "Projection", 0l, 0l, 2l),
   m_cell2DMode(this, "Cell2DMode", 1l, 1l, 2l),
   m_drawValuesIn2D(this,"Draw Cell2D threshold (pixels)",40l,16l,200l),
   m_showOverlay(this,"Draw scales", true)
{
   viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
   viewerGL()->GetLightSet()->SetUseSpecular(false);

   m_projectionMode.addEntry(0, "Auto");
   m_projectionMode.addEntry(1, "3D");
   m_projectionMode.addEntry(2, "2D");

   m_cell2DMode.addEntry(1, "Plain");
   m_cell2DMode.addEntry(2, "Outline");
   if (typeId == FWViewType::kLegoHF) m_cell2DMode.set(2); // different default for HF view

   m_autoRebin.changed_.connect(boost::bind(&FWLegoViewBase::setAutoRebin,this));
   m_pixelsPerBin.changed_.connect(boost::bind(&FWLegoViewBase::setPixelsPerBin,this));
   m_drawValuesIn2D.changed_.connect(boost::bind(&FWLegoViewBase::setFontSizein2D,this));
   m_showOverlay.changed_.connect(boost::bind(&FWLegoViewBase::showOverlay,this));
   m_projectionMode.changed_.connect(boost::bind(&FWLegoViewBase::setProjectionMode, this));
   m_cell2DMode.changed_.connect(boost::bind(&FWLegoViewBase::setCell2DMode, this));
}
FWLegoViewBase::~FWLegoViewBase ( ) [virtual]

Definition at line 83 of file FWLegoViewBase.cc.

References m_lego, m_overlay, and FWEveView::viewerGL().

{
   viewerGL()->RemoveOverlayElement(m_overlay);
   m_lego->Destroy();
}
FWLegoViewBase::FWLegoViewBase ( const FWLegoViewBase ) [private]

Member Function Documentation

void FWLegoViewBase::addTo ( FWConfiguration iTo) const [virtual]

Reimplemented from FWEveView.

Definition at line 265 of file FWLegoViewBase.cc.

References FWConfiguration::addKeyValue(), FWEveView::addToOrthoCamera(), FWEveView::addToPerspectiveCamera(), mergeVDriftHistosByStation::name, alignCSCRings::s, FWViewBase::typeName(), and FWEveView::viewerGL().

{
   FWEveView::addTo(iTo);
   
   bool topView =  viewerGL()->CurrentCamera().IsOrthographic();
   std::ostringstream s;
   s << topView;
   std::string name = "topView";
   iTo.addKeyValue(name+typeName(),FWConfiguration(s.str()));
   
   if (topView)
   {
      TGLOrthoCamera* camera = dynamic_cast<TGLOrthoCamera*>(&(viewerGL()->RefCamera(TGLViewer::kCameraOrthoXOY)));
      addToOrthoCamera(camera, iTo);  
   }
   else
   {
      TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->RefCamera(TGLViewer::kCameraPerspXOY)));
      addToPerspectiveCamera(camera, typeName(), iTo);   
   }
}
void FWLegoViewBase::autoScale ( ) [private]
TEveCaloViz * FWLegoViewBase::getEveCalo ( ) const [virtual]

Reimplemented from FWEveView.

Definition at line 91 of file FWLegoViewBase.cc.

References m_lego.

{
   return static_cast<TEveCaloViz*>(m_lego);
}
const FWLegoViewBase& FWLegoViewBase::operator= ( const FWLegoViewBase ) [private]
void FWLegoViewBase::populateController ( ViewerParameterGUI gui) const [virtual]

Reimplemented from FWEveView.

Definition at line 313 of file FWLegoViewBase.cc.

References m_autoRebin, m_cell2DMode, m_drawValuesIn2D, m_pixelsPerBin, m_projectionMode, m_showOverlay, and ViewerParameterGUI::requestTab().

{
   FWEveView::populateController(gui);

   gui.requestTab("Style").
      separator().
      addParam(&m_projectionMode).
      addParam(&m_cell2DMode).
      addParam(&m_drawValuesIn2D);
  
   gui.requestTab("Scales").
      separator().
      addParam(&m_showOverlay);

   gui.requestTab("Rebin").
      addParam(&m_autoRebin).
      addParam(&m_pixelsPerBin);
}
void FWLegoViewBase::setAutoRebin ( ) [private]

Definition at line 163 of file FWLegoViewBase.cc.

References m_autoRebin, m_lego, and FWGenericParameter< T >::value().

Referenced by FWLegoViewBase().

{
   m_lego->SetAutoRebin(m_autoRebin.value());
   m_lego->ElementChanged(kTRUE,kTRUE);
}
void FWLegoViewBase::setCameras ( ) [private]
void FWLegoViewBase::setCell2DMode ( ) [private]

Definition at line 304 of file FWLegoViewBase.cc.

References m_cell2DMode, m_lego, FWGenericParameter< T >::value(), and FWEveView::viewerGL().

Referenced by FWLegoViewBase().

{
   m_lego->Set2DMode((TEveCaloLego::E2DMode_e)m_cell2DMode.value());
   m_lego->ElementChanged();
   viewerGL()->Changed();
   gEve->Redraw3D();
}
void FWLegoViewBase::setContext ( const fireworks::Context ctx) [virtual]

Reimplemented from FWEveView.

Reimplemented in FWEveLegoView, and FWHFView.

Definition at line 97 of file FWLegoViewBase.cc.

References data, FWEveView::eventScene(), fireworks::Context::getCaloData(), fireworks::Context::getCaloDataHF(), FWViewType::kLego, FWViewType::kLegoHF, m_autoRebin, m_cell2DMode, m_drawValuesIn2D, m_lego, m_overlay, m_pixelsPerBin, Pi, ntuplemaker::status, TwoPi, FWViewBase::typeId(), FWGenericParameter< T >::value(), FWEveView::viewerGL(), fw3dlego::xbins, and fw3dlego::xbins_n.

{
   FWEveView::setContext(ctx);
  
   TEveCaloData* data;
   if (typeId() == FWViewType::kLego)  {
      data = static_cast<TEveCaloData*>(ctx.getCaloData());
   }
   else if (typeId() == FWViewType::kLegoHF) {
      data = static_cast<TEveCaloData*>(ctx.getCaloDataHF());
   }
   else
   {
      // create empty data locally instead of context
      TEveCaloDataHist* hdata = new TEveCaloDataHist();
      hdata->IncDenyDestroy();

      Bool_t status = TH1::AddDirectoryStatus();
      TH1::AddDirectory(kFALSE); //Keeps histogram from going into memory
      TH2F* dummy = new TH2F("background",
                             "background",
                             fw3dlego::xbins_n - 1, fw3dlego::xbins,
                             72, -1*TMath::Pi(), TMath::Pi());
      
      TH1::AddDirectory(status);
      Int_t sliceIndex = hdata->AddHistogram(dummy);
      (hdata)->RefSliceInfo(sliceIndex).Setup("background", 0., 0);
      data = hdata;
   } 

   data->GetEtaBins()->SetNdivisions(710);
   data->GetPhiBins()->SetNdivisions(510);
   data->GetEtaBins()->SetTitleFont(120);
   data->GetEtaBins()->SetTitle("h");
   data->GetPhiBins()->SetTitleFont(120);
   data->GetPhiBins()->SetTitle("f");
   data->GetEtaBins()->SetLabelSize(0.02);
   data->GetEtaBins()->SetTitleSize(0.03);

   m_lego = new TEveCaloLego(data);
   m_lego->Set2DMode((TEveCaloLego::E2DMode_e)m_cell2DMode.value());
   m_lego->SetDrawNumberCellPixels(m_drawValuesIn2D.value());
   m_lego->SetAutoRebin(m_autoRebin.value());
   m_lego->SetPixelsPerBin(m_pixelsPerBin.value());

   m_lego->InitMainTrans();
   m_lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
   m_lego->SetScaleAbs(true);
   
   // set flat in 2D
   m_lego->SetHasFixedHeightIn2DMode(true);
   m_lego->SetFixedHeightValIn2DMode(0.001);
   eventScene()->AddElement(m_lego);

   TEveLegoEventHandler* eh = dynamic_cast<TEveLegoEventHandler*>( viewerGL()->GetEventHandler());
   if (eh) eh->SetLego(m_lego);
  
   m_overlay = new TEveCaloLegoOverlay();
   m_overlay->SetCaloLego(m_lego);
   m_overlay->SetShowPlane(kFALSE);
   m_overlay->SetScalePosition(0.8, 0.6);
   m_overlay->SetShowScales(1); //temporary
   viewerGL()->AddOverlayElement(m_overlay);
}
void FWLegoViewBase::setFontSizein2D ( ) [private]

Definition at line 288 of file FWLegoViewBase.cc.

References m_drawValuesIn2D, m_lego, and FWGenericParameter< T >::value().

Referenced by FWLegoViewBase().

{
   m_lego->SetDrawNumberCellPixels( m_drawValuesIn2D.value());
   m_lego->ElementChanged(kTRUE,kTRUE);
}
void FWLegoViewBase::setFrom ( const FWConfiguration iFrom) [virtual]

Reimplemented from FWEveView.

Definition at line 187 of file FWLegoViewBase.cc.

References m_autoRebin, m_cell2DMode, m_showOverlay, mode, alignCSCRings::s, FWGenericParameter< T >::set(), FWEveView::setFromOrthoCamera(), FWEveView::setFromPerspectiveCamera(), FWViewBase::typeName(), FWConfiguration::value(), relativeConstraints::value, FWConfiguration::valueForKey(), FWConfiguration::version(), and FWEveView::viewerGL().

{
   FWEveView::setFrom(iFrom);

   // cell 2D style
   if (iFrom.version() < 5)
   {
      const FWConfiguration* value = iFrom.valueForKey( "Cell2DMode" );
      if ( value !=  0 )
      {
         int mode;
         std::istringstream s(value->value());
         s>> mode;
         m_cell2DMode.set(mode);
      }
  
   }

   // view controller parameters, changed name in version 4
   if (iFrom.version() < 4)
   {
      bool xb;/* double xd;
      {
         std::istringstream s(iFrom.valueForKey("Lego auto scale")->value());
         s >> xb; m_energyScaleMode.set(xb ? FWEveView::kAutoScale : FWEveView::kFixedScale);
      }
      {
         std::istringstream s(iFrom.valueForKey("Lego scale GeV)")->value());
         s >> xd; m_energyMaxAbsVal.set(xd);
         }*/
      {
         std::istringstream s(iFrom.valueForKey("Show scales")->value());
         s >> xb; m_showOverlay.set(xb);
      }
      {
         std::istringstream s(iFrom.valueForKey("Show scales")->value());
         s >> xb; m_showOverlay.set(xb);
      }
      {
         std::istringstream s(iFrom.valueForKey("Auto rebin on zoom")->value());
         s >> xb; m_autoRebin.set(xb);
      }
   }

   //
   // camera restore

   if (iFrom.version() > 1)
   {
      bool topView = true;
      std::string stateName("topView"); stateName += typeName();
      assert( 0 != iFrom.valueForKey(stateName));
      std::istringstream s(iFrom.valueForKey(stateName)->value());
      s >> topView;


      if (topView)
      {
         viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
         TGLOrthoCamera* camera = dynamic_cast<TGLOrthoCamera*>( &(viewerGL()->RefCamera(TGLViewer::kCameraOrthoXOY)) );
         setFromOrthoCamera(camera, iFrom);
      }
      else
      {
         viewerGL()->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
         TGLPerspectiveCamera* camera = dynamic_cast<TGLPerspectiveCamera*>(&(viewerGL()->RefCamera(TGLViewer::kCameraPerspXOY)));
         setFromPerspectiveCamera(camera, typeName(), iFrom);
      }
   }
   else
   {
      // reset camera if version not supported    
      viewerGL()->ResetCamerasAfterNextUpdate();
   }
   
}
void FWLegoViewBase::setPixelsPerBin ( ) [private]

Definition at line 170 of file FWLegoViewBase.cc.

References m_lego, m_pixelsPerBin, and FWGenericParameter< T >::value().

Referenced by FWLegoViewBase().

{
   m_lego->SetPixelsPerBin((Int_t) (m_pixelsPerBin.value()));
   m_lego->ElementChanged(kTRUE,kTRUE);
}
void FWLegoViewBase::setProjectionMode ( ) [private]

Definition at line 295 of file FWLegoViewBase.cc.

References m_lego, m_projectionMode, FWGenericParameter< T >::value(), and FWEveView::viewerGL().

Referenced by FWLegoViewBase().

{
   m_lego->SetProjection((TEveCaloLego::EProjection_e)m_projectionMode.value());
   m_lego->ElementChanged();
   viewerGL()->Changed();
   gEve->Redraw3D();
}
void FWLegoViewBase::showOverlay ( ) [private]

Definition at line 177 of file FWLegoViewBase.cc.

References m_overlay, m_showOverlay, FWGenericParameter< T >::value(), and FWEveView::viewerGL().

Referenced by FWLegoViewBase().

{
   if (m_overlay) m_overlay->SetShowScales(m_showOverlay.value());
   viewerGL()->Changed();
   gEve->Redraw3D();
}

Member Data Documentation

Definition at line 83 of file FWLegoViewBase.h.

Referenced by FWLegoViewBase(), populateController(), setContext(), and setFontSizein2D().

TEveCaloLego* FWLegoViewBase::m_lego [protected]
TEveCaloLegoOverlay* FWLegoViewBase::m_overlay [protected]

Definition at line 61 of file FWLegoViewBase.h.

Referenced by setContext(), showOverlay(), and ~FWLegoViewBase().

Definition at line 80 of file FWLegoViewBase.h.

Referenced by FWLegoViewBase(), populateController(), setContext(), and setPixelsPerBin().

Definition at line 81 of file FWLegoViewBase.h.

Referenced by FWLegoViewBase(), populateController(), and setProjectionMode().

Definition at line 84 of file FWLegoViewBase.h.

Referenced by FWLegoViewBase(), populateController(), setFrom(), and showOverlay().