Logo ROOT  
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 <cstring>
13 #include <cstdlib>
14 #include <iostream>
15 #include <fstream>
16 
17 #include "TROOT.h"
18 #include "TBuffer.h"
19 #include "TCanvas.h"
20 #include "TCanvasImp.h"
21 #include "TDatime.h"
22 #include "TClass.h"
23 #include "TStyle.h"
24 #include "TBox.h"
25 #include "TCanvasImp.h"
26 #include "TDialogCanvas.h"
27 #include "TGuiFactory.h"
28 #include "TEnv.h"
29 #include "TError.h"
30 #include "TContextMenu.h"
31 #include "TControlBar.h"
32 #include "TInterpreter.h"
33 #include "TApplication.h"
34 #include "TColor.h"
35 #include "TObjArray.h"
36 #include "TVirtualPadEditor.h"
37 #include "TVirtualViewer3D.h"
38 #include "TPadPainter.h"
39 #include "TVirtualGL.h"
40 #include "TVirtualPS.h"
41 #include "TVirtualX.h"
42 #include "TAxis.h"
43 #include "TH1.h"
44 #include "TGraph.h"
45 #include "TMath.h"
46 #include "TView.h"
47 #include "strlcpy.h"
48 #include "snprintf.h"
49 
50 #include "TVirtualMutex.h"
51 
52 class TCanvasInit {
53 public:
54  TCanvasInit() { TApplication::NeedGraphicsLibs(); }
56 
57 //*-*x16 macros/layout_canvas
58 
60 
62 
64 
65 
66 /** \class TCanvas
67 \ingroup gpad
68 
69 The Canvas class.
70 
71 A Canvas is an area mapped to a window directly under the control of the display
72 manager. A ROOT session may have several canvases open at any given time.
73 
74 A Canvas may be subdivided into independent graphical areas: the __Pads__.
75 A canvas has a default pad which has the name of the canvas itself.
76 An example of a Canvas layout is sketched in the picture below.
77 
78 \image html gpad_canvas.png
79 
80 This canvas contains two pads named P1 and P2. Both Canvas, P1 and P2 can be
81 moved, grown, shrunk using the normal rules of the Display manager.
82 
83 Once objects have been drawn in a canvas, they can be edited/moved by pointing
84 directly to them. The cursor shape is changed to suggest the type of action that
85 one can do on this object. Clicking with the right mouse button on an object
86 pops-up a contextmenu with a complete list of actions possible on this object.
87 
88 A graphical editor may be started from the canvas "View" menu under the menu
89 entry "Toolbar".
90 
91 An interactive HELP is available by clicking on the HELP button at the top right
92 of the canvas. It gives a short explanation about the canvas' menus.
93 
94 A canvas may be automatically divided into pads via `TPad::Divide`.
95 
96 At creation time, no matter if in interactive or batch mode, the canvas size
97 defines the size of the canvas window (including the size of the window
98 manager's decoration). To define precisely the graphics area size of a canvas in
99 the interactive mode, the following four lines of code should be used:
100 ~~~ {.cpp}
101  {
102  Double_t w = 600;
103  Double_t h = 600;
104  auto c = new TCanvas("c", "c", w, h);
105  c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
106  }
107 ~~~
108 and in the batch mode simply do:
109 ~~~ {.cpp}
110  c->SetCanvasSize(w,h);
111 ~~~
112 
113 If the canvas size this exceed the window size, scroll bars will be added to the canvas
114 This allows to display very large canvases (even bigger than the screen size). The
115 Following example shows how to proceed.
116 ~~~ {.cpp}
117  {
118  auto c = new TCanvas("c","c");
119  c->SetCanvasSize(1500, 1500);
120  c->SetWindowSize(500, 500);
121  }
122 ~~~
123 */
124 
125 ////////////////////////////////////////////////////////////////////////////////
126 /// Canvas default constructor.
127 
128 TCanvas::TCanvas(Bool_t build) : TPad(), fDoubleBuffer(0)
129 {
130  fPainter = 0;
131  fWindowTopX = 0;
132  fWindowTopY = 0;
133  fWindowWidth = 0;
134  fWindowHeight = 0;
135  fCw = 0;
136  fCh = 0;
137  fXsizeUser = 0;
138  fYsizeUser = 0;
139  fXsizeReal = kDefaultCanvasSize;
140  fYsizeReal = kDefaultCanvasSize;
141  fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
142  fEvent = -1;
143  fEventX = -1;
144  fEventY = -1;
145  fSelectedX = 0;
146  fSelectedY = 0;
147  fRetained = kTRUE;
148  fDrawn = kFALSE;
149  fSelected = 0;
150  fClickSelected = 0;
151  fSelectedPad = 0;
152  fClickSelectedPad = 0;
153  fPadSave = 0;
154  fCanvasImp = 0;
155  fContextMenu = 0;
156 
157  fUseGL = gStyle->GetCanvasPreferGL();
158 
159  if (!build || TClass::IsCallingNew() != TClass::kRealNew) {
160  Constructor();
161  } else {
162  const char *defcanvas = gROOT->GetDefCanvasName();
163  char *cdef;
164 
165  auto lc = (TList*)gROOT->GetListOfCanvases();
166  if (lc->FindObject(defcanvas)) {
167  Int_t n = lc->GetSize()+1;
168  while (lc->FindObject(Form("%s_n%d",defcanvas,n))) n++;
169  cdef = StrDup(Form("%s_n%d",defcanvas,n));
170  } else {
171  cdef = StrDup(Form("%s",defcanvas));
172  }
173  Constructor(cdef, cdef, 1);
174  delete [] cdef;
175  }
176 }
177 
178 ////////////////////////////////////////////////////////////////////////////////
179 /// Canvas default constructor
180 
182 {
183  if (gThreadXAR) {
184  void *arr[2];
185  arr[1] = this;
186  if ((*gThreadXAR)("CANV", 2, arr, 0)) return;
187  }
188 
189  fCanvas = 0;
190  fCanvasID = -1;
191  fCanvasImp = 0;
192  fBatch = kTRUE;
193  fUpdating = kFALSE;
194 
195  fContextMenu = 0;
196  fSelected = 0;
197  fClickSelected = 0;
198  fSelectedPad = 0;
199  fClickSelectedPad = 0;
200  fPadSave = 0;
201  SetBit(kAutoExec);
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////
207 /// Create an embedded canvas, i.e. a canvas that is in a TGCanvas widget
208 /// which is placed in a TGFrame. This ctor is only called via the
209 /// TRootEmbeddedCanvas class.
210 ///
211 /// If "name" starts with "gl" the canvas is ready to receive GL output.
212 
213 TCanvas::TCanvas(const char *name, Int_t ww, Int_t wh, Int_t winid) : TPad(), fDoubleBuffer(0)
214 {
215  fCanvasImp = 0;
216  fPainter = 0;
217  Init();
218 
219  fCanvasID = winid;
220  fWindowTopX = 0;
221  fWindowTopY = 0;
222  fWindowWidth = ww;
223  fWindowHeight = wh;
224  fCw = ww + 4;
225  fCh = wh +28;
226  fBatch = kFALSE;
227  fUpdating = kFALSE;
228 
229  //This is a very special ctor. A window exists already!
230  //Can create painter now.
232 
233  if (fUseGL) {
234  fGLDevice = gGLManager->CreateGLContext(winid);
235  if (fGLDevice == -1)
236  fUseGL = kFALSE;
237  }
238 
240  if (!fCanvasImp) return;
241 
242  CreatePainter();
243  SetName(name);
244  Build();
245 }
246 
247 ////////////////////////////////////////////////////////////////////////////////
248 /// Create a new canvas with a predefined size form.
249 /// If form < 0 the menubar is not shown.
250 ///
251 /// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
252 /// - form = 2 500x500 at 20,20
253 /// - form = 3 500x500 at 30,30
254 /// - form = 4 500x500 at 40,40
255 /// - form = 5 500x500 at 50,50
256 ///
257 /// If "name" starts with "gl" the canvas is ready to receive GL output.
258 
259 TCanvas::TCanvas(const char *name, const char *title, Int_t form) : TPad(), fDoubleBuffer(0)
260 {
261  fPainter = 0;
263 
264  Constructor(name, title, form);
265 }
266 
267 ////////////////////////////////////////////////////////////////////////////////
268 /// Create a new canvas with a predefined size form.
269 /// If form < 0 the menubar is not shown.
270 ///
271 /// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
272 /// - form = 2 500x500 at 20,20
273 /// - form = 3 500x500 at 30,30
274 /// - form = 4 500x500 at 40,40
275 /// - form = 5 500x500 at 50,50
276 
277 void TCanvas::Constructor(const char *name, const char *title, Int_t form)
278 {
279  if (gThreadXAR) {
280  void *arr[6];
281  static Int_t ww = 500;
282  static Int_t wh = 500;
283  arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
284  if ((*gThreadXAR)("CANV", 6, arr, 0)) return;
285  }
286 
287  Init();
288  SetBit(kMenuBar,1);
289  if (form < 0) {
290  form = -form;
291  SetBit(kMenuBar,0);
292  }
293 
294  fCanvas = this;
295 
296  fCanvasID = -1;
297  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
298  if (old && old->IsOnHeap()) {
299  Warning("Constructor","Deleting canvas with same name: %s",name);
300  delete old;
301  }
302  if (gROOT->IsBatch()) { //We are in Batch mode
303  fWindowTopX = fWindowTopY = 0;
304  if (form == 1) {
307  } else {
308  fWindowWidth = 500;
309  fWindowHeight = 500;
310  }
311  fCw = fWindowWidth;
312  fCh = fWindowHeight;
314  if (!fCanvasImp) return;
315  fBatch = kTRUE;
316  } else { //normal mode with a screen window
318  if (form < 1 || form > 5) form = 1;
319  if (form == 1) {
320  UInt_t uh = UInt_t(cx*gStyle->GetCanvasDefH());
321  UInt_t uw = UInt_t(cx*gStyle->GetCanvasDefW());
322  Int_t ux = Int_t(cx*gStyle->GetCanvasDefX());
323  Int_t uy = Int_t(cx*gStyle->GetCanvasDefY());
324  fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, ux, uy, uw, uh);
325  }
326  fCw = 500;
327  fCh = 500;
328  if (form == 2) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 20, 20, UInt_t(cx*500), UInt_t(cx*500));
329  if (form == 3) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 30, 30, UInt_t(cx*500), UInt_t(cx*500));
330  if (form == 4) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 40, 40, UInt_t(cx*500), UInt_t(cx*500));
331  if (form == 5) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 50, 50, UInt_t(cx*500), UInt_t(cx*500));
332  if (!fCanvasImp) return;
333 
334  if (!gROOT->IsBatch() && fCanvasID == -1)
336 
338  fBatch = kFALSE;
339  }
340 
341  CreatePainter();
342 
343  SetName(name);
344  SetTitle(title); // requires fCanvasImp set
345  Build();
346 
347  // Popup canvas
348  fCanvasImp->Show();
349 }
350 
351 ////////////////////////////////////////////////////////////////////////////////
352 /// Create a new canvas at a random position.
353 ///
354 /// \param[in] name canvas name
355 /// \param[in] title canvas title
356 /// \param[in] ww is the canvas size in pixels along X
357 /// (if ww < 0 the menubar is not shown)
358 /// \param[in] wh is the canvas size in pixels along Y
359 ///
360 /// If "name" starts with "gl" the canvas is ready to receive GL output.
361 
362 TCanvas::TCanvas(const char *name, const char *title, Int_t ww, Int_t wh) : TPad(), fDoubleBuffer(0)
363 {
364  fPainter = 0;
366 
367  Constructor(name, title, ww, wh);
368 }
369 
370 ////////////////////////////////////////////////////////////////////////////////
371 /// Create a new canvas at a random position.
372 ///
373 /// \param[in] name canvas name
374 /// \param[in] title canvas title
375 /// \param[in] ww is the canvas size in pixels along X
376 /// (if ww < 0 the menubar is not shown)
377 /// \param[in] wh is the canvas size in pixels along Y
378 
379 void TCanvas::Constructor(const char *name, const char *title, Int_t ww, Int_t wh)
380 {
381  if (gThreadXAR) {
382  void *arr[6];
383  arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
384  if ((*gThreadXAR)("CANV", 6, arr, 0)) return;
385  }
386 
387  Init();
388  SetBit(kMenuBar,1);
389  if (ww < 0) {
390  ww = -ww;
391  SetBit(kMenuBar,0);
392  }
393  if (wh <= 0) {
394  Error("Constructor", "Invalid canvas height: %d",wh);
395  return;
396  }
397  fCw = ww;
398  fCh = wh;
399  fCanvasID = -1;
400  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
401  if (old && old->IsOnHeap()) {
402  Warning("Constructor","Deleting canvas with same name: %s",name);
403  delete old;
404  }
405  if (gROOT->IsBatch()) { //We are in Batch mode
406  fWindowTopX = fWindowTopY = 0;
407  fWindowWidth = ww;
408  fWindowHeight = wh;
409  fCw = ww;
410  fCh = wh;
412  if (!fCanvasImp) return;
413  fBatch = kTRUE;
414  } else {
416  fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, UInt_t(cx*ww), UInt_t(cx*wh));
417  if (!fCanvasImp) return;
418 
419  if (!gROOT->IsBatch() && fCanvasID == -1)
421 
423  fBatch = kFALSE;
424  }
425 
426  CreatePainter();
427 
428  SetName(name);
429  SetTitle(title); // requires fCanvasImp set
430  Build();
431 
432  // Popup canvas
433  fCanvasImp->Show();
434 }
435 
436 ////////////////////////////////////////////////////////////////////////////////
437 /// Create a new canvas.
438 ///
439 /// \param[in] name canvas name
440 /// \param[in] title canvas title
441 /// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
442 /// the canvas (if wtopx < 0) the menubar is not shown)
443 /// \param[in] ww is the canvas size in pixels along X
444 /// \param[in] wh is the canvas size in pixels along Y
445 ///
446 /// If "name" starts with "gl" the canvas is ready to receive GL output.
447 
448 TCanvas::TCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
449  : TPad(), fDoubleBuffer(0)
450 {
451  fPainter = 0;
453 
454  Constructor(name, title, wtopx, wtopy, ww, wh);
455 }
456 
457 ////////////////////////////////////////////////////////////////////////////////
458 /// Create a new canvas.
459 ///
460 /// \param[in] name canvas name
461 /// \param[in] title canvas title
462 /// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
463 /// the canvas (if wtopx < 0) the menubar is not shown)
464 /// \param[in] ww is the canvas size in pixels along X
465 /// \param[in] wh is the canvas size in pixels along Y
466 
467 void TCanvas::Constructor(const char *name, const char *title, Int_t wtopx,
468  Int_t wtopy, Int_t ww, Int_t wh)
469 {
470  if (gThreadXAR) {
471  void *arr[8];
472  arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title;
473  arr[4] = &wtopx; arr[5] = &wtopy; arr[6] = &ww; arr[7] = &wh;
474  if ((*gThreadXAR)("CANV", 8, arr, 0)) return;
475  }
476 
477  Init();
478  SetBit(kMenuBar,1);
479  if (wtopx < 0) {
480  wtopx = -wtopx;
481  SetBit(kMenuBar,0);
482  }
483  fCw = ww;
484  fCh = wh;
485  fCanvasID = -1;
486  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
487  if (old && old->IsOnHeap()) {
488  Warning("Constructor","Deleting canvas with same name: %s",name);
489  delete old;
490  }
491  if (gROOT->IsBatch()) { //We are in Batch mode
492  fWindowTopX = fWindowTopY = 0;
493  fWindowWidth = ww;
494  fWindowHeight = wh;
495  fCw = ww;
496  fCh = wh;
498  if (!fCanvasImp) return;
499  fBatch = kTRUE;
500  } else { //normal mode with a screen window
502  fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, Int_t(cx*wtopx), Int_t(cx*wtopy), UInt_t(cx*ww), UInt_t(cx*wh));
503  if (!fCanvasImp) return;
504 
505  if (!gROOT->IsBatch() && fCanvasID == -1)
507 
509  fBatch = kFALSE;
510  }
511 
512  CreatePainter();
513 
514  SetName(name);
515  SetTitle(title); // requires fCanvasImp set
516  Build();
517 
518  // Popup canvas
519  fCanvasImp->Show();
520 }
521 
522 ////////////////////////////////////////////////////////////////////////////////
523 /// Initialize the TCanvas members. Called by all constructors.
524 
526 {
527  // Make sure the application environment exists. It is need for graphics
528  // (colors are initialized in the TApplication ctor).
529  if (!gApplication)
531 
532  // Load and initialize graphics libraries if
533  // TApplication::NeedGraphicsLibs() has been called by a
534  // library static initializer.
535  if (gApplication)
537 
538  // Get some default from .rootrc. Used in fCanvasImp->InitWindow().
539  fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
540  SetBit(kMoveOpaque, gEnv->GetValue("Canvas.MoveOpaque", 0));
541  SetBit(kResizeOpaque, gEnv->GetValue("Canvas.ResizeOpaque", 0));
542  if (gEnv->GetValue("Canvas.ShowEventStatus", kFALSE)) SetBit(kShowEventStatus);
543  if (gEnv->GetValue("Canvas.ShowToolTips", kFALSE)) SetBit(kShowToolTips);
544  if (gEnv->GetValue("Canvas.ShowToolBar", kFALSE)) SetBit(kShowToolBar);
545  if (gEnv->GetValue("Canvas.ShowEditor", kFALSE)) SetBit(kShowEditor);
546  if (gEnv->GetValue("Canvas.AutoExec", kTRUE)) SetBit(kAutoExec);
547 
548  // Fill canvas ROOT data structure
549  fXsizeUser = 0;
550  fYsizeUser = 0;
553 
554  fDISPLAY = "$DISPLAY";
555  fUpdating = kFALSE;
556  fRetained = kTRUE;
557  fSelected = 0;
558  fClickSelected = 0;
559  fSelectedX = 0;
560  fSelectedY = 0;
561  fSelectedPad = 0;
563  fPadSave = 0;
564  fEvent = -1;
565  fEventX = -1;
566  fEventY = -1;
567  fContextMenu = 0;
568  fDrawn = kFALSE;
569 }
570 
571 ////////////////////////////////////////////////////////////////////////////////
572 /// Build a canvas. Called by all constructors.
573 
575 {
576  // Get window identifier
577  if (fCanvasID == -1 && fCanvasImp)
579  if (fCanvasID == -1) return;
580 
581  if (fCw !=0 && fCh !=0) {
584  }
585 
586  // Set Pad parameters
587  gPad = this;
588  fCanvas = this;
589  fMother = (TPad*)gPad;
590 
591  if (IsBatch()) {
592  // Make sure that batch interactive canvas sizes are the same
593  fCw -= 4;
594  fCh -= 28;
595  } else if (IsWeb()) {
596  // mark canvas as batch - avoid virtualx in many places
597  SetBatch(kTRUE);
598  } else {
599  //normal mode with a screen window
600  // Set default physical canvas attributes
601  //Should be done via gVirtualX, not via fPainter (at least now). No changes here.
602  gVirtualX->SelectWindow(fCanvasID);
603  gVirtualX->SetFillColor(1); //Set color index for fill area
604  gVirtualX->SetLineColor(1); //Set color index for lines
605  gVirtualX->SetMarkerColor(1); //Set color index for markers
606  gVirtualX->SetTextColor(1); //Set color index for text
607  // Clear workstation
608  gVirtualX->ClearWindow();
609 
610  // Set Double Buffer on by default
611  SetDoubleBuffer(1);
612 
613  // Get effective window parameters (with borders and menubar)
616 
617  // Get effective canvas parameters without borders
618  Int_t dum1, dum2;
619  gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
620 
621  fContextMenu = new TContextMenu("ContextMenu");
622  }
623 
624  gROOT->GetListOfCanvases()->Add(this);
625 
626  if (!fPrimitives) {
627  fPrimitives = new TList;
629  SetFillStyle(1001);
641  fBorderMode=gStyle->GetCanvasBorderMode(); // do not call SetBorderMode (function redefined in TCanvas)
642  SetPad(0, 0, 1, 1);
643  Range(0, 0, 1, 1); //pad range is set by default to [0,1] in x and y
644 
646  if (vpp) vpp->SelectDrawable(fPixmapID);//gVirtualX->SelectPixmap(fPixmapID); //pixmap must be selected
647  PaintBorder(GetFillColor(), kTRUE); //paint background
648  }
649 
650  // transient canvases have typically no menubar and should not get
651  // by default the event status bar (if set by default)
652  if (TestBit(kMenuBar) && fCanvasImp) {
654  // ... and toolbar + editor
658  }
659 }
660 
661 ////////////////////////////////////////////////////////////////////////////////
662 /// Canvas destructor
663 
665 {
666  Destructor();
667 }
668 
669 ////////////////////////////////////////////////////////////////////////////////
670 /// Browse.
671 
673 {
674  Draw();
675  cd();
677 }
678 
679 ////////////////////////////////////////////////////////////////////////////////
680 /// Actual canvas destructor.
681 
683 {
684  if (gThreadXAR) {
685  void *arr[2];
686  arr[1] = this;
687  if ((*gThreadXAR)("CDEL", 2, arr, 0)) return;
688  }
689 
690  if (!TestBit(kNotDeleted)) return;
691 
693  if (!gPad) return;
694 
695  Close();
696 
697  //If not yet (batch mode?).
699 }
700 
701 ////////////////////////////////////////////////////////////////////////////////
702 /// Set current canvas & pad. Returns the new current pad,
703 /// or 0 in case of failure.
704 /// See TPad::cd() for an explanation of the parameter.
705 
707 {
708  if (fCanvasID == -1) return 0;
709 
710  TPad::cd(subpadnumber);
711 
712  // in case doublebuffer is off, draw directly onto display window
713  if (!IsBatch()) {
714  if (!fDoubleBuffer)
715  gVirtualX->SelectWindow(fCanvasID);//Ok, does not matter for glpad.
716  }
717  return gPad;
718 }
719 
720 ////////////////////////////////////////////////////////////////////////////////
721 /// Remove all primitives from the canvas.
722 /// If option "D" is specified, direct sub-pads are cleared but not deleted.
723 /// This option is not recursive, i.e. pads in direct sub-pads are deleted.
724 
726 {
727  if (fCanvasID == -1) return;
728 
730 
731  TString opt = option;
732  opt.ToLower();
733  if (opt.Contains("d")) {
734  // clear subpads, but do not delete pads in case the canvas
735  // has been divided (note: option "D" is propagated so could cause
736  // conflicts for primitives using option "D" for something else)
737  if (fPrimitives) {
738  TIter next(fPrimitives);
739  TObject *obj;
740  while ((obj=next())) {
741  obj->Clear(option);
742  }
743  }
744  } else {
745  //default, clear everything in the canvas. Subpads are deleted
746  TPad::Clear(option); //Remove primitives from pad
747  }
748 
749  fSelected = 0;
750  fClickSelected = 0;
751  fSelectedPad = 0;
752  fClickSelectedPad = 0;
753 }
754 
755 ////////////////////////////////////////////////////////////////////////////////
756 /// Emit pad Cleared signal.
757 
759 {
760  Emit("Cleared(TVirtualPad*)", (Long_t)pad);
761 }
762 
763 ////////////////////////////////////////////////////////////////////////////////
764 /// Emit Closed signal.
765 
767 {
768  Emit("Closed()");
769 }
770 
771 ////////////////////////////////////////////////////////////////////////////////
772 /// Close canvas.
773 ///
774 /// Delete window/pads data structure
775 
777 {
778  TPad *padsave = (TPad*)gPad;
779  TCanvas *cansave = 0;
780  if (padsave) cansave = (TCanvas*)gPad->GetCanvas();
781 
782  if (fCanvasID != -1) {
783 
784  if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
785  gInterpreter->Execute(this, IsA(), "Close", option);
786  return;
787  }
788 
790 
792 
793  cd();
794  TPad::Close(option);
795 
796  if (!IsBatch()) {
797  gVirtualX->SelectWindow(fCanvasID); //select current canvas
798 
800 
801  if (fCanvasImp)
802  fCanvasImp->Close();
803  }
804  fCanvasID = -1;
805  fBatch = kTRUE;
806 
807  gROOT->GetListOfCanvases()->Remove(this);
808 
809  // Close actual window on screen
811  }
812 
813  if (cansave == this) {
814  gPad = (TCanvas *) gROOT->GetListOfCanvases()->First();
815  } else {
816  gPad = padsave;
817  }
818 
819  Closed();
820 }
821 
822 ////////////////////////////////////////////////////////////////////////////////
823 /// Copy the canvas pixmap of the pad to the canvas.
824 
826 {
827  if (!IsBatch()) {
828  CopyPixmap();
830  }
831 }
832 
833 ////////////////////////////////////////////////////////////////////////////////
834 /// Draw a canvas.
835 /// If a canvas with the name is already on the screen, the canvas is repainted.
836 /// This function is useful when a canvas object has been saved in a Root file.
837 /// One can then do:
838 /// ~~~ {.cpp}
839 /// Root > Tfile f("file.root");
840 /// Root > canvas.Draw();
841 /// ~~~
842 
844 {
845  // Load and initialize graphics libraries if
846  // TApplication::NeedGraphicsLibs() has been called by a
847  // library static initializer.
848  if (gApplication)
850 
851  fDrawn = kTRUE;
852 
853  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(GetName());
854  if (old == this) {
855  Paint();
856  return;
857  }
858  if (old) { gROOT->GetListOfCanvases()->Remove(old); delete old;}
859 
860  if (fWindowWidth == 0) {
861  if (fCw !=0) fWindowWidth = fCw+4;
862  else fWindowWidth = 800;
863  }
864  if (fWindowHeight == 0) {
865  if (fCh !=0) fWindowHeight = fCh+28;
866  else fWindowHeight = 600;
867  }
868  if (gROOT->IsBatch()) { //We are in Batch mode
870  if (!fCanvasImp) return;
871  fBatch = kTRUE;
872 
873  } else { //normal mode with a screen window
876  if (!fCanvasImp) return;
878  }
879  Build();
880  ResizePad();
882  fCanvasImp->Show();
883  Modified();
884 }
885 
886 ////////////////////////////////////////////////////////////////////////////////
887 /// Draw a clone of this canvas
888 /// A new canvas is created that is a clone of this canvas
889 
891 {
892  TCanvas *newCanvas = (TCanvas*)Clone();
893  newCanvas->SetName();
894 
895  newCanvas->Draw(option);
896  newCanvas->Update();
897  return newCanvas;
898 }
899 
900 ////////////////////////////////////////////////////////////////////////////////
901 /// Draw a clone of this canvas into the current pad
902 /// In an interactive session, select the destination/current pad
903 /// with the middle mouse button, then point to the canvas area to select
904 /// the canvas context menu item DrawClonePad.
905 /// Note that the original canvas may have subpads.
906 
908 {
909  TPad *padsav = (TPad*)gPad;
910  TPad *selpad = (TPad*)gROOT->GetSelectedPad();
911  TPad *pad = padsav;
912  if (pad == this) pad = selpad;
913  if (padsav == 0 || pad == 0 || pad == this) {
914  TCanvas *newCanvas = (TCanvas*)DrawClone();
916  return newCanvas;
917  }
918  if (fCanvasID == -1) {
921  if (!fCanvasImp) return 0;
924  }
925  this->cd();
926  TObject *obj, *clone;
927  //copy pad attributes
928  pad->Range(fX1,fY1,fX2,fY2);
929  pad->SetTickx(GetTickx());
930  pad->SetTicky(GetTicky());
931  pad->SetGridx(GetGridx());
932  pad->SetGridy(GetGridy());
933  pad->SetLogx(GetLogx());
934  pad->SetLogy(GetLogy());
935  pad->SetLogz(GetLogz());
938  TAttLine::Copy((TAttLine&)*pad);
939  TAttFill::Copy((TAttFill&)*pad);
940  TAttPad::Copy((TAttPad&)*pad);
941 
942  //copy primitives
943  TIter next(GetListOfPrimitives());
944  while ((obj=next())) {
945  pad->cd();
946  clone = obj->Clone();
947  pad->GetListOfPrimitives()->Add(clone,next.GetOption());
948  }
949  pad->ResizePad();
950  pad->Modified();
951  pad->Update();
952  if (padsav) padsav->cd();
953  return 0;
954 }
955 
956 ////////////////////////////////////////////////////////////////////////////////
957 /// Report name and title of primitive below the cursor.
958 ///
959 /// This function is called when the option "Event Status"
960 /// in the canvas menu "Options" is selected.
961 
962 void TCanvas::DrawEventStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
963 {
964  const Int_t kTMAX=256;
965  static char atext[kTMAX];
966 
967  if (!TestBit(kShowEventStatus) || !selected) return;
968 
969  if (!fCanvasImp) return; //this may happen when closing a TAttCanvas
970 
971  TVirtualPad* savepad;
972  savepad = gPad;
973  gPad = GetSelectedPad();
974 
975  fCanvasImp->SetStatusText(selected->GetTitle(),0);
976  fCanvasImp->SetStatusText(selected->GetName(),1);
977  if (event == kKeyPress)
978  snprintf(atext, kTMAX, "%c", (char) px);
979  else
980  snprintf(atext, kTMAX, "%d,%d", px, py);
981  fCanvasImp->SetStatusText(atext,2);
982 
983  // Show date/time if TimeDisplay is selected
984  TAxis *xaxis = NULL;
985  if ( selected->InheritsFrom("TH1") )
986  xaxis = ((TH1*)selected)->GetXaxis();
987  else if ( selected->InheritsFrom("TGraph") )
988  xaxis = ((TGraph*)selected)->GetXaxis();
989  else if ( selected->InheritsFrom("TAxis") )
990  xaxis = (TAxis*)selected;
991  if ( xaxis != NULL && xaxis->GetTimeDisplay()) {
992  TString objinfo = selected->GetObjectInfo(px,py);
993  // check if user has overwritten GetObjectInfo and altered
994  // the default text from TObject::GetObjectInfo "x=.. y=.."
995  if (objinfo.Contains("x=") && objinfo.Contains("y=") ) {
996  UInt_t toff = 0;
997  TString time_format(xaxis->GetTimeFormat());
998  // TimeFormat may contain offset: %F2000-01-01 00:00:00
999  Int_t idF = time_format.Index("%F");
1000  if (idF>=0) {
1001  Int_t lnF = time_format.Length();
1002  // minimal check for correct format
1003  if (lnF - idF == 21) {
1004  time_format = time_format(idF+2, lnF);
1005  TDatime dtoff(time_format);
1006  toff = dtoff.Convert();
1007  }
1008  } else {
1009  toff = (UInt_t)gStyle->GetTimeOffset();
1010  }
1011  TDatime dt((UInt_t)gPad->AbsPixeltoX(px) + toff);
1012  snprintf(atext, kTMAX, "%s, y=%g",
1013  dt.AsSQLString(),gPad->AbsPixeltoY(py));
1014  fCanvasImp->SetStatusText(atext,3);
1015  gPad = savepad;
1016  return;
1017  }
1018  }
1019  // default
1020  fCanvasImp->SetStatusText(selected->GetObjectInfo(px,py),3);
1021 
1022  gPad = savepad;
1023 }
1024 
1025 ////////////////////////////////////////////////////////////////////////////////
1026 /// Get editor bar.
1027 
1029 {
1031 }
1032 
1033 ////////////////////////////////////////////////////////////////////////////////
1034 /// Embedded a canvas into a TRootEmbeddedCanvas. This method is only called
1035 /// via TRootEmbeddedCanvas::AdoptCanvas.
1036 
1038 {
1039  // If fCanvasImp already exists, no need to go further.
1040  if(fCanvasImp) return;
1041 
1042  fCanvasID = winid;
1043  fWindowTopX = 0;
1044  fWindowTopY = 0;
1045  fWindowWidth = ww;
1046  fWindowHeight = wh;
1047  fCw = ww;
1048  fCh = wh;
1049  fBatch = kFALSE;
1050  fUpdating = kFALSE;
1051 
1053  if (!fCanvasImp) return;
1054  Build();
1055  Resize();
1056 }
1057 
1058 ////////////////////////////////////////////////////////////////////////////////
1059 /// Generate kMouseEnter and kMouseLeave events depending on the previously
1060 /// selected object and the currently selected object. Does nothing if the
1061 /// selected object does not change.
1062 
1063 void TCanvas::EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
1064 {
1065  if (prevSelObj == fSelected) return;
1066 
1067  TPad *padsav = (TPad *)gPad;
1068  Int_t sevent = fEvent;
1069 
1070  if (prevSelObj) {
1071  gPad = prevSelPad;
1072  prevSelObj->ExecuteEvent(kMouseLeave, fEventX, fEventY);
1073  fEvent = kMouseLeave;
1074  RunAutoExec();
1075  ProcessedEvent(kMouseLeave, fEventX, fEventY, prevSelObj); // emit signal
1076  }
1077 
1078  gPad = fSelectedPad;
1079 
1080  if (fSelected) {
1082  fEvent = kMouseEnter;
1083  RunAutoExec();
1084  ProcessedEvent(kMouseEnter, fEventX, fEventY, fSelected); // emit signal
1085  }
1086 
1087  fEvent = sevent;
1088  gPad = padsav;
1089 }
1090 
1091 ////////////////////////////////////////////////////////////////////////////////
1092 /// Execute action corresponding to one event.
1093 ///
1094 /// This member function must be implemented to realize the action
1095 /// corresponding to the mouse click on the object in the canvas
1096 ///
1097 /// Only handle mouse motion events in TCanvas, all other events are
1098 /// ignored for the time being
1099 
1101 {
1102  if (gROOT->GetEditorMode()) {
1103  TPad::ExecuteEvent(event,px,py);
1104  return;
1105  }
1106 
1107  switch (event) {
1108 
1109  case kMouseMotion:
1110  SetCursor(kCross);
1111  break;
1112  }
1113 }
1114 
1115 ////////////////////////////////////////////////////////////////////////////////
1116 /// Turn rubberband feedback mode on or off.
1117 
1119 {
1120  if (set) {
1121  SetDoubleBuffer(0); // turn off double buffer mode
1122  gVirtualX->SetDrawMode(TVirtualX::kInvert); // set the drawing mode to XOR mode
1123  } else {
1124  SetDoubleBuffer(1); // turn on double buffer mode
1125  gVirtualX->SetDrawMode(TVirtualX::kCopy); // set drawing mode back to normal (copy) mode
1126  }
1127 }
1128 
1129 ////////////////////////////////////////////////////////////////////////////////
1130 /// Flush canvas buffers.
1131 
1133 {
1134  if ((fCanvasID == -1) || IsWeb()) return;
1135 
1136  TPad *padsav = (TPad*)gPad;
1137  cd();
1138  if (!IsBatch()) {
1139  if (!UseGL()) {
1140  gVirtualX->SelectWindow(fCanvasID);
1141  gPad = padsav; //don't do cd() because than also the pixmap is changed
1142  CopyPixmaps();
1143  gVirtualX->UpdateWindow(1);
1144  } else {
1145  TVirtualPS *tvps = gVirtualPS;
1146  gVirtualPS = 0;
1147  gGLManager->MakeCurrent(fGLDevice);
1148  fPainter->InitPainter();
1149  Paint();
1150  if (padsav && padsav->GetCanvas() == this) {
1151  padsav->cd();
1152  padsav->HighLight(padsav->GetHighLightColor());
1153  //cd();
1154  }
1155  fPainter->LockPainter();
1156  gGLManager->Flush(fGLDevice);
1157  gVirtualPS = tvps;
1158  }
1159  }
1160  if (padsav) padsav->cd();
1161 }
1162 
1163 ////////////////////////////////////////////////////////////////////////////////
1164 /// Force canvas update
1165 
1167 {
1169 }
1170 
1171 ////////////////////////////////////////////////////////////////////////////////
1172 /// Force a copy of current style for all objects in canvas.
1173 
1175 {
1176  if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
1177  gInterpreter->Execute(this, IsA(), "UseCurrentStyle", "");
1178  return;
1179  }
1180 
1182 
1184 
1185  if (gStyle->IsReading()) {
1189  } else {
1193  }
1194 }
1195 
1196 ////////////////////////////////////////////////////////////////////////////////
1197 /// Returns current top x position of window on screen.
1198 
1200 {
1203 
1204  return fWindowTopX;
1205 }
1206 
1207 ////////////////////////////////////////////////////////////////////////////////
1208 /// Returns current top y position of window on screen.
1209 
1211 {
1214 
1215  return fWindowTopY;
1216 }
1217 
1218 ////////////////////////////////////////////////////////////////////////////////
1219 /// Handle Input Events.
1220 ///
1221 /// Handle input events, like button up/down in current canvas.
1222 
1224 {
1225  TPad *pad;
1226  TPad *prevSelPad = (TPad*) fSelectedPad;
1227  TObject *prevSelObj = fSelected;
1228 
1229  fPadSave = (TPad*)gPad;
1230  cd(); // make sure this canvas is the current canvas
1231 
1232  fEvent = event;
1233  fEventX = px;
1234  fEventY = py;
1235 
1236  switch (event) {
1237 
1238  case kMouseMotion:
1239  // highlight object tracked over
1240  pad = Pick(px, py, prevSelObj);
1241  if (!pad) return;
1242 
1243  EnterLeave(prevSelPad, prevSelObj);
1244 
1245  gPad = pad; // don't use cd() we will use the current
1246  // canvas via the GetCanvas member and not via
1247  // gPad->GetCanvas
1248 
1249  if (fSelected) {
1250  fSelected->ExecuteEvent(event, px, py);
1251  RunAutoExec();
1252  }
1253 
1254  break;
1255 
1256  case kMouseEnter:
1257  // mouse enters canvas
1259  break;
1260 
1261  case kMouseLeave:
1262  // mouse leaves canvas
1263  {
1264  // force popdown of tooltips
1265  TObject *sobj = fSelected;
1266  TPad *spad = fSelectedPad;
1267  fSelected = 0;
1268  fSelectedPad = 0;
1269  EnterLeave(prevSelPad, prevSelObj);
1270  fSelected = sobj;
1271  fSelectedPad = spad;
1273  }
1274  break;
1275 
1276  case kButton1Double:
1277  // triggered on the second button down within 350ms and within
1278  // 3x3 pixels of the first button down, button up finishes action
1279 
1280  case kButton1Down:
1281  // find pad in which input occurred
1282  pad = Pick(px, py, prevSelObj);
1283  if (!pad) return;
1284 
1285  gPad = pad; // don't use cd() because we won't draw in pad
1286  // we will only use its coordinate system
1287 
1288  if (fSelected) {
1289  FeedbackMode(kTRUE); // to draw in rubberband mode
1290  fSelected->ExecuteEvent(event, px, py);
1291 
1292  RunAutoExec();
1293  }
1294 
1295  break;
1296 
1297  case kArrowKeyPress:
1298  case kArrowKeyRelease:
1299  case kButton1Motion:
1300  case kButton1ShiftMotion: //8 == kButton1Motion + shift modifier
1301  if (fSelected) {
1302  gPad = fSelectedPad;
1303 
1304  fSelected->ExecuteEvent(event, px, py);
1305  gVirtualX->Update();
1307  Bool_t resize = kFALSE;
1309  resize = ((TBox*)fSelected)->IsBeingResized();
1311  resize = ((TVirtualPad*)fSelected)->IsBeingResized();
1312 
1313  if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) {
1314  gPad = fPadSave;
1315  Update();
1317  }
1318  }
1319 
1320  RunAutoExec();
1321  }
1322 
1323  break;
1324 
1325  case kButton1Up:
1326 
1327  if (fSelected) {
1328  gPad = fSelectedPad;
1329 
1330  fSelected->ExecuteEvent(event, px, py);
1331 
1332  RunAutoExec();
1333 
1334  if (fPadSave)
1335  gPad = fPadSave;
1336  else {
1337  gPad = this;
1338  fPadSave = this;
1339  }
1340 
1341  Update(); // before calling update make sure gPad is reset
1342  }
1343  break;
1344 
1345 //*-*----------------------------------------------------------------------
1346 
1347  case kButton2Down:
1348  // find pad in which input occurred
1349  pad = Pick(px, py, prevSelObj);
1350  if (!pad) return;
1351 
1352  gPad = pad; // don't use cd() because we won't draw in pad
1353  // we will only use its coordinate system
1354 
1356 
1357  if (fSelected) fSelected->Pop(); // pop object to foreground
1358  pad->cd(); // and make its pad the current pad
1359  if (gDebug)
1360  printf("Current Pad: %s / %s\n", pad->GetName(), pad->GetTitle());
1361 
1362  // loop over all canvases to make sure that only one pad is highlighted
1363  {
1364  TIter next(gROOT->GetListOfCanvases());
1365  TCanvas *tc;
1366  while ((tc = (TCanvas *)next()))
1367  tc->Update();
1368  }
1369 
1370  //if (pad->GetGLDevice() != -1 && fSelected)
1371  // fSelected->ExecuteEvent(event, px, py);
1372 
1373  break; // don't want fPadSave->cd() to be executed at the end
1374 
1375  case kButton2Motion:
1376  //was empty!
1377  case kButton2Up:
1378  if (fSelected) {
1379  gPad = fSelectedPad;
1380 
1381  fSelected->ExecuteEvent(event, px, py);
1382  RunAutoExec();
1383  }
1384  break;
1385 
1386  case kButton2Double:
1387  break;
1388 
1389 //*-*----------------------------------------------------------------------
1390 
1391  case kButton3Down:
1392  // popup context menu
1393  pad = Pick(px, py, prevSelObj);
1394  if (!pad) return;
1395 
1397 
1400  fContextMenu->Popup(px, py, fSelected, this, pad);
1401 
1402  break;
1403 
1404  case kButton3Motion:
1405  break;
1406 
1407  case kButton3Up:
1409  break;
1410 
1411  case kButton3Double:
1412  break;
1413 
1414  case kKeyPress:
1415  if (!fSelectedPad || !fSelected) return;
1416  gPad = fSelectedPad; // don't use cd() because we won't draw in pad
1417  // we will only use its coordinate system
1418  fSelected->ExecuteEvent(event, px, py);
1419 
1420  RunAutoExec();
1421 
1422  break;
1423 
1424  case kButton1Shift:
1425  // Try to select
1426  pad = Pick(px, py, prevSelObj);
1427 
1428  if (!pad) return;
1429 
1430  EnterLeave(prevSelPad, prevSelObj);
1431 
1432  gPad = pad; // don't use cd() we will use the current
1433  // canvas via the GetCanvas member and not via
1434  // gPad->GetCanvas
1435  if (fSelected) {
1436  fSelected->ExecuteEvent(event, px, py);
1437  RunAutoExec();
1438  }
1439  break;
1440 
1441  case kWheelUp:
1442  case kWheelDown:
1443  pad = Pick(px, py, prevSelObj);
1444  if (!pad) return;
1445 
1446  gPad = pad;
1447  if (fSelected)
1448  fSelected->ExecuteEvent(event, px, py);
1449  break;
1450 
1451  default:
1452  break;
1453  }
1454 
1455  if (fPadSave && event != kButton2Down)
1456  fPadSave->cd();
1457 
1458  if (event != kMouseLeave) { // signal was already emitted for this event
1459  ProcessedEvent(event, px, py, fSelected); // emit signal
1460  DrawEventStatus(event, px, py, fSelected);
1461  }
1462 }
1463 
1464 ////////////////////////////////////////////////////////////////////////////////
1465 /// Iconify canvas
1466 
1468 {
1469  if (fCanvasImp)
1470  fCanvasImp->Iconify();
1471 }
1472 
1473 ////////////////////////////////////////////////////////////////////////////////
1474 /// Is folder ?
1475 
1477 {
1478  return fgIsFolder;
1479 }
1480 
1481 ////////////////////////////////////////////////////////////////////////////////
1482 /// Is web canvas
1483 
1485 {
1486  return fCanvasImp ? fCanvasImp->IsWeb() : kFALSE;
1487 }
1488 
1489 ////////////////////////////////////////////////////////////////////////////////
1490 /// List all pads.
1491 
1492 void TCanvas::ls(Option_t *option) const
1493 {
1495  std::cout <<"Canvas Name=" <<GetName()<<" Title="<<GetTitle()<<" Option="<<option<<std::endl;
1497  TPad::ls(option);
1499 }
1500 
1501 ////////////////////////////////////////////////////////////////////////////////
1502 /// Static function to build a default canvas.
1503 
1505 {
1506  const char *defcanvas = gROOT->GetDefCanvasName();
1507  char *cdef;
1508 
1509  auto lc = (TList*)gROOT->GetListOfCanvases();
1510  if (lc->FindObject(defcanvas)) {
1511  Int_t n = lc->GetSize() + 1;
1512  cdef = new char[strlen(defcanvas)+15];
1513  do {
1514  strlcpy(cdef,Form("%s_n%d", defcanvas, n++),strlen(defcanvas)+15);
1515  } while (lc->FindObject(cdef));
1516  } else
1517  cdef = StrDup(Form("%s",defcanvas));
1518 
1519  TCanvas *c = new TCanvas(cdef, cdef, 1);
1520 
1521  ::Info("TCanvas::MakeDefCanvas"," created default TCanvas with name %s",cdef);
1522  delete [] cdef;
1523  return c;
1524 }
1525 
1526 ////////////////////////////////////////////////////////////////////////////////
1527 /// Set option to move objects/pads in a canvas.
1528 ///
1529 /// - set = 1 (default) graphics objects are moved in opaque mode
1530 /// - set = 0 only the outline of objects is drawn when moving them
1531 ///
1532 /// The option opaque produces the best effect. It requires however a
1533 /// a reasonably fast workstation or response time.
1534 
1536 {
1537  SetBit(kMoveOpaque,set);
1538 }
1539 
1540 ////////////////////////////////////////////////////////////////////////////////
1541 /// Paint canvas.
1542 
1544 {
1545  if (fCanvas)
1546  TPad::Paint(option);
1547 }
1548 
1549 ////////////////////////////////////////////////////////////////////////////////
1550 /// Prepare for pick, call TPad::Pick() and when selected object
1551 /// is different from previous then emit Picked() signal.
1552 
1553 TPad *TCanvas::Pick(Int_t px, Int_t py, TObject *prevSelObj)
1554 {
1555  TObjLink *pickobj = 0;
1556 
1557  fSelected = 0;
1558  fSelectedOpt = "";
1559  fSelectedPad = 0;
1560 
1561  TPad *pad = Pick(px, py, pickobj);
1562  if (!pad) return 0;
1563 
1564  if (!pickobj) {
1565  fSelected = pad;
1566  fSelectedOpt = "";
1567  } else {
1568  if (!fSelected) { // can be set via TCanvas::SetSelected()
1569  fSelected = pickobj->GetObject();
1570  fSelectedOpt = pickobj->GetOption();
1571  }
1572  }
1573  fSelectedPad = pad;
1574 
1575  if (fSelected != prevSelObj)
1576  Picked(fSelectedPad, fSelected, fEvent); // emit signal
1577 
1578  if ((fEvent == kButton1Down) || (fEvent == kButton2Down) || (fEvent == kButton3Down)) {
1582  Selected(fSelectedPad, fSelected, fEvent); // emit signal
1583  fSelectedX = px;
1584  fSelectedY = py;
1585  }
1586  }
1587  return pad;
1588 }
1589 
1590 ////////////////////////////////////////////////////////////////////////////////
1591 /// Emit Picked() signal.
1592 
1593 void TCanvas::Picked(TPad *pad, TObject *obj, Int_t event)
1594 {
1595  Long_t args[3];
1596 
1597  args[0] = (Long_t) pad;
1598  args[1] = (Long_t) obj;
1599  args[2] = event;
1600 
1601  Emit("Picked(TPad*,TObject*,Int_t)", args);
1602 }
1603 
1604 ////////////////////////////////////////////////////////////////////////////////
1605 /// Emit Highlighted() signal.
1606 ///
1607 /// - pad is pointer to pad with highlighted histogram or graph
1608 /// - obj is pointer to highlighted histogram or graph
1609 /// - x is highlighted x bin for 1D histogram or highlighted x-th point for graph
1610 /// - y is highlighted y bin for 2D histogram (for 1D histogram or graph not in use)
1611 
1613 {
1614  Long_t args[4];
1615 
1616  args[0] = (Long_t) pad;
1617  args[1] = (Long_t) obj;
1618  args[2] = x;
1619  args[3] = y;
1620 
1621  Emit("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", args);
1622 }
1623 
1624 ////////////////////////////////////////////////////////////////////////////////
1625 /// This is "simplification" for function TCanvas::Connect with Highlighted
1626 /// signal for specific slot.
1627 ///
1628 /// Slot has to be defined "UserFunction(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)"
1629 /// all parameters of UserFunction are taken from TCanvas::Highlighted
1630 
1631 void TCanvas::HighlightConnect(const char *slot)
1632 {
1633  Connect("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", 0, 0, slot);
1634 }
1635 
1636 ////////////////////////////////////////////////////////////////////////////////
1637 /// Emit Selected() signal.
1638 
1640 {
1641  Long_t args[3];
1642 
1643  args[0] = (Long_t) pad;
1644  args[1] = (Long_t) obj;
1645  args[2] = event;
1646 
1647  Emit("Selected(TVirtualPad*,TObject*,Int_t)", args);
1648 }
1649 
1650 ////////////////////////////////////////////////////////////////////////////////
1651 /// Emit ProcessedEvent() signal.
1652 
1654 {
1655  Long_t args[4];
1656 
1657  args[0] = event;
1658  args[1] = x;
1659  args[2] = y;
1660  args[3] = (Long_t) obj;
1661 
1662  Emit("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", args);
1663 }
1664 
1665 ////////////////////////////////////////////////////////////////////////////////
1666 /// Recompute canvas parameters following a X11 Resize.
1667 
1669 {
1670  if (fCanvasID == -1) return;
1671 
1672  if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
1673  gInterpreter->Execute(this, IsA(), "Resize", "");
1674  return;
1675  }
1676 
1678 
1679  TPad *padsav = (TPad*)gPad;
1680  cd();
1681 
1682  if (!IsBatch()) {
1683  gVirtualX->SelectWindow(fCanvasID); //select current canvas
1684  gVirtualX->ResizeWindow(fCanvasID); //resize canvas and off-screen buffer
1685 
1686  // Get effective window parameters including menubar and borders
1689 
1690  // Get effective canvas parameters without borders
1691  Int_t dum1, dum2;
1692  gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
1693  }
1694 
1695  if (fXsizeUser && fYsizeUser) {
1696  UInt_t nwh = fCh;
1697  UInt_t nww = fCw;
1699  if (rxy < 1) {
1700  UInt_t twh = UInt_t(Double_t(fCw)/rxy);
1701  if (twh > fCh)
1702  nww = UInt_t(Double_t(fCh)*rxy);
1703  else
1704  nwh = twh;
1705  if (nww > fCw) {
1706  nww = fCw; nwh = twh;
1707  }
1708  if (nwh > fCh) {
1709  nwh = fCh; nww = UInt_t(Double_t(fCh)/rxy);
1710  }
1711  } else {
1712  UInt_t twh = UInt_t(Double_t(fCw)*rxy);
1713  if (twh > fCh)
1714  nwh = UInt_t(Double_t(fCw)/rxy);
1715  else
1716  nww = twh;
1717  if (nww > fCw) {
1718  nww = fCw; nwh = twh;
1719  }
1720  if (nwh > fCh) {
1721  nwh = fCh; nww = UInt_t(Double_t(fCh)*rxy);
1722  }
1723  }
1724  fCw = nww;
1725  fCh = nwh;
1726  }
1727 
1728  if (fCw < fCh) {
1731  }
1732  else {
1735  }
1736 
1737 //*-*- Loop on all pads to recompute conversion coefficients
1738  TPad::ResizePad();
1739 
1740  if (padsav) padsav->cd();
1741 }
1742 
1743 
1744 ////////////////////////////////////////////////////////////////////////////////
1745 /// Raise canvas window
1746 
1748 {
1749  if (fCanvasImp)
1751 }
1752 
1753 ////////////////////////////////////////////////////////////////////////////////
1754 /// Set option to resize objects/pads in a canvas.
1755 ///
1756 /// - set = 1 (default) graphics objects are resized in opaque mode
1757 /// - set = 0 only the outline of objects is drawn when resizing them
1758 ///
1759 /// The option opaque produces the best effect. It requires however a
1760 /// a reasonably fast workstation or response time.
1761 
1763 {
1764  SetBit(kResizeOpaque,set);
1765 }
1766 
1767 ////////////////////////////////////////////////////////////////////////////////
1768 /// Execute the list of TExecs in the current pad.
1769 
1771 {
1772  if (!TestBit(kAutoExec)) return;
1773  if (!gPad) return;
1774  ((TPad*)gPad)->AutoExec();
1775 }
1776 
1777 
1778 ////////////////////////////////////////////////////////////////////////////////
1779 /// Save primitives in this canvas in C++ macro file with GUI.
1780 
1781 void TCanvas::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1782 {
1783  // Write canvas options (in $TROOT or $TStyle)
1784  if (gStyle->GetOptFit()) {
1785  out<<" gStyle->SetOptFit(1);"<<std::endl;
1786  }
1787  if (!gStyle->GetOptStat()) {
1788  out<<" gStyle->SetOptStat(0);"<<std::endl;
1789  }
1790  if (!gStyle->GetOptTitle()) {
1791  out<<" gStyle->SetOptTitle(0);"<<std::endl;
1792  }
1793  if (gROOT->GetEditHistograms()) {
1794  out<<" gROOT->SetEditHistograms();"<<std::endl;
1795  }
1796  if (GetShowEventStatus()) {
1797  out<<" "<<GetName()<<"->ToggleEventStatus();"<<std::endl;
1798  }
1799  if (GetShowToolTips()) {
1800  out<<" "<<GetName()<<"->ToggleToolTips();"<<std::endl;
1801  }
1802  if (GetShowToolBar()) {
1803  out<<" "<<GetName()<<"->ToggleToolBar();"<<std::endl;
1804  }
1805  if (GetHighLightColor() != 5) {
1806  if (GetHighLightColor() > 228) {
1808  out<<" "<<GetName()<<"->SetHighLightColor(ci);" << std::endl;
1809  } else
1810  out<<" "<<GetName()<<"->SetHighLightColor("<<GetHighLightColor()<<");"<<std::endl;
1811  }
1812 
1813  // Now recursively scan all pads of this canvas
1814  cd();
1815  TPad::SavePrimitive(out,option);
1816 }
1817 
1818 ////////////////////////////////////////////////////////////////////////////////
1819 /// Save primitives in this canvas as a C++ macro file.
1820 /// This function loops on all the canvas primitives and for each primitive
1821 /// calls the object SavePrimitive function.
1822 /// When outputting floating point numbers, the default precision is 7 digits.
1823 /// The precision can be changed (via system.rootrc) by changing the value
1824 /// of the environment variable "Canvas.SavePrecision"
1825 
1826 void TCanvas::SaveSource(const char *filename, Option_t *option)
1827 {
1828  // reset bit TClass::kClassSaved for all classes
1829  TIter next(gROOT->GetListOfClasses());
1830  TClass *cl;
1831  while((cl = (TClass*)next())) {
1833  }
1834 
1835  char quote = '"';
1836  std::ofstream out;
1837  Int_t lenfile = strlen(filename);
1838  char * fname;
1839  char lcname[10];
1840  const char *cname = GetName();
1841  Bool_t invalid = kFALSE;
1842  // if filename is given, open this file, otherwise create a file
1843  // with a name equal to the canvasname.C
1844  if (lenfile) {
1845  fname = (char*)filename;
1846  out.open(fname, std::ios::out);
1847  } else {
1848  Int_t nch = strlen(cname);
1849  if (nch < 10) {
1850  strlcpy(lcname,cname,10);
1851  for (Int_t k=1;k<=nch;k++) {if (lcname[nch-k] == ' ') lcname[nch-k] = 0;}
1852  if (lcname[0] == 0) {invalid = kTRUE; strlcpy(lcname,"c1",10); nch = 2;}
1853  cname = lcname;
1854  }
1855  fname = new char[nch+3];
1856  strlcpy(fname,cname,nch+3);
1857  strncat(fname,".C",3);
1858  out.open(fname, std::ios::out);
1859  }
1860  if (!out.good ()) {
1861  Error("SaveSource", "Cannot open file: %s",fname);
1862  if (!lenfile) delete [] fname;
1863  return;
1864  }
1865 
1866  //set precision
1867  Int_t precision = gEnv->GetValue("Canvas.SavePrecision",7);
1868  out.precision(precision);
1869 
1870  // Write macro header and date/time stamp
1871  TDatime t;
1872  Float_t cx = gStyle->GetScreenFactor();
1873  Int_t topx,topy;
1874  UInt_t w, h;
1875  if (!fCanvasImp) {
1876  Error("SaveSource", "Cannot open TCanvas");
1877  return;
1878  }
1879  UInt_t editorWidth = fCanvasImp->GetWindowGeometry(topx,topy,w,h);
1880  w = UInt_t((fWindowWidth - editorWidth)/cx);
1881  h = UInt_t((fWindowHeight)/cx);
1882  topx = GetWindowTopX();
1883  topy = GetWindowTopY();
1884 
1885  if (w == 0) {
1886  w = GetWw()+4; h = GetWh()+4;
1887  topx = 1; topy = 1;
1888  }
1889 
1890  TString mname(fname);
1891 // out <<"#ifdef __CLING__"<<std::endl;
1892 // out <<"#pragma cling optimize(0)"<<std::endl;
1893 // out <<"#endif"<<std::endl;
1894 // out <<""<<std::endl;
1895  Int_t p = mname.Last('.');
1896  Int_t s = mname.Last('/')+1;
1897 
1898  // A named macro is generated only if the function name is valid. If not, the
1899  // macro is unnamed.
1900  TString first(mname(s,s+1));
1901  if (!first.IsDigit()) out <<"void " << mname(s,p-s) << "()" << std::endl;
1902 
1903  out <<"{"<<std::endl;
1904  out <<"//=========Macro generated from canvas: "<<GetName()<<"/"<<GetTitle()<<std::endl;
1905  out <<"//========= ("<<t.AsString()<<") by ROOT version "<<gROOT->GetVersion()<<std::endl;
1906 
1907  if (gStyle->GetCanvasPreferGL())
1908  out <<std::endl<<" gStyle->SetCanvasPreferGL(kTRUE);"<<std::endl<<std::endl;
1909 
1910  // Write canvas parameters (TDialogCanvas case)
1912  out<<" "<<ClassName()<<" *"<<cname<<" = new "<<ClassName()<<"("<<quote<<GetName()
1913  <<quote<<", "<<quote<<GetTitle()<<quote<<","<<w<<","<<h<<");"<<std::endl;
1914  } else {
1915  // Write canvas parameters (TCanvas case)
1916  out<<" TCanvas *"<<cname<<" = new TCanvas("<<quote<<GetName()<<quote<<", "<<quote<<GetTitle()
1917  <<quote;
1918  if (!HasMenuBar())
1919  out<<",-"<<topx<<","<<topy<<","<<w<<","<<h<<");"<<std::endl;
1920  else
1921  out<<","<<topx<<","<<topy<<","<<w<<","<<h<<");"<<std::endl;
1922  }
1923  // Write canvas options (in $TROOT or $TStyle)
1924  if (gStyle->GetOptFit()) {
1925  out<<" gStyle->SetOptFit(1);"<<std::endl;
1926  }
1927  if (!gStyle->GetOptStat()) {
1928  out<<" gStyle->SetOptStat(0);"<<std::endl;
1929  }
1930  if (!gStyle->GetOptTitle()) {
1931  out<<" gStyle->SetOptTitle(0);"<<std::endl;
1932  }
1933  if (gROOT->GetEditHistograms()) {
1934  out<<" gROOT->SetEditHistograms();"<<std::endl;
1935  }
1936  if (GetShowEventStatus()) {
1937  out<<" "<<GetName()<<"->ToggleEventStatus();"<<std::endl;
1938  }
1939  if (GetShowToolTips()) {
1940  out<<" "<<GetName()<<"->ToggleToolTips();"<<std::endl;
1941  }
1942  if (GetHighLightColor() != 5) {
1943  if (GetHighLightColor() > 228) {
1945  out<<" "<<GetName()<<"->SetHighLightColor(ci);" << std::endl;
1946  } else
1947  out<<" "<<GetName()<<"->SetHighLightColor("<<GetHighLightColor()<<");"<<std::endl;
1948  }
1949 
1950  // Now recursively scan all pads of this canvas
1951  cd();
1952  if (invalid) SetName("c1");
1953  TPad::SavePrimitive(out,option);
1954  // Write canvas options related to pad editor
1955  out<<" "<<GetName()<<"->SetSelected("<<GetName()<<");"<<std::endl;
1956  if (GetShowToolBar()) {
1957  out<<" "<<GetName()<<"->ToggleToolBar();"<<std::endl;
1958  }
1959  if (invalid) SetName(" ");
1960 
1961  out <<"}"<<std::endl;
1962  out.close();
1963  Info("SaveSource","C++ Macro file: %s has been generated", fname);
1964 
1965  // reset bit TClass::kClassSaved for all classes
1966  next.Reset();
1967  while((cl = (TClass*)next())) {
1969  }
1970  if (!lenfile) delete [] fname;
1971 }
1972 
1973 ////////////////////////////////////////////////////////////////////////////////
1974 /// Toggle batch mode. However, if the canvas is created without a window
1975 /// then batch mode always stays set.
1976 
1978 {
1979  if (gROOT->IsBatch() || IsWeb())
1980  fBatch = kTRUE;
1981  else
1982  fBatch = batch;
1983 }
1984 
1985 ////////////////////////////////////////////////////////////////////////////////
1986 /// Set Width and Height of canvas to ww and wh respectively. If ww and/or wh
1987 /// are greater than the current canvas window a scroll bar is automatically
1988 /// generated. Use this function to zoom in a canvas and navigate via
1989 /// the scroll bars. The Width and Height in this method are different from those
1990 /// given in the TCanvas constructors where these two dimension include the size
1991 /// of the window decoration whereas they do not in this method.
1992 
1994 {
1995  if (fCanvasImp) {
1996  fCanvasImp->SetCanvasSize(ww, wh);
1997  fCw = ww;
1998  fCh = wh;
1999  ResizePad();
2000  }
2001 }
2002 
2003 ////////////////////////////////////////////////////////////////////////////////
2004 /// Set cursor.
2005 
2007 {
2008  if (IsBatch()) return;
2009  gVirtualX->SetCursor(fCanvasID, cursor);
2010 }
2011 
2012 ////////////////////////////////////////////////////////////////////////////////
2013 /// Set Double Buffer On/Off.
2014 
2016 {
2017  if (IsBatch()) return;
2018  fDoubleBuffer = mode;
2019  gVirtualX->SetDoubleBuffer(fCanvasID, mode);
2020 
2021  // depending of the buffer mode set the drawing window to either
2022  // the canvas pixmap or to the canvas on-screen window
2023  if (fDoubleBuffer) {
2025  } else
2027 }
2028 
2029 ////////////////////////////////////////////////////////////////////////////////
2030 /// Fix canvas aspect ratio to current value if fixed is true.
2031 
2033 {
2034  if (fixed) {
2035  if (!fFixedAspectRatio) {
2036  if (fCh != 0)
2038  else {
2039  Error("SetAspectRatio", "cannot fix aspect ratio, height of canvas is 0");
2040  return;
2041  }
2043  }
2044  } else {
2046  fAspectRatio = 0;
2047  }
2048 }
2049 
2050 ////////////////////////////////////////////////////////////////////////////////
2051 /// If isfolder=kTRUE, the canvas can be browsed like a folder
2052 /// by default a canvas is not browsable.
2053 
2055 {
2056  fgIsFolder = isfolder;
2057 }
2058 
2059 ////////////////////////////////////////////////////////////////////////////////
2060 /// Set canvas name. In case `name` is an empty string, a default name is set.
2061 
2062 void TCanvas::SetName(const char *name)
2063 {
2064  if (!name || !name[0]) {
2065  const char *defcanvas = gROOT->GetDefCanvasName();
2066  char *cdef;
2067  auto lc = (TList*)gROOT->GetListOfCanvases();
2068  if (lc->FindObject(defcanvas)) {
2069  cdef = Form("%s_n%d",defcanvas,lc->GetSize()+1);
2070  } else {
2071  cdef = Form("%s",defcanvas);
2072  }
2073  fName = cdef;
2074  } else {
2075  fName = name;
2076  }
2077  if (gPad && TestBit(kMustCleanup)) gPad->Modified();
2078 }
2079 
2080 
2081 ////////////////////////////////////////////////////////////////////////////////
2082 /// Function to resize a canvas so that the plot inside is shown in real aspect
2083 /// ratio
2084 ///
2085 /// \param[in] axis 1 for resizing horizontally (x-axis) in order to get real
2086 /// aspect ratio, 2 for the resizing vertically (y-axis)
2087 /// \return false if error is encountered, true otherwise
2088 ///
2089 /// ~~~ {.cpp}
2090 /// hpxpy->Draw();
2091 /// c1->SetRealAspectRatio();
2092 /// ~~~
2093 ///
2094 /// - For defining the concept of real aspect ratio, it is assumed that x and y
2095 /// axes are in same units, e.g. both in MeV or both in ns.
2096 /// - You can resize either the width of the canvas or the height, but not both
2097 /// at the same time
2098 /// - Call this function AFTER drawing AND zooming (SetUserRange) your TGraph or
2099 /// Histogram, otherwise it cannot infer your actual axes lengths
2100 /// - This function ensures that the TFrame has a real aspect ratio, this does not
2101 /// mean that the full pad (i.e. the canvas or png output) including margins has
2102 /// exactly the same ratio
2103 /// - This function does not work if the canvas is divided in several subpads
2104 
2106 {
2107  Update();
2108 
2109  //Get how many pixels are occupied by the canvas
2110  Int_t npx = GetWw();
2111  Int_t npy = GetWh();
2112 
2113  //Get x-y coordinates at the edges of the canvas (extrapolating outside the axes, NOT at the edges of the histogram)
2114  Double_t x1 = GetX1();
2115  Double_t y1 = GetY1();
2116  Double_t x2 = GetX2();
2117  Double_t y2 = GetY2();
2118 
2119  //Get the length of extrapolated x and y axes
2120  Double_t xlength2 = x2 - x1;
2121  Double_t ylength2 = y2 - y1;
2122  Double_t ratio2 = xlength2/ylength2;
2123 
2124  //Now get the number of pixels including the canvas borders
2125  Int_t bnpx = GetWindowWidth();
2126  Int_t bnpy = GetWindowHeight();
2127 
2128  if (axis==1) {
2129  SetCanvasSize(TMath::Nint(npy*ratio2), npy);
2130  SetWindowSize((bnpx-npx)+TMath::Nint(npy*ratio2), bnpy);
2131  } else if (axis==2) {
2132  SetCanvasSize(npx, TMath::Nint(npx/ratio2));
2133  SetWindowSize(bnpx, (bnpy-npy)+TMath::Nint(npx/ratio2));
2134  } else {
2135  Error("SetRealAspectRatio", "axis value %d is neither 1 (resize along x-axis) nor 2 (resize along y-axis).",axis);
2136  return false;
2137  }
2138 
2139  //Check now that resizing has worked
2140 
2141  Update();
2142 
2143  //Get how many pixels are occupied by the canvas
2144  npx = GetWw();
2145  npy = GetWh();
2146 
2147  //Get x-y coordinates at the edges of the canvas (extrapolating outside the axes,
2148  //NOT at the edges of the histogram)
2149  x1 = GetX1();
2150  y1 = GetY1();
2151  x2 = GetX2();
2152  y2 = GetY2();
2153 
2154  //Get the length of extrapolated x and y axes
2155  xlength2 = x2 - x1;
2156  ylength2 = y2 - y1;
2157  ratio2 = xlength2/ylength2;
2158 
2159  //Check accuracy +/-1 pixel due to rounding
2160  if (abs(TMath::Nint(npy*ratio2) - npx)<2) {
2161  return true;
2162  } else {
2163  Error("SetRealAspectRatio", "Resizing failed.");
2164  return false;
2165  }
2166 }
2167 
2168 
2169 ////////////////////////////////////////////////////////////////////////////////
2170 /// Set selected canvas.
2171 
2173 {
2174  fSelected = obj;
2175  if (obj) obj->SetBit(kMustCleanup);
2176 }
2177 
2178 ////////////////////////////////////////////////////////////////////////////////
2179 /// Set canvas title.
2180 
2181 void TCanvas::SetTitle(const char *title)
2182 {
2183  fTitle = title;
2184  if (fCanvasImp) fCanvasImp->SetWindowTitle(title);
2185 }
2186 
2187 ////////////////////////////////////////////////////////////////////////////////
2188 /// Set canvas window position
2189 
2191 {
2192  if (fCanvasImp)
2194 }
2195 
2196 ////////////////////////////////////////////////////////////////////////////////
2197 /// Set canvas window size
2198 
2200 {
2201  if (fBatch)
2202  SetCanvasSize((ww + fCw) / 2, (wh + fCh) / 2);
2203  else if (fCanvasImp)
2204  fCanvasImp->SetWindowSize(ww, wh);
2205 }
2206 
2207 ////////////////////////////////////////////////////////////////////////////////
2208 /// Set the canvas scale in centimeters.
2209 ///
2210 /// This information is used by PostScript to set the page size.
2211 ///
2212 /// \param[in] xsize size of the canvas in centimeters along X
2213 /// \param[in] ysize size of the canvas in centimeters along Y
2214 ///
2215 /// if xsize and ysize are not equal to 0, then the scale factors will
2216 /// be computed to keep the ratio ysize/xsize independently of the canvas
2217 /// size (parts of the physical canvas will be unused).
2218 ///
2219 /// if xsize = 0 and ysize is not zero, then xsize will be computed
2220 /// to fit to the current canvas scale. If the canvas is resized,
2221 /// a new value for xsize will be recomputed. In this case the aspect
2222 /// ratio is not preserved.
2223 ///
2224 /// if both xsize = 0 and ysize = 0, then the scaling is automatic.
2225 /// the largest dimension will be allocated a size of 20 centimeters.
2226 
2227 void TCanvas::Size(Float_t xsize, Float_t ysize)
2228 {
2229  fXsizeUser = xsize;
2230  fYsizeUser = ysize;
2231 
2232  Resize();
2233 }
2234 
2235 ////////////////////////////////////////////////////////////////////////////////
2236 /// Show canvas
2237 
2239 {
2240  if (fCanvasImp)
2241  fCanvasImp->Show();
2242 }
2243 
2244 ////////////////////////////////////////////////////////////////////////////////
2245 /// Stream a class object.
2246 
2247 void TCanvas::Streamer(TBuffer &b)
2248 {
2249  UInt_t R__s, R__c;
2250  if (b.IsReading()) {
2251  Version_t v = b.ReadVersion(&R__s, &R__c);
2252  gPad = this;
2253  fCanvas = this;
2254  if (v>7) b.ClassBegin(TCanvas::IsA());
2255  if (v>7) b.ClassMember("TPad");
2256  TPad::Streamer(b);
2257  gPad = this;
2258  //restore the colors
2259  TObjArray *colors = (TObjArray*)fPrimitives->FindObject("ListOfColors");
2260  if (colors) {
2261  TIter next(colors);
2262  TColor *colold;
2263  while ((colold = (TColor*)next())) {
2264  if (colold) {
2265  Int_t cn = 0;
2266  if (colold) cn = colold->GetNumber();
2267  TColor *colcur = gROOT->GetColor(cn);
2268  if (colcur) {
2269  colcur->SetRGB(colold->GetRed(),colold->GetGreen(),colold->GetBlue());
2270  } else {
2271  colcur = new TColor(cn,colold->GetRed(),
2272  colold->GetGreen(),
2273  colold->GetBlue(),
2274  colold->GetName());
2275  if (!colcur) return;
2276  }
2277  }
2278  }
2279  //restore the palette if needed
2280  TObjArray *currentpalette = (TObjArray*)fPrimitives->FindObject("CurrentColorPalette");
2281  if (currentpalette) {
2282  TIter nextpal(currentpalette);
2283  Int_t n = currentpalette->GetEntries();
2284  TArrayI palcolors(n);
2285  TColor *col = 0;
2286  Int_t i = 0;
2287  while ((col = (TColor*)nextpal())) palcolors[i++] = col->GetNumber();
2288  gStyle->SetPalette(n,palcolors.GetArray());
2289  fPrimitives->Remove(currentpalette);
2290  delete currentpalette;
2291  }
2293  colors->Delete();
2294  delete colors;
2295  }
2296 
2297  if (v>7) b.ClassMember("fDISPLAY","TString");
2298  fDISPLAY.Streamer(b);
2299  if (v>7) b.ClassMember("fDoubleBuffer", "Int_t");
2300  b >> fDoubleBuffer;
2301  if (v>7) b.ClassMember("fRetained", "Bool_t");
2302  b >> fRetained;
2303  if (v>7) b.ClassMember("fXsizeUser", "Size_t");
2304  b >> fXsizeUser;
2305  if (v>7) b.ClassMember("fYsizeUser", "Size_t");
2306  b >> fYsizeUser;
2307  if (v>7) b.ClassMember("fXsizeReal", "Size_t");
2308  b >> fXsizeReal;
2309  if (v>7) b.ClassMember("fYsizeReal", "Size_t");
2310  b >> fYsizeReal;
2311  fCanvasID = -1;
2312  if (v>7) b.ClassMember("fWindowTopX", "Int_t");
2313  b >> fWindowTopX;
2314  if (v>7) b.ClassMember("fWindowTopY", "Int_t");
2315  b >> fWindowTopY;
2316  if (v > 2) {
2317  if (v>7) b.ClassMember("fWindowWidth", "UInt_t");
2318  b >> fWindowWidth;
2319  if (v>7) b.ClassMember("fWindowHeight", "UInt_t");
2320  b >> fWindowHeight;
2321  }
2322  if (v>7) b.ClassMember("fCw", "UInt_t");
2323  b >> fCw;
2324  if (v>7) b.ClassMember("fCh", "UInt_t");
2325  b >> fCh;
2326  if (v <= 2) {
2327  fWindowWidth = fCw;
2328  fWindowHeight = fCh;
2329  }
2330  if (v>7) b.ClassMember("fCatt", "TAttCanvas");
2331  fCatt.Streamer(b);
2332  Bool_t dummy;
2333  if (v>7) b.ClassMember("kMoveOpaque", "Bool_t");
2334  b >> dummy; if (dummy) MoveOpaque(1);
2335  if (v>7) b.ClassMember("kResizeOpaque", "Bool_t");
2336  b >> dummy; if (dummy) ResizeOpaque(1);
2337  if (v>7) b.ClassMember("fHighLightColor", "Color_t");
2338  b >> fHighLightColor;
2339  if (v>7) b.ClassMember("fBatch", "Bool_t");
2340  b >> dummy; //was fBatch
2341  if (v < 2) return;
2342  if (v>7) b.ClassMember("kShowEventStatus", "Bool_t");
2343  b >> dummy; if (dummy) SetBit(kShowEventStatus);
2344 
2345  if (v > 3) {
2346  if (v>7) b.ClassMember("kAutoExec", "Bool_t");
2347  b >> dummy; if (dummy) SetBit(kAutoExec);
2348  }
2349  if (v>7) b.ClassMember("kMenuBar", "Bool_t");
2350  b >> dummy; if (dummy) SetBit(kMenuBar);
2351  fBatch = gROOT->IsBatch();
2352  if (v>7) b.ClassEnd(TCanvas::IsA());
2353  b.CheckByteCount(R__s, R__c, TCanvas::IsA());
2354  } else {
2355  //save list of colors
2356  //we must protect the case when two or more canvases are saved
2357  //in the same buffer. If the list of colors has already been saved
2358  //in the buffer, do not add the list of colors to the list of primitives.
2359  TObjArray *colors = 0;
2360  TObjArray *CurrentColorPalette = 0;
2361  if (TColor::DefinedColors()) {
2362  if (!b.CheckObject(gROOT->GetListOfColors(),TObjArray::Class())) {
2363  colors = (TObjArray*)gROOT->GetListOfColors();
2365  }
2366  //save the current palette
2367  TArrayI pal = TColor::GetPalette();
2368  Int_t palsize = pal.GetSize();
2369  CurrentColorPalette = new TObjArray();
2370  CurrentColorPalette->SetName("CurrentColorPalette");
2371  for (Int_t i=0; i<palsize; i++) CurrentColorPalette->Add(gROOT->GetColor(pal[i]));
2372  fPrimitives->Add(CurrentColorPalette);
2373  }
2374 
2375  R__c = b.WriteVersion(TCanvas::IsA(), kTRUE);
2376  b.ClassBegin(TCanvas::IsA());
2377  b.ClassMember("TPad");
2378  TPad::Streamer(b);
2380  if (CurrentColorPalette) { fPrimitives->Remove(CurrentColorPalette); delete CurrentColorPalette; }
2381  b.ClassMember("fDISPLAY","TString");
2382  fDISPLAY.Streamer(b);
2383  b.ClassMember("fDoubleBuffer", "Int_t");
2384  b << fDoubleBuffer;
2385  b.ClassMember("fRetained", "Bool_t");
2386  b << fRetained;
2387  b.ClassMember("fXsizeUser", "Size_t");
2388  b << fXsizeUser;
2389  b.ClassMember("fYsizeUser", "Size_t");
2390  b << fYsizeUser;
2391  b.ClassMember("fXsizeReal", "Size_t");
2392  b << fXsizeReal;
2393  b.ClassMember("fYsizeReal", "Size_t");
2394  b << fYsizeReal;
2396  Int_t topx = fWindowTopX, topy = fWindowTopY;
2397  UInt_t editorWidth = 0;
2398  if(fCanvasImp) editorWidth = fCanvasImp->GetWindowGeometry(topx,topy,w,h);
2399  b.ClassMember("fWindowTopX", "Int_t");
2400  b << topx;
2401  b.ClassMember("fWindowTopY", "Int_t");
2402  b << topy;
2403  b.ClassMember("fWindowWidth", "UInt_t");
2404  b << (UInt_t)(w-editorWidth);
2405  b.ClassMember("fWindowHeight", "UInt_t");
2406  b << h;
2407  b.ClassMember("fCw", "UInt_t");
2408  b << fCw;
2409  b.ClassMember("fCh", "UInt_t");
2410  b << fCh;
2411  b.ClassMember("fCatt", "TAttCanvas");
2412  fCatt.Streamer(b);
2413  b.ClassMember("kMoveOpaque", "Bool_t");
2414  b << TestBit(kMoveOpaque); //please remove in ROOT version 6
2415  b.ClassMember("kResizeOpaque", "Bool_t");
2416  b << TestBit(kResizeOpaque); //please remove in ROOT version 6
2417  b.ClassMember("fHighLightColor", "Color_t");
2418  b << fHighLightColor;
2419  b.ClassMember("fBatch", "Bool_t");
2420  b << fBatch; //please remove in ROOT version 6
2421  b.ClassMember("kShowEventStatus", "Bool_t");
2422  b << TestBit(kShowEventStatus); //please remove in ROOT version 6
2423  b.ClassMember("kAutoExec", "Bool_t");
2424  b << TestBit(kAutoExec); //please remove in ROOT version 6
2425  b.ClassMember("kMenuBar", "Bool_t");
2426  b << TestBit(kMenuBar); //please remove in ROOT version 6
2427  b.ClassEnd(TCanvas::IsA());
2428  b.SetByteCount(R__c, kTRUE);
2429  }
2430 }
2431 
2432 ////////////////////////////////////////////////////////////////////////////////
2433 /// Toggle pad auto execution of list of TExecs.
2434 
2436 {
2437  Bool_t autoExec = TestBit(kAutoExec);
2438  SetBit(kAutoExec,!autoExec);
2439 }
2440 
2441 ////////////////////////////////////////////////////////////////////////////////
2442 /// Toggle event statusbar.
2443 
2445 {
2446  Bool_t showEventStatus = !TestBit(kShowEventStatus);
2447  SetBit(kShowEventStatus,showEventStatus);
2448 
2449  if (fCanvasImp) fCanvasImp->ShowStatusBar(showEventStatus);
2450 }
2451 
2452 ////////////////////////////////////////////////////////////////////////////////
2453 /// Toggle toolbar.
2454 
2456 {
2457  Bool_t showToolBar = !TestBit(kShowToolBar);
2458  SetBit(kShowToolBar,showToolBar);
2459 
2460  if (fCanvasImp) fCanvasImp->ShowToolBar(showToolBar);
2461 }
2462 
2463 ////////////////////////////////////////////////////////////////////////////////
2464 /// Toggle editor.
2465 
2467 {
2468  Bool_t showEditor = !TestBit(kShowEditor);
2469  SetBit(kShowEditor,showEditor);
2470 
2471  if (fCanvasImp) fCanvasImp->ShowEditor(showEditor);
2472 }
2473 
2474 ////////////////////////////////////////////////////////////////////////////////
2475 /// Toggle tooltip display.
2476 
2478 {
2479  Bool_t showToolTips = !TestBit(kShowToolTips);
2480  SetBit(kShowToolTips, showToolTips);
2481 
2482  if (fCanvasImp) fCanvasImp->ShowToolTips(showToolTips);
2483 }
2484 
2485 
2486 ////////////////////////////////////////////////////////////////////////////////
2487 /// Static function returning "true" if transparency is supported.
2488 
2490 {
2491  return gPad && (gVirtualX->InheritsFrom("TGQuartz") ||
2492  gPad->GetGLDevice() != -1);
2493 }
2494 
2495 extern "C" void ROOT_TCanvas_Update(void* TheCanvas) {
2496  static_cast<TCanvas*>(TheCanvas)->Update();
2497 }
2498 
2499 ////////////////////////////////////////////////////////////////////////////////
2500 /// Update canvas pad buffers.
2501 
2503 {
2504  if (fUpdating) return;
2505 
2506  if (fPixmapID == -1) return;
2507 
2508  static const union CastFromFuncToVoidPtr_t {
2509  CastFromFuncToVoidPtr_t(): fFuncPtr(ROOT_TCanvas_Update) {}
2510  void (*fFuncPtr)(void*);
2511  void* fVoidPtr;
2512  } castFromFuncToVoidPtr;
2513 
2514  if (gThreadXAR) {
2515  void *arr[3];
2516  arr[1] = this;
2517  arr[2] = castFromFuncToVoidPtr.fVoidPtr;
2518  if ((*gThreadXAR)("CUPD", 3, arr, 0)) return;
2519  }
2520 
2521  if (!fCanvasImp) return;
2522 
2523  if (!gVirtualX->IsCmdThread()) {
2524  // Why do we have this (which uses the interpreter to funnel the Update()
2525  // through the main thread) when the gThreadXAR mechanism does seemingly
2526  // the same?
2527  gInterpreter->Execute(this, IsA(), "Update", "");
2528  return;
2529  }
2530 
2532 
2533  fUpdating = kTRUE;
2534 
2535  if (!fCanvasImp->PerformUpdate()) {
2536 
2537  if (!IsBatch()) FeedbackMode(kFALSE); // Goto double buffer mode
2538 
2539  if (!UseGL()) PaintModified(); // Repaint all modified pad's
2540 
2541  Flush(); // Copy all pad pixmaps to the screen
2542 
2543  SetCursor(kCross);
2544  }
2545 
2546  fUpdating = kFALSE;
2547 }
2548 
2549 ////////////////////////////////////////////////////////////////////////////////
2550 /// Used by friend class TCanvasImp.
2551 
2553 {
2554  fCanvasID = 0;
2555  fContextMenu = 0;
2556 }
2557 
2558 ////////////////////////////////////////////////////////////////////////////////
2559 /// Check whether this canvas is to be drawn in grayscale mode.
2560 
2562 {
2563  return TestBit(kIsGrayscale);
2564 }
2565 
2566 ////////////////////////////////////////////////////////////////////////////////
2567 /// Set whether this canvas should be painted in grayscale, and re-paint
2568 /// it if necessary.
2569 
2570 void TCanvas::SetGrayscale(Bool_t set /*= kTRUE*/)
2571 {
2572  if (IsGrayscale() == set) return;
2573  SetBit(kIsGrayscale, set);
2574  Paint(); // update canvas and all sub-pads, unconditionally!
2575 }
2576 
2577 ////////////////////////////////////////////////////////////////////////////////
2578 /// Probably, TPadPainter must be placed in a separate ROOT module -
2579 /// "padpainter" (the same as "histpainter"). But now, it's directly in a
2580 /// gpad dir, so, in case of default painter, no *.so should be loaded,
2581 /// no need in plugin managers.
2582 /// May change in future.
2583 
2585 {
2586  //Even for batch mode painter is still required, just to delegate
2587  //some calls to batch "virtual X".
2588  if (!UseGL() || fBatch) {
2589  fPainter = 0;
2591  if (!fPainter) fPainter = new TPadPainter; // Do not need plugin manager for this!
2592  } else {
2594  if (!fPainter) {
2595  Error("CreatePainter", "GL Painter creation failed! Will use default!");
2596  fPainter = new TPadPainter;
2597  fUseGL = kFALSE;
2598  }
2599  }
2600 }
2601 
2602 ////////////////////////////////////////////////////////////////////////////////
2603 /// Access and (probably) creation of pad painter.
2604 
2606 {
2607  if (!fPainter) CreatePainter();
2608  return fPainter;
2609 }
2610 
2611 
2612 ////////////////////////////////////////////////////////////////////////////////
2613 ///assert on IsBatch() == false?
2614 
2616 {
2617  if (fGLDevice != -1) {
2618  //fPainter has a font manager.
2619  //Font manager will delete textures.
2620  //If context is wrong (we can have several canvases) -
2621  //wrong texture will be deleted, damaging some of our fonts.
2622  gGLManager->MakeCurrent(fGLDevice);
2623  }
2624 
2626 
2627  if (fGLDevice != -1) {
2628  gGLManager->DeleteGLContext(fGLDevice);//?
2629  fGLDevice = -1;
2630  }
2631 }
TCanvas::fgIsFolder
static Bool_t fgIsFolder
Indicates if canvas can be browsed as a folder.
Definition: TCanvas.h:66
TVirtualPS
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition: TVirtualPS.h:30
TObject::kMustCleanup
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition: TObject.h:60
TCanvasImp.h
c
#define c(i)
Definition: RSha256.hxx:101
kMouseLeave
@ kMouseLeave
Definition: Buttons.h:23
TCanvas::fCatt
TAttCanvas fCatt
Canvas attributes.
Definition: TCanvas.h:30
TCanvas::SetGrayscale
void SetGrayscale(Bool_t set=kTRUE)
Set whether this canvas should be painted in grayscale, and re-paint it if necessary.
Definition: TCanvas.cxx:2570
TCanvas::fDrawn
Bool_t fDrawn
! Set to True when the Draw method is called
Definition: TCanvas.h:62
kButton3Double
@ kButton3Double
Definition: Buttons.h:24
TPad::fX2
Double_t fX2
X of upper X coordinate.
Definition: TPad.h:34
kWheelUp
@ kWheelUp
Definition: Buttons.h:18
n
const Int_t n
Definition: legend1.C:16
TPad::SavePrimitive
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitives in this pad on the C++ source file out.
Definition: TPad.cxx:5695
TDialogCanvas.h
TAxis
Class to manage histogram axis.
Definition: TAxis.h:30
TPad::CopyPixmaps
void CopyPixmaps() override
Copy the sub-pixmaps of the pad to the canvas.
Definition: TPad.cxx:1071
TCanvas::kAutoExec
@ kAutoExec
Definition: TCanvas.h:88
TClass::kClassSaved
@ kClassSaved
Definition: TClass.h:94
first
Definition: first.py:1
TCanvas::fEventX
Int_t fEventX
! Last X mouse position in canvas
Definition: TCanvas.h:45
TCanvas::Clear
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition: TCanvas.cxx:725
TCanvasImp::ShowToolBar
virtual void ShowToolBar(Bool_t show=kTRUE)
Definition: TCanvasImp.h:100
TPad::SetTickx
void SetTickx(Int_t value=1) override
Definition: TPad.h:348
TCanvasImp::Close
virtual void Close()
Definition: TCanvasImp.h:56
TAttPad::SetTopMargin
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:129
TBrowser
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
TAttPad
Manages default Pad attributes.
Definition: TAttPad.h:19
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187
TCanvas::ExecuteEvent
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition: TCanvas.cxx:1100
TCanvas::fXsizeReal
Size_t fXsizeReal
Current size of canvas along X in CM.
Definition: TCanvas.h:34
Version_t
short Version_t
Definition: RtypesCore.h:65
TStyle::GetOptLogy
Int_t GetOptLogy() const
Definition: TStyle.h:239
snprintf
#define snprintf
Definition: civetweb.c:1540
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
TCanvas::fBatch
Bool_t fBatch
! True when in batchmode
Definition: TCanvas.h:58
TCanvas::ToggleAutoExec
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition: TCanvas.cxx:2435
TCanvas::kIsGrayscale
@ kIsGrayscale
Definition: TCanvas.h:94
TROOT::DecreaseDirLevel
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition: TROOT.cxx:2702
Option_t
const char Option_t
Definition: RtypesCore.h:66
kButton2Double
@ kButton2Double
Definition: Buttons.h:24
TPad
The most important graphics class in the ROOT system.
Definition: TPad.h:26
TCanvas::HasMenuBar
Bool_t HasMenuBar() const
Definition: TCanvas.h:166
TCanvasImp::SetWindowSize
virtual void SetWindowSize(UInt_t w, UInt_t h)
Definition: TCanvasImp.h:91
kButton1Motion
@ kButton1Motion
Definition: Buttons.h:20
TPad::Modified
void Modified(Bool_t flag=1) override
Definition: TPad.h:414
TPad::GetLogy
Int_t GetLogy() const override
Definition: TPad.h:251
TPad::GetY1
Double_t GetY1() const override
Definition: TPad.h:236
ECursor
ECursor
Definition: GuiTypes.h:372
gEnv
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
gVirtualX
#define gVirtualX
Definition: TVirtualX.h:338
TCanvas::CopyPixmaps
void CopyPixmaps() override
Copy the canvas pixmap of the pad to the canvas.
Definition: TCanvas.cxx:825
TCanvas::DisconnectWidget
void DisconnectWidget()
Used by friend class TCanvasImp.
Definition: TCanvas.cxx:2552
TList::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:578
TPad::GetCanvas
TCanvas * GetCanvas() const override
Definition: TPad.h:256
TPad::GetTicky
Int_t GetTicky() const override
Definition: TPad.h:233
TStyle::GetCanvasBorderMode
Int_t GetCanvasBorderMode() const
Definition: TStyle.h:182
TCanvas::Selected
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
Definition: TCanvas.cxx:1639
TPad::Close
void Close(Option_t *option="") override
Delete all primitives in pad and pad itself.
Definition: TPad.cxx:999
TCanvas::SetTitle
void SetTitle(const char *title="") override
Set canvas title.
Definition: TCanvas.cxx:2181
Form
char * Form(const char *fmt,...)
TCanvas::Paint
void Paint(Option_t *option="") override
Paint canvas.
Definition: TCanvas.cxx:1543
TCanvas::IsWeb
Bool_t IsWeb() const
Is web canvas.
Definition: TCanvas.cxx:1484
TDatime.h
TCanvas::ResizeOpaque
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition: TCanvas.cxx:1762
TGraph.h
TCanvas::Close
void Close(Option_t *option="") override
Close canvas.
Definition: TCanvas.cxx:776
TObject::Info
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:867
TView.h
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:893
colors
Color * colors
Definition: X3DBuffer.c:21
TContextMenu::Popup
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr)
Popup context menu at given location in canvas c and pad p for selected object.
Definition: TContextMenu.cxx:411
TApplication::InitializeGraphics
void InitializeGraphics()
Initialize the graphics environment.
Definition: TApplication.cxx:260
kButton1Up
@ kButton1Up
Definition: Buttons.h:19
TStyle::GetCanvasDefH
Int_t GetCanvasDefH() const
Definition: TStyle.h:183
TCanvas::EditorBar
virtual void EditorBar()
Get editor bar.
Definition: TCanvas.cxx:1028
TPad::fAspectRatio
Double_t fAspectRatio
ratio of w/h in case of fixed ratio
Definition: TPad.h:78
TCanvas::fYsizeReal
Size_t fYsizeReal
Current size of canvas along Y in CM.
Definition: TCanvas.h:35
TControlBar.h
TColor::DefinedColors
static Bool_t DefinedColors()
Static function returning kTRUE if some new colors have been defined after initialisation or since th...
Definition: TColor.cxx:1432
TPad::fY2
Double_t fY2
Y of upper Y coordinate.
Definition: TPad.h:35
gInterpreter
#define gInterpreter
Definition: TInterpreter.h:560
TCanvas::CreatePainter
void CreatePainter()
Probably, TPadPainter must be placed in a separate ROOT module - "padpainter" (the same as "histpaint...
Definition: TCanvas.cxx:2584
TColor::SetRGB
virtual void SetRGB(Float_t r, Float_t g, Float_t b)
Initialize this color and its associated colors.
Definition: TColor.cxx:1711
TCanvas::EnterLeave
void EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
Generate kMouseEnter and kMouseLeave events depending on the previously selected object and the curre...
Definition: TCanvas.cxx:1063
TObject::GetObjectInfo
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition: TObject.cxx:388
Float_t
float Float_t
Definition: RtypesCore.h:57
TCanvas::fPainter
TVirtualPadPainter * fPainter
! Canvas (pad) painter.
Definition: TCanvas.h:64
TStyle::GetOptFit
Int_t GetOptFit() const
Definition: TStyle.h:235
TStyle.h
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
TCanvas::fSelectedY
Int_t fSelectedY
! Y of selected object
Definition: TCanvas.h:51
TDatime::AsString
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition: TDatime.cxx:102
TStyle::SetCanvasBorderSize
void SetCanvasBorderSize(Width_t size=1)
Definition: TStyle.h:328
EEventType
EEventType
Definition: Buttons.h:15
Int_t
int Int_t
Definition: RtypesCore.h:45
TCanvas::FeedbackMode
void FeedbackMode(Bool_t set)
Turn rubberband feedback mode on or off.
Definition: TCanvas.cxx:1118
TPad::fFixedAspectRatio
Bool_t fFixedAspectRatio
True if fixed aspect ratio.
Definition: TPad.h:100
TCanvas::fSelectedPad
TPad * fSelectedPad
! Pad containing currently selected object
Definition: TCanvas.h:53
TPad::ls
void ls(Option_t *option="") const override
List all primitives in pad.
Definition: TPad.cxx:2995
TStyle::GetPadTopMargin
Float_t GetPadTopMargin() const
Definition: TStyle.h:203
TString::Contains
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
SafeDelete
#define SafeDelete(p)
Definition: RConfig.hxx:536
TPadPainter.h
TObjArray::GetEntries
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:523
x
Double_t x[n]
Definition: legend1.C:17
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TCanvas::SetFolder
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:2054
TCanvas::fEventY
Int_t fEventY
! Last Y mouse position in canvas
Definition: TCanvas.h:46
TClass.h
kButton1Shift
@ kButton1Shift
Definition: Buttons.h:18
TEnv::GetValue
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
TVirtualPS.h
TCanvas::IsGrayscale
Bool_t IsGrayscale()
Check whether this canvas is to be drawn in grayscale mode.
Definition: TCanvas.cxx:2561
TColor.h
TIter::Reset
void Reset()
Definition: TCollection.h:252
TPad::PaintModified
void PaintModified() override
Traverse pad hierarchy and (re)paint only modified pads.
Definition: TPad.cxx:3664
TVirtualX.h
TCanvas::RunAutoExec
void RunAutoExec()
Execute the list of TExecs in the current pad.
Definition: TCanvas.cxx:1770
TCanvas::UseGL
Bool_t UseGL() const
Definition: TCanvas.h:223
TCanvas::GetWh
UInt_t GetWh() const override
Definition: TCanvas.h:162
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
TCanvas::SetFixedAspectRatio
void SetFixedAspectRatio(Bool_t fixed=kTRUE) override
Fix canvas aspect ratio to current value if fixed is true.
Definition: TCanvas.cxx:2032
TPad::GetLogz
Int_t GetLogz() const override
Definition: TPad.h:252
TAxis::GetTimeDisplay
virtual Bool_t GetTimeDisplay() const
Definition: TAxis.h:126
kMouseMotion
@ kMouseMotion
Definition: Buttons.h:23
TObject::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:403
TCanvas.h
gCanvasInit
class TCanvasInit gCanvasInit
TEnv.h
TPad::SetLogz
void SetLogz(Int_t value=1) override
Set Lin/Log scale for Z.
Definition: TPad.cxx:5958
TColor::SaveColor
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:2127
TCanvas::Size
virtual void Size(Float_t xsizeuser=0, Float_t ysizeuser=0)
Set the canvas scale in centimeters.
Definition: TCanvas.cxx:2227
TCanvas::fCanvasID
Int_t fCanvasID
! Canvas identifier
Definition: TCanvas.h:47
TCanvas::GetHighLightColor
Color_t GetHighLightColor() const override
Definition: TCanvas.h:136
TString
Basic string class.
Definition: TString.h:136
TCanvasImp::Iconify
virtual void Iconify()
Definition: TCanvasImp.h:59
TCanvas::UseCurrentStyle
void UseCurrentStyle() override
Force a copy of current style for all objects in canvas.
Definition: TCanvas.cxx:1174
TCanvas::fCh
UInt_t fCh
Height of the canvas along Y (pixels)
Definition: TCanvas.h:43
TCanvas::Browse
void Browse(TBrowser *b) override
Browse.
Definition: TCanvas.cxx:672
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TCanvasImp::GetWindowGeometry
virtual UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Definition: TCanvasImp.h:87
TIter::GetOption
Option_t * GetOption() const
Definition: TCollection.h:251
TPad::UseCurrentStyle
void UseCurrentStyle() override
Force a copy of current style for all objects in pad.
Definition: TPad.cxx:6771
TCanvas::fCw
UInt_t fCw
Width of the canvas along X (pixels)
Definition: TCanvas.h:42
TCanvas::SaveSource
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition: TCanvas.cxx:1826
TColor::GetBlue
Float_t GetBlue() const
Definition: TColor.h:59
TObject::InheritsFrom
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
TPad::Clear
void Clear(Option_t *option="") override
Delete all pad primitives.
Definition: TPad.cxx:634
v
@ v
Definition: rootcling_impl.cxx:3664
TCanvas::SetBatch
void SetBatch(Bool_t batch=kTRUE) override
Toggle batch mode.
Definition: TCanvas.cxx:1977
TStyle::GetPadTickY
Int_t GetPadTickY() const
Definition: TStyle.h:209
b
#define b(i)
Definition: RSha256.hxx:100
TCanvasImp::IsWeb
virtual Bool_t IsWeb() const
Definition: TCanvasImp.h:45
TPad::SetGridy
void SetGridy(Int_t value=1) override
Definition: TPad.h:329
TVirtualX::kInvert
@ kInvert
Definition: TVirtualX.h:49
TCanvas::fPadSave
TPad * fPadSave
! Pointer to saved pad in HandleInput
Definition: TCanvas.h:55
TCanvas::fSelected
TObject * fSelected
! Currently selected object
Definition: TCanvas.h:48
TPad::GetY2
Double_t GetY2() const override
Definition: TPad.h:237
TPad::fGLDevice
Int_t fGLDevice
! OpenGL off-screen pixmap identifier
Definition: TPad.h:81
TCanvas::Constructor
void Constructor()
Canvas default constructor.
Definition: TCanvas.cxx:181
bool
TVirtualPadPainter::LockPainter
virtual void LockPainter()
Empty definition.
Definition: TVirtualPadPainter.cxx:51
TObjArray::Add
void Add(TObject *obj)
Definition: TObjArray.h:74
TCanvas::fDoubleBuffer
Int_t fDoubleBuffer
Double buffer flag (0=off, 1=on)
Definition: TCanvas.h:37
TPad::HighLight
void HighLight(Color_t col=kRed, Bool_t set=kTRUE) override
Highlight pad.
Definition: TPad.cxx:2960
TCanvas::HandleInput
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition: TCanvas.cxx:1223
TPad::fName
TString fName
Pad name.
Definition: TPad.h:105
TPad::GetLogx
Int_t GetLogx() const override
Definition: TPad.h:250
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TString::Last
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:913
TVirtualPadEditor::GetPadEditor
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
Definition: TVirtualPadEditor.cxx:74
TCanvas::Destructor
void Destructor()
Actual canvas destructor.
Definition: TCanvas.cxx:682
TStyle::GetCanvasPreferGL
Bool_t GetCanvasPreferGL() const
Definition: TStyle.h:179
TStyle::GetCanvasColor
Color_t GetCanvasColor() const
Definition: TStyle.h:180
TROOT.h
TCanvas::Closed
void Closed() override
Emit Closed signal.
Definition: TCanvas.cxx:766
TPad::SetBorderSize
void SetBorderSize(Short_t bordersize) override
Definition: TPad.h:318
TCanvas::SetCursor
void SetCursor(ECursor cursor) override
Set cursor.
Definition: TCanvas.cxx:2006
TPad::SetGridx
void SetGridx(Int_t value=1) override
Definition: TPad.h:328
TCanvas::kMoveOpaque
@ kMoveOpaque
Definition: TCanvas.h:92
TCanvas::SetDoubleBuffer
void SetDoubleBuffer(Int_t mode=1) override
Set Double Buffer On/Off.
Definition: TCanvas.cxx:2015
TCanvasImp::ForceUpdate
virtual void ForceUpdate()
Definition: TCanvasImp.h:57
TCanvas::fDISPLAY
TString fDISPLAY
Name of destination screen.
Definition: TCanvas.h:31
TCanvas::cd
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition: TCanvas.cxx:706
TObject::kNoContextMenu
@ kNoContextMenu
if object does not want context menu
Definition: TObject.h:65
TApplication.h
TContextMenu
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
kWheelDown
@ kWheelDown
Definition: Buttons.h:18
TAttLine::Copy
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition: TAttLine.cxx:175
TContextMenu.h
TCanvas::fYsizeUser
Size_t fYsizeUser
User specified size of canvas along Y in CM.
Definition: TCanvas.h:33
TCanvas::TCanvas
TCanvas(const TCanvas &canvas)=delete
TPad::cd
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition: TPad.cxx:604
TStyle::GetCanvasDefX
Int_t GetCanvasDefX() const
Definition: TStyle.h:185
TPad::Range
void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Set world coordinate system for the pad.
Definition: TPad.cxx:5197
TPad::fY1
Double_t fY1
Y of lower Y coordinate.
Definition: TPad.h:33
TStyle::GetScreenFactor
Float_t GetScreenFactor() const
Definition: TStyle.h:247
TCanvas::SupportAlpha
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
Definition: TCanvas.cxx:2489
TStyle::GetCanvasDefY
Int_t GetCanvasDefY() const
Definition: TStyle.h:186
TCanvas::DrawClonePad
virtual TObject * DrawClonePad()
Draw a clone of this canvas into the current pad In an interactive session, select the destination/cu...
Definition: TCanvas.cxx:907
TPad::SetFillStyle
void SetFillStyle(Style_t fstyle) override
Override TAttFill::FillStyle for TPad because we want to handle style=0 as style 4000.
Definition: TPad.cxx:5921
TCanvas::Highlighted
virtual void Highlighted(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)
Emit Highlighted() signal.
Definition: TCanvas.cxx:1612
TMath::Nint
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition: TMath.h:713
TCanvas::GetCanvasPainter
TVirtualPadPainter * GetCanvasPainter()
Access and (probably) creation of pad painter.
Definition: TCanvas.cxx:2605
gBatchGuiFactory
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition: TGuiFactory.h:67
TAttFill::Copy
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition: TAttFill.cxx:204
TBuffer.h
TVirtualPadEditor.h
TPad::GetHighLightColor
Color_t GetHighLightColor() const override
Get highlight color.
Definition: TPad.cxx:2714
TAttLine
Line Attributes class.
Definition: TAttLine.h:18
TPad::fX1
Double_t fX1
X of lower X coordinate.
Definition: TPad.h:32
TCanvas::MoveOpaque
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition: TCanvas.cxx:1535
TCanvas::ProcessedEvent
virtual void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected)
Emit ProcessedEvent() signal.
Definition: TCanvas.cxx:1653
TPad::GetBorderSize
Short_t GetBorderSize() const override
Definition: TPad.h:194
TCanvas::GetShowToolTips
Bool_t GetShowToolTips() const
Definition: TCanvas.h:149
TCanvas::GetShowToolBar
Bool_t GetShowToolBar() const
Definition: TCanvas.h:147
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
TObject::ResetBit
void ResetBit(UInt_t f)
Definition: TObject.h:186
TAttPad::SetBottomMargin
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:99
TCanvas::kShowEventStatus
@ kShowEventStatus
Definition: TCanvas.h:87
TCanvas::SetWindowPosition
void SetWindowPosition(Int_t x, Int_t y)
Set canvas window position.
Definition: TCanvas.cxx:2190
kButton1Double
@ kButton1Double
Definition: Buttons.h:24
TBox.h
TColor
The color creation and management class.
Definition: TColor.h:19
gROOTMutex
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:61
TStyle::GetOptTitle
Int_t GetOptTitle() const
Definition: TStyle.h:237
h
#define h(i)
Definition: RSha256.hxx:106
TPad::fPrimitives
TList * fPrimitives
->List of primitives (subpads)
Definition: TPad.h:103
TCanvas::GetShowEventStatus
Bool_t GetShowEventStatus() const
Definition: TCanvas.h:146
TObject::SetBit
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
TDatime::AsSQLString
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
Definition: TDatime.cxx:152
TCanvas::GetSelectedPad
TVirtualPad * GetSelectedPad() const override
Definition: TCanvas.h:144
TStyle::GetPadTickX
Int_t GetPadTickX() const
Definition: TStyle.h:208
TPad::fBorderMode
Short_t fBorderMode
Bordermode (-1=down, 0 = no border, 1=up)
Definition: TPad.h:94
TPad::GetListOfPrimitives
TList * GetListOfPrimitives() const override
Definition: TPad.h:239
TCanvas::ToggleToolBar
virtual void ToggleToolBar()
Toggle toolbar.
Definition: TCanvas.cxx:2455
TCanvas::fClickSelected
TObject * fClickSelected
! Currently click-selected object
Definition: TCanvas.h:49
TVirtualViewer3D.h
TPad::GetX2
Double_t GetX2() const override
Definition: TPad.h:235
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TCanvas::fWindowWidth
UInt_t fWindowWidth
Width of window (including borders, etc.)
Definition: TCanvas.h:40
kCross
@ kCross
Definition: GuiTypes.h:374
TCanvas::DrawEventStatus
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:962
TPad::Paint
void Paint(Option_t *option="") override
Paint all primitives in pad.
Definition: TPad.cxx:3447
TCanvas::GetWw
UInt_t GetWw() const override
Definition: TCanvas.h:161
Long_t
long Long_t
Definition: RtypesCore.h:54
TStyle::GetTimeOffset
Double_t GetTimeOffset() const
Definition: TStyle.h:260
TPadPainter
Implement TVirtualPadPainter which abstracts painting operations.
Definition: TPadPainter.h:26
TPad::GetBorderMode
Short_t GetBorderMode() const override
Definition: TPad.h:193
TCanvasImp::ShowToolTips
virtual void ShowToolTips(Bool_t show=kTRUE)
Definition: TCanvasImp.h:101
ClassImpQ
#define ClassImpQ(name)
Definition: TQObject.h:282
TObject::Clone
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:146
kDefaultCanvasSize
const Size_t kDefaultCanvasSize
Definition: TCanvas.cxx:61
TCanvas::Show
void Show()
Show canvas.
Definition: TCanvas.cxx:2238
gGuiFactory
R__EXTERN TGuiFactory * gGuiFactory
Definition: TGuiFactory.h:66
TCanvas::~TCanvas
virtual ~TCanvas()
Canvas destructor.
Definition: TCanvas.cxx:664
TCanvas::fSelectedX
Int_t fSelectedX
! X of selected object
Definition: TCanvas.h:50
TPad::SetBorderMode
void SetBorderMode(Short_t bordermode) override
Definition: TPad.h:317
gApplication
R__EXTERN TApplication * gApplication
Definition: TApplication.h:166
StrDup
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2512
TCanvas::SavePrimitive
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitives in this canvas in C++ macro file with GUI.
Definition: TCanvas.cxx:1781
TCanvas::kShowToolBar
@ kShowToolBar
Definition: TCanvas.h:90
gGLManager
#define gGLManager
Definition: TVirtualGL.h:162
TColor::GetRed
Float_t GetRed() const
Definition: TColor.h:57
gDebug
Int_t gDebug
Definition: TROOT.cxx:590
R__LOCKGUARD
#define R__LOCKGUARD(mutex)
Definition: TVirtualMutex.h:104
TPad::fBorderSize
Short_t fBorderSize
pad bordersize in pixels
Definition: TPad.h:93
TCollection::Browse
void Browse(TBrowser *b)
Browse this collection (called by TBrowser).
Definition: TCollection.cxx:248
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TAxis::GetTimeFormat
virtual const char * GetTimeFormat() const
Definition: TAxis.h:127
TCanvas::GetWindowWidth
UInt_t GetWindowWidth() const
Definition: TCanvas.h:159
y
Double_t y[n]
Definition: legend1.C:17
TCanvas::GetWindowHeight
UInt_t GetWindowHeight() const
Definition: TCanvas.h:160
TCanvas::fWindowTopY
Int_t fWindowTopY
Top Y position of window (in pixels)
Definition: TCanvas.h:39
TPad::SetTicky
void SetTicky(Int_t value=1) override
Definition: TPad.h:349
TCanvas::EmbedInto
void EmbedInto(Int_t winid, Int_t ww, Int_t wh)
Embedded a canvas into a TRootEmbeddedCanvas.
Definition: TCanvas.cxx:1037
TCanvas::SetName
void SetName(const char *name="") override
Set canvas name. In case name is an empty string, a default name is set.
Definition: TCanvas.cxx:2062
kButton2Motion
@ kButton2Motion
Definition: Buttons.h:20
TCanvasImp::ShowEditor
virtual void ShowEditor(Bool_t show=kTRUE)
Definition: TCanvasImp.h:99
TCanvas::Init
void Init()
Initialize the TCanvas members. Called by all constructors.
Definition: TCanvas.cxx:525
kButton3Down
@ kButton3Down
Definition: Buttons.h:17
TCanvas::ToggleToolTips
virtual void ToggleToolTips()
Toggle tooltip display.
Definition: TCanvas.cxx:2477
TCanvas::SetSelected
void SetSelected(TObject *obj) override
Set selected canvas.
Definition: TCanvas.cxx:2172
TStyle::GetPadLeftMargin
Float_t GetPadLeftMargin() const
Definition: TStyle.h:204
TPad::fTitle
TString fTitle
Pad title.
Definition: TPad.h:106
TCanvas::fWindowTopX
Int_t fWindowTopX
Top X position of window (in pixels)
Definition: TCanvas.h:38
TStyle::GetPadGridY
Bool_t GetPadGridY() const
Definition: TStyle.h:207
kRed
@ kRed
Definition: Rtypes.h:66
TStyle::IsReading
Bool_t IsReading() const
Definition: TStyle.h:282
TCanvas::Iconify
void Iconify()
Iconify canvas.
Definition: TCanvas.cxx:1467
TVirtualMutex.h
TCanvas::ToggleEventStatus
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2444
TObject::Warning
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:879
TCanvasImp::SetStatusText
virtual void SetStatusText(const char *text=0, Int_t partidx=0)
Definition: TCanvasImp.h:89
TCanvas::fXsizeUser
Size_t fXsizeUser
User specified size of canvas along X in CM.
Definition: TCanvas.h:32
TROOT::IncreaseDirLevel
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition: TROOT.cxx:2798
TPad::PaintBorder
void PaintBorder(Color_t color, Bool_t tops)
Paint the pad border.
Definition: TPad.cxx:3509
void
typedef void((*Func_t)())
TCanvas::Build
void Build()
Build a canvas. Called by all constructors.
Definition: TCanvas.cxx:574
TCanvasImp::SetWindowPosition
virtual void SetWindowPosition(Int_t x, Int_t y)
Definition: TCanvasImp.h:90
TROOT::IndentLevel
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2806
TCanvas::IsBatch
Bool_t IsBatch() const override
Definition: TCanvas.h:169
TCanvas::fCanvasImp
TCanvasImp * fCanvasImp
! Window system specific canvas implementation
Definition: TCanvas.h:56
TCanvasImp::SetCanvasSize
virtual void SetCanvasSize(UInt_t w, UInt_t h)
Definition: TCanvasImp.h:93
unsigned int
TCanvas::fContextMenu
TContextMenu * fContextMenu
! Context menu pointer
Definition: TCanvas.h:57
TCanvas::Pick
TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj) override
Search for an object at pixel position px,py.
Definition: TCanvas.h:180
TCanvasImp::PerformUpdate
virtual Bool_t PerformUpdate()
Definition: TCanvasImp.h:46
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
kArrowKeyPress
@ kArrowKeyPress
Definition: Buttons.h:21
kButton1ShiftMotion
@ kButton1ShiftMotion
Definition: Buttons.h:18
TCanvas::MakeDefCanvas
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
Definition: TCanvas.cxx:1504
TAttPad::SetLeftMargin
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:109
TGuiFactory::CreateCanvasImp
virtual TCanvasImp * CreateCanvasImp(TCanvas *c, const char *title, UInt_t width, UInt_t height)
Create a batch version of TCanvasImp.
Definition: TGuiFactory.cxx:56
TBox
Create a Box.
Definition: TBox.h:22
TCanvasImp::InitWindow
virtual Int_t InitWindow()
Definition: TCanvasImp.h:60
TVirtualPadPainter::PadPainter
static TVirtualPadPainter * PadPainter(Option_t *opt="")
Create a pad painter of specified type.
Definition: TVirtualPadPainter.cxx:58
TCanvas::Picked
virtual void Picked(TPad *selpad, TObject *selected, Int_t event)
Emit Picked() signal.
Definition: TCanvas.cxx:1593
gVirtualPS
R__EXTERN TVirtualPS * gVirtualPS
Definition: TVirtualPS.h:81
TCanvas::fClickSelectedPad
TPad * fClickSelectedPad
! Pad containing currently click-selected object
Definition: TCanvas.h:54
TStyle::GetPadRightMargin
Float_t GetPadRightMargin() const
Definition: TStyle.h:205
kButton1Down
@ kButton1Down
Definition: Buttons.h:17
TStyle::SetCanvasColor
void SetCanvasColor(Color_t color=19)
Definition: TStyle.h:327
TCanvasImp::Show
virtual void Show()
Definition: TCanvasImp.h:66
TPad::ResizePad
void ResizePad(Option_t *option="") override
Compute pad conversion coefficients.
Definition: TPad.cxx:5478
Double_t
double Double_t
Definition: RtypesCore.h:59
TCanvas::IsFolder
Bool_t IsFolder() const override
Is folder ?
Definition: TCanvas.cxx:1476
TStyle::SetCanvasBorderMode
void SetCanvasBorderMode(Int_t mode=1)
Definition: TStyle.h:329
TQObject::Connect
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:869
TGraph
A TGraph is an object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
TApplication::NeedGraphicsLibs
static void NeedGraphicsLibs()
Static method.
Definition: TApplication.cxx:252
TVirtualPad
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51
TAttPad::SetRightMargin
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition: TAttPad.cxx:119
TVirtualGL.h
TCanvas::RaiseWindow
void RaiseWindow()
Raise canvas window.
Definition: TCanvas.cxx:1747
TVirtualPadPainter::InitPainter
virtual void InitPainter()
Empty definition.
Definition: TVirtualPadPainter.cxx:37
TObject::kNotDeleted
@ kNotDeleted
object has not been deleted
Definition: TObject.h:78
TStyle::SetPalette
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1782
TObjArray.h
TPad::GetTitle
const char * GetTitle() const override
Returns title of object.
Definition: TPad.h:255
TCanvas
The Canvas class.
Definition: TCanvas.h:23
TAttPad::Copy
virtual void Copy(TAttPad &attpad) const
copy function
Definition: TAttPad.cxx:44
TList::Remove
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:822
ROOT_TCanvas_Update
void ROOT_TCanvas_Update(void *TheCanvas)
Definition: TCanvas.cxx:2495
TCanvas::ls
void ls(Option_t *option="") const override
List all pads.
Definition: TCanvas.cxx:1492
TPad::SetTicks
void SetTicks(Int_t valuex=1, Int_t valuey=1) override
Definition: TPad.h:347
TInterpreter.h
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TStyle::GetCanvasBorderSize
Width_t GetCanvasBorderSize() const
Definition: TStyle.h:181
TCanvas::SetCanvasSize
void SetCanvasSize(UInt_t ww, UInt_t wh) override
Set Width and Height of canvas to ww and wh respectively.
Definition: TCanvas.cxx:1993
TCanvas::Resize
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition: TCanvas.cxx:1668
TCanvas::SetWindowSize
void SetWindowSize(UInt_t ww, UInt_t wh)
Set canvas window size.
Definition: TCanvas.cxx:2199
TCollection::SetName
void SetName(const char *name)
Definition: TCollection.h:204
TAttFill::SetFillColor
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TCanvas::DrawClone
TObject * DrawClone(Option_t *option="") const override
Draw a clone of this canvas A new canvas is created that is a clone of this canvas.
Definition: TCanvas.cxx:890
TAxis.h
TStyle::GetOptLogz
Int_t GetOptLogz() const
Definition: TStyle.h:240
TPad::GetGridx
Bool_t GetGridx() const override
Definition: TPad.h:229
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TCanvas::kShowToolTips
@ kShowToolTips
Definition: TCanvas.h:95
kButton3Motion
@ kButton3Motion
Definition: Buttons.h:20
TStyle::GetCanvasDefW
Int_t GetCanvasDefW() const
Definition: TStyle.h:184
TCanvas::kShowEditor
@ kShowEditor
Definition: TCanvas.h:91
TH1
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
TStyle::GetOptLogx
Int_t GetOptLogx() const
Definition: TStyle.h:238
TObject::IsOnHeap
R__ALWAYS_INLINE Bool_t IsOnHeap() const
Definition: TObject.h:148
TPad::ExecuteEvent
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition: TPad.cxx:1715
name
char name[80]
Definition: TGX11.cxx:110
TPad::CopyPixmap
void CopyPixmap() override
Copy the pixmap of the pad to the canvas.
Definition: TPad.cxx:1057
TCanvasImp::SetWindowTitle
virtual void SetWindowTitle(const char *newTitle)
Definition: TCanvasImp.h:92
TCanvas::ForceUpdate
void ForceUpdate()
Force canvas update.
Definition: TCanvas.cxx:1166
TPad::fCanvas
TCanvas * fCanvas
! Pointer to mother canvas
Definition: TPad.h:102
TCanvas::fRetained
Bool_t fRetained
Retain structure flag.
Definition: TCanvas.h:60
TCanvas::Cleared
virtual void Cleared(TVirtualPad *pad)
Emit pad Cleared signal.
Definition: TCanvas.cxx:758
TApplication::CreateApplication
static void CreateApplication()
TCanvas::fWindowHeight
UInt_t fWindowHeight
Height of window (including menubar, borders, etc.)
Definition: TCanvas.h:41
TStyle::GetPadGridX
Bool_t GetPadGridX() const
Definition: TStyle.h:206
TPad::SetLogx
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition: TPad.cxx:5933
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
gPad
#define gPad
Definition: TVirtualPad.h:287
TAttFill::GetFillColor
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
TIter
Definition: TCollection.h:233
TPad::GetName
const char * GetName() const override
Returns name of object.
Definition: TPad.h:254
TPad::GetGridy
Bool_t GetGridy() const override
Definition: TPad.h:230
TDatime
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
TCanvas::Draw
void Draw(Option_t *option="") override
Draw a canvas.
Definition: TCanvas.cxx:843
kButton2Up
@ kButton2Up
Definition: Buttons.h:19
TClass::IsCallingNew
static ENewType IsCallingNew()
Static method returning the defConstructor flag passed to TClass::New().
Definition: TClass.cxx:5886
kKeyPress
@ kKeyPress
Definition: Buttons.h:20
TCanvas::GetWindowTopX
Int_t GetWindowTopX()
Returns current top x position of window on screen.
Definition: TCanvas.cxx:1199
kMouseEnter
@ kMouseEnter
Definition: Buttons.h:23
TStyle::GetOptStat
Int_t GetOptStat() const
Definition: TStyle.h:236
TAttFill
Fill Area Attributes class.
Definition: TAttFill.h:19
TDatime::Convert
UInt_t Convert(Bool_t toGMT=kFALSE) const
Convert fDatime from TDatime format to the standard time_t format.
Definition: TDatime.cxx:182
TCanvas::SetRealAspectRatio
bool SetRealAspectRatio(const Int_t axis=1)
Function to resize a canvas so that the plot inside is shown in real aspect ratio.
Definition: TCanvas.cxx:2105
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TCanvas::kResizeOpaque
@ kResizeOpaque
Definition: TCanvas.h:93
kButton2Down
@ kButton2Down
Definition: Buttons.h:17
TVirtualPadPainter
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
Definition: TVirtualPadPainter.h:19
gThreadXAR
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
Definition: TVirtualPad.h:289
TCanvas::fUseGL
Bool_t fUseGL
! True when rendering is with GL
Definition: TCanvas.h:61
TPad::GetX1
Double_t GetX1() const override
Definition: TPad.h:234
TPad::SetGrid
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
Definition: TPad.h:327
Class
void Class()
Definition: Class.C:29
TString::ToLower
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1147
TObject::Pop
virtual void Pop()
Pop on object drawn in a pad to the top of the display list.
Definition: TObject.cxx:530
TVirtualX::kCopy
@ kCopy
Definition: TVirtualX.h:49
TPad::GetTickx
Int_t GetTickx() const override
Definition: TPad.h:232
kArrowKeyRelease
@ kArrowKeyRelease
Definition: Buttons.h:21
TCanvasImp::ShowStatusBar
virtual void ShowStatusBar(Bool_t show=kTRUE)
Definition: TCanvasImp.h:95
TCanvas::DeleteCanvasPainter
void DeleteCanvasPainter()
assert on IsBatch() == false?
Definition: TCanvas.cxx:2615
TCanvas::Flush
void Flush()
Flush canvas buffers.
Definition: TCanvas.cxx:1132
TVirtualPadPainter::SelectDrawable
virtual void SelectDrawable(Int_t device)=0
TCanvas::fHighLightColor
Color_t fHighLightColor
Highlight color of active pad.
Definition: TCanvas.h:36
TClass::kRealNew
@ kRealNew
Definition: TClass.h:107
TColor::GetGreen
Float_t GetGreen() const
Definition: TColor.h:58
TH1.h
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
TObject::ExecuteEvent
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition: TObject.cxx:313
TGuiFactory.h
TPad::SetPad
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) override
Set all pad parameters.
Definition: TPad.cxx:6018
TCanvasImp::CreatePadPainter
virtual TVirtualPadPainter * CreatePadPainter()
Definition: TCanvasImp.h:47
TObject::Clear
virtual void Clear(Option_t *="")
Definition: TObject.h:115
TCanvas::HighlightConnect
virtual void HighlightConnect(const char *slot)
This is "simplification" for function TCanvas::Connect with Highlighted signal for specific slot.
Definition: TCanvas.cxx:1631
TCanvas::fUpdating
Bool_t fUpdating
! True when Updating the canvas
Definition: TCanvas.h:59
TPad::fMother
TPad * fMother
! pointer to mother of the list
Definition: TPad.h:101
TCanvas::Update
void Update() override
Update canvas pad buffers.
Definition: TCanvas.cxx:2502
TCanvas::kMenuBar
@ kMenuBar
Definition: TCanvas.h:89
TList
A doubly linked list.
Definition: TList.h:44
TCanvas::fEvent
Int_t fEvent
! Type of current or last handled event
Definition: TCanvas.h:44
TCanvasImp::RaiseWindow
virtual void RaiseWindow()
Definition: TCanvasImp.h:96
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
TArray::GetSize
Int_t GetSize() const
Definition: TArray.h:47
TMath.h
TPad::SetLogy
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition: TPad.cxx:5947
TArrayI
Array of integers (32 bits per element).
Definition: TArrayI.h:27
kButton3Up
@ kButton3Up
Definition: Buttons.h:19
gROOT
#define gROOT
Definition: TROOT.h:406
int
TPad::fPixmapID
Int_t fPixmapID
! Off-screen pixmap identifier
Definition: TPad.h:80
TCanvas::GetWindowTopY
Int_t GetWindowTopY()
Returns current top y position of window on screen.
Definition: TCanvas.cxx:1210
TCanvasImp::ShowMenuBar
virtual void ShowMenuBar(Bool_t show=kTRUE)
Definition: TCanvasImp.h:94
Size_t
float Size_t
Definition: RtypesCore.h:96
TError.h
TCanvas::ToggleEditor
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2466
TStyle::GetPadBottomMargin
Float_t GetPadBottomMargin() const
Definition: TStyle.h:202
TColor::GetPalette
static const TArrayI & GetPalette()
Static function returning the current active palette.
Definition: TColor.cxx:1414
TColor::GetNumber
Int_t GetNumber() const
Definition: TColor.h:55
TCanvas::fSelectedOpt
TString fSelectedOpt
! Drawing option of selected object
Definition: TCanvas.h:52