112 const Int_t kMaxDiff = 5;
113 const Int_t kMinSize = 20;
115 static Int_t px1, px2, py1, py2, pxl, pyl, pxt, pyt, pxold, pyold;
116 static Int_t px1p, px2p, py1p, py2p;
117 static Int_t pTx,pTy,pLx,pLy,pRx,pRy,pBx,pBy;
119 static Bool_t pTop, pL, pR, pBot, pINSIDE;
126 if (!
gPad->IsEditable())
return;
172 pTx = pBx = (pxl+pxt)/2;
173 pLy = pRy = (pyl+pyt)/2;
179 pTop = pL = pR = pBot = pINSIDE =
kFALSE;
181 if ((
TMath::Abs(px-(pxl+pxt)/2) < kMaxDiff) &&
183 pxold = pxl; pyold = pyl; pTop =
kTRUE;
187 if ((
TMath::Abs(px-(pxl+pxt)/2) < kMaxDiff) &&
189 pxold = pxt; pyold = pyt; pBot =
kTRUE;
193 if ((
TMath::Abs(py-(pyl+pyt)/2) < kMaxDiff) &&
195 pxold = pxl; pyold = pyl; pL =
kTRUE;
199 if ((
TMath::Abs(py-(pyl+pyt)/2) < kMaxDiff) &&
201 pxold = pxt; pyold = pyt; pR =
kTRUE;
205 x1c = (py-pTy)*(pTx-pLx)/(pTy-pLy)+pTx;
206 x2c = (py-pTy)*(pRx-pTx)/(pRy-pTy)+pTx;
207 x3c = (py-pRy)*(pRx-pBx)/(pRy-pBy)+pRx;
208 x4c = (py-pBy)*(pBx-pLx)/(pBy-pLy)+pBx;
210 if (px > x1c+kMaxDiff && px < x2c-kMaxDiff &&
211 px > x4c+kMaxDiff && px < x3c-kMaxDiff) {
212 pxold = px; pyold = py; pINSIDE =
kTRUE;
220 if (pTop || pL || pR || pBot)
223 if (!pTop && !pL && !pR && !pBot && !pINSIDE)
232 x[0] =
x[2] =
x[4] = (px1+px2)/2;
237 y[1] =
y[3] = (py1+py2)/2;
239 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
241 if (py2 > py1-kMinSize) { py2 = py1-kMinSize; wy = py2; }
242 if (py2 < py2p) { py2 = py2p; wy = py2; }
244 y[1] =
y[3] = (py1+py2)/2;
245 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
248 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
250 if (py1 < py2+kMinSize) { py1 = py2+kMinSize; wy = py1; }
251 if (py1 > py1p) { py1 = py1p; wy = py1; }
253 y[1] =
y[3] = (py1+py2)/2;
254 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
257 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
259 if (px1 > px2-kMinSize) { px1 = px2-kMinSize; wx = px1; }
260 if (px1 < px1p) { px1 = px1p; wx = px1; }
262 x[0] =
x[2] =
x[4] = (px1+px2)/2;
263 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
266 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
268 if (px2 < px1+kMinSize) { px2 = px1+kMinSize; wx = px2; }
269 if (px2 > px2p) { px2 = px2p; wx = px2; }
271 x[0] =
x[2] =
x[4] = (px1+px2)/2;
272 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
275 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
276 Int_t dx = px - pxold;
277 Int_t dy = py - pyold;
283 x[0] =
x[2] =
x[4] = (px1+px2)/2;
288 y[1] =
y[3] = (py1+py2)/2;
289 for (i=0;i<4;i++)
gVirtualX->DrawLine(
x[i],
y[i],
x[i+1],
y[i+1]);
301 if ((pINSIDE && opaque) || (
fResizing && ropaque)) {
302 if (pTop || pBot || pL || pR) {
318 if (pINSIDE)
gPad->ShowGuidelines(
this, event,
'i',
true);
319 if (pTop)
gPad->ShowGuidelines(
this, event,
't',
true);
320 if (pBot)
gPad->ShowGuidelines(
this, event,
'b',
true);
321 if (pL)
gPad->ShowGuidelines(
this, event,
'l',
true);
322 if (pR)
gPad->ShowGuidelines(
this, event,
'r',
true);
324 if (pTop || pL || pR || pBot)
333 gPad->ShowGuidelines(
this, event);
335 if (pTop || pBot || pL || pR || pINSIDE) {
349 if (pTop || pL || pR || pBot)
gPad->Modified(
kTRUE);
364 event =
gVirtualX->RequestLocator(1, 1, px, py);
419 else if (y2-y1<x2-x1) {
427 x[0] =
x[2] = (x1+x2)/2+depx;
432 y[1] =
y[3] =(y1+y2)/2+depy;
433 x[4] =
x[0];
y[4] =
y[0];
437 gPad->PaintFillArea(4,
x,
y);
439 x[0] =
x[2] = (x1+x2)/2;
444 y[1] =
y[3] = (y1+y2)/2;
445 x[4] =
x[0];
y[4] =
y[0];
450 gPad->PaintFillArea(4,
x,
y);
451 gPad->PaintPolyLine(5,
x,
y);
462 SavePrimitiveConstructor(out,
Class(),
"diamond",
TString::Format(
"%g, %g, %g, %g",
fX1,
fY1,
fX2,
fY2));
void Streamer(TBuffer &) override
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Style_t GetFillStyle() const
Return the fill area style.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
virtual Color_t GetLineColor() const
Return the line color.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
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)
Double_t fX1
X of 1st point.
Double_t fY2
Y of 2nd point.
Double_t fX2
X of 2nd point.
Double_t fY1
Y of 1st point.
Bool_t fResizing
! True if box is being resized
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
void Draw(Option_t *option="") override
Draw this box with its current attributes.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void Paint(Option_t *option="") override
Paint this box with its current attributes.
void Streamer(TBuffer &) override
Stream an object of class TBox.
Int_t IsInside(Double_t x, Double_t y) const override
Function which returns 1 if point x,y lies inside the box, 0 otherwise.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a box.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point (px,py) to the object.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
virtual void SaveLines(std::ostream &out, const char *name, Bool_t)
virtual void PaintPrimitives(Int_t mode)
Int_t fBorderSize
window box bordersize in pixels
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual Int_t YtoAbsPixel(Double_t y) const =0
virtual Double_t GetX2() const =0
virtual Int_t XtoAbsPixel(Double_t x) const =0
virtual Double_t GetY1() const =0
virtual Double_t GetY2() const =0
virtual Short_t GetBorderSize() const =0
virtual Double_t GetX1() const =0
Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y)
Function which returns kTRUE if point xp,yp lies inside the polygon defined by the np points in array...
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.