Skip to content

Commit 0b64239

Browse files
committed
Build with title editing
1 parent 4294bc5 commit 0b64239

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

build/jsroot.js

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const version_id = 'dev',
1212

1313
/** @summary version date
1414
* @desc Release date in format day/month/year like '14/04/2022' */
15-
version_date = '17/02/2025',
15+
version_date = '20/02/2025',
1616

1717
/** @summary version id and date
1818
* @desc Produced by concatenation of {@link version_id} and {@link version_date}
@@ -76185,7 +76185,9 @@ class THistPainter extends ObjectPainter {
7618576185
Object.assign(pt, { fName: kTitle, fOption: 'blNDC', fFillColor: st.fTitleColor, fFillStyle: st.fTitleStyle, fBorderSize: st.fTitleBorderSize,
7618676186
fTextFont: st.fTitleFont, fTextSize: st.fTitleFontSize, fTextColor: st.fTitleTextColor, fTextAlign: 22 });
7618776187

76188-
if (draw_title) pt.AddText(histo.fTitle);
76188+
if (draw_title)
76189+
pt.AddText(histo.fTitle);
76190+
7618976191
return TPavePainter.draw(pp, pt, kPosTitle).then(p => { p?.setSecondaryId(this, kTitle); return this; });
7619076192
}
7619176193

@@ -76561,13 +76563,21 @@ class THistPainter extends ObjectPainter {
7656176563
fillContextMenuItems(menu) {
7656276564
const histo = this.getHisto(),
7656376565
fp = this.getFramePainter();
76564-
if (!histo) return;
76566+
if (!histo)
76567+
return;
7656576568

7656676569
if ((this.options.Axis <= 0) && !this.isTF1())
7656776570
menu.addchk(this.toggleStat('only-check'), 'Show statbox', () => this.toggleStat());
7656876571

76569-
if (histo.fTitle && this.isMainPainter())
76570-
menu.addchk(this.toggleTitle('only-check'), 'Show title', () => this.toggleTitle());
76572+
if (this.isMainPainter()) {
76573+
menu.sub('Title');
76574+
menu.addchk(this.toggleTitle('only-check'), 'Show', () => this.toggleTitle());
76575+
menu.add('Edit', () => menu.input('Enter histogram title', histo.fTitle).then(res => {
76576+
setHistogramTitle(histo, res);
76577+
this.interactiveRedraw();
76578+
}));
76579+
menu.endsub();
76580+
}
7657176581

7657276582
if (this.draw_content) {
7657376583
if (this.getDimension() === 1)
@@ -79649,7 +79659,7 @@ let TH2Painter$2 = class TH2Painter extends THistPainter {
7964979659
}
7965079660

7965179661
if ((isOption(kHistoRight) || isOption(kHistoLeft) || isOption(kHistoViolin)) && (res.max > 0) && (res.first >= 0)) {
79652-
const arr = [], scale = (swapXY ? -0.5 : 0.5) *histoWidth/res.max;
79662+
const arr = [], scale = (swapXY ? -0.5 : 0.5) * histoWidth / res.max;
7965379663

7965479664
xindx1 = Math.max(xindx1, res.first);
7965579665
xindx2 = Math.min(xindx2-1, res.last);
@@ -83784,7 +83794,8 @@ let TH1Painter$2 = class TH1Painter extends THistPainter {
8378483794
mx1 = Math.round(funcs.grx(xaxis.GetBinLowEdge(bin+1)));
8378583795
mx2 = Math.round(funcs.grx(xaxis.GetBinLowEdge(bin+2)));
8378683796
midx = Math.round((mx1 + mx2) / 2);
83787-
if (startmidx === undefined) startmidx = midx;
83797+
if (startmidx === undefined)
83798+
startmidx = midx;
8378883799
my = Math.round(funcs.gry(bincont));
8378983800
if (show_errors) {
8379083801
binerr = this.getBinErrors(histo, bin + 1, bincont);
@@ -83922,9 +83933,11 @@ let TH1Painter$2 = class TH1Painter extends THistPainter {
8392283933
if (bestimin === bestimax)
8392383934
draw_bin(bestimin);
8392483935
else if (bestimin < bestimax) {
83925-
draw_bin(bestimin); draw_bin(bestimax);
83936+
draw_bin(bestimin);
83937+
draw_bin(bestimax);
8392683938
} else {
83927-
draw_bin(bestimax); draw_bin(bestimin);
83939+
draw_bin(bestimax);
83940+
draw_bin(bestimin);
8392883941
}
8392983942
}
8393083943

@@ -83960,8 +83973,10 @@ let TH1Painter$2 = class TH1Painter extends THistPainter {
8396083973
}
8396183974
// end of use_minmax
8396283975
} else if ((gry !== curry) || lastbin) {
83963-
if (grx !== currx) res += `h${grx-currx}`;
83964-
if (gry !== curry) res += `v${gry-curry}`;
83976+
if (grx !== currx)
83977+
res += `h${grx-currx}`;
83978+
if (gry !== curry)
83979+
res += `v${gry-curry}`;
8396583980
curry = gry;
8396683981
currx = grx;
8396783982
}
@@ -147758,15 +147773,12 @@ class HierarchyPainter extends BasePainter {
147758147773
/** @summary function updates object drawings for other painters
147759147774
* @private */
147760147775
updateOnOtherFrames(painter, obj) {
147761-
const mdi = this.disp;
147762-
if (!mdi) return false;
147763-
147764147776
const handle = obj._typename ? getDrawHandle(prROOT + obj._typename) : null;
147765147777
if (handle?.draw_field && obj[handle?.draw_field])
147766147778
obj = obj[handle?.draw_field];
147767147779

147768147780
let isany = false;
147769-
mdi.forEachPainter((p /* , frame */) => {
147781+
this.disp?.forEachPainter((p /* , frame */) => {
147770147782
if ((p === painter) || (p.getItemName() !== painter.getItemName())) return;
147771147783

147772147784
// do not activate frame when doing update
@@ -147779,7 +147791,7 @@ class HierarchyPainter extends BasePainter {
147779147791
/** @summary Process resize event
147780147792
* @private */
147781147793
checkResize(size) {
147782-
if (this.disp) this.disp.checkMDIResize(null, size);
147794+
this.disp?.checkMDIResize(null, size);
147783147795
}
147784147796

147785147797
/** @summary Load and execute scripts, kept to support v6 applications
@@ -150507,15 +150519,25 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
150507150519
fillContextMenuItems(menu) {
150508150520
if (!this.snapid) {
150509150521
menu.addchk(this.testEditable(), 'Editable', () => { this.testEditable('toggle'); this.drawGraph(); });
150510-
150522+
if (this.axes_draw) {
150523+
menu.add('Title', () => menu.input('Enter graph title', this.getObject().fTitle).then(res => {
150524+
this.getObject().fTitle = res;
150525+
const hist_painter = this.getMainPainter();
150526+
if (hist_painter?.isSecondary(this)) {
150527+
setHistogramTitle(hist_painter.getHisto(), res);
150528+
this.interactiveRedraw('pad');
150529+
}
150530+
}));
150531+
}
150511150532
menu.addRedrawMenu(this.getPrimary());
150512150533
}
150513150534
}
150514150535

150515150536
/** @summary Execute menu command
150516150537
* @private */
150517150538
executeMenuCommand(method, args) {
150518-
if (super.executeMenuCommand(method, args)) return true;
150539+
if (super.executeMenuCommand(method, args))
150540+
return true;
150519150541

150520150542
const canp = this.getCanvPainter(), pmain = this.get_main();
150521150543

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1. Support fAxisAngle in `TGraphPolargram`, provide 'rangleNN' draw option
1111
1. Implement 'arc' draw option for `TPave`
1212
1. Provide context menus for all derived from `TPave` classes
13+
1. Let edit histograms and graphs title via context menu
1314
1. Support Poisson errors for `TH1`/`TH2`, https://root-forum.cern.ch/t/62335/
1415
1. Support `TLink` and `TButton` object, used in `TInspectCanvas`
1516
1. Support `TF12` - projection of `TF2`

modules/core.mjs

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

55
/** @summary version date
66
* @desc Release date in format day/month/year like '14/04/2022' */
7-
version_date = '17/02/2025',
7+
version_date = '20/02/2025',
88

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

0 commit comments

Comments
 (0)