Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TVirtualPad.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Rene Brun 05/12/95
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 "TVirtualPad.h"
13#include "TBuffer.h"
14#include "TThreadSlots.h"
15
16/** \class TVirtualPad
17\ingroup Base
18
19TVirtualPad is an abstract base class for the Pad and Canvas classes.
20*/
21
22Int_t (*gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret) = nullptr;
23
24
25/** \class TVirtualPad::TContext
26\ingroup Base
27
28Small helper class to preserve gPad, which will be restored when TContext object is destroyed
29*/
30
31
32////////////////////////////////////////////////////////////////////////////////
33/// Constructor which just store gPad
34/// @param _interactive defines how gPad will be restored: with cd() call (kTRUE) or just by assign gPad back
35
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor which stores gPad and set it to new value
44/// @param gpad pointer to current pad
45/// @param interactive defines how gPad will be restored: with cd() call (kTRUE) or just by assign gPad back
46/// @param not_null allows to set only pad which is not null
47
49{
50 fInteractive = interactive;
51 fSaved = gPad;
52 if (fInteractive && gpad)
53 gpad->cd();
54 else if (!not_null || gpad)
55 gPad = gpad;
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// Destructor
60/// Restores previous value of gPad
61
63{
64 if (!fInteractive || !fSaved)
65 gPad = fSaved;
66 else
67 fSaved->cd();
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Inform context that pad deleted or will be deleted soon
72/// Reference on that pad should be cleared
73
75{
76 if (pad == fSaved)
77 fSaved = nullptr;
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// Return the current pad for the current thread.
82
84{
85 static TVirtualPad *currentPad = nullptr;
86 if (!gThreadTsd)
87 return currentPad;
88 else
90}
91
92
93////////////////////////////////////////////////////////////////////////////////
94/// VirtualPad default constructor
95
100
101////////////////////////////////////////////////////////////////////////////////
102/// VirtualPad constructor
103
104TVirtualPad::TVirtualPad(const char *, const char *, Double_t,
106 : TAttPad()
107{
109
110 SetFillColor(color);
111 SetFillStyle(1001);
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// VirtualPad destructor
116
120
121////////////////////////////////////////////////////////////////////////////////
122/// Stream an object of class TVirtualPad.
123
125{
126 if (R__b.IsReading()) {
128 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
129 if (R__v > 1) {
130 R__b.ReadClassBuffer(TVirtualPad::Class(), this, R__v, R__s, R__c);
131 return;
132 }
133 //====process old versions before automatic schema evolution
138 //====end of old versions
139
140 } else {
141 R__b.WriteClassBuffer(TVirtualPad::Class(),this);
142 }
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Should always return false unless you have non-standard picking.
147
149{
150 return kFALSE;
151}
152
153////////////////////////////////////////////////////////////////////////////////
154/// Should always return false, unless you can highlight selected object in pad.
155
157{
158 return kFALSE;
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Paint N individual segments
163/// Provided arrays should have 2*n elements
164/// IMPORTANT! Provided arrays can be modified after function call!
165
167{
168 for (Int_t i = 0; i < 2*n; i += 2)
169 PaintLine(x[i], y[i], x[i+1], y[i+1]);
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Paint N individual segments in NDC coordinates
174/// Provided arrays should have 2*n elements
175
177{
178 for (Int_t i = 0; i < 2*n; i += 2)
179 PaintLineNDC(u[i], v[i], u[i+1], v[i+1]);
180}
181
182
183////////////////////////////////////////////////////////////////////////////////
184/// Does nothing, unless you implement your own picking.
185/// When complex object containing sub-objects (which can be picked)
186/// is painted in a pad, this "top-level" object is pushed into
187/// the selectables stack.
188
190{
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Does nothing, unless you implement your own picking.
195/// "Complete" object, or part of complex object, which
196/// can be picked.
197
199{
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// Does nothing, unless you implement your own picking.
204/// Remove top level selectable and all its' children.
205
209
210////////////////////////////////////////////////////////////////////////////////
211/// Scope-guards ctor, pushe the object on stack.
212
214{
215 gPad->PushTopLevelSelectable(obj);
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Guard does out of scope, pop object from stack.
220
222{
223 gPad->PopTopLevelSelectable();
224}
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
short Version_t
Class version identifier (short)
Definition RtypesCore.h:79
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t SetFillStyle
Option_t Option_t SetFillColor
R__EXTERN void **(* gThreadTsd)(void *, Int_t)
Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
#define gPad
virtual void Streamer(TBuffer &)
virtual void Streamer(TBuffer &)
Manages default Pad attributes.
Definition TAttPad.h:19
virtual void Streamer(TBuffer &)
Stream an object of class TAttPad.
Definition TAttPad.cxx:149
Buffer base class used for serializing objects.
Definition TBuffer.h:43
Mother of all ROOT objects.
Definition TObject.h:42
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:994
~TPickerStackGuard()
Guard does out of scope, pop object from stack.
TPickerStackGuard(TObject *obj)
Scope-guards ctor, pushe the object on stack.
~TContext()
Destructor Restores previous value of gPad.
TContext(Bool_t _interactive=kFALSE)
Constructor which just store gPad.
TVirtualPad * fSaved
Definition TVirtualPad.h:63
void PadDeleted(TVirtualPad *pad)
Inform context that pad deleted or will be deleted soon Reference on that pad should be cleared.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
virtual Bool_t PadInHighlightMode() const
Should always return false, unless you can highlight selected object in pad.
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual ~TVirtualPad()
VirtualPad destructor.
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)=0
virtual Bool_t PadInSelectionMode() const
Should always return false unless you have non-standard picking.
virtual void PushTopLevelSelectable(TObject *top)
Does nothing, unless you implement your own picking.
void Streamer(TBuffer &) override
Stream an object of class TVirtualPad.
virtual void PaintSegmentsNDC(Int_t n, Double_t *u, Double_t *v)
Paint N individual segments in NDC coordinates Provided arrays should have 2*n elements.
virtual void PushSelectableObject(TObject *obj)
Does nothing, unless you implement your own picking.
static TClass * Class()
virtual void PaintLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)=0
TVirtualPad()
VirtualPad default constructor.
static TVirtualPad *& Pad()
Return the current pad for the current thread.
Bool_t fResizing
!true when resizing the pad
Definition TVirtualPad.h:54
virtual void PopTopLevelSelectable()
Does nothing, unless you implement your own picking.
virtual void PaintSegments(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Paint N individual segments Provided arrays should have 2*n elements IMPORTANT! Provided arrays can b...
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
@ kPadThreadSlot