40REveScene::REveScene(
const std::string&
n,
const std::string& t) :
74 auto pred = [&](std::unique_ptr<REveClient> &client) {
75 return client->fId ==
id;
91 throw eh +
"Element id and dictionary has to be defined";
138 nlohmann::json jarr = nlohmann::json::array();
140 nlohmann::json jhdr = {};
141 jhdr[
"content"] =
"REveScene::StreamElements";
145 jhdr[
"commands"] = nlohmann::json::array();
147 nlohmann::json jcmd = {};
148 jcmd[
"name"] = cmd.fName;
149 jcmd[
"icon"] = cmd.fIcon;
150 jcmd[
"elementid"] = cmd.fElementId;
151 jcmd[
"elementclass"] = cmd.fElementClass;
152 jcmd[
"func"] = cmd.fAction;
153 jhdr[
"commands"].push_back(jcmd);
157 jarr.push_back(jhdr);
182 nlohmann::json jobj = {};
184 jarr.push_back(jobj);
189 if (el->
fScene == el && el !=
this)
196 assert (rd_size % 4 == 0);
217 if (
c->GetMother() == el)
238 nlohmann::json jarr = nlohmann::json::array();
240 nlohmann::json jhdr = {};
241 jhdr[
"content"] =
"ElementsRepresentaionChanges";
244 jhdr[
"removedElements"] = nlohmann::json::array();
246 jhdr[
"removedElements"].push_back(re);
254 UChar_t bits = el->GetChangeBits();
256 nlohmann::json jobj = {};
257 jobj[
"fElementId"] = el->GetElementId();
258 jobj[
"changeBit"] = bits;
264 Info(
"REveScene::StreamRepresentationChanges",
"new element change %s %d\n",
265 el->GetCName(), bits);
270 assert (rd_size % 4 == 0);
279 jobj[
"fRnrSelf"] = el->GetRnrSelf();
280 jobj[
"fRnrChildren"] = el->GetRnrChildren();
285 el->WriteCoreJson(jobj, -1);
293 jarr.push_back(jobj);
314 nlohmann::json msg = { {
"header", jhdr}, {
"arr", jarr}};
318 Info(
"REveScene::StreamRepresentationChanges",
"class: %s changes %s ...",
GetCName(), msg.dump(1).c_str() );
325 printf(
" sending json, len = %d --> to conn_id = %d\n", (
int)
fOutputJson.size(), client->fId);
326 client->fWebWindow->Send(client->fId,
fOutputJson);
329 printf(
" sending binary, len = %d --> to conn_id = %d\n",
fTotalBinarySize, client->fId);
338 ::Info(
"REveScene::IsChanged",
"%s (changed_or_added=%d, removed=%d)",
GetCName(),
349void REveScene::Repaint(Bool_t dropLogicals)
351 if (dropLogicals) fGLScene->SetSmartRefresh(kFALSE);
352 fGLScene->PadPaint(fPad);
353 if (dropLogicals) fGLScene->SetSmartRefresh(kTRUE);
356 // Hack to propagate selection state to physical shapes.
358 // Should actually be published in PadPaint() following a direct
359 // AddObject() call, but would need some other stuff for that.
360 // Optionally, this could be exported via the TAtt3D and everything
363 TGLScene::LogicalShapeMap_t& logs = fGLScene->RefLogicalShapes();
365 for (TGLScene::LogicalShapeMapIt_t li = logs.begin(); li != logs.end(); ++li)
367 elm = dynamic_cast<REveElement*>(li->first);
368 if (elm && li->second->Ref() == 1)
370 TGLPhysicalShape* pshp = const_cast<TGLPhysicalShape*>(li->second->GetFirstPhysical());
371 pshp->Select(elm->GetSelectedLevel());
375 // Fix positions for hierarchical scenes.
378 RetransHierarchically();
386void REveScene::RetransHierarchically()
388 fGLScene->BeginUpdate();
390 RetransHierarchicallyRecurse(this, RefMainTrans());
392 fGLScene->EndUpdate();
399void REveScene::RetransHierarchicallyRecurse(REveElement* el, const REveTrans& tp)
401 static const REveException eh("REveScene::RetransHierarchicallyRecurse ");
404 if (el->HasMainTrans())
405 t *= el->RefMainTrans();
407 if (el->GetRnrSelf() && el != this)
409 fGLScene->UpdatePhysioLogical(el->GetRenderObject(eh), t.Array(), 0);
412 if (el->GetRnrChildren())
414 for (auto &c: el->RefChildren())
416 if (c->GetRnrAnything())
417 RetransHierarchicallyRecurse(c, t);
428void REveScene::Paint(Option_t* option)
432 for (auto &c: fChildren)
434 // c->PadPaint(option);
443void REveScene::DestroyElementRenderers(REveElement* element)
445 static const REveException eh("REveScene::DestroyElementRenderers ");
447 fGLScene->BeginUpdate();
448 Bool_t changed = fGLScene->DestroyLogical(element->GetRenderObject(eh), kFALSE);
449 fGLScene->EndUpdate(changed, changed);
456void REveScene::DestroyElementRenderers(TObject* rnrObj)
458 fGLScene->BeginUpdate();
459 Bool_t changed = fGLScene->DestroyLogical(rnrObj, kFALSE);
460 fGLScene->EndUpdate(changed, changed);
512void REveSceneList::RepaintChangedScenes(Bool_t dropLogicals)
514 for (auto &c: fChildren)
516 REveScene* s = (REveScene*) c;
519 s->Repaint(dropLogicals);
527void REveSceneList::RepaintAllScenes(Bool_t dropLogicals)
529 for (auto &c: fChildren)
531 ((REveScene *)c)->Repaint(dropLogicals);
538void REveSceneList::DestroyElementRenderers(REveElement* element)
540 static const REveException eh("REveSceneList::DestroyElementRenderers ");
542 TObject* obj = element->GetRenderObject(eh);
543 for (auto &c: fChildren)
545 ((REveScene *)c)->DestroyElementRenderers(obj);
560 ::Info(
"REveSceneList::ProcessSceneChanges",
"processing");
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.
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
virtual void RemoveElement(REveElement *el)
Remove el from the list of children.
REveException Exception-type thrown by Eve classes.
REveSceneList * GetScenes() const
REveViewerList * GetViewers() const
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 AddCommand(const std::string &name, const std::string &icon, const REveElement *element, const std::string &action)
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)
void SceneDestructing(REveScene *scene)
Callback done from a REveScene destructor allowing proper removal of the scene from affected viewers.
R__EXTERN REveManager * gEve