File indexing completed on 2025-01-18 10:10:36
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ROOT7_RCanvas
0010 #define ROOT7_RCanvas
0011
0012 #include "ROOT/RPadBase.hxx"
0013 #include "ROOT/RVirtualCanvasPainter.hxx"
0014 #include "ROOT/RDrawableRequest.hxx"
0015
0016 #include <memory>
0017 #include <string>
0018 #include <vector>
0019 #include <list>
0020
0021 namespace ROOT {
0022 namespace Experimental {
0023
0024 class RChangeAttrRequest : public RDrawableRequest {
0025 std::vector<std::string> ids;
0026 std::vector<std::string> names;
0027 std::vector<std::unique_ptr<RAttrMap::Value_t>> values;
0028 bool update{true};
0029 bool fNeedUpdate{false};
0030 RChangeAttrRequest(const RChangeAttrRequest &) = delete;
0031 RChangeAttrRequest& operator=(const RChangeAttrRequest &) = delete;
0032 public:
0033 RChangeAttrRequest() = default;
0034 ~RChangeAttrRequest() override = default;
0035 std::unique_ptr<RDrawableReply> Process() override;
0036 bool NeedCanvasUpdate() const override { return fNeedUpdate; }
0037 };
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 class RCanvas: public RPadBase {
0048 friend class RPadBase;
0049 friend class RCanvasPainter;
0050 friend class RChangeAttrRequest;
0051 private:
0052
0053 std::string fTitle;
0054
0055
0056 int fWidth{0};
0057
0058
0059 int fHeight{0};
0060
0061
0062 Version_t fModified{1};
0063
0064
0065
0066
0067 std::unique_ptr<Internal::RVirtualCanvasPainter> fPainter;
0068
0069
0070 bool fShown{false};
0071
0072
0073 bool fUpdated{false};
0074
0075
0076 RCanvas(const RCanvas &) = delete;
0077
0078
0079 RCanvas &operator=(const RCanvas &) = delete;
0080
0081
0082 uint64_t IncModified() { return ++fModified; }
0083
0084 public:
0085 static std::shared_ptr<RCanvas> Create(const std::string &title);
0086
0087
0088 RCanvas() : RPadBase("canvas") {}
0089
0090 ~RCanvas() override = default;
0091
0092 const RCanvas *GetCanvas() const override { return this; }
0093
0094
0095 RCanvas *GetCanvas() override { return this; }
0096
0097
0098 void SetSize(int width, int height)
0099 {
0100 fWidth = width;
0101 fHeight = height;
0102 }
0103
0104
0105 void SetWidth(int width) { fWidth = width; }
0106
0107
0108 void SetHeight(int height) { fHeight = height; }
0109
0110
0111 int GetWidth() const { return fWidth; }
0112
0113
0114 int GetHeight() const { return fHeight; }
0115
0116
0117 void Show(const std::string &where = "");
0118
0119
0120 bool IsShown() const { return fShown; }
0121
0122
0123 void ClearShown() { fShown = false; }
0124
0125
0126 std::string GetWindowAddr() const;
0127
0128
0129 std::string GetWindowUrl(bool remote);
0130
0131
0132 void Hide();
0133
0134
0135 void Remove();
0136
0137
0138 template <class PANEL>
0139 bool AddPanel(std::shared_ptr<PANEL> &panel)
0140 {
0141 if (!fPainter) return false;
0142 return fPainter->AddPanel(panel->GetWindow());
0143 }
0144
0145
0146 uint64_t GetModified() const { return fModified; }
0147
0148
0149 void Modified() { SetDrawableVersion(IncModified()); }
0150
0151
0152 void Modified(std::shared_ptr<RDrawable> drawable)
0153 {
0154
0155 if (drawable)
0156 drawable->SetDrawableVersion(IncModified());
0157 }
0158
0159
0160 bool IsModified() const;
0161
0162
0163 void Update(bool async = false, CanvasCallback_t callback = nullptr);
0164
0165
0166 bool IsUpdated() const { return fUpdated; }
0167
0168
0169 void ClearUpdated() { fUpdated = false; }
0170
0171
0172 void Run(double tm = 0.);
0173
0174
0175 bool SaveAs(const std::string &filename);
0176
0177
0178 std::string CreateJSON();
0179
0180 std::string GetUID() const;
0181
0182
0183 const std::string &GetTitle() const { return fTitle; }
0184
0185
0186 RCanvas &SetTitle(const std::string &title)
0187 {
0188 fTitle = title;
0189 return *this;
0190 }
0191
0192 void ResolveSharedPtrs();
0193
0194 void ClearOnClose(const std::shared_ptr<void> &handle);
0195
0196 static const std::vector<std::shared_ptr<RCanvas>> GetCanvases();
0197
0198 static void ReleaseHeldCanvases();
0199 };
0200
0201 }
0202 }
0203
0204 #endif