diff --git a/modules/gpad/TCanvasPainter.mjs b/modules/gpad/TCanvasPainter.mjs index caceb6d87..ec8d03dee 100644 --- a/modules/gpad/TCanvasPainter.mjs +++ b/modules/gpad/TCanvasPainter.mjs @@ -764,7 +764,7 @@ class TCanvasPainter extends TPadPainter { } /** @summary produce JSON for TCanvas, which can be used to display canvas once again */ - produceJSON() { + produceJSON(spacing) { const canv = this.getObject(), fill0 = (canv.fFillStyle === 0), axes = [], hists = []; @@ -817,7 +817,7 @@ class TCanvasPainter extends TPadPainter { // const fp = this.getFramePainter(); // fp?.setRootPadRange(this.getRootPad()); - const res = toJSON(canv); + const res = toJSON(canv, spacing); if (fill0) canv.fFillStyle = 0; diff --git a/modules/gpad/TPadPainter.mjs b/modules/gpad/TPadPainter.mjs index fcd2eb6ff..613dfc7eb 100644 --- a/modules/gpad/TPadPainter.mjs +++ b/modules/gpad/TPadPainter.mjs @@ -1340,9 +1340,12 @@ class TPadPainter extends ObjectPainter { const fname = this.this_pad_name || (this.iscan ? 'canvas' : 'pad'); menu.sub('Save as'); - const formats = ['svg', 'png', 'jpeg', 'pdf', 'webp']; - if (this.iscan) formats.push('json'); - formats.forEach(fmt => menu.add(`${fname}.${fmt}`, () => this.saveAs(fmt, this.iscan, `${fname}.${fmt}`))); + ['svg', 'png', 'jpeg', 'pdf', 'webp'].forEach(fmt => menu.add(`${fname}.${fmt}`, () => this.saveAs(fmt, this.iscan, `${fname}.${fmt}`))); + if (this.iscan) { + menu.separator(); + menu.add(`${fname}.json`, () => this.saveAs('json', true, `${fname}.json`), 'Produce JSON with line spacing'); + menu.add(`${fname}0.json`, () => this.saveAs('json', false, `${fname}0.json`), 'Produce JSON without line spacing'); + } menu.endsub(); return true; @@ -2252,7 +2255,7 @@ class TPadPainter extends ObjectPainter { * @return {Promise} with created image */ async produceImage(full_canvas, file_format) { if (file_format === 'json') - return isFunc(this.produceJSON) ? this.produceJSON() : ''; + return isFunc(this.produceJSON) ? this.produceJSON(full_canvas ? 2 : 0) : ''; const use_frame = (full_canvas === 'frame'), elem = use_frame ? this.getFrameSvg(this.this_pad_name) : (full_canvas ? this.getCanvSvg() : this.svg_this_pad()),