58 if (x2 >= x1) {
fX1 =x1;
fX2 = x2;}
60 if (y2 >= y1) {
fY1 =y1;
fY2 = y2;}
97 TAttLine::operator=(
b);
98 TAttFill::operator=(
b);
137 if (!
gPad)
return 9999;
138 Int_t pxl, pyl, pxt, pyt;
147 if (
gPad->GetLogx()) {
151 if (
gPad->GetLogy()) {
157 if (px1 < px2) {pxl = px1; pxt = px2;}
158 else {pxl = px2; pxt = px1;}
159 if (py1 < py2) {pyl = py1; pyt = py2;}
160 else {pyl = py2; pyt = py1;}
164 if ( (px >= pxl && px <= pxt) && (py >= pyl && py <= pyt) )
return 0;
170 if (py < pyl) dxl += pyl - py;
171 if (py > pyt) dxl += py - pyt;
173 if (py < pyl) dxt += pyl - py;
174 if (py > pyt) dxt += py - pyt;
176 if (px < pxl) dyl += pxl - px;
177 if (px > pxt) dyl += px - pxt;
179 if (px < pxl) dyt += pxl - px;
180 if (px > pxt) dyt += px - pxt;
182 Int_t distance = dxl;
183 if (dxt < distance) distance = dxt;
184 if (dyl < distance) distance = dyl;
185 if (dyt < distance) distance = dyt;
207 TBox *newbox =
new TBox(x1,y1,x2,y2);
238 auto &parent = *
gPad;
240 if (!parent.IsEditable() && event !=
kMouseEnter)
return;
244 constexpr Int_t kMaxDiff = 7;
245 constexpr Int_t kMinSize = 20;
247 static Int_t px1, px2, py1, py2, dpx1, dpy2;
248 static Int_t px1p, px2p, py1p, py2p;
249 static Double_t oldX1, oldY1, oldX2, oldY2;
251 static enum { pNone, pA, pB, pC, pD, pTop, pL, pR, pBot, pINSIDE } mode = pNone;
252 static bool firstPaint =
kFALSE;
253 Bool_t opaque = parent.OpaqueMoving();
254 Bool_t ropaque = parent.OpaqueResizing();
257 auto paint_or_set = [&parent,isBox,
this](
Bool_t paint)
259 auto x1 = parent.AbsPixeltoX(px1);
260 auto y1 = parent.AbsPixeltoY(py1);
261 auto x2 = parent.AbsPixeltoX(px2);
262 auto y2 = parent.AbsPixeltoY(py2);
265 x1 = parent.PadtoX(x1);
266 x2 = parent.PadtoX(x2);
267 y1 = parent.PadtoY(y1);
268 y2 = parent.PadtoY(y2);
274 }
else if (firstPaint) {
277 auto pp = parent.GetPainter();
288 if (
fTip) parent.ResetToolTip(
fTip);
304 px1 = parent.XtoAbsPixel(isBox ? parent.XtoPad(
GetX1()) :
GetX1());
305 py1 = parent.YtoAbsPixel(isBox ? parent.YtoPad(
GetY1()) :
GetY1());
306 px2 = parent.XtoAbsPixel(isBox ? parent.XtoPad(
GetX2()) :
GetX2());
307 py2 = parent.YtoAbsPixel(isBox ? parent.YtoPad(
GetY2()) :
GetY2());
313 px1p = parent.XtoAbsPixel(parent.GetX1()) + parent.GetBorderSize();
314 py1p = parent.YtoAbsPixel(parent.GetY1()) - parent.GetBorderSize();
315 px2p = parent.XtoAbsPixel(parent.GetX2()) - parent.GetBorderSize();
316 py2p = parent.YtoAbsPixel(parent.GetY2()) + parent.GetBorderSize();
318 std::swap(px1p, px2p);
320 std::swap(py1p, py2p);
336 }
else if ((px > px1 + kMaxDiff && px < px2 - kMaxDiff) &&
TMath::Abs(py - py2) < kMaxDiff) {
339 }
else if ((px > px1 + kMaxDiff && px < px2 - kMaxDiff) &&
TMath::Abs(py - py1) < kMaxDiff) {
342 }
else if ((py > py2 + kMaxDiff && py < py1 - kMaxDiff) &&
TMath::Abs(px - px1) < kMaxDiff) {
345 }
else if ((py > py2 + kMaxDiff && py < py1 - kMaxDiff) &&
TMath::Abs(px - px2) < kMaxDiff) {
348 }
else if ((px > px1+kMaxDiff && px < px2-kMaxDiff) && (py > py2+kMaxDiff && py < py1-kMaxDiff)) {
353 parent.SetCursor(
kMove);
358 fResizing = (mode != pNone) && (mode != pINSIDE);
372 if (!ropaque) paint_or_set(
kTRUE);
375 paint_or_set(!ropaque);
378 if (!ropaque) paint_or_set(
kTRUE);
381 paint_or_set(!ropaque);
384 if (!ropaque) paint_or_set(
kTRUE);
387 paint_or_set(!ropaque);
390 if (!ropaque) paint_or_set(
kTRUE);
393 paint_or_set(!ropaque);
396 if (!ropaque) paint_or_set(
kTRUE);
398 paint_or_set(!ropaque);
401 if (!ropaque) paint_or_set(
kTRUE);
403 paint_or_set(!ropaque);
406 if (!ropaque) paint_or_set(
kTRUE);
408 paint_or_set(!ropaque);
411 if (!ropaque) paint_or_set(
kTRUE);
413 paint_or_set(!ropaque);
416 if (!opaque) paint_or_set(
kTRUE);
417 px2 += px - dpx1 - px1;
419 py1 += py - dpy2 - py2;
421 if (px1 < px1p) { px2 += px1p - px1; px1 = px1p; }
422 if (px2 > px2p) { px1 -= px2 - px2p; px2 = px2p; }
423 if (py1 > py1p) { py2 -= py1 - py1p; py1 = py1p; }
424 if (py2 < py2p) { py1 += py2p - py2; py2 = py2p; }
425 paint_or_set(!opaque);
429 if ((mode == pINSIDE && opaque) || (
fResizing && ropaque)) {
431 case pINSIDE: parent.ShowGuidelines(
this, event,
'i',
true);
break;
432 case pTop: parent.ShowGuidelines(
this, event,
't',
true);
break;
433 case pBot: parent.ShowGuidelines(
this, event,
'b',
true);
break;
434 case pL: parent.ShowGuidelines(
this, event,
'l',
true);
break;
435 case pR: parent.ShowGuidelines(
this, event,
'r',
true);
break;
436 case pA: parent.ShowGuidelines(
this, event,
'1',
true);
break;
437 case pB: parent.ShowGuidelines(
this, event,
'2',
true);
break;
438 case pC: parent.ShowGuidelines(
this, event,
'3',
true);
break;
439 case pD: parent.ShowGuidelines(
this, event,
'4',
true);
break;
442 parent.Modified(
kTRUE);
448 if (opaque || ropaque)
449 parent.ShowGuidelines(
this, event);
451 if (
gROOT->IsEscaped()) {
453 if (opaque && (mode != pNone)) {
463 parent.ModifiedUpdate();
468 if ((!opaque && mode == pINSIDE) || (!ropaque &&
fResizing))
472 parent.Modified(
kTRUE);
487 event = parent.GetCanvasImp()->RequestLocator(px, py);
551 else gPad->PaintBox(x1,y1,x2,y2);
553 gPad->PaintBox(x1,y1,x2,y2);
576 SavePrimitiveConstructor(out,
Class(),
"box",
TString::Format(
"%g, %g, %g, %g",
fX1,
fY1,
fX2,
fY2));
592 Warning(
"SetToolTipText",
"a canvas must exist before setting the tool tip text");
622 R__b >> x1;
fX1 = x1;
623 R__b >> y1;
fY1 = y1;
624 R__b >> x2;
fX2 = x2;
625 R__b >> y2;
fY2 = y2;
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
short Color_t
Color number (short).
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
Abstract base class for elements drawn in the editor.
Double_t GetYCoord(const Int_t y, Bool_t is_ndc=kFALSE)
Double_t GetXCoord(const Int_t x, Bool_t is_ndc=kFALSE)
virtual void Streamer(TBuffer &)
virtual Color_t GetFillColor() const
Return the fill area color.
void Copy(TAttFill &attfill) const
virtual Style_t GetFillStyle() const
Return the fill area style.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
virtual void Streamer(TBuffer &)
virtual Color_t GetLineColor() const
Return the line color.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Width_t fLineWidth
Line width.
virtual Style_t GetLineStyle() const
Return the line style.
void Copy(TAttLine &attline) const
void Draw(Option_t *option="") override
Draw this box with its current attributes.
virtual void SetToolTipText(const char *text, Long_t delayms=1000)
Set tool tip text associated with this box.
virtual void SetY2(Double_t y2)
virtual void PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option="")
Draw this box with new coordinates.
void Streamer(TBuffer &) override
Stream an object of class TBox.
void SetBBoxX1(const Int_t x) override
Set left hand side of BoundingBox to a value (resize in x direction on left).
~TBox() override
Box destructor.
TBox & operator=(const TBox &)
Assignment operator.
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom).
void SetBBoxY1(const Int_t y) override
Set top of BoundingBox to a value (resize in y direction on top).
Double_t fX1
X of 1st point.
TClass * IsA() const override
virtual void HideToolTip(Int_t event)
Hide tool tip depending on the event type.
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the Box.
void ls(Option_t *option="") const override
List this box with its attributes.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
virtual void SetX1(Double_t x1)
void Paint(Option_t *option="") override
Paint this box with its current attributes.
virtual Int_t IsInside(Double_t x, Double_t y) const
Function which returns 1 if point x,y lies inside the box, 0 otherwise.
virtual void SetX2(Double_t x2)
TBox()
Box default constructor.
virtual TBox * DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this box with new coordinates.
Rectangle_t GetBBox() override
Return the "bounding Box" of the Box.
void Print(Option_t *option="") const override
Dump this box with its attributes.
TObject * fTip
! tool tip associated with box
Double_t fY2
Y of 2nd point.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Double_t fX2
X of 2nd point.
Double_t fY1
Y of 1st point.
void Copy(TObject &box) const override
Copy a Box.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a box.
Bool_t fResizing
! True if box is being resized
void SetBBoxX2(const Int_t x) override
Set right hand side of BoundingBox to a value (resize in x direction on right).
virtual void SetY1(Double_t y1)
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the Box.
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
TObject & operator=(const TObject &rhs) noexcept
TObject assignment operator.
Bool_t TestBit(UInt_t f) const
virtual const char * GetName() const
Returns name of object.
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Copy(TObject &object) const
Copy this to obj.
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.
TObject()
TObject constructor.
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".
@ kCanDelete
if object in a list can be deleted
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
void ToLower()
Change string to lower-case.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
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.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Rectangle structure (maps to the X11 XRectangle structure).