diff --git a/graf2d/gpad/inc/TCanvas.h b/graf2d/gpad/inc/TCanvas.h index b32991e..e435fe3 100644 --- a/graf2d/gpad/inc/TCanvas.h +++ b/graf2d/gpad/inc/TCanvas.h @@ -188,6 +188,7 @@ public: {wtopx=GetWindowTopX(); wtopy=fWindowTopY; ww=fWindowWidth; wh=fWindowHeight;} virtual void HandleInput(EEventType button, Int_t x, Int_t y); Bool_t HasMenuBar() const { return TestBit(kMenuBar); } + virtual void HighlightConnect(const char *slot); void Iconify() { fCanvasImp->Iconify(); } Bool_t IsBatch() const { return fBatch; } Bool_t IsFolder() const; @@ -201,6 +202,7 @@ public: virtual TPad *Pick(Int_t px, Int_t py, TObjLink *&pickobj) { return TPad::Pick(px, py, pickobj); } virtual TPad *Pick(Int_t px, Int_t py, TObject *prevSelObj); virtual void Picked(TPad *selpad, TObject *selected, Int_t event); // *SIGNAL* + virtual void Highlighted(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y); // *SIGNAL* virtual void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected); // *SIGNAL* virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event); // *SIGNAL* virtual void Cleared(TVirtualPad *pad); // *SIGNAL* diff --git a/graf2d/gpad/src/TCanvas.cxx b/graf2d/gpad/src/TCanvas.cxx index 6ec81ac..aecedf1 100644 --- a/graf2d/gpad/src/TCanvas.cxx +++ b/graf2d/gpad/src/TCanvas.cxx @@ -1506,6 +1506,30 @@ void TCanvas::Picked(TPad *pad, TObject *obj, Int_t event) Emit("Picked(TPad*,TObject*,Int_t)", args); } +//______________________________________________________________________________ +void TCanvas::Highlighted(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y) +{ + // Emit Highlighted() signal + + Long_t args[4]; + + args[0] = (Long_t) pad; + args[1] = (Long_t) obj; + args[2] = x; + args[3] = y; + + Emit("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", args); +} + +//______________________________________________________________________________ +void TCanvas::HighlightConnect(const char *slot) +{ + // This is "simplification" for function TCanvas::Connect with Highlighted + // signal for specific slot. + + Connect("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", 0, 0, slot); +} + //______________________________________________________________________________ void TCanvas::Selected(TVirtualPad *pad, TObject *obj, Int_t event) { diff --git a/graf3d/gl/inc/TGLHistPainter.h b/graf3d/gl/inc/TGLHistPainter.h index 62d9350..5aeed46 100644 --- a/graf3d/gl/inc/TGLHistPainter.h +++ b/graf3d/gl/inc/TGLHistPainter.h @@ -77,6 +77,7 @@ public: void Paint(Option_t *option); void PaintStat(Int_t dostat, TF1 *fit); void ProcessMessage(const char *message, const TObject *obj); + void SetHighlight(); void SetHistogram(TH1 *hist); void SetStack(TList *stack); Int_t MakeCuts(char *cutsOpt); diff --git a/graf3d/gl/src/TGLHistPainter.cxx b/graf3d/gl/src/TGLHistPainter.cxx index f73fd76..63625d3 100644 --- a/graf3d/gl/src/TGLHistPainter.cxx +++ b/graf3d/gl/src/TGLHistPainter.cxx @@ -513,6 +513,14 @@ void TGLHistPainter::ProcessMessage(const char *m, const TObject *o) fDefaultPainter->ProcessMessage(m, o); } +//______________________________________________________________________________ +void TGLHistPainter::SetHighlight() +{ + // Set highlight mode + if (fDefaultPainter.get()) + fDefaultPainter->SetHighlight(); +} + //______________________________________________________________________________ void TGLHistPainter::SetHistogram(TH1 *h) { diff --git a/hist/hist/inc/TGraph.h b/hist/hist/inc/TGraph.h index f2f9809..2df1db5 100644 --- a/hist/hist/inc/TGraph.h +++ b/hist/hist/inc/TGraph.h @@ -80,7 +80,8 @@ public: // TGraph status bits enum { kClipFrame = BIT(10), // clip to the frame boundary - kNotEditable = BIT(18) // bit set if graph is non editable + kNotEditable = BIT(18), // bit set if graph is non editable + kIsHighlight = BIT(19) // bit set if graph is highlight (different than in ROOT6) }; TGraph(); @@ -160,6 +161,7 @@ public: virtual Int_t InsertPoint(); // *MENU* virtual Double_t Integral(Int_t first=0, Int_t last=-1) const; virtual Bool_t IsEditable() const {return !TestBit(kNotEditable);} + virtual Bool_t IsHighlight() const { return TestBit(kIsHighlight); } virtual Int_t IsInside(Double_t x, Double_t y) const; virtual void LeastSquareFit(Int_t m, Double_t *a, Double_t xmin=0, Double_t xmax=0); virtual void LeastSquareLinearFit(Int_t n, Double_t &a0, Double_t &a1, Int_t &ifail, Double_t xmin=0, Double_t xmax=0); @@ -174,6 +176,7 @@ public: virtual Int_t RemovePoint(Int_t ipoint); virtual void SavePrimitive(ostream &out, Option_t *option = ""); virtual void SetEditable(Bool_t editable=kTRUE); // *TOGGLE* *GETTER=GetEditable + virtual void SetHighlight(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsHighlight virtual void SetHistogram(TH1F *h) {fHistogram = h;} virtual void SetMaximum(Double_t maximum=-1111); // *MENU* virtual void SetMinimum(Double_t minimum=-1111); // *MENU* diff --git a/hist/hist/inc/TH1.h b/hist/hist/inc/TH1.h index f9f3ebd..531fc8f 100644 --- a/hist/hist/inc/TH1.h +++ b/hist/hist/inc/TH1.h @@ -158,7 +158,8 @@ public: kLogX = BIT(15), // X-axis in log scale kIsZoomed = BIT(16), // bit set when zooming on Y axis kNoTitle = BIT(17), // don't draw the histogram title - kIsAverage = BIT(18) // Bin contents are average (used by Add) + kIsAverage = BIT(18), // Bin contents are average (used by Add) + kIsHighlight = BIT(19) // bit set if histo is highlight (different than in ROOT6) }; // size of statistics data (size of array used in GetStats()/ PutStats ) // s[0] = sumw s[1] = sumw2 @@ -312,6 +313,7 @@ public: virtual Double_t Interpolate(Double_t x, Double_t y, Double_t z); Bool_t IsBinOverflow(Int_t bin) const; Bool_t IsBinUnderflow(Int_t bin) const; + virtual Bool_t IsHighlight() const { return TestBit(kIsHighlight); } virtual Double_t AndersonDarlingTest(const TH1 *h2, Option_t *option="") const; virtual Double_t AndersonDarlingTest(const TH1 *h2, Double_t &advalue) const; virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const; @@ -365,6 +367,7 @@ public: virtual void SetDirectory(TDirectory *dir); virtual void SetEntries(Double_t n) {fEntries = n;}; virtual void SetError(const Double_t *error); + virtual void SetHighlight(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsHighlight virtual void SetLabelColor(Color_t color=1, Option_t *axis="X"); virtual void SetLabelFont(Style_t font=62, Option_t *axis="X"); virtual void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X"); diff --git a/hist/hist/inc/TVirtualGraphPainter.h b/hist/hist/inc/TVirtualGraphPainter.h index 30db223..3f7d760 100644 --- a/hist/hist/inc/TVirtualGraphPainter.h +++ b/hist/hist/inc/TVirtualGraphPainter.h @@ -43,6 +43,7 @@ public: virtual void PaintGraph(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt) = 0; virtual void PaintGrapHist(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt) = 0; virtual void PaintStats(TGraph *theGraph, TF1 *fit) = 0; + virtual void SetHighlight(TGraph *theGraph) = 0; static TVirtualGraphPainter *GetPainter(); static void SetPainter(TVirtualGraphPainter *painter); diff --git a/hist/hist/inc/TVirtualHistPainter.h b/hist/hist/inc/TVirtualHistPainter.h index 475221d..c22d2e9 100644 --- a/hist/hist/inc/TVirtualHistPainter.h +++ b/hist/hist/inc/TVirtualHistPainter.h @@ -48,6 +48,7 @@ public: virtual void Paint(Option_t *option="") = 0; virtual void PaintStat(Int_t dostat, TF1 *fit) = 0; virtual void ProcessMessage(const char *mess, const TObject *obj) = 0; + virtual void SetHighlight() = 0; virtual void SetHistogram(TH1 *h) = 0; virtual void SetStack(TList *stack) = 0; virtual Int_t MakeCuts(char *cutsopt) = 0; diff --git a/hist/hist/src/TGraph.cxx b/hist/hist/src/TGraph.cxx index a313e86..2644177 100644 --- a/hist/hist/src/TGraph.cxx +++ b/hist/hist/src/TGraph.cxx @@ -2220,6 +2220,21 @@ void TGraph::SetEditable(Bool_t editable) } +//______________________________________________________________________________ +void TGraph::SetHighlight(Bool_t set) +{ + // Set highlight (enable/disble) mode for the graph, by default highlight + // mode is disable. Invokes directly TGraphPainter::SetHighlight(). + + if (IsHighlight() == set) return; + + TVirtualGraphPainter *painter = TVirtualGraphPainter::GetPainter(); + if (!painter) return; + SetBit(kIsHighlight, set); + painter->SetHighlight(this); +} + + //______________________________________________________________________________ void TGraph::SetMaximum(Double_t maximum) { diff --git a/hist/hist/src/TH1.cxx b/hist/hist/src/TH1.cxx index 1a1c01c..42a2c52 100644 --- a/hist/hist/src/TH1.cxx +++ b/hist/hist/src/TH1.cxx @@ -4024,6 +4024,26 @@ Double_t TH1::GetEffectiveEntries() const return (s[1] ? s[0]*s[0]/s[1] : TMath::Abs(s[0]) ); } +//______________________________________________________________________________ +void TH1::SetHighlight(Bool_t set) +{ + // Set highlight (enable/disable) mode for the histogram, by default + // highlight mode is disable. Invokes directly THistPainter::SetHighlight(). + + if (IsHighlight() == set) return; + if (fDimension > 2) { + Info("SetHighlight", "Supported only 1-D or 2-D histograms"); + return; + } + + if (!fPainter) { + Info("SetHighlight", "Need to draw histogram first"); + return; + } + SetBit(kIsHighlight, set); + fPainter->SetHighlight(); +} + //______________________________________________________________________________ char *TH1::GetObjectInfo(Int_t px, Int_t py) const { diff --git a/hist/histpainter/inc/TGraphPainter.h b/hist/histpainter/inc/TGraphPainter.h index 86c364b..1b40926 100644 --- a/hist/histpainter/inc/TGraphPainter.h +++ b/hist/histpainter/inc/TGraphPainter.h @@ -41,6 +41,9 @@ public: virtual void DrawPanelHelper(TGraph *theGraph); virtual void ExecuteEventHelper(TGraph *theGraph, Int_t event, Int_t px, Int_t py); virtual char *GetObjectInfoHelper(TGraph *theGraph, Int_t px, Int_t py) const; + virtual Int_t GetHighlightPoint(TGraph *theGraph) const; + virtual void HighlightPoint(TGraph *theGraph, Int_t hpoint, Int_t distance); + virtual void PaintHighlightPoint(TGraph *theGraph, Option_t *option); void PaintHelper(TGraph *theGraph, Option_t *option); virtual void PaintGraph(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt); virtual void PaintGrapHist(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt); @@ -52,6 +55,7 @@ public: void PaintGraphSimple(TGraph *theGraph, Option_t *option); void PaintPolyLineHatches(TGraph *theGraph, Int_t n, const Double_t *x, const Double_t *y); void PaintStats(TGraph *theGraph, TF1 *fit); + virtual void SetHighlight(TGraph *theGraph); void Smooth(TGraph *theGraph, Int_t npoints, Double_t *x, Double_t *y, Int_t drawtype); ClassDef(TGraphPainter,0) // TGraph painter diff --git a/hist/histpainter/inc/THistPainter.h b/hist/histpainter/inc/THistPainter.h index 5c8d9fa..798a272 100644 --- a/hist/histpainter/inc/THistPainter.h +++ b/hist/histpainter/inc/THistPainter.h @@ -57,6 +57,8 @@ protected: TList *fStack; //Pointer to stack of histograms (if any) Int_t fShowProjection; //True if a projection must be drawn TString fShowOption; //Option to draw the projection + Int_t fXHighlightBin; //X highlight bin + Int_t fYHighlightBin; //Y highlight bin public: THistPainter(); @@ -68,6 +70,9 @@ public: virtual TList *GetContourList(Double_t contour) const; virtual char *GetObjectInfo(Int_t px, Int_t py) const; virtual TList *GetStack() const {return fStack;} + virtual Int_t GetXHighlightBin() const { return fXHighlightBin; } + virtual Int_t GetYHighlightBin() const { return fYHighlightBin; } + virtual void HighlightBin(Int_t px, Int_t py); virtual Bool_t IsInside(Int_t x, Int_t y); virtual Bool_t IsInside(Double_t x, Double_t y); virtual Int_t MakeChopt(Option_t *option); @@ -93,6 +98,7 @@ public: virtual void Paint2DErrors(Option_t *option); virtual void PaintFrame(); virtual void PaintFunction(Option_t *option); + virtual void PaintHighlightBin(Option_t *option=""); virtual void PaintHist(Option_t *option); virtual void PaintH3(Option_t *option=""); virtual void PaintH3Iso(); @@ -118,6 +124,7 @@ public: static Int_t ProjectParabolic2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab); virtual void RecalculateRange(); virtual void RecursiveRemove(TObject *) {;} + virtual void SetHighlight(); virtual void SetHistogram(TH1 *h); virtual void SetStack(TList *stack) {fStack = stack;} virtual void SetShowProjection(const char *option,Int_t nbins); diff --git a/hist/histpainter/src/TGraphPainter.cxx b/hist/histpainter/src/TGraphPainter.cxx index d918099..d7a9264 100644 --- a/hist/histpainter/src/TGraphPainter.cxx +++ b/hist/histpainter/src/TGraphPainter.cxx @@ -15,7 +15,7 @@ #include "TGraph.h" #include "TPolyLine.h" #include "TPolyMarker.h" -#include "TVirtualPad.h" +#include "TCanvas.h" #include "TView.h" #include "TStyle.h" #include "TH1.h" @@ -30,10 +30,15 @@ #include "TLatex.h" #include "TArrow.h" #include "TFrame.h" +#include "TMarker.h" #include "TVirtualPadEditor.h" Double_t *gxwork, *gywork, *gxworkl, *gyworkl; +static Int_t gHighlightPoint = -1; // highlight point of graph +static TGraph *gHighlightGraph = 0; // pointer to graph with highlight point +static TMarker *gHighlightMarker = 0; // highlight marker + ClassImp(TGraphPainter); @@ -654,12 +659,19 @@ Int_t TGraphPainter::DistancetoPrimitiveHelper(TGraph *theGraph, Int_t px, Int_t theY = theGraph->GetY(); } + Int_t hpoint = -1; for (i=0;i<theNpoints;i++) { pxp = gPad->XtoAbsPixel(gPad->XtoPad(theX[i])); pyp = gPad->YtoAbsPixel(gPad->YtoPad(theY[i])); d = TMath::Abs(pxp-px) + TMath::Abs(pyp-py); - if (d < distance) distance = d; + if (d < distance) { + distance = d; + hpoint = i; + } } + + if (theGraph->IsHighlight()) // only if highlight is enable + HighlightPoint(theGraph, hpoint, distance); if (distance < kMaxDiff) return distance; for (i=0;i<theNpoints-1;i++) { @@ -1008,6 +1020,105 @@ char *TGraphPainter::GetObjectInfoHelper(TGraph * /*theGraph*/, Int_t /*px*/, In } +//______________________________________________________________________________ +Int_t TGraphPainter::GetHighlightPoint(TGraph *theGraph) const +{ + // Return the highlighted point for theGraph + + if (theGraph == gHighlightGraph) return gHighlightPoint; + else return -1; +} + + +//______________________________________________________________________________ +void TGraphPainter::SetHighlight(TGraph *theGraph) +{ + // Set highlight (enable/disable) mode for theGraph + + gHighlightPoint = -1; // must be -1 + gHighlightGraph = 0; + if (theGraph->IsHighlight()) return; + + // delete previous highlight marker + if (gHighlightMarker) { gHighlightMarker->Delete(); gHighlightMarker = 0; } + // emit Highlighted() signal (user can check on disabled) + if (gPad->GetCanvas()) gPad->GetCanvas()->Highlighted(gPad, theGraph, gHighlightPoint, -1); +} + + +//______________________________________________________________________________ +void TGraphPainter::HighlightPoint(TGraph *theGraph, Int_t hpoint, Int_t distance) +{ + // Check on highlight point + // call from DistancetoPrimitiveHelper (only if highlight is enable) + + const Int_t kHighlightRange = 50; // maybe as fgHighlightRange and Set/Get + static Int_t distanceOld = kHighlightRange; + if (gHighlightPoint == -1) distanceOld = kHighlightRange; // reset + + if ((distance < kHighlightRange) && (distance < distanceOld)) { // closest point + if ((gHighlightPoint != hpoint) || (gHighlightGraph != theGraph)) { // was changed + // Info("HighlightPoint", "graph: %p\tpoint: %d", (void *)theGraph, hpoint); + gHighlightPoint = hpoint; + gHighlightGraph = theGraph; + + // paint highlight point as marker (recursive calls PaintHighlightPoint) + gPad->Modified(kTRUE); + gPad->Update(); + + // emit Highlighted() signal + if (gPad->GetCanvas()) gPad->GetCanvas()->Highlighted(gPad, theGraph, gHighlightPoint, -1); + } + } + if (gHighlightGraph == theGraph) distanceOld = distance; +} + + +//______________________________________________________________________________ +void TGraphPainter::PaintHighlightPoint(TGraph *theGraph, Option_t * /*option*/) +{ + // Paint highlight point as TMarker object (open circle) + // call from PaintGraphSimple + + if ((!theGraph->IsHighlight()) || (gHighlightGraph != theGraph)) return; + + Double_t hx, hy; + if (theGraph->GetPoint(gHighlightPoint, hx, hy) == -1) { + // special case, e.g. after interactive remove last point + if (gHighlightMarker) { gHighlightMarker->Delete(); gHighlightMarker = 0; } + return; + } + // testing specific possibility (after zoom, draw with "same", log, etc.) + Double_t uxmin = gPad->GetUxmin(); + Double_t uxmax = gPad->GetUxmax(); + Double_t uymin = gPad->GetUymin(); + Double_t uymax = gPad->GetUymax(); + if (gPad->GetLogx()) { + uxmin = TMath::Power(10.0, uxmin); + uxmax = TMath::Power(10.0, uxmax); + } + if (gPad->GetLogy()) { + uymin = TMath::Power(10.0, uymin); + uymax = TMath::Power(10.0, uymax); + } + if ((hx < uxmin) || (hx > uxmax)) return; + if ((hy < uymin) || (hy > uymax)) return; + + if (!gHighlightMarker) { + gHighlightMarker = new TMarker(hx, hy, 24); + gHighlightMarker->SetBit(kCannotPick); + } + gHighlightMarker->SetX(hx); + gHighlightMarker->SetY(hy); + gHighlightMarker->SetMarkerSize(theGraph->GetMarkerSize()*2.0); + if (gHighlightMarker->GetMarkerSize() < 1.0) gHighlightMarker->SetMarkerSize(1.0); // always visible + gHighlightMarker->SetMarkerColor(theGraph->GetMarkerColor()); + gHighlightMarker->Paint(); + // Info("PaintHighlightPoint", "graph: %p\tpoint: %d", + // (void *)gHighlightGraph, gHighlightPoint); +} + + //______________________________________________________________________________ void TGraphPainter::PaintHelper(TGraph *theGraph, Option_t *option) { @@ -3330,6 +3441,8 @@ void TGraphPainter::PaintGraphSimple(TGraph *theGraph, Option_t *option) PaintGraph(theGraph, theGraph->GetN(), theGraph->GetX(), theGraph->GetY(), option); } + PaintHighlightPoint(theGraph, option); + // Paint associated objects in the list of functions (for instance // the fit function). TList *functions = theGraph->GetListOfFunctions(); diff --git a/hist/histpainter/src/THistPainter.cxx b/hist/histpainter/src/THistPainter.cxx index 5caaa63..34a294d 100644 --- a/hist/histpainter/src/THistPainter.cxx +++ b/hist/histpainter/src/THistPainter.cxx @@ -2931,6 +2931,9 @@ const Int_t kNMAX = 2000; const Int_t kMAXCONTOUR = 104; const UInt_t kCannotRotate = BIT(11); +static TBox *gXHighlightBox = 0; // highlight X box +static TBox *gYHighlightBox = 0; // highlight Y box + static TString gStringEntries; static TString gStringMean; static TString gStringMeanX; @@ -2981,6 +2984,8 @@ THistPainter::THistPainter() fCuts[i] = 0; fCutsOpt[i] = 0; } + fXHighlightBin = -1; + fYHighlightBin = -1; gStringEntries = gEnv->GetValue("Hist.Stats.Entries", "Entries"); gStringMean = gEnv->GetValue("Hist.Stats.Mean", "Mean"); @@ -3115,6 +3120,11 @@ Int_t THistPainter::DistancetoPrimitive(Int_t px, Int_t py) } } + if (fH->IsHighlight()) { // only if highlight is enable + if ((px > puxmin) && (py < puymin) && (px < puxmax) && (py > puymax)) + HighlightBin(px, py); + } + // if object is 2D or 3D return this object if (fH->GetDimension() == 2) { if (fH->InheritsFrom(TH2Poly::Class())) { @@ -3580,6 +3590,144 @@ char *THistPainter::GetObjectInfo(Int_t px, Int_t py) const } +//______________________________________________________________________________ +void THistPainter::SetHighlight() +{ + // Set highlight (enable/disable) mode for fH + + if (fH->IsHighlight()) return; + + fXHighlightBin = -1; + fYHighlightBin = -1; + // delete previous highlight box + if (gXHighlightBox) { gXHighlightBox->Delete(); gXHighlightBox = 0; } + if (gYHighlightBox) { gYHighlightBox->Delete(); gYHighlightBox = 0; } + // emit Highlighted() signal (user can check on disabled) + if (gPad->GetCanvas()) gPad->GetCanvas()->Highlighted(gPad, fH, fXHighlightBin, fYHighlightBin); +} + + +//______________________________________________________________________________ +void THistPainter::HighlightBin(Int_t px, Int_t py) +{ + // Check on highlight bin + // call from DistancetoPrimitive (only if highlight is enable) + + Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px)); + Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py)); + Int_t binx = fXaxis->FindFixBin(x); + Int_t biny = fYaxis->FindFixBin(y); + if (!gPad->IsVertical()) binx = fXaxis->FindFixBin(y); + + Bool_t changedBin = kFALSE; + if (binx != fXHighlightBin) { + fXHighlightBin = binx; + changedBin = kTRUE; + } else if (fH->GetDimension() == 1) return; + if (biny != fYHighlightBin) { + fYHighlightBin = biny; + changedBin = kTRUE; + } + if (!changedBin) return; + + // Info("HighlightBin", "histo: %p '%s'\txbin: %d, ybin: %d", + // (void *)fH, fH->GetName(), fXHighlightBin, fYHighlightBin); + + // paint highlight bin as box (recursive calls PaintHighlightBin) + gPad->Modified(kTRUE); + gPad->Update(); + + // emit Highlighted() signal + if (gPad->GetCanvas()) gPad->GetCanvas()->Highlighted(gPad, fH, fXHighlightBin, fYHighlightBin); +} + + +//______________________________________________________________________________ +void THistPainter::PaintHighlightBin(Option_t * /*option*/) +{ + // Paint highlight bin as TBox object + // call from PaintTitle + + if (!fH->IsHighlight()) return; + + Double_t uxmin = gPad->GetUxmin(); + Double_t uxmax = gPad->GetUxmax(); + Double_t uymin = gPad->GetUymin(); + Double_t uymax = gPad->GetUymax(); + if (gPad->GetLogx()) { + uxmin = TMath::Power(10.0, uxmin); + uxmax = TMath::Power(10.0, uxmax); + } + if (gPad->GetLogy()) { + uymin = TMath::Power(10.0, uymin); + uymax = TMath::Power(10.0, uymax); + } + + // testing specific possibility (after zoom, draw with "same", log, etc.) + Double_t hcenter; + if (gPad->IsVertical()) { + hcenter = fXaxis->GetBinCenter(fXHighlightBin); + if ((hcenter < uxmin) || (hcenter > uxmax)) return; + } else { + hcenter = fYaxis->GetBinCenter(fXHighlightBin); + if ((hcenter < uymin) || (hcenter > uymax)) return; + } + if (fH->GetDimension() == 2) { + hcenter = fYaxis->GetBinCenter(fYHighlightBin); + if ((hcenter < uymin) || (hcenter > uymax)) return; + } + + // paint X highlight bin (for 1D or 2D) + Double_t hbx1, hbx2, hby1, hby2; + if (gPad->IsVertical()) { + hbx1 = fXaxis->GetBinLowEdge(fXHighlightBin); + hbx2 = fXaxis->GetBinUpEdge(fXHighlightBin); + hby1 = uymin; + hby2 = uymax; + } else { + hbx1 = uxmin; + hbx2 = uxmax; + hby1 = fYaxis->GetBinLowEdge(fXHighlightBin); + hby2 = fYaxis->GetBinUpEdge(fXHighlightBin); + } + + if (!gXHighlightBox) { + gXHighlightBox = new TBox(hbx1, hby1, hbx2, hby2); + gXHighlightBox->SetBit(kCannotPick); + gXHighlightBox->SetFillColor(TColor::GetColor("#9797ff")); + if (!TCanvas::SupportAlpha()) gXHighlightBox->SetFillStyle(3001); + else gROOT->GetColor(gXHighlightBox->GetFillColor())->SetAlpha(0.5); + } + gXHighlightBox->SetX1(hbx1); + gXHighlightBox->SetX2(hbx2); + gXHighlightBox->SetY1(hby1); + gXHighlightBox->SetY2(hby2); + gXHighlightBox->Paint(); + + // Info("PaintHighlightBin", "histo: %p '%s'\txbin: %d, ybin: %d", + // (void *)fH, fH->GetName(), fXHighlightBin, fYHighlightBin); + + // paint Y highlight bin (only for 2D) + if (fH->GetDimension() != 2) return; + hbx1 = uxmin; + hbx2 = uxmax; + hby1 = fYaxis->GetBinLowEdge(fYHighlightBin); + hby2 = fYaxis->GetBinUpEdge(fYHighlightBin); + + if (!gYHighlightBox) { + gYHighlightBox = new TBox(hbx1, hby1, hbx2, hby2); + gYHighlightBox->SetBit(kCannotPick); + gYHighlightBox->SetFillColor(gXHighlightBox->GetFillColor()); + gYHighlightBox->SetFillStyle(gXHighlightBox->GetFillStyle()); + } + gYHighlightBox->SetX1(hbx1); + gYHighlightBox->SetX2(hbx2); + gYHighlightBox->SetY1(hby1); + gYHighlightBox->SetY2(hby2); + gYHighlightBox->Paint(); +} + + //______________________________________________________________________________ Bool_t THistPainter::IsInside(Int_t ix, Int_t iy) { @@ -9179,6 +9327,10 @@ void THistPainter::PaintTitle() for instance the default alignment is: 13 (left top) End_html */ + // probably best place for calls PaintHighlightBin + // calls after paint histo (1D or 2D) and before paint title and stats + if (!gPad->GetView()) PaintHighlightBin(); + if (Hoption.Same) return; if (fH->TestBit(TH1::kNoTitle)) return; Int_t nt = strlen(fH->GetTitle());