22#include <nlohmann/json.hpp>
54 REX::gEve->GetViewers()->SceneDestructing(
this);
55 REX::gEve->GetScenes()->RemoveElement(
this);
82 auto pred = [&](std::unique_ptr<REveClient> &client) {
83 return client->fId == id;
99 throw eh +
"Element id and dictionary has to be defined";
144 nlohmann::json jarr = nlohmann::json::array();
146 nlohmann::json jhdr = {};
147 jhdr[
"content"] =
"REveScene::StreamElements";
151 jhdr[
"commands"] = nlohmann::json::array();
153 nlohmann::json jcmd = {};
154 jcmd[
"name"] = cmd.fName;
155 jcmd[
"icon"] = cmd.fIcon;
156 jcmd[
"elementid"] = cmd.fElementId;
157 jcmd[
"elementclass"] = cmd.fElementClass;
158 jcmd[
"func"] = cmd.fAction;
159 jhdr[
"commands"].push_back(jcmd);
163 jarr.push_back(jhdr);
188 nlohmann::json jobj = {};
190 jarr.push_back(jobj);
195 if (el->
fScene == el && el !=
this)
202 assert (rd_size % 4 == 0);
223 if (
c->GetMother() == el)
241 nlohmann::json jarr = nlohmann::json::array();
243 nlohmann::json jhdr = {};
244 jhdr[
"content"] =
"ElementsRepresentaionChanges";
247 jhdr[
"removedElements"] = nlohmann::json::array();
249 jhdr[
"removedElements"].push_back(re);
257 UChar_t bits = el->GetChangeBits();
259 nlohmann::json jobj = {};
260 jobj[
"fElementId"] = el->GetElementId();
261 jobj[
"changeBit"] = bits;
267 Info(
"REveScene::StreamRepresentationChanges",
"new element change %s %d\n",
268 el->GetCName(), bits);
273 assert (rd_size % 4 == 0);
282 jobj[
"fRnrSelf"] = el->GetRnrSelf();
283 jobj[
"fRnrChildren"] = el->GetRnrChildren();
288 el->WriteCoreJson(jobj, -1);
296 jarr.push_back(jobj);
317 nlohmann::json msg = { {
"header", jhdr}, {
"arr", jarr}};
321 Info(
"REveScene::StreamRepresentationChanges",
"class: %s changes %s ...",
GetCName(), msg.dump(1).c_str() );
329 printf(
" sending json, len = %d --> to conn_id = %d\n", (
int)
fOutputJson.size(), client->fId);
330 client->fWebWindow->Send(client->fId,
fOutputJson);
334 printf(
" sending binary, len = %d --> to conn_id = %d\n",
fTotalBinarySize, client->fId);
337 REX::gEve->SceneSubscriberWaitingResponse(client->fId);
347 ::Info(
"REveScene::IsChanged",
"%s (changed_or_added=%d, removed=%d)",
GetCName(),
int Int_t
Signed integer 4 bytes (int).
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
bool Bool_t
Boolean (0=false, 1=true) (bool).
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
virtual void DestroyOrWarn()
Destroy this element. Prints a warning if deny-destroy is in force.
TClass * IsA() const
Return class for this element Return REveElement class in case dicitonary is not exisiting.
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
const char * GetCName() const
virtual void DestroyElements()
Destroy all children of this element.
void SetChildClass(TClass *c)
ElementId_t GetElementId() const
REveElement(const std::string &name="", const std::string &title="")
Default constructor.
REveException Exception-type thrown by Eve classes.
void EndAcceptingChanges()
REveSceneList(const REveSceneList &)=delete
void BeginAcceptingChanges()
Loop-wrapers over Scene children, element type checked on insertion.
void DestroyScenes()
Destroy all scenes and their contents.
std::vector< std::unique_ptr< REveClient > > fSubscribers
!
REveScene(const REveScene &)=delete
Bool_t HasSubscribers() const
void AddCommand(const std::string &name, const std::string &icon, const REveElement *element, const std::string &action)
void AddSubscriber(std::unique_ptr< REveClient > &&sub)
std::vector< char > fOutputBinary
!
~REveScene() override
Destructor.
Bool_t fAcceptingChanges
!
void SceneElementRemoved(ElementId_t id)
void StreamRepresentationChanges()
Prepare data for sending element changes.
void StreamJsonRecurse(REveElement *el, nlohmann::json &jobj)
std::vector< SceneCommand > fCommands
!
void SendChangesToSubscribers()
void BeginAcceptingChanges()
List_t fElsWithBinaryData
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
std::vector< ElementId_t > fRemovedElements
!
void SceneElementChanged(REveElement *element)
void EndAcceptingChanges()
void RemoveSubscriber(unsigned int)
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Namespace for ROOT features in testing.