Skip to content

Commit

Permalink
Build with last edits
Browse files Browse the repository at this point in the history
  • Loading branch information
linev committed Feb 17, 2025
1 parent c532f7f commit 5eb6b8e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 38 deletions.
89 changes: 52 additions & 37 deletions build/jsroot.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const version_id = 'dev',

/** @summary version date
* @desc Release date in format day/month/year like '14/04/2022' */
version_date = '14/02/2025',
version_date = '17/02/2025',

/** @summary version id and date
* @desc Produced by concatenation of {@link version_id} and {@link version_date}
Expand Down Expand Up @@ -9249,33 +9249,38 @@ async function svgToImage(svg, image_format, args) {

// required with df104.py/df105.py example with RCanvas or any special symbols in TLatex
const doctype = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">';
svg = encodeURIComponent(doctype + svg);
svg = svg.replace(/%([0-9A-F]{2})/g, (match, p1) => {
const c = String.fromCharCode('0x'+p1);
return c === '%' ? '%25' : c;
});

// Cannot use prSVG because of some special cases like RCanvas/rh2
const img_src = 'data:image/svg+xml;base64,' + btoa_func(decodeURIComponent(svg));

if (isNodeJs()) {
svg = encodeURIComponent(doctype + svg);
svg = svg.replace(/%([0-9A-F]{2})/g, (match, p1) => {
const c = String.fromCharCode('0x'+p1);
return c === '%' ? '%25' : c;
});

const img_src = 'data:image/svg+xml;base64,' + btoa_func(decodeURIComponent(svg));

return Promise.resolve().then(function () { return _rollup_plugin_ignore_empty_module_placeholder$1; }).then(async handle => {
return handle.default.loadImage(img_src).then(img => {
const canvas = handle.default.createCanvas(img.width, img.height);

canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);

if (args?.as_buffer) return canvas.toBuffer('image/' + image_format);
if (args?.as_buffer)
return canvas.toBuffer('image/' + image_format);

return image_format ? canvas.toDataURL('image/' + image_format) : canvas;
});
});
}

const img_src = URL.createObjectURL(new Blob([doctype + svg], { type: 'image/svg+xml;charset=utf-8' }));

return new Promise(resolveFunc => {
const image = document.createElement('img');

image.onload = function() {
URL.revokeObjectURL(img_src);

const canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
Expand All @@ -9288,11 +9293,12 @@ async function svgToImage(svg, image_format, args) {
resolveFunc(image_format ? canvas.toDataURL('image/' + image_format) : canvas);
};
image.onerror = function(arg) {
URL.revokeObjectURL(img_src);
console.log(`IMAGE ERROR ${arg}`);
resolveFunc(null);
};

image.src = img_src;
image.setAttribute('src', img_src);
});
}

Expand Down Expand Up @@ -13822,12 +13828,15 @@ class ObjectPainter extends BasePainter {
* @param {Object} evnt - object with clientX and clientY positions
* @private */
getToolTip(evnt) {
if ((evnt?.clientX === undefined) || (evnt?.clientY === undefined)) return null;
if ((evnt?.clientX === undefined) || (evnt?.clientY === undefined))
return null;

const frame = this.getFrameSvg();
if (frame.empty()) return null;
if (frame.empty())
return null;
const layer = frame.selectChild('.main_layer');
if (layer.empty()) return null;
if (layer.empty())
return null;

const pos = pointer(evnt, layer.node()),
pnt = { touch: false, x: pos[0], y: pos[1] };
Expand Down Expand Up @@ -71088,13 +71097,13 @@ class TPadPainter extends ObjectPainter {
if (this.painters.indexOf(objpainter) < 0)
this.painters.push(objpainter);

objpainter.snapid = lst[indx].fObjectID;
objpainter.assignSnapId(lst[indx].fObjectID);
const setSubSnaps = p => {
if (!p.getUniqueId(true)) return;
for (let k = 0; k < this.painters.length; ++k) {
const sub = this.painters[k];
if (sub.isSecondary(p) && sub.getSecondaryId()) {
sub.snapid = p.snapid + '#' + sub.getSecondaryId();
sub.assignSnapId(p.snapid + '#' + sub.getSecondaryId());
setSubSnaps(sub);
}
}
Expand Down Expand Up @@ -71234,7 +71243,7 @@ class TPadPainter extends ObjectPainter {
const padpainter = new TPadPainter(this, subpad, false);
padpainter.decodeOptions(snap.fOption);
padpainter.addToPadPrimitives();
padpainter.snapid = snap.fObjectID;
padpainter.assignSnapId(snap.fObjectID);
padpainter.is_active_pad = !!snap.fActive; // enforce boolean flag
padpainter._readonly = snap.fReadOnly ?? false; // readonly flag
padpainter._snap_primitives = snap.fPrimitives; // keep list to be able find primitive
Expand Down Expand Up @@ -71316,7 +71325,7 @@ class TPadPainter extends ObjectPainter {
if (this.snapid === undefined) {
// first time getting snap, create all gui elements first

this.snapid = snap.fObjectID;
this.assignSnapId(snap.fObjectID);

this.assignObject(first);
this.pad = first; // first object is pad
Expand Down Expand Up @@ -81605,7 +81614,7 @@ function drawXYZ(toplevel, AxisPainter, opts) {
this.x_handle = new AxisPainter(null, this.xaxis);
if (opts.v7) {
this.x_handle.pad_name = this.pad_name;
this.x_handle.snapid = this.snapid;
this.x_handle.assignSnapId(this.snapid);
} else if (opts.hist_painter)
this.x_handle.setHistPainter(opts.hist_painter, 'x');

Expand All @@ -81617,7 +81626,7 @@ function drawXYZ(toplevel, AxisPainter, opts) {
this.y_handle = new AxisPainter(null, this.yaxis);
if (opts.v7) {
this.y_handle.pad_name = this.pad_name;
this.y_handle.snapid = this.snapid;
this.y_handle.assignSnapId(this.snapid);
} else if (opts.hist_painter)
this.y_handle.setHistPainter(opts.hist_painter, 'y');
this.y_handle.configureAxis('yaxis', this.ymin, this.ymax, ymin, ymax, false, [grminy, grmaxy],
Expand All @@ -81628,7 +81637,7 @@ function drawXYZ(toplevel, AxisPainter, opts) {
this.z_handle = new AxisPainter(null, this.zaxis);
if (opts.v7) {
this.z_handle.pad_name = this.pad_name;
this.z_handle.snapid = this.snapid;
this.z_handle.assignSnapId(this.snapid);
} else if (opts.hist_painter)
this.z_handle.setHistPainter(opts.hist_painter, 'z');
this.z_handle.configureAxis('zaxis', this.zmin, this.zmax, zmin, zmax, false, [grminz, grmaxz],
Expand Down Expand Up @@ -147830,17 +147839,20 @@ class HierarchyPainter extends BasePainter {

getOptionAsArray = opt => {
let res = getUrlOptionAsArray(opt);
if (res.length > 0 || !gui_div || gui_div.empty()) return res;
if (res.length > 0 || !gui_div || gui_div.empty())
return res;
while (opt) {
const separ = opt.indexOf(';');
let part = separ > 0 ? opt.slice(0, separ) : opt;
if (separ > 0) opt = opt.slice(separ+1); else opt = '';
opt = separ > 0 ? opt.slice(separ+1) : '';

let canarray = true;
if (part[0] === '#') { part = part.slice(1); canarray = false; }
if (part === 'files') continue; // special case for normal UI

if (!gui_div.node().hasAttribute(part)) continue;
if (part[0] === '#') {
part = part.slice(1);
canarray = false;
}
if (part === 'files' || !gui_div.node().hasAttribute(part))
continue;

const val = gui_div.attr(part);

Expand Down Expand Up @@ -148097,7 +148109,8 @@ class HierarchyPainter extends BasePainter {
* @desc works only when inspector or streamer info is displayed
* @private */
redrawObject(obj) {
if (!this._inspector && !this._streamer_info) return false;
if (!this._inspector && !this._streamer_info)
return false;
if (this._streamer_info)
this.h = createStreamerInfoContent(obj);
else
Expand Down Expand Up @@ -158144,6 +158157,8 @@ const kNormal = 1, /* kLessTraffic = 2, */ kOffline = 3;

class RObjectPainter extends ObjectPainter {

#pending_request;

constructor(dom, obj, opt, csstype) {
super(dom, obj, opt);
this.csstype = csstype;
Expand Down Expand Up @@ -158452,7 +158467,7 @@ class RObjectPainter extends ObjectPainter {
// special situation when snapid not yet assigned - just keep ref until snapid is there
// maybe keep full list - for now not clear if really needed
if (!this.snapid) {
this._pending_request = { kind, req, method };
this.#pending_request = { kind, req, method };
return req;
}

Expand All @@ -158463,10 +158478,10 @@ class RObjectPainter extends ObjectPainter {
* @desc Overwrite default method */
assignSnapId(id) {
this.snapid = id;
if (this.snapid && this._pending_request) {
const p = this._pending_request;
if (this.snapid && this.#pending_request) {
const p = this.#pending_request;
this.#pending_request = undefined;
this.v7SubmitRequest(p.kind, p.req, p.method);
delete this._pending_request;
}
}

Expand Down Expand Up @@ -159945,17 +159960,17 @@ class RFramePainter extends RObjectPainter {
this.recalculateRange(0);

this.x_handle = new RAxisPainter(pp, this, this.xaxis, 'x_');
this.x_handle.snapid = this.snapid;
this.x_handle.assignSnapId(this.snapid);
this.x_handle.draw_swapside = (sidex < 0);
this.x_handle.draw_ticks = ticksx;

this.y_handle = new RAxisPainter(pp, this, this.yaxis, 'y_');
this.y_handle.snapid = this.snapid;
this.y_handle.assignSnapId(this.snapid);
this.y_handle.draw_swapside = (sidey < 0);
this.y_handle.draw_ticks = ticksy;

this.z_handle = new RAxisPainter(pp, this, this.zaxis, 'z_');
this.z_handle.snapid = this.snapid;
this.z_handle.assignSnapId(this.snapid);

this.x_handle.configureAxis('xaxis', this.xmin, this.xmax, this.scale_xmin, this.scale_xmax, false, [0, w], w, { reverse: false });
this.x_handle.assignFrameMembers(this, 'x');
Expand Down Expand Up @@ -160039,7 +160054,7 @@ class RFramePainter extends RObjectPainter {
this.scale_x2max = this.x2max;
}
this.x2_handle = new RAxisPainter(pp, this, this.x2axis, 'x2_');
this.x2_handle.snapid = this.snapid;
this.x2_handle.assignSnapId(this.snapid);

this.x2_handle.configureAxis('x2axis', this.x2min, this.x2max, this.scale_x2min, this.scale_x2max, false, [0, w], w, { reverse: false });
this.x2_handle.assignFrameMembers(this, 'x2');
Expand All @@ -160057,7 +160072,7 @@ class RFramePainter extends RObjectPainter {
}

this.y2_handle = new RAxisPainter(pp, this, this.y2axis, 'y2_');
this.y2_handle.snapid = this.snapid;
this.y2_handle.assignSnapId(this.snapid);

this.y2_handle.configureAxis('y2axis', this.y2min, this.y2max, this.scale_y2min, this.scale_y2max, true, [h, 0], -h, { reverse: false });
this.y2_handle.assignFrameMembers(this, 'y2');
Expand Down
2 changes: 1 addition & 1 deletion modules/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const version_id = 'dev',

/** @summary version date
* @desc Release date in format day/month/year like '14/04/2022' */
version_date = '14/02/2025',
version_date = '17/02/2025',

/** @summary version id and date
* @desc Produced by concatenation of {@link version_id} and {@link version_date}
Expand Down

0 comments on commit 5eb6b8e

Please sign in to comment.