3 if (typeof JSROOT !=
"object") {
4 var e1 =
new Error(
"condition.js requires JSROOT to be already loaded");
5 e1.source =
"condition.js";
9 if (typeof GO4 !=
"object") {
10 var e1 =
new Error(
"condition.js requires GO4 to be already loaded");
11 e1.source =
"condition.js";
17 GO4.ConditionEditor =
function(cond) {
18 JSROOT.TBasePainter.call(
this, cond);
20 this.changes = [
"dummy",
"init"];
24 GO4.ConditionEditor.prototype = Object.create(JSROOT.TBasePainter.prototype);
27 GO4.ConditionEditor.prototype.isPolyCond =
function() {
28 return ((this.cond._typename ==
"TGo4PolyCond") || (this.cond._typename ==
"TGo4ShapedCond"));
31 GO4.ConditionEditor.prototype.isEllipseCond =
function() {
32 return (this.cond._typename ==
"TGo4ShapedCond");
36 GO4.ConditionEditor.prototype.DabcCommand =
function(cmd, option, callback) {
38 if (this.GetItemName()!=
"") {
39 pre = this.GetItemName() +
"/";
42 pre +=
"exe.json\?method=";
43 var fullcom = pre + cmd + option;
45 JSROOT.NewHttpRequest(fullcom,
'text',
function(res) {
46 console.log(
"DabcCommand completed.");
52 GO4.ConditionEditor.prototype.MarkChanged =
function(key) {
55 for (index = 0; index < this.changes.length; index++) {
56 if (this.changes[index]== key)
return;
58 this.changes.push(key);
59 console.log(
"Mark changed :%s", key);
60 var
id =
"#"+this.divid;
62 $(
id+
" .buttonChangeLabel").show();
66 GO4.ConditionEditor.prototype.ClearChanges =
function() {
68 var len=this.changes.length;
69 for (index = 0; index < len ; index++) {
70 var removed=this.changes.pop();
71 console.log(
"Clear changes removed :%s", removed);
73 var
id =
"#"+this.divid;
74 $(
id+
" .buttonChangeLabel").hide();
79 GO4.ConditionEditor.prototype.EvaluateChanges =
function(optionstring) {
80 var
id =
"#"+this.divid;
82 var len=this.changes.length;
83 for (index = 0; index < len ; index++) {
85 var key=this.changes[index];
91 var xmin=$(
id+
" .cond_xmin")[0].value;
92 var xmax=$(
id+
" .cond_xmax")[0].value;
93 optionstring +=
"&xmin="+xmin+
"&xmax="+xmax;
94 this.cond.fLow1 = xmin;
95 this.cond.fUp1 = xmax;
96 if (this.cond.fiDim==2) {
97 var ymin=$(
id+
" .cond_ymin")[0].value;
98 var ymax=$(
id+
" .cond_ymax")[0].value;
99 this.cond.fLow2 = xmin;
100 this.cond.fUp2 = xmax;
101 optionstring +=
"&ymin="+ymin+
"&ymax="+ymax;
104 else if(key==
"polygon")
106 var npoints=$(
id+
" .cut_points")[0].value;
107 optionstring +=
"&npolygon="+npoints;
109 for(i=0; i<npoints; ++i)
111 var x = $(
id +
" .cut_values input").eq(2*i)[0].value;
112 var y = $(
id +
" .cut_values input").eq(2*i+1)[0].value;
113 optionstring +=
"&x"+i+
"="+x+
"&y"+i+
"="+y;
116 else if (key==
"ellinpts"){
117 var val=$(
id+
" .cond_ellipse_points")[0].value;
118 optionstring +=
"&"+key+
"="+val;
120 else if (key==
"ellicx"){
121 var val=$(
id+
" .cond_ellipse_cx")[0].value;
122 optionstring +=
"&"+key+
"="+val;
124 else if (key==
"ellicy"){
125 var val=$(
id+
" .cond_ellipse_cy")[0].value;
126 optionstring +=
"&"+key+
"="+val;
128 else if (key==
"ellia1"){
129 var val=$(
id+
" .cond_ellipse_a1")[0].value;
130 optionstring +=
"&"+key+
"="+val;
132 else if (key==
"ellia2"){
133 var val=$(
id+
" .cond_ellipse_a2")[0].value;
134 optionstring +=
"&"+key+
"="+val;
136 else if (key==
"ellishape"){
137 var arg=$(
id+
" .cond_ellipse_iscircle")[0].value;
138 optionstring +=
"&"+key+
"="+arg;
140 else if (key==
"ellith"){
141 var val=$(
id+
" .cond_ellipse_theta")[0].value;
142 optionstring +=
"&"+key+
"="+val;
144 else if (key==
"resultmode"){
145 var selected=$(
id+
" .cond_execmode")[0].value;
146 optionstring +=
"&"+key+
"="+selected;
148 else if (key==
"invertmode"){
149 var selected=$(
id+
" .cond_invertmode")[0].value;
150 optionstring +=
"&"+key+
"="+selected;
152 else if (key==
"visible"){
153 var checked=$(
id+
" .cond_visible")[0].checked;
154 var arg= (checked ?
"1" :
"0");
155 optionstring +=
"&"+key+
"="+arg;
157 else if (key==
"labeldraw"){
158 var checked=$(
id+
" .cond_label")[0].checked;
159 var arg= (checked ?
"1" :
"0");
160 this.cond.fbLabelDraw=arg;
161 optionstring +=
"&"+key+
"="+arg;
163 else if (key==
"limitsdraw"){
164 var checked=$(
id+
" .cond_limits")[0].checked;
165 var arg= (checked ?
"1" :
"0");
166 this.cond.fbLimitsDraw=arg;
167 optionstring +=
"&"+key+
"="+arg;
169 else if (key==
"intdraw"){
170 var checked=$(
id+
" .cond_integr")[0].checked;
171 var arg= (checked ?
"1" :
"0");
172 this.cond.fbIntDraw=arg;
173 optionstring +=
"&"+key+
"="+arg;
175 else if (key==
"xmeandraw"){
176 var checked=$(
id+
" .cond_xmean")[0].checked;
177 var arg= (checked ?
"1" :
"0");
178 this.cond.fbXMeanDraw=arg;
179 optionstring +=
"&"+key+
"="+arg;
181 else if (key==
"xrmsdraw"){
182 var checked=$(
id+
" .cond_xrms")[0].checked;
183 var arg= (checked ?
"1" :
"0");
184 this.cond.fbXRMSDraw=arg;
185 optionstring +=
"&"+key+
"="+arg;
187 else if (key==
"ymeandraw"){
188 var checked=$(
id+
" .cond_ymean")[0].checked;
189 var arg= (checked ?
"1" :
"0");
190 this.cond.fbYMeanDraw=arg;
191 optionstring +=
"&"+key+
"="+arg;
193 else if (key==
"yrmsdraw"){
194 var checked=$(
id+
" .cond_yrms")[0].checked;
195 var arg= (checked ?
"1" :
"0");
196 this.cond.fbYRMSDraw=arg;
197 optionstring +=
"&"+key+
"="+arg;
199 else if (key==
"xmaxdraw"){
200 var checked=$(
id+
" .cond_maxx")[0].checked;
201 var arg= (checked ?
"1" :
"0");
202 this.cond.fbXMaxDraw=arg;
203 optionstring +=
"&"+key+
"="+arg;
206 else if (key==
"ymaxdraw"){
207 var checked=$(
id+
" .cond_maxy")[0].checked;
208 var arg= (checked ?
"1" :
"0");
209 this.cond.fbYMaxDraw=arg;
210 optionstring +=
"&"+key+
"="+arg;
212 else if (key==
"cmaxdraw"){
213 var checked=$(
id+
" .cond_max")[0].checked;
214 var arg= (checked ?
"1" :
"0");
215 this.cond.fbCMaxDraw=arg;
216 optionstring +=
"&"+key+
"="+arg;
219 console.log(
"Warning: EvaluateChanges found unknown key:%s", key);
225 console.log(
"Resulting option string:%s", optionstring);
231 GO4.ConditionEditor.prototype.CheckResize =
function() {
240 GO4.ConditionEditor.prototype.ChangePolygonDimension =
function() {
246 var
id =
"#"+this.divid;
247 var oldpoints=this.cond.fxCut.fNpoints;
248 var npoints=$(
id+
" .cut_points")[0].value;
249 console.log(
"ChangePolygonDimension with numpoints="+npoints+
", oldpoints="+oldpoints);
251 if (this.cond.fxCut != null) {
253 $(
id +
" .cut_values tbody").html(
"");
254 if (npoints > oldpoints) {
257 for (i = 0; i < oldpoints - 1; i++) {
258 var x = this.cond.fxCut.fX[i];
259 var y = this.cond.fxCut.fY[i];
260 $(
id +
" .cut_values tbody")
262 "<tr><td><input type='text' value='"
264 +
"'/></td> <td> <input type='text' value='"
265 + y +
"'/> </td></tr>");
266 console.log(
"i:" + i +
", X=" + x +
" Y=" + y);
269 var insx = this.cond.fxCut.fX[oldpoints - 2];
270 var insy = this.cond.fxCut.fY[oldpoints - 2];
271 for (i = oldpoints - 1; i < npoints - 1; i++) {
272 $(
id +
" .cut_values tbody")
274 "<tr><td><input type='text' value='"
276 +
"'/></td> <td> <input type='text' value='"
277 + insy +
"'/> </td></tr>");
278 console.log(
"i:" + i +
", X=" + insx +
" Y=" + insy);
282 var lastx = this.cond.fxCut.fX[oldpoints - 1];
283 var lasty = this.cond.fxCut.fY[oldpoints - 1];
284 $(
id +
" .cut_values tbody").append(
285 "<tr><td><input type='text' value='" + lastx
286 +
"'/></td> <td> <input type='text' value='"
287 + lasty +
"'/> </td></tr>");
288 console.log(
"i:" + npoints - 1 +
", X=" + lastx +
" Y=" + lasty);
294 for (i = 0; i < npoints - 1; i++) {
295 var x = this.cond.fxCut.fX[i];
296 var y = this.cond.fxCut.fY[i];
297 $(
id +
" .cut_values tbody")
299 "<tr><td><input type='text' value='"
301 +
"'/></td> <td> <input type='text' value='"
302 + y +
"'/> </td></tr>");
303 console.log(
"i:" + i +
", X=" + x +
" Y=" + y);
307 var lastx = this.cond.fxCut.fX[oldpoints - 1];
308 var lasty = this.cond.fxCut.fY[oldpoints - 1];
309 $(
id +
" .cut_values tbody").append(
310 "<tr><td><input type='text' value='" + lastx
311 +
"'/></td> <td> <input type='text' value='"
312 + lasty +
"'/> </td></tr>");
313 console.log(
"i:" + npoints - 1 +
", X=" + lastx +
" Y=" + lasty);
320 this.MarkChanged(
"polygon");
323 GO4.ConditionEditor.prototype.refreshEditor =
function() {
325 var
id =
"#"+this.divid;
326 var cond = this.cond;
328 $(
id+
" .cond_name").text(cond.fName);
329 $(
id+
" .cond_type").text(cond._typename);
333 $(
id+
" .cond_execmode").val(0);
337 $(
id+
" .cond_execmode").val(1);
339 $(
id+
" .cond_execmode").val(2);
341 $(
id+
" .cond_execmode").selectmenu(
"refresh");
342 $(
id+
" .cond_execmode").selectmenu(
"option",
"width",
"100%");
344 $(
id+
" .cond_invertmode").val(0);
346 $(
id+
" .cond_invertmode").val(1);
348 $(
id+
" .cond_invertmode").selectmenu(
"refresh");
349 $(
id+
" .cond_invertmode").selectmenu(
"option",
"width",
"100%");
352 $(
id+
" .cond_xmin").val(cond.fLow1).change(
function(){ editor.MarkChanged(
"limits")});
353 $(
id+
" .cond_xmax").val(cond.fUp1).change(
function(){ editor.MarkChanged(
"limits")});
355 $(
id+
" .cond_ymin").val(cond.fLow2).change(
function(){editor.MarkChanged(
"limits")});
356 $(
id+
" .cond_ymax").val(cond.fUp2).change(
function(){ editor.MarkChanged(
"limits")});
358 $(
id+
" .cond_ymin").prop(
'disabled',
true);
359 $(
id+
" .cond_ymax").prop(
'disabled',
true);
363 $(
id+
" .cond_tabs").tabs(
"disable", 0 );
364 $(
id+
" .cond_tabs").tabs(
"enable", 1 );
365 if (this.cond.fxCut != null) {
366 var numpoints=this.cond.fxCut.fNpoints;
367 console.log(
"refreshEditor: npoints="+numpoints);
368 $(
id+
" .cut_points").val(numpoints);
369 $(
id +
" .cut_values tbody").html(
"");
372 for(i = 0; i < numpoints; i++) {
373 var x= this.cond.fxCut.fX[i];
374 var y= this.cond.fxCut.fY[i];
375 $(
id +
" .cut_values tbody").append(
"<tr><td><input type='text' value='" + x +
"'/></td> <td> <input type='text' value='" + y +
"'/> </td></tr>");
376 console.log(
"i:"+i+
", X="+x+
" Y="+y);
378 $(
id +
" .cut_values tbody").change(
function(){ editor.MarkChanged(
"polygon")});
381 if(this.isEllipseCond()) {
382 $(
id+
" .cond_tabs").tabs(
"enable", 2 );
383 var numpoints=this.cond.fiResolution;
384 $(
id+
" .cond_ellipse_points").val(numpoints);
385 $(
id+
" .cond_ellipse_cx").val(cond.fdCenterX).change(
function(){ editor.MarkChanged(
"ellicx")});
386 $(
id+
" .cond_ellipse_cy").val(cond.fdCenterY).change(
function(){ editor.MarkChanged(
"ellicy")});
387 $(
id+
" .cond_ellipse_a1").val(cond.fdRadius1).change(
function(){ editor.MarkChanged(
"ellia1")});
388 $(
id+
" .cond_ellipse_a2").val(cond.fdRadius2).prop(
'disabled', cond.fbIsCircle).change(
function(){ editor.MarkChanged(
"ellia2")});
389 $(
id+
" .cond_ellipse_theta").val(cond.fdTheta).prop(
'disabled', cond.fbIsCircle).change(
function(){
390 editor.MarkChanged(
"ellith");
391 $(
id+
" .cond_ellipse_theta_slider").slider(
"option",
"value", $(
this)[0].value % 360);
392 console.log(
"ellipse theta value="+$(
this)[0].value);
396 var options = $(
id+
" .cond_ellipse_iscircle")[0].options;
397 for ( var i = 0; i < options.length; i++){
398 options[i].selected = (options[i].value == cond.fiShapeType);
400 $(
id+
" .cond_ellipse_iscircle").selectmenu(
'refresh',
true).selectmenu(
"option",
"width",
"80%");;
405 $(
id +
" .cond_ellipse_theta_slider")
411 disabled: cond.fbIsCircle,
412 change :
function(event, ui) {
413 editor.MarkChanged(
"ellith");
414 $(
id +
" .cond_ellipse_theta").val(ui.value);
415 console.log(
"slider changed to" + ui.value);
417 stop :
function(event, ui) {
418 editor.MarkChanged(
"ellith");
419 console.log(
"sliderstopped.");
430 console.log(
"refreshEditor: - NO POLYGON CUT");
431 $(
id+
" .cond_tabs").tabs(
"enable", 0 );
432 $(
id+
" .cond_tabs").tabs(
"disable", 1 );
433 $(
id+
" .cond_tabs").tabs(
"disable", 2 );
440 $(
id+
" .cond_counts").text(cond.fiCounts);
441 $(
id+
" .cond_true").text(cond.fiTrueCounts);
442 $(
id+
" .cond_percent").text((cond.fiCounts > 0 ? 100. * cond.fiTrueCounts / cond.fiCounts : 0.).toFixed(2) +
"%");
448 $(
id+
" .cond_visible")
449 .prop(
'checked', cond.fbVisible)
450 .click(
function() { cond.fbVisible = this.checked; editor.MarkChanged(
"visible")});
451 $(
id+
" .cond_limits")
452 .prop(
'checked', cond.fbLimitsDraw)
453 .click(
function() { cond.fbLimitsDraw = this.checked; editor.MarkChanged(
"limitsdraw")});
456 .prop(
'checked', cond.fbLabelDraw)
457 .click(
function() { cond.fbLabelDraw = this.checked; editor.MarkChanged(
"labeldraw")});
460 $(
id+
" .cond_integr")
461 .prop(
'checked', cond.fbIntDraw)
462 .click(
function() { cond.fbIntDraw = this.checked; editor.MarkChanged(
"intdraw")});
465 .prop(
'checked', cond.fbXMaxDraw)
466 .click(
function() { cond.fbXMaxDraw = this.checked; editor.MarkChanged(
"xmaxdraw")});
469 .prop(
'checked', cond.fbCMaxDraw)
470 .click(
function() { cond.fbCMaxDraw = this.checked; editor.MarkChanged(
"cmaxdraw")});
473 .prop(
'checked', cond.fbYMaxDraw)
474 .click(
function() { cond.fbYMaxDraw = this.checked; editor.MarkChanged(
"ymaxdraw")});
477 .prop(
'checked', cond.fbXMeanDraw)
478 .click(
function() { cond.fbXMeanDraw = this.checked; editor.MarkChanged(
"xmeandraw")});
481 .prop(
'checked', cond.fbXRMSDraw)
482 .click(
function() { cond.fbXRMSDraw = this.checked; editor.MarkChanged(
"xrmsdraw")});
485 .prop(
'checked', cond.fbYMeanDraw)
486 .click(
function() { cond.fbYMeanDraw = this.checked; editor.MarkChanged(
"ymeandraw")});
489 .prop(
'checked', cond.fbYRMSDraw)
490 .click(
function() { cond.fbYRMSDraw = this.checked; editor.MarkChanged(
"yrmsdraw")});
493 editor.ClearChanges();
506 GO4.ConditionEditor.prototype.fillEditor =
function() {
507 var
id =
"#"+this.divid;
509 var cond = this.cond;
510 console.log(
"GO4.ConditionEditor.prototype.fillEditor " + this.cond.fName);
515 $(
id+
" .cond_tabs").tabs();
518 $(
id +
" .cond_execmode").selectmenu({
519 change :
function(event, ui) {
520 editor.MarkChanged(
"resultmode");
523 $(
id +
" .cond_invertmode").selectmenu({
524 change :
function(event, ui) {
525 editor.MarkChanged(
"invertmode");
529 if(this.isEllipseCond()) {
530 $(
id+
" .cond_ellipse_iscircle").selectmenu({
531 change :
function(event, ui) {
532 cond.fiShapeType = ui.item.value;
533 if(cond.fiShapeType == 2)
536 $(
id+
" .cond_ellipse_a2").prop(
'disabled',
true);
537 $(
id+
" .cond_ellipse_theta").prop(
'disabled',
true);
538 $(
id +
" .cond_ellipse_theta_slider").slider(
"disable");
539 $(
id +
"cond_ellipse_points").prop(
'disabled',
false);
541 else if(cond.fiShapeType == 3)
544 $(
id+
" .cond_ellipse_a2").prop(
'disabled',
false);
545 $(
id+
" .cond_ellipse_theta").prop(
'disabled',
false);
546 $(
id +
" .cond_ellipse_theta_slider").slider(
"enable");
547 $(
id +
"cond_ellipse_points").prop(
'disabled',
false);
551 else if(cond.fiShapeType == 4)
554 $(
id+
" .cond_ellipse_a2").prop(
'disabled',
false);
555 $(
id+
" .cond_ellipse_theta").prop(
'disabled',
false);
556 $(
id +
" .cond_ellipse_theta_slider").slider(
"enable");
557 $(
id +
"cond_ellipse_points").prop(
'disabled',
true);
562 $(
id+
" .cond_ellipse_a2").prop(
'disabled',
true);
563 $(
id+
" .cond_ellipse_theta").prop(
'disabled',
true);
564 $(
id +
" .cond_ellipse_theta_slider").slider(
"disable");
565 $(
id +
"cond_ellipse_points").prop(
'disabled',
false);
569 editor.MarkChanged(
"ellishape");
575 $(
id+
" .buttonGetCondition")
576 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}})
578 console.log(
"update item = " + editor.GetItemName());
579 if (JSROOT.hpainter) JSROOT.hpainter.display(editor.GetItemName());
580 else console.log(
"hierarhy painter object not found!");
583 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/right.png)");
587 $(
id+
" .buttonSetCondition")
588 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}})
591 options=editor.EvaluateChanges(options);
592 console.log(
"set - condition "+ editor.GetItemName()+
", options="+options);
593 editor.DabcCommand(
"UpdateFromUrl",options,
function(result) {
594 console.log(result ?
"set condition done. " :
"set condition FAILED.");
595 if(result) editor.ClearChanges();
599 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/left.png)");
602 $(
id+
" .buttonChangeLabel")
603 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}}).click()
605 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/info1.png)");
607 $(
id+
" .buttonDrawCondition")
608 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}})
612 if (JSROOT.hpainter) {
613 editor.EvaluateChanges(
"");
615 if (JSROOT.hpainter.updateOnOtherFrames(editor, editor.cond))
return;
617 JSROOT.hpainter.drawOnSuitableHistogram(editor, editor.cond, editor.cond.fiDim==2);
625 var baseurl = editor.GetItemName() +
"/";
626 var drawurl = baseurl +
"draw.htm", editorurl = baseurl +
"draw.htm?opt=editor";
627 console.log(
"draw condition to next window with url="+drawurl);
629 window.open(drawurl,
'_blank');
643 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/chart.png)");
646 $(
id+
" .buttonClearCondition")
647 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}})
649 console.log(
"clearing counters...");
650 var options=
"&resetcounters=1";
651 editor.DabcCommand(
"UpdateFromUrl",options,
function(result) {
652 console.log(result ?
"reset condition counters done. " :
"reset condition counters FAILED.");
654 if(JSROOT.hpainter) JSROOT.hpainter.display(editor.GetItemName());
655 else console.log(
"hpainter object not found!");
660 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/clear.png)");
665 $(
id+
" .cut_points").spinner({
670 change:
function( event, ui ) {editor.ChangePolygonDimension();
672 stop:
function( event, ui ) {editor.ChangePolygonDimension();
676 $(
id+
" .cond_ellipse_points").spinner({
681 change:
function( event, ui ) {editor.MarkChanged(
"ellinpts");console.log(
"ellipse points changed.");
683 stop:
function( event, ui ) {editor.MarkChanged(
"ellinpts");console.log(
"ellipse points stopped.");
687 this.refreshEditor();
693 GO4.ConditionEditor.prototype.drawEditor =
function(divid) {
696 $(
"#"+divid).empty();
697 $(
"#"+divid).load(GO4.source_dir +
"html/condeditor.htm",
"",
698 function() { pthis.SetDivId(divid); pthis.fillEditor(); pthis.DrawingReady(); });
703 GO4.ConditionEditor.prototype.RedrawPad =
function(resize) {
704 this.refreshEditor();
707 GO4.ConditionEditor.prototype.UpdateObject =
function(obj) {
708 if (obj._typename !=
this.cond._typename)
return false;
710 this.cond= JSROOT.clone(obj);
718 GO4.ConditionPainter =
function(cond) {
719 JSROOT.TObjectPainter.call(
this, cond);
724 GO4.ConditionPainter.prototype = Object.create(JSROOT.TObjectPainter.prototype);
726 GO4.ConditionPainter.prototype.Test =
function(x,y) {
729 if (!cond.fbEnabled)
return cond.fbResult;
732 return cond.fxCut.IsInside(x,y) ? cond.fbTrue : cond.fbFalse;
734 if ((x < cond.fLow1) || (x > cond.fUp1))
return cond.fbFalse;
737 if ((y < cond.fLow2) || (y > cond.fUp2))
return cond.fbFalse;
743 GO4.ConditionPainter.prototype.GetObject =
function() {
747 GO4.ConditionPainter.prototype.isPolyCond =
function() {
748 return ((this.cond._typename ==
"TGo4PolyCond") || (this.cond._typename ==
"TGo4ShapedCond"));
751 GO4.ConditionPainter.prototype.isEllipseCond =
function() {
752 return (this.cond._typename ==
"TGo4ShapedCond");
756 GO4.ConditionPainter.prototype.drawCondition =
function() {
759 if (this.cond.fxCut != null) {
762 var cut=this.cond.fxCut;
763 this.ForEachPainter(
function(p) {
764 if (p.obj_typename !=
"TCutG")
return;
765 console.log(
"Find TCutG painter");
772 this.cond.fxCut.fFillStyle = 3006;
773 this.cond.fxCut.fFillColor = 2;
774 JSROOT.draw(this.divid, this.cond.fxCut,
"LF");
781 var w = this.frame_width(),
782 h = this.frame_height(),
783 main = this.main_painter();
785 if (!
main.grx || !
main.gry)
main = this.frame_painter();
787 if ((this.cond.fFillStyle==1001) && (
this.cond.fFillColor==19)) {
788 this.cond.fFillStyle = 3006;
789 this.cond.fFillColor = 2;
792 var fill = this.createAttFill(this.cond);
793 var line = JSROOT.Painter.createAttLine(this.cond);
795 this.draw_g.attr(
"class",
"cond_container");
797 var ndim = this.cond.fiDim;
799 this.draw_g.append(
"svg:rect")
800 .attr(
"x",
main.grx(
this.cond.fLow1))
801 .attr(
"y", (ndim==1) ? 0 :
main.gry(this.cond.fUp2))
802 .attr(
"width",
main.grx(
this.cond.fUp1) -
main.grx(this.cond.fLow1))
803 .attr(
"height", (ndim==1) ? h :
main.gry(this.cond.fLow2) -
main.gry(this.cond.fUp2))
808 GO4.ConditionPainter.prototype.drawLabel =
function() {
809 if (!this.cond.fbLabelDraw)
return;
811 var pave_painter = this.FindPainterFor(this.pave);
813 if (pave_painter == null) {
814 this.pave = JSROOT.Create(
"TPaveStats");
815 this.pave.fName =
"stats_" + this.cond.fName;
816 jQuery.extend(this.pave, { fX1NDC: 0.1, fY1NDC: 0.4, fX2NDC: 0.4, fY2NDC: 0.65, fBorderSize: 1, fFillColor: 0, fFillStyle: 1001 });
817 jQuery.extend(this.pave, JSROOT.gStyle.StatText);
818 jQuery.extend(this.pave, JSROOT.gStyle.StatFill);
823 this.pave.AddText(this.cond.fName);
825 this.pave.AddText(
"Counts = " + this.cond.fiCounts);
827 if (this.cond.fbLimitsDraw)
829 var r = this.cond.fxCut.ComputeRange();
830 this.pave.AddText(
"Xmin = " + r.xmin);
831 this.pave.AddText(
"Xmax = " + r.xmax);
832 this.pave.AddText(
"Ymin = " + r.ymin);
833 this.pave.AddText(
"Ymax = " + r.ymax);
835 this.pave.AddText(
"Xmin = " + this.cond.fLow1);
836 this.pave.AddText(
"Xmax = " + this.cond.fUp1);
837 if (this.cond.fiDim==2) {
838 this.pave.AddText(
"Ymin = " + this.cond.fLow2);
839 this.pave.AddText(
"Ymax = " + this.cond.fUp2);
844 var cond = this.cond;
846 if (!(
'FFormat' in JSROOT))
847 JSROOT.FFormat =
function(value, fmt) {
848 if (fmt ==
'14.7g')
return value.toFixed(1);
849 return value.toFixed(4);
852 var stat = this.main_painter().CountStat(
function(x,y) {
return painter.Test(x,y); });
854 if (this.cond.fbIntDraw) this.pave.AddText(
"Integral = " + JSROOT.FFormat(stat.integral,
"14.7g"));
856 if (this.cond.fbXMeanDraw) this.pave.AddText(
"Mean x = " + JSROOT.FFormat(stat.meanx,
"6.4g"));
858 if (this.cond.fbXRMSDraw) this.pave.AddText(
"RMS x = " + JSROOT.FFormat(stat.rmsx,
"6.4g"));
860 if (this.cond.fiDim==2) {
861 if (this.cond.fbYMeanDraw) this.pave.AddText(
"Mean y = " + JSROOT.FFormat(stat.meany,
"6.4g"));
862 if (this.cond.fbYRMSDraw) this.pave.AddText(
"RMS y = " + JSROOT.FFormat(stat.rmsy,
"6.4g"));
865 if (this.cond.fbXMaxDraw) this.pave.AddText(
"X max = " + JSROOT.FFormat(stat.xmax,
"6.4g"));
867 if (this.cond.fiDim==2)
868 if (this.cond.fbYMaxDraw) this.pave.AddText(
"Y max = " + JSROOT.FFormat(stat.ymax,
"6.4g"));
869 if (this.cond.fbCMaxDraw) this.pave.AddText(
"C max = " + JSROOT.FFormat(stat.wmax,
"14.7g"));
871 if (pave_painter == null)
872 pave_painter = JSROOT.draw(this.divid, this.pave,
"");
874 pave_painter.Redraw();
877 GO4.ConditionPainter.prototype.RedrawObject =
function(obj) {
878 if (this.UpdateObject(obj))
882 GO4.ConditionPainter.prototype.UpdateObject =
function(obj) {
883 if (obj._typename !=
this.cond._typename)
return false;
885 this.cond = JSROOT.clone(obj);
890 GO4.ConditionPainter.prototype.Redraw =
function() {
891 this.drawCondition();
895 GO4.drawGo4Cond =
function(divid, cond, option, painter) {
897 if (option==
'same') {
898 var condpainter =
new GO4.ConditionPainter(cond);
899 if (painter) condpainter = JSROOT.extend(painter, condpainter);
900 condpainter.SetDivId(divid);
901 condpainter.drawCondition();
902 condpainter.drawLabel();
903 return condpainter.DrawingReady();
906 if ((cond.fxHistoName==
"") || (option==
'editor')) {
908 var h = $(
"#"+divid).height(), w = $(
"#"+divid).width();
909 if ((h<10) && (w>10)) $(
"#"+divid).height(w*0.4);
910 var editor =
new GO4.ConditionEditor(cond);
911 if (painter) editor = JSROOT.extend(painter, editor);
912 return editor.drawEditor(divid);
917 if (JSROOT.hpainter==null) {
918 $(
'#'+divid).append(
"<br/>Error - did not found hierarchy painter");
922 var histofullpath = null;
924 JSROOT.hpainter.ForEach(
function(h) {
925 if ((h[
'_name'] == cond.fxHistoName) && (h[
'_kind'].indexOf(
"ROOT.TH")==0)) {
926 histofullpath = JSROOT.hpainter.itemFullName(h);
931 if (histofullpath == null) {
932 $(
'#'+divid).append(
"<br/>Error - did not found histogram " + cond.fxHistoName);
934 histofullpath =
"../../Histograms/" + cond.fxHistoName;
936 JSROOT.hpainter.Find({ name: histofullpath, force:
true})[
'_kind'] =
"ROOT.TH1I";
938 console.log(
"Try histogram" + histofullpath);
941 $(
'#'+divid).append(
"<br/>Drawing histogram " + histofullpath);
943 $(
'#'+divid).empty();
945 var condpainter =
new GO4.ConditionPainter(cond);
946 if (painter) condpainter = JSROOT.extend(painter, condpainter);
948 JSROOT.hpainter.display(histofullpath,
"divid:" + divid,
function(res) {
949 if (res==null)
return console.log(
"fail to get histogram " + histofullpath);
950 condpainter.SetDivId(divid);
951 condpainter.drawCondition();
952 condpainter.drawLabel();
953 condpainter.DrawingReady();
function GO4 ConditionEditor prototype isPolyCond
int main(int argc, char **argv)
function GO4 ParameterEditor prototype CheckResize