47 fPosX(posx), fPosY(posy),
48 fMouseX(0), fMouseY(0),
50 fDrawW(0), fDrawH(0), fTextSizeDrag(0),
52 fMainFrame(0), fTextEdit(0),
59 fBackColor(fgBackColor),
60 fTextColor(fgTextColor),
123 switch (event->
fType)
171 using namespace TMath;
218 glGetFloatv(GL_DEPTH_RANGE, old_depth_range);
219 glDepthRange(0, 0.001);
222 glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_POLYGON_BIT);
224 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
225 glDisable(GL_CULL_FACE);
227 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
254 glTranslatef(-1.0
f, -1.0
f, 0.0
f);
255 glScalef(2.0
f, 2.0
f, 1.0
f);
257 glEnable(GL_POLYGON_OFFSET_FILL);
258 glPolygonOffset(0.1
f, 1.0
f);
268 TIter line_iter(lines);
271 Float_t widthTxt, heightTxt, sx, sy, descent, line_height;
279 Float_t llx, lly, llz, urx, ury, urz;
280 widthTxt = heightTxt = 0;
281 while ((osl = (
TObjString*) line_iter()) != 0)
285 heightTxt += line_height;
287 widthTxt += 2.0f * descent;
288 heightTxt += 2.0f * descent;
291 sy =
fTextSize / (line_height + descent);
296 glScalef(sx, sy, 1.0
f);
314 glVertex3f(x1, y1, z3);
315 glVertex3f(x2, y1, z3);
316 glVertex3f(x2, y2, z3);
317 glVertex3f(x1, y2, z3);
321 glBegin(GL_LINE_LOOP);
322 glVertex3f(x1, y1, z2);
323 glVertex3f(x2, y1, z2);
324 glVertex3f(x2, y2, z2);
325 glVertex3f(x1, y2, z2);
334 while ((osl = (
TObjString*) line_iter()) != 0)
340 tx = 0.5f * widthTxt - descent ;
343 tx = widthTxt - 2.0f * descent;
345 glTranslatef(0.0
f, -line_height, 0.0
f);
358 fFont.
BBox(
"X", bbox[0], bbox[1], bbox[2], bbox[3], bbox[4], bbox[5]);
361 x2 = bbox[3] + 2.0f * descent;
371 y2 = line_height + descent;
378 glVertex3f(x1, y1, z3);
379 glVertex3f(x2, y1, z3);
380 glVertex3f(x2, y2, z3);
381 glVertex3f(x1, y2, z3);
385 glBegin(GL_LINE_LOOP);
386 glVertex3f(x1, y1, z0);
387 glVertex3f(x2, y1, z0);
388 glVertex3f(x2, y2, z0);
389 glVertex3f(x1, y2, z0);
401 glVertex3f(x1, y1, z3);
402 glVertex3f(x2, y1, z3);
403 glVertex3f(x2, y2, z3);
404 glVertex3f(x1, y2, z3);
408 glBegin(GL_LINE_LOOP);
409 glVertex3f(x1, y1, z0);
410 glVertex3f(x2, y1, z0);
411 glVertex3f(x2, y2, z0);
412 glVertex3f(x1, y2, z0);
419 x1 = widthTxt - line_height;
422 y2 = -heightTxt + line_height;
425 glVertex3f(x1, y1, z1);
426 glVertex3f(x2, y1, z1);
427 glVertex3f(x2, y2, z1);
428 glVertex3f(x1, y2, z1);
433 Float_t aOff = 0.25*line_height;
434 glVertex3f(x1+aOff, y1+aOff, z0);
435 glVertex3f(x2-aOff, y1+aOff, z0);
436 glVertex3f(x2-aOff, y1+aOff, z0);
437 glVertex3f(x2-aOff, y2-aOff, z0);
454 if (fx != 0.5
f || fy != 0.5
f)
460 glVertex3f(op[0], op[1], z3);
468 glDepthRange(old_depth_range[0], old_depth_range[1]);
507 btt1->
Connect(
"Clicked()",
"TGLAnnotation",
this,
"UpdateText()");
508 btt2->
Connect(
"Clicked()",
"TGLAnnotation",
this,
"CloseEditor()");
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const
Set-up GL state before FTFont rendering.
static void Color(const TGLColor &color)
Set color from TGLColor.
void Render(const char *txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const
static void ColorTransparency(Color_t color_index, Char_t transparency=0)
Set color from color_index and ROOT-style transparency (default 0).
void ProjectionMatrixPushIdentity()
Collectable string class.
Float_t fTextSizeDrag
width and height when drawing
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
void BBox(const char *txt, Float_t &llx, Float_t &lly, Float_t &llz, Float_t &urx, Float_t &ury, Float_t &urz) const
Get bounding box.
void CloseEditor()
Close the annotation editor.
virtual Long_t ReturnLongestLineWidth()
Return width of longest line in widget.
Short_t Min(Short_t a, Short_t b)
void RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont &out)
Get font in the GL rendering context.
virtual void MouseLeave()
Mouse has left overlay area.
virtual void Layout()
Layout the elements of the composite frame.
Bool_t LoadBuffer(const char *txtbuf)
Load a 0 terminated buffer. Lines will be split at ' '.
Base class for GL viewers.
static const double x2[5]
3 component (x/y/z) vertex class.
EDrag fDrag
last mouse position
static Int_t GetFontSize(Int_t ds)
Get availabe font size.
Viewport (pixel base) 2D rectangle class.
3 component (x/y/z) vector class.
void ProjectionMatrixPop()
virtual void RemoveOverlayElement(TGLOverlayElement *el)
Remove overlay element.
Float_t GetDescent() const
Get font's descent. The returned value is positive.
virtual Bool_t Handle(TGLRnrCtx &rnrCtx, TGLOvlSelectRecord &selRec, Event_t *event)
Handle overlay event.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
const TString & GetString() const
TGLAnnotation(const TGLAnnotation &)
void RequestDraw(Short_t LOD=TGLRnrCtx::kLODMed)
Post request for redraw of viewer at level of detail 'LOD' Request is directed via cross thread gVirt...
static Color_t fgTextColor
TGLVertex3 WorldToViewport(const TGLVertex3 &worldVertex, TGLMatrix *modviewMat=0) const
Convert a 3D world vertex to '3D' viewport (screen) one.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb"...
TGLVector3 fPointer
text-size at start of drag
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Float_t GetLineHeight() const
Get font's line-height.
Char_t GetLineTransparency() const
Returns transparency of annotation outline.
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
static const double x1[5]
TGLFont::ETextAlignH_e fTextAlign
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
UInt_t GetItem(Int_t i) const
Color_t GetColorIndex() const
Returns color-index representing the color.
The color creation and management class.
virtual void SetText(TGText *text)
Adopt a new text buffer. The text will be deleted by this object.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
TString AsString()
Returns content as ROOT string.
static Color_t fgBackColor
virtual void UnmapWindow()
virtual void PostRender() const
Reset GL state after FTFont rendering.
double f2(const double *x)
Short_t Max(Short_t a, Short_t b)
void UpdateText()
Modify the annotation text from the text-edit widget.
virtual void Render(TGLRnrCtx &rnrCtx)
Render the annotation.
void MakeEditor()
Show the annotation editor.
virtual Bool_t MouseEnter(TGLOvlSelectRecord &selRec)
Mouse has entered overlay area.
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
A wrapper class for FTFont.
Selection record for overlay objects.
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Short_t ViewerLOD() const
virtual ~TGLAnnotation()
Destructor.