76 auto pred = [&](std::unique_ptr<REveClient> &client) {
77 return client->fId ==
id;
129 jhdr[
"content"] =
"REveScene::StreamElements";
133 jhdr[
"commands"] = nlohmann::json::array();
136 jcmd[
"name"] = cmd.fName;
137 jcmd[
"icon"] = cmd.fIcon;
138 jcmd[
"elementid"] = cmd.fElementId;
139 jcmd[
"elementclass"] = cmd.fElementClass;
140 jcmd[
"func"] = cmd.fAction;
141 jhdr[
"commands"].push_back(jcmd);
145 jarr.push_back(jhdr);
172 jarr.push_back(jobj);
177 if (el->
fScene == el && el !=
this)
184 assert (rd_size % 4 == 0);
205 if (
c->GetMother() == el)
229 jhdr[
"content"] =
"ElementsRepresentaionChanges";
232 jhdr[
"removedElements"] = nlohmann::json::array();
234 jhdr[
"removedElements"].push_back(re);
242 UChar_t bits = el->GetChangeBits();
245 jobj[
"fElementId"] = el->GetElementId();
246 jobj[
"changeBit"] = bits;
252 Info(
"REveScene::StreamRepresentationChanges",
"new element change %s %d\n",
253 el->GetCName(), bits);
258 assert (rd_size % 4 == 0);
267 jobj[
"fRnrSelf"] = el->GetRnrSelf();
268 jobj[
"fRnrChildren"] = el->GetRnrChildren();
273 el->WriteCoreJson(jobj, -1);
281 jarr.push_back(jobj);
306 Info(
"REveScene::StreamRepresentationChanges",
"class: %s changes %s ...",
GetCName(), msg.dump(1).c_str() );
313 printf(
" sending json, len = %d --> to conn_id = %d\n", (
int)
fOutputJson.size(), client->fId);
314 client->fWebWindow->Send(client->fId,
fOutputJson);
317 printf(
" sending binary, len = %d --> to conn_id = %d\n",
fTotalBinarySize, client->fId);
326 ::Info(
"REveScene::IsChanged",
"%s (changed_or_added=%d, removed=%d)",
GetCName(),
337void REveScene::Repaint(Bool_t dropLogicals)
339 if (dropLogicals) fGLScene->SetSmartRefresh(kFALSE);
340 fGLScene->PadPaint(fPad);
341 if (dropLogicals) fGLScene->SetSmartRefresh(kTRUE);
344 // Hack to propagate selection state to physical shapes.
346 // Should actually be published in PadPaint() following a direct
347 // AddObject() call, but would need some other stuff for that.
348 // Optionally, this could be exported via the TAtt3D and everything
351 TGLScene::LogicalShapeMap_t& logs = fGLScene->RefLogicalShapes();
353 for (TGLScene::LogicalShapeMapIt_t li = logs.begin(); li != logs.end(); ++li)
355 elm = dynamic_cast<REveElement*>(li->first);
356 if (elm && li->second->Ref() == 1)
358 TGLPhysicalShape* pshp = const_cast<TGLPhysicalShape*>(li->second->GetFirstPhysical());
359 pshp->Select(elm->GetSelectedLevel());
363 // Fix positions for hierarchical scenes.
366 RetransHierarchically();
374void REveScene::RetransHierarchically()
376 fGLScene->BeginUpdate();
378 RetransHierarchicallyRecurse(this, RefMainTrans());
380 fGLScene->EndUpdate();
387void REveScene::RetransHierarchicallyRecurse(REveElement* el, const REveTrans& tp)
389 static const REveException eh("REveScene::RetransHierarchicallyRecurse ");
392 if (el->HasMainTrans())
393 t *= el->RefMainTrans();
395 if (el->GetRnrSelf() && el != this)
397 fGLScene->UpdatePhysioLogical(el->GetRenderObject(eh), t.Array(), 0);
400 if (el->GetRnrChildren())
402 for (auto &c: el->RefChildren())
404 if (c->GetRnrAnything())
405 RetransHierarchicallyRecurse(c, t);
416void REveScene::Paint(Option_t* option)
420 for (auto &c: fChildren)
422 // c->PadPaint(option);
431void REveScene::DestroyElementRenderers(REveElement* element)
433 static const REveException eh("REveScene::DestroyElementRenderers ");
435 fGLScene->BeginUpdate();
436 Bool_t changed = fGLScene->DestroyLogical(element->GetRenderObject(eh), kFALSE);
437 fGLScene->EndUpdate(changed, changed);
444void REveScene::DestroyElementRenderers(TObject* rnrObj)
446 fGLScene->BeginUpdate();
447 Bool_t changed = fGLScene->DestroyLogical(rnrObj, kFALSE);
448 fGLScene->EndUpdate(changed, changed);
477 s->DestroyElements();
491 s->BeginAcceptingChanges();
493 s->EndAcceptingChanges();
500void REveSceneList::RepaintChangedScenes(Bool_t dropLogicals)
502 for (auto &c: fChildren)
504 REveScene* s = (REveScene*) c;
507 s->Repaint(dropLogicals);
515void REveSceneList::RepaintAllScenes(Bool_t dropLogicals)
517 for (auto &c: fChildren)
519 ((REveScene *)c)->Repaint(dropLogicals);
526void REveSceneList::DestroyElementRenderers(REveElement* element)
528 static const REveException eh("REveSceneList::DestroyElementRenderers ");
530 TObject* obj = element->GetRenderObject(eh);
531 for (auto &c: fChildren)
533 ((REveScene *)c)->DestroyElementRenderers(obj);
548 ::Info(
"REveSceneList::ProcessSceneChanges",
"processing");
void Info(const char *location, const char *msgfmt,...)
R__EXTERN TEveManager * gEve
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
const char * GetCName() const
void SetChildClass(TClass *c)
REveSceneList(const REveSceneList &)=delete
void ProcessSceneChanges()
void DestroyScenes()
Destroy all scenes and their contents.
void AcceptChanges(bool)
Set accept changes flag on all scenes.
std::vector< std::unique_ptr< REveClient > > fSubscribers
!
Bool_t HasSubscribers() const
void AddSubscriber(std::unique_ptr< REveClient > &&sub)
virtual ~REveScene()
Destructor.
std::vector< char > fOutputBinary
!
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
std::vector< ElementId_t > fRemovedElements
!
void SceneElementChanged(REveElement *element)
void EndAcceptingChanges()
void RemoveSubscriber(unsigned int)
virtual void RemoveElement(TEveElement *el)
Remove el from the list of children.
TEveViewerList * GetViewers() const
TEveSceneList * GetScenes() const
void SceneDestructing(TEveScene *scene)
Callback done from a TEveScene destructor allowing proper removal of the scene from affected viewers.
static constexpr double s
basic_json<> json
default JSON class