ROOT  6.06/09
Reference Guide
TCanvas.cxx
Go to the documentation of this file.
1 // @(#)root/gpad:$Id$
2 // Author: Rene Brun 12/12/94
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include <string.h>
13 #include <stdlib.h>
14 
15 #include "Riostream.h"
16 #include "TROOT.h"
17 #include "TCanvas.h"
18 #include "TClass.h"
19 #include "TStyle.h"
20 #include "TText.h"
21 #include "TBox.h"
22 #include "TCanvasImp.h"
23 #include "TDialogCanvas.h"
24 #include "TGuiFactory.h"
25 #include "TEnv.h"
26 #include "TError.h"
27 #include "TContextMenu.h"
28 #include "TControlBar.h"
29 #include "TInterpreter.h"
30 #include "TApplication.h"
31 #include "TColor.h"
32 #include "TVirtualPadEditor.h"
33 #include "TVirtualViewer3D.h"
34 #include "TPadPainter.h"
35 #include "TVirtualGL.h"
36 #include "TVirtualPS.h"
37 #include "TObjectSpy.h"
38 #include "TAxis.h"
39 #include "TView.h"
40 
41 #include "TVirtualMutex.h"
42 
43 class TCanvasInit {
44 public:
45  TCanvasInit() { TApplication::NeedGraphicsLibs(); }
46 };
47 static TCanvasInit gCanvasInit;
48 
49 
50 //*-*x16 macros/layout_canvas
51 
53 
55 
57 
58 
59 /** \class TCanvas
60 \ingroup gpad
61 
62 The Canvas class.
63 
64 A Canvas is an area mapped to a window directly under the control of the display
65 manager. A ROOT session may have several canvases open at any given time.
66 
67 A Canvas may be subdivided into independent graphical areas: the __Pads__.
68 A canvas has a default pad which has the name of the canvas itself.
69 An example of a Canvas layout is sketched in the picture below.
70 
71 \image html gpad_canvas.png
72 
73 This canvas contains two pads named P1 and P2. Both Canvas, P1 and P2 can be
74 moved, grown, shrinked using the normal rules of the Display manager.
75 
76 Once objects have been drawn in a canvas, they can be edited/moved by pointing
77 directly to them. The cursor shape is changed to suggest the type of action that
78 one can do on this object. Clicking with the right mouse button on an object
79 pops-up a contextmenu with a complete list of actions possible on this object.
80 
81 A graphical editor may be started from the canvas "View" menu under the menu
82 entry "Toolbar".
83 
84 An interactive HELP is available by clicking on the HELP button at the top right
85 of the canvas. It gives a short explanation about the canvas' menus.
86 
87 A canvas may be automatically divided into pads via `TPad::Divide`.
88 
89 At creation time, no matter if in interactive or batch mode, the canvas size
90 defines the size of the canvas window (including the size of the window
91 manager's decoration). To define precisely the graphics area size of a canvas in
92 the interactive mode, the following four lines of code should be used:
93 ~~~ {.cpp}
94  {
95  Double_t w = 600;
96  Double_t h = 600;
97  TCanvas * c1 = new TCanvas("c", "c", w, h);
98  c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
99  }
100 ~~~
101 and in the batch mode simply do:
102 ~~~ {.cpp}
103  c->SetCanvasSize(w,h);
104 ~~~
105 */
106 
107 ////////////////////////////////////////////////////////////////////////////////
108 /// Canvas default constructor.
109 
110 TCanvas::TCanvas(Bool_t build) : TPad(), fDoubleBuffer(0)
111 {
112  fPainter = 0;
113  fWindowTopX = 0;
114  fWindowTopY = 0;
115  fWindowWidth = 0;
116  fWindowHeight = 0;
117  fCw = 0;
118  fCh = 0;
119 
120  fUseGL = gStyle->GetCanvasPreferGL();
121 
122  if (!build || TClass::IsCallingNew() != TClass::kRealNew) {
123  Constructor();
124  } else {
125  const char *defcanvas = gROOT->GetDefCanvasName();
126  char *cdef;
127 
128  TList *lc = (TList*)gROOT->GetListOfCanvases();
129  if (lc->FindObject(defcanvas)) {
130  Int_t n = lc->GetSize()+1;
131  while (lc->FindObject(Form("%s_n%d",defcanvas,n))) n++;
132  cdef = StrDup(Form("%s_n%d",defcanvas,n));
133  } else {
134  cdef = StrDup(Form("%s",defcanvas));
135  }
136  Constructor(cdef, cdef, 1);
137  delete [] cdef;
138  }
139 }
140 
141 ////////////////////////////////////////////////////////////////////////////////
142 /// Canvas default constructor
143 
145 {
146  if (gThreadXAR) {
147  void *arr[2];
148  arr[1] = this;
149  if ((*gThreadXAR)("CANV", 2, arr, 0)) return;
150  }
151 
152  fCanvas = 0;
153  fCanvasID = -1;
154  fCanvasImp = 0;
155  fBatch = kTRUE;
156  fUpdating = kFALSE;
157 
158  fContextMenu = 0;
159  fSelected = 0;
160  fClickSelected = 0;
161  fSelectedPad = 0;
162  fClickSelectedPad = 0;
163  fPadSave = 0;
164  SetBit(kAutoExec);
167 }
168 
169 ////////////////////////////////////////////////////////////////////////////////
170 /// Create an embedded canvas, i.e. a canvas that is in a TGCanvas widget
171 /// which is placed in a TGFrame. This ctor is only called via the
172 /// TRootEmbeddedCanvas class.
173 ///
174 /// If "name" starts with "gl" the canvas is ready to receive GL output.
175 
176 TCanvas::TCanvas(const char *name, Int_t ww, Int_t wh, Int_t winid) : TPad(), fDoubleBuffer(0)
177 {
178  fPainter = 0;
179  Init();
180 
181  fCanvasID = winid;
182  fWindowTopX = 0;
183  fWindowTopY = 0;
184  fWindowWidth = ww;
185  fWindowHeight = wh;
186  fCw = ww + 4;
187  fCh = wh +28;
188  fBatch = kFALSE;
189  fUpdating = kFALSE;
190 
191  //This is a very special ctor. A window exists already!
192  //Can create painter now.
194 
195  if (fUseGL) {
196  fGLDevice = gGLManager->CreateGLContext(winid);
197  if (fGLDevice == -1)
198  fUseGL = kFALSE;
199  }
200 
201  CreatePainter();
202 
203  fCanvasImp = gBatchGuiFactory->CreateCanvasImp(this, name, fCw, fCh);
204  if (!fCanvasImp) return;
205  SetName(name);
206  Build();
207 }
208 
209 ////////////////////////////////////////////////////////////////////////////////
210 /// Create a new canvas with a predefined size form.
211 /// If form < 0 the menubar is not shown.
212 ///
213 /// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
214 /// - form = 2 500x500 at 20,20
215 /// - form = 3 500x500 at 30,30
216 /// - form = 4 500x500 at 40,40
217 /// - form = 5 500x500 at 50,50
218 ///
219 /// If "name" starts with "gl" the canvas is ready to receive GL output.
220 
221 TCanvas::TCanvas(const char *name, const char *title, Int_t form) : TPad(), fDoubleBuffer(0)
222 {
223  fPainter = 0;
225 
226  Constructor(name, title, form);
227 }
228 
229 ////////////////////////////////////////////////////////////////////////////////
230 /// Create a new canvas with a predefined size form.
231 /// If form < 0 the menubar is not shown.
232 ///
233 /// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
234 /// - form = 2 500x500 at 20,20
235 /// - form = 3 500x500 at 30,30
236 /// - form = 4 500x500 at 40,40
237 /// - form = 5 500x500 at 50,50
238 
239 void TCanvas::Constructor(const char *name, const char *title, Int_t form)
240 {
241  if (gThreadXAR) {
242  void *arr[6];
243  static Int_t ww = 500;
244  static Int_t wh = 500;
245  arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
246  if ((*gThreadXAR)("CANV", 6, arr, 0)) return;
247  }
248 
249  Init();
250  SetBit(kMenuBar,1);
251  if (form < 0) {
252  form = -form;
253  SetBit(kMenuBar,0);
254  }
255 
256  fCanvas = this;
257 
258  fCanvasID = -1;
259  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
260  if (old && old->IsOnHeap()) {
261  Warning("Constructor","Deleting canvas with same name: %s",name);
262  delete old;
263  }
264  if (!name[0] || gROOT->IsBatch()) { //We are in Batch mode
265  fWindowTopX = fWindowTopY = 0;
266  if (form == 1) {
267  fWindowWidth = gStyle->GetCanvasDefW();
269  } else {
270  fWindowWidth = 500;
271  fWindowHeight = 500;
272  }
273  fCw = fWindowWidth;
274  fCh = fWindowHeight;
275  fCanvasImp = gBatchGuiFactory->CreateCanvasImp(this, name, fCw, fCh);
276  if (!fCanvasImp) return;
277  fBatch = kTRUE;
278  } else { //normal mode with a screen window
280  if (form < 1 || form > 5) form = 1;
281  if (form == 1) {
282  UInt_t uh = UInt_t(cx*gStyle->GetCanvasDefH());
283  UInt_t uw = UInt_t(cx*gStyle->GetCanvasDefW());
284  Int_t ux = Int_t(cx*gStyle->GetCanvasDefX());
285  Int_t uy = Int_t(cx*gStyle->GetCanvasDefY());
286  fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, ux, uy, uw, uh);
287  }
288  fCw = 500;
289  fCh = 500;
290  if (form == 2) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 20, 20, UInt_t(cx*500), UInt_t(cx*500));
291  if (form == 3) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 30, 30, UInt_t(cx*500), UInt_t(cx*500));
292  if (form == 4) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 40, 40, UInt_t(cx*500), UInt_t(cx*500));
293  if (form == 5) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 50, 50, UInt_t(cx*500), UInt_t(cx*500));
294  if (!fCanvasImp) return;
295 
296  if (!gROOT->IsBatch() && fCanvasID == -1)
298 
300  fBatch = kFALSE;
301  }
302 
303  CreatePainter();
304 
305  SetName(name);
306  SetTitle(title); // requires fCanvasImp set
307  Build();
308 
309  // Popup canvas
310  fCanvasImp->Show();
311 }
312 
313 ////////////////////////////////////////////////////////////////////////////////
314 /// Create a new canvas at a random position.
315 ///
316 /// \param[in] name canvas name
317 /// \param[in] title canvas title
318 /// \param[in] ww is the canvas size in pixels along X
319 /// (if ww < 0 the menubar is not shown)
320 /// \param[in] wh is the canvas size in pixels along Y
321 ///
322 /// If "name" starts with "gl" the canvas is ready to receive GL output.
323 
324 TCanvas::TCanvas(const char *name, const char *title, Int_t ww, Int_t wh) : TPad(), fDoubleBuffer(0)
325 {
326  fPainter = 0;
328 
329  Constructor(name, title, ww, wh);
330 }
331 
332 ////////////////////////////////////////////////////////////////////////////////
333 /// Create a new canvas at a random position.
334 ///
335 /// \param[in] name canvas name
336 /// \param[in] title canvas title
337 /// \param[in] ww is the canvas size in pixels along X
338 /// (if ww < 0 the menubar is not shown)
339 /// \param[in] wh is the canvas size in pixels along Y
340 
341 void TCanvas::Constructor(const char *name, const char *title, Int_t ww, Int_t wh)
342 {
343  if (gThreadXAR) {
344  void *arr[6];
345  arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
346  if ((*gThreadXAR)("CANV", 6, arr, 0)) return;
347  }
348 
349  Init();
350  SetBit(kMenuBar,1);
351  if (ww < 0) {
352  ww = -ww;
353  SetBit(kMenuBar,0);
354  }
355  fCw = ww;
356  fCh = wh;
357  fCanvasID = -1;
358  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
359  if (old && old->IsOnHeap()) {
360  Warning("Constructor","Deleting canvas with same name: %s",name);
361  delete old;
362  }
363  if (!name[0] || gROOT->IsBatch()) { //We are in Batch mode
364  fWindowTopX = fWindowTopY = 0;
365  fWindowWidth = ww;
366  fWindowHeight = wh;
367  fCw = ww;
368  fCh = wh;
369  fCanvasImp = gBatchGuiFactory->CreateCanvasImp(this, name, fCw, fCh);
370  if (!fCanvasImp) return;
371  fBatch = kTRUE;
372  } else {
374  fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, UInt_t(cx*ww), UInt_t(cx*wh));
375  if (!fCanvasImp) return;
376 
377  if (!gROOT->IsBatch() && fCanvasID == -1)
379 
381  fBatch = kFALSE;
382  }
383 
384  CreatePainter();
385 
386  SetName(name);
387  SetTitle(title); // requires fCanvasImp set
388  Build();
389 
390  // Popup canvas
391  fCanvasImp->Show();
392 }
393 
394 ////////////////////////////////////////////////////////////////////////////////
395 /// Create a new canvas.
396 ///
397 /// \param[in] name canvas name
398 /// \param[in] title canvas title
399 /// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
400 /// the canvas (if wtopx < 0) the menubar is not shown)
401 /// \param[in] ww is the canvas size in pixels along X
402 /// \param[in] wh is the canvas size in pixels along Y
403 ///
404 /// If "name" starts with "gl" the canvas is ready to receive GL output.
405 
406 TCanvas::TCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
407  : TPad(), fDoubleBuffer(0)
408 {
409  fPainter = 0;
411 
412  Constructor(name, title, wtopx, wtopy, ww, wh);
413 }
414 
415 ////////////////////////////////////////////////////////////////////////////////
416 /// Create a new canvas.
417 ///
418 /// \param[in] name canvas name
419 /// \param[in] title canvas title
420 /// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
421 /// the canvas (if wtopx < 0) the menubar is not shown)
422 /// \param[in] ww is the canvas size in pixels along X
423 /// \param[in] wh is the canvas size in pixels along Y
424 
425 void TCanvas::Constructor(const char *name, const char *title, Int_t wtopx,
426  Int_t wtopy, Int_t ww, Int_t wh)
427 {
428  if (gThreadXAR) {
429  void *arr[8];
430  arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title;
431  arr[4] = &wtopx; arr[5] = &wtopy; arr[6] = &ww; arr[7] = &wh;
432  if ((*gThreadXAR)("CANV", 8, arr, 0)) return;
433  }
434 
435  Init();
436  SetBit(kMenuBar,1);
437  if (wtopx < 0) {
438  wtopx = -wtopx;
439  SetBit(kMenuBar,0);
440  }
441  fCw = ww;
442  fCh = wh;
443  fCanvasID = -1;
444  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
445  if (old && old->IsOnHeap()) {
446  Warning("Constructor","Deleting canvas with same name: %s",name);
447  delete old;
448  }
449  if (!name[0] || gROOT->IsBatch()) { //We are in Batch mode
450  fWindowTopX = fWindowTopY = 0;
451  fWindowWidth = ww;
452  fWindowHeight = wh;
453  fCw = ww;
454  fCh = wh;
455  fCanvasImp = gBatchGuiFactory->CreateCanvasImp(this, name, fCw, fCh);
456  if (!fCanvasImp) return;
457  fBatch = kTRUE;
458  } else { //normal mode with a screen window
460  fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, Int_t(cx*wtopx), Int_t(cx*wtopy), UInt_t(cx*ww), UInt_t(cx*wh));
461  if (!fCanvasImp) return;
462 
463  if (!gROOT->IsBatch() && fCanvasID == -1)
465 
467  fBatch = kFALSE;
468  }
469 
470  CreatePainter();
471 
472  SetName(name);
473  SetTitle(title); // requires fCanvasImp set
474  Build();
475 
476  // Popup canvas
477  fCanvasImp->Show();
478 }
479 
480 ////////////////////////////////////////////////////////////////////////////////
481 /// Initialize the TCanvas members. Called by all constructors.
482 
484 {
485  // Make sure the application environment exists. It is need for graphics
486  // (colors are initialized in the TApplication ctor).
487  if (!gApplication)
489 
490  // Load and initialize graphics libraries if
491  // TApplication::NeedGraphicsLibs() has been called by a
492  // library static initializer.
493  if (gApplication)
495 
496  // Get some default from .rootrc. Used in fCanvasImp->InitWindow().
497  fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
498  SetBit(kMoveOpaque, gEnv->GetValue("Canvas.MoveOpaque", 0));
499  SetBit(kResizeOpaque, gEnv->GetValue("Canvas.ResizeOpaque", 0));
500  if (gEnv->GetValue("Canvas.ShowEventStatus", kFALSE)) SetBit(kShowEventStatus);
501  if (gEnv->GetValue("Canvas.ShowToolTips", kFALSE)) SetBit(kShowToolTips);
502  if (gEnv->GetValue("Canvas.ShowToolBar", kFALSE)) SetBit(kShowToolBar);
503  if (gEnv->GetValue("Canvas.ShowEditor", kFALSE)) SetBit(kShowEditor);
504  if (gEnv->GetValue("Canvas.AutoExec", kTRUE)) SetBit(kAutoExec);
505 
506  // Fill canvas ROOT data structure
507  fXsizeUser = 0;
508  fYsizeUser = 0;
509  fXsizeReal = kDefaultCanvasSize;
510  fYsizeReal = kDefaultCanvasSize;
511 
512  fDISPLAY = "$DISPLAY";
513  fUpdating = kFALSE;
514  fRetained = kTRUE;
515  fSelected = 0;
516  fClickSelected = 0;
517  fSelectedX = 0;
518  fSelectedY = 0;
519  fSelectedPad = 0;
521  fPadSave = 0;
522  fEvent = -1;
523  fEventX = -1;
524  fEventY = -1;
525  fContextMenu = 0;
526  fDrawn = kFALSE;
527 }
528 
529 ////////////////////////////////////////////////////////////////////////////////
530 /// Build a canvas. Called by all constructors.
531 
533 {
534  // Get window identifier
535  if (fCanvasID == -1 && fCanvasImp)
537  if (fCanvasID == -1) return;
538 
539  if (fCw !=0 && fCh !=0) {
540  if (fCw < fCh) fXsizeReal = fYsizeReal*Float_t(fCw)/Float_t(fCh);
541  else fYsizeReal = fXsizeReal*Float_t(fCh)/Float_t(fCw);
542  }
543 
544  // Set Pad parameters
545  gPad = this;
546  fCanvas = this;
547  fMother = (TPad*)gPad;
548 
549  if (!IsBatch()) { //normal mode with a screen window
550  // Set default physical canvas attributes
551  //Should be done via gVirtualX, not via fPainter (at least now). No changes here.
552  gVirtualX->SelectWindow(fCanvasID);
553  gVirtualX->SetFillColor(1); //Set color index for fill area
554  gVirtualX->SetLineColor(1); //Set color index for lines
555  gVirtualX->SetMarkerColor(1); //Set color index for markers
556  gVirtualX->SetTextColor(1); //Set color index for text
557  // Clear workstation
558  gVirtualX->ClearWindow();
559 
560  // Set Double Buffer on by default
561  SetDoubleBuffer(1);
562 
563  // Get effective window parameters (with borders and menubar)
564  fCanvasImp->GetWindowGeometry(fWindowTopX, fWindowTopY,
565  fWindowWidth, fWindowHeight);
566 
567  // Get effective canvas parameters without borders
568  Int_t dum1, dum2;
569  gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
570 
571  fContextMenu = new TContextMenu("ContextMenu");
572  } else {
573  // Make sure that batch interactive canvas sizes are the same
574  fCw -= 4;
575  fCh -= 28;
576  }
577  gROOT->GetListOfCanvases()->Add(this);
578 
579  if (!fPrimitives) {
580  fPrimitives = new TList;
582  SetFillStyle(1001);
594  fBorderMode=gStyle->GetCanvasBorderMode(); // do not call SetBorderMode (function redefined in TCanvas)
595  SetPad(0, 0, 1, 1);
596  Range(0, 0, 1, 1); //pad range is set by default to [0,1] in x and y
597 
599  if (vpp) vpp->SelectDrawable(fPixmapID);//gVirtualX->SelectPixmap(fPixmapID); //pixmap must be selected
600  PaintBorder(GetFillColor(), kTRUE); //paint background
601  }
602 
603  // transient canvases have typically no menubar and should not get
604  // by default the event status bar (if set by default)
605  if (TestBit(kMenuBar) && fCanvasImp) {
607  // ... and toolbar + editor
611  }
612 }
613 
614 ////////////////////////////////////////////////////////////////////////////////
615 /// Canvas destructor
616 
618 {
619  Destructor();
620 }
621 
622 ////////////////////////////////////////////////////////////////////////////////
623 /// Browse.
624 
626 {
627  Draw();
628  cd();
629  if (fgIsFolder) fPrimitives->Browse(b);
630 }
631 
632 ////////////////////////////////////////////////////////////////////////////////
633 /// Actual canvas destructor.
634 
636 {
637  if (gThreadXAR) {
638  void *arr[2];
639  arr[1] = this;
640  if ((*gThreadXAR)("CDEL", 2, arr, 0)) return;
641  }
642 
643  if (!TestBit(kNotDeleted)) return;
644 
645  if (fContextMenu) { delete fContextMenu; fContextMenu = 0; }
646  if (!gPad) return;
647 
648  Close();
649 
650  //If not yet (batch mode?).
651  delete fPainter;
652 }
653 
654 ////////////////////////////////////////////////////////////////////////////////
655 /// Set current canvas & pad. Returns the new current pad,
656 /// or 0 in case of failure.
657 /// See TPad::cd() for an explanation of the parameter.
658 
660 {
661  if (fCanvasID == -1) return 0;
662 
663  TPad::cd(subpadnumber);
664 
665  // in case doublebuffer is off, draw directly onto display window
666  if (!IsBatch()) {
667  if (!fDoubleBuffer)
668  gVirtualX->SelectWindow(fCanvasID);//Ok, does not matter for glpad.
669  }
670  return gPad;
671 }
672 
673 ////////////////////////////////////////////////////////////////////////////////
674 /// Remove all primitives from the canvas.
675 /// If option "D" is specified, direct sub-pads are cleared but not deleted.
676 /// This option is not recursive, i.e. pads in direct sub-pads are deleted.
677 
679 {
680  if (fCanvasID == -1) return;
681 
683 
684  TString opt = option;
685  opt.ToLower();
686  if (opt.Contains("d")) {
687  // clear subpads, but do not delete pads in case the canvas
688  // has been divided (note: option "D" is propagated so could cause
689  // conflicts for primitives using option "D" for something else)
690  if (fPrimitives) {
692  TObject *obj;
693  while ((obj=next())) {
694  obj->Clear(option);
695  }
696  }
697  } else {
698  //default, clear everything in the canvas. Subpads are deleted
699  TPad::Clear(option); //Remove primitives from pad
700  }
701 
702  fSelected = 0;
703  fClickSelected = 0;
704  fSelectedPad = 0;
705  fClickSelectedPad = 0;
706 }
707 
708 ////////////////////////////////////////////////////////////////////////////////
709 /// Emit pad Cleared signal.
710 
712 {
713  Emit("Cleared(TVirtualPad*)", (Long_t)pad);
714 }
715 
716 ////////////////////////////////////////////////////////////////////////////////
717 /// Emit Closed signal.
718 
720 {
721  Emit("Closed()");
722 }
723 
724 ////////////////////////////////////////////////////////////////////////////////
725 /// Close canvas.
726 ///
727 /// Delete window/pads data structure
728 
730 {
731  TPad *padsave = (TPad*)gPad;
732  TCanvas *cansave = 0;
733  if (padsave) cansave = (TCanvas*)gPad->GetCanvas();
734 
735  if (fCanvasID != -1) {
736 
737  if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
738  gInterpreter->Execute(this, IsA(), "Close", option);
739  return;
740  }
741 
743 
745 
746  cd();
747  TPad::Close(option);
748 
749  if (!IsBatch()) {
750  gVirtualX->SelectWindow(fCanvasID); //select current canvas
751 
753 
754  if (fCanvasImp) fCanvasImp->Close();
755  }
756  fCanvasID = -1;
757  fBatch = kTRUE;
758 
759  gROOT->GetListOfCanvases()->Remove(this);
760 
761  // Close actual window on screen
763  }
764 
765  if (cansave == this) {
766  gPad = (TCanvas *) gROOT->GetListOfCanvases()->First();
767  } else {
768  gPad = padsave;
769  }
770 
771  Closed();
772 }
773 
774 ////////////////////////////////////////////////////////////////////////////////
775 /// Copy the canvas pixmap of the pad to the canvas.
776 
778 {
779  if (!IsBatch()) {
780  CopyPixmap();
782  }
783 }
784 
785 ////////////////////////////////////////////////////////////////////////////////
786 /// Draw a canvas.
787 /// If a canvas with the name is already on the screen, the canvas is repainted.
788 /// This function is useful when a canvas object has been saved in a Root file.
789 /// One can then do:
790 /// ~~~ {.cpp}
791 /// Root > Tfile f("file.root");
792 /// Root > canvas.Draw();
793 /// ~~~
794 
796 {
797  // Load and initialize graphics libraries if
798  // TApplication::NeedGraphicsLibs() has been called by a
799  // library static initializer.
800  if (gApplication)
802 
803  fDrawn = kTRUE;
804 
805  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(GetName());
806  if (old == this) {
807  Paint();
808  return;
809  }
810  if (old) { gROOT->GetListOfCanvases()->Remove(old); delete old;}
811 
812  if (fWindowWidth == 0) {
813  if (fCw !=0) fWindowWidth = fCw+4;
814  else fWindowWidth = 800;
815  }
816  if (fWindowHeight == 0) {
817  if (fCh !=0) fWindowHeight = fCh+28;
818  else fWindowHeight = 600;
819  }
820  if (gROOT->IsBatch()) { //We are in Batch mode
822  if (!fCanvasImp) return;
823  fBatch = kTRUE;
824 
825  } else { //normal mode with a screen window
826  fCanvasImp = gGuiFactory->CreateCanvasImp(this, GetName(), fWindowTopX, fWindowTopY,
827  fWindowWidth, fWindowHeight);
828  if (!fCanvasImp) return;
830  }
831  Build();
832  ResizePad();
833  fCanvasImp->Show();
834  Modified();
835 }
836 
837 ////////////////////////////////////////////////////////////////////////////////
838 /// Draw a clone of this canvas
839 /// A new canvas is created that is a clone of this canvas
840 
842 {
843  const char *defcanvas = gROOT->GetDefCanvasName();
844  char *cdef;
845 
846  TList *lc = (TList*)gROOT->GetListOfCanvases();
847  if (lc->FindObject(defcanvas))
848  cdef = Form("%s_n%d",defcanvas,lc->GetSize()+1);
849  else
850  cdef = Form("%s",defcanvas);
851 
852  TCanvas *newCanvas = (TCanvas*)Clone();
853  newCanvas->SetName(cdef);
854 
855  newCanvas->Draw(option);
856  newCanvas->Update();
857  return newCanvas;
858 }
859 
860 ////////////////////////////////////////////////////////////////////////////////
861 /// Draw a clone of this canvas into the current pad
862 /// In an interactive session, select the destination/current pad
863 /// with the middle mouse button, then point to the canvas area to select
864 /// the canvas context menu item DrawClonePad.
865 /// Note that the original canvas may have subpads.
866 
868 {
869  TPad *padsav = (TPad*)gPad;
870  TPad *selpad = (TPad*)gROOT->GetSelectedPad();
871  TPad *pad = padsav;
872  if (pad == this) pad = selpad;
873  if (padsav == 0 || pad == 0 || pad == this) {
874  TCanvas *newCanvas = (TCanvas*)DrawClone();
876  return newCanvas;
877  }
878  if (fCanvasID == -1) {
879  fCanvasImp = gGuiFactory->CreateCanvasImp(this, GetName(), fWindowTopX, fWindowTopY,
880  fWindowWidth, fWindowHeight);
881  if (!fCanvasImp) return 0;
884  }
885  this->cd();
886  TObject *obj, *clone;
887  //copy pad attributes
888  pad->Range(fX1,fY1,fX2,fY2);
889  pad->SetTickx(GetTickx());
890  pad->SetTicky(GetTicky());
891  pad->SetGridx(GetGridx());
892  pad->SetGridy(GetGridy());
893  pad->SetLogx(GetLogx());
894  pad->SetLogy(GetLogy());
895  pad->SetLogz(GetLogz());
898  TAttLine::Copy((TAttLine&)*pad);
899  TAttFill::Copy((TAttFill&)*pad);
900  TAttPad::Copy((TAttPad&)*pad);
901 
902  //copy primitives
904  while ((obj=next())) {
905  pad->cd();
906  clone = obj->Clone();
907  pad->GetListOfPrimitives()->Add(clone,next.GetOption());
908  }
909  pad->ResizePad();
910  pad->Modified();
911  pad->Update();
912  if (padsav) padsav->cd();
913  return 0;
914 }
915 
916 ////////////////////////////////////////////////////////////////////////////////
917 /// Report name and title of primitive below the cursor.
918 ///
919 /// This function is called when the option "Event Status"
920 /// in the canvas menu "Options" is selected.
921 
922 void TCanvas::DrawEventStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
923 {
924  const Int_t kTMAX=256;
925  static char atext[kTMAX];
926 
927  if (!TestBit(kShowEventStatus) || !selected) return;
928 
929  if (!fCanvasImp) return; //this may happen when closing a TAttCanvas
930 
931  TVirtualPad* savepad;
932  savepad = gPad;
933  gPad = GetSelectedPad();
934 
935  fCanvasImp->SetStatusText(selected->GetTitle(),0);
936  fCanvasImp->SetStatusText(selected->GetName(),1);
937  if (event == kKeyPress)
938  snprintf(atext, kTMAX, "%c", (char) px);
939  else
940  snprintf(atext, kTMAX, "%d,%d", px, py);
941  fCanvasImp->SetStatusText(atext,2);
942  fCanvasImp->SetStatusText(selected->GetObjectInfo(px,py),3);
943  gPad = savepad;
944 }
945 
946 ////////////////////////////////////////////////////////////////////////////////
947 /// Get editor bar.
948 
950 {
952 }
953 
954 ////////////////////////////////////////////////////////////////////////////////
955 /// Embedded a canvas into a TRootEmbeddedCanvas. This method is only called
956 /// via TRootEmbeddedCanvas::AdoptCanvas.
957 
958 void TCanvas::EmbedInto(Int_t winid, Int_t ww, Int_t wh)
959 {
960  // If fCanvasImp already exists, no need to go further.
961  if(fCanvasImp) return;
962 
963  fCanvasID = winid;
964  fWindowTopX = 0;
965  fWindowTopY = 0;
966  fWindowWidth = ww;
967  fWindowHeight = wh;
968  fCw = ww;
969  fCh = wh;
970  fBatch = kFALSE;
971  fUpdating = kFALSE;
972 
973  fCanvasImp = gBatchGuiFactory->CreateCanvasImp(this, GetName(), fCw, fCh);
974  if (!fCanvasImp) return;
975  Build();
976  Resize();
977 }
978 
979 ////////////////////////////////////////////////////////////////////////////////
980 /// Generate kMouseEnter and kMouseLeave events depending on the previously
981 /// selected object and the currently selected object. Does nothing if the
982 /// selected object does not change.
983 
984 void TCanvas::EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
985 {
986  if (prevSelObj == fSelected) return;
987 
988  TPad *padsav = (TPad *)gPad;
989  Int_t sevent = fEvent;
990 
991  if (prevSelObj) {
992  gPad = prevSelPad;
993  prevSelObj->ExecuteEvent(kMouseLeave, fEventX, fEventY);
995  RunAutoExec();
996  ProcessedEvent(kMouseLeave, fEventX, fEventY, prevSelObj); // emit signal
997  }
998 
999  gPad = fSelectedPad;
1000 
1001  if (fSelected) {
1003  fEvent = kMouseEnter;
1004  RunAutoExec();
1005  ProcessedEvent(kMouseEnter, fEventX, fEventY, fSelected); // emit signal
1006  }
1007 
1008  fEvent = sevent;
1009  gPad = padsav;
1010 }
1011 
1012 ////////////////////////////////////////////////////////////////////////////////
1013 /// Execute action corresponding to one event.
1014 ///
1015 /// This member function must be implemented to realize the action
1016 /// corresponding to the mouse click on the object in the canvas
1017 ///
1018 /// Only handle mouse motion events in TCanvas, all other events are
1019 /// ignored for the time being
1020 
1022 {
1023  if (gROOT->GetEditorMode()) {
1024  TPad::ExecuteEvent(event,px,py);
1025  return;
1026  }
1027 
1028  switch (event) {
1029 
1030  case kMouseMotion:
1031  SetCursor(kCross);
1032  break;
1033  }
1034 }
1035 
1036 ////////////////////////////////////////////////////////////////////////////////
1037 /// Turn rubberband feedback mode on or off.
1038 
1040 {
1041  if (set) {
1042  SetDoubleBuffer(0); // turn off double buffer mode
1043  gVirtualX->SetDrawMode(TVirtualX::kInvert); // set the drawing mode to XOR mode
1044  } else {
1045  SetDoubleBuffer(1); // turn on double buffer mode
1046  gVirtualX->SetDrawMode(TVirtualX::kCopy); // set drawing mode back to normal (copy) mode
1047  }
1048 }
1049 
1050 ////////////////////////////////////////////////////////////////////////////////
1051 /// Flush canvas buffers.
1052 
1054 {
1055  if (fCanvasID == -1) return;
1056 
1057  TPad *padsav = (TPad*)gPad;
1058  cd();
1059  if (!IsBatch()) {
1060  if (!UseGL()) {
1061  gVirtualX->SelectWindow(fCanvasID);
1062  gPad = padsav; //don't do cd() because than also the pixmap is changed
1063  CopyPixmaps();
1064  gVirtualX->UpdateWindow(1);
1065  } else {
1066  TVirtualPS *tvps = gVirtualPS;
1067  gVirtualPS = 0;
1068  gGLManager->MakeCurrent(fGLDevice);
1069  fPainter->InitPainter();
1070  Paint();
1071  if (padsav && padsav->GetCanvas() == this) {
1072  padsav->cd();
1073  padsav->HighLight(padsav->GetHighLightColor());
1074  //cd();
1075  }
1076  fPainter->LockPainter();
1077  gGLManager->Flush(fGLDevice);
1078  gVirtualPS = tvps;
1079  }
1080  }
1081  if (padsav) padsav->cd();
1082 }
1083 
1084 ////////////////////////////////////////////////////////////////////////////////
1085 /// Force a copy of current style for all objects in canvas.
1086 
1088 {
1089  if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
1090  gInterpreter->Execute(this, IsA(), "UseCurrentStyle", "");
1091  return;
1092  }
1093 
1095 
1097 
1098  if (gStyle->IsReading()) {
1102  } else {
1106  }
1107 }
1108 
1109 ////////////////////////////////////////////////////////////////////////////////
1110 /// Returns current top x position of window on screen.
1111 
1113 {
1114  if (fCanvasImp) fCanvasImp->GetWindowGeometry(fWindowTopX, fWindowTopY,
1115  fWindowWidth,fWindowHeight);
1116 
1117  return fWindowTopX;
1118 }
1119 
1120 ////////////////////////////////////////////////////////////////////////////////
1121 /// Returns current top y position of window on screen.
1122 
1124 {
1125  if (fCanvasImp) fCanvasImp->GetWindowGeometry(fWindowTopX, fWindowTopY,
1126  fWindowWidth,fWindowHeight);
1127 
1128  return fWindowTopY;
1129 }
1130 
1131 ////////////////////////////////////////////////////////////////////////////////
1132 /// Handle Input Events.
1133 ///
1134 /// Handle input events, like button up/down in current canvas.
1135 
1137 {
1138  TPad *pad;
1139  TPad *prevSelPad = (TPad*) fSelectedPad;
1140  TObject *prevSelObj = fSelected;
1141 
1142  fPadSave = (TPad*)gPad;
1143  cd(); // make sure this canvas is the current canvas
1144 
1145  fEvent = event;
1146  fEventX = px;
1147  fEventY = py;
1148 
1149  switch (event) {
1150 
1151  case kMouseMotion:
1152  // highlight object tracked over
1153  pad = Pick(px, py, prevSelObj);
1154  if (!pad) return;
1155 
1156  EnterLeave(prevSelPad, prevSelObj);
1157 
1158  gPad = pad; // don't use cd() we will use the current
1159  // canvas via the GetCanvas member and not via
1160  // gPad->GetCanvas
1161 
1162  if (fSelected) {
1163  fSelected->ExecuteEvent(event, px, py);
1164  RunAutoExec();
1165  }
1166 
1167  break;
1168 
1169  case kMouseEnter:
1170  // mouse enters canvas
1171  if (!fDoubleBuffer) FeedbackMode(kTRUE);
1172  break;
1173 
1174  case kMouseLeave:
1175  // mouse leaves canvas
1176  {
1177  // force popdown of tooltips
1178  TObject *sobj = fSelected;
1179  TPad *spad = fSelectedPad;
1180  fSelected = 0;
1181  fSelectedPad = 0;
1182  EnterLeave(prevSelPad, prevSelObj);
1183  fSelected = sobj;
1184  fSelectedPad = spad;
1185  if (!fDoubleBuffer) FeedbackMode(kFALSE);
1186  }
1187  break;
1188 
1189  case kButton1Double:
1190  // triggered on the second button down within 350ms and within
1191  // 3x3 pixels of the first button down, button up finishes action
1192 
1193  case kButton1Down:
1194  // find pad in which input occurred
1195  pad = Pick(px, py, prevSelObj);
1196  if (!pad) return;
1197 
1198  gPad = pad; // don't use cd() because we won't draw in pad
1199  // we will only use its coordinate system
1200 
1201  if (fSelected) {
1202  FeedbackMode(kTRUE); // to draw in rubberband mode
1203  fSelected->ExecuteEvent(event, px, py);
1204 
1205  RunAutoExec();
1206  }
1207 
1208  break;
1209 
1210  case kArrowKeyPress:
1211  case kArrowKeyRelease:
1212  case kButton1Motion:
1213  case kButton1ShiftMotion: //8 == kButton1Motion + shift modifier
1214  if (fSelected) {
1215  gPad = fSelectedPad;
1216 
1217  fSelected->ExecuteEvent(event, px, py);
1218  gVirtualX->Update();
1219 
1220  if (!fSelected->InheritsFrom(TAxis::Class())) {
1221  Bool_t resize = kFALSE;
1223  resize = ((TBox*)fSelected)->IsBeingResized();
1225  resize = ((TVirtualPad*)fSelected)->IsBeingResized();
1226 
1227  if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) {
1228  gPad = fPadSave;
1229  Update();
1231  }
1232  }
1233 
1234  RunAutoExec();
1235  }
1236 
1237  break;
1238 
1239  case kButton1Up:
1240 
1241  if (fSelected) {
1242  gPad = fSelectedPad;
1243 
1244  fSelected->ExecuteEvent(event, px, py);
1245 
1246  RunAutoExec();
1247 
1248  if (fPadSave)
1249  gPad = fPadSave;
1250  else {
1251  gPad = this;
1252  fPadSave = this;
1253  }
1254 
1255  Update(); // before calling update make sure gPad is reset
1256  }
1257  break;
1258 
1259 //*-*----------------------------------------------------------------------
1260 
1261  case kButton2Down:
1262  // find pad in which input occurred
1263  pad = Pick(px, py, prevSelObj);
1264  if (!pad) return;
1265 
1266  gPad = pad; // don't use cd() because we won't draw in pad
1267  // we will only use its coordinate system
1268 
1270 
1271  if (fSelected) fSelected->Pop(); // pop object to foreground
1272  pad->cd(); // and make its pad the current pad
1273  if (gDebug)
1274  printf("Current Pad: %s / %s\n", pad->GetName(), pad->GetTitle());
1275 
1276  // loop over all canvases to make sure that only one pad is highlighted
1277  {
1278  TIter next(gROOT->GetListOfCanvases());
1279  TCanvas *tc;
1280  while ((tc = (TCanvas *)next()))
1281  tc->Update();
1282  }
1283 
1284  //if (pad->GetGLDevice() != -1 && fSelected)
1285  // fSelected->ExecuteEvent(event, px, py);
1286 
1287  break; // don't want fPadSave->cd() to be executed at the end
1288 
1289  case kButton2Motion:
1290  //was empty!
1291  case kButton2Up:
1292  if (fSelected) {
1293  gPad = fSelectedPad;
1294 
1295  fSelected->ExecuteEvent(event, px, py);
1296  RunAutoExec();
1297  }
1298  break;
1299 
1300  case kButton2Double:
1301  break;
1302 
1303 //*-*----------------------------------------------------------------------
1304 
1305  case kButton3Down:
1306  // popup context menu
1307  pad = Pick(px, py, prevSelObj);
1308  if (!pad) return;
1309 
1310  if (!fDoubleBuffer) FeedbackMode(kFALSE);
1311 
1314  fContextMenu->Popup(px, py, fSelected, this, pad);
1315 
1316  break;
1317 
1318  case kButton3Motion:
1319  break;
1320 
1321  case kButton3Up:
1322  if (!fDoubleBuffer) FeedbackMode(kTRUE);
1323  break;
1324 
1325  case kButton3Double:
1326  break;
1327 
1328  case kKeyPress:
1329  if (!fSelectedPad || !fSelected) return;
1330  gPad = fSelectedPad; // don't use cd() because we won't draw in pad
1331  // we will only use its coordinate system
1332  fSelected->ExecuteEvent(event, px, py);
1333 
1334  RunAutoExec();
1335 
1336  break;
1337 
1338  case kButton1Shift:
1339  // Try to select
1340  pad = Pick(px, py, prevSelObj);
1341 
1342  if (!pad) return;
1343 
1344  EnterLeave(prevSelPad, prevSelObj);
1345 
1346  gPad = pad; // don't use cd() we will use the current
1347  // canvas via the GetCanvas member and not via
1348  // gPad->GetCanvas
1349  if (fSelected) {
1350  fSelected->ExecuteEvent(event, px, py);
1351  RunAutoExec();
1352  }
1353  break;
1354 
1355  case kWheelUp:
1356  case kWheelDown:
1357  pad = Pick(px, py, prevSelObj);
1358  if (!pad) return;
1359 
1360  gPad = pad;
1361  if (fSelected)
1362  fSelected->ExecuteEvent(event, px, py);
1363  break;
1364 
1365  default:
1366  break;
1367  }
1368 
1369  if (fPadSave && event != kButton2Down)
1370  fPadSave->cd();
1371 
1372  if (event != kMouseLeave) { // signal was already emitted for this event
1373  ProcessedEvent(event, px, py, fSelected); // emit signal
1374  DrawEventStatus(event, px, py, fSelected);
1375  }
1376 }
1377 
1378 ////////////////////////////////////////////////////////////////////////////////
1379 /// Is folder ?
1380 
1382 {
1383  return fgIsFolder;
1384 }
1385 
1386 ////////////////////////////////////////////////////////////////////////////////
1387 /// List all pads.
1388 
1389 void TCanvas::ls(Option_t *option) const
1390 {
1392  std::cout <<"Canvas Name=" <<GetName()<<" Title="<<GetTitle()<<" Option="<<option<<std::endl;
1394  TPad::ls(option);
1396 }
1397 
1398 ////////////////////////////////////////////////////////////////////////////////
1399 /// Static function to build a default canvas.
1400 
1402 {
1403  const char *defcanvas = gROOT->GetDefCanvasName();
1404  char *cdef;
1405 
1406  TList *lc = (TList*)gROOT->GetListOfCanvases();
1407  if (lc->FindObject(defcanvas)) {
1408  Int_t n = lc->GetSize() + 1;
1409  cdef = new char[strlen(defcanvas)+15];
1410  do {
1411  strlcpy(cdef,Form("%s_n%d", defcanvas, n++),strlen(defcanvas)+15);
1412  } while (lc->FindObject(cdef));
1413  } else
1414  cdef = StrDup(Form("%s",defcanvas));
1415 
1416  TCanvas *c = new TCanvas(cdef, cdef, 1);
1417 
1418  ::Info("TCanvas::MakeDefCanvas"," created default TCanvas with name %s",cdef);
1419  delete [] cdef;
1420  return c;
1421 }
1422 
1423 ////////////////////////////////////////////////////////////////////////////////
1424 /// Set option to move objects/pads in a canvas.
1425 ///
1426 /// - set = 1 (default) graphics objects are moved in opaque mode
1427 /// - set = 0 only the outline of objects is drawn when moving them
1428 ///
1429 /// The option opaque produces the best effect. It requires however a
1430 /// a reasonably fast workstation or response time.
1431 
1433 {
1434  SetBit(kMoveOpaque,set);
1435 }
1436 
1437 ////////////////////////////////////////////////////////////////////////////////
1438 /// Paint canvas.
1439 
1441 {
1442  if (fCanvas) TPad::Paint(option);
1443 }
1444 
1445 ////////////////////////////////////////////////////////////////////////////////
1446 /// Prepare for pick, call TPad::Pick() and when selected object
1447 /// is different from previous then emit Picked() signal.
1448 
1449 TPad *TCanvas::Pick(Int_t px, Int_t py, TObject *prevSelObj)
1450 {
1451  TObjLink *pickobj = 0;
1452 
1453  fSelected = 0;
1454  fSelectedOpt = "";
1455  fSelectedPad = 0;
1456 
1457  TPad *pad = Pick(px, py, pickobj);
1458  if (!pad) return 0;
1459 
1460  if (!pickobj) {
1461  fSelected = pad;
1462  fSelectedOpt = "";
1463  } else {
1464  if (!fSelected) { // can be set via TCanvas::SetSelected()
1465  fSelected = pickobj->GetObject();
1466  fSelectedOpt = pickobj->GetOption();
1467  }
1468  }
1469  fSelectedPad = pad;
1470 
1471  if (fSelected != prevSelObj)
1472  Picked(fSelectedPad, fSelected, fEvent); // emit signal
1473 
1474  if ((fEvent == kButton1Down) || (fEvent == kButton2Down) || (fEvent == kButton3Down)) {
1478  Selected(fSelectedPad, fSelected, fEvent); // emit signal
1479  fSelectedX = px;
1480  fSelectedY = py;
1481  }
1482  }
1483  return pad;
1484 }
1485 
1486 ////////////////////////////////////////////////////////////////////////////////
1487 /// Emit Picked() signal.
1488 
1489 void TCanvas::Picked(TPad *pad, TObject *obj, Int_t event)
1490 {
1491  Long_t args[3];
1492 
1493  args[0] = (Long_t) pad;
1494  args[1] = (Long_t) obj;
1495  args[2] = event;
1496 
1497  Emit("Picked(TPad*,TObject*,Int_t)", args);
1498 }
1499 
1500 ////////////////////////////////////////////////////////////////////////////////
1501 /// Emit Selected() signal.
1502 
1504 {
1505  Long_t args[3];
1506 
1507  args[0] = (Long_t) pad;
1508  args[1] = (Long_t) obj;
1509  args[2] = event;
1510 
1511  Emit("Selected(TVirtualPad*,TObject*,Int_t)", args);
1512 }
1513 
1514 ////////////////////////////////////////////////////////////////////////////////
1515 /// Emit ProcessedEvent() signal.
1516 
1518 {
1519  Long_t args[4];
1520 
1521  args[0] = event;
1522  args[1] = x;
1523  args[2] = y;
1524  args[3] = (Long_t) obj;
1525 
1526  Emit("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", args);
1527 }
1528 
1529 ////////////////////////////////////////////////////////////////////////////////
1530 /// Recompute canvas parameters following a X11 Resize.
1531 
1533 {
1534  if (fCanvasID == -1) return;
1535 
1536  if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
1537  gInterpreter->Execute(this, IsA(), "Resize", "");
1538  return;
1539  }
1540 
1542 
1543  TPad *padsav = (TPad*)gPad;
1544  cd();
1545 
1546  if (!IsBatch()) {
1547  gVirtualX->SelectWindow(fCanvasID); //select current canvas
1548  gVirtualX->ResizeWindow(fCanvasID); //resize canvas and off-screen buffer
1549 
1550  // Get effective window parameters including menubar and borders
1551  fCanvasImp->GetWindowGeometry(fWindowTopX, fWindowTopY,
1552  fWindowWidth, fWindowHeight);
1553 
1554  // Get effective canvas parameters without borders
1555  Int_t dum1, dum2;
1556  gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
1557  }
1558 
1559  if (fXsizeUser && fYsizeUser) {
1560  UInt_t nwh = fCh;
1561  UInt_t nww = fCw;
1562  Double_t rxy = fXsizeUser/fYsizeUser;
1563  if (rxy < 1) {
1564  UInt_t twh = UInt_t(Double_t(fCw)/rxy);
1565  if (twh > fCh)
1566  nww = UInt_t(Double_t(fCh)*rxy);
1567  else
1568  nwh = twh;
1569  if (nww > fCw) {
1570  nww = fCw; nwh = twh;
1571  }
1572  if (nwh > fCh) {
1573  nwh = fCh; nww = UInt_t(Double_t(fCh)/rxy);
1574  }
1575  } else {
1576  UInt_t twh = UInt_t(Double_t(fCw)*rxy);
1577  if (twh > fCh)
1578  nwh = UInt_t(Double_t(fCw)/rxy);
1579  else
1580  nww = twh;
1581  if (nww > fCw) {
1582  nww = fCw; nwh = twh;
1583  }
1584  if (nwh > fCh) {
1585  nwh = fCh; nww = UInt_t(Double_t(fCh)*rxy);
1586  }
1587  }
1588  fCw = nww;
1589  fCh = nwh;
1590  }
1591 
1592  if (fCw < fCh) {
1593  fYsizeReal = kDefaultCanvasSize;
1594  fXsizeReal = fYsizeReal*Double_t(fCw)/Double_t(fCh);
1595  }
1596  else {
1597  fXsizeReal = kDefaultCanvasSize;
1598  fYsizeReal = fXsizeReal*Double_t(fCh)/Double_t(fCw);
1599  }
1600 
1601 //*-*- Loop on all pads to recompute conversion coefficients
1602  TPad::ResizePad();
1603 
1604  if (padsav) padsav->cd();
1605 }
1606 
1607 ////////////////////////////////////////////////////////////////////////////////
1608 /// Set option to resize objects/pads in a canvas.
1609 ///
1610 /// - set = 1 (default) graphics objects are resized in opaque mode
1611 /// - set = 0 only the outline of objects is drawn when resizing them
1612 ///
1613 /// The option opaque produces the best effect. It requires however a
1614 /// a reasonably fast workstation or response time.
1615 
1617 {
1618  SetBit(kResizeOpaque,set);
1619 }
1620 
1621 ////////////////////////////////////////////////////////////////////////////////
1622 /// Execute the list of TExecs in the current pad.
1623 
1625 {
1626  if (!TestBit(kAutoExec)) return;
1627  if (!gPad) return;
1628  ((TPad*)gPad)->AutoExec();
1629 }
1630 
1631 
1632 ////////////////////////////////////////////////////////////////////////////////
1633 /// Save primitives in this canvas in C++ macro file with GUI.
1634 
1635 void TCanvas::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1636 {
1637  // Write canvas options (in $TROOT or $TStyle)
1638  if (gStyle->GetOptFit()) {
1639  out<<" gStyle->SetOptFit(1);"<<std::endl;
1640  }
1641  if (!gStyle->GetOptStat()) {
1642  out<<" gStyle->SetOptStat(0);"<<std::endl;
1643  }
1644  if (!gStyle->GetOptTitle()) {
1645  out<<" gStyle->SetOptTitle(0);"<<std::endl;
1646  }
1647  if (gROOT->GetEditHistograms()) {
1648  out<<" gROOT->SetEditHistograms();"<<std::endl;
1649  }
1650  if (GetShowEventStatus()) {
1651  out<<" "<<GetName()<<"->ToggleEventStatus();"<<std::endl;
1652  }
1653  if (GetShowToolTips()) {
1654  out<<" "<<GetName()<<"->ToggleToolTips();"<<std::endl;
1655  }
1656  if (GetShowToolBar()) {
1657  out<<" "<<GetName()<<"->ToggleToolBar();"<<std::endl;
1658  }
1659  if (GetHighLightColor() != 5) {
1660  if (GetHighLightColor() > 228) {
1662  out<<" "<<GetName()<<"->SetHighLightColor(ci);" << std::endl;
1663  } else
1664  out<<" "<<GetName()<<"->SetHighLightColor("<<GetHighLightColor()<<");"<<std::endl;
1665  }
1666 
1667  // Now recursively scan all pads of this canvas
1668  cd();
1669  TPad::SavePrimitive(out,option);
1670 }
1671 
1672 ////////////////////////////////////////////////////////////////////////////////
1673 /// Save primitives in this canvas as a C++ macro file.
1674 /// This function loops on all the canvas primitives and for each primitive
1675 /// calls the object SavePrimitive function.
1676 /// When outputting floating point numbers, the default precision is 7 digits.
1677 /// The precision can be changed (via system.rootrc) by changing the value
1678 /// of the environment variable "Canvas.SavePrecision"
1679 
1680 void TCanvas::SaveSource(const char *filename, Option_t *option)
1681 {
1682  // reset bit TClass::kClassSaved for all classes
1683  TIter next(gROOT->GetListOfClasses());
1684  TClass *cl;
1685  while((cl = (TClass*)next())) {
1687  }
1688 
1689  char quote = '"';
1690  std::ofstream out;
1691  Int_t lenfile = strlen(filename);
1692  char * fname;
1693  char lcname[10];
1694  const char *cname = GetName();
1695  Bool_t invalid = kFALSE;
1696  // if filename is given, open this file, otherwise create a file
1697  // with a name equal to the canvasname.C
1698  if (lenfile) {
1699  fname = (char*)filename;
1700  out.open(fname, std::ios::out);
1701  } else {
1702  Int_t nch = strlen(cname);
1703  if (nch < 10) {
1704  strlcpy(lcname,cname,10);
1705  for (Int_t k=1;k<=nch;k++) {if (lcname[nch-k] == ' ') lcname[nch-k] = 0;}
1706  if (lcname[0] == 0) {invalid = kTRUE; strlcpy(lcname,"c1",10); nch = 2;}
1707  cname = lcname;
1708  }
1709  fname = new char[nch+3];
1710  strlcpy(fname,cname,nch+3);
1711  strncat(fname,".C",2);
1712  out.open(fname, std::ios::out);
1713  }
1714  if (!out.good ()) {
1715  Error("SaveSource", "Cannot open file: %s",fname);
1716  if (!lenfile) delete [] fname;
1717  return;
1718  }
1719 
1720  //set precision
1721  Int_t precision = gEnv->GetValue("Canvas.SavePrecision",7);
1722  out.precision(precision);
1723 
1724  // Write macro header and date/time stamp
1725  TDatime t;
1726  Float_t cx = gStyle->GetScreenFactor();
1727  Int_t topx,topy;
1728  UInt_t w, h;
1729  if (!fCanvasImp) {
1730  Error("SaveSource", "Cannot open TCanvas");
1731  return;
1732  }
1733  UInt_t editorWidth = fCanvasImp->GetWindowGeometry(topx,topy,w,h);
1734  w = UInt_t((fWindowWidth - editorWidth)/cx);
1735  h = UInt_t((fWindowHeight)/cx);
1736  topx = GetWindowTopX();
1737  topy = GetWindowTopY();
1738 
1739  if (w == 0) {
1740  w = GetWw()+4; h = GetWh()+4;
1741  topx = 1; topy = 1;
1742  }
1743 
1744  TString mname(fname);
1745  Int_t p = mname.Last('.');
1746  Int_t s = mname.Last('/')+1;
1747  out <<"void " << mname(s,p-s) << "()" <<std::endl;
1748  out <<"{"<<std::endl;
1749  out <<"//=========Macro generated from canvas: "<<GetName()<<"/"<<GetTitle()<<std::endl;
1750  out <<"//========= ("<<t.AsString()<<") by ROOT version"<<gROOT->GetVersion()<<std::endl;
1751 
1752  if (gStyle->GetCanvasPreferGL())
1753  out <<std::endl<<" gStyle->SetCanvasPreferGL(kTRUE);"<<std::endl<<std::endl;
1754 
1755  // Write canvas parameters (TDialogCanvas case)
1757  out<<" "<<ClassName()<<" *"<<cname<<" = new "<<ClassName()<<"("<<quote<<GetName()
1758  <<quote<<", "<<quote<<GetTitle()<<quote<<","<<w<<","<<h<<");"<<std::endl;
1759  } else {
1760  // Write canvas parameters (TCanvas case)
1761  out<<" TCanvas *"<<cname<<" = new TCanvas("<<quote<<GetName()<<quote<<", "<<quote<<GetTitle()
1762  <<quote;
1763  if (!HasMenuBar())
1764  out<<",-"<<topx<<","<<topy<<","<<w<<","<<h<<");"<<std::endl;
1765  else
1766  out<<","<<topx<<","<<topy<<","<<w<<","<<h<<");"<<std::endl;
1767  }
1768  // Write canvas options (in $TROOT or $TStyle)
1769  if (gStyle->GetOptFit()) {
1770  out<<" gStyle->SetOptFit(1);"<<std::endl;
1771  }
1772  if (!gStyle->GetOptStat()) {
1773  out<<" gStyle->SetOptStat(0);"<<std::endl;
1774  }
1775  if (!gStyle->GetOptTitle()) {
1776  out<<" gStyle->SetOptTitle(0);"<<std::endl;
1777  }
1778  if (gROOT->GetEditHistograms()) {
1779  out<<" gROOT->SetEditHistograms();"<<std::endl;
1780  }
1781  if (GetShowEventStatus()) {
1782  out<<" "<<GetName()<<"->ToggleEventStatus();"<<std::endl;
1783  }
1784  if (GetShowToolTips()) {
1785  out<<" "<<GetName()<<"->ToggleToolTips();"<<std::endl;
1786  }
1787  if (GetHighLightColor() != 5) {
1788  if (GetHighLightColor() > 228) {
1790  out<<" "<<GetName()<<"->SetHighLightColor(ci);" << std::endl;
1791  } else
1792  out<<" "<<GetName()<<"->SetHighLightColor("<<GetHighLightColor()<<");"<<std::endl;
1793  }
1794 
1795  // Now recursively scan all pads of this canvas
1796  cd();
1797  if (invalid) SetName("c1");
1798  TPad::SavePrimitive(out,option);
1799  // Write canvas options related to pad editor
1800  out<<" "<<GetName()<<"->SetSelected("<<GetName()<<");"<<std::endl;
1801  if (GetShowToolBar()) {
1802  out<<" "<<GetName()<<"->ToggleToolBar();"<<std::endl;
1803  }
1804  if (invalid) SetName(" ");
1805 
1806  out <<"}"<<std::endl;
1807  out.close();
1808  Info("SaveSource","C++ Macro file: %s has been generated", fname);
1809 
1810  // reset bit TClass::kClassSaved for all classes
1811  next.Reset();
1812  while((cl = (TClass*)next())) {
1814  }
1815  if (!lenfile) delete [] fname;
1816 }
1817 
1818 ////////////////////////////////////////////////////////////////////////////////
1819 /// Toggle batch mode. However, if the canvas is created without a window
1820 /// then batch mode always stays set.
1821 
1823 {
1824  if (gROOT->IsBatch())
1825  fBatch = kTRUE;
1826  else
1827  fBatch = batch;
1828 }
1829 
1830 ////////////////////////////////////////////////////////////////////////////////
1831 /// Set Width and Height of canvas to ww and wh respectively. If ww and/or wh
1832 /// are greater than the current canvas window a scroll bar is automatically
1833 /// generated. Use this function to zoom in a canvas and navigate via
1834 /// the scroll bars. The Width and Height in this method are different from those
1835 /// given in the TCanvas constructors where these two dimension include the size
1836 /// of the window decoration whereas they do not in this method.
1837 
1839 {
1840  if (fCanvasImp) {
1841  fCanvasImp->SetCanvasSize(ww, wh);
1842  fCw = ww;
1843  fCh = wh;
1844  ResizePad();
1845  }
1846 }
1847 
1848 ////////////////////////////////////////////////////////////////////////////////
1849 /// Set cursor.
1850 
1852 {
1853  if (IsBatch()) return;
1854  gVirtualX->SetCursor(fCanvasID, cursor);
1855 }
1856 
1857 ////////////////////////////////////////////////////////////////////////////////
1858 /// Set Double Buffer On/Off.
1859 
1861 {
1862  if (IsBatch()) return;
1863  fDoubleBuffer = mode;
1864  gVirtualX->SetDoubleBuffer(fCanvasID, mode);
1865 
1866  // depending of the buffer mode set the drawing window to either
1867  // the canvas pixmap or to the canvas on-screen window
1868  if (fDoubleBuffer) {
1870  } else
1872 }
1873 
1874 ////////////////////////////////////////////////////////////////////////////////
1875 /// Fix canvas aspect ratio to current value if fixed is true.
1876 
1878 {
1879  if (fixed) {
1880  if (!fFixedAspectRatio) {
1881  if (fCh != 0)
1882  fAspectRatio = Double_t(fCw) / fCh;
1883  else {
1884  Error("SetAspectRatio", "cannot fix aspect ratio, height of canvas is 0");
1885  return;
1886  }
1888  }
1889  } else {
1891  fAspectRatio = 0;
1892  }
1893 }
1894 
1895 ////////////////////////////////////////////////////////////////////////////////
1896 /// If isfolder=kTRUE, the canvas can be browsed like a folder
1897 /// by default a canvas is not browsable.
1898 
1900 {
1901  fgIsFolder = isfolder;
1902 }
1903 
1904 ////////////////////////////////////////////////////////////////////////////////
1905 /// Set selected canvas.
1906 
1908 {
1909  fSelected = obj;
1910  if (obj) obj->SetBit(kMustCleanup);
1911 }
1912 
1913 ////////////////////////////////////////////////////////////////////////////////
1914 /// Set canvas title.
1915 
1916 void TCanvas::SetTitle(const char *title)
1917 {
1918  fTitle = title;
1919  if (fCanvasImp) fCanvasImp->SetWindowTitle(title);
1920 }
1921 
1922 ////////////////////////////////////////////////////////////////////////////////
1923 /// Set the canvas scale in centimeters.
1924 ///
1925 /// This information is used by PostScript to set the page size.
1926 ///
1927 /// \param[in] xsize size of the canvas in centimeters along X
1928 /// \param[in] ysize size of the canvas in centimeters along Y
1929 ///
1930 /// if xsize and ysize are not equal to 0, then the scale factors will
1931 /// be computed to keep the ratio ysize/xsize independently of the canvas
1932 /// size (parts of the physical canvas will be unused).
1933 ///
1934 /// if xsize = 0 and ysize is not zero, then xsize will be computed
1935 /// to fit to the current canvas scale. If the canvas is resized,
1936 /// a new value for xsize will be recomputed. In this case the aspect
1937 /// ratio is not preserved.
1938 ///
1939 /// if both xsize = 0 and ysize = 0, then the scaling is automatic.
1940 /// the largest dimension will be allocated a size of 20 centimeters.
1941 
1942 void TCanvas::Size(Float_t xsize, Float_t ysize)
1943 {
1944  fXsizeUser = xsize;
1945  fYsizeUser = ysize;
1946 
1947  Resize();
1948 }
1949 
1950 ////////////////////////////////////////////////////////////////////////////////
1951 /// Stream a class object.
1952 
1953 void TCanvas::Streamer(TBuffer &b)
1954 {
1955  UInt_t R__s, R__c;
1956  if (b.IsReading()) {
1957  Version_t v = b.ReadVersion(&R__s, &R__c);
1958  gPad = this;
1959  fCanvas = this;
1960  if (v>7) b.ClassBegin(TCanvas::IsA());
1961  if (v>7) b.ClassMember("TPad");
1962  TPad::Streamer(b);
1963  gPad = this;
1964  //restore the colors
1965  TObjArray *colors = (TObjArray*)fPrimitives->FindObject("ListOfColors");
1966  if (colors) {
1967  TIter next(colors);
1968  TColor *colold;
1969  while ((colold = (TColor*)next())) {
1970  if (colold) {
1971  Int_t cn = 0;
1972  if (colold) cn = colold->GetNumber();
1973  TColor *colcur = gROOT->GetColor(cn);
1974  if (colcur) {
1975  colcur->SetRGB(colold->GetRed(),colold->GetGreen(),colold->GetBlue());
1976  } else {
1977  colcur = new TColor(cn,colold->GetRed(),
1978  colold->GetGreen(),
1979  colold->GetBlue(),
1980  colold->GetName());
1981  if (!colcur) return;
1982  }
1983  }
1984  }
1985  fPrimitives->Remove(colors);
1986  colors->Delete();
1987  delete colors;
1988  }
1989  if (v>7) b.ClassMember("fDISPLAY","TString");
1990  fDISPLAY.Streamer(b);
1991  if (v>7) b.ClassMember("fDoubleBuffer", "Int_t");
1992  b >> fDoubleBuffer;
1993  if (v>7) b.ClassMember("fRetained", "Bool_t");
1994  b >> fRetained;
1995  if (v>7) b.ClassMember("fXsizeUser", "Size_t");
1996  b >> fXsizeUser;
1997  if (v>7) b.ClassMember("fYsizeUser", "Size_t");
1998  b >> fYsizeUser;
1999  if (v>7) b.ClassMember("fXsizeReal", "Size_t");
2000  b >> fXsizeReal;
2001  if (v>7) b.ClassMember("fYsizeReal", "Size_t");
2002  b >> fYsizeReal;
2003  fCanvasID = -1;
2004  if (v>7) b.ClassMember("fWindowTopX", "Int_t");
2005  b >> fWindowTopX;
2006  if (v>7) b.ClassMember("fWindowTopY", "Int_t");
2007  b >> fWindowTopY;
2008  if (v > 2) {
2009  if (v>7) b.ClassMember("fWindowWidth", "UInt_t");
2010  b >> fWindowWidth;
2011  if (v>7) b.ClassMember("fWindowHeight", "UInt_t");
2012  b >> fWindowHeight;
2013  }
2014  if (v>7) b.ClassMember("fCw", "UInt_t");
2015  b >> fCw;
2016  if (v>7) b.ClassMember("fCh", "UInt_t");
2017  b >> fCh;
2018  if (v <= 2) {
2019  fWindowWidth = fCw;
2020  fWindowHeight = fCh;
2021  }
2022  if (v>7) b.ClassMember("fCatt", "TAttCanvas");
2023  fCatt.Streamer(b);
2024  Bool_t dummy;
2025  if (v>7) b.ClassMember("kMoveOpaque", "Bool_t");
2026  b >> dummy; if (dummy) MoveOpaque(1);
2027  if (v>7) b.ClassMember("kResizeOpaque", "Bool_t");
2028  b >> dummy; if (dummy) ResizeOpaque(1);
2029  if (v>7) b.ClassMember("fHighLightColor", "Color_t");
2030  b >> fHighLightColor;
2031  if (v>7) b.ClassMember("fBatch", "Bool_t");
2032  b >> dummy; //was fBatch
2033  if (v < 2) return;
2034  if (v>7) b.ClassMember("kShowEventStatus", "Bool_t");
2035  b >> dummy; if (dummy) SetBit(kShowEventStatus);
2036 
2037  if (v > 3) {
2038  if (v>7) b.ClassMember("kAutoExec", "Bool_t");
2039  b >> dummy; if (dummy) SetBit(kAutoExec);
2040  }
2041  if (v>7) b.ClassMember("kMenuBar", "Bool_t");
2042  b >> dummy; if (dummy) SetBit(kMenuBar);
2043  fBatch = gROOT->IsBatch();
2044  if (v>7) b.ClassEnd(TCanvas::IsA());
2045  b.CheckByteCount(R__s, R__c, TCanvas::IsA());
2046  } else {
2047  //save list of colors
2048  //we must protect the case when two or more canvases are saved
2049  //in the same buffer. If the list of colors has already been saved
2050  //in the buffer, do not add the list of colors to the list of primitives.
2051  TObjArray *colors = 0;
2052  if (!b.CheckObject(gROOT->GetListOfColors(),TObjArray::Class())) {
2053  colors = (TObjArray*)gROOT->GetListOfColors();
2054  fPrimitives->Add(colors);
2055  }
2056  R__c = b.WriteVersion(TCanvas::IsA(), kTRUE);
2057  b.ClassBegin(TCanvas::IsA());
2058  b.ClassMember("TPad");
2059  TPad::Streamer(b);
2060  if(colors) fPrimitives->Remove(colors);
2061  b.ClassMember("fDISPLAY","TString");
2062  fDISPLAY.Streamer(b);
2063  b.ClassMember("fDoubleBuffer", "Int_t");
2064  b << fDoubleBuffer;
2065  b.ClassMember("fRetained", "Bool_t");
2066  b << fRetained;
2067  b.ClassMember("fXsizeUser", "Size_t");
2068  b << fXsizeUser;
2069  b.ClassMember("fYsizeUser", "Size_t");
2070  b << fYsizeUser;
2071  b.ClassMember("fXsizeReal", "Size_t");
2072  b << fXsizeReal;
2073  b.ClassMember("fYsizeReal", "Size_t");
2074  b << fYsizeReal;
2076  Int_t topx = fWindowTopX, topy = fWindowTopY;
2077  UInt_t editorWidth = 0;
2078  if(fCanvasImp) editorWidth = fCanvasImp->GetWindowGeometry(topx,topy,w,h);
2079  b.ClassMember("fWindowTopX", "Int_t");
2080  b << topx;
2081  b.ClassMember("fWindowTopY", "Int_t");
2082  b << topy;
2083  b.ClassMember("fWindowWidth", "UInt_t");
2084  b << (UInt_t)(w-editorWidth);
2085  b.ClassMember("fWindowHeight", "UInt_t");
2086  b << h;
2087  b.ClassMember("fCw", "UInt_t");
2088  b << fCw;
2089  b.ClassMember("fCh", "UInt_t");
2090  b << fCh;
2091  b.ClassMember("fCatt", "TAttCanvas");
2092  fCatt.Streamer(b);
2093  b.ClassMember("kMoveOpaque", "Bool_t");
2094  b << TestBit(kMoveOpaque); //please remove in ROOT version 6
2095  b.ClassMember("kResizeOpaque", "Bool_t");
2096  b << TestBit(kResizeOpaque); //please remove in ROOT version 6
2097  b.ClassMember("fHighLightColor", "Color_t");
2098  b << fHighLightColor;
2099  b.ClassMember("fBatch", "Bool_t");
2100  b << fBatch; //please remove in ROOT version 6
2101  b.ClassMember("kShowEventStatus", "Bool_t");
2102  b << TestBit(kShowEventStatus); //please remove in ROOT version 6
2103  b.ClassMember("kAutoExec", "Bool_t");
2104  b << TestBit(kAutoExec); //please remove in ROOT version 6
2105  b.ClassMember("kMenuBar", "Bool_t");
2106  b << TestBit(kMenuBar); //please remove in ROOT version 6
2107  b.ClassEnd(TCanvas::IsA());
2108  b.SetByteCount(R__c, kTRUE);
2109  }
2110 }
2111 
2112 ////////////////////////////////////////////////////////////////////////////////
2113 /// Toggle pad auto execution of list of TExecs.
2114 
2116 {
2117  Bool_t autoExec = TestBit(kAutoExec);
2118  SetBit(kAutoExec,!autoExec);
2119 }
2120 
2121 ////////////////////////////////////////////////////////////////////////////////
2122 /// Toggle event statusbar.
2123 
2125 {
2126  Bool_t showEventStatus = !TestBit(kShowEventStatus);
2127  SetBit(kShowEventStatus,showEventStatus);
2128 
2129  if (fCanvasImp) fCanvasImp->ShowStatusBar(showEventStatus);
2130 }
2131 
2132 ////////////////////////////////////////////////////////////////////////////////
2133 /// Toggle toolbar.
2134 
2136 {
2137  Bool_t showToolBar = !TestBit(kShowToolBar);
2138  SetBit(kShowToolBar,showToolBar);
2139 
2140  if (fCanvasImp) fCanvasImp->ShowToolBar(showToolBar);
2141 }
2142 
2143 ////////////////////////////////////////////////////////////////////////////////
2144 /// Toggle editor.
2145 
2147 {
2148  Bool_t showEditor = !TestBit(kShowEditor);
2149  SetBit(kShowEditor,showEditor);
2150 
2151  if (fCanvasImp) fCanvasImp->ShowEditor(showEditor);
2152 }
2153 
2154 ////////////////////////////////////////////////////////////////////////////////
2155 /// Toggle tooltip display.
2156 
2158 {
2159  Bool_t showToolTips = !TestBit(kShowToolTips);
2160  SetBit(kShowToolTips, showToolTips);
2161 
2162  if (fCanvasImp) fCanvasImp->ShowToolTips(showToolTips);
2163 }
2164 
2165 
2166 ////////////////////////////////////////////////////////////////////////////////
2167 /// Static function returning "true" if transparency is supported.
2168 
2170 {
2171  return gPad && (gVirtualX->InheritsFrom("TGQuartz") ||
2172  gPad->GetGLDevice() != -1);
2173 }
2174 
2175 
2176 ////////////////////////////////////////////////////////////////////////////////
2177 /// Update canvas pad buffers.
2178 
2180 {
2181  if (fUpdating) return;
2182 
2183  if (fPixmapID == -1) return;
2184 
2185  if (gThreadXAR) {
2186  void *arr[2];
2187  arr[1] = this;
2188  if ((*gThreadXAR)("CUPD", 2, arr, 0)) return;
2189  }
2190 
2191  if (!fCanvasImp) return;
2192 
2193  if (!gVirtualX->IsCmdThread()) {
2194  gInterpreter->Execute(this, IsA(), "Update", "");
2195  return;
2196  }
2197 
2199 
2200  fUpdating = kTRUE;
2201 
2202  if (!IsBatch()) FeedbackMode(kFALSE); // Goto double buffer mode
2203 
2204  if (!UseGL())
2205  PaintModified(); // Repaint all modified pad's
2206 
2207  Flush(); // Copy all pad pixmaps to the screen
2208 
2209  SetCursor(kCross);
2210  fUpdating = kFALSE;
2211 }
2212 
2213 ////////////////////////////////////////////////////////////////////////////////
2214 /// Used by friend class TCanvasImp.
2215 
2217 {
2218  fCanvasID = 0;
2219  fContextMenu = 0;
2220 }
2221 
2222 ////////////////////////////////////////////////////////////////////////////////
2223 /// Check whether this canvas is to be drawn in grayscale mode.
2224 
2226 {
2227  return TestBit(kIsGrayscale);
2228 }
2229 
2230 ////////////////////////////////////////////////////////////////////////////////
2231 /// Set whether this canvas should be painted in grayscale, and re-paint
2232 /// it if necessary.
2233 
2234 void TCanvas::SetGrayscale(Bool_t set /*= kTRUE*/)
2235 {
2236  if (IsGrayscale() == set) return;
2237  SetBit(kIsGrayscale, set);
2238  Paint(); // update canvas and all sub-pads, unconditionally!
2239 }
2240 
2241 ////////////////////////////////////////////////////////////////////////////////
2242 /// Probably, TPadPainter must be placed in a separate ROOT module -
2243 /// "padpainter" (the same as "histpainter"). But now, it's directly in a
2244 /// gpad dir, so, in case of default painter, no *.so should be loaded,
2245 /// no need in plugin managers.
2246 /// May change in future.
2247 
2249 {
2250  //Even for batch mode painter is still required, just to delegate
2251  //some calls to batch "virtual X".
2252  if (!UseGL() || fBatch)
2253  fPainter = new TPadPainter;//Do not need plugin manager for this!
2254  else {
2256  if (!fPainter) {
2257  Error("CreatePainter", "GL Painter creation failed! Will use default!");
2258  fPainter = new TPadPainter;
2259  fUseGL = kFALSE;
2260  }
2261  }
2262 }
2263 
2264 ////////////////////////////////////////////////////////////////////////////////
2265 /// Access and (probably) creation of pad painter.
2266 
2268 {
2269  if (!fPainter) CreatePainter();
2270  return fPainter;
2271 }
2272 
2273 
2274 ////////////////////////////////////////////////////////////////////////////////
2275 ///assert on IsBatch() == false?
2276 
2278 {
2279  if (fGLDevice != -1) {
2280  //fPainter has a font manager.
2281  //Font manager will delete textures.
2282  //If context is wrong (we can have several canvases) -
2283  //wrong texture will be deleted, damaging some of our fonts.
2284  gGLManager->MakeCurrent(fGLDevice);
2285  }
2286 
2287  delete fPainter;
2288  fPainter = 0;
2289 
2290  if (fGLDevice != -1) {
2291  gGLManager->DeleteGLContext(fGLDevice);//?
2292  fGLDevice = -1;
2293  }
2294 }
virtual void Clear(Option_t *="")
Definition: TObject.h:110
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TCanvas.cxx:1021
void RunAutoExec()
Execute the list of TExecs in the current pad.
Definition: TCanvas.cxx:1624
void EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
Generate kMouseEnter and kMouseLeave events depending on the previously selected object and the curre...
Definition: TCanvas.cxx:984
Bool_t IsFolder() const
Is folder ?
Definition: TCanvas.cxx:1381
virtual void SetGridx(Int_t value=1)
Definition: TPad.h:327
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:864
void FeedbackMode(Bool_t set)
Turn rubberband feedback mode on or off.
Definition: TCanvas.cxx:1039
Int_t GetTicky() const
Definition: TPad.h:234
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition: TGuiFactory.h:69
virtual void SetPad(const char *name, const char *title, Double_t xlow, Double_t ylow, Double_t xup, Double_t yup, Color_t color=35, Short_t bordersize=5, Short_t bordermode=-1)
Set all pad parameters.
Definition: TPad.cxx:5367
virtual void SetTickx(Int_t value=1)
Definition: TPad.h:347
An array of TObjects.
Definition: TObjArray.h:39
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition: TROOT.cxx:2390
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
Definition: TCanvas.cxx:1503
virtual void ClassBegin(const TClass *, Version_t=-1)=0
TList * fPrimitives
Pointer to mother canvas.
Definition: TPad.h:123
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition: TCanvas.cxx:1432
virtual void ResizePad(Option_t *option="")
Compute pad conversion coefficients.
Definition: TPad.cxx:4877
Bool_t IsOnHeap() const
Definition: TObject.h:140
virtual TCanvas * GetCanvas() const
Definition: TPad.h:257
TPad * fSelectedPad
Drawing option of selected object.
Definition: TCanvas.h:78
virtual void SetCursor(ECursor cursor)
Set cursor.
Definition: TCanvas.cxx:1851
Bool_t GetPadGridX() const
Definition: TStyle.h:224
Bool_t UseGL() const
Definition: TCanvas.h:242
TCanvas(const TCanvas &canvas)
Int_t fEvent
Definition: TCanvas.h:69
TContextMenu * fContextMenu
Window system specific canvas implementation.
Definition: TCanvas.h:82
Int_t GetCanvasBorderMode() const
Definition: TStyle.h:200
virtual void Copy(TAttPad &attpad) const
copy function
Definition: TAttPad.cxx:42
TString fTitle
Definition: TPad.h:126
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2124
Bool_t fDrawn
True when rendering is with GL.
Definition: TCanvas.h:87
Bool_t IsReading() const
Definition: TBuffer.h:81
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
Bool_t fUseGL
Definition: TCanvas.h:86
short Version_t
Definition: RtypesCore.h:61
TPad * fPadSave
Pad containing currently click-selected object.
Definition: TCanvas.h:80
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
TVirtualPadPainter * GetCanvasPainter()
Access and (probably) creation of pad painter.
Definition: TCanvas.cxx:2267
float Float_t
Definition: RtypesCore.h:53
Size_t fYsizeReal
Definition: TCanvas.h:60
Bool_t GetCanvasPreferGL() const
Definition: TStyle.h:197
float Size_t
Definition: RtypesCore.h:83
virtual void Paint(Option_t *option="")
Paint all primitives in pad.
Definition: TPad.cxx:2920
void SetTitle(const char *title="")
Set canvas title.
Definition: TCanvas.cxx:1916
const char Option_t
Definition: RtypesCore.h:62
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:328
Definition: Rtypes.h:61
void Build()
Build a canvas. Called by all constructors.
Definition: TCanvas.cxx:532
Manages default Pad attributes.
Definition: TAttPad.h:29
Create a Box.
Definition: TBox.h:44
Int_t GetPadTickX() const
Definition: TStyle.h:226
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
TVirtualPadPainter * fPainter
Set to True when the Draw method is called.
Definition: TCanvas.h:89
Int_t GetLogx() const
Definition: TPad.h:251
TObject * fSelected
Canvas identifier.
Definition: TCanvas.h:73
TH1 * h
Definition: legend2.C:5
static void SaveColor(std::ostream &out, Int_t ci)
Save a color with index > 228 as a C++ statement(s) on output stream out.
Definition: TColor.cxx:1967
Short_t fBorderSize
Definition: TPad.h:113
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
virtual void SetBorderMode(Short_t bordermode)
Definition: TPad.h:316
static Bool_t fgIsFolder
Canvas (pad) painter.
Definition: TCanvas.h:91
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
Int_t fCanvasID
Last Y mouse position in canvas.
Definition: TCanvas.h:72
Int_t GetLogz() const
Definition: TPad.h:253
static TVirtualPadPainter * PadPainter(Option_t *opt="")
Create a pad painter of specified type.
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition: TAttLine.cxx:159
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual void CopyPixmap()
Copy the pixmap of the pad to the canvas.
Definition: TPad.cxx:956
virtual void SetWindowTitle(const char *newTitle)
Definition: TCanvasImp.h:90
EEventType
Definition: Buttons.h:15
static const char * filename()
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
#define gROOT
Definition: TROOT.h:340
virtual void ToggleToolTips()
Toggle tooltip display.
Definition: TCanvas.cxx:2157
Size_t fYsizeUser
Definition: TCanvas.h:58
void PaintBorder(Color_t color, Bool_t tops)
Paint the pad border.
Definition: TPad.cxx:2982
Basic string class.
Definition: TString.h:137
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition: TAttFill.cxx:197
Int_t fWindowTopX
Definition: TCanvas.h:63
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1088
Int_t fSelectedX
Currently click-selected object.
Definition: TCanvas.h:75
int Int_t
Definition: RtypesCore.h:41
virtual void Size(Float_t xsizeuser=0, Float_t ysizeuser=0)
Set the canvas scale in centimeters.
Definition: TCanvas.cxx:1942
bool Bool_t
Definition: RtypesCore.h:59
virtual void PaintModified()
Traverse pad hierarchy and (re)paint only modified pads.
Definition: TPad.cxx:3137
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:63
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t GetOptStat() const
Definition: TStyle.h:253
Float_t GetGreen() const
Definition: TColor.h:61
virtual void InitPainter()
Empty definition.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:496
#define gInterpreter
Definition: TInterpreter.h:502
Int_t GetTickx() const
Definition: TPad.h:233
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
void Constructor()
Canvas default constructor.
Definition: TCanvas.cxx:144
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
ECursor
Definition: TVirtualX.h:56
void DrawEventStatus(Int_t event, Int_t x, Int_t y, TObject *selected)
Report name and title of primitive below the cursor.
Definition: TCanvas.cxx:922
virtual Short_t GetBorderMode() const
Definition: TPad.h:200
UInt_t GetWindowHeight() const
Definition: TCanvas.h:185
void Flush()
Flush canvas buffers.
Definition: TCanvas.cxx:1053
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:127
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
virtual TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj)
Search for an object at pixel position px,py.
Definition: TCanvas.h:203
void SetCanvasColor(Color_t color=19)
Definition: TStyle.h:339
Bool_t HasMenuBar() const
Definition: TCanvas.h:191
virtual void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected)
Emit ProcessedEvent() signal.
Definition: TCanvas.cxx:1517
virtual void ClassMember(const char *, const char *=0, Int_t=-1, Int_t=-1)=0
#define SafeDelete(p)
Definition: RConfig.h:436
Size_t fXsizeReal
Definition: TCanvas.h:59
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:203
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
virtual void Browse(TBrowser *b)
Browse.
Definition: TCanvas.cxx:625
TString fSelectedOpt
Y of selected object.
Definition: TCanvas.h:77
Fill Area Attributes class.
Definition: TAttFill.h:32
Double_t x[n]
Definition: legend1.C:17
Int_t GetWindowTopY()
Returns current top y position of window on screen.
Definition: TCanvas.cxx:1123
virtual void SetFixedAspectRatio(Bool_t fixed=kTRUE)
Fix canvas aspect ratio to current value if fixed is true.
Definition: TCanvas.cxx:1877
virtual void Cleared(TVirtualPad *pad)
Emit pad Cleared signal.
Definition: TCanvas.cxx:711
virtual void Paint(Option_t *option="")
Paint canvas.
Definition: TCanvas.cxx:1440
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition: TCanvas.cxx:1532
virtual void Close(Option_t *option="")
Delete all primitives in pad and pad itself.
Definition: TPad.cxx:898
void Class()
Definition: Class.C:29
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
Definition: TVirtualPad.h:290
Float_t GetPadBottomMargin() const
Definition: TStyle.h:220
Bool_t IsBeingResized() const
Definition: TVirtualPad.h:151
void HighLight(Color_t col=kRed, Bool_t set=kTRUE)
Highlight pad.
Definition: TPad.cxx:2829
virtual void ShowEditor(Bool_t show=kTRUE)
Definition: TCanvasImp.h:97
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
Definition: TPad.h:326
UChar_t mod R__LOCKGUARD2(gSrvAuthenticateMutex)
Float_t GetBlue() const
Definition: TColor.h:62
virtual void Show()
Definition: TCanvasImp.h:64
TCanvas * fCanvas
pointer to mother of the list
Definition: TPad.h:122
TPad * fClickSelectedPad
Pad containing currently selected object.
Definition: TCanvas.h:79
void SetCanvasBorderSize(Width_t size=1)
Definition: TStyle.h:340
void DeleteCanvasPainter()
assert on IsBatch() == false?
Definition: TCanvas.cxx:2277
void Clear(Option_t *option="")
Remove all primitives from the canvas.
Definition: TCanvas.cxx:678
virtual void Pop()
Pop on object drawn in a pad to the top of the display list.
Definition: TObject.cxx:572
virtual void Close()
Definition: TCanvasImp.h:54
virtual void ShowToolBar(Bool_t show=kTRUE)
Definition: TCanvasImp.h:98
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=0, TVirtualPad *p=0)
Popup context menu at given location in canvas c and pad p for selected object.
UInt_t GetWw() const
Get Ww.
Definition: TCanvas.h:186
virtual ~TCanvas()
Canvas destructor.
Definition: TCanvas.cxx:617
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
virtual void SetLogx(Int_t value=1)
Set Lin/Log scale for X.
Definition: TPad.cxx:5305
static ENewType IsCallingNew()
Static method returning the defConstructor flag passed to TClass::New().
Definition: TClass.cxx:5516
virtual void ShowMenuBar(Bool_t show=kTRUE)
Definition: TCanvasImp.h:92
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
R__EXTERN TGuiFactory * gGuiFactory
Definition: TGuiFactory.h:68
static void SetFolder(Bool_t isfolder=kTRUE)
If isfolder=kTRUE, the canvas can be browsed like a folder by default a canvas is not browsable...
Definition: TCanvas.cxx:1899
Int_t GetLogy() const
Definition: TPad.h:252
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition: TCanvas.cxx:1680
char * out
Definition: TBase64.cxx:29
Int_t GetOptFit() const
Definition: TStyle.h:252
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
static TCanvasInit gCanvasInit
Definition: TCanvas.cxx:47
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
Definition: TCanvas.cxx:2169
Double_t fX2
Definition: TPad.h:54
const char * GetName() const
Returns name of object.
Definition: TPad.h:255
A doubly linked list.
Definition: TList.h:47
Int_t GetOptLogz() const
Definition: TStyle.h:257
virtual Color_t GetHighLightColor() const
Get highlight color.
Definition: TPad.cxx:2583
Bool_t fRetained
True when Updating the canvas.
Definition: TCanvas.h:85
virtual void CopyPixmaps()
Copy the sub-pixmaps of the pad to the canvas.
Definition: TPad.cxx:970
Int_t GetPadTickY() const
Definition: TStyle.h:227
Int_t GetOptTitle() const
Definition: TStyle.h:254
Float_t GetPadRightMargin() const
Definition: TStyle.h:223
Bool_t IsReading() const
Definition: TStyle.h:296
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
UInt_t fCw
Definition: TCanvas.h:67
void DisconnectWidget()
Used by friend class TCanvasImp.
Definition: TCanvas.cxx:2216
TPad * fMother
Definition: TPad.h:121
virtual Bool_t CheckObject(const TObject *obj)=0
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TPad.cxx:1587
void CopyPixmaps()
Copy the canvas pixmap of the pad to the canvas.
Definition: TCanvas.cxx:777
virtual void ToggleToolBar()
Toggle toolbar.
Definition: TCanvas.cxx:2135
Int_t fSelectedY
X of selected object.
Definition: TCanvas.h:76
void SetCanvasBorderMode(Int_t mode=1)
Definition: TStyle.h:341
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:97
static void NeedGraphicsLibs()
Static method.
Int_t fPixmapID
Definition: TPad.h:100
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition: TCanvas.cxx:1616
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this canvas A new canvas is created that is a clone of this canvas.
Definition: TCanvas.cxx:841
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
Definition: TPad.cxx:4627
UInt_t fWindowHeight
Definition: TCanvas.h:66
Int_t GetOptLogy() const
Definition: TStyle.h:256
virtual void SetTicky(Int_t value=1)
Definition: TPad.h:348
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:494
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:187
virtual void ls(Option_t *option="") const
List all primitives in pad.
Definition: TPad.cxx:2864
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:674
virtual void UseCurrentStyle()
Force a copy of current style for all objects in pad.
Definition: TPad.cxx:6117
virtual Color_t GetFillColor() const
Definition: TAttFill.h:43
TClass * IsA() const
Bool_t GetShowToolTips() const
Definition: TCanvas.h:174
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
TString fDISPLAY
Definition: TCanvas.h:56
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
The most important graphics class in the ROOT system.
Definition: TPad.h:46
char * Form(const char *fmt,...)
void CreatePainter()
Probably, TPadPainter must be placed in a separate ROOT module - "padpainter" (the same as "histpaint...
Definition: TCanvas.cxx:2248
virtual Short_t GetBorderSize() const
Definition: TPad.h:201
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitives in this pad on the C++ source file out.
Definition: TPad.cxx:5070
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
Definition: TCanvas.cxx:1401
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2146
Bool_t fUpdating
True when in batchmode.
Definition: TCanvas.h:84
Bool_t GetGridx() const
Definition: TPad.h:230
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition: TCanvas.cxx:2115
void Destructor()
Actual canvas destructor.
Definition: TCanvas.cxx:635
#define gVirtualX
Definition: TVirtualX.h:362
UInt_t GetWindowWidth() const
Definition: TCanvas.h:184
Int_t GetCanvasDefW() const
Definition: TStyle.h:202
virtual void ShowStatusBar(Bool_t show=kTRUE)
Definition: TCanvasImp.h:93
virtual void SelectDrawable(Int_t device)=0
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2513
Double_t fY2
Definition: TPad.h:55
static void CreateApplication()
Static function used to create a default application environment.
Double_t fAspectRatio
Definition: TPad.h:98
Float_t GetPadLeftMargin() const
Definition: TStyle.h:222
Int_t GetWindowTopX()
Returns current top x position of window on screen.
Definition: TCanvas.cxx:1112
TAttCanvas fCatt
Definition: TCanvas.h:55
const char * GetTitle() const
Returns title of object.
Definition: TPad.h:256
void InitializeGraphics()
Initialize the graphics environment.
long Long_t
Definition: RtypesCore.h:50
Color * colors
Definition: X3DBuffer.c:19
TCanvasImp * fCanvasImp
Pointer to saved pad in HandleInput.
Definition: TCanvas.h:81
Option_t * GetOption() const
Definition: TCollection.h:160
The Canvas class.
Definition: TCanvas.h:48
Int_t GetCanvasDefX() const
Definition: TStyle.h:203
virtual Int_t GetSize() const
Definition: TCollection.h:95
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition: TObject.cxx:444
const Size_t kDefaultCanvasSize
Definition: TCanvas.cxx:54
Int_t GetCanvasDefY() const
Definition: TStyle.h:204
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition: TObject.cxx:369
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
double Double_t
Definition: RtypesCore.h:55
virtual void SetGridy(Int_t value=1)
Definition: TPad.h:328
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
void SetCanvasSize(UInt_t ww, UInt_t wh)
Set Width and Height of canvas to ww and wh respectively.
Definition: TCanvas.cxx:1838
virtual void SetFillStyle(Style_t fstyle)
Override TAttFill::FillStyle for TPad because we want to handle style=0 as style 4000.
Definition: TPad.cxx:5293
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
Bool_t IsBatch() const
Is pad in batch mode ?
Definition: TCanvas.h:193
static RooMathCoreReg dummy
Double_t y[n]
Definition: legend1.C:17
void Init()
Initialize the TCanvas members. Called by all constructors.
Definition: TCanvas.cxx:483
virtual void SetRGB(Float_t r, Float_t g, Float_t b)
Initialize this color and its associated colors.
Definition: TColor.cxx:1605
Bool_t IsGrayscale()
Check whether this canvas is to be drawn in grayscale mode.
Definition: TCanvas.cxx:2225
virtual TCanvasImp * CreateCanvasImp(TCanvas *c, const char *title, UInt_t width, UInt_t height)
Create a batch version of TCanvasImp.
Definition: TGuiFactory.cxx:55
#define gGLManager
Definition: TVirtualGL.h:168
Color_t fHighLightColor
Definition: TCanvas.h:61
Size_t fXsizeUser
Definition: TCanvas.h:57
The color creation and management class.
Definition: TColor.h:23
void Browse(TBrowser *b)
Browse this collection (called by TBrowser).
Float_t GetRed() const
Definition: TColor.h:60
void SetWindowSize(UInt_t ww, UInt_t wh)
Definition: TCanvas.h:221
virtual void SetTicks(Int_t valuex=1, Int_t valuey=1)
Definition: TPad.h:346
#define name(a, b)
Definition: linkTestLib0.cpp:5
Int_t fWindowTopY
Definition: TCanvas.h:64
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition: TAttPad.cxx:117
virtual void SetName(const char *name)
Definition: TPad.h:344
Bool_t GetShowToolBar() const
Definition: TCanvas.h:172
Mother of all ROOT objects.
Definition: TObject.h:58
Bool_t fFixedAspectRatio
Definition: TPad.h:120
void UseCurrentStyle()
Force a copy of current style for all objects in canvas.
Definition: TCanvas.cxx:1087
void Clear(Option_t *option="")
Delete all pad primitives.
Definition: TPad.cxx:543
virtual void Draw(Option_t *option="")
Draw a canvas.
Definition: TCanvas.cxx:795
Int_t fDoubleBuffer
Definition: TCanvas.h:62
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition: TROOT.cxx:2453
virtual void SetDoubleBuffer(Int_t mode=1)
Set Double Buffer On/Off.
Definition: TCanvas.cxx:1860
void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitives in this canvas in C++ macro file with GUI.
Definition: TCanvas.cxx:1635
TList * GetListOfPrimitives() const
Definition: TPad.h:240
virtual TObject * DrawClonePad()
Draw a clone of this canvas into the current pad In an interactive session, select the destination/cu...
Definition: TCanvas.cxx:867
#define ClassImpQ(name)
Definition: TQObject.h:244
void EmbedInto(Int_t winid, Int_t ww, Int_t wh)
Embedded a canvas into a TRootEmbeddedCanvas.
Definition: TCanvas.cxx:958
virtual void ShowToolTips(Bool_t show=kTRUE)
Definition: TCanvasImp.h:99
virtual void Add(TObject *obj)
Definition: TList.h:81
virtual void LockPainter()
Empty definition.
virtual void ClassEnd(const TClass *)=0
Int_t fEventX
Type of current or last handled event.
Definition: TCanvas.h:70
virtual void ls(Option_t *option="") const
List all pads.
Definition: TCanvas.cxx:1389
void SetSelected(TObject *obj)
Set selected canvas.
Definition: TCanvas.cxx:1907
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
void Close(Option_t *option="")
Close canvas.
Definition: TCanvas.cxx:729
virtual void EditorBar()
Get editor bar.
Definition: TCanvas.cxx:949
R__EXTERN TVirtualPS * gVirtualPS
Definition: TVirtualPS.h:91
TVirtualPad * GetSelectedPad() const
Definition: TCanvas.h:169
#define gPad
Definition: TVirtualPad.h:288
virtual Int_t InitWindow()
Definition: TCanvasImp.h:58
Width_t GetCanvasBorderSize() const
Definition: TStyle.h:199
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
Implement TVirtualPadPainter which abstracts painting operations.
Definition: TPadPainter.h:28
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2461
TObject * fClickSelected
Currently selected object.
Definition: TCanvas.h:74
Int_t fEventY
Last X mouse position in canvas.
Definition: TCanvas.h:71
Bool_t GetShowEventStatus() const
Definition: TCanvas.h:171
Bool_t GetPadGridY() const
Definition: TStyle.h:225
Bool_t GetGridy() const
Definition: TPad.h:231
void SetBatch(Bool_t batch=kTRUE)
Toggle batch mode.
Definition: TCanvas.cxx:1822
void ResetBit(UInt_t f)
Definition: TObject.h:172
virtual UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Definition: TCanvasImp.h:85
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition: TVirtualPS.h:40
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition: TCanvas.cxx:1136
virtual void SetBorderSize(Short_t bordersize)
Definition: TPad.h:317
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2179
Double_t fY1
Definition: TPad.h:53
virtual void SetStatusText(const char *text=0, Int_t partidx=0)
Definition: TCanvasImp.h:87
Int_t fGLDevice
Off-screen pixmap identifier.
Definition: TPad.h:101
Bool_t fBatch
Context menu pointer.
Definition: TCanvas.h:83
Float_t GetPadTopMargin() const
Definition: TStyle.h:221
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition: TDatime.cxx:99
Int_t GetOptLogx() const
Definition: TStyle.h:255
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetCanvasSize(UInt_t w, UInt_t h)
Definition: TCanvasImp.h:91
Double_t fX1
tool tip associated with box
Definition: TPad.h:52
virtual void SetLogz(Int_t value=1)
Set Lin/Log scale for Z.
Definition: TPad.cxx:5328
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:459
Float_t GetScreenFactor() const
Definition: TStyle.h:264
TObject * obj
Color_t GetHighLightColor() const
Get highlight color.
Definition: TCanvas.h:161
Int_t GetCanvasDefH() const
Definition: TStyle.h:201
virtual void Closed()
Emit Closed signal.
Definition: TCanvas.cxx:719
const Int_t n
Definition: legend1.C:16
Color_t GetCanvasColor() const
Definition: TStyle.h:198
Line Attributes class.
Definition: TAttLine.h:32
void Modified(Bool_t flag=1)
Definition: TPad.h:407
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
UInt_t GetWh() const
Get Wh.
Definition: TCanvas.h:187
virtual void Picked(TPad *selpad, TObject *selected, Int_t event)
Emit Picked() signal.
Definition: TCanvas.cxx:1489
UInt_t fCh
Definition: TCanvas.h:68
Short_t fBorderMode
Definition: TPad.h:114
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
UInt_t fWindowWidth
Definition: TCanvas.h:65
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:39
Int_t GetNumber() const
Definition: TColor.h:58
void SetGrayscale(Bool_t set=kTRUE)
Set whether this canvas should be painted in grayscale, and re-paint it if necessary.
Definition: TCanvas.cxx:2234
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:107
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.
Definition: TPad.cxx:5318
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904