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 fHandlingInput = 0;
185 fCanvasImp = nullptr;
186 fContextMenu = nullptr;
187
189
190 if (!build || TClass::IsCallingNew() != TClass::kRealNew) {
191 Constructor();
192 } else {
193 auto cdef = GetNewCanvasName();
194
195 Constructor(cdef.Data(), cdef.Data(), 1);
196 }
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Canvas default constructor
201
203{
204 if (gThreadXAR) {
205 void *arr[2];
206 arr[1] = this;
207 if ((*gThreadXAR)("CANV", 2, arr, nullptr)) return;
208 }
209
210 fCanvas = nullptr;
211 fCanvasID = -1;
212 fCanvasImp = nullptr;
213 fBatch = kTRUE;
215
216 fContextMenu = nullptr;
217 fSelected = nullptr;
218 fClickSelected = nullptr;
219 fSelectedPad = nullptr;
220 fClickSelectedPad = nullptr;
221 fPadSave = nullptr;
222 fHandlingInput = 0;
223
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Create an embedded canvas, i.e. a canvas that is in a TGCanvas widget
231/// which is placed in a TGFrame. This ctor is only called via the
232/// TRootEmbeddedCanvas class.
233///
234/// If "name" starts with "gl" the canvas is ready to receive GL output.
235
236TCanvas::TCanvas(const char *name, Int_t ww, Int_t wh, Int_t winid) : TPad(), fDoubleBuffer(0)
237{
238 fCanvasImp = nullptr;
239 fPainter = nullptr;
240 Init();
241
243 fWindowTopX = 0;
244 fWindowTopY = 0;
245 fWindowWidth = ww;
247 fCw = ww + 4;
248 fCh = wh +28;
249 fBatch = kFALSE;
251
252 //This is a very special ctor. A window exists already!
253 //Can create painter now.
255
256 if (fUseGL) {
257 fGLDevice = gGLManager->CreateGLContext(winid);
258 if (fGLDevice == -1)
259 fUseGL = kFALSE;
260 }
261
263 if (!fCanvasImp) return;
264
266 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
267 Build();
268}
269
270////////////////////////////////////////////////////////////////////////////////
271/// Create a new canvas with a predefined size form.
272/// If form < 0 the menubar is not shown.
273///
274/// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
275/// - form = 2 500x500 at 20,20
276/// - form = 3 500x500 at 30,30
277/// - form = 4 500x500 at 40,40
278/// - form = 5 500x500 at 50,50
279///
280/// If "name" starts with "gl" the canvas is ready to receive GL output.
281
282TCanvas::TCanvas(const char *name, const char *title, Int_t form) : TPad(), fDoubleBuffer(0)
283{
284 fPainter = nullptr;
286
287 Constructor(name, title, form);
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Create a new canvas with a predefined size form.
292/// If form < 0 the menubar is not shown.
293///
294/// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
295/// - form = 2 500x500 at 20,20
296/// - form = 3 500x500 at 30,30
297/// - form = 4 500x500 at 40,40
298/// - form = 5 500x500 at 50,50
299
300void TCanvas::Constructor(const char *name, const char *title, Int_t form)
301{
302 if (gThreadXAR) {
303 void *arr[6];
304 static Int_t ww = 500;
305 static Int_t wh = 500;
306 arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
307 if ((*gThreadXAR)("CANV", 6, arr, nullptr)) return;
308 }
309
310 Init();
311 SetBit(kMenuBar,true);
312 if (form < 0) {
313 form = -form;
314 SetBit(kMenuBar,false);
315 }
316
317 fCanvas = this;
318
319 fCanvasID = -1;
320 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
321 if (old && old->IsOnHeap()) {
322 Warning("Constructor","Deleting canvas with same name: %s",name);
323 delete old;
324 }
325 if (gROOT->IsBatch()) { //We are in Batch mode
327 if (form == 1) {
330 } else {
331 fWindowWidth = 500;
332 fWindowHeight = 500;
333 }
337 if (!fCanvasImp) return;
338 fBatch = kTRUE;
339 } else { //normal mode with a screen window
341 if (form < 1 || form > 20) form = 1;
342 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
343 Int_t ux, uy, cw, ch;
344 if (form == 1) {
345 cw = gStyle->GetCanvasDefW();
346 ch = gStyle->GetCanvasDefH();
349 } else {
350 cw = ch = 500;
351 ux = uy = form * 10;
352 }
353
354 fCanvasImp = factory->CreateCanvasImp(this, name, Int_t(cx*ux), Int_t(cx*uy), UInt_t(cx*cw), UInt_t(cx*ch));
355 if (!fCanvasImp) return;
356
357 if (!gROOT->IsBatch() && fCanvasID == -1)
359
361 fBatch = kFALSE;
362 }
363
365
366 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
367 SetTitle(title); // requires fCanvasImp set
368 Build();
369
370 // Popup canvas
371 fCanvasImp->Show();
372}
373
374////////////////////////////////////////////////////////////////////////////////
375/// Create a new canvas at a random position.
376///
377/// \param[in] name canvas name
378/// \param[in] title canvas title
379/// \param[in] ww is the window size in pixels along X
380/// (if ww < 0 the menubar is not shown)
381/// \param[in] wh is the window size in pixels along Y
382///
383/// If "name" starts with "gl" the canvas is ready to receive GL output.
384
385TCanvas::TCanvas(const char *name, const char *title, Int_t ww, Int_t wh) : TPad(), fDoubleBuffer(0)
386{
387 fPainter = nullptr;
389
390 Constructor(name, title, ww, wh);
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Create a new canvas at a random position.
395///
396/// \param[in] name canvas name
397/// \param[in] title canvas title
398/// \param[in] ww is the window size in pixels along X
399/// (if ww < 0 the menubar is not shown)
400/// \param[in] wh is the window size in pixels along Y
401
402void TCanvas::Constructor(const char *name, const char *title, Int_t ww, Int_t wh)
403{
404 if (gThreadXAR) {
405 void *arr[6];
406 arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
407 if ((*gThreadXAR)("CANV", 6, arr, nullptr)) return;
408 }
409
410 Init();
411 SetBit(kMenuBar,true);
412 if (ww < 0) {
413 ww = -ww;
414 SetBit(kMenuBar,false);
415 }
416 if (wh <= 0) {
417 Error("Constructor", "Invalid canvas height: %d",wh);
418 return;
419 }
420 fCw = ww;
421 fCh = wh;
422 fCanvasID = -1;
423 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
424 if (old && old->IsOnHeap()) {
425 Warning("Constructor","Deleting canvas with same name: %s",name);
426 delete old;
427 }
428 if (gROOT->IsBatch()) { //We are in Batch mode
430 fWindowWidth = ww;
432 fCw = ww;
433 fCh = wh;
435 if (!fCanvasImp) return;
436 fBatch = kTRUE;
437 } else {
439 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
440 fCanvasImp = factory->CreateCanvasImp(this, name, UInt_t(cx*ww), UInt_t(cx*wh));
441 if (!fCanvasImp) return;
442
443 if (!gROOT->IsBatch() && fCanvasID == -1)
445
447 fBatch = kFALSE;
448 }
449
451
452 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
453 SetTitle(title); // requires fCanvasImp set
454 Build();
455
456 // Popup canvas
457 fCanvasImp->Show();
458}
459
460////////////////////////////////////////////////////////////////////////////////
461/// Create a new canvas.
462///
463/// \param[in] name canvas name
464/// \param[in] title canvas title
465/// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
466/// the canvas (if wtopx < 0) the menubar is not shown)
467/// \param[in] ww is the window size in pixels along X
468/// \param[in] wh is the window size in pixels along Y
469///
470/// If "name" starts with "gl" the canvas is ready to receive GL output.
471
472TCanvas::TCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
473 : TPad(), fDoubleBuffer(0)
474{
475 fPainter = nullptr;
477
478 Constructor(name, title, wtopx, wtopy, ww, wh);
479}
480
481////////////////////////////////////////////////////////////////////////////////
482/// Create a new canvas.
483///
484/// \param[in] name canvas name
485/// \param[in] title canvas title
486/// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
487/// the canvas (if wtopx < 0) the menubar is not shown)
488/// \param[in] ww is the window size in pixels along X
489/// \param[in] wh is the window size in pixels along Y
490
491void TCanvas::Constructor(const char *name, const char *title, Int_t wtopx,
492 Int_t wtopy, Int_t ww, Int_t wh)
493{
494 if (gThreadXAR) {
495 void *arr[8];
496 arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title;
497 arr[4] = &wtopx; arr[5] = &wtopy; arr[6] = &ww; arr[7] = &wh;
498 if ((*gThreadXAR)("CANV", 8, arr, nullptr)) return;
499 }
500
501 Init();
502 SetBit(kMenuBar,true);
503 if (wtopx < 0) {
504 wtopx = -wtopx;
505 SetBit(kMenuBar,false);
506 }
507 fCw = ww;
508 fCh = wh;
509 fCanvasID = -1;
510 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
511 if (old && old->IsOnHeap()) {
512 Warning("Constructor","Deleting canvas with same name: %s",name);
513 delete old;
514 }
515 if (gROOT->IsBatch()) { //We are in Batch mode
517 fWindowWidth = ww;
519 fCw = ww;
520 fCh = wh;
522 if (!fCanvasImp) return;
523 fBatch = kTRUE;
524 } else { //normal mode with a screen window
526 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
527 fCanvasImp = factory->CreateCanvasImp(this, name, Int_t(cx*wtopx), Int_t(cx*wtopy), UInt_t(cx*ww), UInt_t(cx*wh));
528 if (!fCanvasImp) return;
529
530 if (!gROOT->IsBatch() && fCanvasID == -1)
532
534 fBatch = kFALSE;
535 }
536
538
539 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
540 SetTitle(title); // requires fCanvasImp set
541 Build();
542
543 // Popup canvas
544 fCanvasImp->Show();
545}
546
547////////////////////////////////////////////////////////////////////////////////
548/// Initialize the TCanvas members. Called by all constructors.
549
551{
552 // Make sure the application environment exists. It is need for graphics
553 // (colors are initialized in the TApplication ctor).
554 if (!gApplication)
556
557 // Load and initialize graphics libraries if
558 // TApplication::NeedGraphicsLibs() has been called by a
559 // library static initializer.
560 if (gApplication)
561 gApplication->InitializeGraphics(gROOT->IsWebDisplay());
562
563 // Get some default from .rootrc. Used in fCanvasImp->InitWindow().
564 fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
565 SetBit(kMoveOpaque, gEnv->GetValue("Canvas.MoveOpaque", 0));
566 SetBit(kResizeOpaque, gEnv->GetValue("Canvas.ResizeOpaque", 0));
567 if (gEnv->GetValue("Canvas.ShowEventStatus", kFALSE)) SetBit(kShowEventStatus);
568 if (gEnv->GetValue("Canvas.ShowToolTips", kFALSE)) SetBit(kShowToolTips);
569 if (gEnv->GetValue("Canvas.ShowToolBar", kFALSE)) SetBit(kShowToolBar);
570 if (gEnv->GetValue("Canvas.ShowEditor", kFALSE)) SetBit(kShowEditor);
571 if (gEnv->GetValue("Canvas.AutoExec", kTRUE)) SetBit(kAutoExec);
572
573 // Fill canvas ROOT data structure
574 fXsizeUser = 0;
575 fYsizeUser = 0;
578
579 fDISPLAY = "$DISPLAY";
582 fSelected = nullptr;
583 fClickSelected = nullptr;
584 fSelectedX = 0;
585 fSelectedY = 0;
586 fSelectedPad = nullptr;
587 fClickSelectedPad= nullptr;
588 fPadSave = nullptr;
589 fHandlingInput = 0;
590 fEvent = -1;
591 fEventX = -1;
592 fEventY = -1;
593 fContextMenu = nullptr;
594 fDrawn = kFALSE;
596}
597
598////////////////////////////////////////////////////////////////////////////////
599/// Build a canvas. Called by all constructors.
600
602{
603 // Get window identifier
604 if (fCanvasID == -1 && fCanvasImp)
606 if (fCanvasID == -1) return;
607
608 if (fCw !=0 && fCh !=0) {
611 }
612
613 // Set Pad parameters
614 gPad = this;
615 fCanvas = this;
616 fMother = (TPad*)gPad;
617
618 if (IsBatch()) {
619 // Make sure that batch interactive canvas sizes are the same
620 fCw -= 4;
621 fCh -= 28;
622 } else if (IsWeb()) {
623 // mark canvas as batch - avoid gVirtualX in many places
625 } else {
626 //normal mode with a screen window
627 if (auto pp = GetCanvasPainter()) {
628 // Set default physical canvas attributes
629 pp->SelectDrawable(fCanvasID);
630 pp->SetAttFill({1, 1001}); //Set color index for fill area
631 pp->SetAttLine({1, 1, 1}); //Set color index for lines
632 pp->SetAttMarker({1, 1, 1}); //Set color index for markers
633 // pp->SetAttText({22, 0., 1, 42, 12}); //Set color index for text
634 // Clear workstation
635 pp->ClearWindow(fCanvasID);
636 }
637
638 // Set Double Buffer on by default
640
641 // Get effective window parameters (with borders and menubar)
644
645 // Get effective canvas parameters without borders
647
648 fContextMenu = new TContextMenu("ContextMenu");
649 }
650
651 gROOT->GetListOfCanvases()->Add(this);
652
653 if (!fPrimitives) {
654 fPrimitives = new TList;
656 SetFillStyle(1001);
668 fBorderMode=gStyle->GetCanvasBorderMode(); // do not call SetBorderMode (function redefined in TCanvas)
669 SetPad(0, 0, 1, 1);
670 Range(0, 0, 1, 1); //pad range is set by default to [0,1] in x and y
671
672 if (auto pp = GetCanvasPainter())
673 pp->SelectDrawable(fPixmapID); //pixmap must be selected
674 PaintBorder(GetFillColor(), kTRUE); //paint background
675 }
676
677 // transient canvases have typically no menubar and should not get
678 // by default the event status bar (if set by default)
679 if (TestBit(kMenuBar) && fCanvasImp) {
681 // ... and toolbar + editor
685 }
686}
687
688////////////////////////////////////////////////////////////////////////////////
689/// Canvas destructor
690
692{
693 Destructor();
694}
695
696////////////////////////////////////////////////////////////////////////////////
697/// Browse.
698
700{
701 Draw();
702 cd();
704}
705
706////////////////////////////////////////////////////////////////////////////////
707/// Actual canvas destructor.
708
710{
711 if (gThreadXAR) {
712 void *arr[2];
713 arr[1] = this;
714 if ((*gThreadXAR)("CDEL", 2, arr, nullptr)) return;
715 }
716
717 if (ROOT::Detail::HasBeenDeleted(this)) return;
718
720 if (!gPad) return;
721
722 Close();
723
724 //If not yet (batch mode?).
726}
727
728////////////////////////////////////////////////////////////////////////////////
729/// Set current canvas & pad. Returns the new current pad,
730/// or 0 in case of failure.
731/// See TPad::cd() for an explanation of the parameter.
732
734{
735 if (fCanvasID == -1) return nullptr;
736
738
739 // in case doublebuffer is off, draw directly onto display window
740 if (!IsBatch() && !IsWeb() && !fDoubleBuffer && fPainter)
741 fPainter->SelectDrawable(fCanvasID);//Ok, does not matter for glpad.
742
743 return gPad;
744}
745
746////////////////////////////////////////////////////////////////////////////////
747/// Remove all primitives from the canvas.
748/// If option "D" is specified, direct sub-pads are cleared but not deleted.
749/// This option is not recursive, i.e. pads in direct sub-pads are deleted.
750
752{
753 if (fCanvasID == -1) return;
754
756
757 TString opt = option;
758 opt.ToLower();
759 if (opt.Contains("d")) {
760 // clear subpads, but do not delete pads in case the canvas
761 // has been divided (note: option "D" is propagated so could cause
762 // conflicts for primitives using option "D" for something else)
763 if (fPrimitives) {
764 TIter next(fPrimitives);
765 TObject *obj;
766 while ((obj=next())) {
767 obj->Clear(option);
768 }
769 }
770 } else {
771 //default, clear everything in the canvas. Subpads are deleted
772 TPad::Clear(option); //Remove primitives from pad
773 }
774
775 fSelected = nullptr;
776 fClickSelected = nullptr;
777 fSelectedPad = nullptr;
778 fClickSelectedPad = nullptr;
779}
780
781////////////////////////////////////////////////////////////////////////////////
782/// Emit pad Cleared signal.
783
785{
786 Emit("Cleared(TVirtualPad*)", (Longptr_t)pad);
787}
788
789////////////////////////////////////////////////////////////////////////////////
790/// Emit Closed signal.
791
793{
794 Emit("Closed()");
795}
796
797////////////////////////////////////////////////////////////////////////////////
798/// Close canvas.
799///
800/// Delete window/pads data structure
801
803{
804 auto padsave = gPad;
805 TCanvas *cansave = padsave ? padsave->GetCanvas() : nullptr;
806
807 if (fCanvasID != -1) {
808
809 if (!gROOT->IsLineProcessing() && !gVirtualX->IsCmdThread()) {
810 gInterpreter->Execute(this, IsA(), "Close", option);
811 return;
812 }
813
815
817
818 cd();
820
822
823 if (fCanvasImp)
824 fCanvasImp->Close();
825
826 fCanvasID = -1;
827 fBatch = kTRUE;
828
829 gROOT->GetListOfCanvases()->Remove(this);
830
831 // Close actual window on screen
833 }
834
835 if (cansave == this) {
836 gPad = (TCanvas *) gROOT->GetListOfCanvases()->First();
837 } else {
838 gPad = padsave;
839 }
840
841 Closed();
842}
843
844////////////////////////////////////////////////////////////////////////////////
845/// Copy the canvas pixmap of the pad to the canvas.
846
848{
849 if (!IsBatch()) {
852 }
853}
854
855////////////////////////////////////////////////////////////////////////////////
856/// Draw a canvas.
857/// If a canvas with the name is already on the screen, the canvas is repainted.
858/// This function is useful when a canvas object has been saved in a Root file.
859/// One can then do:
860/// ~~~ {.cpp}
861/// Root > TFile::Open("file.root");
862/// Root > canvas->Draw();
863/// ~~~
864
866{
867 // Load and initialize graphics libraries if
868 // TApplication::NeedGraphicsLibs() has been called by a
869 // library static initializer.
870 if (gApplication)
871 gApplication->InitializeGraphics(gROOT->IsWebDisplay());
872
873 fDrawn = kTRUE;
874
875 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(GetName());
876 if (old == this) {
877 if (IsWeb()) {
878 Modified();
879 UpdateAsync();
880 } else {
881 Paint();
882 }
883 return;
884 }
885 if (old) { gROOT->GetListOfCanvases()->Remove(old); delete old;}
886
887 if (fWindowWidth == 0) {
888 if (fCw !=0) fWindowWidth = fCw+4;
889 else fWindowWidth = 800;
890 }
891 if (fWindowHeight == 0) {
892 if (fCh !=0) fWindowHeight = fCh+28;
893 else fWindowHeight = 600;
894 }
895 if (gROOT->IsBatch()) { //We are in Batch mode
897 if (!fCanvasImp) return;
898 fBatch = kTRUE;
899
900 } else { //normal mode with a screen window
901 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
902 fCanvasImp = factory->CreateCanvasImp(this, GetName(), fWindowTopX, fWindowTopY,
904 if (!fCanvasImp) return;
906 }
907 Build();
908 ResizePad();
910 fCanvasImp->Show();
911 Modified();
912}
913
914////////////////////////////////////////////////////////////////////////////////
915/// Draw a clone of this canvas
916/// A new canvas is created that is a clone of this canvas
917
919{
921 newCanvas->SetName();
922
923 newCanvas->Draw(option);
924 newCanvas->Update();
925 return newCanvas;
926}
927
928////////////////////////////////////////////////////////////////////////////////
929/// Draw a clone of this canvas into the current pad
930/// In an interactive session, select the destination/current pad
931/// with the middle mouse button, then point to the canvas area to select
932/// the canvas context menu item DrawClonePad.
933/// Note that the original canvas may have subpads.
934
936{
937 auto padsav = gPad;
938 auto selpad = gROOT->GetSelectedPad();
939 auto pad = padsav;
940 if (pad == this) pad = selpad;
941 if (!padsav || !pad || pad == this) {
943 newCanvas->SetWindowSize(GetWindowWidth(),GetWindowHeight());
944 return newCanvas;
945 }
946 if (fCanvasID == -1) {
947 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
948 fCanvasImp = factory->CreateCanvasImp(this, GetName(), fWindowTopX, fWindowTopY,
950 if (!fCanvasImp) return nullptr;
953 }
954 this->cd();
955 //copy pad attributes
956 pad->Range(fX1,fY1,fX2,fY2);
957 pad->SetTickx(GetTickx());
958 pad->SetTicky(GetTicky());
959 pad->SetGridx(GetGridx());
960 pad->SetGridy(GetGridy());
961 pad->SetLogx(GetLogx());
962 pad->SetLogy(GetLogy());
963 pad->SetLogz(GetLogz());
964 pad->SetBorderSize(GetBorderSize());
965 pad->SetBorderMode(GetBorderMode());
969
970 //copy primitives
972 while (auto obj = next()) {
973 pad->cd();
974 pad->Add(obj->Clone(), next.GetOption(), kFALSE); // do not issue modified for each object
975 }
976 pad->ResizePad();
977 pad->Modified();
978 pad->Update();
979 if (padsav) padsav->cd();
980 return nullptr;
981}
982
983////////////////////////////////////////////////////////////////////////////////
984/// Report name and title of primitive below the cursor.
985///
986/// This function is called when the option "Event Status"
987/// in the canvas menu "Options" is selected.
988
990{
991 const Int_t kTMAX=256;
992 static char atext[kTMAX];
993
994 if (!TestBit(kShowEventStatus) || !selected) return;
995
996 if (!fCanvasImp) return; //this may happen when closing a TAttCanvas
997
999
1000 fCanvasImp->SetStatusText(selected->GetTitle(),0);
1001 fCanvasImp->SetStatusText(selected->GetName(),1);
1002 if (event == kKeyPress)
1003 snprintf(atext, kTMAX, "%c", (char) px);
1004 else
1005 snprintf(atext, kTMAX, "%d,%d", px, py);
1007
1008 // Show date/time if TimeDisplay is selected
1009 TAxis *xaxis = nullptr;
1010 if ( selected->InheritsFrom("TH1") )
1011 xaxis = ((TH1*)selected)->GetXaxis();
1012 else if ( selected->InheritsFrom("TGraph") )
1013 xaxis = ((TGraph*)selected)->GetXaxis();
1014 else if ( selected->InheritsFrom("TAxis") )
1015 xaxis = (TAxis*)selected;
1016 if ( xaxis != nullptr && xaxis->GetTimeDisplay()) {
1017 TString objinfo = selected->GetObjectInfo(px,py);
1018 // check if user has overwritten GetObjectInfo and altered
1019 // the default text from TObject::GetObjectInfo "x=.. y=.."
1020 if (objinfo.Contains("x=") && objinfo.Contains("y=") ) {
1021 UInt_t toff = 0;
1022 TString time_format(xaxis->GetTimeFormat());
1023 // TimeFormat may contain offset: %F2000-01-01 00:00:00
1024 Int_t idF = time_format.Index("%F");
1025 if (idF>=0) {
1026 Int_t lnF = time_format.Length();
1027 // minimal check for correct format
1028 if (lnF - idF == 21) {
1031 toff = dtoff.Convert();
1032 }
1033 } else {
1035 }
1036 TDatime dt((UInt_t)gPad->AbsPixeltoX(px) + toff);
1037 snprintf(atext, kTMAX, "%s, y=%g",
1038 dt.AsSQLString(),gPad->AbsPixeltoY(py));
1040 return;
1041 }
1042 }
1043 // default
1044 fCanvasImp->SetStatusText(selected->GetObjectInfo(px,py),3);
1045}
1046
1047////////////////////////////////////////////////////////////////////////////////
1048/// Get editor bar.
1049
1054
1055////////////////////////////////////////////////////////////////////////////////
1056/// Embedded a canvas into a TRootEmbeddedCanvas. This method is only called
1057/// via TRootEmbeddedCanvas::AdoptCanvas.
1058
1060{
1061 // If fCanvasImp already exists, no need to go further.
1062 if(fCanvasImp) return;
1063
1064 fCanvasID = winid;
1065 fWindowTopX = 0;
1066 fWindowTopY = 0;
1067 fWindowWidth = ww;
1068 fWindowHeight = wh;
1069 fCw = ww;
1070 fCh = wh;
1071 fBatch = kFALSE;
1072 fUpdating = kFALSE;
1073
1075 if (!fCanvasImp) return;
1076 Build();
1077 Resize();
1078}
1079
1080////////////////////////////////////////////////////////////////////////////////
1081/// Generate kMouseEnter and kMouseLeave events depending on the previously
1082/// selected object and the currently selected object. Does nothing if the
1083/// selected object does not change.
1084
1086{
1087 if (prevSelObj == fSelected) return;
1088
1091
1092 if (prevSelObj) {
1093 gPad = prevSelPad;
1094 prevSelObj->ExecuteEvent(kMouseLeave, fEventX, fEventY);
1096 RunAutoExec();
1098 }
1099
1101
1102 if (fSelected) {
1105 RunAutoExec();
1107 }
1108
1109 fEvent = sevent;
1110}
1111
1112////////////////////////////////////////////////////////////////////////////////
1113/// Execute action corresponding to one event.
1114///
1115/// This member function must be implemented to realize the action
1116/// corresponding to the mouse click on the object in the canvas
1117///
1118/// Only handle mouse motion events in TCanvas, all other events are
1119/// ignored for the time being
1120
1122{
1123 if (gROOT->GetEditorMode()) {
1125 return;
1126 }
1127
1128 switch (event) {
1129
1130 case kMouseMotion:
1132 break;
1133 }
1134}
1135
1136////////////////////////////////////////////////////////////////////////////////
1137/// Turn rubberband feedback mode on or off.
1138
1140{
1141 if (IsWeb() || (fCanvasID == -1))
1142 return;
1143
1144 SetDoubleBuffer(set ? 0 : 1); // switch double buffer
1145
1146 // now direcly switch draw mode in painter,
1147 // later move such special code to place where painting performed
1148 if (fPainter)
1150}
1151
1152////////////////////////////////////////////////////////////////////////////////
1153/// Flush canvas buffers.
1154
1156{
1157 if ((fCanvasID == -1) || IsWeb() || IsBatch())
1158 return;
1159
1160 if (!UseGL() || fGLDevice == -1) {
1162 CopyPixmaps();
1164 } else {
1165 if (IsEditable())
1167
1168 TContext ctxt(this, kTRUE);
1169
1171 gVirtualPS = nullptr;
1172 gGLManager->MakeCurrent(fGLDevice);
1174 Paint();
1176 gGLManager->Flush(fGLDevice);
1177 gVirtualPS = tvps;
1178 fHilightPadBorder = nullptr;
1179 }
1180}
1181
1182////////////////////////////////////////////////////////////////////////////////
1183/// Force canvas update
1184
1189
1190////////////////////////////////////////////////////////////////////////////////
1191/// Force a copy of current style for all objects in canvas.
1192
1194{
1195 if (!gROOT->IsLineProcessing() && !gVirtualX->IsCmdThread()) {
1196 gInterpreter->Execute(this, IsA(), "UseCurrentStyle", "");
1197 return;
1198 }
1199
1201
1203
1204 if (gStyle->IsReading()) {
1208 } else {
1212 }
1213}
1214
1215////////////////////////////////////////////////////////////////////////////////
1216/// Returns current top x position of window on screen.
1217
1225
1226////////////////////////////////////////////////////////////////////////////////
1227/// Returns current top y position of window on screen.
1228
1236
1237////////////////////////////////////////////////////////////////////////////////
1238/// Handle Input Events.
1239///
1240/// Handle input events, like button up/down in current canvas.
1241
1243{
1244 TPad *pad;
1247
1248 fHandlingInput = 1;
1249 fPadSave = (TPad*)gPad;
1250 cd(); // make sure this canvas is the current canvas
1251
1252 fEvent = event;
1253 fEventX = px;
1254 fEventY = py;
1255
1256 switch (event) {
1257
1258 case kMouseMotion:
1259 // highlight object tracked over
1260 pad = Pick(px, py, prevSelObj);
1261 if (!pad) break;
1262
1264
1265 gPad = pad; // don't use cd() we will use the current
1266 // canvas via the GetCanvas member and not via
1267 // gPad->GetCanvas
1268
1269 if (fSelected) {
1270 fSelected->ExecuteEvent(event, px, py);
1271 RunAutoExec();
1272 }
1273
1274 break;
1275
1276 case kMouseEnter:
1277 // mouse enters canvas
1278 //FeedbackMode(kTRUE);
1279 break;
1280
1281 case kMouseLeave:
1282 // mouse leaves canvas
1283 {
1284 // force popdown of tooltips
1287 fSelected = nullptr;
1288 fSelectedPad = nullptr;
1290 fSelected = sobj;
1292 //FeedbackMode(kFALSE);
1293 }
1294 break;
1295
1296 case kButton1Double:
1297 // triggered on the second button down within 350ms and within
1298 // 3x3 pixels of the first button down, button up finishes action
1299
1300 case kButton1Down:
1301 // find pad in which input occurred
1302 pad = Pick(px, py, prevSelObj);
1303 if (!pad) break;
1304
1305 gPad = pad; // don't use cd() because we won't draw in pad
1306 // we will only use its coordinate system
1307
1308 if (fSelected) {
1309 FeedbackMode(kTRUE); // to draw in rubberband mode
1310 fSelected->ExecuteEvent(event, px, py);
1311
1312 RunAutoExec();
1313 }
1314
1315 break;
1316
1317 case kArrowKeyPress:
1318 case kArrowKeyRelease:
1319 case kButton1Motion:
1320 case kButton1ShiftMotion: //8 == kButton1Motion + shift modifier
1321 if (fSelected) {
1323
1324 fSelected->ExecuteEvent(event, px, py);
1327 Bool_t resize = kFALSE;
1329 resize = ((TBox*)fSelected)->IsBeingResized();
1331 resize = ((TVirtualPad*)fSelected)->IsBeingResized();
1332
1333 if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) {
1334 gPad = fPadSave;
1335 Update();
1337 }
1338 }
1339
1340 RunAutoExec();
1341 }
1342
1343 break;
1344
1345 case kButton1Up:
1346
1347 if (fSelected) {
1349
1350 fSelected->ExecuteEvent(event, px, py);
1351
1352 RunAutoExec();
1353
1354 if (fPadSave)
1355 gPad = fPadSave;
1356 else {
1357 gPad = this;
1358 fPadSave = this;
1359 }
1360
1361 Update(); // before calling update make sure gPad is reset
1362 }
1363 break;
1364
1365//*-*----------------------------------------------------------------------
1366
1367 case kButton2Down:
1368 // find pad in which input occurred
1369 pad = Pick(px, py, prevSelObj);
1370 if (!pad)
1371 break;
1372
1373 gPad = pad; // don't use cd() because we won't draw in pad
1374 // we will only use its coordinate system
1375
1376 fPadSave = nullptr; // don't want fPadSave->cd() to be executed at the end
1378
1379 if (fSelected)
1380 fSelected->Pop(); // pop object to foreground
1381 pad->cd(); // and make its pad the current pad
1382
1383 // loop over all canvases to make sure that only one pad is highlighted
1384 {
1385 TIter next(gROOT->GetListOfCanvases());
1386 while (auto tc = dynamic_cast<TCanvas *>(next()))
1387 tc->Update();
1388 }
1389
1390 //if (pad->GetGLDevice() != -1 && fSelected)
1391 // fSelected->ExecuteEvent(event, px, py);
1392
1393 break;
1394
1395 case kButton2Motion:
1396 //was empty!
1397 case kButton2Up:
1398 if (fSelected) {
1400
1401 fSelected->ExecuteEvent(event, px, py);
1402 RunAutoExec();
1403 }
1404 break;
1405
1406 case kButton2Double:
1407 break;
1408
1409//*-*----------------------------------------------------------------------
1410
1411 case kButton3Down:
1412 // popup context menu
1413 pad = Pick(px, py, prevSelObj);
1414 if (!pad)
1415 break;
1416
1417 if (!fDoubleBuffer)
1419
1422 fContextMenu->Popup(px, py, fSelected, this, pad);
1423
1424 break;
1425
1426 case kButton3Motion:
1427 break;
1428
1429 case kButton3Up:
1431 break;
1432
1433 case kButton3Double:
1434 break;
1435
1436 case kKeyPress:
1437 if (!fSelectedPad || !fSelected)
1438 break;
1439 gPad = fSelectedPad; // don't use cd() because we won't draw in pad
1440 // we will only use its coordinate system
1441 fSelected->ExecuteEvent(event, px, py);
1442
1443 RunAutoExec();
1444
1445 break;
1446
1447 case kButton1Shift:
1448 // Try to select
1449 pad = Pick(px, py, prevSelObj);
1450
1451 if (!pad)
1452 break;
1453
1455
1456 gPad = pad; // don't use cd() we will use the current
1457 // canvas via the GetCanvas member and not via
1458 // gPad->GetCanvas
1459 if (fSelected) {
1460 fSelected->ExecuteEvent(event, px, py);
1461 RunAutoExec();
1462 }
1463 break;
1464
1465 case kWheelUp:
1466 case kWheelDown:
1467 pad = Pick(px, py, prevSelObj);
1468 if (!pad)
1469 break;
1470
1471 gPad = pad;
1472 if (fSelected)
1473 fSelected->ExecuteEvent(event, px, py);
1474 break;
1475
1476 default:
1477 break;
1478 }
1479
1480 if (fPadSave)
1481 fPadSave->cd();
1482
1483 if (event != kMouseLeave) { // signal was already emitted for this event
1484 ProcessedEvent(event, px, py, fSelected); // emit signal
1486 }
1487
1488 // When during input handling async update was requested
1489 // only counter was increased. It may happen several times
1490 // Now reset counter and really call update of the canvas
1491 bool do_update = fHandlingInput > 1;
1492 fHandlingInput = 0;
1493 if (do_update)
1494 UpdateAsync();
1495}
1496
1497////////////////////////////////////////////////////////////////////////////////
1498/// Iconify canvas
1499
1501{
1502 if (fCanvasImp)
1504}
1505
1506////////////////////////////////////////////////////////////////////////////////
1507/// Is folder ?
1508
1510{
1511 return fgIsFolder;
1512}
1513
1514////////////////////////////////////////////////////////////////////////////////
1515/// Is web canvas
1516
1518{
1519 return fCanvasImp ? fCanvasImp->IsWeb() : kFALSE;
1520}
1521
1522////////////////////////////////////////////////////////////////////////////////
1523/// List all pads.
1524
1526{
1528 std::cout <<"Canvas Name=" <<GetName()<<" Title="<<GetTitle()<<" Option="<<option<<std::endl;
1532}
1533
1534////////////////////////////////////////////////////////////////////////////////
1535/// Static function to build a default canvas.
1536
1538{
1539 auto cdef = GetNewCanvasName();
1540
1541 auto c = new TCanvas(cdef.Data(), cdef.Data(), 1);
1542
1543 ::Info("TCanvas::MakeDefCanvas"," created default TCanvas with name %s", cdef.Data());
1544 return c;
1545}
1546
1547////////////////////////////////////////////////////////////////////////////////
1548/// Set option to move objects/pads in a canvas.
1549///
1550/// - set = 1 (default) graphics objects are moved in opaque mode
1551/// - set = 0 only the outline of objects is drawn when moving them
1552///
1553/// The option opaque produces the best effect. It requires however a
1554/// a reasonably fast workstation or response time.
1555
1557{
1558 SetBit(kMoveOpaque,set);
1559}
1560
1561////////////////////////////////////////////////////////////////////////////////
1562/// Paint canvas.
1563
1565{
1566 if (fCanvas)
1568}
1569
1570////////////////////////////////////////////////////////////////////////////////
1571/// Prepare for pick, call TPad::Pick() and when selected object
1572/// is different from previous then emit Picked() signal.
1573
1575{
1576 TObjLink *pickobj = nullptr;
1577
1578 fSelected = nullptr;
1579 fSelectedOpt = "";
1580 fSelectedPad = nullptr;
1581
1582 TPad *pad = Pick(px, py, pickobj);
1583 if (!pad) return nullptr;
1584
1585 if (!pickobj) {
1586 fSelected = pad;
1587 fSelectedOpt = "";
1588 } else {
1589 if (!fSelected) { // can be set via TCanvas::SetSelected()
1590 fSelected = pickobj->GetObject();
1591 fSelectedOpt = pickobj->GetOption();
1592 }
1593 }
1594 fSelectedPad = pad;
1595
1596 if (fSelected != prevSelObj)
1597 Picked(fSelectedPad, fSelected, fEvent); // emit signal
1598
1599 if ((fEvent == kButton1Down) || (fEvent == kButton2Down) || (fEvent == kButton3Down)) {
1603 Selected(fSelectedPad, fSelected, fEvent); // emit signal
1604 fSelectedX = px;
1605 fSelectedY = py;
1606 }
1607 }
1608 return pad;
1609}
1610
1611////////////////////////////////////////////////////////////////////////////////
1612/// Emit Picked() signal.
1613
1615{
1616 Longptr_t args[3];
1617
1618 args[0] = (Longptr_t) pad;
1619 args[1] = (Longptr_t) obj;
1620 args[2] = event;
1621
1622 Emit("Picked(TPad*,TObject*,Int_t)", args);
1623}
1624
1625////////////////////////////////////////////////////////////////////////////////
1626/// Emit Highlighted() signal.
1627///
1628/// - pad is pointer to pad with highlighted histogram or graph
1629/// - obj is pointer to highlighted histogram or graph
1630/// - x is highlighted x bin for 1D histogram or highlighted x-th point for graph
1631/// - y is highlighted y bin for 2D histogram (for 1D histogram or graph not in use)
1632
1634{
1635 Longptr_t args[4];
1636
1637 args[0] = (Longptr_t) pad;
1638 args[1] = (Longptr_t) obj;
1639 args[2] = x;
1640 args[3] = y;
1641
1642 Emit("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", args);
1643}
1644
1645////////////////////////////////////////////////////////////////////////////////
1646/// This is "simplification" for function TCanvas::Connect with Highlighted
1647/// signal for specific slot.
1648///
1649/// Slot has to be defined "UserFunction(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)"
1650/// all parameters of UserFunction are taken from TCanvas::Highlighted
1651
1653{
1654 Connect("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", nullptr, nullptr, slot);
1655}
1656
1657////////////////////////////////////////////////////////////////////////////////
1658/// Emit Selected() signal.
1659
1661{
1662 Longptr_t args[3];
1663
1664 args[0] = (Longptr_t) pad;
1665 args[1] = (Longptr_t) obj;
1666 args[2] = event;
1667
1668 Emit("Selected(TVirtualPad*,TObject*,Int_t)", args);
1669}
1670
1671////////////////////////////////////////////////////////////////////////////////
1672/// Emit ProcessedEvent() signal.
1673
1675{
1676 Longptr_t args[4];
1677
1678 args[0] = event;
1679 args[1] = x;
1680 args[2] = y;
1681 args[3] = (Longptr_t) obj;
1682
1683 Emit("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", args);
1684}
1685
1686////////////////////////////////////////////////////////////////////////////////
1687/// Recompute canvas parameters following a X11 Resize.
1688
1690{
1691 if (fCanvasID == -1)
1692 return;
1693
1694 if (!gROOT->IsLineProcessing() && !gVirtualX->IsCmdThread()) {
1695 gInterpreter->Execute(this, IsA(), "Resize", "");
1696 return;
1697 }
1698
1700
1701 TContext ctxt(this, kTRUE);
1702
1703 if (!IsBatch() && !IsWeb()) {
1704 // SL: do we need it here?
1705 fPainter->SelectDrawable(fCanvasID); //select current canvas for painting???
1706
1707 fCanvasImp->ResizeCanvasWindow(fCanvasID); //resize canvas and off-screen buffer
1708
1709 // Get effective window parameters including menubar and borders
1712
1713 // Get effective canvas parameters without borders
1715 }
1716
1717 if (fXsizeUser && fYsizeUser) {
1718 UInt_t nwh = fCh;
1719 UInt_t nww = fCw;
1721 if (rxy < 1) {
1723 if (twh > fCh)
1725 else
1726 nwh = twh;
1727 if (nww > fCw) {
1728 nww = fCw; nwh = twh;
1729 }
1730 if (nwh > fCh) {
1731 nwh = fCh; nww = UInt_t(Double_t(fCh)/rxy);
1732 }
1733 } else {
1735 if (twh > fCh)
1737 else
1738 nww = twh;
1739 if (nww > fCw) {
1740 nww = fCw; nwh = twh;
1741 }
1742 if (nwh > fCh) {
1743 nwh = fCh; nww = UInt_t(Double_t(fCh)*rxy);
1744 }
1745 }
1746 fCw = nww;
1747 fCh = nwh;
1748 }
1749
1750 if (fCw < fCh) {
1753 }
1754 else {
1757 }
1758
1759 //*-*- Loop on all pads to recompute conversion coefficients
1761}
1762
1763
1764////////////////////////////////////////////////////////////////////////////////
1765/// Raise canvas window
1766
1768{
1769 if (fCanvasImp)
1771}
1772
1773////////////////////////////////////////////////////////////////////////////////
1774/// Set option to resize objects/pads in a canvas.
1775///
1776/// - set = 1 (default) graphics objects are resized in opaque mode
1777/// - set = 0 only the outline of objects is drawn when resizing them
1778///
1779/// The option opaque produces the best effect. It requires however a
1780/// a reasonably fast workstation or response time.
1781
1783{
1784 SetBit(kResizeOpaque,set);
1785}
1786
1787////////////////////////////////////////////////////////////////////////////////
1788/// Execute the list of TExecs in the current pad.
1789
1791{
1792 if (!TestBit(kAutoExec))
1793 return;
1794 if (gPad)
1795 ((TPad*)gPad)->AutoExec();
1796}
1797
1798////////////////////////////////////////////////////////////////////////////////
1799/// Save primitives in this canvas in C++ macro file with GUI.
1800
1801void TCanvas::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1802{
1803 // Write canvas options (in $TROOT or $TStyle)
1804 out << " gStyle->SetOptFit(" << gStyle->GetOptFit() << ");\n";
1805 out << " gStyle->SetOptStat(" << gStyle->GetOptStat() << ");\n";
1806 out << " gStyle->SetOptTitle(" << gStyle->GetOptTitle() << ");\n";
1807
1808 if (gROOT->GetEditHistograms())
1809 out << " gROOT->SetEditHistograms();\n";
1810
1811 if (GetShowEventStatus())
1812 out << " " << GetName() << "->ToggleEventStatus();\n";
1813
1814 if (GetShowToolTips())
1815 out << " " << GetName() << "->ToggleToolTips();\n";
1816
1817 if (GetShowToolBar())
1818 out << " " << GetName() << "->ToggleToolBar();\n";
1819 if (GetHighLightColor() != 5)
1820 out << " " << GetName() << "->SetHighLightColor(" << TColor::SavePrimitiveColor(GetHighLightColor()) << ");\n";
1821
1822 // Now recursively scan all pads of this canvas
1823 cd();
1825}
1826
1827////////////////////////////////////////////////////////////////////////////////
1828/// Save primitives in this canvas as a C++ macro file.
1829/// This function loops on all the canvas primitives and for each primitive
1830/// calls the object SavePrimitive function.
1831/// When outputting floating point numbers, the default precision is 7 digits.
1832/// The precision can be changed (via system.rootrc) by changing the value
1833/// of the environment variable "Canvas.SavePrecision"
1834
1835void TCanvas::SaveSource(const char *filename, Option_t * /*option*/)
1836{
1837 // Reset the ClassSaved status of all classes
1838 gROOT->ResetClassSaved();
1839
1842
1844 if (cname.IsNull()) {
1845 invalid = kTRUE;
1846 cname = "c1";
1847 }
1848
1849 // if filename is given, open this file, otherwise create a file
1850 // with a name equal to the canvasname.C
1851 TString fname;
1852 if (filename && *filename) {
1853 fname = filename;
1854 } else {
1855 fname = cname + ".C";
1856 }
1857
1858 std::ofstream out;
1859 out.open(fname.Data(), std::ios::out);
1860 if (!out.good()) {
1861 Error("SaveSource", "Cannot open file: %s", fname.Data());
1862 return;
1863 }
1864
1865 //set precision
1866 Int_t precision = gEnv->GetValue("Canvas.SavePrecision",7);
1867 out.precision(precision);
1868
1869 // Write macro header and date/time stamp
1870 TDatime t;
1872 Int_t topx,topy;
1873 UInt_t w, h;
1874 if (!fCanvasImp) {
1875 Error("SaveSource", "Cannot open TCanvas");
1876 return;
1877 }
1880 h = UInt_t((fWindowHeight)/cx);
1881 topx = GetWindowTopX();
1882 topy = GetWindowTopY();
1883
1884 if (w == 0) {
1885 w = GetWw()+4; h = GetWh()+4;
1886 topx = 1; topy = 1;
1887 }
1888
1890 out << R"CODE(#ifdef __CLING__
1891#pragma cling optimize(0)
1892#endif
1893)CODE";
1894 Int_t p = mname.Last('.');
1895 Int_t s = mname.Last('/')+1;
1896
1897 // A named macro is generated only if the function name is valid. If not, the
1898 // macro is unnamed.
1899 TString first(mname(s,s+1));
1900 if (!first.IsDigit()) out <<"void " << mname(s,p-s) << "()" << std::endl;
1901
1902 out <<"{"<<std::endl;
1903 out <<"//=========Macro generated from canvas: "<<GetName()<<"/"<<GetTitle()<<std::endl;
1904 out <<"//========= ("<<t.AsString()<<") by ROOT version "<<gROOT->GetVersion()<<std::endl;
1905
1907 out <<std::endl<<" gStyle->SetCanvasPreferGL(kTRUE);"<<std::endl<<std::endl;
1908
1909 // Write canvas parameters (TDialogCanvas case)
1911 out << " " << ClassName() << " *" << cname << " = new " << ClassName() << "(\"" << GetName() << "\", \""
1912 << TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << w << ", " << h << ");\n";
1913 } else {
1914 // Write canvas parameters (TCanvas case)
1915 out << " TCanvas *" << cname << " = new TCanvas(\"" << GetName() << "\", \""
1916 << TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << (HasMenuBar() ? topx : -topx) << ", " << topy
1917 << ", " << w << ", " << h << ");\n";
1918 }
1919 // Write canvas options (in $TROOT or $TStyle)
1920 out << " gStyle->SetOptFit(" << gStyle->GetOptFit() << ");\n";
1921 out << " gStyle->SetOptStat(" << gStyle->GetOptStat() << ");\n";
1922 out << " gStyle->SetOptTitle(" << gStyle->GetOptTitle() << ");\n";
1923 if (gROOT->GetEditHistograms())
1924 out << " gROOT->SetEditHistograms();\n";
1925 if (GetShowEventStatus())
1926 out << " " << GetName() << "->ToggleEventStatus();\n";
1927 if (GetShowToolTips())
1928 out << " " << GetName() << "->ToggleToolTips();\n";
1929 if (GetHighLightColor() != 5)
1930 out << " " << GetName() << "->SetHighLightColor(" << TColor::SavePrimitiveColor(GetHighLightColor()) << ");\n";
1931
1933
1934 // Now recursively scan all pads of this canvas
1935 cd();
1936 if (invalid) fName = cname;
1937 TPad::SavePrimitive(out,"toplevel");
1938
1939 // Write canvas options related to pad editor
1940 out << " " << GetName() << "->SetSelected(" << GetName() << ");\n";
1941 if (GetShowToolBar())
1942 out << " " << GetName() << "->ToggleToolBar();\n";
1943 if (invalid)
1944 fName = cname0;
1945
1946 out <<"}\n";
1947 out.close();
1948 Info("SaveSource","C++ Macro file: %s has been generated", fname.Data());
1949
1950 // Reset the ClassSaved status of all classes
1951 gROOT->ResetClassSaved();
1952}
1953
1954////////////////////////////////////////////////////////////////////////////////
1955/// Toggle batch mode. However, if the canvas is created without a window
1956/// then batch mode always stays set.
1957
1959{
1960 if (gROOT->IsBatch() || IsWeb())
1961 fBatch = kTRUE;
1962 else
1963 fBatch = batch;
1964}
1965
1966////////////////////////////////////////////////////////////////////////////////
1967/// Set Width and Height of canvas to ww and wh respectively. If ww and/or wh
1968/// are greater than the current canvas window a scroll bar is automatically
1969/// generated. Use this function to zoom in a canvas and navigate via
1970/// the scroll bars. The Width and Height in this method are different from those
1971/// given in the TCanvas constructors where these two dimensions include the size
1972/// of the ROOT canvas menubar decoration whereas they do not in this method.
1973/// When both ww==0 and wh==0, auto resize mode will be enabled again and
1974/// canvas drawing area will automatically fit available window size
1975
1977{
1978 if (fCanvasImp) {
1979 fCw = ww;
1980 fCh = wh;
1982 TContext ctxt(this, kTRUE);
1983 ResizePad();
1984 }
1985}
1986
1987////////////////////////////////////////////////////////////////////////////////
1988/// Set cursor.
1989
1991{
1992 if (fCanvasImp)
1994}
1995
1996////////////////////////////////////////////////////////////////////////////////
1997/// Set Double Buffer On/Off.
1998
2000{
2001 if (IsBatch() || IsWeb())
2002 return;
2004 if (fCanvasID != -1)
2006
2007 // depending of the buffer mode set the drawing window to either
2008 // the canvas pixmap or to the canvas on-screen window
2009 if (fDoubleBuffer) {
2011 } else
2013}
2014
2015////////////////////////////////////////////////////////////////////////////////
2016/// Fix canvas aspect ratio to current value if fixed is true.
2017
2019{
2020 if (fixed) {
2021 if (!fFixedAspectRatio) {
2022 if (fCh != 0)
2024 else {
2025 Error("SetAspectRatio", "cannot fix aspect ratio, height of canvas is 0");
2026 return;
2027 }
2029 }
2030 } else {
2032 fAspectRatio = 0;
2033 }
2034}
2035
2036////////////////////////////////////////////////////////////////////////////////
2037/// If isfolder=kTRUE, the canvas can be browsed like a folder
2038/// by default a canvas is not browsable.
2039
2041{
2043}
2044
2045////////////////////////////////////////////////////////////////////////////////
2046/// Set canvas name. In case `name` is an empty string, a default name is set.
2047/// Canvas automatically marked as modified when SetName method called
2048
2049void TCanvas::SetName(const char *name)
2050{
2052
2053 Modified();
2054}
2055
2056
2057////////////////////////////////////////////////////////////////////////////////
2058/// Function to resize a canvas so that the plot inside is shown in real aspect
2059/// ratio
2060///
2061/// \param[in] axis 1 for resizing horizontally (x-axis) in order to get real
2062/// aspect ratio, 2 for the resizing vertically (y-axis)
2063/// \return false if error is encountered, true otherwise
2064///
2065/// ~~~ {.cpp}
2066/// hpxpy->Draw();
2067/// c1->SetRealAspectRatio();
2068/// ~~~
2069///
2070/// - For defining the concept of real aspect ratio, it is assumed that x and y
2071/// axes are in same units, e.g. both in MeV or both in ns.
2072/// - You can resize either the width of the canvas or the height, but not both
2073/// at the same time
2074/// - Call this function AFTER drawing AND zooming (SetUserRange) your TGraph or
2075/// Histogram, otherwise it cannot infer your actual axes lengths
2076/// - This function ensures that the TFrame has a real aspect ratio, this does not
2077/// mean that the full pad (i.e. the canvas or png output) including margins has
2078/// exactly the same ratio
2079/// - This function does not work if the canvas is divided in several subpads
2080
2081bool TCanvas::SetRealAspectRatio(const Int_t axis)
2082{
2083 Update();
2084
2085 //Get how many pixels are occupied by the canvas
2086 Int_t npx = GetWw();
2087 Int_t npy = GetWh();
2088
2089 //Get x-y coordinates at the edges of the canvas (extrapolating outside the axes, NOT at the edges of the histogram)
2090 Double_t x1 = GetX1();
2091 Double_t y1 = GetY1();
2092 Double_t x2 = GetX2();
2093 Double_t y2 = GetY2();
2094
2095 //Get the length of extrapolated x and y axes
2096 Double_t xlength2 = x2 - x1;
2097 Double_t ylength2 = y2 - y1;
2099
2100 //Now get the number of pixels including the canvas borders
2103
2104 if (axis==1) {
2107 } else if (axis==2) {
2110 } else {
2111 Error("SetRealAspectRatio", "axis value %d is neither 1 (resize along x-axis) nor 2 (resize along y-axis).",axis);
2112 return false;
2113 }
2114
2115 //Check now that resizing has worked
2116
2117 Update();
2118
2119 //Get how many pixels are occupied by the canvas
2120 npx = GetWw();
2121 npy = GetWh();
2122
2123 //Get x-y coordinates at the edges of the canvas (extrapolating outside the axes,
2124 //NOT at the edges of the histogram)
2125 x1 = GetX1();
2126 y1 = GetY1();
2127 x2 = GetX2();
2128 y2 = GetY2();
2129
2130 //Get the length of extrapolated x and y axes
2131 xlength2 = x2 - x1;
2132 ylength2 = y2 - y1;
2134
2135 //Check accuracy +/-1 pixel due to rounding
2136 if (abs(TMath::Nint(npy*ratio2) - npx)<2) {
2137 return true;
2138 } else {
2139 Error("SetRealAspectRatio", "Resizing failed.");
2140 return false;
2141 }
2142}
2143
2144
2145////////////////////////////////////////////////////////////////////////////////
2146/// Set selected canvas.
2147
2149{
2150 fSelected = obj;
2151 if (obj) obj->SetBit(kMustCleanup);
2152}
2153
2154////////////////////////////////////////////////////////////////////////////////
2155/// Set canvas title.
2156
2157void TCanvas::SetTitle(const char *title)
2158{
2159 fTitle = title;
2161}
2162
2163////////////////////////////////////////////////////////////////////////////////
2164/// Set canvas window position
2165
2167{
2168 if (fCanvasImp)
2170}
2171
2172////////////////////////////////////////////////////////////////////////////////
2173/// Set canvas window size
2174
2176{
2177 if (fBatch && !IsWeb())
2178 SetCanvasSize((ww + fCw) / 2, (wh + fCh) / 2);
2179 else if (fCanvasImp)
2181}
2182
2183////////////////////////////////////////////////////////////////////////////////
2184/// Set canvas implementation
2185/// If web-based implementation provided, some internal fields also initialized
2186
2188{
2189 Bool_t was_web = IsWeb();
2190
2191 fCanvasImp = imp;
2192
2193 if (!was_web && IsWeb()) {
2195 fPixmapID = 0;
2196 fMother = this;
2197 if (!fCw) fCw = 800;
2198 if (!fCh) fCh = 600;
2199 } else if (was_web && !imp) {
2200 fCanvasID = -1;
2201 fPixmapID = -1;
2202 fMother = nullptr;
2203 fCw = fCh = 0;
2204 }
2205}
2206
2207////////////////////////////////////////////////////////////////////////////////
2208/// Set the canvas scale in centimeters.
2209///
2210/// This information is used by PostScript to set the page size.
2211///
2212/// \param[in] xsize size of the canvas in centimeters along X
2213/// \param[in] ysize size of the canvas in centimeters along Y
2214///
2215/// if xsize and ysize are not equal to 0, then the scale factors will
2216/// be computed to keep the ratio ysize/xsize independently of the canvas
2217/// size (parts of the physical canvas will be unused).
2218///
2219/// if xsize = 0 and ysize is not zero, then xsize will be computed
2220/// to fit to the current canvas scale. If the canvas is resized,
2221/// a new value for xsize will be recomputed. In this case the aspect
2222/// ratio is not preserved.
2223///
2224/// if both xsize = 0 and ysize = 0, then the scaling is automatic.
2225/// the largest dimension will be allocated a size of 20 centimeters.
2226
2228{
2229 fXsizeUser = xsize;
2230 fYsizeUser = ysize;
2231
2232 Resize();
2233}
2234
2235////////////////////////////////////////////////////////////////////////////////
2236/// Show canvas
2237
2238void TCanvas::Show()
2239{
2240 if (fCanvasImp)
2241 fCanvasImp->Show();
2242}
2243
2244////////////////////////////////////////////////////////////////////////////////
2245/// Stream a class object.
2246
2248{
2249 UInt_t R__s, R__c;
2250 if (b.IsReading()) {
2251 Version_t v = b.ReadVersion(&R__s, &R__c);
2252 gPad = this;
2253 fCanvas = this;
2254 if (v>7) b.ClassBegin(TCanvas::IsA());
2255 if (v>7) b.ClassMember("TPad");
2257 gPad = this;
2258 //restore the colors
2259 auto colors = dynamic_cast<TObjArray *>(fPrimitives->FindObject("ListOfColors"));
2260 if (colors) {
2261 auto root_colors = dynamic_cast<TObjArray *>(gROOT->GetListOfColors());
2262
2263 TIter next(colors);
2264 while (auto colold = static_cast<TColor *>(next())) {
2265 Int_t cn = colold->GetNumber();
2266 TColor *colcur = gROOT->GetColor(cn);
2267 if (colcur && (colcur->IsA() == TColor::Class()) && (colold->IsA() == TColor::Class())) {
2268 colcur->SetName(colold->GetName());
2269 colcur->SetRGB(colold->GetRed(), colold->GetGreen(), colold->GetBlue());
2270 colcur->SetAlpha(colold->GetAlpha());
2271 } else {
2272 if (colcur) {
2273 if (root_colors) root_colors->Remove(colcur);
2274 delete colcur;
2275 }
2276 colors->Remove(colold);
2277 if (root_colors) {
2278 if (colcur) {
2279 root_colors->AddAtAndExpand(colold, cn);
2280 }
2281 else {
2282 // Copy to current session
2283 // do not use copy constructor which does not update highest color index
2284 [[maybe_unused]] TColor* const colnew = new TColor(cn, colold->GetRed(), colold->GetGreen(), colold->GetBlue(), colold->GetName(), colold->GetAlpha());
2285 delete colold;
2286 // No need to delete colnew, as the constructor adds it to global list of colors
2287 assert(root_colors->At(cn) == colnew);
2288 }
2289 }
2290 }
2291 }
2292 //restore the palette if needed
2293 auto palette = dynamic_cast<TObjArray *>(fPrimitives->FindObject("CurrentColorPalette"));
2294 if (palette) {
2296 Int_t number = palette->GetEntries();
2297 TArrayI palcolors(number);
2298 Int_t i = 0;
2299 while (auto col = static_cast<TColor *>(nextcol()))
2300 palcolors[i++] = col->GetNumber();
2301 gStyle->SetPalette(number, palcolors.GetArray());
2303 delete palette;
2304 }
2306 colors->Delete();
2307 delete colors;
2308 }
2309
2310 if (v>7) b.ClassMember("fDISPLAY","TString");
2312 if (v>7) b.ClassMember("fDoubleBuffer", "Int_t");
2313 b >> fDoubleBuffer;
2314 if (v>7) b.ClassMember("fRetained", "Bool_t");
2315 b >> fRetained;
2316 if (v>7) b.ClassMember("fXsizeUser", "Size_t");
2317 b >> fXsizeUser;
2318 if (v>7) b.ClassMember("fYsizeUser", "Size_t");
2319 b >> fYsizeUser;
2320 if (v>7) b.ClassMember("fXsizeReal", "Size_t");
2321 b >> fXsizeReal;
2322 if (v>7) b.ClassMember("fYsizeReal", "Size_t");
2323 b >> fYsizeReal;
2324 fCanvasID = -1;
2325 if (v>7) b.ClassMember("fWindowTopX", "Int_t");
2326 b >> fWindowTopX;
2327 if (v>7) b.ClassMember("fWindowTopY", "Int_t");
2328 b >> fWindowTopY;
2329 if (v > 2) {
2330 if (v>7) b.ClassMember("fWindowWidth", "UInt_t");
2331 b >> fWindowWidth;
2332 if (v>7) b.ClassMember("fWindowHeight", "UInt_t");
2333 b >> fWindowHeight;
2334 }
2335 if (v>7) b.ClassMember("fCw", "UInt_t");
2336 b >> fCw;
2337 if (v>7) b.ClassMember("fCh", "UInt_t");
2338 b >> fCh;
2339 if (v <= 2) {
2340 fWindowWidth = fCw;
2342 }
2343 if (v>7) b.ClassMember("fCatt", "TAttCanvas");
2344 fCatt.Streamer(b);
2345 Bool_t dummy;
2346 if (v>7) b.ClassMember("kMoveOpaque", "Bool_t");
2347 b >> dummy; if (dummy) MoveOpaque(1);
2348 if (v>7) b.ClassMember("kResizeOpaque", "Bool_t");
2349 b >> dummy; if (dummy) ResizeOpaque(1);
2350 if (v>7) b.ClassMember("fHighLightColor", "Color_t");
2351 b >> fHighLightColor;
2352 if (v>7) b.ClassMember("fBatch", "Bool_t");
2353 b >> dummy; //was fBatch
2354 if (v < 2) return;
2355 if (v>7) b.ClassMember("kShowEventStatus", "Bool_t");
2356 b >> dummy; if (dummy) SetBit(kShowEventStatus);
2357
2358 if (v > 3) {
2359 if (v>7) b.ClassMember("kAutoExec", "Bool_t");
2360 b >> dummy; if (dummy) SetBit(kAutoExec);
2361 }
2362 if (v>7) b.ClassMember("kMenuBar", "Bool_t");
2363 b >> dummy; if (dummy) SetBit(kMenuBar);
2364 fBatch = gROOT->IsBatch();
2365 if (v>7) b.ClassEnd(TCanvas::IsA());
2366 b.CheckByteCount(R__s, R__c, TCanvas::IsA());
2367 } else {
2368 //save list of colors
2369 //we must protect the case when two or more canvases are saved
2370 //in the same buffer. If the list of colors has already been saved
2371 //in the buffer, do not add the list of colors to the list of primitives.
2372 TObjArray *colors = nullptr;
2373 TObjArray *CurrentColorPalette = nullptr;
2374 // fPrimitives can be temporarily null while streaming a web-canvas
2375 // snapshot (see TWebCanvas::CreatePadSnapshot). In that case colors and
2376 // palette are delivered separately, so the list of colors must not be
2377 // added here. The guard also avoids a null dereference that crashes when
2378 // colors storage has been forced on via TColor::DefinedColors(1)
2379 // (see https://github.com/root-project/root/issues/20018).
2381 if (!b.CheckObject(gROOT->GetListOfColors(),TObjArray::Class())) {
2382 colors = (TObjArray*)gROOT->GetListOfColors();
2384 }
2385 //save the current palette
2387 Int_t palsize = pal.GetSize();
2389 CurrentColorPalette->SetName("CurrentColorPalette");
2390 for (Int_t i=0; i<palsize; i++) CurrentColorPalette->Add(gROOT->GetColor(pal[i]));
2392 }
2393
2394 R__c = b.WriteVersion(TCanvas::IsA(), kTRUE);
2395 b.ClassBegin(TCanvas::IsA());
2396 b.ClassMember("TPad");
2400 b.ClassMember("fDISPLAY","TString");
2402 b.ClassMember("fDoubleBuffer", "Int_t");
2403 b << fDoubleBuffer;
2404 b.ClassMember("fRetained", "Bool_t");
2405 b << fRetained;
2406 b.ClassMember("fXsizeUser", "Size_t");
2407 b << fXsizeUser;
2408 b.ClassMember("fYsizeUser", "Size_t");
2409 b << fYsizeUser;
2410 b.ClassMember("fXsizeReal", "Size_t");
2411 b << fXsizeReal;
2412 b.ClassMember("fYsizeReal", "Size_t");
2413 b << fYsizeReal;
2416 UInt_t editorWidth = 0;
2418 b.ClassMember("fWindowTopX", "Int_t");
2419 b << topx;
2420 b.ClassMember("fWindowTopY", "Int_t");
2421 b << topy;
2422 b.ClassMember("fWindowWidth", "UInt_t");
2423 b << (UInt_t)(w-editorWidth);
2424 b.ClassMember("fWindowHeight", "UInt_t");
2425 b << h;
2426 b.ClassMember("fCw", "UInt_t");
2427 b << fCw;
2428 b.ClassMember("fCh", "UInt_t");
2429 b << fCh;
2430 b.ClassMember("fCatt", "TAttCanvas");
2431 fCatt.Streamer(b);
2432 b.ClassMember("kMoveOpaque", "Bool_t");
2433 b << TestBit(kMoveOpaque); //please remove in ROOT version 6
2434 b.ClassMember("kResizeOpaque", "Bool_t");
2435 b << TestBit(kResizeOpaque); //please remove in ROOT version 6
2436 b.ClassMember("fHighLightColor", "Color_t");
2437 b << fHighLightColor;
2438 b.ClassMember("fBatch", "Bool_t");
2439 b << fBatch; //please remove in ROOT version 6
2440 b.ClassMember("kShowEventStatus", "Bool_t");
2441 b << TestBit(kShowEventStatus); //please remove in ROOT version 6
2442 b.ClassMember("kAutoExec", "Bool_t");
2443 b << TestBit(kAutoExec); //please remove in ROOT version 6
2444 b.ClassMember("kMenuBar", "Bool_t");
2445 b << TestBit(kMenuBar); //please remove in ROOT version 6
2446 b.ClassEnd(TCanvas::IsA());
2447 b.SetByteCount(R__c, kTRUE);
2448 }
2449}
2450
2451////////////////////////////////////////////////////////////////////////////////
2452/// Toggle pad auto execution of list of TExecs.
2453
2455{
2458}
2459
2460////////////////////////////////////////////////////////////////////////////////
2461/// Toggle event statusbar.
2462
2464{
2467
2469}
2470
2471////////////////////////////////////////////////////////////////////////////////
2472/// Toggle toolbar.
2473
2475{
2478
2480}
2481
2482////////////////////////////////////////////////////////////////////////////////
2483/// Toggle editor.
2484
2486{
2489
2491}
2492
2493////////////////////////////////////////////////////////////////////////////////
2494/// Toggle tooltip display.
2495
2497{
2500
2502}
2503
2504
2505////////////////////////////////////////////////////////////////////////////////
2506/// Static function returning "true" if transparency is supported.
2507
2509{
2510 if (gPad)
2511 if (auto pp = gPad->GetPainter())
2512 return pp->IsSupportAlpha();
2513 return kFALSE;
2514}
2515
2516extern "C" void ROOT_TCanvas_Update(void* TheCanvas) {
2517 static_cast<TCanvas*>(TheCanvas)->Update();
2518}
2519
2520////////////////////////////////////////////////////////////////////////////////
2521/// Update canvas pad buffers.
2522
2523void TCanvas::Update()
2524{
2525 fUpdated = kTRUE;
2526
2527 if (fUpdating) return;
2528
2529 if (fPixmapID == -1) return;
2530
2531 static const union CastFromFuncToVoidPtr_t {
2533 void (*fFuncPtr)(void*);
2534 void* fVoidPtr;
2536
2537 if (gThreadXAR) {
2538 void *arr[3];
2539 arr[1] = this;
2540 arr[2] = castFromFuncToVoidPtr.fVoidPtr;
2541 if ((*gThreadXAR)("CUPD", 3, arr, nullptr)) return;
2542 }
2543
2544 if (!fCanvasImp) return;
2545
2546 if (!gVirtualX->IsCmdThread()) {
2547 // Why do we have this (which uses the interpreter to funnel the Update()
2548 // through the main thread) when the gThreadXAR mechanism does seemingly
2549 // the same?
2550 gInterpreter->Execute(this, IsA(), "Update", "");
2551 return;
2552 }
2553
2555
2556 fUpdating = kTRUE;
2557
2559
2560 if (!IsBatch())
2561 FeedbackMode(kFALSE); // Goto double buffer mode
2562
2564
2565 if (UseGL() && (fGLDevice != -1)) {
2566 // TODO: try to reorganize GL part to follow normal painting rules
2567 if (need_rapaint & 5)
2568 Flush();
2569 } else {
2571 Int_t mask = useXor ? 3 : 7; // if XOR not supported, pad repaint by any change
2572
2573 // TODO: verify why transparency is used
2574 if (need_rapaint & mask) {
2575 PaintModified();
2576 Flush();
2577 }
2578
2579 // real XOR only when supported
2580 if (useXor && (need_rapaint & 4)) {
2584 }
2585 }
2586
2588 }
2589
2590 fUpdating = kFALSE;
2591}
2592
2593////////////////////////////////////////////////////////////////////////////////
2594/// Asynchronous canvas update.
2595/// In case of web-based canvas triggers update of the canvas on the client side,
2596/// but does not wait that real update is completed. Avoids blocking of caller thread.
2597/// Have to be used if called from other web-based widget to avoid logical dead-locks.
2598/// In case of normal canvas just canvas->Update() is performed.
2599/// Only when called from inside of HandleInput handler,
2600/// canvas will be updated at the end.
2601
2603{
2604 if (fHandlingInput > 0) {
2606 return;
2607 }
2608
2609 fUpdated = kTRUE;
2610
2611 if (IsWeb())
2613 else
2614 Update();
2615}
2616
2617////////////////////////////////////////////////////////////////////////////////
2618/// Used by friend class TCanvasImp.
2619
2621{
2622 fCanvasID = 0;
2623 fContextMenu = nullptr;
2624}
2625
2626////////////////////////////////////////////////////////////////////////////////
2627/// Check whether this canvas is to be drawn in grayscale mode.
2628
2630{
2631 return TestBit(kIsGrayscale);
2632}
2633
2634////////////////////////////////////////////////////////////////////////////////
2635/// Set whether this canvas should be painted in grayscale, and re-paint
2636/// it if necessary.
2637
2638void TCanvas::SetGrayscale(Bool_t set /*= kTRUE*/)
2639{
2640 if (IsGrayscale() == set) return;
2641 SetBit(kIsGrayscale, set);
2642 if (IsWeb()) {
2643 Modified();
2644 UpdateAsync();
2645 } else {
2646 Paint(); // update canvas and all sub-pads, unconditionally!
2647 }
2648}
2649
2650////////////////////////////////////////////////////////////////////////////////
2651/// Probably, TPadPainter must be placed in a separate ROOT module -
2652/// "padpainter" (the same as "histpainter"). But now, it's directly in a
2653/// gpad dir, so, in case of default painter, no *.so should be loaded,
2654/// no need in plugin managers.
2655/// May change in future.
2656
2658{
2659 //Even for batch mode painter is still required, just to delegate
2660 //some calls to batch "virtual X".
2661 if (!UseGL() || fBatch || IsWeb()) {
2662 fPainter = nullptr;
2664 if (!fPainter) fPainter = new TPadPainter; // Do not need plugin manager for this!
2665 } else {
2667 if (!fPainter) {
2668 Error("CreatePainter", "GL Painter creation failed! Will use default!");
2669 fPainter = new TPadPainter;
2670 fUseGL = kFALSE;
2671 }
2672 }
2673}
2674
2675////////////////////////////////////////////////////////////////////////////////
2676/// Access and (probably) creation of pad painter.
2677
2679{
2680 if (!fPainter) CreatePainter();
2681 return fPainter;
2682}
2683
2684////////////////////////////////////////////////////////////////////////////////
2685/// Replace canvas painter
2686/// For internal use only - when creating PS images
2687
2689{
2690 if (!create) {
2691 delete fPainter;
2692 fPainter = oldp;
2693 return kFALSE;
2694 }
2695
2696 if (!gVirtualPS /* || !IsBatch() */)
2697 return kFALSE;
2698
2699
2701 return kFALSE;
2702
2703 oldp = fPainter;
2705 return kTRUE;
2706}
2707
2708////////////////////////////////////////////////////////////////////////////////
2709///assert on IsBatch() == false?
2710
2712{
2713 if (fGLDevice != -1) {
2714 //fPainter has a font manager.
2715 //Font manager will delete textures.
2716 //If context is wrong (we can have several canvases) -
2717 //wrong texture will be deleted, damaging some of our fonts.
2718 gGLManager->MakeCurrent(fGLDevice);
2719 }
2720
2722
2723 if (fGLDevice != -1) {
2724 gGLManager->DeleteGLContext(fGLDevice);//?
2725 fGLDevice = -1;
2726 }
2727}
2728
2729
2730////////////////////////////////////////////////////////////////////////////////
2731/// Save provided pads/canvases into the image file(s)
2732/// Filename can include printf argument for image number - like "image%03d.png".
2733/// In this case images: "image000.png", "image001.png", "image002.png" will be created.
2734/// If pattern is not provided - it will be automatically inserted before extension except PDF and ROOT files.
2735/// In last case PDF or ROOT file will contain all pads.
2736/// Parameter option only used when output into PDF/PS files
2737/// If TCanvas::SaveAll() called without arguments - all existing canvases will be stored in allcanvases.pdf file.
2738
2739Bool_t TCanvas::SaveAll(const std::vector<TPad *> &pads, const char *filename, Option_t *option)
2740{
2741 if (pads.empty()) {
2742 std::vector<TPad *> canvases;
2743 TIter iter(gROOT->GetListOfCanvases());
2744 while (auto c = dynamic_cast<TCanvas *>(iter()))
2745 canvases.emplace_back(c);
2746
2747 if (canvases.empty()) {
2748 ::Warning("TCanvas::SaveAll", "No pads are provided");
2749 return kFALSE;
2750 }
2751
2752 return TCanvas::SaveAll(canvases, filename && *filename ? filename : "allcanvases.pdf", option);
2753 }
2754
2756
2757 Bool_t hasArg = fname.Contains("%");
2758
2759 if ((pads.size() == 1) && !hasArg) {
2760 pads[0]->SaveAs(filename);
2761 return kTRUE;
2762 }
2763
2764 auto p = fname.Last('.');
2765 if (p != kNPOS) {
2766 ext = fname(p+1, fname.Length() - p - 1);
2767 ext.ToLower();
2768 } else {
2769 p = fname.Length();
2770 ::Warning("TCanvas::SaveAll", "Extension is not provided in file name %s, append .png", filename);
2771 fname.Append(".png");
2772 ext = "png";
2773 }
2774
2775 if (ext != "pdf" && ext != "ps" && ext != "root" && ext != "html" && ext != "xml" && !hasArg) {
2776 fname.Insert(p, "%d");
2777 hasArg = kTRUE;
2778 }
2779
2780 static std::vector<TString> webExtensions = { "png", "json", "html", "svg", "pdf", "jpg", "jpeg", "webp" };
2781
2782 if (gROOT->IsWebDisplay() || (ext == "html")) {
2784 for (auto &wext : webExtensions) {
2785 if ((isSupported = (wext == ext)))
2786 break;
2787 }
2788
2789 if (isSupported) {
2790 auto cmd = TString::Format("TWebCanvas::ProduceImages( *((std::vector<TPad *> *) 0x%zx), \"%s\");", (size_t) &pads, fname.Data());
2791
2792 return (Bool_t) gROOT->ProcessLine(cmd);
2793 }
2794
2795 if ((ext != "root") && (ext != "xml"))
2796 ::Warning("TCanvas::SaveAll", "TWebCanvas does not support image format %s - using normal ROOT functionality", fname.Data());
2797 }
2798
2799 // store all pads into single PDF/PS files
2800 if (ext == "pdf" || ext == "ps") {
2801 for (unsigned n = 0; n < pads.size(); ++n) {
2802 TString fn = fname;
2803 if (hasArg)
2804 fn = TString::Format(fname.Data(), (int) n);
2805 else if (n == 0)
2806 fn.Append("(");
2807 else if (n == pads.size() - 1)
2808 fn.Append(")");
2809
2810 pads[n]->Print(fn.Data(), option && *option ? option : ext.Data());
2811 }
2812
2813 return kTRUE;
2814 }
2815
2816 // store all pads in single ROOT file
2817 if ((ext == "root" || ext == "xml") && !hasArg) {
2818 TString fn = fname;
2820 if (fn.IsNull()) {
2821 fn.Form("%s.%s", pads[0]->GetName(), ext.Data());
2822 ::Warning("TCanvas::SaveAll", "Filename %s cannot be used - use pad name %s as pattern", fname.Data(), fn.Data());
2823 }
2824
2826
2827 if (!gDirectory) {
2828 isError = kTRUE;
2829 } else {
2830 for (unsigned n = 0; n < pads.size(); ++n) {
2831 auto sz = gDirectory->SaveObjectAs(pads[n], fn.Data(), n==0 ? "q" : "qa");
2832 if (!sz) { isError = kTRUE; break; }
2833 }
2834 }
2835
2836 if (isError)
2837 ::Error("TCanvas::SaveAll", "Failure to store pads in %s", filename);
2838 else
2839 ::Info("TCanvas::SaveAll", "ROOT file %s has been created", filename);
2840
2841 return !isError;
2842 }
2843
2844 for (unsigned n = 0; n < pads.size(); ++n) {
2845 TString fn = TString::Format(fname.Data(), (int) n);
2847 if (fn.IsNull()) {
2848 fn.Form("%s%d.%s", pads[n]->GetName(), (int) n, ext.Data());
2849 ::Warning("TCanvas::SaveAll", "Filename %s cannot be used - use pad name %s as pattern", fname.Data(), fn.Data());
2850 }
2851
2852 pads[n]->SaveAs(fn.Data());
2853 }
2854
2855 return kTRUE;
2856
2857}
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:2513
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 WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
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
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:550
UInt_t fCw
Width of the canvas along X (pixels)
Definition TCanvas.h:44
~TCanvas() override
Canvas destructor.
Definition TCanvas.cxx:691
void EmbedInto(Int_t winid, Int_t ww, Int_t wh)
Embedded a canvas into a TRootEmbeddedCanvas.
Definition TCanvas.cxx:1059
void SetWindowSize(UInt_t ww, UInt_t wh)
Set canvas window size.
Definition TCanvas.cxx:2172
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:2037
void Browse(TBrowser *b) override
Browse.
Definition TCanvas.cxx:699
UInt_t GetWindowHeight() const
Definition TCanvas.h:167
virtual void EditorBar()
Get editor bar.
Definition TCanvas.cxx:1050
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
Definition TCanvas.cxx:1537
void EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
Generate kMouseEnter and kMouseLeave events depending on the previously selected object and the curre...
Definition TCanvas.cxx:1085
Size_t fYsizeReal
Current size of canvas along Y in CM.
Definition TCanvas.h:37
void Constructor()
Canvas default constructor.
Definition TCanvas.cxx:202
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition TCanvas.cxx:2451
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:865
void SetDoubleBuffer(Int_t mode=1) override
Set Double Buffer On/Off.
Definition TCanvas.cxx:1996
virtual void ToggleToolTips()
Toggle tooltip display.
Definition TCanvas.cxx:2493
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:751
void UseCurrentStyle() override
Force a copy of current style for all objects in canvas.
Definition TCanvas.cxx:1193
void Iconify()
Iconify canvas.
Definition TCanvas.cxx:1500
Int_t GetWindowTopX()
Returns current top x position of window on screen.
Definition TCanvas.cxx:1218
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2460
void Destructor()
Actual canvas destructor.
Definition TCanvas.cxx:709
Bool_t fUpdated
! Set to True when Update method was called
Definition TCanvas.h:66
void DeleteCanvasPainter()
assert on IsBatch() == false?
Definition TCanvas.cxx:2708
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:2505
Bool_t fBatch
! True when in batchmode
Definition TCanvas.h:61
Bool_t fUseGL
! True when rendering is with GL
Definition TCanvas.h:64
Int_t fEventX
! Last X mouse position in canvas
Definition TCanvas.h:47
Bool_t IsBatch() const override
Definition TCanvas.h:178
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:918
Size_t fXsizeReal
Current size of canvas along X in CM.
Definition TCanvas.h:36
Bool_t HasMenuBar() const
Definition TCanvas.h:175
TVirtualPadPainter * GetCanvasPainter()
Access and (probably) creation of pad painter.
Definition TCanvas.cxx:2675
virtual void HighlightConnect(const char *slot)
This is "simplification" for function TCanvas::Connect with Highlighted signal for specific slot.
Definition TCanvas.cxx:1652
Int_t fHandlingInput
! use to implement posponded update of canvas
Definition TCanvas.h:58
TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj) override
Search for an object at pixel position px,py.
Definition TCanvas.h:190
void Close(Option_t *option="") override
Close canvas.
Definition TCanvas.cxx:802
void SetFixedAspectRatio(Bool_t fixed=kTRUE) override
Fix canvas aspect ratio to current value if fixed is true.
Definition TCanvas.cxx:2015
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition TCanvas.cxx:1689
Color_t GetHighLightColor() const override
Definition TCanvas.h:143
Bool_t GetShowToolBar() const
Definition TCanvas.h:154
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:989
Bool_t IsFolder() const override
Is folder ?
Definition TCanvas.cxx:1509
Bool_t EnsurePSPainter(Bool_t create, TVirtualPadPainter *&oldp)
Replace canvas painter For internal use only - when creating PS images.
Definition TCanvas.cxx:2685
UInt_t fWindowWidth
Width of window (including borders, etc.)
Definition TCanvas.h:42
TVirtualPadPainter * fPainter
! Canvas (pad) painter.
Definition TCanvas.h:68
void CopyPixmaps() override
Copy the canvas pixmap of the pad to the canvas.
Definition TCanvas.cxx:847
Bool_t IsGrayscale()
Check whether this canvas is to be drawn in grayscale mode.
Definition TCanvas.cxx:2626
TPad * fClickSelectedPad
! Pad containing currently click-selected object
Definition TCanvas.h:56
Bool_t fUpdating
! True when Updating the canvas
Definition TCanvas.h:62
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1835
void SetCanvasImp(TCanvasImp *i)
Set canvas implementation If web-based implementation provided, some internal fields also initialized...
Definition TCanvas.cxx:2184
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:2224
virtual void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected)
Emit ProcessedEvent() signal.
Definition TCanvas.cxx:1674
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1242
void UpdateAsync() override
Asynchronous canvas update.
Definition TCanvas.cxx:2599
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:733
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:1229
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:1973
void Show()
Show canvas.
Definition TCanvas.cxx:2235
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:1660
Int_t fSelectedX
! X of selected object
Definition TCanvas.h:52
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2482
TVirtualPad * GetSelectedPad() const override
Definition TCanvas.h:151
virtual void Picked(TPad *selpad, TObject *selected, Int_t event)
Emit Picked() signal.
Definition TCanvas.cxx:1614
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:1801
void SetCursor(ECursor cursor) override
Set cursor.
Definition TCanvas.cxx:1987
void Streamer(TBuffer &) override
Stream a class object.
Definition TCanvas.cxx:2244
Bool_t GetShowToolTips() const
Definition TCanvas.h:156
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:2635
void SetTitle(const char *title="") override
Set canvas title.
Definition TCanvas.cxx:2154
UInt_t fCh
Height of the canvas along Y (pixels)
Definition TCanvas.h:45
TContextMenu * fContextMenu
! Context menu pointer
Definition TCanvas.h:60
TAttCanvas fCatt
Canvas attributes.
Definition TCanvas.h:32
void SetName(const char *name="") override
Set canvas name.
Definition TCanvas.cxx:2046
UInt_t GetWindowWidth() const
Definition TCanvas.h:166
Bool_t fRetained
Retain structure flag.
Definition TCanvas.h:63
void DisconnectWidget()
Used by friend class TCanvasImp.
Definition TCanvas.cxx:2617
void ls(Option_t *option="") const override
List all pads.
Definition TCanvas.cxx:1525
void RaiseWindow()
Raise canvas window.
Definition TCanvas.cxx:1767
void Build()
Build a canvas. Called by all constructors.
Definition TCanvas.cxx:601
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:2736
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:1564
TClass * IsA() const override
Definition TCanvas.h:245
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2520
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TCanvas.cxx:1121
void RunAutoExec()
Execute the list of TExecs in the current pad.
Definition TCanvas.cxx:1790
virtual void Cleared(TVirtualPad *pad)
Emit pad Cleared signal.
Definition TCanvas.cxx:784
UInt_t GetWw() const override
Definition TCanvas.h:168
TCanvasImp * fCanvasImp
! Window system specific canvas implementation
Definition TCanvas.h:59
UInt_t GetWh() const override
Definition TCanvas.h:169
void FeedbackMode(Bool_t set) override
Turn rubberband feedback mode on or off.
Definition TCanvas.cxx:1139
virtual void Highlighted(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)
Emit Highlighted() signal.
Definition TCanvas.cxx:1633
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1155
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:1185
void CreatePainter()
Probably, TPadPainter must be placed in a separate ROOT module - "padpainter" (the same as "histpaint...
Definition TCanvas.cxx:2654
void SetSelected(TObject *obj) override
Set selected canvas.
Definition TCanvas.cxx:2145
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition TCanvas.cxx:1556
static Bool_t fgIsFolder
Indicates if canvas can be browsed as a folder.
Definition TCanvas.h:72
void Closed() override
Emit Closed signal.
Definition TCanvas.cxx:792
Bool_t IsWeb() const override
Is web canvas.
Definition TCanvas.cxx:1517
void SetWindowPosition(Int_t x, Int_t y)
Set canvas window position.
Definition TCanvas.cxx:2163
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:2078
Int_t fEvent
! Type of current or last handled event
Definition TCanvas.h:46
Bool_t GetShowEventStatus() const
Definition TCanvas.h:153
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:65
void SetBatch(Bool_t batch=kTRUE) override
Toggle batch mode.
Definition TCanvas.cxx:1955
Bool_t UseGL() const
Definition TCanvas.h:235
@ kResizeOpaque
Definition TCanvas.h:100
@ kShowToolTips
Definition TCanvas.h:102
@ kShowToolBar
Definition TCanvas.h:97
@ kMoveOpaque
Definition TCanvas.h:99
@ kIsGrayscale
Definition TCanvas.h:101
@ kShowEventStatus
Definition TCanvas.h:94
@ kAutoExec
Definition TCanvas.h:95
@ kMenuBar
Definition TCanvas.h:96
@ kShowEditor
Definition TCanvas.h:98
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition TCanvas.cxx:1782
virtual void ToggleToolBar()
Toggle toolbar.
Definition TCanvas.cxx:2471
TVirtualPad * fHilightPadBorder
! pad which border will be hilghlighrt when paint canvas
Definition TCanvas.h:70
virtual TObject * DrawClonePad()
Draw a clone of this canvas into the current pad In an interactive session, select the destination/cu...
Definition TCanvas.cxx:935
@ 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:32
Short_t GetBorderMode() const override
Definition TPad.h:207
void SetBorderSize(Short_t bordersize) override
Definition TPad.h:342
Int_t GetTicky() const override
Definition TPad.h:250
void PaintBorder(Color_t color, Bool_t tops)
Paint the pad border.
Definition TPad.cxx:3592
Bool_t IsEditable() const override
Definition TPad.h:283
void ResizePad(Option_t *option="") override
Compute pad conversion coefficients.
Definition TPad.cxx:5653
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
Definition TPad.h:351
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitives in this pad on the C++ source file out.
Definition TPad.cxx:5868
void PaintOperations(Bool_t withXor=kFALSE)
Perform buffered paint operations Used for interactivity functionality immediately after normal paint...
Definition TPad.cxx:3823
Bool_t GetGridx() const override
Definition TPad.h:246
Double_t fX2
X of upper X coordinate.
Definition TPad.h:44
void SetLogz(Int_t value=1) override
Set Lin/Log scale for Z.
Definition TPad.cxx:6081
Double_t GetY2() const override
Definition TPad.h:254
void Close(Option_t *option="") override
Delete all primitives in pad and pad itself.
Definition TPad.cxx:1121
void PaintModified() override
Traverse pad hierarchy and (re)paint only modified pads.
Definition TPad.cxx:3727
const char * GetTitle() const override
Returns title of object.
Definition TPad.h:272
Double_t fX1
X of lower X coordinate.
Definition TPad.h:42
TList * GetListOfPrimitives() const override
Definition TPad.h:256
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:6141
void UseCurrentStyle() override
Force a copy of current style for all objects in pad.
Definition TPad.cxx:6898
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:5360
Double_t fY1
Y of lower Y coordinate.
Definition TPad.h:43
Int_t fGLDevice
! OpenGL off-screen pixmap identifier
Definition TPad.h:91
void Clear(Option_t *option="") override
Delete all pad primitives.
Definition TPad.cxx:760
Int_t GetTickx() const override
Definition TPad.h:249
Double_t fAspectRatio
ratio of w/h in case of fixed ratio
Definition TPad.h:88
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:6070
TCanvas * fCanvas
! Pointer to mother canvas
Definition TPad.h:112
Bool_t fFixedAspectRatio
True if fixed aspect ratio.
Definition TPad.h:110
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Definition TPad.cxx:7359
void ls(Option_t *option="") const override
List all primitives in pad.
Definition TPad.cxx:2996
void Streamer(TBuffer &) override
Stream a class object.
Definition TPad.cxx:6684
TString fTitle
Pad title.
Definition TPad.h:116
void CopyPixmaps() override
Copy the sub-pixmaps of the pad to the canvas.
Definition TPad.cxx:1196
void CopyPixmap() override
Copy the pixmap of the pad to the canvas.
Definition TPad.cxx:1180
Double_t GetY1() const override
Definition TPad.h:253
Bool_t GetGridy() const override
Definition TPad.h:247
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TPad.cxx:1978
Int_t GetLogz() const override
Definition TPad.h:269
Short_t GetBorderSize() const override
Definition TPad.h:208
TList * fPrimitives
->List of primitives (subpads)
Definition TPad.h:113
Short_t fBorderSize
pad bordersize in pixels
Definition TPad.h:103
void Paint(Option_t *option="") override
Paint all primitives in pad.
Definition TPad.cxx:3514
TString fName
Pad name.
Definition TPad.h:115
Int_t fPixmapID
! Off-screen pixmap identifier
Definition TPad.h:90
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:2540
Int_t IsAnyNeedRepaint() const
Check if pad or any subpads need to be repaint Returns flag with following mask: 1 - some pad is modi...
Definition TPad.cxx:2742
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition TPad.cxx:731
Int_t GetLogy() const override
Definition TPad.h:268
void SetBorderMode(Short_t bordermode) override
Definition TPad.h:341
void SetTicks(Int_t valuex=1, Int_t valuey=1) override
Definition TPad.h:371
Double_t fY2
Y of upper Y coordinate.
Definition TPad.h:45
Short_t fBorderMode
Bordermode (-1=down, 0 = no border, 1=up)
Definition TPad.h:104
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition TPad.cxx:6056
Int_t GetLogx() const override
Definition TPad.h:267
Double_t GetX2() const override
Definition TPad.h:252
Double_t GetX1() const override
Definition TPad.h:251
TPad * fMother
! pointer to mother of the list
Definition TPad.h:111
const char * GetName() const override
Returns name of object.
Definition TPad.h:271
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:1290
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 Bool_t IsNative() const
virtual Bool_t IsCocoa() const
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, Int_t)
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()