CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
16 FWGLEventHandler::FWGLEventHandler(TGWindow *w, TObject *obj, TEveCaloLego* l):
17  TEveLegoEventHandler(w, obj, l),
18  m_viewer(0)
19 {}
20 
21 void
22 FWGLEventHandler::PopupContextMenu(TGLPhysicalShape* pshp, Event_t *event, Int_t gx, Int_t gy)
23 {
24  // Popup context menu.
25 
26  if (event->fState & kKeyShiftMask && event->fState & kKeyControlMask)
27  {
28  TGLEventHandler::PopupContextMenu(pshp, event, gx, gy);
29  return;
30  }
31 
32  if (pshp)
33  {
34  SelectForClicked(event);
35 
36  if (pshp->GetLogical())
37  {
38  FWGeoTopNodeGLScene* js = dynamic_cast<FWGeoTopNodeGLScene*>(pshp->GetLogical()->GetScene());
39  if (js) {
40  js->GeoPopupMenu(gx, gy, m_viewer->viewerGL());
41  return;
42  }
43  }
44 
46  }
47 }
48 
50 {
51  Bool_t res = TEveLegoEventHandler::HandleButton(event);
52  if (m_viewer->requestGLHandlerPick() && event->fType == kButtonPress )
53  {
54  Int_t x, y;
55  Window_t childdum;
56  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(), fGLViewer->GetGLWidget()->GetId(),event->fX, event->fY, x, y, childdum); fGLViewer->RequestSelect(event->fX, event->fY);
57  if (fGLViewer->GetSelRec().GetN() > 0 )
58  {
59  TGLVector3 v(event->fX, event->fY, 0.5*fGLViewer->GetSelRec().GetMinZ());
60  fGLViewer->CurrentCamera().WindowToViewport(v);
61  v = fGLViewer->CurrentCamera().ViewportToWorld(v);
62  FW3DViewBase* v3d = dynamic_cast<FW3DViewBase*>(m_viewer);
63  v3d->setCurrentDMTVertex(v.X(), v.Y(), v.Z());
64  }
65  }
66 
67  return res;
68 }
69 
71 {
72  UInt_t keysym;
73  char tmp[2];
74  gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
75 
76  if (keysym == kKey_Enter || keysym == kKey_Return || keysym == kKey_Space)
77  {
78  if (event->fType == kGKeyPress)
79  {
80  Int_t x, y;
81  Window_t childdum;
82  gVirtualX->TranslateCoordinates(fGLViewer->GetGLWidget()->GetId(), gClient->GetDefaultRoot()->GetId(),
83  event->fX, event->fY, x, y, childdum);
84 
85  fGLViewer->RequestSelect(event->fX, event->fY);
86  PopupContextMenu(fGLViewer->GetSelRec().GetPhysShape(), event, x, y);
87  }
88  return kTRUE;
89  }
90  else {
91  return TEveLegoEventHandler::HandleKey(event);
92 
93  }
94 }
95 
97 {
98  // Handle generic Event_t type 'event' - provided to catch focus changes
99  // and terminate any interaction in viewer.
100 
101  if (m_viewer->viewer() && event->fType == kFocusOut)
102  TEveGedEditor::ElementChanged(m_viewer->viewer());
103 
104  return TGLEventHandler::HandleFocusChange(event);
105 }
106 
107 //______________________________________________________________________________
109 {
110  // Handle generic Event_t type 'event' - provided to catch focus changes
111  // and terminate any interaction in viewer.
112 
113  if (m_viewer->viewer() && event->fType == kLeaveNotify)
114  TEveGedEditor::ElementChanged(m_viewer->viewer());
115 
116  return TGLEventHandler::HandleCrossing(event);
117 }
void GeoPopupMenu(Int_t gx, Int_t gy, TGLViewer *)
virtual Bool_t HandleCrossing(Event_t *event)
virtual bool requestGLHandlerPick() const
Definition: FWEveView.h:88
virtual Bool_t HandleKey(Event_t *event)
FWEveView * m_viewer
void setCurrentDMTVertex(double x, double y, double z)
TGLViewer * viewerGL() const
Definition: FWEveView.cc:198
FWGLEventHandler(TGWindow *w, TObject *obj, TEveCaloLego *l=0)
virtual Bool_t HandleButton(Event_t *event)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
sigc::signal< void, Int_t, Int_t > openSelectedModelContextMenu_
TEveViewer * viewer()
Definition: FWEveView.h:75
unsigned int UInt_t
Definition: FUTypes.h:12
virtual void PopupContextMenu(TGLPhysicalShape *pshp, Event_t *event, Int_t gx, Int_t gy)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
virtual Bool_t HandleFocusChange(Event_t *event)
T w() const
Definition: DDAxes.h:10