3 #include "TGLIncludes.h" 6 #include "TGLSelectRecord.h" 7 #include "TGLViewerBase.h" 10 #include "TEveManager.h" 17 : TGLOverlayElement(TGLOverlayElement::
kUser),
27 fAllowDestroy(
false) {
31 parent->AddOverlayElement(
this);
38 fParent->RemoveOverlayElement(
this);
42 if (rnrCtx.GetCamera()->RefViewport().Width() == 0 || rnrCtx.GetCamera()->RefViewport().Height() == 0)
45 static UInt_t ttid_black = 0;
46 static UInt_t ttid_white = 0;
48 bool whiteBg = rnrCtx.ColorSet().Background().GetColorIndex() == kWhite;
49 UInt_t& ttid = whiteBg ? ttid_white : ttid_black;
51 if ((whiteBg ==
false && ttid == 0) || (whiteBg && ttid == 0)) {
53 TString
base = whiteBg ?
"White" :
"Black";
58 glGenTextures(1, &ttid);
59 glBindTexture(GL_TEXTURE_2D, ttid);
61 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
62 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
63 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
64 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
65 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
66 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
68 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
69 glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
71 for (
int i = 0;
i < 3;
i++)
72 glTexImage2D(GL_TEXTURE_2D,
80 imgs[
i]->GetArgbArray());
82 glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
84 for (
int i = 0;
i < 3;
i++)
88 glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_POLYGON_BIT);
89 TGLCapabilitySwitch lights_off(GL_LIGHTING, kFALSE);
92 glMatrixMode(GL_PROJECTION);
96 if (rnrCtx.Selection()) {
97 TGLRect rect(*rnrCtx.GetPickRectangle());
98 rnrCtx.GetCamera()->WindowToViewport(rect);
99 gluPickMatrix(rect.X(), rect.Y(), rect.Width(), rect.Height(), (Int_t*)rnrCtx.GetCamera()->RefViewport().CArr());
101 const TGLRect& vp = rnrCtx.RefCamera().RefViewport();
102 glOrtho(vp.X(), vp.Width(), vp.Y(), vp.Height(), 0, 1);
103 glMatrixMode(GL_MODELVIEW);
112 glDisable(GL_DEPTH_TEST);
114 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
116 glEnable(GL_TEXTURE_2D);
117 glBindTexture(GL_TEXTURE_2D, ttid);
119 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
123 TGLUtil::Color(rnrCtx.ColorSet().Background().GetColorIndex());
126 Float_t
a =
fSize * vp.Height();
128 glVertex3f(0, -
a,
z);
130 glVertex3f(
a, -
a,
z);
138 glDisable(GL_TEXTURE_2D);
144 Float_t
a =
fSize * vp.Height();
145 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 95);
147 glVertex3f(0, -
a,
z);
149 glVertex3f(
a, -
a,
z);
156 glTranslatef(
a, -
a, 0);
160 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 100);
164 glVertex3f(-
a,
a,
z);
165 glVertex3f(-
a, 0,
z);
168 glTranslatef(-
a / 3,
a / 3, 0);
170 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 40);
175 glVertex3f(-
s, 0,
z);
184 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 100);
185 glTranslatef(0, -
a, 0);
194 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 40);
197 glVertex3f(
a -
s,
a -
s,
z);
198 glVertex3f(
s,
a -
s,
z);
199 glVertex3f(
a -
s,
s,
z);
206 glEnable(GL_DEPTH_TEST);
207 glMatrixMode(GL_PROJECTION);
209 glMatrixMode(GL_MODELVIEW);
219 if (selRec.GetN() < 2)
221 int recID = selRec.GetItem(1);
223 switch (
event->fType) {
231 case kButtonRelease: {
234 fParent->RequestDraw(rnrCtx.ViewerLOD());
240 case kMotionNotify: {
241 const TGLRect& vp = rnrCtx.RefCamera().RefViewport();
242 if (vp.Width() == 0 || vp.Height() == 0)
252 Float_t
w =
fSize / vp.Aspect();
264 using namespace TMath;
265 Float_t oovpw = 1.0f / vp.Width(), oovph = 1.0f / vp.Height();
267 Float_t xw = oovpw *
Min(
Max(0,
event->fX), vp.Width());
268 Float_t yw = oovph *
Min(
Max(0, vp.Height() -
event->fY), vp.Height());
306 SetState(
x ? (TGLOverlayElement::kActive) : (TGLOverlayElement::kInvisible));
static const TString & coreIcondir()
virtual void addTo(FWConfiguration &) const
virtual void setFrom(const FWConfiguration &)
Bool_t MouseEnter(TGLOvlSelectRecord &selRec) override
void Render(TGLRnrCtx &rnrCtx) override
~CmsAnnotation() override
CmsAnnotation(TGLViewerBase *parent, Float_t posx, Float_t posy)
EDrag fDrag
last mouse position
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
Bool_t Handle(TGLRnrCtx &rnrCtx, TGLOvlSelectRecord &selRec, Event_t *event) override
void MouseLeave() override
const FWConfiguration * valueForKey(const std::string &iKey) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Float_t fSizeDrag
relative size to viewport width