-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[draft] [DO NOT MERGE] Introducing TObject::PaintOn()
method
#15937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Test Results 9 files 9 suites 2d 7h 33m 44s ⏱️ For more details on these failures, see this check. Results for commit 33ec5ea. ♻️ This comment has been updated with latest results. |
There is problem with derived classes. |
Suppose I have N threads creating M png files in batch. Will this work? |
Yes, this is that I want to achieve. But replacing Most critical point are |
This is new method for object painting. One should invoke respective methods of pad to paint lines, text, circles to represent object graphically. To add object to the pad or canvas, one should use TPad::Add() method. For backward compatibility old Paint() method is invoked when this method not implemented
TObject::PaintOn()
methodTObject::PaintOn()
method
It is central place where it should be used If custom Paint method still exists in the class - it will be invoked to keep backward compatibility GCC allows direct check of virtual method pointer, For all other compilers use type_info and TClass. For ROOT classes with existing dictionaries we can define if custom Paint exists or not. For user classes - only with existing dictionary and no Paint in list of methods - PaintOn will be used Such workaround can be removed after two ROOT major releases when Paint is declared as depricted.
Directly draw on provided pad, no need to use gPad
Keep support of extra public methods for painting
Use in all internal methods pad as first argument
It will be central method to paint any primitive on specified pad.
To support all kinds of old implementations in TObject class Paint() method will be implemented as:
Main trick will be painting of pad primitives. There one can use semi-standard method to detect
if custom
Paint()
method implemented for the object. If yes - such oldPaint()
will be invoked.If class converted into new scheme -
Paint()
method MUST be re removed and replaced by newPaintOn()
.This is very important to support sub-classes of classes like
TLine
orTBox
.TLine::PaintOn()
implemented from very beginning, butSubClass::Paint()
will exists. Calling scheme will be:SubClass::Paint()
->TObject::Paint()
->TLine::PaintOn()
Step-by-step in all ROOT classes one will implement
PaintOn()
methods - without breaking any existing code.PR shows example with several "simple" classes how it can be done.
During ROOT code modifications graphics continues to work as before.
But contentiously usage of
gPad
will be reduced.Main goal -
gPad
should not be touched when painting ROOT classes.Only to support arbitrary user classes one will keep
TObject::PaintOn()
as shown.After code conversion is completed, one can declare
special methods which are using
gPad
(likeTLine::PaintLineNDC()
) deprecated andadvertise use of new methods (like
TLine::PaintLineNDCOn()
).Ultimate goal - painting of main ROOT classes do not touch
gPad
and thus will be really thread-safe.Interactive methods (like moving stats box around) will still rely on
gPad
,but this pointer will not be touched during any re-painting and will remain consistent.