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