25static std::mutex &GetHeldCanvasesMutex()
27 static std::mutex sMutex;
31static std::vector<std::shared_ptr<ROOT::Experimental::RCanvas>> &GetHeldCanvases()
33 static std::vector<std::shared_ptr<ROOT::Experimental::RCanvas>> sCanvases;
42 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
44 return GetHeldCanvases();
52 return fPainter ? fPainter->IsCanvasModified(fModified) : fModified;
58 fPainter->CanvasUpdated(fModified, async, callback);
63 auto pCanvas = std::make_shared<RCanvas>();
64 pCanvas->SetTitle(title);
66 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
67 GetHeldCanvases().emplace_back(pCanvas);
89 bool isany = (fPainter->NumDisplays() > 0);
92 fPainter->NewDisplay(where);
104 fPainter->NewDisplay(where);
105 fPainter->CanvasUpdated(fModified,
true,
nullptr);
115 return fPainter->GetWindowAddr();
127 delete fPainter.release();
147 if (filename.find(
".json") != std::string::npos) {
148 fPainter->DoWhenReady(
"JSON", filename, async, callback);
149 }
else if (filename.find(
".svg") != std::string::npos)
150 fPainter->DoWhenReady(
"SVG", filename, async, callback);
151 else if (filename.find(
".png") != std::string::npos)
152 fPainter->DoWhenReady(
"PNG", filename, async, callback);
153 else if ((filename.find(
".jpg") != std::string::npos) || (filename.find(
".jpeg") != std::string::npos))
154 fPainter->DoWhenReady(
"JPEG", filename, async, callback);
162 std::lock_guard<std::mutex> grd(GetHeldCanvasesMutex());
163 auto &held = GetHeldCanvases();
164 auto indx = held.size();
166 if (held[indx].get() ==
this)
167 held.erase(held.begin() + indx);
216 std::this_thread::sleep_for(std::chrono::milliseconds(
int(tm*1000)));
231 for (
unsigned n = 0;
n < vect.size(); ++
n) {
232 if (vect[
n]->HasShared() || !vect[
n]->GetIOPtr())
continue;
234 auto shrd_ptr = vect[
n]->MakeShared();
236 for (
auto n2 =
n+1; n2 < vect.size(); ++n2) {
237 if (vect[n2]->GetIOPtr() == vect[
n]->GetIOPtr()) {
238 if (vect[n2]->HasShared())
239 R__ERROR_HERE(
"Gpadv7") <<
"FATAL Shared pointer for same IO ptr already exists";
241 vect[n2]->SetShared(shrd_ptr);
#define R__ERROR_HERE(GROUP)
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.
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)
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.
void Hide()
Hide all canvas displays.
std::vector< RIOSharedBase * > RIOSharedVector_t
std::function< void(bool)> CanvasCallback_t