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