CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Fireworks/Core/src/FWGLEventHandler.cc

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 "FWGeoTopNodeScene.h"
00010 
00011 FWGLEventHandler::FWGLEventHandler(TGWindow *w, TObject *obj, TEveCaloLego* l):
00012    TEveLegoEventHandler(w, obj, l)
00013 {
00014 }
00015 
00016 void
00017 FWGLEventHandler::PopupContextMenu(TGLPhysicalShape* pshp,  Event_t *event, Int_t gx, Int_t gy)
00018 {
00019    // Popup context menu.
00020   
00021    if (event->fState & kKeyShiftMask && event->fState & kKeyControlMask)
00022    {
00023       TGLEventHandler::PopupContextMenu(pshp, event, gx, gy);
00024       return;
00025    }
00026 
00027   
00028   if (pshp)
00029   {
00030     SelectForClicked(event);
00031     
00032     if (pshp->GetLogical()) 
00033     {
00034       FWGeoTopNodeGLScene* js = dynamic_cast<FWGeoTopNodeGLScene*>(pshp->GetLogical()->GetScene());
00035       if (js) {
00036         js->GeoPopupMenu(gx, gy);
00037         return;
00038       }
00039     }
00040     
00041     openSelectedModelContextMenu_(gx,gy);
00042   }
00043 }
00044 
00045 Bool_t FWGLEventHandler::HandleKey(Event_t *event)
00046 {
00047    UInt_t keysym;
00048    char tmp[2];
00049    gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
00050 
00051    if (keysym == kKey_Enter || keysym == kKey_Return || keysym == kKey_Space)
00052    {
00053       if (event->fType == kGKeyPress)
00054       {
00055          Int_t    x, y;
00056          Window_t childdum;
00057          gVirtualX->TranslateCoordinates(fGLViewer->GetGLWidget()->GetId(), gClient->GetDefaultRoot()->GetId(),
00058                                          event->fX, event->fY, x, y, childdum);
00059 
00060          fGLViewer->RequestSelect(event->fX, event->fY);
00061          PopupContextMenu(fGLViewer->GetSelRec().GetPhysShape(), event, x, y);
00062       }
00063       return kTRUE;
00064    }
00065    else
00066    {
00067       return TEveLegoEventHandler::HandleKey(event);
00068    }
00069 }