Logo ROOT  
Reference Guide
TFrame.cxx
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Rene Brun 31/10/96
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TVirtualPad.h"
13 #include "TFrame.h"
14 #include "TStyle.h"
15 
17 
18 /** \class TFrame
19 \ingroup BasicGraphics
20 
21 Define a Frame.
22 
23 A `TFrame` is a `TWbox` for drawing histogram frames.
24 */
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 /// Frame default constructor.
28 
30 {
31 }
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Frame normal constructor.
35 
37  :TWbox(x1,y1,x2,y2)
38 {
39 }
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// Frame copy constructor.
43 
44 TFrame::TFrame(const TFrame &frame) : TWbox(frame)
45 {
46  ((TFrame&)frame).Copy(*this);
47 }
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// Frame default destructor.
51 
53 {
54 }
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Copy this frame to frame.
58 
59 void TFrame::Copy(TObject &frame) const
60 {
61  TWbox::Copy(frame);
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Draw this frame with its current attributes.
66 
67 void TFrame::Draw(Option_t *option)
68 {
69  AppendPad(option);
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Execute action corresponding to one event.
74 ///
75 /// This member function is called when a TFrame object is clicked.
76 
78 {
79  if (!gPad) return;
80 
81  if (!gPad->IsEditable()) return;
82 
83  TWbox::ExecuteEvent(event, px, py);
84 
85  Bool_t opaque = gPad->OpaqueMoving();
86 
87  if ((event == kButton1Up) || ((opaque)&&(event == kButton1Motion))) {
88  // update pad margins
89  Double_t xmin = gPad->GetUxmin();
90  Double_t xmax = gPad->GetUxmax();
91  Double_t ymin = gPad->GetUymin();
92  Double_t ymax = gPad->GetUymax();
93  Double_t dx = xmax-xmin;
94  Double_t dy = ymax-ymin;
95  Double_t leftMargin = (fX1-gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
96  Double_t topMargin = (gPad->GetY2()-fY2)/(gPad->GetY2()-gPad->GetY1());
97  Double_t rightMargin = (gPad->GetX2()-fX2)/(gPad->GetX2()-gPad->GetX1());
98  Double_t bottomMargin = (fY1-gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
99  // margin may get very small negative values
100  if (leftMargin < 0) leftMargin = 0;
101  if (topMargin < 0) topMargin = 0;
102  if (rightMargin < 0) rightMargin = 0;
103  if (bottomMargin < 0) bottomMargin = 0;
104  gPad->SetLeftMargin(leftMargin);
105  gPad->SetRightMargin(rightMargin);
106  gPad->SetBottomMargin(bottomMargin);
107  gPad->SetTopMargin(topMargin);
108  Double_t dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
109  Double_t dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
110 
111  // Range() could change the size of the pad pixmap and therefore should
112  // be called before the other paint routines
113  gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
114  ymin - dyr*gPad->GetBottomMargin(),
115  xmax + dxr*gPad->GetRightMargin(),
116  ymax + dyr*gPad->GetTopMargin());
117  gPad->RangeAxis(xmin, ymin, xmax, ymax);
118  fX1 = xmin;
119  fY1 = ymin;
120  fX2 = xmax;
121  fY2 = ymax;
122  }
123 }
124 
125 ////////////////////////////////////////////////////////////////////////////////
126 /// Paint this wbox with its current attributes.
127 
128 void TFrame::Paint(Option_t *option)
129 {
130  const TPickerStackGuard stackGuard(this);
131 
132  if (!gPad->PadInHighlightMode() || (gPad->PadInHighlightMode() && this == gPad->GetSelected())) {
133  TWbox::Paint(option);
134 
135  gPad->PaintBox(fX1,fY1,fX2,fY2,"s");
136  }
137 
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// Do not pop frame's, if allowed they would cover the picture they frame.
142 
144 {
145 }
146 
147 ////////////////////////////////////////////////////////////////////////////////
148 /// Save primitive as a C++ statement(s) on output stream out
149 
150 void TFrame::SavePrimitive(std::ostream &, Option_t * /*= ""*/)
151 {
152 }
153 
154 ////////////////////////////////////////////////////////////////////////////////
155 /// Replace current frame attributes by current style.
156 
158 {
159  if (gStyle->IsReading()) {
167  } else {
175  }
176 }
TFrame::TFrame
TFrame()
Frame default constructor.
Definition: TFrame.cxx:29
ymax
float ymax
Definition: THbookFile.cxx:95
TWbox::SetBorderMode
virtual void SetBorderMode(Short_t bordermode)
Definition: TWbox.h:51
TWbox::Copy
void Copy(TObject &wbox) const
Copy this wbox to wbox.
Definition: TWbox.cxx:75
TStyle::GetFrameLineColor
Color_t GetFrameLineColor() const
Definition: TStyle.h:217
TAttFill::SetFillStyle
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
Option_t
const char Option_t
Definition: RtypesCore.h:66
kButton1Motion
@ kButton1Motion
Definition: Buttons.h:20
TStyle::GetFrameFillStyle
Style_t GetFrameFillStyle() const
Definition: TStyle.h:218
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TStyle::SetFrameFillStyle
void SetFrameFillStyle(Style_t styl=0)
Definition: TStyle.h:357
xmax
float xmax
Definition: THbookFile.cxx:95
kButton1Up
@ kButton1Up
Definition: Buttons.h:19
TBox::fX2
Double_t fX2
X of 2nd point.
Definition: TBox.h:30
TStyle::GetFrameBorderMode
Int_t GetFrameBorderMode() const
Definition: TStyle.h:222
TStyle.h
TObject::AppendPad
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:107
TBox::fX1
Double_t fX1
X of 1st point.
Definition: TBox.h:28
TFrame::UseCurrentStyle
virtual void UseCurrentStyle()
Replace current frame attributes by current style.
Definition: TFrame.cxx:157
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
TStyle::GetFrameBorderSize
Width_t GetFrameBorderSize() const
Definition: TStyle.h:221
TFrame::Pop
virtual void Pop()
Do not pop frame's, if allowed they would cover the picture they frame.
Definition: TFrame.cxx:143
bool
TStyle::GetFrameLineWidth
Width_t GetFrameLineWidth() const
Definition: TStyle.h:220
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TFrame::Paint
virtual void Paint(Option_t *option="")
Paint this wbox with its current attributes.
Definition: TFrame.cxx:128
TWbox::GetBorderSize
Short_t GetBorderSize() const
Definition: TWbox.h:41
TPickerStackGuard
Definition: TVirtualPad.h:275
TStyle::GetFrameFillColor
Color_t GetFrameFillColor() const
Definition: TStyle.h:216
TStyle::GetFrameLineStyle
Style_t GetFrameLineStyle() const
Definition: TStyle.h:219
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
xmin
float xmin
Definition: THbookFile.cxx:95
TAttLine::GetLineColor
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
TAttLine::GetLineStyle
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:34
TFrame::Copy
void Copy(TObject &frame) const
Copy this frame to frame.
Definition: TFrame.cxx:59
TWbox::GetBorderMode
Short_t GetBorderMode() const
Definition: TWbox.h:40
TFrame::~TFrame
virtual ~TFrame()
Frame default destructor.
Definition: TFrame.cxx:52
TVirtualPad.h
TWbox::SetBorderSize
virtual void SetBorderSize(Short_t bordersize)
Definition: TWbox.h:52
TStyle::SetFrameBorderMode
void SetFrameBorderMode(Int_t mode=1)
Definition: TStyle.h:361
TAttFill::GetFillStyle
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition: TAttFill.h:31
TStyle::IsReading
Bool_t IsReading() const
Definition: TStyle.h:282
TStyle::SetFrameLineWidth
void SetFrameLineWidth(Width_t width=1)
Definition: TStyle.h:359
TBox::fY1
Double_t fY1
Y of 1st point.
Definition: TBox.h:29
TFrame::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TFrame.cxx:150
TFrame
Define a Frame.
Definition: TFrame.h:19
ymin
float ymin
Definition: THbookFile.cxx:95
TStyle::SetFrameLineColor
void SetFrameLineColor(Color_t color=1)
Definition: TStyle.h:356
TAttLine::SetLineWidth
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
Double_t
double Double_t
Definition: RtypesCore.h:59
TStyle::SetFrameLineStyle
void SetFrameLineStyle(Style_t styl=0)
Definition: TStyle.h:358
TWbox
A TBox with a bordersize and a bordermode.
Definition: TWbox.h:20
TStyle::SetFrameBorderSize
void SetFrameBorderSize(Width_t size=1)
Definition: TStyle.h:360
TAttFill::SetFillColor
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TBox::fY2
Double_t fY2
Y of 2nd point.
Definition: TBox.h:31
TFrame.h
TFrame::ExecuteEvent
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TFrame.cxx:77
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
gPad
#define gPad
Definition: TVirtualPad.h:287
TAttFill::GetFillColor
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
TFrame::Draw
virtual void Draw(Option_t *option="")
Draw this frame with its current attributes.
Definition: TFrame.cxx:67
TWbox::Paint
virtual void Paint(Option_t *option="")
Paint this wbox with its current attributes.
Definition: TWbox.cxx:114
TStyle::SetFrameFillColor
void SetFrameFillColor(Color_t color=1)
Definition: TStyle.h:355
TAttLine::GetLineWidth
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:35
TAttLine::SetLineStyle
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
TWbox::ExecuteEvent
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TWbox.cxx:106
int