Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLAnnotation.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz and Alja Tadel 20/02/2009
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGLAnnotation
13 #define ROOT_TGLAnnotation
14 
15 #include "TGLOverlay.h"
16 #include "TGLUtil.h"
17 #include "TGLFontManager.h"
18 
19 class TGLViewer;
20 class TGLViewerBase;
21 class TGLFont;
22 class TGTextEdit;
23 class TGMainFrame;
24 
25 class TGLAnnotation : public TGLOverlayElement
26 {
27 private:
28  TGLAnnotation(const TGLAnnotation&); // Not implemented
29  TGLAnnotation& operator=(const TGLAnnotation&); // Not implemented
30 
31 protected:
32  enum EDrag { kMove, kResize, kNone };
33  enum ENameStack { kMoveID, kEditID, kDeleteID, kResizeID };
34 
35  void MakeEditor();
36  Char_t GetLineTransparency() const;
37 
38  Float_t fPosX; // x position [0, 1]
39  Float_t fPosY; // y position [0, 1]
40  Float_t fWidth;
41  Float_t fHeight;
42 
43  Int_t fMouseX, fMouseY; //! last mouse position
44  EDrag fDrag; //!
45  Float_t fDrawW, fDrawH; //! width and height when drawing
46  Float_t fTextSizeDrag; //! text-size at start of drag
47 
48  TGLVector3 fPointer; // picked location in 3D space
49  Bool_t fActive; // active item identifier
50 
51  TGMainFrame *fMainFrame; // editors
52  TGTextEdit *fTextEdit; // editors
53 
54  static Color_t fgBackColor;
55  static Color_t fgTextColor;
56 
57  TGLViewer *fParent;
58 
59  TString fText; // annotation text
60  Float_t fTextSize; // relative font size
61  TGLFont fFont; // font used to render labels
62  TGLFont fMenuFont; // font used to render menu buttons
63  TGLFont::ETextAlignH_e fTextAlign;
64 
65  Color_t fBackColor; // background color
66  Color_t fTextColor; // text color
67  Char_t fTransparency; // transparency of background
68 
69  Bool_t fDrawRefLine; // draw 3D refrence line
70  Bool_t fUseColorSet; // use color set from rnrCtx
71  Bool_t fAllowClose; // allow closing via 'X' button
72 
73 public:
74  TGLAnnotation(TGLViewerBase *parent, const char *text, Float_t posx, Float_t posy);
75  TGLAnnotation(TGLViewerBase *parent, const char *text, Float_t posx, Float_t posy, TGLVector3 ref);
76  virtual ~TGLAnnotation();
77 
78  void SetText(const TString& x) { fText = x; }
79  const TString& GetText() const { return fText; }
80 
81  void SetTransparency(Char_t x) { fTransparency = x; }
82  Char_t GetTransparency() const { return fTransparency; }
83 
84  void SetUseColorSet(Bool_t x) { fUseColorSet = x; }
85  Bool_t GetUseColorSet() const { return fUseColorSet; }
86 
87  void SetBackColor(Color_t x) { fBackColor = x; }
88  Color_t GetBackColor() const { return fBackColor; }
89 
90  void SetTextColor(Color_t x) { fTextColor = x; }
91  Color_t GetTextColor() const { return fTextColor; }
92 
93  void SetTextSize(Float_t x) { fTextSize = x; }
94  Float_t GetTextSize() const { return fTextSize; }
95 
96  void SetAllowClose(Bool_t x) { fAllowClose = x; }
97  Bool_t GetAllowClose() const { return fAllowClose; }
98 
99  TGLFont::ETextAlignH_e GetTextAlign() const { return fTextAlign; }
100  void SetTextAlign(TGLFont::ETextAlignH_e a) { fTextAlign = a; }
101 
102  virtual Bool_t MouseEnter(TGLOvlSelectRecord& selRec);
103  virtual Bool_t Handle(TGLRnrCtx& rnrCtx, TGLOvlSelectRecord& selRec,
104  Event_t* event);
105  virtual void MouseLeave();
106 
107  void CloseEditor();
108 
109  void UpdateText();
110 
111  virtual void Render(TGLRnrCtx& rnrCtx);
112 
113  ClassDef(TGLAnnotation, 0); // GL-annotation.
114 };
115 
116 #endif