3 #include "TGLIncludes.h"
6 #include "TGLSelectRecord.h"
7 #include "TGLViewerBase.h"
10 #include "TEveManager.h"
17 TGLOverlayElement(TGLOverlayElement::kUser),
18 fPosX(posx), fPosY(posy),
19 fMouseX(0), fMouseY(0),
30 parent->AddOverlayElement(
this);
39 fParent->RemoveOverlayElement(
this);
46 if (rnrCtx.GetCamera()->RefViewport().Width() == 0 ||
47 rnrCtx.GetCamera()->RefViewport().Height() == 0 )
return;
49 static UInt_t ttid_black = 0;
50 static UInt_t ttid_white = 0;
52 bool whiteBg = rnrCtx.ColorSet().Background().GetColorIndex() == kWhite;
53 UInt_t& ttid = whiteBg ? ttid_white : ttid_black;
55 if ( (whiteBg ==
false && ttid == 0) || (whiteBg && ttid == 0))
58 TString
base = whiteBg ?
"White" :
"Black";
63 glGenTextures(1, &ttid);
64 glBindTexture(GL_TEXTURE_2D, ttid);
66 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
67 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
68 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
69 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
70 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL,0);
71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
74 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
75 glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
77 for (
int i=0;
i < 3;
i++)
78 glTexImage2D(GL_TEXTURE_2D,
i, GL_RGBA, imgs[
i]->GetWidth(), imgs[
i]->GetHeight(), 0,
79 GL_BGRA, GL_UNSIGNED_BYTE, imgs[
i]->GetArgbArray());
81 glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
83 for (
int i=0;
i < 3;
i++)
87 glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_POLYGON_BIT );
88 TGLCapabilitySwitch lights_off(GL_LIGHTING, kFALSE);
92 glMatrixMode(GL_PROJECTION);
96 if (rnrCtx.Selection())
98 TGLRect rect(*rnrCtx.GetPickRectangle());
99 rnrCtx.GetCamera()->WindowToViewport(rect);
100 gluPickMatrix(rect.X(), rect.Y(), rect.Width(), rect.Height(),
101 (Int_t*) rnrCtx.GetCamera()->RefViewport().CArr());
103 const TGLRect& vp = rnrCtx.RefCamera().RefViewport();
104 glOrtho(vp.X(), vp.Width(), vp.Y(), vp.Height(), 0, 1);
105 glMatrixMode(GL_MODELVIEW);
110 Float_t posX = vp.Width() *
fPosX;
111 Float_t posY = vp.Height() *
fPosY;
112 glTranslatef(posX, posY, -0.99);
114 glDisable(GL_DEPTH_TEST);
116 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
118 glEnable(GL_TEXTURE_2D);
119 glBindTexture(GL_TEXTURE_2D, ttid);
121 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
125 TGLUtil::Color(rnrCtx.ColorSet().Background().GetColorIndex());
128 Float_t
a =
fSize * vp.Height();
129 glTexCoord2f(0, 1); glVertex3f( 0, -a, z);
130 glTexCoord2f(1, 1); glVertex3f( a, -a, z);
131 glTexCoord2f(1, 0); glVertex3f( a, 0, z);
132 glTexCoord2f(0, 0); glVertex3f( 0, 0, z);
137 glDisable(GL_TEXTURE_2D);
144 Float_t a =
fSize * vp.Height();
145 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 95);
146 glTexCoord2f(0, 1); glVertex3f( 0, -a, z);
147 glTexCoord2f(1, 1); glVertex3f( a, -a, z);
148 glTexCoord2f(1, 0); glVertex3f( a, 0, z);
149 glTexCoord2f(0, 0); glVertex3f( 0, 0, z);
152 glTranslatef(a, -a, 0);
156 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 100);
158 glVertex3f( 0, 0, z);
159 glVertex3f( 0, a, z);
160 glVertex3f(-a, a, z);
161 glVertex3f(-a, 0, z);
164 glTranslatef(-a/3, a/3, 0);
166 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 40);
168 glVertex3f( 0, 0, z); glVertex3f( 0, s, z);
169 glVertex3f( 0, 0, z); glVertex3f( -s, 0, z);
179 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 100);
180 glTranslatef(0, -a, 0);
182 glVertex3f( 0, 0, z);
183 glVertex3f( a, 0, z);
184 glVertex3f( a, a, z);
185 glVertex3f( 0, a, z);
189 TGLUtil::ColorTransparency(rnrCtx.ColorSet().Markup().GetColorIndex(), 40);
191 glVertex3f( s, s, z);
192 glVertex3f( a-s, a-s, z);
193 glVertex3f( s, a-s, z);
194 glVertex3f( a-s, s, z);
201 glEnable(GL_DEPTH_TEST);
202 glMatrixMode(GL_PROJECTION);
204 glMatrixMode(GL_MODELVIEW);
212 TGLOvlSelectRecord& selRec,
218 if (selRec.GetN() < 2)
return kFALSE;
219 int recID = selRec.GetItem(1);
221 switch (event->fType)
236 fParent->RequestDraw(rnrCtx.ViewerLOD());
244 const TGLRect& vp = rnrCtx.RefCamera().RefViewport();
245 if (vp.Width() == 0 || vp.Height() == 0)
return false;
256 Float_t
w =
fSize/vp.Aspect();
270 using namespace TMath;
271 Float_t oovpw = 1.0f / vp.Width(), oovph = 1.0f / vp.Height();
273 Float_t xw = oovpw *
Min(
Max(0, event->fX), vp.Width());
274 Float_t yw = oovph *
Min(
Max(0, vp.Height() -
event->fY), vp.Height());
314 return GetState() == TGLOverlayElement::kActive;
320 SetState(x ? (TGLOverlayElement::kActive) : (TGLOverlayElement::kInvisible));
348 if (value)
fSize = atof(value->
value().c_str());
351 if (value)
fPosX = atof(value->value().c_str());
354 if (value)
fPosY = atof(value->value().c_str());
static const TString & coreIcondir()
virtual void MouseLeave()
virtual void setFrom(const FWConfiguration &)
virtual void Render(TGLRnrCtx &rnrCtx)
virtual void addTo(FWConfiguration &) const
CmsAnnotation(TGLViewerBase *parent, Float_t posx, Float_t posy)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
EDrag fDrag
last mouse position
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
const std::string & value(unsigned int iIndex=0) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
virtual Bool_t Handle(TGLRnrCtx &rnrCtx, TGLOvlSelectRecord &selRec, Event_t *event)
virtual Bool_t MouseEnter(TGLOvlSelectRecord &selRec)
const FWConfiguration * valueForKey(const std::string &iKey) const
Float_t fSizeDrag
relative size to viewport width