CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
FWViewContextMenuHandlerGL Class Reference

#include <FWViewContextMenuHandlerGL.h>

Inheritance diagram for FWViewContextMenuHandlerGL:
FWViewContextMenuHandlerBase

Public Types

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

Public Member Functions

 FWViewContextMenuHandlerGL (FWEveView *v)
 
void select (int iEntryIndex, const FWModelId &id, int iX, int iY) override
 
 ~FWViewContextMenuHandlerGL () override
 
- Public Member Functions inherited from FWViewContextMenuHandlerBase
void addTo (FWModelContextMenuHandler &, const FWModelId &id)
 
 FWViewContextMenuHandlerBase ()
 
virtual ~FWViewContextMenuHandlerBase ()
 

Private Member Functions

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

Private Attributes

FWEveViewm_view
 

Detailed Description

Definition at line 9 of file FWViewContextMenuHandlerGL.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

FWViewContextMenuHandlerGL::FWViewContextMenuHandlerGL ( FWEveView v)

Definition at line 21 of file FWViewContextMenuHandlerGL.cc.

Referenced by ~FWViewContextMenuHandlerGL().

21  :
22  m_view(v)
23 {}
FWViewContextMenuHandlerGL::~FWViewContextMenuHandlerGL ( )
inlineoverride

Definition at line 15 of file FWViewContextMenuHandlerGL.h.

References FWViewContextMenuHandlerGL(), init(), operator=(), and select().

15 {}
FWViewContextMenuHandlerGL::FWViewContextMenuHandlerGL ( const FWViewContextMenuHandlerGL )
privatedelete

Member Function Documentation

void FWViewContextMenuHandlerGL::init ( FWViewContextMenuHandlerBase::MenuEntryAdder ,
const FWModelId id 
)
overrideprivatevirtual

Called when have to add entries to the context menu.

Implements FWViewContextMenuHandlerBase.

Definition at line 26 of file FWViewContextMenuHandlerGL.cc.

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

Referenced by ~FWViewContextMenuHandlerGL().

27 {
28  adder.addEntry("Add Annotation", kAnnotate);
30  {
31  const char* p = id.item()->purpose().c_str();
32  bool enabled = (strstr(p, "Beam Spot") || strstr(p, "Vertices") );
33  adder.addEntry("Use As Projection Origin", kCameraCenter, enabled);
34  adder.addEntry("Reset Projection Origin", kResetCameraCenter, enabled);
35  }
36  else
37  {
38  adder.addEntry("Set Camera Center", kCameraCenter);
39  adder.addEntry("Reset Camera Center", kResetCameraCenter);
40  }
41 }
static bool isProjected(int)
Definition: FWViewType.cc:128
FWViewType::EType typeId() const
Definition: FWViewBase.h:43
const FWViewContextMenuHandlerGL& FWViewContextMenuHandlerGL::operator= ( const FWViewContextMenuHandlerGL )
privatedelete
void FWViewContextMenuHandlerGL::select ( int  iEntryIndex,
const FWModelId id,
int  iX,
int  iY 
)
overridevirtual

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, FWModelId::index(), diffTreeTool::index, FWViewType::isProjected(), FWModelId::item(), kAnnotate, kCameraCenter, kResetCameraCenter, m_view, FWEventItem::modelData(), dataset::name, MetAnalyzer::pv(), FWRPZView::resetOrigin(), FWSelectionManager::selected(), fireworks::Context::selectionManager(), FWRPZView::shiftOrigin(), AlCaHLTBitMon_QueryRunRegistry::string, FWViewBase::typeId(), findQualityFiles::v, FWItemValueGetter::valueFor(), FWEventItem::valueGetter(), FWEveView::viewerGL(), x, and y.

Referenced by Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Views.LineDecayView.LineDecayContainer::mousePressEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), Vispa.Views.AbstractView.AbstractView::restoreSelection(), and ~FWViewContextMenuHandlerGL().

45 {
46  TGLViewer *v = m_view->viewerGL();
47 
48  Window_t wdummy;
49  Int_t x, y;
50  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(), v->GetGLWidget()->GetId(), iX, iY, x, y, wdummy);
51 
52  TGLVector3 pnt(x, y, 0.5*v->GetSelRec().GetMinZ());
53  v->CurrentCamera().WindowToViewport(pnt);
54  pnt = v->CurrentCamera().ViewportToWorld(pnt);
55 
56  switch (iEntryIndex)
57  {
58  case kAnnotate:
59  {
60  TGFrame* f = v->GetGLWidget();
61  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(), f->GetId(), iX, iY, x, y, wdummy);
62 
63  std::string name = id.item()->modelName(id.index());
64  if (id.item()->haveInterestingValue())
65  name += ", " + id.item()->modelInterestingValueAsString(id.index());
66 
67  TGLAnnotation *an = new TGLAnnotation(v, name.c_str(), x*1.f/f->GetWidth(), 1 - y*1.f/f->GetHeight(), pnt);
68  an->SetUseColorSet(true);
69  an->SetTextSize(0.03);
70  break;
71  }
72  case kCameraCenter:
73  {
75  {
76  FWModelId mId = *(m_view->context().selectionManager()->selected().begin());
77  const FWItemValueGetter& valueGetter = mId.item()->valueGetter();
78  TEveVector center;
79  center.fX = valueGetter.valueFor(mId.item()->modelData(mId.index()), 0);
80  center.fY = valueGetter.valueFor(mId.item()->modelData(mId.index()), 1);
81  center.fZ = valueGetter.valueFor(mId.item()->modelData(mId.index()), 2);
82 
83  FWRPZView* pv = static_cast<FWRPZView*>(m_view);
84  pv->shiftOrigin(center);
85  }
86  else
87  {
88  v->CurrentCamera().SetExternalCenter(true);
89  v->CurrentCamera().SetCenterVec(pnt.X(), pnt.Y(), pnt.Z());
90  v->SetDrawCameraCenter(true);
91  }
92  break;
93  }
94  case kResetCameraCenter:
95  {
97  {
98  FWRPZView* pv = static_cast<FWRPZView*>(m_view);
99  pv->resetOrigin();
100  }
101 
102  v->CurrentCamera().SetExternalCenter(false);
103  v->SetDrawCameraCenter(false);
104  break;
105  }
106  }
107 }
const std::set< FWModelId > & selected() const
const FWItemValueGetter & valueGetter() const
one value from the model which is normally used for the popup
Definition: FWEventItem.h:119
TGLViewer * viewerGL() const
Definition: FWEveView.cc:190
void resetOrigin()
Definition: FWRPZView.cc:261
static bool isProjected(int)
Definition: FWViewType.cc:128
int index() const
Definition: FWModelId.h:49
def pv(vc)
Definition: MetAnalyzer.py:6
double f[11][100]
FWSelectionManager * selectionManager() const
Definition: Context.h:57
void shiftOrigin(TEveVector &center)
Definition: FWRPZView.cc:243
const fireworks::Context & context()
Definition: FWEveView.h:67
double valueFor(const void *, int idx) const
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:569
const FWEventItem * item() const
Definition: FWModelId.h:44
FWViewType::EType typeId() const
Definition: FWViewBase.h:43

Member Data Documentation

FWEveView* FWViewContextMenuHandlerGL::m_view
private

Definition at line 24 of file FWViewContextMenuHandlerGL.h.

Referenced by init(), and select().