Ignore:
Timestamp:
02/10/09 20:00:10 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhbase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhbase/MH.cc

    r9302 r9312  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.43 2009-02-07 20:40:12 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.44 2009-02-10 20:00:09 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    18131813    return "MH::GetObjectInfo: unknown class.";
    18141814}
     1815
     1816// --------------------------------------------------------------------------
     1817//
     1818// Set the pad-range such that at the smallest width it is still
     1819// two times max and that the displayed "pixels" (i.e. its coordinate
     1820// system) have the width to height ratio of aspect.
     1821//
     1822void MH::SetPadRange(Float_t max, Float_t aspect)
     1823{
     1824    if (!gPad)
     1825        return;
     1826
     1827    const Float_t w = gPad->GetWw();
     1828    const Float_t h = gPad->GetWh();
     1829
     1830    if (w>aspect*h)
     1831    {
     1832        const Double_t dx = ((w/h-aspect)/2+1)*max;
     1833        gPad->Range(-dx, -max, dx, max);
     1834    }
     1835    else
     1836    {
     1837        const Double_t dy = ((h/w-1./aspect)/2+1)*max;
     1838        gPad->Range(-max, -dy, max, dy);
     1839    }
     1840}
     1841
     1842// --------------------------------------------------------------------------
     1843//
     1844// Set the range of a pad in a way that the coordinates fit into the pad
     1845// without abberation.
     1846//
     1847void MH::SetPadRange(Float_t x0, Float_t y0, Float_t x1, Float_t y1)
     1848{
     1849    if (!gPad)
     1850        return;
     1851
     1852    const Float_t w = x1-x0;                              // Width  in user coordinates
     1853    const Float_t h = y1-y0;                              // Hieght in user coordinates
     1854
     1855    const Float_t ww = gPad->GetWw()*gPad->GetAbsWNDC();  // Width  of pad in pixels
     1856    const Float_t hh = gPad->GetWh()*gPad->GetAbsHNDC();  // Height of pad in pixels
     1857
     1858    if (ww/hh > w/h)
     1859    {
     1860        const Double_t dx = (ww/hh-w/h)/2*h;
     1861
     1862        gPad->Range(x0-dx, y0, x1+dx, y1);
     1863    }
     1864    else
     1865    {
     1866        const Double_t dy = (hh/ww-h/w)/2*w;
     1867
     1868        gPad->Range(x0, y0-dy, x1, y1+dy);
     1869    }
     1870}
  • trunk/MagicSoft/Mars/mhbase/MH.h

    r9205 r9312  
    130130
    131131    static void SetPalette(TString paletteName="pretty", Int_t ncol=50);
     132    static void SetPadRange(Float_t max, Float_t aspect=1);
     133    static void SetPadRange(Float_t x0, Float_t y0, Float_t x1, Float_t y1);
    132134
    133135    static char *GetObjectInfoH(Int_t px, Int_t py, const TH1 &h);
Note: See TracChangeset for help on using the changeset viewer.