// Author: Sergey Linev, GSI 7/12/2016 /************************************************************************* * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifndef ROOT_TWebCanvas #define ROOT_TWebCanvas #include "TCanvasImp.h" #include "TString.h" #include "TList.h" #include "TWebPadOptions.h" #include #include #include #include #include class TPad; class TPadWebSnapshot; class TWebPS; class TObjLink; class TWebCanvas : public TCanvasImp { public: /// Function type for signals, invoked when canvas drawing or update is completed using UpdatedSignal_t = std::function; /// Function type for pad-related signals - like activate pad signal using PadSignal_t = std::function; /// Function type for pad-click signals using PadClickedSignal_t = std::function; /// Function type for signals, invoked when object is selected using ObjectSelectSignal_t = std::function; protected: /// Function called when pad painting produced using PadPaintingReady_t = std::function; struct WebConn { unsigned fConnId{0}; /// fSend; /// fWebConn; /// fWindow; ///!< configured display Bool_t fReadOnly{true}; /// fCustomClasses; ///0) && (fWebConn[0].fConnId == connid) ;} void ShowCmd(const std::string &arg, Bool_t show); void AssignStatusBits(UInt_t bits); virtual Bool_t ProcessData(unsigned connid, const std::string &arg); virtual Bool_t DecodePadOptions(const std::string &); virtual Bool_t CanCreateObject(const std::string &) { return !IsReadOnly() && fCanCreateObjects; } TPad *ProcessObjectOptions(TWebObjectOptions &item, TPad *pad); TObject *FindPrimitive(const std::string &id, TPad *pad = nullptr, TObjLink **padlnk = nullptr, TPad **objpad = nullptr); public: TWebCanvas(TCanvas *c, const char *name, Int_t x, Int_t y, UInt_t width, UInt_t height, Bool_t readonly = kTRUE); virtual ~TWebCanvas() = default; void ShowWebWindow(const ROOT::Experimental::RWebDisplayArgs &user_args = ""); const std::shared_ptr &GetWebWindow() const { return fWindow; } virtual Bool_t IsReadOnly() const { return fReadOnly; } Int_t InitWindow() override; void Close() override; void Show() override; UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h) override; void ShowMenuBar(Bool_t show = kTRUE) override { ShowCmd("Menu", show); } void ShowStatusBar(Bool_t show = kTRUE) override { ShowCmd("StatusBar", show); } void ShowEditor(Bool_t show = kTRUE) override { ShowCmd("Editor", show); } void ShowToolBar(Bool_t show = kTRUE) override { ShowCmd("ToolBar", show); } void ShowToolTips(Bool_t show = kTRUE) override { ShowCmd("ToolTips", show); } // web-canvas specific methods void ActivateInEditor(TPad *pad, TObject *obj); void ForceUpdate() override; /* virtual void Iconify() { } virtual void SetStatusText(const char *text = 0, Int_t partidx = 0); virtual void SetWindowPosition(Int_t x, Int_t y); virtual void SetWindowSize(UInt_t w, UInt_t h); virtual void SetWindowTitle(const char *newTitle); virtual void SetCanvasSize(UInt_t w, UInt_t h); virtual void RaiseWindow(); virtual void ReallyDelete(); */ Bool_t HasEditor() const override; Bool_t HasMenuBar() const override; Bool_t HasStatusBar() const override; Bool_t HasToolBar() const override { return kFALSE; } Bool_t HasToolTips() const override; void SetUpdatedHandler(UpdatedSignal_t func) { fUpdatedSignal = func; } void SetActivePadChangedHandler(PadSignal_t func) { fActivePadChangedSignal = func; } void SetPadClickedHandler(PadClickedSignal_t func) { fPadClickedSignal = func; } void SetPadDblClickedHandler(PadClickedSignal_t func) { fPadDblClickedSignal = func; } void SetObjSelectHandler(ObjectSelectSignal_t func) { fObjSelectSignal = func; } void SetCanCreateObjects(Bool_t on = kTRUE) { fCanCreateObjects = on; } Bool_t GetCanCreateObjects() const { return fCanCreateObjects; } void SetStyleDelivery(Int_t val) { fStyleDelivery = val; } Int_t GetStyleDelivery() const { return fStyleDelivery; } void SetPaletteDelivery(Int_t val) { fPaletteDelivery = val; } Int_t GetPaletteDelivery() const { return fPaletteDelivery; } void SetPrimitivesMerge(Int_t cnt) { fPrimitivesMerge = cnt; } Int_t GetPrimitivesMerge() const { return fPrimitivesMerge; } void SetCustomScripts(const std::string &src); void AddCustomClass(const std::string &clname, bool with_derived = false); bool IsCustomClass(const TClass *cl) const; static TString CreateCanvasJSON(TCanvas *c, Int_t json_compression = 0); static Int_t StoreCanvasJSON(TCanvas *c, const char *filename, const char *option = ""); static bool ProduceImage(TCanvas *c, const char *filename, Int_t width = 0, Int_t height = 0); ClassDefOverride(TWebCanvas, 0) // Web-based implementation for TCanvasImp, read-only mode }; #endif