Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TWebSnapshot.h
Go to the documentation of this file.
1// Author: Sergey Linev, GSI, 6/04/2017
2
3/*************************************************************************
4 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_TWebSnapshot
12#define ROOT_TWebSnapshot
13
14#include "TObject.h"
15
16#include <vector>
17#include <memory>
18#include <string>
19
20class TWebSnapshot : public TObject {
21
22protected:
23 std::string fObjectID; ///< object identifier
24 std::string fOption; ///< object draw option
25 Int_t fKind{0}; ///< kind of snapshots
26 TObject *fSnapshot{nullptr}; ///< snapshot data
27 Bool_t fOwner{kFALSE}; ///<! if objected owned
28
29 void SetKind(Int_t kind) { fKind = kind; }
30
31public:
32
33 enum {
34 kNone = 0, // dummy
35 kObject = 1, // object itself
36 kSVG = 2, // list of SVG primitives
37 kSubPad = 3, // subpad
38 kColors = 4, // list of ROOT colors + palette
39 kStyle = 5 // gStyle object
40 };
41
42 virtual ~TWebSnapshot();
43
44 void SetObjectIDAsPtr(void *ptr);
45 void SetObjectID(const std::string &id) { fObjectID = id; }
46 const char* GetObjectID() const { return fObjectID.c_str(); }
47
48 void SetOption(const std::string &opt) { fOption = opt; }
49
50 void SetSnapshot(Int_t kind, TObject *snapshot, Bool_t owner = kFALSE);
51 Int_t GetKind() const { return fKind; }
52 TObject *GetSnapshot() const { return fSnapshot; }
53
54 ClassDef(TWebSnapshot,1) // Object painting snapshot, used for JSROOT
55};
56
57// =================================================================================
58
60protected:
61 bool fActive{false}; ///< true when pad is active
62 bool fReadOnly{true}; ///< when canvas or pad are in readonly mode
63 std::vector<std::unique_ptr<TWebSnapshot>> fPrimitives; ///< list of all primitives, drawn in the pad
64
65public:
66 TPadWebSnapshot(bool readonly = true)
67 {
69 fReadOnly = readonly;
70 }
71
72 void SetActive(bool on = true) { fActive = on; }
73
74 bool IsReadOnly() const { return fReadOnly; }
75
76 TWebSnapshot &NewPrimitive(TObject *obj = nullptr, const std::string &opt = "");
77
79
81
82 ClassDef(TPadWebSnapshot, 1) // Pad painting snapshot, used for JSROOT
83};
84
85// =================================================================================
86
88protected:
89 Long64_t fVersion{0}; ///< actual canvas version
90 std::string fScripts; ///< custom scripts to load
91public:
92 TCanvasWebSnapshot() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
93 TCanvasWebSnapshot(bool readonly, Long64_t v) : TPadWebSnapshot(readonly), fVersion(v) {}
94
95 Long64_t GetVersion() const { return fVersion; }
96
97 void SetScripts(const std::string &src) { fScripts = src; }
98
99 ClassDef(TCanvasWebSnapshot, 1) // Canvas painting snapshot, used for JSROOT
100};
101
102
103#endif
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:101
bool Bool_t
Definition RtypesCore.h:63
long long Long64_t
Definition RtypesCore.h:80
#define ClassDef(name, id)
Definition Rtypes.h:325
XFontStruct * id
Definition TGX11.cxx:109
std::string fScripts
custom scripts to load
void SetScripts(const std::string &src)
Long64_t fVersion
actual canvas version
Long64_t GetVersion() const
TCanvasWebSnapshot(bool readonly, Long64_t v)
Mother of all ROOT objects.
Definition TObject.h:41
TPadWebSnapshot & NewSubPad()
Create new entry for subpad.
std::vector< std::unique_ptr< TWebSnapshot > > fPrimitives
list of all primitives, drawn in the pad
TWebSnapshot & NewSpecials()
Create new entry in list of primitives in the front.
bool fActive
true when pad is active
void SetActive(bool on=true)
TWebSnapshot & NewPrimitive(TObject *obj=nullptr, const std::string &opt="")
Create new entry in list of primitives.
bool fReadOnly
when canvas or pad are in readonly mode
TPadWebSnapshot(bool readonly=true)
bool IsReadOnly() const
Paint state of object to transfer to JavaScript side.
Bool_t fOwner
! if objected owned
void SetObjectIDAsPtr(void *ptr)
Use pointer to assign object id - TString::Hash.
void SetKind(Int_t kind)
virtual ~TWebSnapshot()
destructor
std::string fOption
object draw option
const char * GetObjectID() const
Int_t GetKind() const
Int_t fKind
kind of snapshots
void SetOption(const std::string &opt)
TObject * fSnapshot
snapshot data
void SetObjectID(const std::string &id)
void SetSnapshot(Int_t kind, TObject *snapshot, Bool_t owner=kFALSE)
SetUse pointer to assign object id - TString::Hash.
std::string fObjectID
object identifier
TObject * GetSnapshot() const