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// clang++ <v20 (-Wshadow) complains about shadowing GuiTypes.h global variable kNone. Let's silence warning:
35#if defined(__clang__) && __clang_major__ < 20
36#pragma clang diagnostic push
37#pragma clang diagnostic ignored "-Wshadow"
38#endif
39 kNone = 0, ///< dummy
40#if defined(__clang__) && __clang_major__ < 20
41#pragma clang diagnostic pop
42#endif
43 kObject = 1, ///< object itself
44 kSVG = 2, ///< list of SVG primitives
45 kSubPad = 3, ///< subpad
46 kColors = 4, ///< list of ROOT colors + palette
47 kStyle = 5, ///< gStyle object
48 kFont = 6 ///< custom web font
49 };
50
51 ~TWebSnapshot() override;
52
53 void SetObjectIDAsPtr(void *ptr, const std::string &suffix = "");
54 void SetObjectID(const std::string &id) { fObjectID = id; }
55 const char* GetObjectID() const { return fObjectID.c_str(); }
56
57 void SetOption(const std::string &opt) { fOption = opt; }
58
59 void SetSnapshot(Int_t kind, TObject *snapshot, Bool_t owner = kFALSE);
60 Int_t GetKind() const { return fKind; }
61 TObject *GetSnapshot() const { return fSnapshot; }
62
63 ClassDefOverride(TWebSnapshot,1) // Object painting snapshot, used for JSROOT
64};
65
66// =================================================================================
67
69protected:
70 bool fActive{false}; ///< true when pad is active
71 bool fReadOnly{true}; ///< when canvas or pad are in readonly mode
72 bool fSetObjectIds{true}; ///<! set objects ids
73 bool fBatchMode{false}; ///<! if object created for image generation
74 bool fWithoutPrimitives{false}; ///< true when primitives not send while there are no modifications
75 bool fHasExecs{false}; ///< if true, more interactive events will be delivered from client
76 std::vector<std::unique_ptr<TWebSnapshot>> fPrimitives; ///< list of all primitives, drawn in the pad
77
78public:
79 TPadWebSnapshot(bool readonly = true, bool setids = true, bool batchmode = false)
80 {
85 }
86
87 void SetActive(bool on = true) { fActive = on; }
88
90
91 void SetHasExecs(bool on = true) { fHasExecs = on; }
92
93 bool IsReadOnly() const { return fReadOnly; }
94
95 bool IsSetObjectIds() const { return fSetObjectIds; }
96
97 bool IsBatchMode() const { return fBatchMode; }
98
99 TWebSnapshot &NewPrimitive(TObject *obj = nullptr, const std::string &opt = "", const std::string &suffix = "");
100
102
104
105 ClassDefOverride(TPadWebSnapshot, 3) // Pad painting snapshot, used for JSROOT
106};
107
108// =================================================================================
109
111protected:
112 std::string fScripts; ///< custom scripts to load
113 bool fHighlightConnect{false}; ///< does HighlightConnect has connection
114 bool fFixedSize{false}; ///< if canvas draw size is fixed
115public:
116 TCanvasWebSnapshot(bool readonly = true, bool setids = true, bool batchmode = false) : TPadWebSnapshot(readonly, setids, batchmode) {}
117
118 void SetScripts(const std::string &src) { fScripts = src; }
119 const std::string &GetScripts() const { return fScripts; }
120
122 bool GetHighlightConnect() const { return fHighlightConnect; }
123
124 void SetFixedSize(bool on = true) { fFixedSize = on; }
125 bool IsFixedSize() const { return fFixedSize; }
126
127 ClassDefOverride(TCanvasWebSnapshot, 4) // Canvas painting snapshot, used for JSROOT
128};
129
130
131#endif
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
std::string fScripts
custom scripts to load
bool fHighlightConnect
does HighlightConnect has connection
TCanvasWebSnapshot(bool readonly=true, bool setids=true, bool batchmode=false)
const std::string & GetScripts() const
void SetScripts(const std::string &src)
bool IsFixedSize() const
void SetFixedSize(bool on=true)
bool GetHighlightConnect() const
bool fFixedSize
if canvas draw size is fixed
void SetHighlightConnect(bool on=true)
Mother of all ROOT objects.
Definition TObject.h:42
TPadWebSnapshot & NewSubPad()
Create new entry for subpad.
TWebSnapshot & NewPrimitive(TObject *obj=nullptr, const std::string &opt="", const std::string &suffix="")
Create new entry in list of primitives.
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 fHasExecs
if true, more interactive events will be delivered from client
bool fActive
true when pad is active
void SetHasExecs(bool on=true)
void SetWithoutPrimitives(bool on=true)
TPadWebSnapshot(bool readonly=true, bool setids=true, bool batchmode=false)
bool fSetObjectIds
! set objects ids
void SetActive(bool on=true)
bool IsSetObjectIds() const
bool fReadOnly
when canvas or pad are in readonly mode
bool IsBatchMode() const
bool IsReadOnly() const
bool fBatchMode
! if object created for image generation
bool fWithoutPrimitives
true when primitives not send while there are no modifications
Paint state of object to transfer to JavaScript side.
Bool_t fOwner
! if objected owned
void SetKind(Int_t kind)
@ kStyle
gStyle object
@ kObject
object itself
@ kSVG
list of SVG primitives
@ kSubPad
subpad
@ kFont
custom web font
@ kColors
list of ROOT colors + palette
std::string fOption
object draw option
const char * GetObjectID() const
Int_t GetKind() const
Int_t fKind
kind of snapshots
~TWebSnapshot() override
destructor
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
void SetObjectIDAsPtr(void *ptr, const std::string &suffix="")
Use pointer to assign object id - TString::Hash.