From a742c2242238c76158d79576e24b31191800e856 Mon Sep 17 00:00:00 2001 From: Sergey Linev <S.Linev@gsi.de> Date: Tue, 2 Apr 2019 16:30:14 +0200 Subject: [PATCH] geom viewer: implement browsing in sub-folders Prepare for support of full model. Server should be able to send full description to avoid many simple transacations --- graf3d/eve7/src/REveGeomData.cxx | 31 ++++++++++++++++---- ui5/geom/controller/GeomViewer.controller.js | 18 +++++++----- ui5/geom/model/BrowserModel.js | 30 ++++++++++++++----- 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/graf3d/eve7/src/REveGeomData.cxx b/graf3d/eve7/src/REveGeomData.cxx index fa51d71e2d6..b9735790e1b 100644 --- a/graf3d/eve7/src/REveGeomData.cxx +++ b/graf3d/eve7/src/REveGeomData.cxx @@ -141,10 +141,35 @@ public: return false; } - bool Navigate(const std::string &) + /** Navigate to specified path. For now path should start from '/' */ + + bool Navigate(const std::string &path) { + size_t pos = path.find("/"); + if (pos != 0) return false; + Reset(); // set to the top of element + while (++pos < path.length()) { + auto last = pos; + + pos = path.find("/", last); + + if (pos == std::string::npos) pos = path.length(); + + std::string folder = path.substr(last, pos-last); + + if (!Enter()) return false; + + bool find = false; + + do { + find = (folder.compare(GetName()) == 0); + } while (!find && Next()); + + if (!find) return false; + } + return true; } @@ -544,12 +569,8 @@ std::string ROOT::Experimental::REveGeomDescription::ProcessBrowserRequest(const RBrowserRequest *request = nullptr; - printf("PROCESS BRREQ %s\n", msg.c_str()); - if (TBufferJSON::FromJSON(request, msg.c_str())) { - printf("DECODE BRREQ %s\n", request->path.c_str()); - RBrowserReply reply; reply.path = request->path; reply.first = request->first; diff --git a/ui5/geom/controller/GeomViewer.controller.js b/ui5/geom/controller/GeomViewer.controller.js index d5b9888a723..cd97bc43e1d 100644 --- a/ui5/geom/controller/GeomViewer.controller.js +++ b/ui5/geom/controller/GeomViewer.controller.js @@ -593,14 +593,17 @@ sap.ui.define(['sap/ui/core/Component', * later should be done differently */ parseDescription: function(msg, is_original) { - if (!this.plainModel) - return console.error('Not allowed to directly set hierarchy in such mode'); - var descr = JSON.parse(msg); - this.buildTree(descr, is_original); + if (this.plainModel) { + this.buildTree(descr, is_original); + this.byId("treeTable").expandToLevel(is_original ? 1 : 99); + } else { + var topnode = this.buildTreeNode(descr, [], 0); - this.byId("treeTable").expandToLevel(is_original ? 1 : 99); + this.model.setFullModel(topnode); + + } }, /** TO BE CHANGED !!! When single node element is modified on the server side */ @@ -661,10 +664,11 @@ sap.ui.define(['sap/ui/core/Component', if (node.chlds && (node.chlds.length>0)) { tnode.chlds = []; - for (var k=0;k<node.chlds.length;++k) + tnode.nchilds = node.chlds.length; + for (var k=0;k<tnode.nchilds;++k) tnode.chlds.push(this.buildTreeNode(nodes, cache, node.chlds[k])); } else { - tnode.end_node = true; + tnode.end_node = true; // TODO: no need for such flag } return tnode; diff --git a/ui5/geom/model/BrowserModel.js b/ui5/geom/model/BrowserModel.js index 28febe935ec..a687b884311 100644 --- a/ui5/geom/model/BrowserModel.js +++ b/ui5/geom/model/BrowserModel.js @@ -27,6 +27,22 @@ sap.ui.define([ this.threshold = 100; // default threshold to prefetch items }, + /* Method can be used when complete hierarchy is ready and can be used directly */ + setFullModel: function(topnode) { + this.fullModel = this.h = topnode; + if (this.oBinding) + this.oBinding.checkUpdate(true); + }, + + clearFullModel: function() { + this.h = { + name: "ROOT", + _expanded: true + }; + delete this.fullModel; + }, + + bindTree: function(sPath, oContext, aFilters, mParameters, aSorters) { Log.warning("root.model.hModel#bindTree() " + sPath); @@ -51,7 +67,7 @@ sap.ui.define([ if (!name) continue; for (var k=0;k<curr._childs.length;++k) { - if (curr._childs[k]._name == name) { + if (curr._childs[k].name == name) { curr = curr._childs[k]; find = true; break; @@ -75,7 +91,7 @@ sap.ui.define([ // now using simple HTTP requests, in ROOT websocket communication will be used submitRequest: function(elem, path, first, number) { - if (!this._websocket || elem._requested) return; + if (!this._websocket || elem._requested || this.fullModel) return; elem._requested = true; this.loadDataCounter++; @@ -88,7 +104,7 @@ sap.ui.define([ sort: this.sortOrder || "" }; - console.log('SEND BROWSER REQUEST ' + JSON.stringify(request)); + console.log('SEND BROWSER REQUEST ' + path); this._websocket.Send("BRREQ:" + JSON.stringify(request)); }, @@ -257,7 +273,7 @@ sap.ui.define([ } for (var k=0;k<elem._childs.length;++k) - scan(lvl+1, elem._childs[k], path + elem._childs[k]._name + "/"); + scan(lvl+1, elem._childs[k], path + elem._childs[k].name + "/"); // check if more elements are required @@ -285,7 +301,7 @@ sap.ui.define([ scan(0, this.h, "/"); if (this.getProperty("/length") != id) { - console.error('LENGTH MISMATCH', this.getProperty("/length"), id); + // console.error('LENGTH MISMATCH', this.getProperty("/length"), id); this.setProperty("/length", id); // update length property } @@ -303,7 +319,7 @@ sap.ui.define([ var elem = this.getElementByIndex(index); if (!elem) return; - console.log('Toggle element', elem._name) + console.log('Toggle element', elem.name) if (elem._expanded) { delete elem._expanded; @@ -315,7 +331,7 @@ sap.ui.define([ return true; - } else if (elem.type === "folder") { + } else if (elem.nchilds || (elem.index==0)) { elem._expanded = true; // structure is changing but not immediately -- GitLab