Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions etc/eve7/EveManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,16 @@
}
}

EveManager.prototype.ProcessModified = function() {
for (var id in this.map) {
var elem = this.map[id];
if (!elem || !elem.$modified) continue;

for (var k=0;k<elem.$receivers.length;++k) {
var f = elem.$receivers[k];
f.obj[f.func](id, elem);
}
EveManager.prototype.ProcessModified = function(sceneid) {
var elem = this.map[sceneid];
if (!elem || !elem.$modified) return;

delete elem.$modified;
for (var k=0;k<elem.$receivers.length;++k) {
var f = elem.$receivers[k];
f.obj[f.func](sceneid, elem);
}

delete elem.$modified;
}

EveManager.prototype.ProcessData = function(arr) {
Expand Down Expand Up @@ -169,6 +167,14 @@

this.MarkModified(elem.fElementId);
}

if (arr[0].fTotalBinarySize == 0) {
console.log("scenemodified ", this.map[arr[0].fSceneId])
this.ProcessModified(arr[0].fSceneId);
}

// temporar workaround until implementing window manager
sap.ui.getCore().byId("TopEveId").getController().configureToolBar();
}

EveManager.prototype.SceneChanged = function(msg) {
Expand Down Expand Up @@ -297,6 +303,7 @@
}
this.DeleteChildsOf(element);
element.$modified = true;
this.ProcessModified(ids[n]);
}
}

Expand Down Expand Up @@ -353,7 +360,10 @@
if (lastoff !== rawdata.byteLength)
console.error('Raw data decoding error - length mismatch', lastoff, rawdata.byteLength);

if (this.scene_changes) this.PostProcessSceneChanges();
if (this.scene_changes)
this.PostProcessSceneChanges();
else
this.ProcessModified(arr[0].fSceneId);
}

EveManager.prototype.CanEdit = function(elem) {
Expand Down
2 changes: 1 addition & 1 deletion etc/eve7/GL.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ sap.ui.define([
var scene = element.childs[k];
if (!scene) { allok = false; break; }
var realscene = this.mgr.GetElement(scene.fSceneId);
if (!realscene || !realscene.childs) { allok = false; break; }
if (!realscene || !realscene.childs) { continue; }
}

if (allok) this.drawGeometry();
Expand Down
22 changes: 15 additions & 7 deletions etc/eve7/Main.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,19 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
// msg.byteLength, 'offset', offset);
this.mgr.UpdateBinary(msg, offset);

this.mgr.ProcessModified();

return;
}

console.log("msg len=", msg.length, " txt:", msg.substr(0,50), "...");

if (msg == "$$nullbinary$$")
return;

var resp = JSON.parse(msg);

if (resp && resp[0] && resp[0].content == "TEveManager::DestroyElementsOf") {

this.mgr.DestroyElements(resp);

this.mgr.ProcessModified();

this.getView().byId("Summary").getController().UpdateMgr(this.mgr);

} else if (resp && resp[0] && resp[0].content == "TEveScene::StreamElements") {
Expand All @@ -58,7 +56,7 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
for (var n=0;n<viewers.length;++n) {
if (viewers[n].$view_created || viewers[n].$view_staged) continue;
viewers[n].$view_staged = true; // mark view which will be created in this loop
total_count++;
if (viewers[n].fRnrSelf) total_count++;
}

if (total_count == 0) return;
Expand All @@ -70,7 +68,7 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
for (var n=0;n<viewers.length;++n) {
var elem = viewers[n];
var viewid = "EveViewer" + elem.fElementId;
if (elem.$view_created) continue;
if (elem.$view_created || !viewers[n].fRnrSelf) continue;

// create missing view
elem.$view_created = true;
Expand Down Expand Up @@ -167,6 +165,16 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
}
},

configureToolBar() {
var top = this.mgr.childs[0].childs;
for (var i = 0; i < top.length; i++) {
if (top[i]._typename === "EventManager") {
console.log("toolbar id", this.byId("newEvent"));
this.byId("newEvent").setVisible(true);
}
}
},

showHelp : function(oEvent) {
alert("User support: root-webgui@cern.ch");
}
Expand Down
4 changes: 2 additions & 2 deletions etc/eve7/Main.view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
showSubHeader="false" id="CanvasMainPage">
<headerContent>
<OverflowToolbar id="otb1">
<Button icon="sap-icon://step" type="Transparent"
tooltip="New event" press="newEvent" />
<Button id="newEvent" icon="sap-icon://step" type="Transparent"
tooltip="New event" press="newEvent" visible="false "/>
<!--
<Button icon="sap-icon://user-edit" type="Transparent"
tooltip="Toggle GED editor" press="toggleGedEditor" enabled="false" />
Expand Down
6 changes: 3 additions & 3 deletions graf3d/eve7/src/TEveDataClasses.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void TEveDataCollection::SetFilterExpr(const TString& filter)
fItemClass->GetName(), &fFilterFoo, fItemClass->GetName(), fItemClass->GetName(),
fFilterExpr.Data());

printf("%s\n", s.Data());
// printf("%s\n", s.Data());
try {
gROOT->ProcessLine(s.Data());
}
Expand All @@ -59,7 +59,7 @@ void TEveDataCollection::ApplyFilter()
{
bool res = fFilterFoo(ii.fDataPtr);

printf("Item:%s -- filter result = %d\n", ii.fItemPtr->GetElementName(), res);
// printf("Item:%s -- filter result = %d\n", ii.fItemPtr->GetElementName(), res);

ii.fItemPtr->SetFiltered( ! res );
}
Expand Down Expand Up @@ -201,7 +201,7 @@ void TEveDataColumn::SetExpressionAndType(const TString& expr, FieldType_e type)
rtyp, icls->GetName(), fooptr, icls->GetName(), icls->GetName(),
fExpression.Data());

printf("%s\n", s.Data());
// printf("%s\n", s.Data());
try {
gROOT->ProcessLine(s.Data());
}
Expand Down
122 changes: 20 additions & 102 deletions tutorials/eve7/points.C
Original file line number Diff line number Diff line change
@@ -1,116 +1,34 @@
/// \file
/// \ingroup tutorial_http
/// This program creates and fills one and two dimensional histogram
/// Macro used to demonstrate usage of custom HTML page in custom.htm
/// One can use plain JavaScript to assign different actions with HTML buttons
///
/// \macro_code
///

#include <vector>
#include <string>

#include "TBufferJSON.h"
#include "TROOT.h"
#include "TFile.h"
#include "TRandom.h"
#include "TSystem.h"

#include <ROOT/TWebWindowsManager.hxx>
#include <ROOT/TEveGeoShapeExtract.hxx>
#include <ROOT/TEveGeoShape.hxx>
#include <ROOT/TEveElement.hxx>
#include <ROOT/TEveScene.hxx>
#include <ROOT/TEveManager.hxx>
#include <ROOT/TEvePointSet.hxx>

namespace REX = ROOT::Experimental;

class WHandler {
private:
std::shared_ptr<REX::TWebWindow> fWindow;
unsigned fConnId{0};

public:
WHandler() {};

virtual ~WHandler() { printf("Destructor!!!!\n"); }

void ProcessData(unsigned connid, const std::string &arg)
{
if (arg == "CONN_READY") {
fConnId = connid;
printf("connection established %u\n", fConnId);
fWindow->Send("INITDONE", fConnId);
{
// send geometry
TFile* geom = TFile::Open("http://amraktad.web.cern.ch/amraktad/root/fake7geo.root", "CACHEREAD");
if (!geom)
return;
auto gse = (REX::TEveGeoShapeExtract*) geom->Get("Extract");
auto gentle_geom = REX::TEveGeoShape::ImportShapeExtract(gse, 0);
geom->Close();
delete geom;
TString json = TBufferJSON::ConvertToJSON(gse, gROOT->GetClass("REX::TEveGeoShapeExtract"));
fWindow->Send(std::string("GEO:") + json.Data(), fConnId);
}
{
// send points
TList* list = new TList();
int npoints = 200;
float s=100;
TRandom r(0);
auto ps = new REX::TEvePointSet("Points");
for (Int_t i=0; i<npoints; ++i)
ps->SetNextPoint(r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s));
ps->SetMarkerColor(TMath::Nint(r.Uniform(2, 9)));
list->Add(ps);
TString json = TBufferJSON::ConvertToJSON(list);
fWindow->Send(std::string("EXT:") + json.Data(), fConnId);
}
return;
}

if (arg == "CONN_CLOSED") {
printf("connection closed\n");
fConnId = 0;
return;
}

printf("Get msg %s \n", arg.c_str());
}

void InitWebWindow(bool mapNewWindow)
{
fWindow = REX::TWebWindowsManager::Instance()->CreateWindow(gROOT->IsBatch());

// this is very important, it defines name of openui5 widget, which
// will run on the client side
fWindow->SetPanelName("localapp.view.TestPanelGL");

// this is call-back, invoked when message received via websocket
fWindow->SetDataCallBack([this](unsigned connid, const std::string &arg) { ProcessData(connid, arg); });

fWindow->SetGeometry(300, 300); // configure predefined geometry
REX::TEvePointSet* getPointSet(int npoints = 2, float s=2, int color=28)
{
TRandom &r = *gRandom;

fWindow->SetConnLimit(100);
REX::TEvePointSet* ps = new REX::TEvePointSet("MyTestPoints", npoints);

if (mapNewWindow) {
fWindow->Show("");
}
else {
// instead showing of window just generate URL, which can be copied into the browser
std::string url = fWindow->GetUrl(true);
printf("URL: %s\n", url.c_str());
}
for (Int_t i=0; i<npoints; ++i) {
ps->SetNextPoint(r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s));
}
};


WHandler* handler = nullptr;

ps->SetMarkerColor(color);
ps->SetMarkerSize(3+r.Uniform(1, 2));
ps->SetMarkerStyle(4);
return ps;
}

void points(bool mapNewWindow = true)
{
gSystem->Load("libROOTEve");
REX::TEveManager::Create();
handler = new WHandler();
handler->InitWebWindow(mapNewWindow);
gSystem->Load("libROOTEve");
auto eveMng = REX::TEveManager::Create();

REX::TEveElement* event = eveMng->GetEventScene();
auto ps = getPointSet(100);
event->AddElement(ps);
}
Loading