Skip to content

Commit ba3fcb9

Browse files
committed
Use menu.addchk function to add function with check-box
1 parent 7cc34bb commit ba3fcb9

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

scripts/JSRootPainter.jquery.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
this.cnt++;
6565
}
6666

67+
menu.addchk = function(flag, name, arg, func) {
68+
return this.add((flag ? "chk:" : "unk:") + name, arg, func);
69+
}
70+
6771
menu.size = function() { return this.cnt-1; }
6872

6973
menu.addDrawMenu = function(menu_name, opts, call_back) {

scripts/JSRootPainter.js

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3384,7 +3384,7 @@
33843384
function AddStatOpt(pos, name) {
33853385
var opt = (pos<10) ? pthis.pavetext.fOptStat : pthis.pavetext.fOptFit;
33863386
opt = parseInt(parseInt(opt) / parseInt(Math.pow(10,pos % 10))) % 10;
3387-
menu.add( (opt ? "chk:" : "unk:") + name, opt * 100 + pos, function(arg) {
3387+
menu.addchk(opt, name, opt * 100 + pos, function(arg) {
33883388
var newopt = (arg % 100 < 10) ? pthis.pavetext.fOptStat : pthis.pavetext.fOptFit;
33893389
var oldopt = parseInt(arg / 100);
33903390
newopt -= (oldopt>0 ? oldopt : -1) * parseInt(Math.pow(10, arg % 10));
@@ -5881,18 +5881,18 @@
58815881
if (arg=="y") faxis = this.histo['fYaxis'];
58825882
menu.add("header: " + arg.toUpperCase() + " axis");
58835883
menu.add("Unzoom", function() { this.Unzoom(arg=="x", arg=="y", arg=="z"); });
5884-
menu.add((this.options["Log" + kind] ? "chk:" : "unk:") + "SetLog"+arg, function() { this.ToggleLog(arg); });
5884+
menu.addchk(this.options["Log" + kind], "SetLog"+arg, this.ToggleLog.bind(this, arg) );
58855885
if (faxis != null) {
5886-
menu.add((faxis.TestBit(JSROOT.EAxisBits.kCenterLabels) ? "chk:" : "unk:") + "CenterLabels",
5887-
function() { faxis.InvertBit(JSROOT.EAxisBits.kCenterLabels); this.RedrawPad(); });
5888-
menu.add((faxis.TestBit(JSROOT.EAxisBits.kCenterTitle) ? "chk:" : "unk:") + "CenterTitle",
5889-
function() { faxis.InvertBit(JSROOT.EAxisBits.kCenterTitle); this.RedrawPad(); });
5890-
menu.add((faxis.TestBit(JSROOT.EAxisBits.kRotateTitle) ? "chk:" : "unk:") + "RotateTitle",
5891-
function() { faxis.InvertBit(JSROOT.EAxisBits.kRotateTitle); this.RedrawPad(); });
5892-
menu.add((faxis.TestBit(JSROOT.EAxisBits.kMoreLogLabels) ? "chk:" : "unk:") + "MoreLogLabels",
5893-
function() { faxis.InvertBit(JSROOT.EAxisBits.kMoreLogLabels); this.RedrawPad(); });
5894-
menu.add((faxis.TestBit(JSROOT.EAxisBits.kNoExponent) ? "chk:" : "unk:") + "NoExponent",
5895-
function() { faxis.InvertBit(JSROOT.EAxisBits.kNoExponent); this.RedrawPad(); });
5886+
menu.addchk(faxis.TestBit(JSROOT.EAxisBits.kCenterLabels), "CenterLabels",
5887+
function() { faxis.InvertBit(JSROOT.EAxisBits.kCenterLabels); this.RedrawPad(); });
5888+
menu.addchk(faxis.TestBit(JSROOT.EAxisBits.kCenterTitle), "CenterTitle",
5889+
function() { faxis.InvertBit(JSROOT.EAxisBits.kCenterTitle); this.RedrawPad(); });
5890+
menu.addchk(faxis.TestBit(JSROOT.EAxisBits.kRotateTitle), "RotateTitle",
5891+
function() { faxis.InvertBit(JSROOT.EAxisBits.kRotateTitle); this.RedrawPad(); });
5892+
menu.addchk(faxis.TestBit(JSROOT.EAxisBits.kMoreLogLabels), "MoreLogLabels",
5893+
function() { faxis.InvertBit(JSROOT.EAxisBits.kMoreLogLabels); this.RedrawPad(); });
5894+
menu.addchk(faxis.TestBit(JSROOT.EAxisBits.kNoExponent), "NoExponent",
5895+
function() { faxis.InvertBit(JSROOT.EAxisBits.kNoExponent); this.RedrawPad(); });
58965896
}
58975897
} else {
58985898
menu.add("header:"+ this.histo['fName']);
@@ -5913,26 +5913,21 @@
59135913
menu.add("Unzoom Z", function() { this.Unzoom(false, false, true); });
59145914
menu.add("Unzoom", function() { this.Unzoom(true, true, true); });
59155915

5916-
menu.add((JSROOT.gStyle.Tooltip ? "chk:" : "unk:") + "Show tooltips", function() {
5916+
menu.addchk(JSROOT.gStyle.Tooltip, "Show tooltips", function() {
59175917
JSROOT.gStyle.Tooltip = !JSROOT.gStyle.Tooltip;
59185918
this.RedrawPad();
59195919
});
59205920

59215921
if (this.options) {
5922-
var item = (this.options.Logx ? "chk:" : "unk:") + "SetLogx";
5922+
menu.addchk(this.options.Logx, "SetLogx", function() { this.ToggleLog("x"); });
59235923

5924-
menu.add(item, function() { this.ToggleLog("x"); });
5924+
menu.addchk(this.options.Logy, "SetLogy", function() { this.ToggleLog("y"); });
59255925

5926-
item = (this.options.Logy ? "chk:" : "unk:") +"SetLogy";
5927-
menu.add(item, function() { this.ToggleLog("y"); });
5928-
5929-
if (this.Dimension() == 2) {
5930-
item = (this.options.Logz ? "chk:" : "unk:") + "SetLogz";
5931-
menu.add(item, function() { this.ToggleLog("z"); });
5932-
}
5926+
if (this.Dimension() == 2)
5927+
menu.addchk(this.options.Logz, "SetLogz", function() { this.ToggleLog("z"); });
59335928
}
59345929
if (this.draw_content)
5935-
menu.add((this.ToggleStat('only-check') ? "chk:" : "unk:") + "Show statbox", this.ToggleStat.bind(this));
5930+
menu.addchk(this.ToggleStat('only-check'), "Show statbox", this.ToggleStat.bind(this));
59365931
}
59375932

59385933
// ======= TH1 painter================================================

0 commit comments

Comments
 (0)