Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mofidications in TBufferXML/SQL/JSON and TXMLFile classes #37

Closed
wants to merge 8 commits into from
60 changes: 48 additions & 12 deletions etc/http/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,63 @@ This is further development of JSRootIO, original version was download from
https://root.cern.ch/svn/root/trunk/js

At its current state code is very differ from original
project of Bertrand Bellenot, but provides at most similar functionality.
project of Bertrand Bellenot, but provides same functionality in default mode.
Main motivation for changes - fix different errors,
make JavaScript code more flexible and applicable for online environment.

October 2014:
1. Add "shortcut icon"
2. Add demo of online THttpServer - shell script copies data from
running httpserver.C macro on Apache webserver
3. Evaluate 'monitoring' parameter for online server like:
http://localhost:8080/?monitoring=1000.
Parameter defines how often displayed objects should be updated.
4. Implement 'opt' and 'opts' URL parameters for main page.
5. Show progress with scripts loading in the browser window
6. When one appends "+" to the filename, its content read completely with first I/O operation.
7. Implement JS custom streamer for TCanvas, restore aspect ratio when drawing
8. Major redesign of drawing classes. Resize and update of TCanvas are implemented.
All major draw functions working with HTML element id as first argument.
9. Extract 3D drawings into separate JSRoot3DPainter.js script
10.Use newest three.min.js (r68) for 3D drawings, solves problem with Firefox.
11.Introduce generic list of draw functions for all supported classes.
12.Add possibility to 'expand' normal objects in the hierarchy browser.
For instance, this gives access to single elements of canvas,
when whole canvas cannot be drawn.
13.Correct usage of colors map, provided with TCanvas.
14.Introduce JSROOT.redraw() function which is capable to create or update object drawing.
15.In main index.htm page browser can be disabled (nobrowser parameter) and
page can be used to display only specified items from the file

September 2014:
1. First try to handle resize of canvas in the browser, for the
moment works only with collapsible layout
1. First try to handle resize of the browser,
for the moment works only with collapsible layout
2. Also first try to interactively move separation line between
browser and drawing field.
3. Small fix of minor ticks drawing on the axis
4. Introduce display class for MDI drawing. Provide two implementations -
'collapsible' for old kind and 'tabs' for new kinds.
5. Adjust size of color palette drawing when labels would take more place as provided.
6. Add correct filling of statistic for TProfile, fix small problem with underflow/overflow bins.
6. Add correct filling of statistic for TProfile,
fix small problem with underflow/overflow bins.
7. Provide way to select display kind ('collapsible', 'tabs') in the simple GUI.

8. Implement 'grid' display, one could specify any number of devision like
'grid 3x3' or 'grid 4x2'.
9. MDI display object created at the moment when first draw is performed.
10.Introduce painter class for TCanvas, support resize and update of canvas drawing
11.Resize almost works for all layouts and all objects kinds.
12.Implement JSROOT.GetUrlOption to extract options from document URL.
13.Provide example fileitem.htm how read and display item from ROOT file.
14.In default index.htm page one could specify 'file', 'layout',
'item' and 'items' parameters like:
http://root.cern.ch/js/3.0/index.htm?file=files/hsimple.root&layout=grid5x5&item=hpx;1
15.Support direct reading of objects from sub-sub-directories.
16.Introduce demo.htm, which demonstrates online usage of JSROOT.
17.One could use demo.htm directly with THttpServer providing address like:
http://localhost:8080/jsrootsys/demo/demo.htm?addr=../../Files/job1.root/hpx/root.json.gz&layout=3x3
18.Also for online server process url options like 'item', 'items', 'layout'
19.Possibility to generate URL, which reproduces opened page with layout and drawn items


August 2014:
1. All communication between server and browser done with JSON format.
Expand Down Expand Up @@ -67,10 +108,12 @@ July 2014:
5. Example with direct usage of JSRootIO graphics
6. Example of inserting ROOT graphics from THttpServer into <iframe></iframe>


May 2014:
1. This JSRootIO code together with THttpServer class included
in ROOT repository


March 2014:
1. Introduce JSROOT.TBuffer class, which plays similar role
as TBuffer in native ROOT I/O. Simplifies I/O logic,
Expand All @@ -91,10 +134,3 @@ March 2014:
basic data types, arrays of basic data types, TString, TArray classes.
Also any object as data member can be streamed.
8. TRootSniffer do not creates sublevels for base classes


To do:
1. Redraw of canvas do not work at all.
3. In JSROOT.R__unzip buffers bigger than 16 MB (0xfffffff) are not
treated correctly. In TKey.cxx, lines 259-275, big raw buffer cutted on blocks of 16MB.

41 changes: 41 additions & 0 deletions etc/http/demo/demo.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// macro used to generate several JSON files,
// used to demonstrate online features of JSROOT
// Files used in demo.htm page.
// In real application JSON data could be produced by THttpServer on-the-fly

void demo() {

TH1I* h1 = new TH1I("histo1","histo title", 100, 0., 100.);
// h1->FillRandom("gaus",10000);

TCanvas *c1 = new TCanvas("c1","Dynamic Filling Example",200,10,700,500);

for (int n=0;n<20;n++) {
double ampl1 = 15000 + 10000 * cos(n/20.*2.*TMath::Pi());
double ampl2 = 15000 + 10000 * sin(n/20.*2.*TMath::Pi());

h1->Reset();

for (int cnt=0;cnt<ampl1;cnt++)
h1->Fill(gRandom->Gaus(25,10));

for (int cnt=0;cnt<ampl2;cnt++)
h1->Fill(gRandom->Gaus(75,10));

if (n==0) h1->Draw();
c1->Modified();
c1->Update();

TString json = TBufferJSON::ConvertToJSON(h1);

FILE* f = fopen(Form("root%d.json",n), "w");
fputs(json.Data(),f);
fclose(f);

// gSystem->Exec(Form("gzip root%d.json",n));

}



}
77 changes: 77 additions & 0 deletions etc/http/demo/demo.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="X-UA-Compatible" content="IE=Edge; text/html">

<title>Demonstrator of online usage of JSROOT</title>

<script src="../scripts/JSRootCore.js" type="text/javascript"></script>

<script type='text/javascript'>

var painter = null;
var mdi = null;
var cnt = 0;
var drawopt = null;
var addr = null;

function updateGUI() {

// here set of generated json files are used
// One could specify addres of running THttpServer like http://localhost:8080/Canvases/c1/root.json.gz?compact=3
// Or one can create root.json file in the application and place it on the webserver
// "dummy=xxxx" parameter used to prevent browser cashing
// To run demo, one should generate rootXX.json files using demo.C macro

var request_addr = "root" + (cnt%20) + ".json?dummy=" + cnt;
cnt++;

if (addr!=null) request_addr = addr;

var req = JSROOT.NewHttpRequest(request_addr, 'object', function(histo) {
if (!histo) {
if (!painter && !mdi) $('#drawing').append("<h3>Can not get " + request_addr + " from the server</h3>");
return;
}

if (mdi!=null) {
mdi.Draw('abstract_item_name_' + cnt, histo, drawopt);
} else {
painter = JSROOT.redraw('drawing', histo, drawopt);
}
});

req.send(null);
}

function startGUI() {
$('html').css('height','100%');
$('body').css('min-height','100%').css('margin','0px').css("overflow", "hidden");

var monitor = JSROOT.GetUrlOption("monitoring");
if ((monitor == "") || (monitor==null))
monitor = 1000;
else
monitor = parseInt(monitor);

drawopt = JSROOT.GetUrlOption("opt");

addr = JSROOT.GetUrlOption("addr");

var layout = JSROOT.GetUrlOption("layout");
if (layout!=null) mdi = new JSROOT.GridDisplay('drawing', layout);

setInterval(updateGUI, monitor);

JSROOT.RegisterForResize(function() { if (painter) painter.CheckResize(); if (mdi) mdi.CheckResize(); });
}
</script>

</head>

<body onload="JSROOT.AssertPrerequisites('2d', startGUI)">
<div id="drawing" style="position:absolute; left:1px; top:1px; bottom:1px; right:1px"></div>
</body>
</html>

59 changes: 59 additions & 0 deletions etc/http/demo/demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Script used to produce number of html/json/xml files, which emulates behaviour of THttpServer
# before script is running, one should run tutorials/http/httpserver.C macro on the same machine
# macro starts http server with address http://localhost:8080
# This script will create number of files, which could be later copied on the web server to demonstrate
# functionality of THttpServer without need to run server itself. Of course, one should understand that
# objects content will not change on such static server

server=http://localhost:8080

rm -rf index.htm h.xml h.json StreamerInfo Canvases Files

# par1 - 0 - only hierarchy, 1 - only drawing, 2 - both
# par2 - path

function grab {
sedarg='s/\/jsrootsys/..'
number=$(grep -o "\/" <<< "$2" | wc -l)
for (( i=0; i<=$number; i++ ))
do
sedarg+='\/..'
done
sedarg+='/g'

mkdir -p $2

if [ "$1" != "1" ]; then
sed $sedarg ../files/online.htm > $2/index.htm
wget -nv $server/$2/h.json -O $2/h.json
wget -nv $server/$2/h.xml -O $2/h.xml
fi

if [ "$1" != "0" ]; then
wget -nv $server/$2/root.json.gz?compact=3 -O $2/root.json.gz
wget -nv "$server/$2/root.png?w=400&h=300" -O $2/root.png
sed $sedarg ../files/draw.htm > $2/draw.htm
fi

}

sed 's/\/jsrootsys/../g' ../files/online.htm > index.htm
wget -nv $server/h.xml -O h.xml
wget -nv $server/h.json -O h.json
mkdir -p StreamerInfo; wget -nv $server/StreamerInfo/root.json.gz?compact=3 -O StreamerInfo/root.json.gz

grab 0 Files
grab 0 Files/job1.root
grab 2 Files/job1.root/hpx
grab 2 Files/job1.root/hpxpy
grab 2 Files/job1.root/hprof

grab 0 Canvases
grab 2 Canvases/c1
grab 0 Canvases/c1/fPrimitives
grab 2 Canvases/c1/fPrimitives/hpx

# copy all files to web server
# cp -rf index.htm h.xml h.json StreamerInfo Canvases Files /your/web_files/locations
47 changes: 45 additions & 2 deletions etc/http/files/draw.htm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,51 @@
<script type="text/javascript" src="/jsrootsys/scripts/JSRootCore.js"></script>
</head>

<body onload="JSROOT.BuildSimpleGUI('2d')">
<div id="drawGUI" style="position:absolute; left:5px; top:5px; bottom:5px; right:5px"></div>
<script type='text/javascript'>

function CreateDrawGui() {
// analyze URL options
var drawopt = JSROOT.GetUrlOption("opt");

var monitor = JSROOT.GetUrlOption("monitoring");
if (monitor == "") monitor = 3000; else
if (monitor != null) monitor = parseInt(monitor);

var objpainter = null;

function drawfunction() {

var req = JSROOT.NewHttpRequest("root.json.gz?compact=3", 'text', function(result) {
var obj = JSROOT.parse(result);
if (!obj) {
if (!objpainter) $('#drawing').append("<h3>Can not get object from the server</h3>");
return;
}

document.body.style.cursor = 'wait';
objpainter = JSROOT.redraw('drawing', obj, drawopt);
document.body.style.cursor = 'auto';

});

// submit request
req.send(null);
}

drawfunction();

if (monitor!=null)
setInterval(drawfunction, monitor);

JSROOT.RegisterForResize(function() { if (objpainter) objpainter.CheckResize(); });
}

</script>

<body onload="JSROOT.AssertPrerequisites('2d', CreateDrawGui, 'drawing')">
<div id="drawing" style="position:absolute; left:1px; top:1px; bottom:1px; right:1px">
loading scripts...
</div>
</body>

</html>
Loading