TBox.cxx

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TBox.cxx 36489 2010-11-03 08:33:25Z brun $
00002 // Author: Rene Brun   12/12/94
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include <stdlib.h>
00013 
00014 #include "Riostream.h"
00015 #include "TROOT.h"
00016 #include "TBox.h"
00017 #include "TVirtualPad.h"
00018 #include "TVirtualX.h"
00019 #include "TClass.h"
00020 #include "TMath.h"
00021 
00022 
00023 ClassImp(TBox)
00024 
00025 
00026 //______________________________________________________________________________
00027 /* Begin_Html
00028 <center><h2>Box class</h2></center>
00029 A box is defined by :
00030 <ul>
00031 <li> Its bottom left coordinates x1,y1
00032 <li> Its top right coordinates x2,y2
00033 </ul>
00034 A box has line attributes (see TAttLine) and fill area attributes
00035 (see TAttFill).
00036 End_Html */
00037 
00038 
00039 //______________________________________________________________________________
00040 TBox::TBox(): TObject(), TAttLine(), TAttFill()
00041 {
00042    // Box default constructor.
00043 
00044    fTip = 0;
00045    fX1       = 0.;
00046    fY1       = 0.;
00047    fX2       = 0.;
00048    fY2       = 0.;
00049    fResizing = kTRUE;
00050 }
00051 
00052 
00053 //______________________________________________________________________________
00054 TBox::TBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
00055      : TObject(), TAttLine(), TAttFill()
00056 {
00057    // Box standard constructor.
00058 
00059    if (x2 >= x1) {fX1  =x1; fX2 = x2;}
00060    else          {fX1 = x2; fX2 = x1;}
00061    if (y2 >= y1) {fY1  =y1; fY2 = y2;}
00062    else          {fY1 = y2; fY2 = y1;}
00063    fResizing = kFALSE;
00064    fTip = 0;
00065 }
00066 
00067 
00068 //______________________________________________________________________________
00069 TBox::~TBox()
00070 {
00071    // Box destructor.
00072 
00073    if (fTip && gPad) {
00074       gPad->CloseToolTip(fTip);
00075       gPad->DeleteToolTip(fTip);
00076    }
00077 }
00078 
00079 
00080 //______________________________________________________________________________
00081 TBox::TBox(const TBox &box) : TObject(box), TAttLine(box), TAttFill(box)
00082 {
00083    // Box copy constructor.
00084 
00085    fX1       = 0.;
00086    fY1       = 0.;
00087    fX2       = 0.;
00088    fY2       = 0.;
00089    fResizing = kTRUE;
00090    ((TBox&)box).TBox::Copy(*this);
00091 }
00092 
00093 
00094 //______________________________________________________________________________
00095 TBox& TBox::operator=(const TBox& b) 
00096 {
00097    // Assignment operator.
00098 
00099    if(this!=&b) {
00100       TObject::operator=(b);
00101       TAttLine::operator=(b);
00102       TAttFill::operator=(b);
00103       fTip=b.fTip;
00104       fX1=b.fX1;
00105       fY1=b.fY1;
00106       fX2=b.fX2;
00107       fY2=b.fY2;
00108       fResizing=b.fResizing;
00109    } 
00110    return *this;
00111 }
00112 
00113 
00114 //______________________________________________________________________________
00115 void TBox::Copy(TObject &obj) const
00116 {
00117    // Copy a Box.
00118 
00119    TObject::Copy(obj);
00120    TAttLine::Copy(((TBox&)obj));
00121    TAttFill::Copy(((TBox&)obj));
00122    ((TBox&)obj).fX1 = fX1;
00123    ((TBox&)obj).fY1 = fY1;
00124    ((TBox&)obj).fX2 = fX2;
00125    ((TBox&)obj).fY2 = fY2;
00126    ((TBox&)obj).fResizing = fResizing;
00127    ((TBox&)obj).fTip = 0;   //FIXME
00128 }
00129 
00130 
00131 //______________________________________________________________________________
00132 Int_t TBox::DistancetoPrimitive(Int_t px, Int_t py)
00133 {
00134    // Compute distance from point px,py to a box.
00135    //
00136    // Compute the closest distance of approach from point px,py to the
00137    // edges of this box.
00138    // The distance is computed in pixels units.
00139    //
00140    // In case of a filled box the distance returned is 0 if the point
00141    // (px,py) is inside the box, and is huge if the point is outside.
00142 
00143    Int_t pxl, pyl, pxt, pyt;
00144    Int_t px1 = gPad->XtoAbsPixel(fX1);
00145    Int_t py1 = gPad->YtoAbsPixel(fY1);
00146    Int_t px2 = gPad->XtoAbsPixel(fX2);
00147    Int_t py2 = gPad->YtoAbsPixel(fY2);
00148    if (px1 < px2) {pxl = px1; pxt = px2;}
00149    else           {pxl = px2; pxt = px1;}
00150    if (py1 < py2) {pyl = py1; pyt = py2;}
00151    else           {pyl = py2; pyt = py1;}
00152 
00153    // Are we inside the box?
00154    if (GetFillStyle()) {
00155       if ( (px >= pxl && px <= pxt) && (py >= pyl && py <= pyt) ) return 0;
00156       else return 9999;
00157    }
00158 
00159    // Are we on the edges?
00160    Int_t dxl = TMath::Abs(px - pxl);
00161    if (py < pyl) dxl += pyl - py; if (py > pyt) dxl += py - pyt;
00162    Int_t dxt = TMath::Abs(px - pxt);
00163    if (py < pyl) dxt += pyl - py; if (py > pyt) dxt += py - pyt;
00164    Int_t dyl = TMath::Abs(py - pyl);
00165    if (px < pxl) dyl += pxl - px; if (px > pxt) dyl += px - pxt;
00166    Int_t dyt = TMath::Abs(py - pyt);
00167    if (px < pxl) dyt += pxl - px; if (px > pxt) dyt += px - pxt;
00168 
00169    Int_t distance = dxl;
00170    if (dxt < distance) distance = dxt;
00171    if (dyl < distance) distance = dyl;
00172    if (dyt < distance) distance = dyt;
00173 
00174    return distance - Int_t(0.5*fLineWidth);
00175 }
00176 
00177 
00178 //______________________________________________________________________________
00179 void TBox::Draw(Option_t *option)
00180 {
00181    // Draw this box with its current attributes.
00182    // if the box has no fill style (ie fill style=0), the box contour is drawn
00183    // if the box has a fill style, the box contour is not drawn by default.
00184    // to force the contour to be drawn, specify option "l"
00185 
00186    AppendPad(option);
00187 
00188 }
00189 
00190 
00191 //______________________________________________________________________________
00192 TBox *TBox::DrawBox(Double_t x1, Double_t y1,Double_t x2, Double_t  y2)
00193 {
00194    // Draw this box with new coordinates.
00195 
00196    TBox *newbox = new TBox(x1,y1,x2,y2);
00197    TAttLine::Copy(*newbox);
00198    TAttFill::Copy(*newbox);
00199    newbox->SetBit(kCanDelete);
00200    newbox->AppendPad();
00201    return newbox;
00202 }
00203 
00204 
00205 //______________________________________________________________________________
00206 void TBox::ExecuteEvent(Int_t event, Int_t px, Int_t py)
00207 {
00208    // Execute action corresponding to one event.
00209    //
00210    //  This member function is called when a BOX/WBOX/PAD object is clicked.
00211    //
00212    //  If the mouse is clicked in one of the 4 corners of the box (pA,pB,pC,pD)
00213    //  the box is resized with the rubber rectangle.
00214    //
00215    //  If the mouse is clicked inside the box, the box is moved.
00216    //
00217    //  If the mouse is clicked on the 4 edges (pL,pR,pTop,pBot), the box is 
00218    //  rescaled parallel to this edge (same as Motif window manager).
00219    //
00220    //    pA                 pTop                       pB
00221    //     +--------------------------------------------+
00222    //     |                                            |
00223    //     |                                            |
00224    //     |                                            |
00225    //   pL|                  pINSIDE                   |pR
00226    //     |                                            |
00227    //     |                                            |
00228    //     |                                            |
00229    //     |                                            |
00230    //     +--------------------------------------------+
00231    //    pD                 pBot                      pC
00232    //
00233    //  Note that this function is duplicated on purpose by TPad::ExecuteEvent.
00234    //  If somebody modifies this function, may be similar changes should also
00235    //  be applied to TPad::ExecuteEvent.
00236 
00237    if (!gPad) return;
00238    if (!gPad->IsEditable() && event != kMouseEnter) return;
00239 
00240    if (TestBit(kCannotMove)) return;
00241    
00242    const Int_t kMaxDiff = 5;
00243    const Int_t kMinSize = 20;
00244 
00245    static Int_t px1, px2, py1, py2, pxl, pyl, pxt, pyt, pxold, pyold;
00246    static Int_t px1p, px2p, py1p, py2p, pxlp, pylp, pxtp, pytp;
00247    static Bool_t pA, pB, pC, pD, pTop, pL, pR, pBot, pINSIDE;
00248    Int_t  wx, wy;
00249    TVirtualPad  *parent = gPad;
00250    Bool_t doing_again = kFALSE;
00251    Bool_t opaque  = gPad->OpaqueMoving();
00252    Bool_t ropaque = gPad->OpaqueResizing();
00253 
00254    HideToolTip(event);
00255 
00256 again:
00257 
00258    switch (event) {
00259 
00260    case kMouseEnter:
00261       if (fTip) gPad->ResetToolTip(fTip);
00262       break;
00263 
00264    case kButton1Double:
00265       px1 = -1; //used by kButton1Up
00266       break;
00267 
00268    case kButton1Down:
00269 
00270       gVirtualX->SetLineColor(-1);
00271       TAttLine::Modify();  //Change line attributes only if necessary
00272       if (GetFillColor())
00273          gVirtualX->SetLineColor(GetFillColor());
00274       else
00275          gVirtualX->SetLineColor(1);
00276       gVirtualX->SetLineWidth(2);
00277 
00278       // No break !!!
00279 
00280    case kMouseMotion:
00281 
00282       px1 = gPad->XtoAbsPixel(GetX1());
00283       py1 = gPad->YtoAbsPixel(GetY1());
00284       px2 = gPad->XtoAbsPixel(GetX2());
00285       py2 = gPad->YtoAbsPixel(GetY2());
00286 
00287       if (px1 < px2) {
00288          pxl = px1;
00289          pxt = px2;
00290       } else {
00291          pxl = px2;
00292          pxt = px1;
00293       }
00294       if (py1 < py2) {
00295          pyl = py1;
00296          pyt = py2;
00297       } else {
00298          pyl = py2;
00299          pyt = py1;
00300       }
00301 
00302       px1p = parent->XtoAbsPixel(parent->GetX1()) + parent->GetBorderSize();
00303       py1p = parent->YtoAbsPixel(parent->GetY1()) - parent->GetBorderSize();
00304       px2p = parent->XtoAbsPixel(parent->GetX2()) - parent->GetBorderSize();
00305       py2p = parent->YtoAbsPixel(parent->GetY2()) + parent->GetBorderSize();
00306 
00307       if (px1p < px2p) {
00308          pxlp = px1p;
00309          pxtp = px2p;
00310       } else {
00311          pxlp = px2p;
00312          pxtp = px1p;
00313       }
00314       if (py1p < py2p) {
00315          pylp = py1p;
00316          pytp = py2p;
00317       } else {
00318          pylp = py2p;
00319          pytp = py1p;
00320       }
00321 
00322       pA = pB = pC = pD = pTop = pL = pR = pBot = pINSIDE = kFALSE;
00323 
00324                                                          // case pA
00325       if (TMath::Abs(px - pxl) <= kMaxDiff && TMath::Abs(py - pyl) <= kMaxDiff) {
00326          pxold = pxl; pyold = pyl; pA = kTRUE;
00327          gPad->SetCursor(kTopLeft);
00328       }
00329                                                          // case pB
00330       if (TMath::Abs(px - pxt) <= kMaxDiff && TMath::Abs(py - pyl) <= kMaxDiff) {
00331          pxold = pxt; pyold = pyl; pB = kTRUE;
00332          gPad->SetCursor(kTopRight);
00333       }
00334                                                          // case pC
00335       if (TMath::Abs(px - pxt) <= kMaxDiff && TMath::Abs(py - pyt) <= kMaxDiff) {
00336          pxold = pxt; pyold = pyt; pC = kTRUE;
00337          gPad->SetCursor(kBottomRight);
00338       }
00339                                                          // case pD
00340       if (TMath::Abs(px - pxl) <= kMaxDiff && TMath::Abs(py - pyt) <= kMaxDiff) {
00341          pxold = pxl; pyold = pyt; pD = kTRUE;
00342          gPad->SetCursor(kBottomLeft);
00343       }
00344 
00345       if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff) &&
00346           TMath::Abs(py - pyl) < kMaxDiff) {             // top edge
00347          pxold = pxl; pyold = pyl; pTop = kTRUE;
00348          gPad->SetCursor(kTopSide);
00349       }
00350 
00351       if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff) &&
00352           TMath::Abs(py - pyt) < kMaxDiff) {             // bottom edge
00353          pxold = pxt; pyold = pyt; pBot = kTRUE;
00354          gPad->SetCursor(kBottomSide);
00355       }
00356 
00357       if ((py > pyl+kMaxDiff && py < pyt-kMaxDiff) &&
00358           TMath::Abs(px - pxl) < kMaxDiff) {             // left edge
00359          pxold = pxl; pyold = pyl; pL = kTRUE;
00360          gPad->SetCursor(kLeftSide);
00361       }
00362 
00363       if ((py > pyl+kMaxDiff && py < pyt-kMaxDiff) &&
00364           TMath::Abs(px - pxt) < kMaxDiff) {             // right edge
00365          pxold = pxt; pyold = pyt; pR = kTRUE;
00366          gPad->SetCursor(kRightSide);
00367       }
00368 
00369       if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff) &&
00370           (py > pyl+kMaxDiff && py < pyt-kMaxDiff)) {    // inside box
00371          pxold = px; pyold = py; pINSIDE = kTRUE;
00372          if (event == kButton1Down)
00373             gPad->SetCursor(kMove);
00374          else
00375             gPad->SetCursor(kCross);
00376       }
00377 
00378       fResizing = kFALSE;
00379       if (pA || pB || pC || pD || pTop || pL || pR || pBot)
00380          fResizing = kTRUE;
00381 
00382       if (!pA && !pB && !pC && !pD && !pTop && !pL && !pR && !pBot && !pINSIDE)
00383          gPad->SetCursor(kCross);
00384 
00385       break;
00386 
00387    case kButton1Motion:
00388 
00389       wx = wy = 0;
00390 
00391       if (pA) {
00392          if (!ropaque) gVirtualX->DrawBox(pxold, pyt, pxt, pyold, TVirtualX::kHollow);  // draw the old box
00393          if (px > pxt-kMinSize) { px = pxt-kMinSize; wx = px; }
00394          if (py > pyt-kMinSize) { py = pyt-kMinSize; wy = py; }
00395          if (px < pxlp) { px = pxlp; wx = px; }
00396          if (py < pylp) { py = pylp; wy = py; }
00397          if (!ropaque) gVirtualX->DrawBox(px   , pyt, pxt, py,    TVirtualX::kHollow);  // draw the new box
00398       }
00399       if (pB) {
00400          if (!ropaque) gVirtualX->DrawBox(pxl  , pyt, pxold, pyold, TVirtualX::kHollow);
00401          if (px < pxl+kMinSize) { px = pxl+kMinSize; wx = px; }
00402          if (py > pyt-kMinSize) { py = pyt-kMinSize; wy = py; }
00403          if (px > pxtp) { px = pxtp; wx = px; }
00404          if (py < pylp) { py = pylp; wy = py; }
00405          if (!ropaque) gVirtualX->DrawBox(pxl  , pyt, px ,  py,    TVirtualX::kHollow);
00406       }
00407       if (pC) {
00408          if (!ropaque) gVirtualX->DrawBox(pxl  , pyl, pxold, pyold, TVirtualX::kHollow);
00409          if (px < pxl+kMinSize) { px = pxl+kMinSize; wx = px; }
00410          if (py < pyl+kMinSize) { py = pyl+kMinSize; wy = py; }
00411          if (px > pxtp) { px = pxtp; wx = px; }
00412          if (py > pytp) { py = pytp; wy = py; }
00413          if (!ropaque) gVirtualX->DrawBox(pxl  , pyl, px ,   py,    TVirtualX::kHollow);
00414       }
00415       if (pD) {
00416          if (!ropaque) gVirtualX->DrawBox(pxold, pyold, pxt, pyl, TVirtualX::kHollow);
00417          if (px > pxt-kMinSize) { px = pxt-kMinSize; wx = px; }
00418          if (py < pyl+kMinSize) { py = pyl+kMinSize; wy = py; }
00419          if (px < pxlp) { px = pxlp; wx = px; }
00420          if (py > pytp) { py = pytp; wy = py; }
00421          if (!ropaque) gVirtualX->DrawBox(px   , py ,   pxt, pyl, TVirtualX::kHollow);
00422       }
00423       if (pTop) {
00424          if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
00425          py2 += py - pyold;
00426          if (py2 > py1-kMinSize) { py2 = py1-kMinSize; wy = py2; }
00427          if (py2 < py2p) { py2 = py2p; wy = py2; }
00428          if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
00429       }
00430       if (pBot) {
00431          if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
00432          py1 += py - pyold;
00433          if (py1 < py2+kMinSize) { py1 = py2+kMinSize; wy = py1; }
00434          if (py1 > py1p) { py1 = py1p; wy = py1; }
00435          if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
00436       }
00437       if (pL) {
00438          if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
00439          px1 += px - pxold;
00440          if (px1 > px2-kMinSize) { px1 = px2-kMinSize; wx = px1; }
00441          if (px1 < px1p) { px1 = px1p; wx = px1; }
00442          if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
00443       }
00444       if (pR) {
00445          if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
00446          px2 += px - pxold;
00447          if (px2 < px1+kMinSize) { px2 = px1+kMinSize; wx = px2; }
00448          if (px2 > px2p) { px2 = px2p; wx = px2; }
00449          if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
00450       }
00451       if (pINSIDE) {
00452          if (!opaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);  // draw the old box
00453          Int_t dx = px - pxold;
00454          Int_t dy = py - pyold;
00455          px1 += dx; py1 += dy; px2 += dx; py2 += dy;
00456          if (px1 < px1p) { dx = px1p - px1; px1 += dx; px2 += dx; wx = px+dx; }
00457          if (px2 > px2p) { dx = px2 - px2p; px1 -= dx; px2 -= dx; wx = px-dx; }
00458          if (py1 > py1p) { dy = py1 - py1p; py1 -= dy; py2 -= dy; wy = py-dy; }
00459          if (py2 < py2p) { dy = py2p - py2; py1 += dy; py2 += dy; wy = py+dy; }
00460          if (!opaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);  // draw the new box
00461       }
00462 
00463       if (wx || wy) {
00464          if (wx) px = wx;
00465          if (wy) py = wy;
00466          gVirtualX->Warp(px, py);
00467       }
00468 
00469       pxold = px;
00470       pyold = py;
00471 
00472       if ((pINSIDE && opaque) || (fResizing && ropaque)) {
00473          event = kButton1Up;
00474          doing_again = kTRUE;
00475          goto again;
00476       }
00477 
00478       break;
00479 
00480    case kButton1Up:
00481       if (gROOT->IsEscaped()) {
00482          gROOT->SetEscape(kFALSE);
00483          break;
00484       }
00485 
00486       if (px1 < 0 ) break;
00487       if (pA) {
00488          fX1 = gPad->AbsPixeltoX(pxold);
00489          fY1 = gPad->AbsPixeltoY(pyt);
00490          fX2 = gPad->AbsPixeltoX(pxt);
00491          fY2 = gPad->AbsPixeltoY(pyold);
00492       }
00493       if (pB) {
00494          fX1 = gPad->AbsPixeltoX(pxl);
00495          fY1 = gPad->AbsPixeltoY(pyt);
00496          fX2 = gPad->AbsPixeltoX(pxold);
00497          fY2 = gPad->AbsPixeltoY(pyold);
00498       }
00499       if (pC) {
00500          fX1 = gPad->AbsPixeltoX(pxl);
00501          fY1 = gPad->AbsPixeltoY(pyold);
00502          fX2 = gPad->AbsPixeltoX(pxold);
00503          fY2 = gPad->AbsPixeltoY(pyl);
00504       }
00505       if (pD) {
00506          fX1 = gPad->AbsPixeltoX(pxold);
00507          fY1 = gPad->AbsPixeltoY(pyold);
00508          fX2 = gPad->AbsPixeltoX(pxt);
00509          fY2 = gPad->AbsPixeltoY(pyl);
00510       }
00511       if (pTop || pBot || pL || pR || pINSIDE) {
00512          fX1 = gPad->AbsPixeltoX(px1);
00513          fY1 = gPad->AbsPixeltoY(py1);
00514          fX2 = gPad->AbsPixeltoX(px2);
00515          fY2 = gPad->AbsPixeltoY(py2);
00516       }
00517 
00518       if (pINSIDE) {
00519          // if it was not a pad that was moved then it must have been
00520          // a box or something like that so we have to redraw the pad
00521          if (parent == gPad) gPad->Modified(kTRUE);
00522          if (!doing_again) gPad->SetCursor(kCross);
00523       }
00524 
00525       if (pA || pB || pC || pD || pTop || pL || pR || pBot)
00526          gPad->Modified(kTRUE);
00527 
00528       gVirtualX->SetLineColor(-1);
00529       gVirtualX->SetLineWidth(-1);
00530 
00531       break;
00532 
00533    case kButton1Locate:
00534 
00535       ExecuteEvent(kButton1Down, px, py);
00536 
00537       while (1) {
00538          px = py = 0;
00539          event = gVirtualX->RequestLocator(1, 1, px, py);
00540 
00541          ExecuteEvent(kButton1Motion, px, py);
00542 
00543          if (event != -1) {                     // button is released
00544             ExecuteEvent(kButton1Up, px, py);
00545             return;
00546          }
00547       }
00548    }
00549 }
00550 
00551 
00552 //______________________________________________________________________________
00553 void TBox::HideToolTip(Int_t event)
00554 {
00555    // Hide tool tip depending on the event type. Typically tool tips
00556    // are hidden when event is not a kMouseEnter and not a kMouseMotion
00557    // event.
00558 
00559    if (event != kMouseEnter && event != kMouseMotion && fTip && gPad)
00560       gPad->CloseToolTip(fTip);
00561 }
00562 
00563 
00564 //______________________________________________________________________________
00565 Int_t TBox::IsInside(Double_t x, Double_t y) const
00566 {
00567    // Function which returns 1 if point x,y lies inside the box, 0 otherwise.
00568    
00569    if (x < fX1 || x > fX2) return 0;
00570    if (y < fY1 || y > fY2) return 0;
00571    return 1;
00572 }
00573 
00574 
00575 //______________________________________________________________________________
00576 void TBox::ls(Option_t *) const
00577 {
00578    // List this box with its attributes.
00579 
00580    TROOT::IndentLevel();
00581    printf("%s  X1= %f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),fX1,fY1,fX2,fY2);
00582 }
00583 
00584 
00585 //______________________________________________________________________________
00586 void TBox::Paint(Option_t *option)
00587 {
00588    // Paint this box with its current attributes.
00589 
00590    PaintBox(gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2),option);
00591 }
00592 
00593 
00594 //______________________________________________________________________________
00595 void TBox::PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option)
00596 {
00597    // Draw this box with new coordinates.
00598 
00599    TAttLine::Modify();  //Change line attributes only if necessary
00600    TAttFill::Modify();  //Change fill area attributes only if necessary
00601 
00602    if (option) {
00603       TString opt = option;
00604       opt.ToLower();
00605       if (opt.Contains("l")) gPad->PaintBox(x1,y1,x2,y2,"l");
00606       else                   gPad->PaintBox(x1,y1,x2,y2);
00607    } else {
00608       gPad->PaintBox(x1,y1,x2,y2);
00609    }
00610 }
00611 
00612 
00613 //______________________________________________________________________________
00614 void TBox::Print(Option_t *) const
00615 {
00616    // Dump this box with its attributes.
00617 
00618    printf("%s  X1=%f Y1=%f X2=%f Y2=%f",IsA()->GetName(),fX1,fY1,fX2,fY2);
00619    if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
00620    if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
00621    if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
00622    if (GetFillColor() != 0) printf(" FillColor=%d",GetFillColor());
00623    if (GetFillStyle() != 0) printf(" FillStyle=%d",GetFillStyle());
00624    printf("\n");
00625 }
00626 
00627 
00628 //______________________________________________________________________________
00629 void TBox::SavePrimitive(ostream &out, Option_t * /*= ""*/)
00630 {
00631    // Save primitive as a C++ statement(s) on output stream out
00632 
00633    if (gROOT->ClassSaved(TBox::Class())) {
00634       out<<"   ";
00635    } else {
00636       out<<"   TBox *";
00637    }
00638    out<<"box = new TBox("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2<<");"<<endl;
00639 
00640    SaveFillAttributes(out,"box",0,1001);
00641    SaveLineAttributes(out,"box",1,1,1);
00642 
00643    out<<"   box->Draw();"<<endl;
00644 }
00645 
00646 
00647 //______________________________________________________________________________
00648 void TBox::SetToolTipText(const char *text, Long_t delayms)
00649 {
00650    // Set tool tip text associated with this box. The delay is in
00651    // milliseconds (minimum 250). To remove tool tip call method with
00652    // text = 0.
00653 
00654    if (!gPad) {
00655       Warning("SetToolTipText", "a canvas must exist before setting the tool tip text");
00656       return;
00657    }
00658 
00659    if (fTip) {
00660       gPad->DeleteToolTip(fTip);
00661       fTip = 0;
00662    }
00663 
00664    if (text && strlen(text))
00665       fTip = gPad->CreateToolTip(this, text, delayms);
00666 }
00667 
00668 
00669 //______________________________________________________________________________
00670 void TBox::Streamer(TBuffer &R__b)
00671 {
00672    // Stream an object of class TBox.
00673 
00674    if (R__b.IsReading()) {
00675       UInt_t R__s, R__c;
00676       Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
00677       if (R__v > 1) {
00678          R__b.ReadClassBuffer(TBox::Class(), this, R__v, R__s, R__c);
00679          return;
00680       }
00681       //====process old versions before automatic schema evolution
00682       TObject::Streamer(R__b);
00683       TAttLine::Streamer(R__b);
00684       TAttFill::Streamer(R__b);
00685       Float_t x1,y1,x2,y2;
00686       R__b >> x1; fX1 = x1;
00687       R__b >> y1; fY1 = y1;
00688       R__b >> x2; fX2 = x2;
00689       R__b >> y2; fY2 = y2;
00690       R__b.CheckByteCount(R__s, R__c, TBox::IsA());
00691       //====end of old versions
00692 
00693    } else {
00694       R__b.WriteClassBuffer(TBox::Class(),this);
00695    }
00696 }

Generated on Tue Jul 5 14:14:27 2011 for ROOT_528-00b_version by  doxygen 1.5.1