SelectPad Class Reference

#include <SelectPad.h>

List of all members.

Public Member Functions

 SelectPad ()
 SelectPad (const char *name, const char *title, double xlow=0, double ylow=0, double xup=1, double yup=1)
virtual ~SelectPad ()

Private Member Functions

void ExecuteEvent (Int_t event, Int_t px, Int_t py)
void ClearSelection (void)
void ApplySelectionToButtons ()

Private Attributes

Int_t xmin
Int_t xmax
Int_t ymin
Int_t ymax
bool fHaveSelection
bool fDrawingSelection
bool fInside

Detailed Description

Definition at line 8 of file SelectPad.h.


Constructor & Destructor Documentation

SelectPad::SelectPad (  ) 

Definition at line 9 of file SelectPad.cxx.

00011     : TPad("sPad","sPad",0,0,1,1)
00012     , fHaveSelection(false)
00013     , fDrawingSelection(false)
00014     , fInside(false)
00015 {
00016 }

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

Definition at line 19 of file SelectPad.cxx.

00022     : TPad(name,title,xlow,ylow,xup,yup)
00023     , fHaveSelection(false)
00024     , fDrawingSelection(false)
00025     , fInside(false)
00026 {
00027 }

SelectPad::~SelectPad (  )  [virtual]

Definition at line 29 of file SelectPad.cxx.

00030 {
00031 }


Member Function Documentation

void SelectPad::ApplySelectionToButtons (  )  [private]

Definition at line 103 of file SelectPad.cxx.

References fHaveSelection, xmax, xmin, ymax, and ymin.

Referenced by ExecuteEvent().

00104 {
00105   if (!fHaveSelection) return;
00106   
00107   double x1 = this->AbsPixeltoX(xmin);
00108   double x2 = this->AbsPixeltoX(xmax);
00109   double y1 = this->AbsPixeltoY(ymin);
00110   double y2 = this->AbsPixeltoY(ymax);
00111   
00112   if (x1 > x2) { double tmp = x1; x1 = x2; x2 = tmp; }
00113   if (y1 > y2) { double tmp = y1; y1 = y2; y2 = tmp; }
00114 
00115   TList *theList = this->GetListOfPrimitives();
00116   TIterator *iter = theList->MakeIterator();
00117   TObject *ob = NULL;
00118   while((ob = iter->Next())){
00119     if(ob->InheritsFrom("TButton")) {
00120       TButton *but = (TButton*) ob;
00121       double bx1,bx2,by1,by2;
00122       but->GetPadPar(bx1,by1,bx2,by2);
00123       if (bx1 > bx2) { double tmp = bx1; bx1 = bx2; bx2 = tmp; }
00124       if (by1 > by2) { double tmp = by1; by1 = by2; by2 = tmp; }      
00125       if(((bx1>x1 && bx1<x2) || (bx2>x1 && bx2<x2)) &&
00126          ((by1>y1 && by1<y2) || (by2>y1 && by2<y2))){
00127         //if(bx1>x1&&bx2<x2&&by1>y1&&by2<y2){
00128         but->ExecuteEvent(kButton1Down,this->XtoAbsPixel((bx1+bx2)/2.),
00129                           this->YtoAbsPixel((by1+by2)/2.));
00130         but->ExecuteEvent(kButton1Up,this->XtoAbsPixel((bx1+bx2)/2.),
00131                           this->YtoAbsPixel((by1+by2)/2.));
00132       }
00133     }
00134   }
00135 }

void SelectPad::ClearSelection ( void   )  [private]

Definition at line 94 of file SelectPad.cxx.

References fHaveSelection, xmax, xmin, ymax, and ymin.

Referenced by ExecuteEvent().

00095 {
00096     fHaveSelection = false;    
00097     xmin = 0;
00098     ymin = 0;
00099     xmax = 0;
00100     ymax = 0;
00101 }

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

Definition at line 33 of file SelectPad.cxx.

References ApplySelectionToButtons(), ClearSelection(), fDrawingSelection, fHaveSelection, fInside, xmax, xmin, ymax, and ymin.

00034 {
00035    switch (event) {
00036 
00037    case kButton1Down:
00038        this->SetCursor(kHand);
00039        fInside = 1;
00040        xmin = px;
00041        ymin = py;
00042        break;
00043 
00044    case kButton1Motion:
00045      fInside=1;
00046      if (fDrawingSelection)
00047        gVirtualX->DrawBox(xmin,ymin,xmax,ymax,
00048                           TVirtualX::kHollow);
00049        xmax = px;
00050        ymax = py;
00051        fDrawingSelection = true;
00052        gVirtualX->DrawBox(xmin,ymin,xmax,ymax,
00053                           TVirtualX::kHollow);
00054        break;
00055        
00056    case kButton1Up: {
00057        this->SetCursor(kPointer);
00058 
00059        Int_t dtp = this->DistancetoPrimitive(xmax,ymax);
00060 
00061        if (!fDrawingSelection || dtp || !fInside) {
00062            cerr
00063                << "fDrawingSelection = " << fDrawingSelection
00064                << ", DistanceToPrimitive = " << dtp
00065                << ", fInside = " << fInside
00066                << endl;
00067            fDrawingSelection = false;
00068            fInside = false;
00069            this->ClearSelection();
00070            break;
00071        }
00072 
00073        fHaveSelection = true;
00074 
00075        this->ApplySelectionToButtons();
00076        this->Update();
00077        fInside = false;
00078        fDrawingSelection = false;
00079        this->ClearSelection();
00080        break;
00081    }
00082    case kMouseLeave:
00083        fInside = false;
00084        break;
00085    case kMouseEnter:
00086        fInside = true;
00087        break;
00088    default:
00089        this->TPad::ExecuteEvent(event,px,py);
00090        break;
00091    }
00092 }


Member Data Documentation

Definition at line 29 of file SelectPad.h.

Referenced by ExecuteEvent().

bool SelectPad::fHaveSelection [private]

Definition at line 28 of file SelectPad.h.

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

bool SelectPad::fInside [private]

Definition at line 30 of file SelectPad.h.

Referenced by ExecuteEvent().

Int_t SelectPad::xmax [private]

Definition at line 25 of file SelectPad.h.

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

Int_t SelectPad::xmin [private]

Definition at line 24 of file SelectPad.h.

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

Int_t SelectPad::ymax [private]

Definition at line 27 of file SelectPad.h.

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

Int_t SelectPad::ymin [private]

Definition at line 26 of file SelectPad.h.

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


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1