27std::mutex &GetHeldCanvasesMutex()
29 static std::mutex sMutex;
33std::vector<std::shared_ptr<ROOT::Experimental::RCanvas>> &GetHeldCanvases()
35 static std::vector<std::shared_ptr<ROOT::Experimental::RCanvas>> sCanvases;
47 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
49 return GetHeldCanvases();
58 std::vector<std::shared_ptr<ROOT::Experimental::RCanvas>> vect;
61 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
63 std::swap(vect, GetHeldCanvases());
91 auto pCanvas = std::make_shared<RCanvas>();
92 pCanvas->SetTitle(title);
94 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
95 GetHeldCanvases().emplace_back(pCanvas);
120 if (
gROOT->IsWebDisplayBatch())
124 bool isany = (
fPainter->NumDisplays() > 0);
162 return fPainter->GetWindowUrl(remote);
202 return fPainter->ProduceBatchOutput(filename, width > 1 ? width : 800, height > 1 ? height : 600);
211 const void *ptr =
this;
237 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
238 auto &held = GetHeldCanvases();
239 auto indx = held.size();
241 if (held[indx].get() ==
this)
242 held.erase(held.begin() + indx);
300 std::this_thread::sleep_for(std::chrono::milliseconds(
int(tm*1000)));
315 for (
unsigned n = 0;
n < vect.size(); ++
n) {
316 if (vect[
n]->HasShared() || !vect[
n]->GetIOPtr())
continue;
318 auto shrd_ptr = vect[
n]->MakeShared();
320 for (
auto n2 =
n+1; n2 < vect.size(); ++n2) {
321 if (vect[n2]->GetIOPtr() == vect[
n]->GetIOPtr()) {
322 if (vect[n2]->HasShared())
325 vect[n2]->SetShared(shrd_ptr);
344 if (!canv)
return nullptr;
353 for(
int indx = 0; indx < (
int)
ids.size(); indx++) {
354 if (
ids[indx] ==
"canvas") {
355 if (canv->GetAttrMap().Change(
names[indx],
values[indx].get())) {
356 if (!vers) vers = canv->IncModified();
357 canv->SetDrawableVersion(vers);
360 auto drawable = canv->FindPrimitiveByDisplayId(
ids[indx]);
361 if (drawable && drawable->GetAttrMap().Change(
names[indx],
values[indx].get())) {
362 if (!vers) vers = canv->IncModified();
363 drawable->SetDrawableVersion(vers);
#define R__LOG_ERROR(...)
short Version_t
Class version identifier (short).
static std::unique_ptr< RVirtualCanvasPainter > Create(RCanvas &canv)
Loads the plugin that implements this class.
static const std::vector< std::shared_ptr< RCanvas > > GetCanvases()
Returns list of created canvases.
static void ReleaseHeldCanvases()
Release list of held canvases pointers If no other shared pointers exists on the canvas,...
bool SaveAs(const std::string &filename)
Save canvas in image file.
Version_t fModified
Modify counter, incremented every time canvas is changed.
std::string GetWindowUrl(bool remote)
Returns window URL which can be used for connection.
int GetHeight() const
Get canvas height.
bool IsModified() const
Returns true is canvas was modified since last painting.
void Show(const std::string &where="")
Display the canvas.
bool fShown
indicate if Show() method was called before
std::string GetWindowAddr() const
Returns window name used to display canvas.
void Remove()
Remove canvas from global canvas lists, will be destroyed when shared_ptr will be removed.
void ResolveSharedPtrs()
To resolve problem with storing of shared pointers Call this method when reading canvas from the file...
void Run(double tm=0.)
Run canvas functionality for given time (in seconds).
std::string GetUID() const
Return unique identifier for the canvas Used in iPython display.
std::string CreateJSON()
Provide JSON which can be used for offline display.
std::unique_ptr< Internal::RVirtualCanvasPainter > fPainter
The painter of this canvas, bootstrapping the graphics connection.
bool fUpdated
indicate if Update() method was called before
static std::shared_ptr< RCanvas > Create(const std::string &title)
Create new canvas instance.
void ClearOnClose(const std::shared_ptr< void > &handle)
Set handle which will be cleared when connection is closed.
void Update(bool async=false, CanvasCallback_t callback=nullptr)
update drawing
int GetWidth() const
Get canvas width.
std::shared_ptr< RWebWindow > GetWindow()
Returns window handle for the canvas.
void Hide()
Hide all canvas displays.
std::vector< std::unique_ptr< RAttrMap::Value_t > > values
array of values
std::vector< std::string > names
array of attribute names
std::vector< std::string > ids
array of ids
bool fNeedUpdate
! is canvas update required
bool update
update canvas at the end
std::unique_ptr< RDrawableReply > Process() override
Apply attributes changes to the drawable Return mask with actions which were really applied.
const RDrawable::RDisplayContext & GetContext() const
void CollectShared(Internal::RIOSharedVector_t &) override
Collect all shared items to resolve shared_ptr after IO.
const char * Data() const
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
std::vector< RIOSharedBase * > RIOSharedVector_t
std::function< void(bool)> CanvasCallback_t
ROOT::RLogChannel & GPadLog()
Log channel for GPad diagnostics.