CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWViewContextMenuHandlerGL.cc
Go to the documentation of this file.
2 
3 #include "TEveViewer.h"
4 #include "TGLViewer.h"
5 #include "TGLAnnotation.h"
6 #include "TGLWidget.h"
7 
10 
12 m_viewer(v),
13 m_pickCameraCenter(false)
14 {
15 }
16 
17 void
19 {
20  adder.addEntry("Add Annotation");
22  {
23  adder.addEntry("Set Camera Center");
24  adder.addEntry("Reset Camera Center");
25  }
26 }
27 
28 void
29 FWViewContextMenuHandlerGL::select(int iEntryIndex, const FWModelId &id, int iX, int iY)
30 {
31  TGLViewer* v = m_viewer->GetGLViewer();
32 
33  Window_t wdummy;
34  Int_t x,y;
35  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(), v->GetGLWidget()->GetId(), iX, iY, x, y, wdummy);
36  TGLVector3 pnt(x, y, 0.5*v->GetSelRec().GetMinZ());
37  v->CurrentCamera().WindowToViewport(pnt);
38  pnt = v->CurrentCamera().ViewportToWorld(pnt);
39 
40  switch (iEntryIndex)
41  {
42  case kAnnotate:
43  {
44  TGFrame* f = v->GetGLWidget();
45  gVirtualX->TranslateCoordinates(gClient->GetDefaultRoot()->GetId(), f->GetId(), iX, iY, x, y, wdummy);
46 
47  std::string name = id.item()->modelName(id.index());
48  if (id.item()->haveInterestingValue())
49  name += ", " + id.item()->modelInterestingValueAsString(id.index());
50 
51  TGLAnnotation* an = new TGLAnnotation(v, name.c_str(), x*1.f/f->GetWidth(), 1 - y*1.f/f->GetHeight(), pnt);
52  an->SetUseColorSet(true);
53  an->SetTextSize(0.03);
54  break;
55  }
56  case kCameraCenter:
57  {
58  v->CurrentCamera().SetExternalCenter(true);
59  v->SetDrawCameraCenter(true);
60  v->CurrentCamera().SetCenterVec(pnt.X(), pnt.Y(), pnt.Z());
61  break;
62  }
63  case kResetCameraCenter:
64  {
65  v->CurrentCamera().SetExternalCenter(false);
66  v->SetDrawCameraCenter(false);
67  break;
68  }
69  }
70 }
virtual void select(int iEntryIndex, const FWModelId &id, int iX, int iY)
virtual void init(FWViewContextMenuHandlerBase::MenuEntryAdder &)
double f[11][100]
mathSSE::Vec4< T > v