14#include "TGLIncludes.h"
46 fPosX(posx), fPosY(posy),
47 fMouseX(0), fMouseY(0),
49 fDrawW(0), fDrawH(0), fTextSizeDrag(0),
51 fMainFrame(0), fTextEdit(0),
58 fBackColor(fgBackColor),
59 fTextColor(fgTextColor),
76 fPosX(posx), fPosY(posy),
77 fMouseX(0), fMouseY(0),
79 fDrawW(0), fDrawH(0), fTextSizeDrag(0),
81 fMainFrame(0), fTextEdit(0),
88 fBackColor(fgBackColor),
89 fTextColor(fgTextColor),
122 switch (
event->fType)
165 else if (
fPosY > 1.0f)
170 using namespace TMath;
217 glGetFloatv(GL_DEPTH_RANGE, old_depth_range);
218 glDepthRange(0, 0.001);
221 glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_POLYGON_BIT);
223 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
224 glDisable(GL_CULL_FACE);
226 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
242 c1->GetGreen()*
f1 +
c2->GetGreen()*f2,
243 c1->GetBlue() *
f1 +
c2->GetBlue() *f2);
253 glTranslatef(-1.0f, -1.0f, 0.0f);
254 glScalef(2.0f, 2.0f, 1.0f);
256 glEnable(GL_POLYGON_OFFSET_FILL);
257 glPolygonOffset(0.1f, 1.0f);
267 TIter line_iter(lines);
270 Float_t widthTxt, heightTxt, sx, sy, descent, line_height;
278 Float_t llx, lly, llz, urx, ury, urz;
279 widthTxt = heightTxt = 0;
280 while ((osl = (
TObjString*) line_iter()) != 0)
284 heightTxt += line_height;
286 widthTxt += 2.0f * descent;
287 heightTxt += 2.0f * descent;
290 sy =
fTextSize / (line_height + descent);
295 glScalef(sx, sy, 1.0f);
313 glVertex3f(
x1,
y1, z3);
314 glVertex3f(
x2,
y1, z3);
315 glVertex3f(
x2,
y2, z3);
316 glVertex3f(
x1,
y2, z3);
321 glVertex3f(
x1,
y1, z2);
322 glVertex3f(
x2,
y1, z2);
323 glVertex3f(
x2,
y2, z2);
324 glVertex3f(
x1,
y2, z2);
333 while ((osl = (
TObjString*) line_iter()) != 0)
339 tx = 0.5f * widthTxt - descent ;
342 tx = widthTxt - 2.0f * descent;
344 glTranslatef(0.0f, -line_height, 0.0f);
357 fFont.
BBox(
"X", bbox[0], bbox[1], bbox[2], bbox[3], bbox[4], bbox[5]);
360 x2 = bbox[3] + 2.0f * descent;
370 y2 = line_height + descent;
377 glVertex3f(
x1,
y1, z3);
378 glVertex3f(
x2,
y1, z3);
379 glVertex3f(
x2,
y2, z3);
380 glVertex3f(
x1,
y2, z3);
385 glVertex3f(
x1,
y1, z0);
386 glVertex3f(
x2,
y1, z0);
387 glVertex3f(
x2,
y2, z0);
388 glVertex3f(
x1,
y2, z0);
400 glVertex3f(
x1,
y1, z3);
401 glVertex3f(
x2,
y1, z3);
402 glVertex3f(
x2,
y2, z3);
403 glVertex3f(
x1,
y2, z3);
408 glVertex3f(
x1,
y1, z0);
409 glVertex3f(
x2,
y1, z0);
410 glVertex3f(
x2,
y2, z0);
411 glVertex3f(
x1,
y2, z0);
418 x1 = widthTxt - line_height;
421 y2 = -heightTxt + line_height;
424 glVertex3f(
x1,
y1, z1);
425 glVertex3f(
x2,
y1, z1);
426 glVertex3f(
x2,
y2, z1);
427 glVertex3f(
x1,
y2, z1);
432 Float_t aOff = 0.25*line_height;
433 glVertex3f(
x1+aOff,
y1+aOff, z0);
434 glVertex3f(
x2-aOff,
y1+aOff, z0);
435 glVertex3f(
x2-aOff,
y1+aOff, z0);
436 glVertex3f(
x2-aOff,
y2-aOff, z0);
453 if (fx != 0.5f || fy != 0.5f)
459 glVertex3f(op[0], op[1], z3);
467 glDepthRange(old_depth_range[0], old_depth_range[1]);
506 btt1->
Connect(
"Clicked()",
"TGLAnnotation",
this,
"UpdateText()");
507 btt2->
Connect(
"Clicked()",
"TGLAnnotation",
this,
"CloseEditor()");
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
The color creation and management class.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
void Layout() override
Layout the elements of the composite frame.
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
void MapWindow() override
map window
void UnmapWindow() override
unmap window
A composite frame that layout their children in horizontal way.
static Color_t fgBackColor
Bool_t MouseEnter(TGLOvlSelectRecord &selRec) override
Mouse has entered overlay area.
Bool_t Handle(TGLRnrCtx &rnrCtx, TGLOvlSelectRecord &selRec, Event_t *event) override
Handle overlay event.
static Color_t fgTextColor
void MakeEditor()
Show the annotation editor.
void UpdateText()
Modify the annotation text from the text-edit widget.
void CloseEditor()
Close the annotation editor.
TGLFont::ETextAlignH_e fTextAlign
Char_t GetLineTransparency() const
Returns transparency of annotation outline.
TGLAnnotation(const TGLAnnotation &)
~TGLAnnotation() override
Destructor.
void MouseLeave() override
Mouse has left overlay area.
EDrag fDrag
last mouse position
void Render(TGLRnrCtx &rnrCtx) override
Render the annotation.
Float_t fTextSizeDrag
width and height when drawing
TGLVector3 fPointer
text-size at start of drag
TGLVertex3 WorldToViewport(const TGLVertex3 &worldVertex, TGLMatrix *modviewMat=nullptr) const
Convert a 3D world vertex to '3D' viewport (screen) one.
Color_t GetColorIndex() const
Returns color-index representing the color.
static Int_t GetFontSize(Int_t ds)
Get availabe font size.
A wrapper class for FTFont.
Float_t GetDescent() const
Get font's descent. The returned value is positive.
Float_t GetLineHeight() const
Get font's line-height.
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 Render(const char *txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const
virtual void PostRender() const
Reset GL state after FTFont rendering.
virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const
Set-up GL state before FTFont rendering.
Selection record for overlay objects.
Viewport (pixel base) 2D rectangle class.
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
void RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont &out)
Get font in the GL rendering context.
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Short_t ViewerLOD() const
void ProjectionMatrixPushIdentity()
void ProjectionMatrixPop()
UInt_t GetItem(Int_t i) const
static void ColorTransparency(Color_t color_index, Char_t transparency=0)
Set color from color_index and ROOT-style transparency (default 0).
static void Color(const TGLColor &color)
Set color from TGLColor.
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
3 component (x/y/z) vector class.
3 component (x/y/z) vertex class.
Base class for GL viewers.
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
Base GL viewer object - used by both standalone and embedded (in pad) GL.
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...
void RemoveOverlayElement(TGLOverlayElement *el) override
Remove overlay element.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Yield an action as soon as it is clicked.
A TGTextEdit is a specialization of TGTextView.
Long_t ReturnLongestLineWidth() override
Return width of longest line in widget.
virtual void SetText(TGText *text)
Adopt a new text buffer. The text will be deleted by this object.
A TGText is a multi line text buffer.
Bool_t LoadBuffer(const char *txtbuf)
Load a 0 terminated buffer. Lines will be split at ' '.
TString AsString()
Returns content as ROOT string.
A composite frame that layout their children in vertical way.
Collectable string class.
const TString & GetString() const
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 char * Data() const
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.