Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TCanvas.cxx
Go to the documentation of this file.
1// @(#)root/gpad:$Id$
2// Author: Rene Brun 12/12/94
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include <cstring>
13#include <cstdlib>
14#include <iostream>
15#include <fstream>
16
17#include "TROOT.h"
18#include "TBuffer.h"
19#include "TCanvas.h"
20#include "TCanvasImp.h"
21#include "TDatime.h"
22#include "TClass.h"
23#include "TStyle.h"
24#include "TBox.h"
25#include "TCanvasImp.h"
26#include "TDialogCanvas.h"
27#include "TGuiFactory.h"
28#include "TEnv.h"
29#include "TError.h"
30#include "TContextMenu.h"
31#include "TControlBar.h"
32#include "TInterpreter.h"
33#include "TApplication.h"
34#include "TColor.h"
35#include "TSystem.h"
36#include "TObjArray.h"
37#include "TVirtualPadEditor.h"
38#include "TVirtualViewer3D.h"
39#include "TPadPainter.h"
40#include "TPadPainterPS.h"
41#include "TVirtualGL.h"
42#include "TVirtualPS.h"
43#include "TVirtualX.h"
44#include "TAxis.h"
45#include "TH1.h"
46#include "TGraph.h"
47#include "TMath.h"
48#include "TView.h"
49#include "strlcpy.h"
50
51#include "TVirtualMutex.h"
52
53#include <cstdio>
54
59
60//*-*x16 macros/layout_canvas
61
63
65
66
67TString GetNewCanvasName(const char *arg = nullptr)
68{
69 if (arg && *arg)
70 return arg;
71
72 const char *defcanvas = gROOT->GetDefCanvasName();
74
75 auto lc = (TList*)gROOT->GetListOfCanvases();
76 Int_t n = lc->GetSize() + 1;
77
78 while(lc->FindObject(cdef.Data()))
79 cdef.Form("%s_n%d", defcanvas, n++);
80
81 return cdef;
82}
83
84
85/** \class TCanvas
86\ingroup gpad
87
88The Canvas class.
89
90A Canvas is an area mapped to a window directly under the control of the display
91manager. A ROOT session may have several canvases open at any given time.
92
93A Canvas may be subdivided into independent graphical areas: the __Pads__.
94A canvas has a default pad which has the name of the canvas itself.
95An example of a Canvas layout is sketched in the picture below.
96
97\image html gpad_canvas.png
98
99This canvas contains two pads named P1 and P2. Both Canvas, P1 and P2 can be
100moved, grown, shrunk using the normal rules of the Display manager.
101
102Once objects have been drawn in a canvas, they can be edited/moved by pointing
103directly to them. The cursor shape is changed to suggest the type of action that
104one can do on this object. Clicking with the right mouse button on an object
105pops-up a contextmenu with a complete list of actions possible on this object.
106
107A graphical editor may be started from the canvas "View" menu under the menu
108entry "Toolbar".
109
110An interactive HELP is available by clicking on the HELP button at the top right
111of the canvas. It gives a short explanation about the canvas' menus.
112
113A canvas may be automatically divided into pads via `TPad::Divide`.
114
115At creation time, no matter if in interactive or batch mode, the constructor
116defines the size of the canvas window (including the size of the ROOT menu bar but
117excluding the size of the OS window manager's decoration). To define precisely the
118graphics area size of a canvas in batch/interactive mode, the following code should
119be used:
120~~~ {.cpp}
121 {
122 Double_t w = 600;
123 Double_t h = 600;
124 auto c = new TCanvas("c", "c", w, h);
125 c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
126 }
127~~~
128
129To ensure similar painting size for the canvas created with default size for both interactive and batch mode:
130~~~ {.cpp}
131 {
132 auto c = new TCanvas("c", "c");
133 c->SetWindowSize(c->GetWindowWidth() + (c->GetWindowWidth() - c->GetWw()), c->GetWindowHeight() + (c->GetWindowHeight() - c->GetWh()));
134 }
135~~~
136
137If you are in batch mode, you can also specify the fixed painting area as follows:
138~~~ {.cpp}
139 c->SetCanvasSize(w, h);
140~~~
141
142If the canvas size exceeds the window size, scroll bars will be added to the canvas
143This allows to display very large canvases (even bigger than the screen size). The
144Following example shows how to proceed.
145~~~ {.cpp}
146 {
147 auto c = new TCanvas("c","c");
148 c->SetCanvasSize(1500, 1500);
149 c->SetWindowSize(500, 500);
150 }
151~~~
152*/
153
154////////////////////////////////////////////////////////////////////////////////
155/// Canvas default constructor.
156
157TCanvas::TCanvas(Bool_t build) : TPad(), fDoubleBuffer(0)
158{
159 fPainter = nullptr;
160 fWindowTopX = 0;
161 fWindowTopY = 0;
162 fWindowWidth = 0;
163 fWindowHeight = 0;
164 fCw = 0;
165 fCh = 0;
166 fXsizeUser = 0;
167 fYsizeUser = 0;
170 fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
171 fEvent = -1;
172 fEventX = -1;
173 fEventY = -1;
174 fSelectedX = 0;
175 fSelectedY = 0;
177 fDrawn = kFALSE;
179 fSelected = nullptr;
180 fClickSelected = nullptr;
181 fSelectedPad = nullptr;
182 fClickSelectedPad = nullptr;
183 fPadSave = nullptr;
184 fCanvasImp = nullptr;
185 fContextMenu = nullptr;
186
188
189 if (!build || TClass::IsCallingNew() != TClass::kRealNew) {
190 Constructor();
191 } else {
192 auto cdef = GetNewCanvasName();
193
194 Constructor(cdef.Data(), cdef.Data(), 1);
195 }
196}
197
198////////////////////////////////////////////////////////////////////////////////
199/// Canvas default constructor
200
202{
203 if (gThreadXAR) {
204 void *arr[2];
205 arr[1] = this;
206 if ((*gThreadXAR)("CANV", 2, arr, nullptr)) return;
207 }
208
209 fCanvas = nullptr;
210 fCanvasID = -1;
211 fCanvasImp = nullptr;
212 fBatch = kTRUE;
214
215 fContextMenu = nullptr;
216 fSelected = nullptr;
217 fClickSelected = nullptr;
218 fSelectedPad = nullptr;
219 fClickSelectedPad = nullptr;
220 fPadSave = nullptr;
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Create an embedded canvas, i.e. a canvas that is in a TGCanvas widget
228/// which is placed in a TGFrame. This ctor is only called via the
229/// TRootEmbeddedCanvas class.
230///
231/// If "name" starts with "gl" the canvas is ready to receive GL output.
232
233TCanvas::TCanvas(const char *name, Int_t ww, Int_t wh, Int_t winid) : TPad(), fDoubleBuffer(0)
234{
235 fCanvasImp = nullptr;
236 fPainter = nullptr;
237 Init();
238
240 fWindowTopX = 0;
241 fWindowTopY = 0;
242 fWindowWidth = ww;
244 fCw = ww + 4;
245 fCh = wh +28;
246 fBatch = kFALSE;
248
249 //This is a very special ctor. A window exists already!
250 //Can create painter now.
252
253 if (fUseGL) {
254 fGLDevice = gGLManager->CreateGLContext(winid);
255 if (fGLDevice == -1)
256 fUseGL = kFALSE;
257 }
258
260 if (!fCanvasImp) return;
261
263 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
264 Build();
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Create a new canvas with a predefined size form.
269/// If form < 0 the menubar is not shown.
270///
271/// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
272/// - form = 2 500x500 at 20,20
273/// - form = 3 500x500 at 30,30
274/// - form = 4 500x500 at 40,40
275/// - form = 5 500x500 at 50,50
276///
277/// If "name" starts with "gl" the canvas is ready to receive GL output.
278
279TCanvas::TCanvas(const char *name, const char *title, Int_t form) : TPad(), fDoubleBuffer(0)
280{
281 fPainter = nullptr;
283
284 Constructor(name, title, form);
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Create a new canvas with a predefined size form.
289/// If form < 0 the menubar is not shown.
290///
291/// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
292/// - form = 2 500x500 at 20,20
293/// - form = 3 500x500 at 30,30
294/// - form = 4 500x500 at 40,40
295/// - form = 5 500x500 at 50,50
296
297void TCanvas::Constructor(const char *name, const char *title, Int_t form)
298{
299 if (gThreadXAR) {
300 void *arr[6];
301 static Int_t ww = 500;
302 static Int_t wh = 500;
303 arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
304 if ((*gThreadXAR)("CANV", 6, arr, nullptr)) return;
305 }
306
307 Init();
308 SetBit(kMenuBar,true);
309 if (form < 0) {
310 form = -form;
311 SetBit(kMenuBar,false);
312 }
313
314 fCanvas = this;
315
316 fCanvasID = -1;
317 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
318 if (old && old->IsOnHeap()) {
319 Warning("Constructor","Deleting canvas with same name: %s",name);
320 delete old;
321 }
322 if (gROOT->IsBatch()) { //We are in Batch mode
324 if (form == 1) {
327 } else {
328 fWindowWidth = 500;
329 fWindowHeight = 500;
330 }
334 if (!fCanvasImp) return;
335 fBatch = kTRUE;
336 } else { //normal mode with a screen window
338 if (form < 1 || form > 20) form = 1;
339 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
340 Int_t ux, uy, cw, ch;
341 if (form == 1) {
342 cw = gStyle->GetCanvasDefW();
343 ch = gStyle->GetCanvasDefH();
346 } else {
347 cw = ch = 500;
348 ux = uy = form * 10;
349 }
350
351 fCanvasImp = factory->CreateCanvasImp(this, name, Int_t(cx*ux), Int_t(cx*uy), UInt_t(cx*cw), UInt_t(cx*ch));
352 if (!fCanvasImp) return;
353
354 if (!gROOT->IsBatch() && fCanvasID == -1)
356
358 fBatch = kFALSE;
359 }
360
362
363 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
364 SetTitle(title); // requires fCanvasImp set
365 Build();
366
367 // Popup canvas
368 fCanvasImp->Show();
369}
370
371////////////////////////////////////////////////////////////////////////////////
372/// Create a new canvas at a random position.
373///
374/// \param[in] name canvas name
375/// \param[in] title canvas title
376/// \param[in] ww is the window size in pixels along X
377/// (if ww < 0 the menubar is not shown)
378/// \param[in] wh is the window size in pixels along Y
379///
380/// If "name" starts with "gl" the canvas is ready to receive GL output.
381
382TCanvas::TCanvas(const char *name, const char *title, Int_t ww, Int_t wh) : TPad(), fDoubleBuffer(0)
383{
384 fPainter = nullptr;
386
387 Constructor(name, title, ww, wh);
388}
389
390////////////////////////////////////////////////////////////////////////////////
391/// Create a new canvas at a random position.
392///
393/// \param[in] name canvas name
394/// \param[in] title canvas title
395/// \param[in] ww is the window size in pixels along X
396/// (if ww < 0 the menubar is not shown)
397/// \param[in] wh is the window size in pixels along Y
398
399void TCanvas::Constructor(const char *name, const char *title, Int_t ww, Int_t wh)
400{
401 if (gThreadXAR) {
402 void *arr[6];
403 arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
404 if ((*gThreadXAR)("CANV", 6, arr, nullptr)) return;
405 }
406
407 Init();
408 SetBit(kMenuBar,true);
409 if (ww < 0) {
410 ww = -ww;
411 SetBit(kMenuBar,false);
412 }
413 if (wh <= 0) {
414 Error("Constructor", "Invalid canvas height: %d",wh);
415 return;
416 }
417 fCw = ww;
418 fCh = wh;
419 fCanvasID = -1;
420 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
421 if (old && old->IsOnHeap()) {
422 Warning("Constructor","Deleting canvas with same name: %s",name);
423 delete old;
424 }
425 if (gROOT->IsBatch()) { //We are in Batch mode
427 fWindowWidth = ww;
429 fCw = ww;
430 fCh = wh;
432 if (!fCanvasImp) return;
433 fBatch = kTRUE;
434 } else {
436 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
437 fCanvasImp = factory->CreateCanvasImp(this, name, UInt_t(cx*ww), UInt_t(cx*wh));
438 if (!fCanvasImp) return;
439
440 if (!gROOT->IsBatch() && fCanvasID == -1)
442
444 fBatch = kFALSE;
445 }
446
448
449 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
450 SetTitle(title); // requires fCanvasImp set
451 Build();
452
453 // Popup canvas
454 fCanvasImp->Show();
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Create a new canvas.
459///
460/// \param[in] name canvas name
461/// \param[in] title canvas title
462/// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
463/// the canvas (if wtopx < 0) the menubar is not shown)
464/// \param[in] ww is the window size in pixels along X
465/// \param[in] wh is the window size in pixels along Y
466///
467/// If "name" starts with "gl" the canvas is ready to receive GL output.
468
469TCanvas::TCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
470 : TPad(), fDoubleBuffer(0)
471{
472 fPainter = nullptr;
474
475 Constructor(name, title, wtopx, wtopy, ww, wh);
476}
477
478////////////////////////////////////////////////////////////////////////////////
479/// Create a new canvas.
480///
481/// \param[in] name canvas name
482/// \param[in] title canvas title
483/// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
484/// the canvas (if wtopx < 0) the menubar is not shown)
485/// \param[in] ww is the window size in pixels along X
486/// \param[in] wh is the window size in pixels along Y
487
488void TCanvas::Constructor(const char *name, const char *title, Int_t wtopx,
489 Int_t wtopy, Int_t ww, Int_t wh)
490{
491 if (gThreadXAR) {
492 void *arr[8];
493 arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title;
494 arr[4] = &wtopx; arr[5] = &wtopy; arr[6] = &ww; arr[7] = &wh;
495 if ((*gThreadXAR)("CANV", 8, arr, nullptr)) return;
496 }
497
498 Init();
499 SetBit(kMenuBar,true);
500 if (wtopx < 0) {
501 wtopx = -wtopx;
502 SetBit(kMenuBar,false);
503 }
504 fCw = ww;
505 fCh = wh;
506 fCanvasID = -1;
507 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
508 if (old && old->IsOnHeap()) {
509 Warning("Constructor","Deleting canvas with same name: %s",name);
510 delete old;
511 }
512 if (gROOT->IsBatch()) { //We are in Batch mode
514 fWindowWidth = ww;
516 fCw = ww;
517 fCh = wh;
519 if (!fCanvasImp) return;
520 fBatch = kTRUE;
521 } else { //normal mode with a screen window
523 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
524 fCanvasImp = factory->CreateCanvasImp(this, name, Int_t(cx*wtopx), Int_t(cx*wtopy), UInt_t(cx*ww), UInt_t(cx*wh));
525 if (!fCanvasImp) return;
526
527 if (!gROOT->IsBatch() && fCanvasID == -1)
529
531 fBatch = kFALSE;
532 }
533
535
536 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
537 SetTitle(title); // requires fCanvasImp set
538 Build();
539
540 // Popup canvas
541 fCanvasImp->Show();
542}
543
544////////////////////////////////////////////////////////////////////////////////
545/// Initialize the TCanvas members. Called by all constructors.
546
548{
549 // Make sure the application environment exists. It is need for graphics
550 // (colors are initialized in the TApplication ctor).
551 if (!gApplication)
553
554 // Load and initialize graphics libraries if
555 // TApplication::NeedGraphicsLibs() has been called by a
556 // library static initializer.
557 if (gApplication)
558 gApplication->InitializeGraphics(gROOT->IsWebDisplay());
559
560 // Get some default from .rootrc. Used in fCanvasImp->InitWindow().
561 fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
562 SetBit(kMoveOpaque, gEnv->GetValue("Canvas.MoveOpaque", 0));
563 SetBit(kResizeOpaque, gEnv->GetValue("Canvas.ResizeOpaque", 0));
564 if (gEnv->GetValue("Canvas.ShowEventStatus", kFALSE)) SetBit(kShowEventStatus);
565 if (gEnv->GetValue("Canvas.ShowToolTips", kFALSE)) SetBit(kShowToolTips);
566 if (gEnv->GetValue("Canvas.ShowToolBar", kFALSE)) SetBit(kShowToolBar);
567 if (gEnv->GetValue("Canvas.ShowEditor", kFALSE)) SetBit(kShowEditor);
568 if (gEnv->GetValue("Canvas.AutoExec", kTRUE)) SetBit(kAutoExec);
569
570 // Fill canvas ROOT data structure
571 fXsizeUser = 0;
572 fYsizeUser = 0;
575
576 fDISPLAY = "$DISPLAY";
579 fSelected = nullptr;
580 fClickSelected = nullptr;
581 fSelectedX = 0;
582 fSelectedY = 0;
583 fSelectedPad = nullptr;
584 fClickSelectedPad= nullptr;
585 fPadSave = nullptr;
586 fEvent = -1;
587 fEventX = -1;
588 fEventY = -1;
589 fContextMenu = nullptr;
590 fDrawn = kFALSE;
592}
593
594////////////////////////////////////////////////////////////////////////////////
595/// Build a canvas. Called by all constructors.
596
598{
599 // Get window identifier
600 if (fCanvasID == -1 && fCanvasImp)
602 if (fCanvasID == -1) return;
603
604 if (fCw !=0 && fCh !=0) {
607 }
608
609 // Set Pad parameters
610 gPad = this;
611 fCanvas = this;
612 fMother = (TPad*)gPad;
613
614 if (IsBatch()) {
615 // Make sure that batch interactive canvas sizes are the same
616 fCw -= 4;
617 fCh -= 28;
618 } else if (IsWeb()) {
619 // mark canvas as batch - avoid gVirtualX in many places
621 } else {
622 //normal mode with a screen window
623 if (auto pp = GetCanvasPainter()) {
624 // Set default physical canvas attributes
625 pp->SelectDrawable(fCanvasID);
626 pp->SetAttFill({1, 1001}); //Set color index for fill area
627 pp->SetAttLine({1, 1, 1}); //Set color index for lines
628 pp->SetAttMarker({1, 1, 1}); //Set color index for markers
629 // pp->SetAttText({22, 0., 1, 42, 12}); //Set color index for text
630 // Clear workstation
631 pp->ClearWindow(fCanvasID);
632 }
633
634 // Set Double Buffer on by default
636
637 // Get effective window parameters (with borders and menubar)
640
641 // Get effective canvas parameters without borders
643
644 fContextMenu = new TContextMenu("ContextMenu");
645 }
646
647 gROOT->GetListOfCanvases()->Add(this);
648
649 if (!fPrimitives) {
650 fPrimitives = new TList;
652 SetFillStyle(1001);
664 fBorderMode=gStyle->GetCanvasBorderMode(); // do not call SetBorderMode (function redefined in TCanvas)
665 SetPad(0, 0, 1, 1);
666 Range(0, 0, 1, 1); //pad range is set by default to [0,1] in x and y
667
668 if (auto pp = GetCanvasPainter())
669 pp->SelectDrawable(fPixmapID); //pixmap must be selected
670 PaintBorder(GetFillColor(), kTRUE); //paint background
671 }
672
673 // transient canvases have typically no menubar and should not get
674 // by default the event status bar (if set by default)
675 if (TestBit(kMenuBar) && fCanvasImp) {
677 // ... and toolbar + editor
681 }
682}
683
684////////////////////////////////////////////////////////////////////////////////
685/// Canvas destructor
686
688{
689 Destructor();
690}
691
692////////////////////////////////////////////////////////////////////////////////
693/// Browse.
694
696{
697 Draw();
698 cd();
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// Actual canvas destructor.
704
706{
707 if (gThreadXAR) {
708 void *arr[2];
709 arr[1] = this;
710 if ((*gThreadXAR)("CDEL", 2, arr, nullptr)) return;
711 }
712
713 if (ROOT::Detail::HasBeenDeleted(this)) return;
714
716 if (!gPad) return;
717
718 Close();
719
720 //If not yet (batch mode?).
722}
723
724////////////////////////////////////////////////////////////////////////////////
725/// Set current canvas & pad. Returns the new current pad,
726/// or 0 in case of failure.
727/// See TPad::cd() for an explanation of the parameter.
728
730{
731 if (fCanvasID == -1) return nullptr;
732
734
735 // in case doublebuffer is off, draw directly onto display window
736 if (!IsBatch() && !IsWeb() && !fDoubleBuffer && fPainter)
737 fPainter->SelectDrawable(fCanvasID);//Ok, does not matter for glpad.
738
739 return gPad;
740}
741
742////////////////////////////////////////////////////////////////////////////////
743/// Remove all primitives from the canvas.
744/// If option "D" is specified, direct sub-pads are cleared but not deleted.
745/// This option is not recursive, i.e. pads in direct sub-pads are deleted.
746
748{
749 if (fCanvasID == -1) return;
750
752
753 TString opt = option;
754 opt.ToLower();
755 if (opt.Contains("d")) {
756 // clear subpads, but do not delete pads in case the canvas
757 // has been divided (note: option "D" is propagated so could cause
758 // conflicts for primitives using option "D" for something else)
759 if (fPrimitives) {
760 TIter next(fPrimitives);
761 TObject *obj;
762 while ((obj=next())) {
763 obj->Clear(option);
764 }
765 }
766 } else {
767 //default, clear everything in the canvas. Subpads are deleted
768 TPad::Clear(option); //Remove primitives from pad
769 }
770
771 fSelected = nullptr;
772 fClickSelected = nullptr;
773 fSelectedPad = nullptr;
774 fClickSelectedPad = nullptr;
775}
776
777////////////////////////////////////////////////////////////////////////////////
778/// Emit pad Cleared signal.
779
781{
782 Emit("Cleared(TVirtualPad*)", (Longptr_t)pad);
783}
784
785////////////////////////////////////////////////////////////////////////////////
786/// Emit Closed signal.
787
789{
790 Emit("Closed()");
791}
792
793////////////////////////////////////////////////////////////////////////////////
794/// Close canvas.
795///
796/// Delete window/pads data structure
797
799{
800 auto padsave = gPad;
801 TCanvas *cansave = padsave ? padsave->GetCanvas() : nullptr;
802
803 if (fCanvasID != -1) {
804
805 if (!gROOT->IsLineProcessing() && !gVirtualX->IsCmdThread()) {
806 gInterpreter->Execute(this, IsA(), "Close", option);
807 return;
808 }
809
811
813
814 cd();
816
817 if (!IsBatch() && !IsWeb()) {
818 //select current canvas
819 if (fPainter)
821
823
824 if (fCanvasImp)
825 fCanvasImp->Close();
826 }
827 fCanvasID = -1;
828 fBatch = kTRUE;
829
830 gROOT->GetListOfCanvases()->Remove(this);
831
832 // Close actual window on screen
834 }
835
836 if (cansave == this) {
837 gPad = (TCanvas *) gROOT->GetListOfCanvases()->First();
838 } else {
839 gPad = padsave;
840 }
841
842 Closed();
843}
844
845////////////////////////////////////////////////////////////////////////////////
846/// Copy the canvas pixmap of the pad to the canvas.
847
849{
850 if (!IsBatch()) {
853 }
854}
855
856////////////////////////////////////////////////////////////////////////////////
857/// Draw a canvas.
858/// If a canvas with the name is already on the screen, the canvas is repainted.
859/// This function is useful when a canvas object has been saved in a Root file.
860/// One can then do:
861/// ~~~ {.cpp}
862/// Root > TFile::Open("file.root");
863/// Root > canvas->Draw();
864/// ~~~
865
867{
868 // Load and initialize graphics libraries if
869 // TApplication::NeedGraphicsLibs() has been called by a
870 // library static initializer.
871 if (gApplication)
872 gApplication->InitializeGraphics(gROOT->IsWebDisplay());
873
874 fDrawn = kTRUE;
875
876 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(GetName());
877 if (old == this) {
878 if (IsWeb()) {
879 Modified();
880 UpdateAsync();
881 } else {
882 Paint();
883 }
884 return;
885 }
886 if (old) { gROOT->GetListOfCanvases()->Remove(old); delete old;}
887
888 if (fWindowWidth == 0) {
889 if (fCw !=0) fWindowWidth = fCw+4;
890 else fWindowWidth = 800;
891 }
892 if (fWindowHeight == 0) {
893 if (fCh !=0) fWindowHeight = fCh+28;
894 else fWindowHeight = 600;
895 }
896 if (gROOT->IsBatch()) { //We are in Batch mode
898 if (!fCanvasImp) return;
899 fBatch = kTRUE;
900
901 } else { //normal mode with a screen window
902 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
903 fCanvasImp = factory->CreateCanvasImp(this, GetName(), fWindowTopX, fWindowTopY,
905 if (!fCanvasImp) return;
907 }
908 Build();
909 ResizePad();
911 fCanvasImp->Show();
912 Modified();
913}
914
915////////////////////////////////////////////////////////////////////////////////
916/// Draw a clone of this canvas
917/// A new canvas is created that is a clone of this canvas
918
920{
922 newCanvas->SetName();
923
924 newCanvas->Draw(option);
925 newCanvas->Update();
926 return newCanvas;
927}
928
929////////////////////////////////////////////////////////////////////////////////
930/// Draw a clone of this canvas into the current pad
931/// In an interactive session, select the destination/current pad
932/// with the middle mouse button, then point to the canvas area to select
933/// the canvas context menu item DrawClonePad.
934/// Note that the original canvas may have subpads.
935
937{
938 auto padsav = gPad;
939 auto selpad = gROOT->GetSelectedPad();
940 auto pad = padsav;
941 if (pad == this) pad = selpad;
942 if (!padsav || !pad || pad == this) {
944 newCanvas->SetWindowSize(GetWindowWidth(),GetWindowHeight());
945 return newCanvas;
946 }
947 if (fCanvasID == -1) {
948 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
949 fCanvasImp = factory->CreateCanvasImp(this, GetName(), fWindowTopX, fWindowTopY,
951 if (!fCanvasImp) return nullptr;
954 }
955 this->cd();
956 //copy pad attributes
957 pad->Range(fX1,fY1,fX2,fY2);
958 pad->SetTickx(GetTickx());
959 pad->SetTicky(GetTicky());
960 pad->SetGridx(GetGridx());
961 pad->SetGridy(GetGridy());
962 pad->SetLogx(GetLogx());
963 pad->SetLogy(GetLogy());
964 pad->SetLogz(GetLogz());
965 pad->SetBorderSize(GetBorderSize());
966 pad->SetBorderMode(GetBorderMode());
970
971 //copy primitives
973 while (auto obj = next()) {
974 pad->cd();
975 pad->Add(obj->Clone(), next.GetOption(), kFALSE); // do not issue modified for each object
976 }
977 pad->ResizePad();
978 pad->Modified();
979 pad->Update();
980 if (padsav) padsav->cd();
981 return nullptr;
982}
983
984////////////////////////////////////////////////////////////////////////////////
985/// Report name and title of primitive below the cursor.
986///
987/// This function is called when the option "Event Status"
988/// in the canvas menu "Options" is selected.
989
991{
992 const Int_t kTMAX=256;
993 static char atext[kTMAX];
994
995 if (!TestBit(kShowEventStatus) || !selected) return;
996
997 if (!fCanvasImp) return; //this may happen when closing a TAttCanvas
998
1000
1001 fCanvasImp->SetStatusText(selected->GetTitle(),0);
1002 fCanvasImp->SetStatusText(selected->GetName(),1);
1003 if (event == kKeyPress)
1004 snprintf(atext, kTMAX, "%c", (char) px);
1005 else
1006 snprintf(atext, kTMAX, "%d,%d", px, py);
1008
1009 // Show date/time if TimeDisplay is selected
1010 TAxis *xaxis = nullptr;
1011 if ( selected->InheritsFrom("TH1") )
1012 xaxis = ((TH1*)selected)->GetXaxis();
1013 else if ( selected->InheritsFrom("TGraph") )
1014 xaxis = ((TGraph*)selected)->GetXaxis();
1015 else if ( selected->InheritsFrom("TAxis") )
1016 xaxis = (TAxis*)selected;
1017 if ( xaxis != nullptr && xaxis->GetTimeDisplay()) {
1018 TString objinfo = selected->GetObjectInfo(px,py);
1019 // check if user has overwritten GetObjectInfo and altered
1020 // the default text from TObject::GetObjectInfo "x=.. y=.."
1021 if (objinfo.Contains("x=") && objinfo.Contains("y=") ) {
1022 UInt_t toff = 0;
1023 TString time_format(xaxis->GetTimeFormat());
1024 // TimeFormat may contain offset: %F2000-01-01 00:00:00
1025 Int_t idF = time_format.Index("%F");
1026 if (idF>=0) {
1027 Int_t lnF = time_format.Length();
1028 // minimal check for correct format
1029 if (lnF - idF == 21) {
1032 toff = dtoff.Convert();
1033 }
1034 } else {
1036 }
1037 TDatime dt((UInt_t)gPad->AbsPixeltoX(px) + toff);
1038 snprintf(atext, kTMAX, "%s, y=%g",
1039 dt.AsSQLString(),gPad->AbsPixeltoY(py));
1041 return;
1042 }
1043 }
1044 // default
1045 fCanvasImp->SetStatusText(selected->GetObjectInfo(px,py),3);
1046}
1047
1048////////////////////////////////////////////////////////////////////////////////
1049/// Get editor bar.
1050
1055
1056////////////////////////////////////////////////////////////////////////////////
1057/// Embedded a canvas into a TRootEmbeddedCanvas. This method is only called
1058/// via TRootEmbeddedCanvas::AdoptCanvas.
1059
1061{
1062 // If fCanvasImp already exists, no need to go further.
1063 if(fCanvasImp) return;
1064
1065 fCanvasID = winid;
1066 fWindowTopX = 0;
1067 fWindowTopY = 0;
1068 fWindowWidth = ww;
1069 fWindowHeight = wh;
1070 fCw = ww;
1071 fCh = wh;
1072 fBatch = kFALSE;
1073 fUpdating = kFALSE;
1074
1076 if (!fCanvasImp) return;
1077 Build();
1078 Resize();
1079}
1080
1081////////////////////////////////////////////////////////////////////////////////
1082/// Generate kMouseEnter and kMouseLeave events depending on the previously
1083/// selected object and the currently selected object. Does nothing if the
1084/// selected object does not change.
1085
1087{
1088 if (prevSelObj == fSelected) return;
1089
1092
1093 if (prevSelObj) {
1094 gPad = prevSelPad;
1095 prevSelObj->ExecuteEvent(kMouseLeave, fEventX, fEventY);
1097 RunAutoExec();
1099 }
1100
1102
1103 if (fSelected) {
1106 RunAutoExec();
1108 }
1109
1110 fEvent = sevent;
1111}
1112
1113////////////////////////////////////////////////////////////////////////////////
1114/// Execute action corresponding to one event.
1115///
1116/// This member function must be implemented to realize the action
1117/// corresponding to the mouse click on the object in the canvas
1118///
1119/// Only handle mouse motion events in TCanvas, all other events are
1120/// ignored for the time being
1121
1123{
1124 if (gROOT->GetEditorMode()) {
1126 return;
1127 }
1128
1129 switch (event) {
1130
1131 case kMouseMotion:
1133 break;
1134 }
1135}
1136
1137////////////////////////////////////////////////////////////////////////////////
1138/// Turn rubberband feedback mode on or off.
1139
1141{
1142 if (IsWeb() || (fCanvasID == -1))
1143 return;
1144
1145 SetDoubleBuffer(set ? 0 : 1); // switch double buffer
1146
1147 if (fPainter)
1149}
1150
1151////////////////////////////////////////////////////////////////////////////////
1152/// Flush canvas buffers.
1153
1155{
1156 if ((fCanvasID == -1) || IsWeb() || IsBatch())
1157 return;
1158
1159 if (!UseGL() || fGLDevice == -1) {
1161 CopyPixmaps();
1163 } else {
1164 if (IsEditable())
1166
1167 TContext ctxt(this, kTRUE);
1168
1170 gVirtualPS = nullptr;
1171 gGLManager->MakeCurrent(fGLDevice);
1173 Paint();
1175 gGLManager->Flush(fGLDevice);
1176 gVirtualPS = tvps;
1177 fHilightPadBorder = nullptr;
1178 }
1179}
1180
1181////////////////////////////////////////////////////////////////////////////////
1182/// Force canvas update
1183
1188
1189////////////////////////////////////////////////////////////////////////////////
1190/// Force a copy of current style for all objects in canvas.
1191
1193{
1194 if (!gROOT->IsLineProcessing() && !gVirtualX->IsCmdThread()) {
1195 gInterpreter->Execute(this, IsA(), "UseCurrentStyle", "");
1196 return;
1197 }
1198
1200
1202
1203 if (gStyle->IsReading()) {
1207 } else {
1211 }
1212}
1213
1214////////////////////////////////////////////////////////////////////////////////
1215/// Returns current top x position of window on screen.
1216
1224
1225////////////////////////////////////////////////////////////////////////////////
1226/// Returns current top y position of window on screen.
1227
1235
1236////////////////////////////////////////////////////////////////////////////////
1237/// Handle Input Events.
1238///
1239/// Handle input events, like button up/down in current canvas.
1240
1242{
1243 TPad *pad;
1246
1247 fPadSave = (TPad*)gPad;
1248 cd(); // make sure this canvas is the current canvas
1249
1250 fEvent = event;
1251 fEventX = px;
1252 fEventY = py;
1253
1254 switch (event) {
1255
1256 case kMouseMotion:
1257 // highlight object tracked over
1258 pad = Pick(px, py, prevSelObj);
1259 if (!pad) return;
1260
1262
1263 gPad = pad; // don't use cd() we will use the current
1264 // canvas via the GetCanvas member and not via
1265 // gPad->GetCanvas
1266
1267 if (fSelected) {
1268 fSelected->ExecuteEvent(event, px, py);
1269 RunAutoExec();
1270 }
1271
1272 break;
1273
1274 case kMouseEnter:
1275 // mouse enters canvas
1276 //FeedbackMode(kTRUE);
1277 break;
1278
1279 case kMouseLeave:
1280 // mouse leaves canvas
1281 {
1282 // force popdown of tooltips
1285 fSelected = nullptr;
1286 fSelectedPad = nullptr;
1288 fSelected = sobj;
1290 //FeedbackMode(kFALSE);
1291 }
1292 break;
1293
1294 case kButton1Double:
1295 // triggered on the second button down within 350ms and within
1296 // 3x3 pixels of the first button down, button up finishes action
1297
1298 case kButton1Down:
1299 // find pad in which input occurred
1300 pad = Pick(px, py, prevSelObj);
1301 if (!pad) return;
1302
1303 gPad = pad; // don't use cd() because we won't draw in pad
1304 // we will only use its coordinate system
1305
1306 if (fSelected) {
1307 FeedbackMode(kTRUE); // to draw in rubberband mode
1308 fSelected->ExecuteEvent(event, px, py);
1309
1310 RunAutoExec();
1311 }
1312
1313 break;
1314
1315 case kArrowKeyPress:
1316 case kArrowKeyRelease:
1317 case kButton1Motion:
1318 case kButton1ShiftMotion: //8 == kButton1Motion + shift modifier
1319 if (fSelected) {
1321
1322 fSelected->ExecuteEvent(event, px, py);
1325 Bool_t resize = kFALSE;
1327 resize = ((TBox*)fSelected)->IsBeingResized();
1329 resize = ((TVirtualPad*)fSelected)->IsBeingResized();
1330
1331 if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) {
1332 gPad = fPadSave;
1333 Update();
1335 }
1336 }
1337
1338 RunAutoExec();
1339 }
1340
1341 break;
1342
1343 case kButton1Up:
1344
1345 if (fSelected) {
1347
1348 fSelected->ExecuteEvent(event, px, py);
1349
1350 RunAutoExec();
1351
1352 if (fPadSave)
1353 gPad = fPadSave;
1354 else {
1355 gPad = this;
1356 fPadSave = this;
1357 }
1358
1359 Update(); // before calling update make sure gPad is reset
1360 }
1361 break;
1362
1363//*-*----------------------------------------------------------------------
1364
1365 case kButton2Down:
1366 // find pad in which input occurred
1367 pad = Pick(px, py, prevSelObj);
1368 if (!pad) return;
1369
1370 gPad = pad; // don't use cd() because we won't draw in pad
1371 // we will only use its coordinate system
1372
1374
1375 if (fSelected) fSelected->Pop(); // pop object to foreground
1376 pad->cd(); // and make its pad the current pad
1377 if (gDebug)
1378 printf("Current Pad: %s / %s\n", pad->GetName(), pad->GetTitle());
1379
1380 // loop over all canvases to make sure that only one pad is highlighted
1381 {
1382 TIter next(gROOT->GetListOfCanvases());
1383 TCanvas *tc;
1384 while ((tc = (TCanvas *)next()))
1385 tc->Update();
1386 }
1387
1388 //if (pad->GetGLDevice() != -1 && fSelected)
1389 // fSelected->ExecuteEvent(event, px, py);
1390
1391 break; // don't want fPadSave->cd() to be executed at the end
1392
1393 case kButton2Motion:
1394 //was empty!
1395 case kButton2Up:
1396 if (fSelected) {
1398
1399 fSelected->ExecuteEvent(event, px, py);
1400 RunAutoExec();
1401 }
1402 break;
1403
1404 case kButton2Double:
1405 break;
1406
1407//*-*----------------------------------------------------------------------
1408
1409 case kButton3Down:
1410 // popup context menu
1411 pad = Pick(px, py, prevSelObj);
1412 if (!pad) return;
1413
1415
1417 !pad->TestBit(kNoContextMenu) && !TestBit(kNoContextMenu))
1418 fContextMenu->Popup(px, py, fSelected, this, pad);
1419
1420 break;
1421
1422 case kButton3Motion:
1423 break;
1424
1425 case kButton3Up:
1427 break;
1428
1429 case kButton3Double:
1430 break;
1431
1432 case kKeyPress:
1433 if (!fSelectedPad || !fSelected) return;
1434 gPad = fSelectedPad; // don't use cd() because we won't draw in pad
1435 // we will only use its coordinate system
1436 fSelected->ExecuteEvent(event, px, py);
1437
1438 RunAutoExec();
1439
1440 break;
1441
1442 case kButton1Shift:
1443 // Try to select
1444 pad = Pick(px, py, prevSelObj);
1445
1446 if (!pad) return;
1447
1449
1450 gPad = pad; // don't use cd() we will use the current
1451 // canvas via the GetCanvas member and not via
1452 // gPad->GetCanvas
1453 if (fSelected) {
1454 fSelected->ExecuteEvent(event, px, py);
1455 RunAutoExec();
1456 }
1457 break;
1458
1459 case kWheelUp:
1460 case kWheelDown:
1461 pad = Pick(px, py, prevSelObj);
1462 if (!pad) return;
1463
1464 gPad = pad;
1465 if (fSelected)
1466 fSelected->ExecuteEvent(event, px, py);
1467 break;
1468
1469 default:
1470 break;
1471 }
1472
1473 if (fPadSave && event != kButton2Down)
1474 fPadSave->cd();
1475
1476 if (event != kMouseLeave) { // signal was already emitted for this event
1477 ProcessedEvent(event, px, py, fSelected); // emit signal
1479 }
1480}
1481
1482////////////////////////////////////////////////////////////////////////////////
1483/// Iconify canvas
1484
1486{
1487 if (fCanvasImp)
1489}
1490
1491////////////////////////////////////////////////////////////////////////////////
1492/// Is folder ?
1493
1495{
1496 return fgIsFolder;
1497}
1498
1499////////////////////////////////////////////////////////////////////////////////
1500/// Is web canvas
1501
1503{
1504 return fCanvasImp ? fCanvasImp->IsWeb() : kFALSE;
1505}
1506
1507////////////////////////////////////////////////////////////////////////////////
1508/// List all pads.
1509
1511{
1513 std::cout <<"Canvas Name=" <<GetName()<<" Title="<<GetTitle()<<" Option="<<option<<std::endl;
1517}
1518
1519////////////////////////////////////////////////////////////////////////////////
1520/// Static function to build a default canvas.
1521
1523{
1524 auto cdef = GetNewCanvasName();
1525
1526 auto c = new TCanvas(cdef.Data(), cdef.Data(), 1);
1527
1528 ::Info("TCanvas::MakeDefCanvas"," created default TCanvas with name %s", cdef.Data());
1529 return c;
1530}
1531
1532////////////////////////////////////////////////////////////////////////////////
1533/// Set option to move objects/pads in a canvas.
1534///
1535/// - set = 1 (default) graphics objects are moved in opaque mode
1536/// - set = 0 only the outline of objects is drawn when moving them
1537///
1538/// The option opaque produces the best effect. It requires however a
1539/// a reasonably fast workstation or response time.
1540
1542{
1543 SetBit(kMoveOpaque,set);
1544}
1545
1546////////////////////////////////////////////////////////////////////////////////
1547/// Paint canvas.
1548
1550{
1551 if (fCanvas)
1553}
1554
1555////////////////////////////////////////////////////////////////////////////////
1556/// Prepare for pick, call TPad::Pick() and when selected object
1557/// is different from previous then emit Picked() signal.
1558
1560{
1561 TObjLink *pickobj = nullptr;
1562
1563 fSelected = nullptr;
1564 fSelectedOpt = "";
1565 fSelectedPad = nullptr;
1566
1567 TPad *pad = Pick(px, py, pickobj);
1568 if (!pad) return nullptr;
1569
1570 if (!pickobj) {
1571 fSelected = pad;
1572 fSelectedOpt = "";
1573 } else {
1574 if (!fSelected) { // can be set via TCanvas::SetSelected()
1575 fSelected = pickobj->GetObject();
1576 fSelectedOpt = pickobj->GetOption();
1577 }
1578 }
1579 fSelectedPad = pad;
1580
1581 if (fSelected != prevSelObj)
1582 Picked(fSelectedPad, fSelected, fEvent); // emit signal
1583
1584 if ((fEvent == kButton1Down) || (fEvent == kButton2Down) || (fEvent == kButton3Down)) {
1588 Selected(fSelectedPad, fSelected, fEvent); // emit signal
1589 fSelectedX = px;
1590 fSelectedY = py;
1591 }
1592 }
1593 return pad;
1594}
1595
1596////////////////////////////////////////////////////////////////////////////////
1597/// Emit Picked() signal.
1598
1600{
1601 Longptr_t args[3];
1602
1603 args[0] = (Longptr_t) pad;
1604 args[1] = (Longptr_t) obj;
1605 args[2] = event;
1606
1607 Emit("Picked(TPad*,TObject*,Int_t)", args);
1608}
1609
1610////////////////////////////////////////////////////////////////////////////////
1611/// Emit Highlighted() signal.
1612///
1613/// - pad is pointer to pad with highlighted histogram or graph
1614/// - obj is pointer to highlighted histogram or graph
1615/// - x is highlighted x bin for 1D histogram or highlighted x-th point for graph
1616/// - y is highlighted y bin for 2D histogram (for 1D histogram or graph not in use)
1617
1619{
1620 Longptr_t args[4];
1621
1622 args[0] = (Longptr_t) pad;
1623 args[1] = (Longptr_t) obj;
1624 args[2] = x;
1625 args[3] = y;
1626
1627 Emit("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", args);
1628}
1629
1630////////////////////////////////////////////////////////////////////////////////
1631/// This is "simplification" for function TCanvas::Connect with Highlighted
1632/// signal for specific slot.
1633///
1634/// Slot has to be defined "UserFunction(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)"
1635/// all parameters of UserFunction are taken from TCanvas::Highlighted
1636
1638{
1639 Connect("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", nullptr, nullptr, slot);
1640}
1641
1642////////////////////////////////////////////////////////////////////////////////
1643/// Emit Selected() signal.
1644
1646{
1647 Longptr_t args[3];
1648
1649 args[0] = (Longptr_t) pad;
1650 args[1] = (Longptr_t) obj;
1651 args[2] = event;
1652
1653 Emit("Selected(TVirtualPad*,TObject*,Int_t)", args);
1654}
1655
1656////////////////////////////////////////////////////////////////////////////////
1657/// Emit ProcessedEvent() signal.
1658
1660{
1661 Longptr_t args[4];
1662
1663 args[0] = event;
1664 args[1] = x;
1665 args[2] = y;
1666 args[3] = (Longptr_t) obj;
1667
1668 Emit("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", args);
1669}
1670
1671////////////////////////////////////////////////////////////////////////////////
1672/// Recompute canvas parameters following a X11 Resize.
1673
1675{
1676 if (fCanvasID == -1)
1677 return;
1678
1679 if (!gROOT->IsLineProcessing() && !gVirtualX->IsCmdThread()) {
1680 gInterpreter->Execute(this, IsA(), "Resize", "");
1681 return;
1682 }
1683
1685
1686 TContext ctxt(this, kTRUE);
1687
1688 if (!IsBatch() && !IsWeb()) {
1689 // SL: do we need it here?
1690 fPainter->SelectDrawable(fCanvasID); //select current canvas for painting???
1691
1692 fCanvasImp->ResizeCanvasWindow(fCanvasID); //resize canvas and off-screen buffer
1693
1694 // Get effective window parameters including menubar and borders
1697
1698 // Get effective canvas parameters without borders
1700 }
1701
1702 if (fXsizeUser && fYsizeUser) {
1703 UInt_t nwh = fCh;
1704 UInt_t nww = fCw;
1706 if (rxy < 1) {
1708 if (twh > fCh)
1710 else
1711 nwh = twh;
1712 if (nww > fCw) {
1713 nww = fCw; nwh = twh;
1714 }
1715 if (nwh > fCh) {
1716 nwh = fCh; nww = UInt_t(Double_t(fCh)/rxy);
1717 }
1718 } else {
1720 if (twh > fCh)
1722 else
1723 nww = twh;
1724 if (nww > fCw) {
1725 nww = fCw; nwh = twh;
1726 }
1727 if (nwh > fCh) {
1728 nwh = fCh; nww = UInt_t(Double_t(fCh)*rxy);
1729 }
1730 }
1731 fCw = nww;
1732 fCh = nwh;
1733 }
1734
1735 if (fCw < fCh) {
1738 }
1739 else {
1742 }
1743
1744 //*-*- Loop on all pads to recompute conversion coefficients
1746}
1747
1748
1749////////////////////////////////////////////////////////////////////////////////
1750/// Raise canvas window
1751
1753{
1754 if (fCanvasImp)
1756}
1757
1758////////////////////////////////////////////////////////////////////////////////
1759/// Set option to resize objects/pads in a canvas.
1760///
1761/// - set = 1 (default) graphics objects are resized in opaque mode
1762/// - set = 0 only the outline of objects is drawn when resizing them
1763///
1764/// The option opaque produces the best effect. It requires however a
1765/// a reasonably fast workstation or response time.
1766
1768{
1769 SetBit(kResizeOpaque,set);
1770}
1771
1772////////////////////////////////////////////////////////////////////////////////
1773/// Execute the list of TExecs in the current pad.
1774
1776{
1777 if (!TestBit(kAutoExec))
1778 return;
1779 if (gPad)
1780 ((TPad*)gPad)->AutoExec();
1781}
1782
1783////////////////////////////////////////////////////////////////////////////////
1784/// Save primitives in this canvas in C++ macro file with GUI.
1785
1786void TCanvas::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1787{
1788 // Write canvas options (in $TROOT or $TStyle)
1789 out << " gStyle->SetOptFit(" << gStyle->GetOptFit() << ");\n";
1790 out << " gStyle->SetOptStat(" << gStyle->GetOptStat() << ");\n";
1791 out << " gStyle->SetOptTitle(" << gStyle->GetOptTitle() << ");\n";
1792
1793 if (gROOT->GetEditHistograms())
1794 out << " gROOT->SetEditHistograms();\n";
1795
1796 if (GetShowEventStatus())
1797 out << " " << GetName() << "->ToggleEventStatus();\n";
1798
1799 if (GetShowToolTips())
1800 out << " " << GetName() << "->ToggleToolTips();\n";
1801
1802 if (GetShowToolBar())
1803 out << " " << GetName() << "->ToggleToolBar();\n";
1804 if (GetHighLightColor() != 5)
1805 out << " " << GetName() << "->SetHighLightColor(" << TColor::SavePrimitiveColor(GetHighLightColor()) << ");\n";
1806
1807 // Now recursively scan all pads of this canvas
1808 cd();
1810}
1811
1812////////////////////////////////////////////////////////////////////////////////
1813/// Save primitives in this canvas as a C++ macro file.
1814/// This function loops on all the canvas primitives and for each primitive
1815/// calls the object SavePrimitive function.
1816/// When outputting floating point numbers, the default precision is 7 digits.
1817/// The precision can be changed (via system.rootrc) by changing the value
1818/// of the environment variable "Canvas.SavePrecision"
1819
1820void TCanvas::SaveSource(const char *filename, Option_t * /*option*/)
1821{
1822 // Reset the ClassSaved status of all classes
1823 gROOT->ResetClassSaved();
1824
1827
1829 if (cname.IsNull()) {
1830 invalid = kTRUE;
1831 cname = "c1";
1832 }
1833
1834 // if filename is given, open this file, otherwise create a file
1835 // with a name equal to the canvasname.C
1836 TString fname;
1837 if (filename && *filename) {
1838 fname = filename;
1839 } else {
1840 fname = cname + ".C";
1841 }
1842
1843 std::ofstream out;
1844 out.open(fname.Data(), std::ios::out);
1845 if (!out.good()) {
1846 Error("SaveSource", "Cannot open file: %s", fname.Data());
1847 return;
1848 }
1849
1850 //set precision
1851 Int_t precision = gEnv->GetValue("Canvas.SavePrecision",7);
1852 out.precision(precision);
1853
1854 // Write macro header and date/time stamp
1855 TDatime t;
1857 Int_t topx,topy;
1858 UInt_t w, h;
1859 if (!fCanvasImp) {
1860 Error("SaveSource", "Cannot open TCanvas");
1861 return;
1862 }
1865 h = UInt_t((fWindowHeight)/cx);
1866 topx = GetWindowTopX();
1867 topy = GetWindowTopY();
1868
1869 if (w == 0) {
1870 w = GetWw()+4; h = GetWh()+4;
1871 topx = 1; topy = 1;
1872 }
1873
1875 out << R"CODE(#ifdef __CLING__
1876#pragma cling optimize(0)
1877#endif
1878)CODE";
1879 Int_t p = mname.Last('.');
1880 Int_t s = mname.Last('/')+1;
1881
1882 // A named macro is generated only if the function name is valid. If not, the
1883 // macro is unnamed.
1884 TString first(mname(s,s+1));
1885 if (!first.IsDigit()) out <<"void " << mname(s,p-s) << "()" << std::endl;
1886
1887 out <<"{"<<std::endl;
1888 out <<"//=========Macro generated from canvas: "<<GetName()<<"/"<<GetTitle()<<std::endl;
1889 out <<"//========= ("<<t.AsString()<<") by ROOT version "<<gROOT->GetVersion()<<std::endl;
1890
1892 out <<std::endl<<" gStyle->SetCanvasPreferGL(kTRUE);"<<std::endl<<std::endl;
1893
1894 // Write canvas parameters (TDialogCanvas case)
1896 out << " " << ClassName() << " *" << cname << " = new " << ClassName() << "(\"" << GetName() << "\", \""
1897 << TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << w << ", " << h << ");\n";
1898 } else {
1899 // Write canvas parameters (TCanvas case)
1900 out << " TCanvas *" << cname << " = new TCanvas(\"" << GetName() << "\", \""
1901 << TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << (HasMenuBar() ? topx : -topx) << ", " << topy
1902 << ", " << w << ", " << h << ");\n";
1903 }
1904 // Write canvas options (in $TROOT or $TStyle)
1905 out << " gStyle->SetOptFit(" << gStyle->GetOptFit() << ");\n";
1906 out << " gStyle->SetOptStat(" << gStyle->GetOptStat() << ");\n";
1907 out << " gStyle->SetOptTitle(" << gStyle->GetOptTitle() << ");\n";
1908 if (gROOT->GetEditHistograms())
1909 out << " gROOT->SetEditHistograms();\n";
1910 if (GetShowEventStatus())
1911 out << " " << GetName() << "->ToggleEventStatus();\n";
1912 if (GetShowToolTips())
1913 out << " " << GetName() << "->ToggleToolTips();\n";
1914 if (GetHighLightColor() != 5)
1915 out << " " << GetName() << "->SetHighLightColor(" << TColor::SavePrimitiveColor(GetHighLightColor()) << ");\n";
1916
1918
1919 // Now recursively scan all pads of this canvas
1920 cd();
1921 if (invalid) fName = cname;
1922 TPad::SavePrimitive(out,"toplevel");
1923
1924 // Write canvas options related to pad editor
1925 out << " " << GetName() << "->SetSelected(" << GetName() << ");\n";
1926 if (GetShowToolBar())
1927 out << " " << GetName() << "->ToggleToolBar();\n";
1928 if (invalid)
1929 fName = cname0;
1930
1931 out <<"}\n";
1932 out.close();
1933 Info("SaveSource","C++ Macro file: %s has been generated", fname.Data());
1934
1935 // Reset the ClassSaved status of all classes
1936 gROOT->ResetClassSaved();
1937}
1938
1939////////////////////////////////////////////////////////////////////////////////
1940/// Toggle batch mode. However, if the canvas is created without a window
1941/// then batch mode always stays set.
1942
1944{
1945 if (gROOT->IsBatch() || IsWeb())
1946 fBatch = kTRUE;
1947 else
1948 fBatch = batch;
1949}
1950
1951////////////////////////////////////////////////////////////////////////////////
1952/// Set Width and Height of canvas to ww and wh respectively. If ww and/or wh
1953/// are greater than the current canvas window a scroll bar is automatically
1954/// generated. Use this function to zoom in a canvas and navigate via
1955/// the scroll bars. The Width and Height in this method are different from those
1956/// given in the TCanvas constructors where these two dimensions include the size
1957/// of the ROOT canvas menubar decoration whereas they do not in this method.
1958/// When both ww==0 and wh==0, auto resize mode will be enabled again and
1959/// canvas drawing area will automatically fit available window size
1960
1962{
1963 if (fCanvasImp) {
1964 fCw = ww;
1965 fCh = wh;
1967 TContext ctxt(this, kTRUE);
1968 ResizePad();
1969 }
1970}
1971
1972////////////////////////////////////////////////////////////////////////////////
1973/// Set cursor.
1974
1976{
1977 if (fCanvasImp)
1979}
1980
1981////////////////////////////////////////////////////////////////////////////////
1982/// Set Double Buffer On/Off.
1983
1985{
1986 if (IsBatch() || IsWeb())
1987 return;
1989 if (fCanvasID != -1)
1991
1992 // depending of the buffer mode set the drawing window to either
1993 // the canvas pixmap or to the canvas on-screen window
1994 if (fDoubleBuffer) {
1996 } else
1998}
1999
2000////////////////////////////////////////////////////////////////////////////////
2001/// Fix canvas aspect ratio to current value if fixed is true.
2002
2004{
2005 if (fixed) {
2006 if (!fFixedAspectRatio) {
2007 if (fCh != 0)
2009 else {
2010 Error("SetAspectRatio", "cannot fix aspect ratio, height of canvas is 0");
2011 return;
2012 }
2014 }
2015 } else {
2017 fAspectRatio = 0;
2018 }
2019}
2020
2021////////////////////////////////////////////////////////////////////////////////
2022/// If isfolder=kTRUE, the canvas can be browsed like a folder
2023/// by default a canvas is not browsable.
2024
2026{
2028}
2029
2030////////////////////////////////////////////////////////////////////////////////
2031/// Set canvas name. In case `name` is an empty string, a default name is set.
2032/// Canvas automatically marked as modified when SetName method called
2033
2034void TCanvas::SetName(const char *name)
2035{
2037
2038 Modified();
2039}
2040
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Function to resize a canvas so that the plot inside is shown in real aspect
2044/// ratio
2045///
2046/// \param[in] axis 1 for resizing horizontally (x-axis) in order to get real
2047/// aspect ratio, 2 for the resizing vertically (y-axis)
2048/// \return false if error is encountered, true otherwise
2049///
2050/// ~~~ {.cpp}
2051/// hpxpy->Draw();
2052/// c1->SetRealAspectRatio();
2053/// ~~~
2054///
2055/// - For defining the concept of real aspect ratio, it is assumed that x and y
2056/// axes are in same units, e.g. both in MeV or both in ns.
2057/// - You can resize either the width of the canvas or the height, but not both
2058/// at the same time
2059/// - Call this function AFTER drawing AND zooming (SetUserRange) your TGraph or
2060/// Histogram, otherwise it cannot infer your actual axes lengths
2061/// - This function ensures that the TFrame has a real aspect ratio, this does not
2062/// mean that the full pad (i.e. the canvas or png output) including margins has
2063/// exactly the same ratio
2064/// - This function does not work if the canvas is divided in several subpads
2065
2066bool TCanvas::SetRealAspectRatio(const Int_t axis)
2067{
2068 Update();
2069
2070 //Get how many pixels are occupied by the canvas
2071 Int_t npx = GetWw();
2072 Int_t npy = GetWh();
2073
2074 //Get x-y coordinates at the edges of the canvas (extrapolating outside the axes, NOT at the edges of the histogram)
2075 Double_t x1 = GetX1();
2076 Double_t y1 = GetY1();
2077 Double_t x2 = GetX2();
2078 Double_t y2 = GetY2();
2079
2080 //Get the length of extrapolated x and y axes
2081 Double_t xlength2 = x2 - x1;
2082 Double_t ylength2 = y2 - y1;
2084
2085 //Now get the number of pixels including the canvas borders
2088
2089 if (axis==1) {
2092 } else if (axis==2) {
2095 } else {
2096 Error("SetRealAspectRatio", "axis value %d is neither 1 (resize along x-axis) nor 2 (resize along y-axis).",axis);
2097 return false;
2098 }
2099
2100 //Check now that resizing has worked
2101
2102 Update();
2103
2104 //Get how many pixels are occupied by the canvas
2105 npx = GetWw();
2106 npy = GetWh();
2107
2108 //Get x-y coordinates at the edges of the canvas (extrapolating outside the axes,
2109 //NOT at the edges of the histogram)
2110 x1 = GetX1();
2111 y1 = GetY1();
2112 x2 = GetX2();
2113 y2 = GetY2();
2114
2115 //Get the length of extrapolated x and y axes
2116 xlength2 = x2 - x1;
2117 ylength2 = y2 - y1;
2119
2120 //Check accuracy +/-1 pixel due to rounding
2121 if (abs(TMath::Nint(npy*ratio2) - npx)<2) {
2122 return true;
2123 } else {
2124 Error("SetRealAspectRatio", "Resizing failed.");
2125 return false;
2126 }
2127}
2128
2129
2130////////////////////////////////////////////////////////////////////////////////
2131/// Set selected canvas.
2132
2134{
2135 fSelected = obj;
2136 if (obj) obj->SetBit(kMustCleanup);
2137}
2138
2139////////////////////////////////////////////////////////////////////////////////
2140/// Set canvas title.
2141
2142void TCanvas::SetTitle(const char *title)
2143{
2144 fTitle = title;
2146}
2147
2148////////////////////////////////////////////////////////////////////////////////
2149/// Set canvas window position
2150
2152{
2153 if (fCanvasImp)
2155}
2156
2157////////////////////////////////////////////////////////////////////////////////
2158/// Set canvas window size
2159
2161{
2162 if (fBatch && !IsWeb())
2163 SetCanvasSize((ww + fCw) / 2, (wh + fCh) / 2);
2164 else if (fCanvasImp)
2166}
2167
2168////////////////////////////////////////////////////////////////////////////////
2169/// Set canvas implementation
2170/// If web-based implementation provided, some internal fields also initialized
2171
2173{
2174 Bool_t was_web = IsWeb();
2175
2176 fCanvasImp = imp;
2177
2178 if (!was_web && IsWeb()) {
2180 fPixmapID = 0;
2181 fMother = this;
2182 if (!fCw) fCw = 800;
2183 if (!fCh) fCh = 600;
2184 } else if (was_web && !imp) {
2185 fCanvasID = -1;
2186 fPixmapID = -1;
2187 fMother = nullptr;
2188 fCw = fCh = 0;
2189 }
2190}
2191
2192////////////////////////////////////////////////////////////////////////////////
2193/// Set the canvas scale in centimeters.
2194///
2195/// This information is used by PostScript to set the page size.
2196///
2197/// \param[in] xsize size of the canvas in centimeters along X
2198/// \param[in] ysize size of the canvas in centimeters along Y
2199///
2200/// if xsize and ysize are not equal to 0, then the scale factors will
2201/// be computed to keep the ratio ysize/xsize independently of the canvas
2202/// size (parts of the physical canvas will be unused).
2203///
2204/// if xsize = 0 and ysize is not zero, then xsize will be computed
2205/// to fit to the current canvas scale. If the canvas is resized,
2206/// a new value for xsize will be recomputed. In this case the aspect
2207/// ratio is not preserved.
2208///
2209/// if both xsize = 0 and ysize = 0, then the scaling is automatic.
2210/// the largest dimension will be allocated a size of 20 centimeters.
2211
2213{
2214 fXsizeUser = xsize;
2215 fYsizeUser = ysize;
2216
2217 Resize();
2218}
2219
2220////////////////////////////////////////////////////////////////////////////////
2221/// Show canvas
2222
2223void TCanvas::Show()
2224{
2225 if (fCanvasImp)
2226 fCanvasImp->Show();
2227}
2228
2229////////////////////////////////////////////////////////////////////////////////
2230/// Stream a class object.
2231
2233{
2234 UInt_t R__s, R__c;
2235 if (b.IsReading()) {
2236 Version_t v = b.ReadVersion(&R__s, &R__c);
2237 gPad = this;
2238 fCanvas = this;
2239 if (v>7) b.ClassBegin(TCanvas::IsA());
2240 if (v>7) b.ClassMember("TPad");
2242 gPad = this;
2243 //restore the colors
2244 auto colors = dynamic_cast<TObjArray *>(fPrimitives->FindObject("ListOfColors"));
2245 if (colors) {
2246 auto root_colors = dynamic_cast<TObjArray *>(gROOT->GetListOfColors());
2247
2248 TIter next(colors);
2249 while (auto colold = static_cast<TColor *>(next())) {
2250 Int_t cn = colold->GetNumber();
2251 TColor *colcur = gROOT->GetColor(cn);
2252 if (colcur && (colcur->IsA() == TColor::Class()) && (colold->IsA() == TColor::Class())) {
2253 colcur->SetName(colold->GetName());
2254 colcur->SetRGB(colold->GetRed(), colold->GetGreen(), colold->GetBlue());
2255 colcur->SetAlpha(colold->GetAlpha());
2256 } else {
2257 if (colcur) {
2258 if (root_colors) root_colors->Remove(colcur);
2259 delete colcur;
2260 }
2261 colors->Remove(colold);
2262 if (root_colors) {
2263 if (colcur) {
2264 root_colors->AddAtAndExpand(colold, cn);
2265 }
2266 else {
2267 // Copy to current session
2268 // do not use copy constructor which does not update highest color index
2269 [[maybe_unused]] TColor* const colnew = new TColor(cn, colold->GetRed(), colold->GetGreen(), colold->GetBlue(), colold->GetName(), colold->GetAlpha());
2270 delete colold;
2271 // No need to delete colnew, as the constructor adds it to global list of colors
2272 assert(root_colors->At(cn) == colnew);
2273 }
2274 }
2275 }
2276 }
2277 //restore the palette if needed
2278 auto palette = dynamic_cast<TObjArray *>(fPrimitives->FindObject("CurrentColorPalette"));
2279 if (palette) {
2281 Int_t number = palette->GetEntries();
2282 TArrayI palcolors(number);
2283 Int_t i = 0;
2284 while (auto col = static_cast<TColor *>(nextcol()))
2285 palcolors[i++] = col->GetNumber();
2286 gStyle->SetPalette(number, palcolors.GetArray());
2288 delete palette;
2289 }
2291 colors->Delete();
2292 delete colors;
2293 }
2294
2295 if (v>7) b.ClassMember("fDISPLAY","TString");
2297 if (v>7) b.ClassMember("fDoubleBuffer", "Int_t");
2298 b >> fDoubleBuffer;
2299 if (v>7) b.ClassMember("fRetained", "Bool_t");
2300 b >> fRetained;
2301 if (v>7) b.ClassMember("fXsizeUser", "Size_t");
2302 b >> fXsizeUser;
2303 if (v>7) b.ClassMember("fYsizeUser", "Size_t");
2304 b >> fYsizeUser;
2305 if (v>7) b.ClassMember("fXsizeReal", "Size_t");
2306 b >> fXsizeReal;
2307 if (v>7) b.ClassMember("fYsizeReal", "Size_t");
2308 b >> fYsizeReal;
2309 fCanvasID = -1;
2310 if (v>7) b.ClassMember("fWindowTopX", "Int_t");
2311 b >> fWindowTopX;
2312 if (v>7) b.ClassMember("fWindowTopY", "Int_t");
2313 b >> fWindowTopY;
2314 if (v > 2) {
2315 if (v>7) b.ClassMember("fWindowWidth", "UInt_t");
2316 b >> fWindowWidth;
2317 if (v>7) b.ClassMember("fWindowHeight", "UInt_t");
2318 b >> fWindowHeight;
2319 }
2320 if (v>7) b.ClassMember("fCw", "UInt_t");
2321 b >> fCw;
2322 if (v>7) b.ClassMember("fCh", "UInt_t");
2323 b >> fCh;
2324 if (v <= 2) {
2325 fWindowWidth = fCw;
2327 }
2328 if (v>7) b.ClassMember("fCatt", "TAttCanvas");
2329 fCatt.Streamer(b);
2330 Bool_t dummy;
2331 if (v>7) b.ClassMember("kMoveOpaque", "Bool_t");
2332 b >> dummy; if (dummy) MoveOpaque(1);
2333 if (v>7) b.ClassMember("kResizeOpaque", "Bool_t");
2334 b >> dummy; if (dummy) ResizeOpaque(1);
2335 if (v>7) b.ClassMember("fHighLightColor", "Color_t");
2336 b >> fHighLightColor;
2337 if (v>7) b.ClassMember("fBatch", "Bool_t");
2338 b >> dummy; //was fBatch
2339 if (v < 2) return;
2340 if (v>7) b.ClassMember("kShowEventStatus", "Bool_t");
2341 b >> dummy; if (dummy) SetBit(kShowEventStatus);
2342
2343 if (v > 3) {
2344 if (v>7) b.ClassMember("kAutoExec", "Bool_t");
2345 b >> dummy; if (dummy) SetBit(kAutoExec);
2346 }
2347 if (v>7) b.ClassMember("kMenuBar", "Bool_t");
2348 b >> dummy; if (dummy) SetBit(kMenuBar);
2349 fBatch = gROOT->IsBatch();
2350 if (v>7) b.ClassEnd(TCanvas::IsA());
2351 b.CheckByteCount(R__s, R__c, TCanvas::IsA());
2352 } else {
2353 //save list of colors
2354 //we must protect the case when two or more canvases are saved
2355 //in the same buffer. If the list of colors has already been saved
2356 //in the buffer, do not add the list of colors to the list of primitives.
2357 TObjArray *colors = nullptr;
2358 TObjArray *CurrentColorPalette = nullptr;
2359 // fPrimitives can be temporarily null while streaming a web-canvas
2360 // snapshot (see TWebCanvas::CreatePadSnapshot). In that case colors and
2361 // palette are delivered separately, so the list of colors must not be
2362 // added here. The guard also avoids a null dereference that crashes when
2363 // colors storage has been forced on via TColor::DefinedColors(1)
2364 // (see https://github.com/root-project/root/issues/20018).
2366 if (!b.CheckObject(gROOT->GetListOfColors(),TObjArray::Class())) {
2367 colors = (TObjArray*)gROOT->GetListOfColors();
2369 }
2370 //save the current palette
2372 Int_t palsize = pal.GetSize();
2374 CurrentColorPalette->SetName("CurrentColorPalette");
2375 for (Int_t i=0; i<palsize; i++) CurrentColorPalette->Add(gROOT->GetColor(pal[i]));
2377 }
2378
2379 R__c = b.WriteVersion(TCanvas::IsA(), kTRUE);
2380 b.ClassBegin(TCanvas::IsA());
2381 b.ClassMember("TPad");
2385 b.ClassMember("fDISPLAY","TString");
2387 b.ClassMember("fDoubleBuffer", "Int_t");
2388 b << fDoubleBuffer;
2389 b.ClassMember("fRetained", "Bool_t");
2390 b << fRetained;
2391 b.ClassMember("fXsizeUser", "Size_t");
2392 b << fXsizeUser;
2393 b.ClassMember("fYsizeUser", "Size_t");
2394 b << fYsizeUser;
2395 b.ClassMember("fXsizeReal", "Size_t");
2396 b << fXsizeReal;
2397 b.ClassMember("fYsizeReal", "Size_t");
2398 b << fYsizeReal;
2401 UInt_t editorWidth = 0;
2403 b.ClassMember("fWindowTopX", "Int_t");
2404 b << topx;
2405 b.ClassMember("fWindowTopY", "Int_t");
2406 b << topy;
2407 b.ClassMember("fWindowWidth", "UInt_t");
2408 b << (UInt_t)(w-editorWidth);
2409 b.ClassMember("fWindowHeight", "UInt_t");
2410 b << h;
2411 b.ClassMember("fCw", "UInt_t");
2412 b << fCw;
2413 b.ClassMember("fCh", "UInt_t");
2414 b << fCh;
2415 b.ClassMember("fCatt", "TAttCanvas");
2416 fCatt.Streamer(b);
2417 b.ClassMember("kMoveOpaque", "Bool_t");
2418 b << TestBit(kMoveOpaque); //please remove in ROOT version 6
2419 b.ClassMember("kResizeOpaque", "Bool_t");
2420 b << TestBit(kResizeOpaque); //please remove in ROOT version 6
2421 b.ClassMember("fHighLightColor", "Color_t");
2422 b << fHighLightColor;
2423 b.ClassMember("fBatch", "Bool_t");
2424 b << fBatch; //please remove in ROOT version 6
2425 b.ClassMember("kShowEventStatus", "Bool_t");
2426 b << TestBit(kShowEventStatus); //please remove in ROOT version 6
2427 b.ClassMember("kAutoExec", "Bool_t");
2428 b << TestBit(kAutoExec); //please remove in ROOT version 6
2429 b.ClassMember("kMenuBar", "Bool_t");
2430 b << TestBit(kMenuBar); //please remove in ROOT version 6
2431 b.ClassEnd(TCanvas::IsA());
2432 b.SetByteCount(R__c, kTRUE);
2433 }
2434}
2435
2436////////////////////////////////////////////////////////////////////////////////
2437/// Toggle pad auto execution of list of TExecs.
2438
2440{
2443}
2444
2445////////////////////////////////////////////////////////////////////////////////
2446/// Toggle event statusbar.
2447
2449{
2452
2454}
2455
2456////////////////////////////////////////////////////////////////////////////////
2457/// Toggle toolbar.
2458
2460{
2463
2465}
2466
2467////////////////////////////////////////////////////////////////////////////////
2468/// Toggle editor.
2469
2471{
2474
2476}
2477
2478////////////////////////////////////////////////////////////////////////////////
2479/// Toggle tooltip display.
2480
2482{
2485
2487}
2488
2489
2490////////////////////////////////////////////////////////////////////////////////
2491/// Static function returning "true" if transparency is supported.
2492
2494{
2495 if (gPad)
2496 if (auto pp = gPad->GetPainter())
2497 return pp->IsSupportAlpha();
2498 return kFALSE;
2499}
2500
2501extern "C" void ROOT_TCanvas_Update(void* TheCanvas) {
2502 static_cast<TCanvas*>(TheCanvas)->Update();
2503}
2504
2505////////////////////////////////////////////////////////////////////////////////
2506/// Update canvas pad buffers.
2507
2508void TCanvas::Update()
2509{
2510 fUpdated = kTRUE;
2511
2512 if (fUpdating) return;
2513
2514 if (fPixmapID == -1) return;
2515
2516 static const union CastFromFuncToVoidPtr_t {
2518 void (*fFuncPtr)(void*);
2519 void* fVoidPtr;
2521
2522 if (gThreadXAR) {
2523 void *arr[3];
2524 arr[1] = this;
2525 arr[2] = castFromFuncToVoidPtr.fVoidPtr;
2526 if ((*gThreadXAR)("CUPD", 3, arr, nullptr)) return;
2527 }
2528
2529 if (!fCanvasImp) return;
2530
2531 if (!gVirtualX->IsCmdThread()) {
2532 // Why do we have this (which uses the interpreter to funnel the Update()
2533 // through the main thread) when the gThreadXAR mechanism does seemingly
2534 // the same?
2535 gInterpreter->Execute(this, IsA(), "Update", "");
2536 return;
2537 }
2538
2540
2541 fUpdating = kTRUE;
2542
2544
2545 if (!IsBatch()) FeedbackMode(kFALSE); // Goto double buffer mode
2546
2547 if (!UseGL() || fGLDevice == -1) PaintModified(); // Repaint all modified pad's
2548
2549 Flush(); // Copy all pad pixmaps to the screen
2550
2552 }
2553
2554 fUpdating = kFALSE;
2555}
2556
2557////////////////////////////////////////////////////////////////////////////////
2558/// Asynchronous pad update.
2559/// In case of web-based canvas triggers update of the canvas on the client side,
2560/// but does not wait that real update is completed. Avoids blocking of caller thread.
2561/// Have to be used if called from other web-based widget to avoid logical dead-locks.
2562/// In case of normal canvas just canvas->Update() is performed.
2563
2565{
2566 fUpdated = kTRUE;
2567
2568 if (IsWeb())
2570 else
2571 Update();
2572}
2573
2574////////////////////////////////////////////////////////////////////////////////
2575/// Used by friend class TCanvasImp.
2576
2578{
2579 fCanvasID = 0;
2580 fContextMenu = nullptr;
2581}
2582
2583////////////////////////////////////////////////////////////////////////////////
2584/// Check whether this canvas is to be drawn in grayscale mode.
2585
2587{
2588 return TestBit(kIsGrayscale);
2589}
2590
2591////////////////////////////////////////////////////////////////////////////////
2592/// Set whether this canvas should be painted in grayscale, and re-paint
2593/// it if necessary.
2594
2595void TCanvas::SetGrayscale(Bool_t set /*= kTRUE*/)
2596{
2597 if (IsGrayscale() == set) return;
2598 SetBit(kIsGrayscale, set);
2599 if (IsWeb()) {
2600 Modified();
2601 UpdateAsync();
2602 } else {
2603 Paint(); // update canvas and all sub-pads, unconditionally!
2604 }
2605}
2606
2607////////////////////////////////////////////////////////////////////////////////
2608/// Probably, TPadPainter must be placed in a separate ROOT module -
2609/// "padpainter" (the same as "histpainter"). But now, it's directly in a
2610/// gpad dir, so, in case of default painter, no *.so should be loaded,
2611/// no need in plugin managers.
2612/// May change in future.
2613
2615{
2616 //Even for batch mode painter is still required, just to delegate
2617 //some calls to batch "virtual X".
2618 if (!UseGL() || fBatch || IsWeb()) {
2619 fPainter = nullptr;
2621 if (!fPainter) fPainter = new TPadPainter; // Do not need plugin manager for this!
2622 } else {
2624 if (!fPainter) {
2625 Error("CreatePainter", "GL Painter creation failed! Will use default!");
2626 fPainter = new TPadPainter;
2627 fUseGL = kFALSE;
2628 }
2629 }
2630}
2631
2632////////////////////////////////////////////////////////////////////////////////
2633/// Access and (probably) creation of pad painter.
2634
2636{
2637 if (!fPainter) CreatePainter();
2638 return fPainter;
2639}
2640
2641////////////////////////////////////////////////////////////////////////////////
2642/// Replace canvas painter
2643/// For internal use only - when creating PS images
2644
2646{
2647 if (!create) {
2648 delete fPainter;
2649 fPainter = oldp;
2650 return kFALSE;
2651 }
2652
2653 if (!gVirtualPS /* || !IsBatch() */)
2654 return kFALSE;
2655
2656
2658 return kFALSE;
2659
2660 oldp = fPainter;
2662 return kTRUE;
2663}
2664
2665////////////////////////////////////////////////////////////////////////////////
2666///assert on IsBatch() == false?
2667
2669{
2670 if (fGLDevice != -1) {
2671 //fPainter has a font manager.
2672 //Font manager will delete textures.
2673 //If context is wrong (we can have several canvases) -
2674 //wrong texture will be deleted, damaging some of our fonts.
2675 gGLManager->MakeCurrent(fGLDevice);
2676 }
2677
2679
2680 if (fGLDevice != -1) {
2681 gGLManager->DeleteGLContext(fGLDevice);//?
2682 fGLDevice = -1;
2683 }
2684}
2685
2686
2687////////////////////////////////////////////////////////////////////////////////
2688/// Save provided pads/canvases into the image file(s)
2689/// Filename can include printf argument for image number - like "image%03d.png".
2690/// In this case images: "image000.png", "image001.png", "image002.png" will be created.
2691/// If pattern is not provided - it will be automatically inserted before extension except PDF and ROOT files.
2692/// In last case PDF or ROOT file will contain all pads.
2693/// Parameter option only used when output into PDF/PS files
2694/// If TCanvas::SaveAll() called without arguments - all existing canvases will be stored in allcanvases.pdf file.
2695
2696Bool_t TCanvas::SaveAll(const std::vector<TPad *> &pads, const char *filename, Option_t *option)
2697{
2698 if (pads.empty()) {
2699 std::vector<TPad *> canvases;
2700 TIter iter(gROOT->GetListOfCanvases());
2701 while (auto c = dynamic_cast<TCanvas *>(iter()))
2702 canvases.emplace_back(c);
2703
2704 if (canvases.empty()) {
2705 ::Warning("TCanvas::SaveAll", "No pads are provided");
2706 return kFALSE;
2707 }
2708
2709 return TCanvas::SaveAll(canvases, filename && *filename ? filename : "allcanvases.pdf", option);
2710 }
2711
2713
2714 Bool_t hasArg = fname.Contains("%");
2715
2716 if ((pads.size() == 1) && !hasArg) {
2717 pads[0]->SaveAs(filename);
2718 return kTRUE;
2719 }
2720
2721 auto p = fname.Last('.');
2722 if (p != kNPOS) {
2723 ext = fname(p+1, fname.Length() - p - 1);
2724 ext.ToLower();
2725 } else {
2726 p = fname.Length();
2727 ::Warning("TCanvas::SaveAll", "Extension is not provided in file name %s, append .png", filename);
2728 fname.Append(".png");
2729 ext = "png";
2730 }
2731
2732 if (ext != "pdf" && ext != "ps" && ext != "root" && ext != "html" && ext != "xml" && !hasArg) {
2733 fname.Insert(p, "%d");
2734 hasArg = kTRUE;
2735 }
2736
2737 static std::vector<TString> webExtensions = { "png", "json", "html", "svg", "pdf", "jpg", "jpeg", "webp" };
2738
2739 if (gROOT->IsWebDisplay() || (ext == "html")) {
2741 for (auto &wext : webExtensions) {
2742 if ((isSupported = (wext == ext)))
2743 break;
2744 }
2745
2746 if (isSupported) {
2747 auto cmd = TString::Format("TWebCanvas::ProduceImages( *((std::vector<TPad *> *) 0x%zx), \"%s\");", (size_t) &pads, fname.Data());
2748
2749 return (Bool_t) gROOT->ProcessLine(cmd);
2750 }
2751
2752 if ((ext != "root") && (ext != "xml"))
2753 ::Warning("TCanvas::SaveAll", "TWebCanvas does not support image format %s - using normal ROOT functionality", fname.Data());
2754 }
2755
2756 // store all pads into single PDF/PS files
2757 if (ext == "pdf" || ext == "ps") {
2758 for (unsigned n = 0; n < pads.size(); ++n) {
2759 TString fn = fname;
2760 if (hasArg)
2761 fn = TString::Format(fname.Data(), (int) n);
2762 else if (n == 0)
2763 fn.Append("(");
2764 else if (n == pads.size() - 1)
2765 fn.Append(")");
2766
2767 pads[n]->Print(fn.Data(), option && *option ? option : ext.Data());
2768 }
2769
2770 return kTRUE;
2771 }
2772
2773 // store all pads in single ROOT file
2774 if ((ext == "root" || ext == "xml") && !hasArg) {
2775 TString fn = fname;
2777 if (fn.IsNull()) {
2778 fn.Form("%s.%s", pads[0]->GetName(), ext.Data());
2779 ::Warning("TCanvas::SaveAll", "Filename %s cannot be used - use pad name %s as pattern", fname.Data(), fn.Data());
2780 }
2781
2783
2784 if (!gDirectory) {
2785 isError = kTRUE;
2786 } else {
2787 for (unsigned n = 0; n < pads.size(); ++n) {
2788 auto sz = gDirectory->SaveObjectAs(pads[n], fn.Data(), n==0 ? "q" : "qa");
2789 if (!sz) { isError = kTRUE; break; }
2790 }
2791 }
2792
2793 if (isError)
2794 ::Error("TCanvas::SaveAll", "Failure to store pads in %s", filename);
2795 else
2796 ::Info("TCanvas::SaveAll", "ROOT file %s has been created", filename);
2797
2798 return !isError;
2799 }
2800
2801 for (unsigned n = 0; n < pads.size(); ++n) {
2802 TString fn = TString::Format(fname.Data(), (int) n);
2804 if (fn.IsNull()) {
2805 fn.Form("%s%d.%s", pads[n]->GetName(), (int) n, ext.Data());
2806 ::Warning("TCanvas::SaveAll", "Filename %s cannot be used - use pad name %s as pattern", fname.Data(), fn.Data());
2807 }
2808
2809 pads[n]->SaveAs(fn.Data());
2810 }
2811
2812 return kTRUE;
2813
2814}
EEventType
Definition Buttons.h:15
@ kButton1ShiftMotion
Definition Buttons.h:18
@ kMouseMotion
Definition Buttons.h:23
@ kWheelUp
Definition Buttons.h:18
@ kButton3Up
Definition Buttons.h:19
@ kButton2Motion
Definition Buttons.h:20
@ kButton3Motion
Definition Buttons.h:20
@ kButton3Down
Definition Buttons.h:17
@ kButton2Down
Definition Buttons.h:17
@ kKeyPress
Definition Buttons.h:20
@ kButton2Double
Definition Buttons.h:24
@ kArrowKeyRelease
Definition Buttons.h:21
@ kButton1Double
Definition Buttons.h:24
@ kButton3Double
Definition Buttons.h:24
@ kButton1Shift
Definition Buttons.h:18
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kWheelDown
Definition Buttons.h:18
@ kArrowKeyPress
Definition Buttons.h:21
@ kButton2Up
Definition Buttons.h:19
@ kMouseLeave
Definition Buttons.h:23
@ kButton1Down
Definition Buttons.h:17
@ kMouseEnter
Definition Buttons.h:23
ECursor
Definition GuiTypes.h:373
@ kCross
Definition GuiTypes.h:375
#define SafeDelete(p)
Definition RConfig.hxx:507
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
cudaEvent_t event
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
float Size_t
Attribute size (float)
Definition RtypesCore.h:104
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
short Version_t
Class version identifier (short)
Definition RtypesCore.h:80
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
@ kRed
Definition Rtypes.h:66
R__EXTERN TApplication * gApplication
void ROOT_TCanvas_Update(void *TheCanvas)
Definition TCanvas.cxx:2498
class TCanvasInit gCanvasInit
TString GetNewCanvasName(const char *arg=nullptr)
Definition TCanvas.cxx:67
const Size_t kDefaultCanvasSize
Definition TCanvas.cxx:64
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gDirectory
Definition TDirectory.h:385
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetDoubleBuffer
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t SetFillStyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetCursor
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:142
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition TGuiFactory.h:69
R__EXTERN TGuiFactory * gGuiFactory
Definition TGuiFactory.h:68
#define gInterpreter
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:792
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:417
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define gGLManager
Definition TVirtualGL.h:158
#define R__LOCKGUARD(mutex)
R__EXTERN TVirtualPS * gVirtualPS
Definition TVirtualPS.h:93
#define gPad
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
#define gVirtualX
Definition TVirtualX.h:379
void InitializeGraphics(Bool_t only_web=kFALSE)
Initialize the graphics environment.
static void CreateApplication()
Static function used to create a default application environment.
static void NeedGraphicsLibs()
Static method.
Array of integers (32 bits per element).
Definition TArrayI.h:27
virtual void Streamer(TBuffer &)
Fill Area Attributes class.
Definition TAttFill.h:21
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition TAttFill.cxx:203
Line Attributes class.
Definition TAttLine.h:21
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition TAttLine.cxx:176
Manages default Pad attributes.
Definition TAttPad.h:19
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition TAttPad.cxx:98
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition TAttPad.cxx:108
virtual void Copy(TAttPad &attpad) const
copy function
Definition TAttPad.cxx:43
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition TAttPad.cxx:118
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition TAttPad.cxx:128
Class to manage histogram axis.
Definition TAxis.h:32
static TClass * Class()
Create a Box.
Definition TBox.h:22
static TClass * Class()
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Buffer base class used for serializing objects.
Definition TBuffer.h:43
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area).
Definition TCanvasImp.h:31
virtual void SetStatusText(const char *text=nullptr, Int_t partidx=0)
Definition TCanvasImp.h:71
virtual void SetWindowPosition(Int_t x, Int_t y)
Definition TCanvasImp.h:72
virtual void ShowMenuBar(Bool_t show=kTRUE)
Definition TCanvasImp.h:78
virtual void Show()
Definition TCanvasImp.h:77
virtual Bool_t PerformUpdate(Bool_t)
Definition TCanvasImp.h:50
virtual void ShowToolTips(Bool_t show=kTRUE)
Definition TCanvasImp.h:85
virtual void Iconify()
Definition TCanvasImp.h:69
virtual Int_t InitWindow()
Definition TCanvasImp.h:70
virtual void UpdateDisplay(Int_t mode=0, Bool_t sleep=kFALSE)
Update gVirtualX display, also optionally sleep to wait until operation finished.
virtual void Close()
Definition TCanvasImp.h:60
virtual void SetWindowTitle(const char *newTitle)
Definition TCanvasImp.h:74
virtual void GetCanvasGeometry(Int_t wid, UInt_t &w, UInt_t &h)
Gets the size and position of the canvas paint area.
virtual Bool_t IsWeb() const
Definition TCanvasImp.h:49
virtual UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Definition TCanvasImp.h:62
virtual void ResizeCanvasWindow(Int_t wid)
Resize canvas window, redirect to gVirtualX.
virtual TVirtualPadPainter * CreatePadPainter()
Definition TCanvasImp.h:51
virtual void ShowEditor(Bool_t show=kTRUE)
Definition TCanvasImp.h:83
virtual void RaiseWindow()
Definition TCanvasImp.h:80
virtual void SetWindowSize(UInt_t width, UInt_t height)
Definition TCanvasImp.h:73
virtual void SetCursor(ECursor cursor)
Definition TCanvasImp.h:76
virtual void SetCanvasSize(UInt_t w, UInt_t h)
Definition TCanvasImp.h:75
virtual void ForceUpdate()
Definition TCanvasImp.h:61
virtual void ShowStatusBar(Bool_t show=kTRUE)
Definition TCanvasImp.h:79
virtual void ShowToolBar(Bool_t show=kTRUE)
Definition TCanvasImp.h:84
The Canvas class.
Definition TCanvas.h:23
void Init()
Initialize the TCanvas members. Called by all constructors.
Definition TCanvas.cxx:547
UInt_t fCw
Width of the canvas along X (pixels)
Definition TCanvas.h:44
~TCanvas() override
Canvas destructor.
Definition TCanvas.cxx:687
void EmbedInto(Int_t winid, Int_t ww, Int_t wh)
Embedded a canvas into a TRootEmbeddedCanvas.
Definition TCanvas.cxx:1060
void SetWindowSize(UInt_t ww, UInt_t wh)
Set canvas window size.
Definition TCanvas.cxx:2157
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:2022
void Browse(TBrowser *b) override
Browse.
Definition TCanvas.cxx:695
UInt_t GetWindowHeight() const
Definition TCanvas.h:166
virtual void EditorBar()
Get editor bar.
Definition TCanvas.cxx:1051
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
Definition TCanvas.cxx:1522
void EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
Generate kMouseEnter and kMouseLeave events depending on the previously selected object and the curre...
Definition TCanvas.cxx:1086
Size_t fYsizeReal
Current size of canvas along Y in CM.
Definition TCanvas.h:37
void Constructor()
Canvas default constructor.
Definition TCanvas.cxx:201
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition TCanvas.cxx:2436
TCanvas(const TCanvas &canvas)=delete
Int_t fWindowTopX
Top X position of window (in pixels)
Definition TCanvas.h:40
void Draw(Option_t *option="") override
Draw a canvas.
Definition TCanvas.cxx:866
void SetDoubleBuffer(Int_t mode=1) override
Set Double Buffer On/Off.
Definition TCanvas.cxx:1981
virtual void ToggleToolTips()
Toggle tooltip display.
Definition TCanvas.cxx:2478
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:747
void UseCurrentStyle() override
Force a copy of current style for all objects in canvas.
Definition TCanvas.cxx:1192
void Iconify()
Iconify canvas.
Definition TCanvas.cxx:1485
Int_t GetWindowTopX()
Returns current top x position of window on screen.
Definition TCanvas.cxx:1217
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2445
void Destructor()
Actual canvas destructor.
Definition TCanvas.cxx:705
Bool_t fUpdated
! Set to True when Update method was called
Definition TCanvas.h:65
void DeleteCanvasPainter()
assert on IsBatch() == false?
Definition TCanvas.cxx:2665
TPad * fPadSave
! Pointer to saved pad in HandleInput
Definition TCanvas.h:57
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
Definition TCanvas.cxx:2490
Bool_t fBatch
! True when in batchmode
Definition TCanvas.h:60
Bool_t fUseGL
! True when rendering is with GL
Definition TCanvas.h:63
Int_t fEventX
! Last X mouse position in canvas
Definition TCanvas.h:47
Bool_t IsBatch() const override
Definition TCanvas.h:177
TObject * DrawClone(Option_t *option="") const override
Draw a clone of this canvas A new canvas is created that is a clone of this canvas.
Definition TCanvas.cxx:919
Size_t fXsizeReal
Current size of canvas along X in CM.
Definition TCanvas.h:36
Bool_t HasMenuBar() const
Definition TCanvas.h:174
TVirtualPadPainter * GetCanvasPainter()
Access and (probably) creation of pad painter.
Definition TCanvas.cxx:2632
virtual void HighlightConnect(const char *slot)
This is "simplification" for function TCanvas::Connect with Highlighted signal for specific slot.
Definition TCanvas.cxx:1637
TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj) override
Search for an object at pixel position px,py.
Definition TCanvas.h:189
void Close(Option_t *option="") override
Close canvas.
Definition TCanvas.cxx:798
void SetFixedAspectRatio(Bool_t fixed=kTRUE) override
Fix canvas aspect ratio to current value if fixed is true.
Definition TCanvas.cxx:2000
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition TCanvas.cxx:1674
Color_t GetHighLightColor() const override
Definition TCanvas.h:142
Bool_t GetShowToolBar() const
Definition TCanvas.h:153
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:990
Bool_t IsFolder() const override
Is folder ?
Definition TCanvas.cxx:1494
Bool_t EnsurePSPainter(Bool_t create, TVirtualPadPainter *&oldp)
Replace canvas painter For internal use only - when creating PS images.
Definition TCanvas.cxx:2642
UInt_t fWindowWidth
Width of window (including borders, etc.)
Definition TCanvas.h:42
TVirtualPadPainter * fPainter
! Canvas (pad) painter.
Definition TCanvas.h:67
void CopyPixmaps() override
Copy the canvas pixmap of the pad to the canvas.
Definition TCanvas.cxx:848
Bool_t IsGrayscale()
Check whether this canvas is to be drawn in grayscale mode.
Definition TCanvas.cxx:2583
TPad * fClickSelectedPad
! Pad containing currently click-selected object
Definition TCanvas.h:56
Bool_t fUpdating
! True when Updating the canvas
Definition TCanvas.h:61
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1820
void SetCanvasImp(TCanvasImp *i)
Set canvas implementation If web-based implementation provided, some internal fields also initialized...
Definition TCanvas.cxx:2169
Color_t fHighLightColor
Highlight color of active pad.
Definition TCanvas.h:38
virtual void Size(Float_t xsizeuser=0, Float_t ysizeuser=0)
Set the canvas scale in centimeters.
Definition TCanvas.cxx:2209
virtual void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected)
Emit ProcessedEvent() signal.
Definition TCanvas.cxx:1659
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1241
void UpdateAsync() override
Asynchronous pad update.
Definition TCanvas.cxx:2561
Size_t fXsizeUser
User specified size of canvas along X in CM.
Definition TCanvas.h:34
Int_t fEventY
! Last Y mouse position in canvas
Definition TCanvas.h:48
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition TCanvas.cxx:729
UInt_t fWindowHeight
Height of window (including menubar, borders, etc.)
Definition TCanvas.h:43
Int_t GetWindowTopY()
Returns current top y position of window on screen.
Definition TCanvas.cxx:1228
TObject * fClickSelected
! Currently click-selected object
Definition TCanvas.h:51
void SetCanvasSize(UInt_t ww, UInt_t wh) override
Set Width and Height of canvas to ww and wh respectively.
Definition TCanvas.cxx:1958
void Show()
Show canvas.
Definition TCanvas.cxx:2220
TPad * fSelectedPad
! Pad containing currently selected object
Definition TCanvas.h:55
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
Definition TCanvas.cxx:1645
Int_t fSelectedX
! X of selected object
Definition TCanvas.h:52
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2467
TVirtualPad * GetSelectedPad() const override
Definition TCanvas.h:150
virtual void Picked(TPad *selpad, TObject *selected, Int_t event)
Emit Picked() signal.
Definition TCanvas.cxx:1599
TObject * fSelected
! Currently selected object
Definition TCanvas.h:50
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitives in this canvas in C++ macro file with GUI.
Definition TCanvas.cxx:1786
void SetCursor(ECursor cursor) override
Set cursor.
Definition TCanvas.cxx:1972
void Streamer(TBuffer &) override
Stream a class object.
Definition TCanvas.cxx:2229
Bool_t GetShowToolTips() const
Definition TCanvas.h:155
Int_t fCanvasID
! Canvas identifier
Definition TCanvas.h:49
void SetGrayscale(Bool_t set=kTRUE)
Set whether this canvas should be painted in grayscale, and re-paint it if necessary.
Definition TCanvas.cxx:2592
void SetTitle(const char *title="") override
Set canvas title.
Definition TCanvas.cxx:2139
UInt_t fCh
Height of the canvas along Y (pixels)
Definition TCanvas.h:45
TContextMenu * fContextMenu
! Context menu pointer
Definition TCanvas.h:59
TAttCanvas fCatt
Canvas attributes.
Definition TCanvas.h:32
void SetName(const char *name="") override
Set canvas name.
Definition TCanvas.cxx:2031
UInt_t GetWindowWidth() const
Definition TCanvas.h:165
Bool_t fRetained
Retain structure flag.
Definition TCanvas.h:62
void DisconnectWidget()
Used by friend class TCanvasImp.
Definition TCanvas.cxx:2574
void FeedbackMode(Bool_t set)
Turn rubberband feedback mode on or off.
Definition TCanvas.cxx:1140
void ls(Option_t *option="") const override
List all pads.
Definition TCanvas.cxx:1510
void RaiseWindow()
Raise canvas window.
Definition TCanvas.cxx:1752
void Build()
Build a canvas. Called by all constructors.
Definition TCanvas.cxx:597
static Bool_t SaveAll(const std::vector< TPad * > &={}, const char *filename="", Option_t *option="")
Save provided pads/canvases into the image file(s) Filename can include printf argument for image num...
Definition TCanvas.cxx:2693
Int_t fWindowTopY
Top Y position of window (in pixels)
Definition TCanvas.h:41
void Paint(Option_t *option="") override
Paint canvas.
Definition TCanvas.cxx:1549
TClass * IsA() const override
Definition TCanvas.h:244
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2505
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TCanvas.cxx:1122
void RunAutoExec()
Execute the list of TExecs in the current pad.
Definition TCanvas.cxx:1775
virtual void Cleared(TVirtualPad *pad)
Emit pad Cleared signal.
Definition TCanvas.cxx:780
UInt_t GetWw() const override
Definition TCanvas.h:167
TCanvasImp * fCanvasImp
! Window system specific canvas implementation
Definition TCanvas.h:58
UInt_t GetWh() const override
Definition TCanvas.h:168
virtual void Highlighted(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)
Emit Highlighted() signal.
Definition TCanvas.cxx:1618
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1154
Size_t fYsizeUser
User specified size of canvas along Y in CM.
Definition TCanvas.h:35
Int_t fDoubleBuffer
Double buffer flag (0=off, 1=on)
Definition TCanvas.h:39
void ForceUpdate()
Force canvas update.
Definition TCanvas.cxx:1184
void CreatePainter()
Probably, TPadPainter must be placed in a separate ROOT module - "padpainter" (the same as "histpaint...
Definition TCanvas.cxx:2611
void SetSelected(TObject *obj) override
Set selected canvas.
Definition TCanvas.cxx:2130
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition TCanvas.cxx:1541
static Bool_t fgIsFolder
Indicates if canvas can be browsed as a folder.
Definition TCanvas.h:71
void Closed() override
Emit Closed signal.
Definition TCanvas.cxx:788
Bool_t IsWeb() const override
Is web canvas.
Definition TCanvas.cxx:1502
void SetWindowPosition(Int_t x, Int_t y)
Set canvas window position.
Definition TCanvas.cxx:2148
TString fDISPLAY
Name of destination screen.
Definition TCanvas.h:33
bool SetRealAspectRatio(const Int_t axis=1)
Function to resize a canvas so that the plot inside is shown in real aspect ratio.
Definition TCanvas.cxx:2063
Int_t fEvent
! Type of current or last handled event
Definition TCanvas.h:46
Bool_t GetShowEventStatus() const
Definition TCanvas.h:152
TString fSelectedOpt
! Drawing option of selected object
Definition TCanvas.h:54
Int_t fSelectedY
! Y of selected object
Definition TCanvas.h:53
Bool_t fDrawn
! Set to True when the Draw method is called
Definition TCanvas.h:64
void SetBatch(Bool_t batch=kTRUE) override
Toggle batch mode.
Definition TCanvas.cxx:1940
Bool_t UseGL() const
Definition TCanvas.h:234
@ kResizeOpaque
Definition TCanvas.h:99
@ kShowToolTips
Definition TCanvas.h:101
@ kShowToolBar
Definition TCanvas.h:96
@ kMoveOpaque
Definition TCanvas.h:98
@ kIsGrayscale
Definition TCanvas.h:100
@ kShowEventStatus
Definition TCanvas.h:93
@ kAutoExec
Definition TCanvas.h:94
@ kMenuBar
Definition TCanvas.h:95
@ kShowEditor
Definition TCanvas.h:97
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition TCanvas.cxx:1767
virtual void ToggleToolBar()
Toggle toolbar.
Definition TCanvas.cxx:2456
TVirtualPad * fHilightPadBorder
! pad which border will be hilghlighrt when paint canvas
Definition TCanvas.h:69
virtual TObject * DrawClonePad()
Draw a clone of this canvas into the current pad In an interactive session, select the destination/cu...
Definition TCanvas.cxx:936
@ kRealNew
Definition TClass.h:110
static ENewType IsCallingNew()
Static method returning the defConstructor flag passed to TClass::New().
Definition TClass.cxx:6070
void Browse(TBrowser *b) override
Browse this collection (called by TBrowser).
The color creation and management class.
Definition TColor.h:22
static const TArrayI & GetPalette()
Static function returning the current active palette.
Definition TColor.cxx:1534
static void SaveColorsPalette(std::ostream &out)
Store current palette in the output macro.
Definition TColor.cxx:3662
static TClass * Class()
static TString SavePrimitiveColor(Int_t ci)
Convert color in C++ statement which can be used in SetColor directives Produced statement either inc...
Definition TColor.cxx:2569
static Bool_t DefinedColors(Int_t set_always_on=0)
Static method returning kTRUE if some new colors have been defined after initialisation or since the ...
Definition TColor.cxx:1555
This class provides an interface to context sensitive popup menus.
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr)
Popup context menu at given location in canvas c and pad p for selected object.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition TDatime.cxx:98
static TClass * Class()
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
virtual TCanvasImp * CreateCanvasImp(TCanvas *c, const char *title, UInt_t width, UInt_t height)
Create a batch version of TCanvasImp.
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
Option_t * GetOption() const
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:952
An array of TObjects.
Definition TObjArray.h:31
static TClass * Class()
Mother of all ROOT objects.
Definition TObject.h:42
virtual void Clear(Option_t *="")
Definition TObject.h:127
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:242
R__ALWAYS_INLINE Bool_t IsOnHeap() const
Definition TObject.h:160
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition TObject.cxx:414
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:548
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual void Pop()
Pop on object drawn in a pad to the top of the display list.
Definition TObject.cxx:639
@ kNoContextMenu
if object does not want context menu
Definition TObject.h:78
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:73
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1070
static TClass * Class()
Implement TVirtualPadPainter which abstracts painting operations.
Definition TPadPainter.h:25
The most important graphics class in the ROOT system.
Definition TPad.h:28
Short_t GetBorderMode() const override
Definition TPad.h:199
void SetBorderSize(Short_t bordersize) override
Definition TPad.h:332
Int_t GetTicky() const override
Definition TPad.h:241
void PaintBorder(Color_t color, Bool_t tops)
Paint the pad border.
Definition TPad.cxx:3690
Bool_t IsEditable() const override
Definition TPad.h:274
void ResizePad(Option_t *option="") override
Compute pad conversion coefficients.
Definition TPad.cxx:5650
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
Definition TPad.h:341
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitives in this pad on the C++ source file out.
Definition TPad.cxx:5865
Bool_t GetGridx() const override
Definition TPad.h:237
Double_t fX2
X of upper X coordinate.
Definition TPad.h:38
void SetLogz(Int_t value=1) override
Set Lin/Log scale for Z.
Definition TPad.cxx:6078
Double_t GetY2() const override
Definition TPad.h:245
void Close(Option_t *option="") override
Delete all primitives in pad and pad itself.
Definition TPad.cxx:1084
void PaintModified() override
Traverse pad hierarchy and (re)paint only modified pads.
Definition TPad.cxx:3825
const char * GetTitle() const override
Returns title of object.
Definition TPad.h:263
Double_t fX1
X of lower X coordinate.
Definition TPad.h:36
TList * GetListOfPrimitives() const override
Definition TPad.h:247
void SetPad(const char *name, const char *title, Double_t xlow, Double_t ylow, Double_t xup, Double_t yup, Color_t color=35, Short_t bordersize=5, Short_t bordermode=-1) override
Set all pad parameters.
Definition TPad.cxx:6138
void UseCurrentStyle() override
Force a copy of current style for all objects in pad.
Definition TPad.cxx:6895
void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Set world coordinate system for the pad.
Definition TPad.cxx:5357
Double_t fY1
Y of lower Y coordinate.
Definition TPad.h:37
Int_t fGLDevice
! OpenGL off-screen pixmap identifier
Definition TPad.h:85
void Clear(Option_t *option="") override
Delete all pad primitives.
Definition TPad.cxx:723
Int_t GetTickx() const override
Definition TPad.h:240
Double_t fAspectRatio
ratio of w/h in case of fixed ratio
Definition TPad.h:82
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:6067
TCanvas * fCanvas
! Pointer to mother canvas
Definition TPad.h:106
Bool_t fFixedAspectRatio
True if fixed aspect ratio.
Definition TPad.h:104
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Definition TPad.cxx:7356
void ls(Option_t *option="") const override
List all primitives in pad.
Definition TPad.cxx:3118
void Streamer(TBuffer &) override
Stream a class object.
Definition TPad.cxx:6681
TString fTitle
Pad title.
Definition TPad.h:110
void CopyPixmaps() override
Copy the sub-pixmaps of the pad to the canvas.
Definition TPad.cxx:1156
void CopyPixmap() override
Copy the pixmap of the pad to the canvas.
Definition TPad.cxx:1143
Double_t GetY1() const override
Definition TPad.h:244
Bool_t GetGridy() const override
Definition TPad.h:238
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TPad.cxx:1948
Int_t GetLogz() const override
Definition TPad.h:260
Short_t GetBorderSize() const override
Definition TPad.h:200
TList * fPrimitives
->List of primitives (subpads)
Definition TPad.h:107
Short_t fBorderSize
pad bordersize in pixels
Definition TPad.h:97
void Paint(Option_t *option="") override
Paint all primitives in pad.
Definition TPad.cxx:3615
TString fName
Pad name.
Definition TPad.h:109
Int_t fPixmapID
! Off-screen pixmap identifier
Definition TPad.h:84
TObject * FindObject(const char *name) const override
Search if object named name is inside this pad or in pads inside this pad.
Definition TPad.cxx:2693
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition TPad.cxx:694
Int_t GetLogy() const override
Definition TPad.h:259
void SetBorderMode(Short_t bordermode) override
Definition TPad.h:331
void SetTicks(Int_t valuex=1, Int_t valuey=1) override
Definition TPad.h:361
Double_t fY2
Y of upper Y coordinate.
Definition TPad.h:39
Short_t fBorderMode
Bordermode (-1=down, 0 = no border, 1=up)
Definition TPad.h:98
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition TPad.cxx:6053
Int_t GetLogx() const override
Definition TPad.h:258
Double_t GetX2() const override
Definition TPad.h:243
Double_t GetX1() const override
Definition TPad.h:242
TPad * fMother
! pointer to mother of the list
Definition TPad.h:105
const char * GetName() const override
Returns name of object.
Definition TPad.h:262
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:3059
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3067
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2916
Basic string class.
Definition TString.h:137
void ToLower()
Change string to lower-case.
Definition TString.cxx:1190
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1122
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition TString.cxx:1911
@ kBoth
Definition TString.h:283
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1493
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
Double_t GetTimeOffset() const
Definition TStyle.h:271
Int_t GetOptLogy() const
Definition TStyle.h:250
Int_t GetOptStat() const
Definition TStyle.h:247
Int_t GetOptTitle() const
Definition TStyle.h:248
void SetCanvasBorderSize(Width_t size=1)
Definition TStyle.h:348
Float_t GetScreenFactor() const
Definition TStyle.h:258
Int_t GetPadTickX() const
Definition TStyle.h:219
Bool_t IsReading() const
Definition TStyle.h:300
void SetCanvasColor(Color_t color=19)
Definition TStyle.h:347
Float_t GetPadRightMargin() const
Definition TStyle.h:216
void SetCanvasBorderMode(Int_t mode=1)
Definition TStyle.h:349
Int_t GetCanvasDefH() const
Definition TStyle.h:193
Int_t GetCanvasDefX() const
Definition TStyle.h:195
Bool_t GetPadGridY() const
Definition TStyle.h:218
Float_t GetPadLeftMargin() const
Definition TStyle.h:215
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1889
Bool_t GetCanvasPreferGL() const
Definition TStyle.h:189
Int_t GetCanvasDefY() const
Definition TStyle.h:196
Bool_t GetPadGridX() const
Definition TStyle.h:217
Int_t GetPadTickY() const
Definition TStyle.h:220
Color_t GetCanvasColor() const
Definition TStyle.h:190
Float_t GetPadBottomMargin() const
Definition TStyle.h:213
Int_t GetCanvasDefW() const
Definition TStyle.h:194
Int_t GetOptLogx() const
Definition TStyle.h:249
Int_t GetCanvasBorderMode() const
Definition TStyle.h:192
Width_t GetCanvasBorderSize() const
Definition TStyle.h:191
Int_t GetOptFit() const
Definition TStyle.h:246
Int_t GetOptLogz() const
Definition TStyle.h:251
Float_t GetPadTopMargin() const
Definition TStyle.h:214
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1289
static TClass * Class()
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition TVirtualPS.h:32
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
virtual void UpdateDrawable(Int_t)
virtual void LockPainter()
Empty definition.
virtual void SetDrawMode(Int_t, Int_t)
virtual TClass * IsA() const
static TVirtualPadPainter * PadPainter(Option_t *opt="")
Create a pad painter of specified type.
virtual void SelectDrawable(Int_t device)=0
virtual void InitPainter()
Empty definition.
virtual void SetDoubleBuffer(Int_t device, Int_t mode)
Set double buffer mode for specified device, redirect to gVirtualX.
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:61
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
static TClass * Class()
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:409
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:706
th1 Draw()