32static std::mutex &GetHeldCanvasesMutex()
34 static std::mutex sMutex;
38static std::vector<std::shared_ptr<ROOT::Experimental::RCanvas>> &GetHeldCanvases()
40 static std::vector<std::shared_ptr<ROOT::Experimental::RCanvas>> sCanvases;
49 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
51 return GetHeldCanvases();
65 return std::to_string(fIdCounter++);
73 return fPainter ? fPainter->IsCanvasModified(fModified) : fModified;
79 fPainter->CanvasUpdated(fModified, async, callback);
90 auto pCanvas = std::make_shared<RCanvas>();
91 pCanvas->SetTitle(title);
93 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
94 GetHeldCanvases().emplace_back(pCanvas);
116 bool isany = (fPainter->NumDisplays() > 0);
119 fPainter->NewDisplay(where);
131 fPainter->NewDisplay(where);
132 fPainter->CanvasUpdated(fModified,
true,
nullptr);
142 delete fPainter.release();
162 if (filename.find(
".json") != std::string::npos) {
163 fPainter->DoWhenReady(
"JSON", filename, async, callback);
164 }
else if (filename.find(
".svg") != std::string::npos)
165 fPainter->DoWhenReady(
"SVG", filename, async, callback);
166 else if (filename.find(
".png") != std::string::npos)
167 fPainter->DoWhenReady(
"PNG", filename, async, callback);
168 else if ((filename.find(
".jpg") != std::string::npos) || (filename.find(
".jpeg") != std::string::npos))
169 fPainter->DoWhenReady(
"JPEG", filename, async, callback);
177 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
178 auto &held = GetHeldCanvases();
179 auto indx = held.size();
181 if (held[indx].get() ==
this)
182 held.erase(held.begin() + indx);
231 std::this_thread::sleep_for(std::chrono::milliseconds(
int(tm*1000)));
static std::unique_ptr< RVirtualCanvasPainter > Create(const RCanvas &canv)
Loads the plugin that implements this class.
static const std::vector< std::shared_ptr< RCanvas > > GetCanvases()
bool IsModified() const
Returns true is canvas was modified since last painting.
void Show(const std::string &where="")
Display the canvas.
void Remove()
Remove canvas from global canvas lists, will be destroyed when shared_ptr will be removed.
void Run(double tm=0.)
Run canvas functionality for given time (in seconds)
static std::shared_ptr< RCanvas > Create(const std::string &title)
void Update(bool async=false, CanvasCallback_t callback=nullptr)
update drawing
void SaveAs(const std::string &filename, bool async=false, CanvasCallback_t callback=nullptr)
Save canvas in image file.
std::string GenerateUniqueId()
Generates unique ID inside the canvas.
void Hide()
Hide all canvas displays.
std::function< void(bool)> CanvasCallback_t