Skip to content

Commit 3a75978

Browse files
committed
Build with new addDrawFunc feature
1 parent 54371f7 commit 3a75978

File tree

3 files changed

+36
-33
lines changed

3 files changed

+36
-33
lines changed

build/jsroot.js

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const version_id = 'dev',
1414

1515
/** @summary version date
1616
* @desc Release date in format day/month/year like '14/04/2022' */
17-
version_date = '25/11/2025',
17+
version_date = '27/11/2025',
1818

1919
/** @summary version id and date
2020
* @desc Produced by concatenation of {@link version_id} and {@link version_date}
@@ -163238,14 +163238,14 @@ const drawFuncs = { lst: [
163238163238
{ name: 'kind:Command', icon: 'img_execute', execute: true },
163239163239
{ name: 'TFolder', icon: 'img_folder', icon2: 'img_folderopen', noinspect: true, get_expand: () => import_h().then(h => h.folderHierarchy) },
163240163240
{ name: 'TTask', icon: 'img_task', get_expand: () => import_h().then(h => h.taskHierarchy), for_derived: true },
163241-
{ name: clTTree, icon: 'img_tree', get_expand: () => Promise.resolve().then(function () { return tree; }).then(h => h.treeHierarchy), draw: () => import_tree().then(h => h.drawTree), dflt: 'expand', opt: 'player;testio', shift: kInspect, pm: true },
163241+
{ name: clTTree, icon: 'img_tree', get_expand: () => Promise.resolve().then(function () { return tree; }).then(h => h.treeHierarchy), draw: () => import_tree().then(h => h.drawTree), dflt: 'expand', opt: 'player;testio', shift: kInspect, pm: true, transform: true },
163242163242
{ name: 'TNtuple', sameas: clTTree },
163243163243
{ name: 'TNtupleD', sameas: clTTree },
163244-
{ name: clTBranchFunc, icon: 'img_leaf_method', draw: () => import_tree().then(h => h.drawTree), opt: ';dump', noinspect: true },
163245-
{ name: /^TBranch/, icon: 'img_branch', draw: () => import_tree().then(h => h.drawTree), dflt: 'expand', opt: ';dump', ctrl: 'dump', shift: kInspect, ignore_online: true, always_draw: true },
163246-
{ name: /^TLeaf/, icon: 'img_leaf', noexpand: true, draw: () => import_tree().then(h => h.drawTree), opt: ';dump', ctrl: 'dump', ignore_online: true, always_draw: true },
163247-
{ name: 'ROOT::RNTuple', icon: 'img_tree', get_expand: () => Promise.resolve().then(function () { return rntuple; }).then(h => h.tupleHierarchy), draw: () => Promise.resolve().then(function () { return RNTuple; }).then(h => h.drawRNTuple), dflt: 'expand', pm: true },
163248-
{ name: 'ROOT::RNTupleField', icon: 'img_leaf', draw: () => Promise.resolve().then(function () { return RNTuple; }).then(h => h.drawRNTuple), opt: ';dump', ctrl: 'dump', shift: kInspect, ignore_online: true, always_draw: true },
163244+
{ name: clTBranchFunc, icon: 'img_leaf_method', draw: () => import_tree().then(h => h.drawTree), opt: ';dump', noinspect: true, transform: true },
163245+
{ name: /^TBranch/, icon: 'img_branch', draw: () => import_tree().then(h => h.drawTree), dflt: 'expand', opt: ';dump', ctrl: 'dump', shift: kInspect, ignore_online: true, always_draw: true, transform: true },
163246+
{ name: /^TLeaf/, icon: 'img_leaf', noexpand: true, draw: () => import_tree().then(h => h.drawTree), opt: ';dump', ctrl: 'dump', ignore_online: true, always_draw: true, transform: true },
163247+
{ name: 'ROOT::RNTuple', icon: 'img_tree', get_expand: () => Promise.resolve().then(function () { return rntuple; }).then(h => h.tupleHierarchy), draw: () => Promise.resolve().then(function () { return RNTuple; }).then(h => h.drawRNTuple), dflt: 'expand', pm: true, transform: true },
163248+
{ name: 'ROOT::RNTupleField', icon: 'img_leaf', draw: () => Promise.resolve().then(function () { return RNTuple; }).then(h => h.drawRNTuple), opt: ';dump', ctrl: 'dump', shift: kInspect, ignore_online: true, always_draw: true, transform: true },
163249163249
{ name: clTList, icon: 'img_list', draw: () => import_h().then(h => h.drawList), get_expand: () => import_h().then(h => h.listHierarchy), dflt: 'expand' },
163250163250
{ name: clTHashList, sameas: clTList },
163251163251
{ name: clTObjArray, sameas: clTList },
@@ -163277,19 +163277,28 @@ const drawFuncs = { lst: [
163277163277

163278163278

163279163279
/** @summary Register draw function for the class
163280-
* @desc List of supported draw options could be provided, separated with ';'
163281163280
* @param {object} args - arguments
163282-
* @param {string|regexp} args.name - class name or regexp pattern
163281+
* @param {string|regexp} args.name - class name or regexp pattern or '*'
163283163282
* @param {function} [args.func] - draw function
163283+
* @param {string} [args.sameas] - let behave same as specified class
163284163284
* @param {function} [args.draw] - async function to load draw function
163285163285
* @param {function} [args.class] - async function to load painter class with static draw function
163286163286
* @param {boolean} [args.direct] - if true, function is just Redraw() method of ObjectPainter
163287163287
* @param {string} [args.opt] - list of supported draw options (separated with semicolon) like 'col;scat;'
163288163288
* @param {string} [args.icon] - icon name shown for the class in hierarchy browser
163289163289
* @param {string} [args.draw_field] - draw only data member from object, like fHistogram
163290+
* @param {string} [args.noinspect] - disable inspect
163291+
* @param {string} [args.noexpand] - disable expand
163292+
* @param {string} [args.pm] - always show plus or minus sign even when no child items exists
163293+
* @desc List of supported draw options could be provided, separated with ';'
163294+
* If args.name parameter is '*', function will be invoked before object drawing.
163295+
* If such function does not return value - normal drawing will be continued.
163290163296
* @protected */
163291163297
function addDrawFunc(args) {
163292-
drawFuncs.lst.push(args);
163298+
if (args?.name === '*')
163299+
internals._alt_draw = isFunc(args.func) ? args.func : null;
163300+
else
163301+
drawFuncs.lst.push(args);
163293163302
return args;
163294163303
}
163295163304

@@ -163500,6 +163509,12 @@ async function draw(dom, obj, opt) {
163500163509
if (handle.draw_field && obj[handle.draw_field])
163501163510
return draw(dom, obj[handle.draw_field], opt || handle.draw_field_opt);
163502163511

163512+
if (internals._alt_draw && !handle.transform) {
163513+
const v = internals._alt_draw(dom, obj, opt);
163514+
if (v)
163515+
return v;
163516+
}
163517+
163503163518
if (!canDrawHandle(handle)) {
163504163519
if (opt && (opt.indexOf('same') >= 0)) {
163505163520
const main_painter = getElementMainPainter(dom);
@@ -164704,8 +164719,6 @@ class HierarchyPainter extends BasePainter {
164704164719
#one_by_one; // process drop items one by one
164705164720
#topname; // top item name
164706164721
#cached_draw_object; // cached object for first draw
164707-
#draw_func; // alternative draw function
164708-
#redraw_func; // alternative redraw function
164709164722

164710164723
/** @summary Create painter
164711164724
* @param {string} name - symbolic name
@@ -164736,23 +164749,6 @@ class HierarchyPainter extends BasePainter {
164736164749
this.textcolor = settings.DarkMode ? '#eee' : '#111';
164737164750
}
164738164751

164739-
/** @summary Set alternative draw/redraw functions
164740-
* @desc If only only draw function specified - it also will be used for re-drawing
164741-
* @protected */
164742-
setDrawFunc(_draw, _redraw) {
164743-
if (isFunc(_draw)) {
164744-
this.#draw_func = _draw;
164745-
this.#redraw_func = isFunc(_redraw) ? _redraw : _draw;
164746-
}
164747-
}
164748-
164749-
/** @summary Invoke configured draw or redraw function
164750-
* @protected */
164751-
async callDrawFunc(dom, obj, opt, doredraw) {
164752-
const func = doredraw ? (this.#redraw_func || redraw) : (this.#draw_func || draw);
164753-
return func(dom, obj, opt);
164754-
}
164755-
164756164752
/** @summary Cleanup hierarchy painter
164757164753
* @desc clear drawing and browser */
164758164754
cleanup() {
@@ -166190,7 +166186,7 @@ class HierarchyPainter extends BasePainter {
166190166186
drawopt = handle.dflt;
166191166187

166192166188
if (dom)
166193-
return this.callDrawFunc(dom, obj, drawopt, updating).then(p => complete(p)).catch(err => complete(null, err));
166189+
return (updating ? redraw : draw)(dom, obj, drawopt).then(p => complete(p)).catch(err => complete(null, err));
166194166190

166195166191
let did_activate = false;
166196166192
const arr = [];
@@ -166234,7 +166230,7 @@ class HierarchyPainter extends BasePainter {
166234166230
cleanup(frame);
166235166231
mdi.activateFrame(frame);
166236166232

166237-
return this.callDrawFunc(frame, obj, drawopt)
166233+
return draw(frame, obj, drawopt)
166238166234
.then(p => complete(p))
166239166235
.catch(err => complete(null, err));
166240166236
});
@@ -166342,7 +166338,7 @@ class HierarchyPainter extends BasePainter {
166342166338
if (isFunc(dom?.addPadButtons))
166343166339
dom.addPadButtons();
166344166340

166345-
return this.callDrawFunc(dom, res.obj, opt).then(p => drop_complete(p, mp === p));
166341+
return draw(dom, res.obj, opt).then(p => drop_complete(p, mp === p));
166346166342
});
166347166343
}
166348166344

@@ -168973,6 +168969,12 @@ async function drawTreeDrawResult(dom, obj, opt) {
168973168969
if (!typ || !isStr(typ))
168974168970
return Promise.reject(Error('Object without type cannot be draw with TTree'));
168975168971

168972+
if (internals._alt_draw) {
168973+
const v = internals._alt_draw(dom, obj, opt);
168974+
if (v)
168975+
return v;
168976+
}
168977+
168976168978
if (typ.indexOf(clTH1) === 0)
168977168979
return TH1Painter.draw(dom, obj, opt);
168978168980
if (typ.indexOf(clTH2) === 0)

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
1. Implement for `TPie` 3d, text, title drawing including interactivity
77
1. Implement `TCanvas` support in `build3d` function #373
88
1. Implements `TTree` branches filtering via context menu #364
9+
1. Let define alternative draw function #378
910
1. Remove support for deprectaed `TH1K` class
1011
1. Fix - paint frame border mode/size from TCanvas
1112

modules/core.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const version_id = 'dev',
66

77
/** @summary version date
88
* @desc Release date in format day/month/year like '14/04/2022' */
9-
version_date = '25/11/2025',
9+
version_date = '27/11/2025',
1010

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

0 commit comments

Comments
 (0)