Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TWebSnapshot.cxx
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#include "TWebSnapshot.h"
12
13#include "TString.h"
14
15#include <memory>
16
17/** \class TWebSnapshot
18\ingroup webgui6
19
20Paint state of object to transfer to JavaScript side
21
22*/
23
24///////////////////////////////////////////////////////////////////////////////////////////
25/// destructor
26
28{
29 SetSnapshot(kNone, nullptr);
30}
31
32///////////////////////////////////////////////////////////////////////////////////////////
33/// SetUse pointer to assign object id - TString::Hash
34
35void TWebSnapshot::SetSnapshot(Int_t kind, TObject *snapshot, Bool_t owner)
36{
37 if (fSnapshot && fOwner) delete fSnapshot;
38 fKind = kind;
39 fSnapshot = snapshot;
40 fOwner = owner;
41}
42
43///////////////////////////////////////////////////////////////////////////////////////////
44/// Use pointer to assign object id - TString::Hash
45
46void TWebSnapshot::SetObjectIDAsPtr(void *ptr, const std::string &suffix)
47{
48 UInt_t hash = TString::Hash(&ptr, sizeof(ptr));
49 SetObjectID(std::to_string(hash) + suffix);
50}
51
52///////////////////////////////////////////////////////////////////////////////////////////
53/// Create new entry in list of primitives
54
55TWebSnapshot &TPadWebSnapshot::NewPrimitive(TObject *obj, const std::string &opt, const std::string &suffix)
56{
57 fPrimitives.emplace_back(std::make_unique<TWebSnapshot>());
58 if (obj) {
59 if (IsSetObjectIds())
60 fPrimitives.back()->SetObjectIDAsPtr(obj, suffix);
61 fPrimitives.back()->SetOption(opt);
62 }
63 return *(fPrimitives.back());
64}
65
66///////////////////////////////////////////////////////////////////////////////////////////
67/// Create new entry for subpad
68
70{
72 fPrimitives.emplace_back(res);
73 return *res;
74}
75
76///////////////////////////////////////////////////////////////////////////////////////////
77/// Create new entry in list of primitives in the front
78
80{
81 fPrimitives.emplace(fPrimitives.begin(), std::make_unique<TWebSnapshot>());
82 return *(fPrimitives.front());
83}
Mother of all ROOT objects.
Definition TObject.h:41
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 IsSetObjectIds() const
bool IsBatchMode() const
bool IsReadOnly() const
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition TString.cxx:677
Paint state of object to transfer to JavaScript side.
Bool_t fOwner
! if objected owned
Int_t fKind
kind of snapshots
~TWebSnapshot() override
destructor
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.
void SetObjectIDAsPtr(void *ptr, const std::string &suffix="")
Use pointer to assign object id - TString::Hash.