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 26 of file FWViewContextMenuHandlerGL.cc.

References FWViewContextMenuHandlerBase::MenuEntryAdder::addEntry(), FWViewType::isProjected(), kAnnotate, kCameraCenter, kResetCameraCenter, m_view, AlCaHLTBitMon_ParallelJobs::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 44 of file FWViewContextMenuHandlerGL.cc.

References FWEveView::context(), f, getHLTprescales::index, FWModelId::index(), FWViewType::isProjected(), FWModelId::item(), kAnnotate, kCameraCenter, kResetCameraCenter, m_view, FWEventItem::modelData(), mergeVDriftHistosByStation::name, FWRPZView::resetOrigin(), FWSelectionManager::selected(), fireworks::Context::selectionManager(), FWRPZView::shiftOrigin(), FWViewBase::typeId(), v, FWItemValueGetter::valueFor(), FWEventItem::valueGetter(), 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:
      {
         if (FWViewType::isProjected(m_view->typeId()))
         {
            FWModelId mId = *(m_view->context().selectionManager()->selected().begin());
            const FWItemValueGetter& valueGetter = mId.item()->valueGetter();
            TEveVector center;
            center.fX = valueGetter.valueFor(mId.item()->modelData(mId.index()), 0);
            center.fY = valueGetter.valueFor(mId.item()->modelData(mId.index()), 1);
            center.fZ = valueGetter.valueFor(mId.item()->modelData(mId.index()), 2);

            FWRPZView* pv = static_cast<FWRPZView*>(m_view);
            pv->shiftOrigin(center);
         }
         else
         {
            v->CurrentCamera().SetExternalCenter(true);
            v->CurrentCamera().SetCenterVec(pnt.X(), pnt.Y(), pnt.Z());
            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().