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