CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

FWViewContextMenuHandlerGL Class Reference

#include <FWViewContextMenuHandlerGL.h>

Inheritance diagram for FWViewContextMenuHandlerGL:
FWViewContextMenuHandlerBase

List of all members.

Public Types

enum  GLViewerAction {
  kAnnotate, kCameraCenter, kResetCameraCenter, kOrigin,
  kNone
}

Public Member Functions

 FWViewContextMenuHandlerGL (FWEveView *v)
virtual void select (int iEntryIndex, const FWModelId &id, int iX, int iY)
virtual ~FWViewContextMenuHandlerGL ()

Private Member Functions

 FWViewContextMenuHandlerGL (const FWViewContextMenuHandlerGL &)
virtual void init (FWViewContextMenuHandlerBase::MenuEntryAdder &, const FWModelId &id)
 Called when have to add entries to the context menu.
const FWViewContextMenuHandlerGLoperator= (const FWViewContextMenuHandlerGL &)

Private Attributes

FWEveViewm_view

Detailed Description

Definition at line 9 of file FWViewContextMenuHandlerGL.h.


Member Enumeration Documentation

Enumerator:
kAnnotate 
kCameraCenter 
kResetCameraCenter 
kOrigin 
kNone 

Definition at line 12 of file FWViewContextMenuHandlerGL.h.


Constructor & Destructor Documentation

FWViewContextMenuHandlerGL::FWViewContextMenuHandlerGL ( FWEveView v)

Definition at line 21 of file FWViewContextMenuHandlerGL.cc.

                                                                   :
m_view(v)
{
}
virtual FWViewContextMenuHandlerGL::~FWViewContextMenuHandlerGL ( ) [inline, virtual]

Definition at line 15 of file FWViewContextMenuHandlerGL.h.

{}
FWViewContextMenuHandlerGL::FWViewContextMenuHandlerGL ( const FWViewContextMenuHandlerGL ) [private]

Member Function Documentation

void FWViewContextMenuHandlerGL::init ( FWViewContextMenuHandlerBase::MenuEntryAdder ,
const FWModelId id 
) [private, virtual]

Called when have to add entries to the context menu.

Implements FWViewContextMenuHandlerBase.

Definition at line 27 of file FWViewContextMenuHandlerGL.cc.

References FWViewContextMenuHandlerBase::MenuEntryAdder::addEntry(), FWViewType::isProjected(), kAnnotate, kCameraCenter, kResetCameraCenter, m_view, L1TEmulatorMonitor_cff::p, and FWViewBase::typeId().

{
   adder.addEntry("Add Annotation", kAnnotate);
   if (FWViewType::isProjected(m_view->typeId()))
   { 
      const char* p  = id.item()->purpose().c_str();
      bool enabled = (strstr(p, "Beam Spot") || strstr(p, "Vertices") );
      adder.addEntry("Use As Projection Origin", kCameraCenter, enabled);
      adder.addEntry("Reset Projection Origin", kResetCameraCenter, enabled);
   }
   else
   { 
      adder.addEntry("Set Camera Center", kCameraCenter);
      adder.addEntry("Reset Camera Center", kResetCameraCenter);
   }   
}
const FWViewContextMenuHandlerGL& FWViewContextMenuHandlerGL::operator= ( const FWViewContextMenuHandlerGL ) [private]
void FWViewContextMenuHandlerGL::select ( int  iEntryIndex,
const FWModelId id,
int  iX,
int  iY 
) [virtual]

Called when a menu item was selected iEntryIndex: the index of the selected menu item. Same as returned from 'addEntry' iX, iY: Screen coordinates of where mouse was clicked

Implements FWViewContextMenuHandlerBase.

Definition at line 45 of file FWViewContextMenuHandlerGL.cc.

References FWEveView::context(), f, getHLTprescales::index, FWModelId::index(), FWViewType::isProjected(), FWModelId::item(), kAnnotate, kCameraCenter, kResetCameraCenter, m_view, FWEventItem::modelData(), FWEventItem::modelType(), mergeVDriftHistosByStation::name, FWEventItem::purpose(), FWRPZView::resetOrigin(), FWSelectionManager::selected(), fireworks::Context::selectionManager(), FWRPZView::shiftOrigin(), FWViewBase::typeId(), v, FWItemValueGetter::valueFor(), FWEveView::viewerGL(), x, and detailsBasic3DVector::y.

{
   TGLViewer* v = m_view->viewerGL();

   Window_t wdummy;
   Int_t x,y;
   gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(), v->GetGLWidget()->GetId(), iX, iY, x, y, wdummy);   
   TGLVector3 pnt(x, y, 0.5*v->GetSelRec().GetMinZ());
   v->CurrentCamera().WindowToViewport(pnt);
   pnt = v->CurrentCamera().ViewportToWorld(pnt);

   switch (iEntryIndex)
   {
      case kAnnotate:
      {
         TGFrame* f = v->GetGLWidget();
         gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(), f->GetId(), iX, iY, x, y, wdummy);

         std::string name = id.item()->modelName(id.index());
         if (id.item()->haveInterestingValue())
            name += ", " + id.item()->modelInterestingValueAsString(id.index());

         TGLAnnotation* an = new TGLAnnotation(v, name.c_str(),  x*1.f/f->GetWidth(), 1 - y*1.f/f->GetHeight(), pnt);
         an->SetUseColorSet(true);
         an->SetTextSize(0.03);
         break;
      }
      case kCameraCenter:
      {
         TEveVector center;
         if (FWViewType::isProjected(m_view->typeId()))
         {

            // AMT:: find way to get values without using FWItemValueGetter

            FWModelId mId = *(m_view->context().selectionManager()->selected().begin());
            const FWEventItem* item = mId.item();

            bool bs = strstr(item->purpose().c_str(), "Beam Spot");
            std::vector<std::pair<std::string,std::string> > func;
            func.push_back(std::pair<std::string,std::string>("", "cm"));
            {  
               func.back().first = bs ? "x0" : "x";
               FWItemValueGetter valueGetter(ROOT::Reflex::Type::ByTypeInfo(*(item->modelType()->GetTypeInfo())), func);
               center.fX = valueGetter.valueFor(item->modelData(mId.index())); 
            }
            {
               func.back().first = bs ? "y0" : "y";
               FWItemValueGetter valueGetter(ROOT::Reflex::Type::ByTypeInfo(*(item->modelType()->GetTypeInfo())), func);
               center.fY = valueGetter.valueFor(item->modelData(mId.index()));
            }
            {  
               func.back().first = bs ? "z0" : "z";
               FWItemValueGetter valueGetter(ROOT::Reflex::Type::ByTypeInfo(*(item->modelType()->GetTypeInfo())), func);
               center.fZ = valueGetter.valueFor(item->modelData(mId.index()));
            }

            FWRPZView* pv = static_cast<FWRPZView*>(m_view);
            pv->shiftOrigin(center);
         }

         else
         {
            v->CurrentCamera().SetCenterVec(pnt.X(), pnt.Y(), pnt.Z());
            v->CurrentCamera().SetExternalCenter(true);
            v->SetDrawCameraCenter(true);
         }

         break;
      }
      case kResetCameraCenter:
      { 
         if (FWViewType::isProjected(m_view->typeId()))
         {
            FWRPZView* pv = static_cast<FWRPZView*>(m_view);
            pv->resetOrigin();
         }

         v->CurrentCamera().SetExternalCenter(false);
         v->SetDrawCameraCenter(false);
         break;
      }
   }
}

Member Data Documentation

Definition at line 24 of file FWViewContextMenuHandlerGL.h.

Referenced by init(), and select().