diff --git a/js/changes.md b/js/changes.md index e0c747e59f245a52c27bfb3ddfae921a16435e56..d17c755b05886460684019a1c63d8a289db0abee 100644 --- a/js/changes.md +++ b/js/changes.md @@ -15,6 +15,7 @@ 12. Provide wrong_http_response workaround (#189) 13. Improve "comp" and "compx" option to show TGeoCompositeShape components 14. Update objects from list of histogram functions (#190) +15. Add support of TGeo in TCanvas ## Changes in 5.7.1 diff --git a/js/scripts/JSRootCore.js b/js/scripts/JSRootCore.js index 93c014747eee42f2b59ede0133018de56aee79b2..81221d2e4312444b871087632bc0ce3aa435982d 100644 --- a/js/scripts/JSRootCore.js +++ b/js/scripts/JSRootCore.js @@ -95,14 +95,14 @@ "use strict"; - JSROOT.version = "dev 4/10/2019"; + JSROOT.version = "dev 9/10/2019"; JSROOT.source_dir = ""; JSROOT.source_min = false; JSROOT.source_fullpath = ""; // full name of source script JSROOT.bower_dir = null; // when specified, use standard libs from bower location JSROOT.nocache = false; // when specified, used as extra URL parameter to load JSROOT scripts - JSROOT.wrong_http_response_handling = false; // wehn configured, try to handle wrong content-length response from server + JSROOT.wrong_http_response_handling = false; // when configured, try to handle wrong content-length response from server JSROOT.sources = ['core']; // indicates which major sources were loaded JSROOT.id_counter = 1; // avoid id value 0, starts from 1 @@ -168,7 +168,7 @@ FrameNDC: { fX1NDC: 0.07, fY1NDC: 0.12, fX2NDC: 0.95, fY2NDC: 0.88 }, Palette: 57, Latex: 2, // 0 - never, 1 - only latex symbols, 2 - normal TLatex processing (default), 3 - use MathJax for complex case, 4 - use MathJax always - // MathJax : 0, // depricated, will be supported till JSROOT 6.0, use Latex variable 0 - never, 1 - only for complex cases, 2 - always + // MathJax : 0, // deprecated, will be supported till JSROOT 6.0, use Latex variable 0 - never, 1 - only for complex cases, 2 - always ProgressBox: true, // show progress box Embed3DinSVG: 2, // 0 - no embed, only 3D plot, 1 - overlay over SVG (IE/WebKit), 2 - embed into SVG (only Firefox) ImageSVG: !JSROOT.nodejs, // when producing SVG images, use <image> elements to insert 3D drawings from three.js, diff --git a/js/scripts/JSRootPainter.js b/js/scripts/JSRootPainter.js index 40513d390313558be06f479a675797a9cf9ee0aa..f7030e7cddbc36397ebd7dd2400aa2b97299f2b3 100644 --- a/js/scripts/JSRootPainter.js +++ b/js/scripts/JSRootPainter.js @@ -2437,8 +2437,7 @@ if (rect_origin.width > lmt) { height_factor = height_factor || 0.66; main_origin.style('height', Math.round(rect_origin.width * height_factor)+'px'); - } else - if (can_resize !== 'height') { + } else if (can_resize !== 'height') { main_origin.style('width', '200px').style('height', '100px'); } } diff --git a/js/scripts/JSRootPainter.v6.js b/js/scripts/JSRootPainter.v6.js index ca1c08242f778fa3274dade2bac6c380967e9616..d803fa93cb40b33fb11b2ed4199526afe0ef438a 100644 --- a/js/scripts/JSRootPainter.v6.js +++ b/js/scripts/JSRootPainter.v6.js @@ -1530,6 +1530,7 @@ this.axes_drawn = false; } + /** Returns frame rectangle plus extra info for hint display */ TFramePainter.prototype.CleanFrameDrawings = function() { // cleanup all 3D drawings if any @@ -3186,7 +3187,7 @@ for (var i=0; i < this.pad.fPrimitives.arr.length; i++) { var obj = this.pad.fPrimitives.arr[i]; - if ((exact_obj!==null) && (obj !== exact_obj)) continue; + if ((exact_obj !== null) && (obj !== exact_obj)) continue; if ((classname !== undefined) && (classname !== null)) if (obj._typename !== classname) continue; @@ -3200,8 +3201,8 @@ return null; } + /** Return true if any objects beside sub-pads exists in the pad */ TPadPainter.prototype.HasObjectsToDraw = function() { - // return true if any objects beside sub-pads exists in the pad if (!this.pad || !this.pad.fPrimitives) return false; @@ -4967,15 +4968,36 @@ return res; } + /** Check if TGeo objects in the canvas - draw them directly @private */ + TCanvasPainter.prototype.DirectGeoDraw = function() { + var lst = this.pad ? this.pad.fPrimitives : null; + if (!lst || (lst.arr.length != 1)) return; + + var obj = lst.arr[0]; + if (obj && obj._typename && (obj._typename.indexOf("TGeo")==0)) + return JSROOT.draw(this.divid, obj, lst.opt[0]); + } + function drawCanvas(divid, can, opt) { var nocanvas = !can; if (nocanvas) can = JSROOT.Create("TCanvas"); var painter = new TCanvasPainter(can); + painter.SetDivId(divid, -1); // just assign id + + if (!nocanvas && can.fCw && can.fCh && !JSROOT.BatchMode) { + var rect0 = painter.select_main().node().getBoundingClientRect(); + if (!rect0.height && (rect0.width > 0.1*can.fCw)) { + painter.select_main().style("width", can.fCw+"px").style("height", can.fCh+"px"); + painter._fixed_size = true; + } + } + + var direct = painter.DirectGeoDraw(); + if (direct) return direct; + painter.DecodeOptions(opt); painter.normal_canvas = !nocanvas; - - painter.SetDivId(divid, -1); // just assign id painter.CheckSpecialsInPrimitives(can); painter.CreateCanvasSvg(0); painter.SetDivId(divid); // now add to painters list diff --git a/js/scripts/JSRootPainter.v7.js b/js/scripts/JSRootPainter.v7.js index 3c71cd8be92b531167836ea76fcb54464b59d399..3b1332d02f3e69c34011e6710a859d932bf5930a 100644 --- a/js/scripts/JSRootPainter.v7.js +++ b/js/scripts/JSRootPainter.v7.js @@ -1240,7 +1240,8 @@ this.axes_drawn = false; } - TFramePainter.prototype.CleanDrawings = function() { + /** Removes all drawn elements of the frame @private */ + TFramePainter.prototype.CleanFrameDrawings = function() { // cleanup all 3D drawings if any if (typeof this.Create3DScene === 'function') this.Create3DScene(-1); @@ -1268,7 +1269,7 @@ TFramePainter.prototype.Cleanup = function() { - this.CleanDrawings(); + this.CleanFrameDrawings(); if (this.draw_g) { this.draw_g.selectAll("*").remove(); @@ -1430,9 +1431,8 @@ setTimeout(this.ProcessTooltipEvent.bind(this, hintsg.property('last_point')), 10); } + /** Returns frame rectangle plus extra info for hint display */ TFramePainter.prototype.GetFrameRect = function() { - // returns frame rectangle plus extra info for hint display - return { x: this.frame_x(), y: this.frame_y(), @@ -1444,9 +1444,9 @@ } } + /** Function called when frame is clicked and object selection can be performed + * such event can be used to select objects */ TFramePainter.prototype.ProcessFrameClick = function(pnt, dblckick) { - // function called when frame is clicked and object selection can be performed - // such event can be used to select var pp = this.pad_painter(); if (!pp) return; @@ -2549,6 +2549,7 @@ function TPadPainter(pad, iscan) { JSROOT.TObjectPainter.call(this, pad); + this.csstype = "pad"; this.pad = pad; this.iscan = iscan; // indicate if working with canvas this.this_pad_name = ""; @@ -3381,7 +3382,7 @@ this.painters = []; if (fp) { this.painters.push(fp); - fp.CleanDrawings(); + fp.CleanFrameDrawings(); } this.RemoveButtons(); this.AddOnlineButtons(); diff --git a/js/scripts/JSRootPainter.v7hist.js b/js/scripts/JSRootPainter.v7hist.js index dd3e61e984bdcd6a184d0622012cde899d140723..d7e802669bc6d820f6595524c443253dd5ae0c4c 100644 --- a/js/scripts/JSRootPainter.v7hist.js +++ b/js/scripts/JSRootPainter.v7hist.js @@ -26,6 +26,7 @@ function THistPainter(histo) { JSROOT.TObjectPainter.call(this, histo); + this.csstype = "hist"; this.draw_content = true; this.nbinsx = 0; this.nbinsy = 0;