113 const Int_t kMaxDiff = 5;
114 const Int_t kMinSize = 20;
116 static Int_t px1, px2, py1, py2, pxl, pyl, pxt, pyt, pxold, pyold;
117 static Int_t px1p, px2p, py1p, py2p;
118 static Int_t pTx,pTy,pLx,pLy,pRx,pRy,pBx,pBy;
120 static Bool_t pTop, pL, pR, pBot, pINSIDE;
127 if (!
gPad->IsEditable())
return;
173 pTx = pBx = (pxl+pxt)/2;
174 pLy = pRy = (pyl+pyt)/2;
180 pTop = pL = pR = pBot = pINSIDE =
kFALSE;
182 if ((
TMath::Abs(px-(pxl+pxt)/2) < kMaxDiff) &&
184 pxold = pxl; pyold = pyl; pTop =
kTRUE;
188 if ((
TMath::Abs(px-(pxl+pxt)/2) < kMaxDiff) &&
190 pxold = pxt; pyold = pyt; pBot =
kTRUE;
194 if ((
TMath::Abs(py-(pyl+pyt)/2) < kMaxDiff) &&
196 pxold = pxl; pyold = pyl; pL =
kTRUE;
200 if ((
TMath::Abs(py-(pyl+pyt)/2) < kMaxDiff) &&
202 pxold = pxt; pyold = pyt; pR =
kTRUE;
206 x1c = (py-pTy)*(pTx-pLx)/(pTy-pLy)+pTx;
207 x2c = (py-pTy)*(pRx-pTx)/(pRy-pTy)+pTx;
208 x3c = (py-pRy)*(pRx-pBx)/(pRy-pBy)+pRx;
209 x4c = (py-pBy)*(pBx-pLx)/(pBy-pLy)+pBx;
211 if (px > x1c+kMaxDiff && px < x2c-kMaxDiff &&
212 px > x4c+kMaxDiff && px < x3c-kMaxDiff) {
213 pxold = px; pyold = py; pINSIDE =
kTRUE;
221 if (pTop || pL || pR || pBot)
224 if (!pTop && !pL && !pR && !pBot && !pINSIDE)
233 x[0] = x[2] = x[4] = (px1+px2)/2;
238 y[1] = y[3] = (py1+py2)/2;
240 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
242 if (py2 > py1-kMinSize) { py2 = py1-kMinSize; wy = py2; }
243 if (py2 < py2p) { py2 = py2p; wy = py2; }
245 y[1] = y[3] = (py1+py2)/2;
246 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
249 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
251 if (py1 < py2+kMinSize) { py1 = py2+kMinSize; wy = py1; }
252 if (py1 > py1p) { py1 = py1p; wy = py1; }
254 y[1] = y[3] = (py1+py2)/2;
255 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
258 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
260 if (px1 > px2-kMinSize) { px1 = px2-kMinSize; wx = px1; }
261 if (px1 < px1p) { px1 = px1p; wx = px1; }
263 x[0] = x[2] = x[4] = (px1+px2)/2;
264 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
267 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
269 if (px2 < px1+kMinSize) { px2 = px1+kMinSize; wx = px2; }
270 if (px2 > px2p) { px2 = px2p; wx = px2; }
272 x[0] = x[2] = x[4] = (px1+px2)/2;
273 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
276 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
277 Int_t dx = px - pxold;
278 Int_t dy = py - pyold;
279 px1 += dx; py1 += dy; px2 += dx; py2 += dy;
280 if (px1 < px1p) { dx = px1p - px1; px1 += dx; px2 += dx; wx = px+dx; }
281 if (px2 > px2p) { dx = px2 - px2p; px1 -= dx; px2 -= dx; wx = px-dx; }
282 if (py1 > py1p) { dy = py1 - py1p; py1 -= dy; py2 -= dy; wy = py-dy; }
283 if (py2 < py2p) { dy = py2p - py2; py1 += dy; py2 += dy; wy = py+dy; }
284 x[0] = x[2] = x[4] = (px1+px2)/2;
289 y[1] = y[3] = (py1+py2)/2;
290 for (i=0;i<4;i++)
gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
302 if ((pINSIDE && opaque) || (
fResizing && ropaque)) {
303 if (pTop || pBot || pL || pR) {
319 if (pINSIDE)
gPad->ShowGuidelines(
this, event,
'i',
true);
320 if (pTop)
gPad->ShowGuidelines(
this, event,
't',
true);
321 if (pBot)
gPad->ShowGuidelines(
this, event,
'b',
true);
322 if (pL)
gPad->ShowGuidelines(
this, event,
'l',
true);
323 if (pR)
gPad->ShowGuidelines(
this, event,
'r',
true);
325 if (pTop || pL || pR || pBot)
334 gPad->ShowGuidelines(
this, event);
336 if (pTop || pBot || pL || pR || pINSIDE) {
350 if (pTop || pL || pR || pBot)
gPad->Modified(
kTRUE);
365 event =
gVirtualX->RequestLocator(1, 1, px, py);
398 else if (y2-y1<x2-x1) {
406 x[0] = x[2] = (x1+
x2)/2+depx;
411 y[1] = y[3] =(y1+y2)/2+depy;
412 x[4] = x[0]; y[4] = y[0];
416 gPad->PaintFillArea(4,x,y);
418 x[0] = x[2] = (x1+
x2)/2;
423 y[1] = y[3] = (y1+y2)/2;
424 x[4] = x[0]; y[4] =y[0];
429 gPad->PaintFillArea(4,x,y);
430 gPad->PaintPolyLine(5,x,y);
446 out<<
"diamond = new TDiamond("<<
fX1<<
","<<
fY1<<
","<<
fX2<<
","<<
fY2<<
");"<<std::endl;
453 out<<
" diamond->Draw();"<<std::endl;
virtual void Draw(Option_t *option="")
Draw this diamond with its current attributes.
void SetBufferOffset(Int_t offset=0)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Double_t fY2
Y of 2nd point.
virtual ~TDiamond()
Diamond destructor.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void Modify()
Change current line attributes if necessary.
virtual Double_t GetX1() const =0
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Double_t fY1
Y of 1st point.
static const double x2[5]
Bool_t fResizing
! True if box is being resized
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual void Modify()
Change current fill area attributes if necessary.
virtual void Paint(Option_t *option="")
Paint this diamond with its current attributes.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual Short_t GetBorderSize() const =0
TDiamond()
Diamond default constructor.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual Double_t GetY2() const =0
virtual void SaveTextAttributes(std::ostream &out, const char *name, Int_t alidef=12, Float_t angdef=0, Int_t coldef=1, Int_t fondef=61, Float_t sizdef=1)
Save text attributes as C++ statement(s) on output stream out.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual Int_t XtoAbsPixel(Double_t x) const =0
Double_t fX2
X of 2nd point.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Double_t fX1
X of 1st point.
void SetReadMode()
Set buffer in read mode.
Int_t fBorderSize
window box bordersize in pixels
virtual Double_t GetY1() const =0
virtual Color_t GetLineColor() const
Return the line color.
virtual Int_t YtoAbsPixel(Double_t y) const =0
static const double x1[5]
A Pave (see TPave) with text, lines or/and boxes inside.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a pave.
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a diamond.
virtual Double_t GetX2() const =0
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual void PaintPrimitives(Int_t mode)
Paint list of primitives in this pavetext.
virtual Style_t GetFillStyle() const
Return the fill area style.
TPaveText()
pavetext default constructor.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
virtual void SaveLines(std::ostream &out, const char *name)
Save lines of this pavetext as C++ statements on output stream out.