TFrame.cxx

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TFrame.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Rene Brun   31/10/96
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 "Riostream.h"
00013 #include "TROOT.h"
00014 #include "TVirtualPad.h"
00015 #include "TFrame.h"
00016 #include "TStyle.h"
00017 
00018 ClassImp(TFrame)
00019 
00020 //______________________________________________________________________________
00021 //
00022 // a TFrame is a TWbox for drawing histogram frames.
00023 //
00024 
00025 //______________________________________________________________________________
00026 TFrame::TFrame(): TWbox()
00027 {
00028    // Frame default constructor.
00029 
00030 }
00031 
00032 //______________________________________________________________________________
00033 TFrame::TFrame(Double_t x1, Double_t y1,Double_t x2, Double_t  y2)
00034        :TWbox(x1,y1,x2,y2)
00035 {
00036    // Frame normal constructor.
00037 
00038 }
00039 
00040 //______________________________________________________________________________
00041 TFrame::TFrame(const TFrame &frame) : TWbox(frame)
00042 {
00043    // Frame copy constructor.
00044 
00045    ((TFrame&)frame).Copy(*this);
00046 }
00047 
00048 //______________________________________________________________________________
00049 TFrame::~TFrame()
00050 {
00051    // Frame default destructor.
00052 
00053 }
00054 
00055 //______________________________________________________________________________
00056 void TFrame::Copy(TObject &frame) const
00057 {
00058    // Copy this frame to frame.
00059 
00060    TWbox::Copy(frame);
00061 }
00062 
00063 //______________________________________________________________________________
00064 void TFrame::Draw(Option_t *option)
00065 {
00066    // Draw this frame with its current attributes.
00067 
00068    AppendPad(option);
00069 }
00070 
00071 //______________________________________________________________________________
00072 void TFrame::ExecuteEvent(Int_t event, Int_t px, Int_t py)
00073 {
00074    // Execute action corresponding to one event.
00075    //
00076    //  This member function is called when a TFrame object is clicked.
00077 
00078    if (!gPad->IsEditable()) return;
00079 
00080    TWbox::ExecuteEvent(event, px, py);
00081 
00082    if (event != kButton1Up) return;
00083    // update pad margins
00084    Double_t xmin         = gPad->GetUxmin();
00085    Double_t xmax         = gPad->GetUxmax();
00086    Double_t ymin         = gPad->GetUymin();
00087    Double_t ymax         = gPad->GetUymax();
00088    Double_t dx           = xmax-xmin;
00089    Double_t dy           = ymax-ymin;
00090    Double_t leftMargin   = (fX1-gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
00091    Double_t topMargin    = (gPad->GetY2()-fY2)/(gPad->GetY2()-gPad->GetY1());
00092    Double_t rightMargin  = (gPad->GetX2()-fX2)/(gPad->GetX2()-gPad->GetX1());
00093    Double_t bottomMargin = (fY1-gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
00094    // margin may get very small negative values
00095    if (leftMargin   < 0) leftMargin   = 0;
00096    if (topMargin    < 0) topMargin    = 0;
00097    if (rightMargin  < 0) rightMargin  = 0;
00098    if (bottomMargin < 0) bottomMargin = 0;
00099    gPad->SetLeftMargin(leftMargin);
00100    gPad->SetRightMargin(rightMargin);
00101    gPad->SetBottomMargin(bottomMargin);
00102    gPad->SetTopMargin(topMargin);
00103    Double_t dxr  = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
00104    Double_t dyr  = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
00105 
00106    // Range() could change the size of the pad pixmap and therefore should
00107    // be called before the other paint routines
00108    gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
00109                       ymin - dyr*gPad->GetBottomMargin(),
00110                       xmax + dxr*gPad->GetRightMargin(),
00111                       ymax + dyr*gPad->GetTopMargin());
00112    gPad->RangeAxis(xmin, ymin, xmax, ymax);
00113    fX1 = xmin;
00114    fY1 = ymin;
00115    fX2 = xmax;
00116    fY2 = ymax;
00117 }
00118 
00119 //______________________________________________________________________________
00120 void TFrame::Paint(Option_t *option)
00121 {
00122    // Paint this wbox with its current attributes.
00123 
00124    TWbox::Paint(option);
00125       
00126    gPad->PaintBox(fX1,fY1,fX2,fY2,"s");
00127 }
00128 
00129 //______________________________________________________________________________
00130 void TFrame::Pop()
00131 {
00132    // Do not pop frame's, if allowed they would cover the picture they frame.
00133 }
00134 
00135 //______________________________________________________________________________
00136 void TFrame::SavePrimitive(ostream &, Option_t * /*= ""*/)
00137 {
00138     // Save primitive as a C++ statement(s) on output stream out
00139 
00140 }
00141 
00142 //______________________________________________________________________________
00143 void TFrame::UseCurrentStyle()
00144 {
00145    // Replace current frame attributes by current style.
00146 
00147    if (gStyle->IsReading()) {
00148       SetFillColor(gStyle->GetFrameFillColor());
00149       SetLineColor(gStyle->GetFrameLineColor());
00150       SetFillStyle(gStyle->GetFrameFillStyle());
00151       SetLineStyle(gStyle->GetFrameLineStyle());
00152       SetLineWidth(gStyle->GetFrameLineWidth());
00153       SetBorderSize(gStyle->GetFrameBorderSize());
00154       SetBorderMode(gStyle->GetFrameBorderMode());
00155    } else {
00156       gStyle->SetFrameFillColor(GetFillColor());
00157       gStyle->SetFrameLineColor(GetLineColor());
00158       gStyle->SetFrameFillStyle(GetFillStyle());
00159       gStyle->SetFrameLineStyle(GetLineStyle());
00160       gStyle->SetFrameLineWidth(GetLineWidth());
00161       gStyle->SetFrameBorderSize(GetBorderSize());
00162       gStyle->SetFrameBorderMode(GetBorderMode());
00163    }
00164 }

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