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

◆ GLViewerAction

Enumerator
kAnnotate 
kCameraCenter 
kResetCameraCenter 
kOrigin 
kNone 

Definition at line 11 of file FWViewContextMenuHandlerGL.h.

Constructor & Destructor Documentation

◆ FWViewContextMenuHandlerGL() [1/2]

FWViewContextMenuHandlerGL::FWViewContextMenuHandlerGL ( FWEveView v)

Definition at line 21 of file FWViewContextMenuHandlerGL.cc.

21 : m_view(v) {}

◆ ~FWViewContextMenuHandlerGL()

FWViewContextMenuHandlerGL::~FWViewContextMenuHandlerGL ( )
inlineoverride

Definition at line 14 of file FWViewContextMenuHandlerGL.h.

14 {}

◆ FWViewContextMenuHandlerGL() [2/2]

FWViewContextMenuHandlerGL::FWViewContextMenuHandlerGL ( const FWViewContextMenuHandlerGL )
privatedelete

Member Function Documentation

◆ init()

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

Called when have to add entries to the context menu.

Implements FWViewContextMenuHandlerBase.

Definition at line 23 of file FWViewContextMenuHandlerGL.cc.

23  {
24  adder.addEntry("Add Annotation", kAnnotate);
26  const char* p = id.item()->purpose().c_str();
27  bool enabled = (strstr(p, "Beam Spot") || strstr(p, "Vertices"));
28  adder.addEntry("Use As Projection Origin", kCameraCenter, enabled);
29  adder.addEntry("Reset Projection Origin", kResetCameraCenter, enabled);
30  } else {
31  adder.addEntry("Set Camera Center", kCameraCenter);
32  adder.addEntry("Reset Camera Center", kResetCameraCenter);
33  }
34 }

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

◆ operator=()

const FWViewContextMenuHandlerGL& FWViewContextMenuHandlerGL::operator= ( const FWViewContextMenuHandlerGL )
privatedelete

◆ select()

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

36  {
37  TGLViewer* v = m_view->viewerGL();
38 
39  Window_t wdummy;
40  Int_t x, y;
41  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(), v->GetGLWidget()->GetId(), iX, iY, x, y, wdummy);
42 
43  TGLVector3 pnt(x, y, 0.5 * v->GetSelRec().GetMinZ());
44  v->CurrentCamera().WindowToViewport(pnt);
45  pnt = v->CurrentCamera().ViewportToWorld(pnt);
46 
47  switch (iEntryIndex) {
48  case kAnnotate: {
49  TGFrame* f = v->GetGLWidget();
50  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(), f->GetId(), iX, iY, x, y, wdummy);
51 
52  std::string name = id.item()->modelName(id.index());
53  if (id.item()->haveInterestingValue())
54  name += ", " + id.item()->modelInterestingValueAsString(id.index());
55 
56  TGLAnnotation* an =
57  new TGLAnnotation(v, name.c_str(), x * 1.f / f->GetWidth(), 1 - y * 1.f / f->GetHeight(), pnt);
58  an->SetUseColorSet(true);
59  an->SetTextSize(0.03);
60  break;
61  }
62  case kCameraCenter: {
64  FWModelId mId = *(m_view->context().selectionManager()->selected().begin());
65  const FWItemValueGetter& valueGetter = mId.item()->valueGetter();
66  TEveVector center;
67  center.fX = valueGetter.valueFor(mId.item()->modelData(mId.index()), 0);
68  center.fY = valueGetter.valueFor(mId.item()->modelData(mId.index()), 1);
69  center.fZ = valueGetter.valueFor(mId.item()->modelData(mId.index()), 2);
70 
71  FWRPZView* pv = static_cast<FWRPZView*>(m_view);
72  pv->shiftOrigin(center);
73  } else {
74  v->CurrentCamera().SetExternalCenter(true);
75  v->CurrentCamera().SetCenterVec(pnt.X(), pnt.Y(), pnt.Z());
76  v->SetDrawCameraCenter(true);
77  }
78  break;
79  }
80  case kResetCameraCenter: {
82  FWRPZView* pv = static_cast<FWRPZView*>(m_view);
83  pv->resetOrigin();
84  }
85 
86  v->CurrentCamera().SetExternalCenter(false);
87  v->SetDrawCameraCenter(false);
88  break;
89  }
90  }
91 }

References FWEveView::context(), f, FWModelId::index(), FWViewType::isProjected(), FWModelId::item(), B2GTnPMonitor_cfi::item, kAnnotate, kCameraCenter, kResetCameraCenter, m_view, FWEventItem::modelData(), Skims_PA_cff::name, MetAnalyzer::pv(), FWSelectionManager::selected(), fireworks::Context::selectionManager(), AlCaHLTBitMon_QueryRunRegistry::string, FWViewBase::typeId(), findQualityFiles::v, FWItemValueGetter::valueFor(), FWEventItem::valueGetter(), FWEveView::viewerGL(), x, and y.

Member Data Documentation

◆ m_view

FWEveView* FWViewContextMenuHandlerGL::m_view
private

Definition at line 23 of file FWViewContextMenuHandlerGL.h.

Referenced by init(), and select().

FWRPZView
Definition: FWRPZView.h:40
DDAxes::y
FWViewContextMenuHandlerGL::kResetCameraCenter
Definition: FWViewContextMenuHandlerGL.h:11
FWEventItem::valueGetter
const FWItemValueGetter & valueGetter() const
one value from the model which is normally used for the popup
Definition: FWEventItem.h:112
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
FWModelId
Definition: FWModelId.h:28
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FWEventItem::modelData
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
FWViewContextMenuHandlerGL::m_view
FWEveView * m_view
Definition: FWViewContextMenuHandlerGL.h:23
FWViewContextMenuHandlerGL::kNone
Definition: FWViewContextMenuHandlerGL.h:11
DDAxes::x
FWModelId::item
const FWEventItem * item() const
Definition: FWModelId.h:39
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FWViewType::isProjected
static bool isProjected(int)
Definition: FWViewType.cc:100
FWViewBase::typeId
FWViewType::EType typeId() const
Definition: FWViewBase.h:42
FWEveView::context
const fireworks::Context & context()
Definition: FWEveView.h:64
FWSelectionManager::selected
const std::set< FWModelId > & selected() const
Definition: FWSelectionManager.cc:168
FWItemValueGetter
Definition: FWItemValueGetter.h:32
FWModelId::index
int index() const
Definition: FWModelId.h:41
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWViewContextMenuHandlerGL::kCameraCenter
Definition: FWViewContextMenuHandlerGL.h:11
FWViewContextMenuHandlerGL::kOrigin
Definition: FWViewContextMenuHandlerGL.h:11
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
FWItemValueGetter::valueFor
double valueFor(const void *, int idx) const
Definition: FWItemValueGetter.cc:122
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
FWEveView::viewerGL
TGLViewer * viewerGL() const
Definition: FWEveView.cc:177
FWViewContextMenuHandlerGL::kAnnotate
Definition: FWViewContextMenuHandlerGL.h:11
fireworks::Context::selectionManager
FWSelectionManager * selectionManager() const
Definition: Context.h:54
pixel_dqm_sourceclient-live_cfg.enabled
enabled
Definition: pixel_dqm_sourceclient-live_cfg.py:136