Skip to content

Commit

Permalink
Build with title editing
Browse files Browse the repository at this point in the history
  • Loading branch information
linev committed Feb 20, 2025
1 parent 4294bc5 commit 0b64239
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 19 deletions.
58 changes: 40 additions & 18 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 = '17/02/2025',
version_date = '20/02/2025',

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

if (draw_title) pt.AddText(histo.fTitle);
if (draw_title)
pt.AddText(histo.fTitle);

return TPavePainter.draw(pp, pt, kPosTitle).then(p => { p?.setSecondaryId(this, kTitle); return this; });
}

Expand Down Expand Up @@ -76561,13 +76563,21 @@ class THistPainter extends ObjectPainter {
fillContextMenuItems(menu) {
const histo = this.getHisto(),
fp = this.getFramePainter();
if (!histo) return;
if (!histo)
return;

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

if (histo.fTitle && this.isMainPainter())
menu.addchk(this.toggleTitle('only-check'), 'Show title', () => this.toggleTitle());
if (this.isMainPainter()) {
menu.sub('Title');
menu.addchk(this.toggleTitle('only-check'), 'Show', () => this.toggleTitle());
menu.add('Edit', () => menu.input('Enter histogram title', histo.fTitle).then(res => {
setHistogramTitle(histo, res);
this.interactiveRedraw();
}));
menu.endsub();
}

if (this.draw_content) {
if (this.getDimension() === 1)
Expand Down Expand Up @@ -79649,7 +79659,7 @@ let TH2Painter$2 = class TH2Painter extends THistPainter {
}

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

xindx1 = Math.max(xindx1, res.first);
xindx2 = Math.min(xindx2-1, res.last);
Expand Down Expand Up @@ -83784,7 +83794,8 @@ let TH1Painter$2 = class TH1Painter extends THistPainter {
mx1 = Math.round(funcs.grx(xaxis.GetBinLowEdge(bin+1)));
mx2 = Math.round(funcs.grx(xaxis.GetBinLowEdge(bin+2)));
midx = Math.round((mx1 + mx2) / 2);
if (startmidx === undefined) startmidx = midx;
if (startmidx === undefined)
startmidx = midx;
my = Math.round(funcs.gry(bincont));
if (show_errors) {
binerr = this.getBinErrors(histo, bin + 1, bincont);
Expand Down Expand Up @@ -83922,9 +83933,11 @@ let TH1Painter$2 = class TH1Painter extends THistPainter {
if (bestimin === bestimax)
draw_bin(bestimin);
else if (bestimin < bestimax) {
draw_bin(bestimin); draw_bin(bestimax);
draw_bin(bestimin);
draw_bin(bestimax);
} else {
draw_bin(bestimax); draw_bin(bestimin);
draw_bin(bestimax);
draw_bin(bestimin);
}
}

Expand Down Expand Up @@ -83960,8 +83973,10 @@ let TH1Painter$2 = class TH1Painter extends THistPainter {
}
// end of use_minmax
} else if ((gry !== curry) || lastbin) {
if (grx !== currx) res += `h${grx-currx}`;
if (gry !== curry) res += `v${gry-curry}`;
if (grx !== currx)
res += `h${grx-currx}`;
if (gry !== curry)
res += `v${gry-curry}`;
curry = gry;
currx = grx;
}
Expand Down Expand Up @@ -147758,15 +147773,12 @@ class HierarchyPainter extends BasePainter {
/** @summary function updates object drawings for other painters
* @private */
updateOnOtherFrames(painter, obj) {
const mdi = this.disp;
if (!mdi) return false;

const handle = obj._typename ? getDrawHandle(prROOT + obj._typename) : null;
if (handle?.draw_field && obj[handle?.draw_field])
obj = obj[handle?.draw_field];

let isany = false;
mdi.forEachPainter((p /* , frame */) => {
this.disp?.forEachPainter((p /* , frame */) => {
if ((p === painter) || (p.getItemName() !== painter.getItemName())) return;

// do not activate frame when doing update
Expand All @@ -147779,7 +147791,7 @@ class HierarchyPainter extends BasePainter {
/** @summary Process resize event
* @private */
checkResize(size) {
if (this.disp) this.disp.checkMDIResize(null, size);
this.disp?.checkMDIResize(null, size);
}

/** @summary Load and execute scripts, kept to support v6 applications
Expand Down Expand Up @@ -150507,15 +150519,25 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
fillContextMenuItems(menu) {
if (!this.snapid) {
menu.addchk(this.testEditable(), 'Editable', () => { this.testEditable('toggle'); this.drawGraph(); });

if (this.axes_draw) {
menu.add('Title', () => menu.input('Enter graph title', this.getObject().fTitle).then(res => {
this.getObject().fTitle = res;
const hist_painter = this.getMainPainter();
if (hist_painter?.isSecondary(this)) {
setHistogramTitle(hist_painter.getHisto(), res);
this.interactiveRedraw('pad');
}
}));
}
menu.addRedrawMenu(this.getPrimary());
}
}

/** @summary Execute menu command
* @private */
executeMenuCommand(method, args) {
if (super.executeMenuCommand(method, args)) return true;
if (super.executeMenuCommand(method, args))
return true;

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

Expand Down
1 change: 1 addition & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
1. Support fAxisAngle in `TGraphPolargram`, provide 'rangleNN' draw option
1. Implement 'arc' draw option for `TPave`
1. Provide context menus for all derived from `TPave` classes
1. Let edit histograms and graphs title via context menu
1. Support Poisson errors for `TH1`/`TH2`, https://root-forum.cern.ch/t/62335/
1. Support `TLink` and `TButton` object, used in `TInspectCanvas`
1. Support `TF12` - projection of `TF2`
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 = '17/02/2025',
version_date = '20/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 0b64239

Please sign in to comment.