CMS 3D CMS Logo

FWGLEventHandler.cc
Go to the documentation of this file.
6 
7 #include "KeySymbols.h"
8 #include "TGLViewer.h"
9 #include "TGLWidget.h"
10 #include "TGLPhysicalShape.h"
11 #include "TGLLogicalShape.h"
12 #include "TEveGedEditor.h"
13 #include "TEveViewer.h"
14 #include "FWGeoTopNodeScene.h"
15 #include "TVirtualX.h"
16 
17 FWGLEventHandler::FWGLEventHandler(TGWindow *w, TObject *obj, TEveCaloLego *l)
18  : TEveLegoEventHandler(w, obj, l), m_viewer(nullptr) {}
19 
20 //______________________________________________________________________________
21 void FWGLEventHandler::PopupContextMenu(TGLPhysicalShape *pshp, Event_t *event, Int_t gx, Int_t gy) {
22  // Popup context menu.
23 
24  if (event->fState & kKeyShiftMask && event->fState & kKeyControlMask) {
25  TGLEventHandler::PopupContextMenu(pshp, event, gx, gy);
26  return;
27  }
28 
29  if (m_viewer && pshp) {
30  SelectForClicked(event);
31 
32  if (pshp->GetLogical()) {
33  FWGeoTopNodeGLScene *js = dynamic_cast<FWGeoTopNodeGLScene *>(pshp->GetLogical()->GetScene());
34  if (js) {
35  js->GeoPopupMenu(gx, gy, fGLViewer);
36  return;
37  }
38  }
39 
41  }
42 }
43 
44 //______________________________________________________________________________
45 
47  Bool_t res = TEveLegoEventHandler::HandleButton(event);
48  if (m_viewer && m_viewer->requestGLHandlerPick() && event->fType == kButtonPress) {
49  Int_t x, y;
50  Window_t childdum;
51  gVirtualX->TranslateCoordinates(
52  gClient->GetDefaultRoot()->GetId(), fGLViewer->GetGLWidget()->GetId(), event->fX, event->fY, x, y, childdum);
53  fGLViewer->RequestSelect(event->fX, event->fY);
54  if (fGLViewer->GetSelRec().GetN() > 0) {
55  TGLVector3 v(event->fX, event->fY, 0.5 * fGLViewer->GetSelRec().GetMinZ());
56  fGLViewer->CurrentCamera().WindowToViewport(v);
57  v = fGLViewer->CurrentCamera().ViewportToWorld(v);
58  FW3DViewBase *v3d = dynamic_cast<FW3DViewBase *>(m_viewer);
59  v3d->setCurrentDMTVertex(v.X(), v.Y(), v.Z());
60  }
61  }
62 
63  return res;
64 }
65 
67  UInt_t keysym;
68  char tmp[2];
69  gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
70 
71  if (m_viewer && (keysym == kKey_Enter || keysym == kKey_Return || keysym == kKey_Space)) {
72  if (event->fType == kGKeyPress) {
73  Int_t x, y;
74  Window_t childdum;
75  gVirtualX->TranslateCoordinates(
76  fGLViewer->GetGLWidget()->GetId(), gClient->GetDefaultRoot()->GetId(), event->fX, event->fY, x, y, childdum);
77 
78  fGLViewer->RequestSelect(event->fX, event->fY);
79  PopupContextMenu(fGLViewer->GetSelRec().GetPhysShape(), event, x, y);
80  }
81  return kTRUE;
82  } else {
83  return TEveLegoEventHandler::HandleKey(event);
84  }
85 }
86 
88  // Handle generic Event_t type 'event' - provided to catch focus changes
89  // and terminate any interaction in viewer.
90 
91  if (m_viewer && m_viewer->viewer() && event->fType == kFocusOut)
92  TEveGedEditor::ElementChanged(m_viewer->viewer());
93 
94  return TGLEventHandler::HandleFocusChange(event);
95 }
96 
97 //______________________________________________________________________________
99  // Handle generic Event_t type 'event' - provided to catch focus changes
100  // and terminate any interaction in viewer.
101 
102  if (m_viewer && m_viewer->viewer() && event->fType == kLeaveNotify)
103  TEveGedEditor::ElementChanged(m_viewer->viewer());
104 
105  return TGLEventHandler::HandleCrossing(event);
106 }
Bool_t HandleKey(Event_t *event) override
void GeoPopupMenu(Int_t gx, Int_t gy, TGLViewer *)
void PopupContextMenu(TGLPhysicalShape *pshp, Event_t *event, Int_t gx, Int_t gy) override
FWEveView * m_viewer
T w() const
virtual bool requestGLHandlerPick() const
Definition: FWEveView.h:92
Bool_t HandleCrossing(Event_t *event) override
void setCurrentDMTVertex(double x, double y, double z)
FWGLEventHandler(TGWindow *w, TObject *obj, TEveCaloLego *l=nullptr)
Definition: Electron.h:6
TEveViewer * viewer()
Definition: FWEveView.cc:179
Bool_t HandleFocusChange(Event_t *event) override
Bool_t HandleButton(Event_t *event) override
sigc::signal< void(Int_t, Int_t)> openSelectedModelContextMenu_
tmp
align.sh
Definition: createJobs.py:716
Definition: event.py:1