4 #include "KVIDGridEditorCanvas.h"
5 #include "KVIDGridEditor.h"
9 #include "TContextMenu.h"
10 #include "TRootCanvas.h"
12 #include <KeySymbols.h>
13 #include "TVirtualX.h"
64 TPad* prevSelPad = (TPad*) fSelectedPad;
65 TObject* prevSelObj = fSelected;
67 fPadSave = (TPad*)gPad;
78 pad = Pick(px, py, prevSelObj);
81 EnterLeave(prevSelPad, prevSelObj);
87 fSelected->ExecuteEvent(event, px, py);
95 if (!fDoubleBuffer) FeedbackMode(kTRUE);
102 TObject* sobj = fSelected;
103 TPad* spad = fSelectedPad;
106 EnterLeave(prevSelPad, prevSelObj);
109 if (!fDoubleBuffer) FeedbackMode(kFALSE);
119 pad = Pick(px, py, prevSelObj);
127 if (!fSelected->InheritsFrom(
"TPaveLabel")) fSelected->ExecuteEvent(event, px, py);
131 if (fSelected && fSelected->InheritsFrom(
"TH2")) {
136 gVirtualX->DrawBox(XtoAbsPixel(
xmin), YtoAbsPixel(
ymin),
oldx,
oldy, TVirtualX::kHollow);
145 if (fSelected->InheritsFrom(
"TH2")) {
146 gVirtualX->DrawBox(XtoAbsPixel(
xmin), YtoAbsPixel(
ymin),
oldx,
oldy, TVirtualX::kHollow);
149 gVirtualX->DrawBox(XtoAbsPixel(
xmin), YtoAbsPixel(
ymin),
oldx,
oldy, TVirtualX::kHollow);
153 case kButton1ShiftMotion:
157 if (!fSelected->InheritsFrom(
"TPaveLabel")) fSelected->ExecuteEvent(event, px, py);
160 if (!fSelected->InheritsFrom(TAxis::Class()) && (!fSelected->InheritsFrom(
"TPaveLabel"))) {
161 Bool_t resize = kFALSE;
162 if (fSelected->InheritsFrom(TBox::Class()))
163 resize = ((TBox*)fSelected)->IsBeingResized();
164 if (fSelected->InheritsFrom(TVirtualPad::Class()))
165 resize = ((TVirtualPad*)fSelected)->IsBeingResized();
167 if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) {
184 if (!fSelected->InheritsFrom(
"TPaveLabel")) fSelected->ExecuteEvent(event, px, py);
192 if (fSelected->InheritsFrom(
"TH2") &&
moved) {
193 xmax = AbsPixeltoX(GetEventX());
194 ymax = AbsPixeltoY(GetEventY());
220 pad = Pick(px, py, prevSelObj);
228 if (!fSelected->InheritsFrom(
"TH1")) {
232 if (fSelected->InheritsFrom(
"TH2")) {
236 theXaxis = ((TH2*)fSelected)->GetXaxis();
237 theYaxis = ((TH2*)fSelected)->GetYaxis();
245 Int_t pixelWidthX = gPad->XtoAbsPixel(gPad->GetUxmax()) - gPad->XtoAbsPixel(gPad->GetUxmin());
246 Int_t pixelWidthY = gPad->YtoAbsPixel(gPad->GetUymax()) - gPad->YtoAbsPixel(gPad->GetUymin());
255 printf(
"Current Pad: %s / %s\n", pad->GetName(), pad->GetTitle());
259 TIter next(gROOT->GetListOfCanvases());
261 while ((tc = (TCanvas*)next()))
271 if (fSelected && fSelected->InheritsFrom(
"TH2")) {
277 Bool_t changed = kFALSE;
278 Int_t newXfirst =
Xfirst0 - dXbins;
285 newXlast =
Xlast0 - dXbins;
291 if (newXfirst !=
Xf1) {
297 Int_t newYfirst =
Yfirst0 - dYbins;
304 newYlast =
Ylast0 - dYbins;
310 if (newYfirst !=
Yf1) {
327 if (!fSelected->InheritsFrom(
"TPaveLabel")) fSelected->ExecuteEvent(event, px, py);
339 pad = Pick(px, py, prevSelObj);
342 if (!fDoubleBuffer) FeedbackMode(kFALSE);
344 if (fContextMenu && !fSelected->TestBit(kNoContextMenu) &&
345 !pad->TestBit(kNoContextMenu) && !TestBit(kNoContextMenu) && (!fSelected->InheritsFrom(
"TPaveLabel")))
346 fContextMenu->Popup(px, py, fSelected,
this, pad);
354 if (!fDoubleBuffer) FeedbackMode(kTRUE);
365 if (!fSelectedPad || !fSelected)
return;
368 if (!fSelected->InheritsFrom(
"TPaveLabel")) fSelected->ExecuteEvent(event, px, py);
377 pad = Pick(px, py, prevSelObj);
381 EnterLeave(prevSelPad, prevSelObj);
386 if (!fSelected->InheritsFrom(
"TPaveLabel")) fSelected->ExecuteEvent(event, px, py);
392 pad = Pick(px, py, prevSelObj);
405 if (fPadSave && event != kButton2Down)
408 if (event != kMouseLeave) {
409 ProcessedEvent(event, px, py, fSelected);
420 if (gIDGridEditor) gIDGridEditor->
HandleKey(px, py);
TCanvas with mouse-controlled dynamic zoom and pan & scan.
void RunAutoExec()
Execute the list of TExecs in the current pad.
void DrawEventStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
void ZoomSelected(TH2 *TheHisto)
Extended version of KVCanvas used by KVIDGridEditor.
Double_t YbinPixel
size of bins in pixels
Int_t NdisYbins
number of displayed bins on X & Y
virtual ~KVIDGridEditorCanvas()
Destructor.
virtual Bool_t HandleKey(Int_t px, Int_t py)
KeyHandler *fKeyHandler; // handler for arrow keys.
Int_t Ylast0
number of bins on y-axis, initial displayed bins
Int_t X0
friend class KeyHandler;
Int_t Xlast0
number of bins on x-axis, initial displayed bins
KVIDGridEditorCanvas()
Default constructor.
Int_t Yl1
last modification to axis limits
TAxis * theYaxis
the axes of the histogram
Int_t Y0
coordinates of initial click in pad pixels
void HandleInput(EEventType event, Int_t px, Int_t py)
Bool_t HandleKey(Int_t px, Int_t py)
Handle keys.