Skip to content

Commit da44714

Browse files
committed
Use getKindForType in hpainter
1 parent 044deab commit da44714

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

modules/gui/HierarchyPainter.mjs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { version, gStyle, httpRequest, create, createHttpRequest, loadScript, loadModules, decodeUrl,
22
source_dir, settings, internals, browser, findFunction, toJSON,
33
isArrayProto, isRootCollection, isBatchMode, isNodeJs, isObject, isFunc, isStr, _ensureJSROOT,
4-
prROOT, clTList, clTMap, clTObjString, clTKey, clTFile, clTText, clTLatex, clTColor, clTStyle,
4+
clTList, clTMap, clTObjString, clTKey, clTFile, clTText, clTLatex, clTColor, clTStyle,
55
getKindForType, getTypeForKind, kInspect, isPromise } from '../core.mjs';
66
import { select as d3_select } from '../d3.mjs';
77
import { openFile, kBaseClass, clTStreamerInfoList, clTDirectory, clTDirectoryFile, nameStreamerInfo, addUserStreamer } from '../io.mjs';
@@ -1227,7 +1227,7 @@ class HierarchyPainter extends BasePainter {
12271227
can_click = true;
12281228

12291229
let can_menu = can_click;
1230-
if (!can_menu && isStr(hitem._kind) && (hitem._kind.indexOf(prROOT) === 0))
1230+
if (!can_menu && getTypeForKind(hitem._kind))
12311231
can_menu = can_click = true;
12321232

12331233
if (!img2) img2 = img1;
@@ -1715,7 +1715,7 @@ class HierarchyPainter extends BasePainter {
17151715
return this.expandItem(itemname, d3cont);
17161716

17171717
// cannot draw, but can inspect ROOT objects
1718-
if (isStr(hitem._kind) && (hitem._kind.indexOf(prROOT) === 0) && sett.inspect && (can_draw !== false))
1718+
if (getTypeForKind(hitem._kind) && sett.inspect && (can_draw !== false))
17191719
return this.display(itemname, kInspect, null, true);
17201720

17211721
if (!hitem._childs || (hitem === this.h)) return;
@@ -2139,12 +2139,12 @@ class HierarchyPainter extends BasePainter {
21392139

21402140
if (!updating) showProgress(`Drawing ${display_itemname} ...`);
21412141

2142-
let handle = obj._typename ? getDrawHandle(prROOT + obj._typename) : null;
2142+
let handle = obj._typename ? getDrawHandle(getKindForType(obj._typename)) : null;
21432143

21442144
if (handle?.draw_field && obj[handle.draw_field]) {
21452145
obj = obj[handle.draw_field];
21462146
if (!drawopt) drawopt = handle.draw_field_opt || '';
2147-
handle = obj._typename ? getDrawHandle(prROOT + obj._typename) : null;
2147+
handle = obj._typename ? getDrawHandle(getKindForType(obj._typename)) : null;
21482148
}
21492149

21502150
if (use_dflt_opt && !drawopt && handle?.dflt && (handle.dflt !== kExpand))
@@ -2219,7 +2219,7 @@ class HierarchyPainter extends BasePainter {
22192219
d3_select(frame).on('dragover', ev => {
22202220
const itemname = ev.dataTransfer.getData('item'),
22212221
ditem = h.findItem(itemname);
2222-
if (isStr(ditem?._kind) && (ditem._kind.indexOf(prROOT) === 0))
2222+
if (getTypeForKind(ditem?._kind))
22232223
ev.preventDefault(); // let accept drop, otherwise it will be refused
22242224
}).on('dragenter', function() {
22252225
d3_select(this).classed('jsroot_drag_area', true);
@@ -2286,7 +2286,7 @@ class HierarchyPainter extends BasePainter {
22862286
if (isFunc(mp?.performDrop))
22872287
return mp.performDrop(res.obj, itemname, res.item, opt).then(p => drop_complete(p, mp === p));
22882288

2289-
const sett = res.obj._typename ? getDrawSettings(prROOT + res.obj._typename) : null;
2289+
const sett = res.obj._typename ? getDrawSettings(getKindForType(res.obj._typename)) : null;
22902290
if (!sett?.draw)
22912291
return null;
22922292

@@ -2676,7 +2676,7 @@ class HierarchyPainter extends BasePainter {
26762676
if (handle?.expand_item && !hpainter._inspector) {
26772677
_obj = _obj[handle.expand_item];
26782678
_item.expand_item = handle.expand_item; // remember that was expand item
2679-
handle = _obj?._typename ? getDrawHandle(prROOT + _obj._typename, '::expand') : null;
2679+
handle = _obj?._typename ? getDrawHandle(getKindForType(_obj._typename), '::expand') : null;
26802680
}
26812681

26822682
if (handle?.expand || handle?.get_expand) {
@@ -3066,7 +3066,7 @@ class HierarchyPainter extends BasePainter {
30663066
}
30673067
}
30683068

3069-
if (!req && item._kind.indexOf(prROOT))
3069+
if (!req && getTypeForKind(item._kind))
30703070
req = 'item.json.gz?compact=3';
30713071
}
30723072

@@ -3153,10 +3153,8 @@ class HierarchyPainter extends BasePainter {
31533153
.then(() => {
31543154
this.forEachItem(item => {
31553155
if (!('_drawfunc' in item) || !('_kind' in item)) return;
3156-
let typename = 'kind:' + item._kind;
3157-
if (item._kind.indexOf(prROOT) === 0)
3158-
typename = item._kind.slice(5);
3159-
const drawopt = item._drawopt;
3156+
const typename = getTypeForKind(item._kind) || `kind:${item._kind}`,
3157+
drawopt = item._drawopt;
31603158
if (!canDrawHandle(typename) || drawopt)
31613159
addDrawFunc({ name: typename, func: item._drawfunc, script: item._drawscript, opt: drawopt });
31623160
});
@@ -3201,7 +3199,7 @@ class HierarchyPainter extends BasePainter {
32013199
const node = this.findItem(itemname),
32023200
sett = getDrawSettings(node._kind, 'nosame;noinspect'),
32033201
handle = getDrawHandle(node._kind),
3204-
root_type = isStr(node._kind) ? node._kind.indexOf(prROOT) === 0 : false;
3202+
root_type = getTypeForKind(node._kind);
32053203

32063204
if (sett.opts && (node._can_draw !== false)) {
32073205
sett.opts.push(kInspect);
@@ -3450,7 +3448,7 @@ class HierarchyPainter extends BasePainter {
34503448
/** @summary function updates object drawings for other painters
34513449
* @private */
34523450
updateOnOtherFrames(painter, obj) {
3453-
const handle = obj._typename ? getDrawHandle(prROOT + obj._typename) : null;
3451+
const handle = obj._typename ? getDrawHandle(getKindForType(obj._typename)) : null;
34543452
if (handle?.draw_field && obj[handle?.draw_field])
34553453
obj = obj[handle?.draw_field];
34563454

0 commit comments

Comments
 (0)