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);
26 GO4.ConditionEditor.prototype.isPolyCond =
function() {
27 return ((this.cond._typename ==
"TGo4PolyCond") || (this.cond._typename ==
"TGo4ShapedCond"));
30 GO4.ConditionEditor.prototype.isEllipseCond =
function() {
31 return (this.cond._typename ==
"TGo4ShapedCond");
34 GO4.ConditionEditor.prototype.DabcCommand =
function(cmd, option, callback) {
36 if (this.GetItemName())
37 pre = this.GetItemName() +
"/";
39 pre +=
"exe.json\?method=";
40 var fullcom = pre + cmd + option;
42 JSROOT.NewHttpRequest(fullcom,
'text',
function(res) {
43 console.log(
"DabcCommand completed.");
49 GO4.ConditionEditor.prototype.MarkChanged =
function(key) {
51 for (var index = 0; index < this.changes.length; index++) {
52 if (this.changes[index]== key)
return;
54 this.changes.push(key);
55 console.log(
"Mark changed :%s", key);
56 var
id =
"#" + this.get_main_id();
58 $(
id+
" .buttonChangeLabel").show();
62 GO4.ConditionEditor.prototype.ClearChanges =
function() {
63 for (var index = 0; index < this.changes.length ; index++) {
64 var removed=this.changes.pop();
65 console.log(
"Clear changes removed :%s", removed);
67 var
id = this.get_main_id();
68 if (
id) $(
"#" +
id +
" .buttonChangeLabel").hide();
72 GO4.ConditionEditor.prototype.EvaluateChanges =
function(optionstring) {
73 var
id =
"#" + this.get_main_id();
75 var len=this.changes.length;
76 for (index = 0; index < len ; index++) {
78 var key=this.changes[index];
84 var xmin=$(
id+
" .cond_xmin")[0].value;
85 var xmax=$(
id+
" .cond_xmax")[0].value;
86 optionstring +=
"&xmin="+xmin+
"&xmax="+xmax;
87 this.cond.fLow1 = xmin;
88 this.cond.fUp1 = xmax;
89 if (this.cond.fiDim==2) {
90 var ymin=$(
id+
" .cond_ymin")[0].value;
91 var ymax=$(
id+
" .cond_ymax")[0].value;
92 this.cond.fLow2 = xmin;
93 this.cond.fUp2 = xmax;
94 optionstring +=
"&ymin="+ymin+
"&ymax="+ymax;
97 else if(key==
"polygon")
99 var npoints=$(
id+
" .cut_points")[0].value;
100 optionstring +=
"&npolygon="+npoints;
102 for(i=0; i<npoints; ++i)
104 var x = $(
id +
" .cut_values input").eq(2*i)[0].value;
105 var y = $(
id +
" .cut_values input").eq(2*i+1)[0].value;
106 optionstring +=
"&x"+i+
"="+x+
"&y"+i+
"="+y;
109 else if (key==
"ellinpts"){
110 var val=$(
id+
" .cond_ellipse_points")[0].value;
111 optionstring +=
"&"+key+
"="+val;
113 else if (key==
"ellicx"){
114 var val=$(
id+
" .cond_ellipse_cx")[0].value;
115 optionstring +=
"&"+key+
"="+val;
117 else if (key==
"ellicy"){
118 var val=$(
id+
" .cond_ellipse_cy")[0].value;
119 optionstring +=
"&"+key+
"="+val;
121 else if (key==
"ellia1"){
122 var val=$(
id+
" .cond_ellipse_a1")[0].value;
123 optionstring +=
"&"+key+
"="+val;
125 else if (key==
"ellia2"){
126 var val=$(
id+
" .cond_ellipse_a2")[0].value;
127 optionstring +=
"&"+key+
"="+val;
129 else if (key==
"ellishape"){
130 var arg=$(
id+
" .cond_ellipse_iscircle")[0].value;
131 optionstring +=
"&"+key+
"="+arg;
133 else if (key==
"ellith"){
134 var val=$(
id+
" .cond_ellipse_theta")[0].value;
135 optionstring +=
"&"+key+
"="+val;
137 else if (key==
"resultmode"){
138 var selected=$(
id+
" .cond_execmode")[0].value;
139 optionstring +=
"&"+key+
"="+selected;
141 else if (key==
"invertmode"){
142 var selected=$(
id+
" .cond_invertmode")[0].value;
143 optionstring +=
"&"+key+
"="+selected;
145 else if (key==
"visible"){
146 var checked=$(
id+
" .cond_visible")[0].checked;
147 var arg= (checked ?
"1" :
"0");
148 optionstring +=
"&"+key+
"="+arg;
150 else if (key==
"labeldraw"){
151 var checked=$(
id+
" .cond_label")[0].checked;
152 var arg= (checked ?
"1" :
"0");
153 this.cond.fbLabelDraw=arg;
154 optionstring +=
"&"+key+
"="+arg;
156 else if (key==
"limitsdraw"){
157 var checked=$(
id+
" .cond_limits")[0].checked;
158 var arg= (checked ?
"1" :
"0");
159 this.cond.fbLimitsDraw=arg;
160 optionstring +=
"&"+key+
"="+arg;
162 else if (key==
"intdraw"){
163 var checked=$(
id+
" .cond_integr")[0].checked;
164 var arg= (checked ?
"1" :
"0");
165 this.cond.fbIntDraw=arg;
166 optionstring +=
"&"+key+
"="+arg;
168 else if (key==
"xmeandraw"){
169 var checked=$(
id+
" .cond_xmean")[0].checked;
170 var arg= (checked ?
"1" :
"0");
171 this.cond.fbXMeanDraw=arg;
172 optionstring +=
"&"+key+
"="+arg;
174 else if (key==
"xrmsdraw"){
175 var checked=$(
id+
" .cond_xrms")[0].checked;
176 var arg= (checked ?
"1" :
"0");
177 this.cond.fbXRMSDraw=arg;
178 optionstring +=
"&"+key+
"="+arg;
180 else if (key==
"ymeandraw"){
181 var checked=$(
id+
" .cond_ymean")[0].checked;
182 var arg= (checked ?
"1" :
"0");
183 this.cond.fbYMeanDraw=arg;
184 optionstring +=
"&"+key+
"="+arg;
186 else if (key==
"yrmsdraw"){
187 var checked=$(
id+
" .cond_yrms")[0].checked;
188 var arg= (checked ?
"1" :
"0");
189 this.cond.fbYRMSDraw=arg;
190 optionstring +=
"&"+key+
"="+arg;
192 else if (key==
"xmaxdraw"){
193 var checked=$(
id+
" .cond_maxx")[0].checked;
194 var arg= (checked ?
"1" :
"0");
195 this.cond.fbXMaxDraw=arg;
196 optionstring +=
"&"+key+
"="+arg;
198 else if (key==
"ymaxdraw"){
199 var checked=$(
id+
" .cond_maxy")[0].checked;
200 var arg= (checked ?
"1" :
"0");
201 this.cond.fbYMaxDraw=arg;
202 optionstring +=
"&"+key+
"="+arg;
204 else if (key==
"cmaxdraw"){
205 var checked=$(
id+
" .cond_max")[0].checked;
206 var arg= (checked ?
"1" :
"0");
207 this.cond.fbCMaxDraw=arg;
208 optionstring +=
"&"+key+
"="+arg;
211 console.log(
"Warning: EvaluateChanges found unknown key:%s", key);
215 console.log(
"Resulting option string:%s", optionstring);
219 GO4.ConditionEditor.prototype.CheckResize =
function() {
223 GO4.ConditionEditor.prototype.ChangePolygonDimension =
function() {
229 var
id =
"#" + this.get_main_id();
230 var oldpoints=this.cond.fxCut.fNpoints;
231 var npoints=$(
id+
" .cut_points")[0].value;
232 console.log(
"ChangePolygonDimension with numpoints="+npoints+
", oldpoints="+oldpoints);
234 if (this.cond.fxCut != null) {
236 $(
id +
" .cut_values tbody").html(
"");
237 if (npoints > oldpoints) {
240 for (i = 0; i < oldpoints - 1; i++) {
241 var x = this.cond.fxCut.fX[i];
242 var y = this.cond.fxCut.fY[i];
243 $(
id +
" .cut_values tbody")
245 "<tr><td><input type='text' value='"
247 +
"'/></td> <td> <input type='text' value='"
248 + y +
"'/> </td></tr>");
249 console.log(
"i:" + i +
", X=" + x +
" Y=" + y);
252 var insx = this.cond.fxCut.fX[oldpoints - 2];
253 var insy = this.cond.fxCut.fY[oldpoints - 2];
254 for (i = oldpoints - 1; i < npoints - 1; i++) {
255 $(
id +
" .cut_values tbody")
257 "<tr><td><input type='text' value='"
259 +
"'/></td> <td> <input type='text' value='"
260 + insy +
"'/> </td></tr>");
261 console.log(
"i:" + i +
", X=" + insx +
" Y=" + insy);
265 var lastx = this.cond.fxCut.fX[oldpoints - 1];
266 var lasty = this.cond.fxCut.fY[oldpoints - 1];
267 $(
id +
" .cut_values tbody").append(
268 "<tr><td><input type='text' value='" + lastx
269 +
"'/></td> <td> <input type='text' value='"
270 + lasty +
"'/> </td></tr>");
271 console.log(
"i:" + npoints - 1 +
", X=" + lastx +
" Y=" + lasty);
277 for (i = 0; i < npoints - 1; i++) {
278 var x = this.cond.fxCut.fX[i];
279 var y = this.cond.fxCut.fY[i];
280 $(
id +
" .cut_values tbody")
282 "<tr><td><input type='text' value='"
284 +
"'/></td> <td> <input type='text' value='"
285 + y +
"'/> </td></tr>");
286 console.log(
"i:" + i +
", X=" + x +
" Y=" + y);
290 var lastx = this.cond.fxCut.fX[oldpoints - 1];
291 var lasty = this.cond.fxCut.fY[oldpoints - 1];
292 $(
id +
" .cut_values tbody").append(
293 "<tr><td><input type='text' value='" + lastx
294 +
"'/></td> <td> <input type='text' value='"
295 + lasty +
"'/> </td></tr>");
296 console.log(
"i:" + npoints - 1 +
", X=" + lastx +
" Y=" + lasty);
300 this.MarkChanged(
"polygon");
303 GO4.ConditionEditor.prototype.refreshEditor =
function() {
305 var
id =
"#" + this.get_main_id();
306 var cond = this.cond;
308 $(
id+
" .cond_name").text(cond.fName);
309 $(
id+
" .cond_type").text(cond._typename);
313 $(
id+
" .cond_execmode").val(0);
317 $(
id+
" .cond_execmode").val(1);
319 $(
id+
" .cond_execmode").val(2);
321 $(
id+
" .cond_execmode").selectmenu(
"refresh");
322 $(
id+
" .cond_execmode").selectmenu(
"option",
"width",
"100%");
324 $(
id+
" .cond_invertmode").val(0);
326 $(
id+
" .cond_invertmode").val(1);
328 $(
id+
" .cond_invertmode").selectmenu(
"refresh");
329 $(
id+
" .cond_invertmode").selectmenu(
"option",
"width",
"100%");
332 $(
id+
" .cond_xmin").val(cond.fLow1).change(
function(){ editor.MarkChanged(
"limits")});
333 $(
id+
" .cond_xmax").val(cond.fUp1).change(
function(){ editor.MarkChanged(
"limits")});
335 $(
id+
" .cond_ymin").val(cond.fLow2).change(
function(){editor.MarkChanged(
"limits")});
336 $(
id+
" .cond_ymax").val(cond.fUp2).change(
function(){ editor.MarkChanged(
"limits")});
338 $(
id+
" .cond_ymin").prop(
'disabled',
true);
339 $(
id+
" .cond_ymax").prop(
'disabled',
true);
343 $(
id+
" .cond_tabs").tabs(
"disable", 0 );
344 $(
id+
" .cond_tabs").tabs(
"enable", 1 );
345 if (this.cond.fxCut != null) {
346 var numpoints=this.cond.fxCut.fNpoints;
347 console.log(
"refreshEditor: npoints="+numpoints);
348 $(
id+
" .cut_points").val(numpoints);
349 $(
id +
" .cut_values tbody").html(
"");
352 for(i = 0; i < numpoints; i++) {
353 var x= this.cond.fxCut.fX[i];
354 var y= this.cond.fxCut.fY[i];
355 $(
id +
" .cut_values tbody").append(
"<tr><td><input type='text' value='" + x +
"'/></td> <td> <input type='text' value='" + y +
"'/> </td></tr>");
356 console.log(
"i:"+i+
", X="+x+
" Y="+y);
358 $(
id +
" .cut_values tbody").change(
function(){ editor.MarkChanged(
"polygon")});
361 if(this.isEllipseCond()) {
362 $(
id+
" .cond_tabs").tabs(
"enable", 2 );
363 var numpoints=this.cond.fiResolution;
364 $(
id+
" .cond_ellipse_points").val(numpoints);
365 $(
id+
" .cond_ellipse_cx").val(cond.fdCenterX).change(
function(){ editor.MarkChanged(
"ellicx")});
366 $(
id+
" .cond_ellipse_cy").val(cond.fdCenterY).change(
function(){ editor.MarkChanged(
"ellicy")});
367 $(
id+
" .cond_ellipse_a1").val(cond.fdRadius1).change(
function(){ editor.MarkChanged(
"ellia1")});
368 $(
id+
" .cond_ellipse_a2").val(cond.fdRadius2).prop(
'disabled', cond.fbIsCircle).change(
function(){ editor.MarkChanged(
"ellia2")});
369 $(
id+
" .cond_ellipse_theta").val(cond.fdTheta).prop(
'disabled', cond.fbIsCircle).change(
function(){
370 editor.MarkChanged(
"ellith");
371 $(
id+
" .cond_ellipse_theta_slider").slider(
"option",
"value", $(
this)[0].value % 360);
372 console.log(
"ellipse theta value="+$(
this)[0].value);
376 var options = $(
id+
" .cond_ellipse_iscircle")[0].options;
377 for ( var i = 0; i < options.length; i++){
378 options[i].selected = (options[i].value == cond.fiShapeType);
380 $(
id+
" .cond_ellipse_iscircle").selectmenu(
'refresh',
true).selectmenu(
"option",
"width",
"80%");;
383 $(
id +
" .cond_ellipse_theta_slider")
389 disabled: cond.fbIsCircle,
390 change :
function(event, ui) {
391 editor.MarkChanged(
"ellith");
392 $(
id +
" .cond_ellipse_theta").val(ui.value);
393 console.log(
"slider changed to" + ui.value);
395 stop :
function(event, ui) {
396 editor.MarkChanged(
"ellith");
397 console.log(
"sliderstopped.");
408 console.log(
"refreshEditor: - NO POLYGON CUT");
409 $(
id+
" .cond_tabs").tabs(
"enable", 0 );
410 $(
id+
" .cond_tabs").tabs(
"disable", 1 );
411 $(
id+
" .cond_tabs").tabs(
"disable", 2 );
415 $(
id+
" .cond_counts").text(cond.fiCounts);
416 $(
id+
" .cond_true").text(cond.fiTrueCounts);
417 $(
id+
" .cond_percent").text((cond.fiCounts > 0 ? 100. * cond.fiTrueCounts / cond.fiCounts : 0.).toFixed(2) +
"%");
423 $(
id+
" .cond_visible")
424 .prop(
'checked', cond.fbVisible)
425 .click(
function() { cond.fbVisible = this.checked; editor.MarkChanged(
"visible")});
426 $(
id+
" .cond_limits")
427 .prop(
'checked', cond.fbLimitsDraw)
428 .click(
function() { cond.fbLimitsDraw = this.checked; editor.MarkChanged(
"limitsdraw")});
431 .prop(
'checked', cond.fbLabelDraw)
432 .click(
function() { cond.fbLabelDraw = this.checked; editor.MarkChanged(
"labeldraw")});
435 $(
id+
" .cond_integr")
436 .prop(
'checked', cond.fbIntDraw)
437 .click(
function() { cond.fbIntDraw = this.checked; editor.MarkChanged(
"intdraw")});
440 .prop(
'checked', cond.fbXMaxDraw)
441 .click(
function() { cond.fbXMaxDraw = this.checked; editor.MarkChanged(
"xmaxdraw")});
444 .prop(
'checked', cond.fbCMaxDraw)
445 .click(
function() { cond.fbCMaxDraw = this.checked; editor.MarkChanged(
"cmaxdraw")});
448 .prop(
'checked', cond.fbYMaxDraw)
449 .click(
function() { cond.fbYMaxDraw = this.checked; editor.MarkChanged(
"ymaxdraw")});
452 .prop(
'checked', cond.fbXMeanDraw)
453 .click(
function() { cond.fbXMeanDraw = this.checked; editor.MarkChanged(
"xmeandraw")});
456 .prop(
'checked', cond.fbXRMSDraw)
457 .click(
function() { cond.fbXRMSDraw = this.checked; editor.MarkChanged(
"xrmsdraw")});
460 .prop(
'checked', cond.fbYMeanDraw)
461 .click(
function() { cond.fbYMeanDraw = this.checked; editor.MarkChanged(
"ymeandraw")});
464 .prop(
'checked', cond.fbYRMSDraw)
465 .click(
function() { cond.fbYRMSDraw = this.checked; editor.MarkChanged(
"yrmsdraw")});
468 editor.ClearChanges();
474 GO4.ConditionEditor.prototype.fillEditor =
function(divid) {
475 this.SetDivId(divid);
476 var
id =
"#" + this.get_main_id();
478 var cond = this.cond;
479 console.log(
"GO4.ConditionEditor.prototype.fillEditor " + this.cond.fName);
484 $(
id+
" .cond_tabs").tabs();
487 $(
id +
" .cond_execmode").selectmenu({
488 change :
function(event, ui) {
489 editor.MarkChanged(
"resultmode");
492 $(
id +
" .cond_invertmode").selectmenu({
493 change :
function(event, ui) {
494 editor.MarkChanged(
"invertmode");
498 if(this.isEllipseCond()) {
499 $(
id+
" .cond_ellipse_iscircle").selectmenu({
500 change :
function(event, ui) {
501 cond.fiShapeType = ui.item.value;
502 if(cond.fiShapeType == 2)
505 $(
id+
" .cond_ellipse_a2").prop(
'disabled',
true);
506 $(
id+
" .cond_ellipse_theta").prop(
'disabled',
true);
507 $(
id +
" .cond_ellipse_theta_slider").slider(
"disable");
508 $(
id +
"cond_ellipse_points").prop(
'disabled',
false);
510 else if(cond.fiShapeType == 3)
513 $(
id+
" .cond_ellipse_a2").prop(
'disabled',
false);
514 $(
id+
" .cond_ellipse_theta").prop(
'disabled',
false);
515 $(
id +
" .cond_ellipse_theta_slider").slider(
"enable");
516 $(
id +
"cond_ellipse_points").prop(
'disabled',
false);
520 else if(cond.fiShapeType == 4)
523 $(
id+
" .cond_ellipse_a2").prop(
'disabled',
false);
524 $(
id+
" .cond_ellipse_theta").prop(
'disabled',
false);
525 $(
id +
" .cond_ellipse_theta_slider").slider(
"enable");
526 $(
id +
"cond_ellipse_points").prop(
'disabled',
true);
531 $(
id+
" .cond_ellipse_a2").prop(
'disabled',
true);
532 $(
id+
" .cond_ellipse_theta").prop(
'disabled',
true);
533 $(
id +
" .cond_ellipse_theta_slider").slider(
"disable");
534 $(
id +
"cond_ellipse_points").prop(
'disabled',
false);
538 editor.MarkChanged(
"ellishape");
544 $(
id+
" .buttonGetCondition")
545 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}})
547 console.log(
"update item = " + editor.GetItemName());
548 if (JSROOT.hpainter) JSROOT.hpainter.display(editor.GetItemName());
549 else console.log(
"hierarhy painter object not found!");
552 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/right.png)");
556 $(
id+
" .buttonSetCondition")
557 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}})
560 options=editor.EvaluateChanges(options);
561 console.log(
"set - condition "+ editor.GetItemName()+
", options="+options);
562 editor.DabcCommand(
"UpdateFromUrl",options,
function(result) {
563 console.log(result ?
"set condition done. " :
"set condition FAILED.");
564 if(result) editor.ClearChanges();
568 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/left.png)");
571 $(
id+
" .buttonChangeLabel")
572 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}}).click()
574 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/info1.png)");
576 $(
id+
" .buttonDrawCondition")
577 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}})
581 if (JSROOT.hpainter) {
582 editor.EvaluateChanges(
"");
584 if (JSROOT.hpainter.updateOnOtherFrames(editor, editor.cond))
return;
586 JSROOT.hpainter.drawOnSuitableHistogram(editor, editor.cond, editor.cond.fiDim==2);
594 var baseurl = editor.GetItemName() +
"/";
595 var drawurl = baseurl +
"draw.htm", editorurl = baseurl +
"draw.htm?opt=editor";
596 console.log(
"draw condition to next window with url="+drawurl);
598 window.open(drawurl,
'_blank');
612 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/chart.png)");
615 $(
id+
" .buttonClearCondition")
616 .button({text:
false, icons: { primary:
"ui-icon-blank MyButtonStyle"}})
618 console.log(
"clearing counters...");
619 var options=
"&resetcounters=1";
620 editor.DabcCommand(
"UpdateFromUrl",options,
function(result) {
621 console.log(result ?
"reset condition counters done. " :
"reset condition counters FAILED.");
623 if(JSROOT.hpainter) JSROOT.hpainter.display(editor.GetItemName());
624 else console.log(
"hpainter object not found!");
629 .css(
'background-image',
"url(" + GO4.source_dir +
"icons/clear.png)");
631 $(
id+
" .cut_points").spinner({
636 change:
function( event, ui ) {editor.ChangePolygonDimension();
638 stop:
function( event, ui ) {editor.ChangePolygonDimension();
642 $(
id+
" .cond_ellipse_points").spinner({
647 change:
function( event, ui ) {editor.MarkChanged(
"ellinpts");console.log(
"ellipse points changed.");
649 stop:
function( event, ui ) {editor.MarkChanged(
"ellinpts");console.log(
"ellipse points stopped.");
653 this.refreshEditor();
661 GO4.ConditionEditor.prototype.drawEditor =
function(divid) {
664 .load(GO4.source_dir +
"html/condeditor.htm",
"",
this.fillEditor.bind(
this, divid));
668 GO4.ConditionEditor.prototype.RedrawPad =
function(resize) {
669 this.refreshEditor();
672 GO4.ConditionEditor.prototype.UpdateObject =
function(obj) {
673 if (obj._typename !=
this.cond._typename)
return false;
675 this.cond= JSROOT.clone(obj);
683 GO4.ConditionPainter =
function(cond) {
684 JSROOT.TObjectPainter.call(
this, cond);
689 GO4.ConditionPainter.prototype = Object.create(JSROOT.TObjectPainter.prototype);
691 GO4.ConditionPainter.prototype.Test =
function(x,y) {
694 if (!cond.fbEnabled)
return cond.fbResult;
697 return cond.fxCut.IsInside(x,y) ? cond.fbTrue : cond.fbFalse;
699 if ((x < cond.fLow1) || (x > cond.fUp1))
return cond.fbFalse;
702 if ((y < cond.fLow2) || (y > cond.fUp2))
return cond.fbFalse;
708 GO4.ConditionPainter.prototype.GetObject =
function() {
712 GO4.ConditionPainter.prototype.isPolyCond =
function() {
713 return ((this.cond._typename ==
"TGo4PolyCond") || (this.cond._typename ==
"TGo4ShapedCond"));
716 GO4.ConditionPainter.prototype.isEllipseCond =
function() {
717 return (this.cond._typename ==
"TGo4ShapedCond");
721 GO4.ConditionPainter.prototype.drawCondition =
function() {
724 if (this.cond.fxCut != null) {
727 var cut=this.cond.fxCut;
728 this.ForEachPainter(
function(p) {
729 if (p.obj_typename !=
"TCutG")
return;
730 console.log(
"Find TCutG painter");
737 this.cond.fxCut.fFillStyle = 3006;
738 this.cond.fxCut.fFillColor = 2;
739 JSROOT.draw(this.divid, this.cond.fxCut,
"LF");
746 var w = this.frame_width(),
747 h = this.frame_height(),
748 main = this.main_painter();
750 if (!
main.grx || !
main.gry)
main = this.frame_painter();
752 if ((this.cond.fFillStyle==1001) && (
this.cond.fFillColor==19)) {
753 this.cond.fFillStyle = 3006;
754 this.cond.fFillColor = 2;
757 var fill = this.createAttFill(this.cond);
758 var line = this.createAttLine(this.cond);
760 this.draw_g.attr(
"class",
"cond_container");
762 var ndim = this.cond.fiDim;
764 this.draw_g.append(
"svg:rect")
765 .attr(
"x",
main.grx(
this.cond.fLow1))
766 .attr(
"y", (ndim==1) ? 0 :
main.gry(this.cond.fUp2))
767 .attr(
"width",
main.grx(
this.cond.fUp1) -
main.grx(this.cond.fLow1))
768 .attr(
"height", (ndim==1) ? h :
main.gry(this.cond.fLow2) -
main.gry(this.cond.fUp2))
773 GO4.ConditionPainter.prototype.drawLabel =
function() {
774 if (!this.cond.fbLabelDraw)
return;
776 var pave_painter = this.FindPainterFor(this.pave);
778 if (pave_painter == null) {
779 this.pave = JSROOT.Create(
"TPaveStats");
780 this.pave.fName =
"stats_" + this.cond.fName;
781 jQuery.extend(this.pave, { fX1NDC: 0.1, fY1NDC: 0.4, fX2NDC: 0.4, fY2NDC: 0.65, fBorderSize: 1, fFillColor: 0, fFillStyle: 1001 });
782 jQuery.extend(this.pave, JSROOT.gStyle.StatText);
783 jQuery.extend(this.pave, JSROOT.gStyle.StatFill);
788 this.pave.AddText(this.cond.fName);
790 this.pave.AddText(
"Counts = " + this.cond.fiCounts);
792 if (this.cond.fbLimitsDraw)
794 var r = this.cond.fxCut.ComputeRange();
795 this.pave.AddText(
"Xmin = " + r.xmin);
796 this.pave.AddText(
"Xmax = " + r.xmax);
797 this.pave.AddText(
"Ymin = " + r.ymin);
798 this.pave.AddText(
"Ymax = " + r.ymax);
800 this.pave.AddText(
"Xmin = " + this.cond.fLow1);
801 this.pave.AddText(
"Xmax = " + this.cond.fUp1);
802 if (this.cond.fiDim==2) {
803 this.pave.AddText(
"Ymin = " + this.cond.fLow2);
804 this.pave.AddText(
"Ymax = " + this.cond.fUp2);
809 var cond = this.cond;
811 if (!(
'FFormat' in JSROOT))
812 JSROOT.FFormat =
function(value, fmt) {
813 if (fmt ==
'14.7g')
return value.toFixed(1);
814 return value.toFixed(4);
817 var stat = this.main_painter().CountStat(
function(x,y) {
return painter.Test(x,y); });
819 if (this.cond.fbIntDraw) this.pave.AddText(
"Integral = " + JSROOT.FFormat(stat.integral,
"14.7g"));
821 if (this.cond.fbXMeanDraw) this.pave.AddText(
"Mean x = " + JSROOT.FFormat(stat.meanx,
"6.4g"));
823 if (this.cond.fbXRMSDraw) this.pave.AddText(
"RMS x = " + JSROOT.FFormat(stat.rmsx,
"6.4g"));
825 if (this.cond.fiDim==2) {
826 if (this.cond.fbYMeanDraw) this.pave.AddText(
"Mean y = " + JSROOT.FFormat(stat.meany,
"6.4g"));
827 if (this.cond.fbYRMSDraw) this.pave.AddText(
"RMS y = " + JSROOT.FFormat(stat.rmsy,
"6.4g"));
830 if (this.cond.fbXMaxDraw) this.pave.AddText(
"X max = " + JSROOT.FFormat(stat.xmax,
"6.4g"));
832 if (this.cond.fiDim==2)
833 if (this.cond.fbYMaxDraw) this.pave.AddText(
"Y max = " + JSROOT.FFormat(stat.ymax,
"6.4g"));
834 if (this.cond.fbCMaxDraw) this.pave.AddText(
"C max = " + JSROOT.FFormat(stat.wmax,
"14.7g"));
836 if (pave_painter == null)
837 pave_painter = JSROOT.draw(this.divid, this.pave,
"");
839 pave_painter.Redraw();
842 GO4.ConditionPainter.prototype.RedrawObject =
function(obj) {
843 if (this.UpdateObject(obj))
847 GO4.ConditionPainter.prototype.UpdateObject =
function(obj) {
848 if (obj._typename !=
this.cond._typename)
return false;
850 this.cond = JSROOT.clone(obj);
855 GO4.ConditionPainter.prototype.Redraw =
function() {
856 this.drawCondition();
860 GO4.drawGo4Cond =
function(divid, cond, option) {
862 if (option==
'same') {
863 var condpainter =
new GO4.ConditionPainter(cond);
864 condpainter.SetDivId(divid);
865 condpainter.drawCondition();
866 condpainter.drawLabel();
867 return condpainter.DrawingReady();
870 if ((cond.fxHistoName==
"") || (option==
'editor')) {
872 var h = $(
"#"+divid).height(), w = $(
"#"+divid).width();
873 if ((h<10) && (w>10)) $(
"#"+divid).height(w*0.4);
874 var editor =
new GO4.ConditionEditor(cond);
875 return editor.drawEditor(divid);
880 if (JSROOT.hpainter==null) {
881 $(
'#'+divid).append(
"<br/>Error - did not found hierarchy painter");
885 var histofullpath = null;
887 JSROOT.hpainter.ForEach(
function(h) {
888 if ((h[
'_name'] == cond.fxHistoName) && (h[
'_kind'].indexOf(
"ROOT.TH")==0)) {
889 histofullpath = JSROOT.hpainter.itemFullName(h);
894 if (histofullpath == null) {
895 $(
'#'+divid).append(
"<br/>Error - did not found histogram " + cond.fxHistoName);
897 histofullpath =
"../../Histograms/" + cond.fxHistoName;
899 JSROOT.hpainter.Find({ name: histofullpath, force:
true})[
'_kind'] =
"ROOT.TH1I";
901 console.log(
"Try histogram" + histofullpath);
904 $(
'#'+divid).append(
"<br/>Drawing histogram " + histofullpath);
906 $(
'#'+divid).empty();
908 var condpainter =
new GO4.ConditionPainter(cond);
910 JSROOT.hpainter.display(histofullpath,
"divid:" + divid,
function(res) {
911 if (res==null)
return console.log(
"fail to get histogram " + histofullpath);
912 condpainter.SetDivId(divid);
913 condpainter.drawCondition();
914 condpainter.drawLabel();
915 condpainter.DrawingReady();
function GO4 ConditionEditor prototype isPolyCond
int main(int argc, char **argv)
function GO4 ParameterEditor prototype CheckResize