23#include <nlohmann/json.hpp>
42REveScene::REveScene(
const std::string&
n,
const std::string& t) :
83 auto pred = [&](std::unique_ptr<REveClient> &client) {
84 return client->fId ==
id;
100 throw eh +
"Element id and dictionary has to be defined";
145 nlohmann::json jarr = nlohmann::json::array();
147 nlohmann::json jhdr = {};
148 jhdr[
"content"] =
"REveScene::StreamElements";
152 jhdr[
"commands"] = nlohmann::json::array();
154 nlohmann::json jcmd = {};
155 jcmd[
"name"] = cmd.fName;
156 jcmd[
"icon"] = cmd.fIcon;
157 jcmd[
"elementid"] = cmd.fElementId;
158 jcmd[
"elementclass"] = cmd.fElementClass;
159 jcmd[
"func"] = cmd.fAction;
160 jhdr[
"commands"].push_back(jcmd);
164 jarr.push_back(jhdr);
190 nlohmann::json jobj = {};
192 jarr.push_back(jobj);
197 if (el->
fScene == el && el !=
this)
204 assert (rd_size % 4 == 0);
225 if (
c->GetMother() == el)
250 nlohmann::json jobj = {};
252 jobj[
"fElementId"] = el->GetElementId();
255 el->WriteTransJson(jobj);
275 nlohmann::json jarr = nlohmann::json::array();
277 nlohmann::json jhdr = {};
278 jhdr[
"content"] =
"ElementsRepresentaionChanges";
281 jhdr[
"removedElements"] = nlohmann::json::array();
283 jhdr[
"removedElements"].push_back(re);
291 UChar_t bits = el->GetChangeBits();
293 nlohmann::json jobj = {};
294 jobj[
"fElementId"] = el->GetElementId();
295 jobj[
"changeBit"] = bits;
301 Info(
"REveScene::StreamRepresentationChanges",
"new element change %s %d\n",
302 el->GetCName(), bits);
307 assert (rd_size % 4 == 0);
316 jobj[
"fRnrSelf"] = el->GetRnrSelf();
317 jobj[
"fRnrChildren"] = el->GetRnrChildren();
321 el->WriteCoreJson(jobj, -1);
325 el->WriteTransJson(jobj);
329 jarr.push_back(jobj);
350 nlohmann::json msg = { {
"header", jhdr}, {
"arr", jarr}};
355 Info(
"REveScene::StreamRepresentationChanges",
"class: %s changes %s ...",
GetCName(), msg.dump(1).c_str() );
364 printf(
" sending json, len = %d --> to conn_id = %d\n", (
int)
fOutputJson.size(), client->fId);
365 client->fWebWindow->Send(client->fId,
fOutputJson);
369 printf(
" sending binary, len = %d --> to conn_id = %d\n",
fTotalBinarySize, client->fId);
382 ::Info(
"REveScene::IsChanged",
"%s (changed_or_added=%d, removed=%d)",
GetCName(),
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
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
std::list< REveElement * > List_t
virtual void RemoveElement(REveElement *el)
Remove el from the list of children.
REveException Exception-type thrown by Eve classes.
REveSceneList * GetScenes() const
void SceneSubscriberWaitingResponse(unsigned cinnId)
REveViewerList * GetViewers() const
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
!
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
void StreamMotionChanges(nlohmann::json &arr)
Move every element whose only pending change is kCBTrans from the change list into arr,...
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 void AppendServerTime(std::string &msg)
Append "server_time" to the JSON message msg, a non-empty object or array: as its last key,...
static void StampServerTime(std::string &msg)
Set the "server_time" that AppendServerTime() put at the end of msg to now.
void SceneDestructing(REveScene *scene)
Callback done from a REveScene destructor allowing proper removal of the scene from affected viewers.
Namespace for ROOT features in testing.
R__EXTERN REveManager * gEve