ZoomPad Class Reference

#include <ZoomPad.h>

List of all members.

Public Member Functions

 ZoomPad (const char *name, const char *title, double xlow=0, double ylow=0, double xup=1, double yup=1)
virtual ~ZoomPad ()
RangeDouble2D GetCurRange ()
void UseCurRangeX (RangeDouble *rx)
void UseCurRangeY (RangeDouble *ry)
RangeDouble2D GetAxisRange ()
void UseAxisRangeX (RangeDouble *rx)
void UseAxisRangeY (RangeDouble *ry)
void Update (void)
void ApplySelectionToZoom ()
void SetIsZoomable (bool x=true, bool y=true)
void Unzoom (int number=1)
void SetScales (double xscale=1.0, double yscale=1.0)

Public Attributes

SigC::Signal0< void > selection

Private Member Functions

void UpdateRange (void)
void UpdateRangeAxis (void)
void ClearSelection (void)
virtual void RangeChanged ()
virtual void RangeAxisChanged ()
void ExecuteEvent (Int_t event, Int_t px, Int_t py)

Private Attributes

RangeDouble2D fCurRange
RangeDouble2D fAxisRange
RangeInt2D fSelRange
SigC::Connection fConCurX
SigC::Connection fConCurY
SigC::Connection fConAxisX
SigC::Connection fConAxisY
bool fHaveSelection
bool fDrawingSelection
bool fInside
bool fIsZoomableX
bool fIsZoomableY
double fXscale
double fYscale


Detailed Description

Id
ZoomPad.h,v 1.5 2005/07/21 20:26:36 bv Exp

Definition at line 29 of file ZoomPad.h.


Constructor & Destructor Documentation

ZoomPad::ZoomPad ( const char *  name,
const char *  title,
double  xlow = 0,
double  ylow = 0,
double  xup = 1,
double  yup = 1 
)

Definition at line 10 of file ZoomPad.cxx.

References fAxisRange, fConAxisX, fConAxisY, fConCurX, fConCurY, fCurRange, UpdateRange(), UpdateRangeAxis(), Range2D< TYPE >::x, and Range2D< TYPE >::y.

00013     : TPad(name,title,xlow,ylow,xup,yup)
00014     , fHaveSelection(false)
00015     , fDrawingSelection(false)
00016     , fIsZoomableX(true)
00017     , fIsZoomableY(true)
00018     , fXscale(1.0)
00019     , fYscale(1.0)
00020 {
00021 
00022     fCurRange.x->Set(0.,1.);
00023     fCurRange.y->Set(0.,1.);
00024 
00025     fConCurX = 
00026         fCurRange.x->modified.connect(SigC::slot_class(*this,&ZoomPad::UpdateRange));
00027     fConCurY = 
00028         fCurRange.y->modified.connect(SigC::slot_class(*this,&ZoomPad::UpdateRange));
00029     fConAxisX = 
00030         fAxisRange.x->modified.connect(SigC::slot_class(*this,&ZoomPad::UpdateRangeAxis));
00031     fConAxisY = 
00032         fAxisRange.y->modified.connect(SigC::slot_class(*this,&ZoomPad::UpdateRangeAxis));
00033 
00034     this->SetRightMargin(0.05);
00035     this->SetLeftMargin(0.05);
00036     this->SetTopMargin(0.05);
00037     this->SetBottomMargin(0.05);
00038 
00039 //    this->Clear();
00040 }

ZoomPad::~ZoomPad (  )  [virtual]

Definition at line 42 of file ZoomPad.cxx.

00043 {
00044 }


Member Function Documentation

void ZoomPad::ApplySelectionToZoom (  ) 

Definition at line 128 of file ZoomPad.cxx.

References fCurRange, fHaveSelection, fIsZoomableX, fIsZoomableY, fSelRange, fXscale, fYscale, Range2D< TYPE >::x, and Range2D< TYPE >::y.

Referenced by MultiPage::SelectionZoom(), EVD::SelectionZoom(), and set_pad_in_history().

00129 {
00130     if (!fHaveSelection) return;
00131 
00132     double x1 = this->AbsPixeltoX(fSelRange.x->Min());
00133     double x2 = this->AbsPixeltoX(fSelRange.x->Max());
00134     double y1 = this->AbsPixeltoY(fSelRange.y->Min());
00135     double y2 = this->AbsPixeltoY(fSelRange.y->Max());
00136 
00137     if (x1 > x2) { double tmp = x1; x1 = x2; x2 = tmp; }
00138     if (y1 > y2) { double tmp = y1; y1 = y2; y2 = tmp; }
00139 
00140     if (fIsZoomableX) fCurRange.x->Set(x1/fXscale,x2/fXscale);
00141     if (fIsZoomableY) fCurRange.y->Set(y1/fYscale,y2/fYscale);
00142 }

void ZoomPad::ClearSelection ( void   )  [private]

Definition at line 119 of file ZoomPad.cxx.

References fDrawingSelection, fHaveSelection, fSelRange, Range2D< TYPE >::x, and Range2D< TYPE >::y.

Referenced by ExecuteEvent().

00120 {
00121     fHaveSelection = false;
00122     fDrawingSelection = false;
00123     fSelRange.x->Set(0,0);
00124     fSelRange.y->Set(0,0);
00125 }

void ZoomPad::ExecuteEvent ( Int_t  event,
Int_t  px,
Int_t  py 
) [private]

Definition at line 57 of file ZoomPad.cxx.

References ClearSelection(), fDrawingSelection, fHaveSelection, fInside, fSelRange, selection, Range2D< TYPE >::x, and Range2D< TYPE >::y.

00058 {
00059    switch (event) {
00060 
00061    case kButton1Down:
00062        this->SetCursor(kHand);
00063        fInside = 1;
00064        fSelRange.x->SetMin(px);
00065        fSelRange.y->SetMin(py);
00066        break;
00067 
00068    case kButton1Motion:
00069        fInside=1;
00070        if (fDrawingSelection)
00071            gVirtualX->DrawBox(fSelRange.x->Min(), fSelRange.y->Min(),
00072                               fSelRange.x->Max(), fSelRange.y->Max(),
00073                               TVirtualX::kHollow);
00074        fSelRange.x->SetMax(px);
00075        fSelRange.y->SetMax(py);
00076        fDrawingSelection = true;
00077        gVirtualX->DrawBox(fSelRange.x->Min(), fSelRange.y->Min(),
00078                           fSelRange.x->Max(), fSelRange.y->Max(),
00079                           TVirtualX::kHollow);
00080        break;
00081 
00082    case kButton1Up: {
00083        this->SetCursor(kPointer);
00084 
00085        Int_t dtp = this->DistancetoPrimitive(fSelRange.x->Max(), 
00086                                              fSelRange.y->Max());
00087 
00088        if (!fDrawingSelection || dtp || !fInside) {
00089 #if 0
00090            cerr
00091                << "fDrawingSelection = " << fDrawingSelection
00092                << ", DistanceToPrimitive = " << dtp
00093                << ", fInside = " << fInside
00094                << endl;
00095 #endif
00096            this->ClearSelection();
00097            break;
00098        }
00099 
00100        fHaveSelection = true;
00101        fDrawingSelection = false;
00102 
00103        selection.emit();
00104        break;
00105    }
00106    case kMouseLeave:
00107        fInside = false;
00108        break;
00109    case kMouseEnter:
00110        fInside = true;
00111        break;
00112    default:
00113        this->TPad::ExecuteEvent(event,px,py);
00114        break;
00115    }
00116 //   cerr << "Got event: " << event  << "[ " << px << " , " << py << " ]\n";
00117 }

RangeDouble2D ZoomPad::GetAxisRange (  )  [inline]

Definition at line 44 of file ZoomPad.h.

References fAxisRange.

00044 { return fAxisRange; }

RangeDouble2D ZoomPad::GetCurRange (  )  [inline]

Definition at line 41 of file ZoomPad.h.

References fCurRange.

Referenced by main(), and set_pad_in_history().

00041 { return fCurRange; }

void ZoomPad::RangeAxisChanged (  )  [private, virtual]

Definition at line 179 of file ZoomPad.cxx.

References fAxisRange, fConAxisX, fConAxisY, Form(), fXscale, fYscale, Range2D< TYPE >::x, and Range2D< TYPE >::y.

00180 {
00181     // Propgate Rt signal
00182     this->TPad::RangeAxisChanged();
00183 
00184     double x1,y1,x2,y2;
00185     this->TPad::GetRangeAxis(x1,y1,x2,y2);
00186 
00187 #if 0
00188     cerr << "ZoomPad::RangeAxisChanged: " 
00189          << Form ("(%.1f, %.1f) --> (%.1f, %.1f)\n",x1,y1,x2,y2);
00190 #endif
00191 
00192     // Axis Range changed, update Range objects
00193     fConAxisX.block(true);
00194     fConAxisY.block(true);
00195     fAxisRange.x->Set(x1/fXscale,x2/fXscale);
00196     fAxisRange.y->Set(y1/fYscale,y2/fYscale);
00197     fConAxisX.block(false);
00198     fConAxisY.block(false);
00199 
00200 
00201 }

void ZoomPad::RangeChanged (  )  [private, virtual]

Definition at line 154 of file ZoomPad.cxx.

References fConCurX, fConCurY, fCurRange, Form(), fXscale, fYscale, Range2D< TYPE >::x, and Range2D< TYPE >::y.

00155 {
00156     // Propgate Rt signal
00157     this->TPad::RangeChanged();
00158 
00159     double x1,y1,x2,y2;
00160     this->TPad::GetRange(x1,y1,x2,y2);
00161 
00162 #if 0
00163     cerr << "ZoomPad::RangeChanged: " 
00164          << Form ("(%.1f, %.1f) --> (%.1f, %.1f)\n",
00165                   x1, y1, x2, y2);
00166 #endif
00167 
00168     // Axis Range changed, update Range objects
00169     fConCurX.block(true);
00170     fConCurY.block(true);
00171     fCurRange.x->Set(x1/fXscale,x2/fXscale);
00172     fCurRange.y->Set(y1/fYscale,y2/fYscale);
00173     fConCurX.block(false);
00174     fConCurY.block(false);
00175 
00176 
00177 
00178 }

void ZoomPad::SetIsZoomable ( bool  x = true,
bool  y = true 
) [inline]

Definition at line 55 of file ZoomPad.h.

References fIsZoomableX, and fIsZoomableY.

00056         { fIsZoomableX = x; fIsZoomableY = y; }

void ZoomPad::SetScales ( double  xscale = 1.0,
double  yscale = 1.0 
)

Definition at line 46 of file ZoomPad.cxx.

References fXscale, and fYscale.

Referenced by TimeHist::TimeHist().

00047 {
00048     fXscale = xscale;
00049     fYscale = yscale;
00050 }

void ZoomPad::Unzoom ( int  number = 1  ) 

Definition at line 52 of file ZoomPad.cxx.

00053 {
00054     cerr << "Can't unzoom yet\n" ; 
00055 }

void ZoomPad::Update ( void   ) 

Definition at line 144 of file ZoomPad.cxx.

References EVD::Update().

Referenced by TimeHist::UpdatePad().

00145 {
00146     this->cd();
00147     this->TPad::Update();
00148 }

void ZoomPad::UpdateRange ( void   )  [private]

Definition at line 204 of file ZoomPad.cxx.

References fCurRange, Form(), fXscale, fYscale, Range2D< TYPE >::x, and Range2D< TYPE >::y.

Referenced by UseCurRangeX(), UseCurRangeY(), and ZoomPad().

00205 {
00206 #if 0
00207     cerr << "ZoomPad::UpdateRange: " 
00208          << Form ("(%.1f, %.1f) --> (%.1f, %.1f)\n",
00209                   fXscale*fCurRange.x->Min(),fYscale*fCurRange.y->Min(),
00210                   fXscale*fCurRange.x->Max(),fYscale*fCurRange.y->Max());
00211 #endif
00212     bool is_editable = this->IsEditable();
00213     this->SetEditable(true);
00214     this->Range(fXscale*fCurRange.x->Min(),fYscale*fCurRange.y->Min(),
00215                 fXscale*fCurRange.x->Max(),fYscale*fCurRange.y->Max());
00216     this->TPad::Modified();
00217     this->SetEditable(is_editable);
00218 }

void ZoomPad::UpdateRangeAxis ( void   )  [private]

Definition at line 219 of file ZoomPad.cxx.

References fAxisRange, Form(), fXscale, fYscale, Range2D< TYPE >::x, and Range2D< TYPE >::y.

Referenced by UseAxisRangeX(), UseAxisRangeY(), and ZoomPad().

00220 {
00221 #if 0
00222     cerr << "ZoomPad::UpdateRangeAxis: " 
00223          << Form ("(%.1f, %.1f) --> (%.1f, %.1f)\n",
00224                   fXscale*fAxisRange.x->Min(),fYscale*fAxisRange.y->Min(),
00225                   fXscale*fAxisRange.x->Max(),fYscale*fAxisRange.y->Max());
00226 #endif
00227     bool is_editable = this->IsEditable();
00228     this->SetEditable(true);
00229     this->RangeAxis(fXscale*fAxisRange.x->Min(),fYscale*fAxisRange.y->Min(),
00230                     fXscale*fAxisRange.x->Max(),fYscale*fAxisRange.y->Max());
00231     this->TPad::Modified();
00232     this->SetEditable(is_editable);
00233 }

void ZoomPad::UseAxisRangeX ( RangeDouble rx  ) 

Definition at line 250 of file ZoomPad.cxx.

References fAxisRange, fConAxisX, UpdateRangeAxis(), and Range2D< TYPE >::x.

00251 {
00252     fConAxisX.disconnect();
00253     fAxisRange.x = rx;
00254     fConAxisX = 
00255         fAxisRange.x->modified.connect(SigC::slot_class(*this,&ZoomPad::UpdateRangeAxis));
00256 
00257 }

void ZoomPad::UseAxisRangeY ( RangeDouble ry  ) 

Definition at line 258 of file ZoomPad.cxx.

References fAxisRange, fConAxisY, UpdateRangeAxis(), and Range2D< TYPE >::y.

00259 {
00260     fConAxisY.disconnect();
00261     fAxisRange.y = ry;
00262     fConAxisY = 
00263         fAxisRange.y->modified.connect(SigC::slot_class(*this,&ZoomPad::UpdateRangeAxis));
00264 }

void ZoomPad::UseCurRangeX ( RangeDouble rx  ) 

Definition at line 235 of file ZoomPad.cxx.

References fConCurX, fCurRange, UpdateRange(), and Range2D< TYPE >::x.

Referenced by MultiPage::Init(), and EVD::Init().

00236 {
00237     fConCurX.disconnect();
00238     fCurRange.x = rx;
00239     fConCurX = 
00240         fCurRange.x->modified.connect(SigC::slot_class(*this,&ZoomPad::UpdateRange));
00241 
00242 }

void ZoomPad::UseCurRangeY ( RangeDouble ry  ) 

Definition at line 243 of file ZoomPad.cxx.

References fConCurY, fCurRange, UpdateRange(), and Range2D< TYPE >::y.

Referenced by MultiPage::Init(), and EVD::Init().

00244 {
00245     fConCurY.disconnect();
00246     fCurRange.y = ry;
00247     fConCurY = 
00248         fCurRange.y->modified.connect(SigC::slot_class(*this,&ZoomPad::UpdateRange));
00249 }


Member Data Documentation

RangeDouble2D ZoomPad::fAxisRange [private]

Definition at line 78 of file ZoomPad.h.

Referenced by GetAxisRange(), RangeAxisChanged(), UpdateRangeAxis(), UseAxisRangeX(), UseAxisRangeY(), and ZoomPad().

SigC::Connection ZoomPad::fConAxisX [private]

Definition at line 80 of file ZoomPad.h.

Referenced by RangeAxisChanged(), UseAxisRangeX(), and ZoomPad().

SigC::Connection ZoomPad::fConAxisY [private]

Definition at line 80 of file ZoomPad.h.

Referenced by RangeAxisChanged(), UseAxisRangeY(), and ZoomPad().

SigC::Connection ZoomPad::fConCurX [private]

Definition at line 80 of file ZoomPad.h.

Referenced by RangeChanged(), UseCurRangeX(), and ZoomPad().

SigC::Connection ZoomPad::fConCurY [private]

Definition at line 80 of file ZoomPad.h.

Referenced by RangeChanged(), UseCurRangeY(), and ZoomPad().

RangeDouble2D ZoomPad::fCurRange [private]

Definition at line 77 of file ZoomPad.h.

Referenced by ApplySelectionToZoom(), GetCurRange(), RangeChanged(), UpdateRange(), UseCurRangeX(), UseCurRangeY(), and ZoomPad().

bool ZoomPad::fDrawingSelection [private]

Definition at line 82 of file ZoomPad.h.

Referenced by ClearSelection(), and ExecuteEvent().

bool ZoomPad::fHaveSelection [private]

Definition at line 82 of file ZoomPad.h.

Referenced by ApplySelectionToZoom(), ClearSelection(), and ExecuteEvent().

bool ZoomPad::fInside [private]

Definition at line 82 of file ZoomPad.h.

Referenced by ExecuteEvent().

bool ZoomPad::fIsZoomableX [private]

Definition at line 83 of file ZoomPad.h.

Referenced by ApplySelectionToZoom(), and SetIsZoomable().

bool ZoomPad::fIsZoomableY [private]

Definition at line 83 of file ZoomPad.h.

Referenced by ApplySelectionToZoom(), and SetIsZoomable().

RangeInt2D ZoomPad::fSelRange [private]

Definition at line 79 of file ZoomPad.h.

Referenced by ApplySelectionToZoom(), ClearSelection(), and ExecuteEvent().

double ZoomPad::fXscale [private]

Definition at line 84 of file ZoomPad.h.

Referenced by ApplySelectionToZoom(), RangeAxisChanged(), RangeChanged(), SetScales(), UpdateRange(), and UpdateRangeAxis().

double ZoomPad::fYscale [private]

Definition at line 84 of file ZoomPad.h.

Referenced by ApplySelectionToZoom(), RangeAxisChanged(), RangeChanged(), SetScales(), UpdateRange(), and UpdateRangeAxis().

SigC::Signal0<void> ZoomPad::selection

Definition at line 39 of file ZoomPad.h.

Referenced by ExecuteEvent(), MultiPage::Init(), EVD::Init(), and main().


The documentation for this class was generated from the following files:
Generated on Mon Aug 11 01:07:07 2014 for loon by  doxygen 1.4.7