Go to the documentation of this file.00001 #include "Fireworks/Core/interface/FWGLEventHandler.h"
00002 #include "Fireworks/Core/interface/FWGUIManager.h"
00003
00004 #include "KeySymbols.h"
00005 #include "TGLViewer.h"
00006 #include "TGLWidget.h"
00007 #include "TGLPhysicalShape.h"
00008 #include "TGLLogicalShape.h"
00009 #include "TEveGedEditor.h"
00010 #include "TEveViewer.h"
00011 #include "FWGeoTopNodeScene.h"
00012
00013 FWGLEventHandler::FWGLEventHandler(TGWindow *w, TObject *obj, TEveCaloLego* l):
00014 TEveLegoEventHandler(w, obj, l),
00015 m_viewer(0)
00016 {}
00017
00018 void
00019 FWGLEventHandler::PopupContextMenu(TGLPhysicalShape* pshp, Event_t *event, Int_t gx, Int_t gy)
00020 {
00021
00022
00023 if (event->fState & kKeyShiftMask && event->fState & kKeyControlMask)
00024 {
00025 TGLEventHandler::PopupContextMenu(pshp, event, gx, gy);
00026 return;
00027 }
00028
00029 if (pshp)
00030 {
00031 SelectForClicked(event);
00032
00033 if (pshp->GetLogical())
00034 {
00035 FWGeoTopNodeGLScene* js = dynamic_cast<FWGeoTopNodeGLScene*>(pshp->GetLogical()->GetScene());
00036 if (js) {
00037 js->GeoPopupMenu(gx, gy, m_viewer->GetGLViewer());
00038 return;
00039 }
00040 }
00041
00042 openSelectedModelContextMenu_(gx,gy);
00043 }
00044 }
00045
00046 Bool_t FWGLEventHandler::HandleKey(Event_t *event)
00047 {
00048 UInt_t keysym;
00049 char tmp[2];
00050 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
00051
00052 if (keysym == kKey_Enter || keysym == kKey_Return || keysym == kKey_Space)
00053 {
00054 if (event->fType == kGKeyPress)
00055 {
00056 Int_t x, y;
00057 Window_t childdum;
00058 gVirtualX->TranslateCoordinates(fGLViewer->GetGLWidget()->GetId(), gClient->GetDefaultRoot()->GetId(),
00059 event->fX, event->fY, x, y, childdum);
00060
00061 fGLViewer->RequestSelect(event->fX, event->fY);
00062 PopupContextMenu(fGLViewer->GetSelRec().GetPhysShape(), event, x, y);
00063 }
00064 return kTRUE;
00065 }
00066 else
00067 {
00068 return TEveLegoEventHandler::HandleKey(event);
00069 }
00070 }
00071
00072 Bool_t FWGLEventHandler::HandleFocusChange(Event_t *event)
00073 {
00074
00075
00076
00077 if (m_viewer && event->fType == kFocusOut)
00078 TEveGedEditor::ElementChanged(m_viewer);
00079
00080 return TGLEventHandler::HandleFocusChange(event);
00081 }
00082
00083
00084 Bool_t FWGLEventHandler::HandleCrossing(Event_t *event)
00085 {
00086
00087
00088
00089 if (m_viewer && event->fType == kLeaveNotify)
00090 TEveGedEditor::ElementChanged(m_viewer);
00091
00092 return TGLEventHandler::HandleCrossing(event);
00093 }