GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
condition.js
Go to the documentation of this file.
1 (function(){
2 
3  if (typeof JSROOT != "object") {
4  var e1 = new Error("condition.js requires JSROOT to be already loaded");
5  e1.source = "condition.js";
6  throw e1;
7  }
8 
9  if (typeof GO4 != "object") {
10  var e1 = new Error("condition.js requires GO4 to be already loaded");
11  e1.source = "condition.js";
12  throw e1;
13  }
14 
15  // =========================================================================================
16 
17  let BasePainter = JSROOT.BasePainter || JSROOT.TBasePainter;
18 
19  GO4.ConditionEditor = function(divid, cond) {
20  BasePainter.call(this, divid);
21  if (this.SetDivId) this.SetDivId(divid);
22  this.cond = cond;
23  this.changes = ["dummy", "init"];
24  this.ClearChanges();
25  }
26 
27  GO4.ConditionEditor.prototype = Object.create(BasePainter.prototype);
28 
29  GO4.ConditionEditor.prototype.isPolyCond = function() {
30  return ((this.cond._typename == "TGo4PolyCond") || (this.cond._typename == "TGo4ShapedCond"));
31  }
32 
33  GO4.ConditionEditor.prototype.isEllipseCond = function() {
34  return (this.cond._typename == "TGo4ShapedCond");
35  }
36 
37  // add identifier of changed element to list, make warning sign visible
38  GO4.ConditionEditor.prototype.MarkChanged = function(key) {
39  // first avoid duplicate keys:
40  for (var index = 0; index < this.changes.length; index++) {
41  if (this.changes[index]== key) return;
42  }
43  this.changes.push(key);
44  console.log("Mark changed :%s", key);
45  var id = "#" + this.get_main_id();
46 
47  $(id+" .buttonChangeLabel").show();// show warning sign
48  }
49 
50  // clear changed elements' ist, make warning sign invisible
51  GO4.ConditionEditor.prototype.ClearChanges = function() {
52  for (var index = 0; index < this.changes.length ; index++) {
53  var removed=this.changes.pop();
54  console.log("Clear changes removed :%s", removed);
55  }
56  var id = this.get_main_id();
57  if (id) $("#" + id + " .buttonChangeLabel").hide(); // hide warning sign
58  }
59 
60  // scan changed value list and return optionstring to be send to server
61  GO4.ConditionEditor.prototype.EvaluateChanges = function(optionstring) {
62  var id = "#" + this.get_main_id();
63  var index;
64  var len=this.changes.length;
65  for (index = 0; index < len ; index++) {
66  //var cursor=changes.pop();
67  var key=this.changes[index];
68  //console.log("Evaluate change key:%s", key);
69 
70  // here mapping of key to editor field:
71  if(key=="limits")
72  {
73  var xmin=$(id+" .cond_xmin")[0].value;
74  var xmax=$(id+" .cond_xmax")[0].value;
75  optionstring +="&xmin="+xmin+"&xmax="+xmax;
76  this.cond.fLow1 = xmin;
77  this.cond.fUp1 = xmax;
78  if (this.cond.fiDim==2) {
79  var ymin=$(id+" .cond_ymin")[0].value;
80  var ymax=$(id+" .cond_ymax")[0].value;
81  this.cond.fLow2 = xmin;
82  this.cond.fUp2 = xmax;
83  optionstring +="&ymin="+ymin+"&ymax="+ymax;
84  }
85  }
86  else if(key=="polygon")
87  {
88  var npoints=$(id+" .cut_points")[0].value;
89  optionstring +="&npolygon="+npoints;
90  // TODO: set display of polygon points
91  for(i=0; i<npoints; ++i)
92  {
93  var x = $(id + " .cut_values input").eq(2*i)[0].value;
94  var y = $(id + " .cut_values input").eq(2*i+1)[0].value;
95  optionstring +="&x"+i+"="+x+"&y"+i+"="+y;
96  }
97  }
98  else if (key=="ellinpts"){
99  var val=$(id+" .cond_ellipse_points")[0].value;
100  optionstring +="&"+key+"="+val;
101  }
102  else if (key=="ellicx"){
103  var val=$(id+" .cond_ellipse_cx")[0].value;
104  optionstring +="&"+key+"="+val;
105  }
106  else if (key=="ellicy"){
107  var val=$(id+" .cond_ellipse_cy")[0].value;
108  optionstring +="&"+key+"="+val;
109  }
110  else if (key=="ellia1"){
111  var val=$(id+" .cond_ellipse_a1")[0].value;
112  optionstring +="&"+key+"="+val;
113  }
114  else if (key=="ellia2"){
115  var val=$(id+" .cond_ellipse_a2")[0].value;
116  optionstring +="&"+key+"="+val;
117  }
118  else if (key=="ellishape"){
119  var arg=$(id+" .cond_ellipse_iscircle")[0].value;
120  optionstring +="&"+key+"="+arg;
121  }
122  else if (key=="ellith"){
123  var val=$(id+" .cond_ellipse_theta")[0].value;
124  optionstring +="&"+key+"="+val;
125  }
126  else if (key=="resultmode"){
127  var selected=$(id+" .cond_execmode")[0].value;
128  optionstring +="&"+key+"="+selected;
129  }
130  else if (key=="invertmode"){
131  var selected=$(id+" .cond_invertmode")[0].value;
132  optionstring +="&"+key+"="+selected;
133  }
134  else if (key=="visible"){
135  var checked=$(id+" .cond_visible")[0].checked;
136  var arg= (checked ? "1" : "0");
137  optionstring +="&"+key+"="+arg;
138  }
139  else if (key=="labeldraw"){
140  var checked=$(id+" .cond_label")[0].checked;
141  var arg= (checked ? "1" : "0");
142  this.cond.fbLabelDraw=arg;
143  optionstring +="&"+key+"="+arg;
144  }
145  else if (key=="limitsdraw"){
146  var checked=$(id+" .cond_limits")[0].checked;
147  var arg= (checked ? "1" : "0");
148  this.cond.fbLimitsDraw=arg;
149  optionstring +="&"+key+"="+arg;
150  }
151  else if (key=="intdraw"){
152  var checked=$(id+" .cond_integr")[0].checked;
153  var arg= (checked ? "1" : "0");
154  this.cond.fbIntDraw=arg;
155  optionstring +="&"+key+"="+arg;
156  }
157  else if (key=="xmeandraw"){
158  var checked=$(id+" .cond_xmean")[0].checked;
159  var arg= (checked ? "1" : "0");
160  this.cond.fbXMeanDraw=arg;
161  optionstring +="&"+key+"="+arg;
162  }
163  else if (key=="xrmsdraw"){
164  var checked=$(id+" .cond_xrms")[0].checked;
165  var arg= (checked ? "1" : "0");
166  this.cond.fbXRMSDraw=arg;
167  optionstring +="&"+key+"="+arg;
168  }
169  else if (key=="ymeandraw"){
170  var checked=$(id+" .cond_ymean")[0].checked;
171  var arg= (checked ? "1" : "0");
172  this.cond.fbYMeanDraw=arg;
173  optionstring +="&"+key+"="+arg;
174  }
175  else if (key=="yrmsdraw"){
176  var checked=$(id+" .cond_yrms")[0].checked;
177  var arg= (checked ? "1" : "0");
178  this.cond.fbYRMSDraw=arg;
179  optionstring +="&"+key+"="+arg;
180  }
181  else if (key=="xmaxdraw"){
182  var checked=$(id+" .cond_maxx")[0].checked;
183  var arg= (checked ? "1" : "0");
184  this.cond.fbXMaxDraw=arg;
185  optionstring +="&"+key+"="+arg;
186  }
187  else if (key=="ymaxdraw"){
188  var checked=$(id+" .cond_maxy")[0].checked;
189  var arg= (checked ? "1" : "0");
190  this.cond.fbYMaxDraw=arg;
191  optionstring +="&"+key+"="+arg;
192  }
193  else if (key=="cmaxdraw"){
194  var checked=$(id+" .cond_max")[0].checked;
195  var arg= (checked ? "1" : "0");
196  this.cond.fbCMaxDraw=arg;
197  optionstring +="&"+key+"="+arg;
198  }
199  else{
200  console.log("Warning: EvaluateChanges found unknown key:%s", key);
201  }
202 
203  }// for index
204  console.log("Resulting option string:%s", optionstring);
205  return optionstring;
206  }
207 
208  GO4.ConditionEditor.prototype.CheckResize = function() {}
209  GO4.ConditionEditor.prototype.checkResize = function() {}
210 
211 
212  GO4.ConditionEditor.prototype.ChangePolygonDimension = function() {
213  // this only changes display of condition, not condition itself!
214  // note that condition is still changed in analysis only by EvaluateChanges
215  // local condition copy is unchanged until we can display it somewhere.
216 
217  if(!this.isPolyCond()) return;
218  var id = "#" + this.get_main_id();
219  var oldpoints=this.cond.fxCut.fNpoints;
220  var npoints=$(id+" .cut_points")[0].value;
221  console.log("ChangePolygonDimension with numpoints="+npoints+", oldpoints="+oldpoints);
222  //if(npoints==oldpoints) return; // no dimension change, do nothing - disabled, error if we again go back to original condition dimension
223  if (this.cond.fxCut != null) {
224 
225  $(id + " .cut_values tbody").html(""); // clear old contents
226  if (npoints > oldpoints) {
227  // insert last but one point into table:
228  // first points are unchanged:
229  for (i = 0; i < oldpoints - 1; i++) {
230  var x = this.cond.fxCut.fX[i];
231  var y = this.cond.fxCut.fY[i];
232  $(id + " .cut_values tbody")
233  .append(
234  "<tr><td><input type='text' value='"
235  + x
236  + "'/></td> <td> <input type='text' value='"
237  + y + "'/> </td></tr>");
238  console.log("i:" + i + ", X=" + x + " Y=" + y);
239  }
240  // inserted points will reproduce values of last but one point:
241  var insx = this.cond.fxCut.fX[oldpoints - 2];
242  var insy = this.cond.fxCut.fY[oldpoints - 2];
243  for (i = oldpoints - 1; i < npoints - 1; i++) {
244  $(id + " .cut_values tbody")
245  .append(
246  "<tr><td><input type='text' value='"
247  + insx
248  + "'/></td> <td> <input type='text' value='"
249  + insy + "'/> </td></tr>");
250  console.log("i:" + i + ", X=" + insx + " Y=" + insy);
251  }
252  // final point is kept as last point of old polygon, should
253  // match first point for closed tcutg:
254  var lastx = this.cond.fxCut.fX[oldpoints - 1];
255  var lasty = this.cond.fxCut.fY[oldpoints - 1];
256  $(id + " .cut_values tbody").append(
257  "<tr><td><input type='text' value='" + lastx
258  + "'/></td> <td> <input type='text' value='"
259  + lasty + "'/> </td></tr>");
260  console.log("i:" + (npoints - 1) + ", X=" + lastx + " Y=" + lasty);
261 
262  }
263  else
264  {
265  // remove last but one point from table:
266  for (i = 0; i < npoints - 1; i++) {
267  var x = this.cond.fxCut.fX[i];
268  var y = this.cond.fxCut.fY[i];
269  $(id + " .cut_values tbody")
270  .append(
271  "<tr><td><input type='text' value='"
272  + x
273  + "'/></td> <td> <input type='text' value='"
274  + y + "'/> </td></tr>");
275  console.log("i:" + i + ", X=" + x + " Y=" + y);
276  }
277  // final point is kept as last point of old polygon, should
278  // match first point for closed tcutg:
279  var lastx = this.cond.fxCut.fX[oldpoints - 1];
280  var lasty = this.cond.fxCut.fY[oldpoints - 1];
281  $(id + " .cut_values tbody").append(
282  "<tr><td><input type='text' value='" + lastx
283  + "'/></td> <td> <input type='text' value='"
284  + lasty + "'/> </td></tr>");
285  console.log("i:" + (npoints - 1) + ", X=" + lastx + " Y=" + lasty);
286 
287  }
288  }
289  this.MarkChanged("polygon");
290  }
291 
292  GO4.ConditionEditor.prototype.refreshEditor = function() {
293  var editor = this;
294  var id = "#" + this.get_main_id();
295  var cond = this.cond;
296 
297  $(id+" .cond_name").text(cond.fName);
298  $(id+" .cond_type").text(cond._typename);
299 
300 
301  if(cond.fbEnabled) {
302  $(id+" .cond_execmode").val(0);
303  }
304  else{
305  if(cond.fbResult)
306  $(id+" .cond_execmode").val(1);
307  else
308  $(id+" .cond_execmode").val(2);
309  }
310  $(id+" .cond_execmode").selectmenu("refresh");
311  $(id+" .cond_execmode").selectmenu("option", "width", "100%"); // workaround for selecmenu refresh problem (increases width each time!)
312  if(cond.fbTrue)
313  $(id+" .cond_invertmode").val(0);
314  else
315  $(id+" .cond_invertmode").val(1);
316 
317  $(id+" .cond_invertmode").selectmenu("refresh");
318  $(id+" .cond_invertmode").selectmenu("option", "width", "100%"); // workaround for selecmenu refresh problem (increases width each time!)
319 
320 
321  $(id+" .cond_xmin").val(cond.fLow1).change(function(){ editor.MarkChanged("limits")});
322  $(id+" .cond_xmax").val(cond.fUp1).change(function(){ editor.MarkChanged("limits")});
323  if (cond.fiDim==2) {
324  $(id+" .cond_ymin").val(cond.fLow2).change(function(){editor.MarkChanged("limits")});
325  $(id+" .cond_ymax").val(cond.fUp2).change(function(){ editor.MarkChanged("limits")});
326  } else {
327  $(id+" .cond_ymin").prop('disabled', true);
328  $(id+" .cond_ymax").prop('disabled', true);
329  }
330 
331  if(this.isPolyCond()) {
332  $(id+" .cond_tabs").tabs( "disable", 0 ); // enable/disable by tab index
333  $(id+" .cond_tabs").tabs( "enable", 1 ); // enable/disable by tab index
334  if (this.cond.fxCut != null) {
335  var numpoints=this.cond.fxCut.fNpoints;
336  console.log("refreshEditor: npoints="+numpoints);
337  $(id+" .cut_points").val(numpoints); //.change(function(){ editor.MarkChanged("polygon")});
338  $(id + " .cut_values tbody").html("");
339 
340 
341  for(i = 0; i < numpoints; i++) {
342  var x= this.cond.fxCut.fX[i];
343  var y= this.cond.fxCut.fY[i];
344  $(id + " .cut_values tbody").append("<tr><td><input type='text' value='" + x + "'/></td> <td> <input type='text' value='" + y + "'/> </td></tr>");
345  console.log("i:"+i+", X="+x+" Y="+y);
346  }
347  $(id + " .cut_values tbody").change(function(){ editor.MarkChanged("polygon")});
348 
349  }
350  if(this.isEllipseCond()) {
351  $(id+" .cond_tabs").tabs( "enable", 2 ); // enable/disable by tab index
352  var numpoints=this.cond.fiResolution;
353  $(id+" .cond_ellipse_points").val(numpoints);
354  $(id+" .cond_ellipse_cx").val(cond.fdCenterX).change(function(){ editor.MarkChanged("ellicx")});
355  $(id+" .cond_ellipse_cy").val(cond.fdCenterY).change(function(){ editor.MarkChanged("ellicy")});
356  $(id+" .cond_ellipse_a1").val(cond.fdRadius1).change(function(){ editor.MarkChanged("ellia1")});
357  $(id+" .cond_ellipse_a2").val(cond.fdRadius2).prop('disabled', cond.fbIsCircle).change(function(){ editor.MarkChanged("ellia2")});
358  $(id+" .cond_ellipse_theta").val(cond.fdTheta).prop('disabled', cond.fbIsCircle).change(function(){
359  editor.MarkChanged("ellith");
360  $(id+" .cond_ellipse_theta_slider").slider( "option", "value", $(this)[0].value % 360);
361  console.log("ellipse theta value="+$(this)[0].value);
362  });
363 
364 
365  var options = $(id+" .cond_ellipse_iscircle")[0].options;
366  for ( var i = 0; i < options.length; i++){
367  options[i].selected = (options[i].value == cond.fiShapeType);
368  }
369  $(id+" .cond_ellipse_iscircle").selectmenu('refresh', true).selectmenu("option", "width", "80%");
370 
371 
372  $(id + " .cond_ellipse_theta_slider")
373  .slider({
374  min : 0,
375  max : 360,
376  step : 1,
377  value: cond.fdTheta,
378  disabled: cond.fbIsCircle,
379  change : function(event, ui) {
380  editor.MarkChanged("ellith");
381  $(id + " .cond_ellipse_theta").val(ui.value);
382  console.log("slider changed to" + ui.value);
383  },
384  stop : function(event, ui) {
385  editor.MarkChanged("ellith");
386  console.log("sliderstopped.");
387  }
388  })
389 
390  ;
391 
392  }
393 
394  }
395  else
396  {
397  console.log("refreshEditor: - NO POLYGON CUT");
398  $(id+" .cond_tabs").tabs( "enable", 0 );
399  $(id+" .cond_tabs").tabs( "disable", 1 ); // enable/disable by tab index
400  $(id+" .cond_tabs").tabs( "disable", 2 ); // enable/disable by tab index
401  }
402 
403 
404  $(id+" .cond_counts").text(cond.fiCounts);
405  $(id+" .cond_true").text(cond.fiTrueCounts);
406  $(id+" .cond_percent").text((cond.fiCounts > 0 ? 100. * cond.fiTrueCounts / cond.fiCounts : 0.).toFixed(2) + "%");
407 
408 
409  // todo: get keywords from condition class definition
410  // problem: static variables are not streamed by default
411 
412  $(id+" .cond_visible")
413  .prop('checked', cond.fbVisible)
414  .click(function() { cond.fbVisible = this.checked; editor.MarkChanged("visible")});
415  $(id+" .cond_limits")
416  .prop('checked', cond.fbLimitsDraw)
417  .click(function() { cond.fbLimitsDraw = this.checked; editor.MarkChanged("limitsdraw")});
418 
419  $(id+" .cond_label")
420  .prop('checked', cond.fbLabelDraw)
421  .click(function() { cond.fbLabelDraw = this.checked; editor.MarkChanged("labeldraw")});
422 
423 
424  $(id+" .cond_integr")
425  .prop('checked', cond.fbIntDraw)
426  .click(function() { cond.fbIntDraw = this.checked; editor.MarkChanged("intdraw")});
427 
428  $(id+" .cond_maxx")
429  .prop('checked', cond.fbXMaxDraw)
430  .click(function() { cond.fbXMaxDraw = this.checked; editor.MarkChanged("xmaxdraw")});
431 
432  $(id+" .cond_max")
433  .prop('checked', cond.fbCMaxDraw)
434  .click(function() { cond.fbCMaxDraw = this.checked; editor.MarkChanged("cmaxdraw")});
435 
436  $(id+" .cond_maxy")
437  .prop('checked', cond.fbYMaxDraw)
438  .click(function() { cond.fbYMaxDraw = this.checked; editor.MarkChanged("ymaxdraw")});
439 
440  $(id+" .cond_xmean")
441  .prop('checked', cond.fbXMeanDraw)
442  .click(function() { cond.fbXMeanDraw = this.checked; editor.MarkChanged("xmeandraw")});
443 
444  $(id+" .cond_xrms")
445  .prop('checked', cond.fbXRMSDraw)
446  .click(function() { cond.fbXRMSDraw = this.checked; editor.MarkChanged("xrmsdraw")});
447 
448  $(id+" .cond_ymean")
449  .prop('checked', cond.fbYMeanDraw)
450  .click(function() { cond.fbYMeanDraw = this.checked; editor.MarkChanged("ymeandraw")});
451 
452  $(id+" .cond_yrms")
453  .prop('checked', cond.fbYRMSDraw)
454  .click(function() { cond.fbYRMSDraw = this.checked; editor.MarkChanged("yrmsdraw")});
455 
456 
457  editor.ClearChanges();
458  }
459  //--------- end refreshEditor
460 
461 
463  GO4.ConditionEditor.prototype.fillEditor = function(divid, resolve) {
464  if (resolve) {
465  this.setTopPainter();
466  } else {
467  this.SetDivId(divid); // old
468  }
469  var id = "#" + divid;
470  var editor = this;
471  var cond = this.cond;
472  console.log("GO4.ConditionEditor.prototype.fillEditor " + this.cond.fName);
473  // $(id).css("display","table");
474 
475  $(id+" .cond_tabs").tabs();
476 
477  $(id + " .cond_execmode").selectmenu({
478  change : function(event, ui) {
479  editor.MarkChanged("resultmode");
480  }
481  });
482  $(id + " .cond_invertmode").selectmenu({
483  change : function(event, ui) {
484  editor.MarkChanged("invertmode");
485  }
486  });
487 
488  if(this.isEllipseCond()) {
489  $(id+" .cond_ellipse_iscircle").selectmenu({
490  change : function(event, ui) {
491  cond.fiShapeType = ui.item.value;
492  if(cond.fiShapeType == 2)
493  {
494  // circle
495  $(id+" .cond_ellipse_a2").prop('disabled', true);
496  $(id+" .cond_ellipse_theta").prop('disabled', true);
497  $(id + " .cond_ellipse_theta_slider").slider("disable");
498  $(id + "cond_ellipse_points").prop('disabled', false);
499  }
500  else if(cond.fiShapeType == 3)
501  {
502  // ellipse
503  $(id+" .cond_ellipse_a2").prop('disabled', false);
504  $(id+" .cond_ellipse_theta").prop('disabled', false);
505  $(id + " .cond_ellipse_theta_slider").slider("enable");
506  $(id + "cond_ellipse_points").prop('disabled', false);
507 
508 
509  }
510  else if(cond.fiShapeType == 4)
511  {
512  // box
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', true);
517  }
518  else
519  {
520  // free style
521  $(id+" .cond_ellipse_a2").prop('disabled', true);
522  $(id+" .cond_ellipse_theta").prop('disabled', true);
523  $(id + " .cond_ellipse_theta_slider").slider("disable");
524  $(id + "cond_ellipse_points").prop('disabled', false);
525  }
526 
527 
528  editor.MarkChanged("ellishape");
529  }
530  })
531 
532  }
533 
534  $(id+" .buttonGetCondition")
535  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
536  .click(function() {
537  console.log("update item = " + editor.getItemName());
538  if (JSROOT.hpainter) JSROOT.hpainter.display(editor.getItemName());
539  else console.log("hierarhy painter object not found!");
540  })
541  .children(":first") // select first button element, used for images
542  .css('background-image', "url(" + GO4.source_dir + "icons/right.png)");
543 
544 
545 
546  $(id+" .buttonSetCondition")
547  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
548  .click(function() {
549  var options=""; // do not need to use name here
550  options=editor.EvaluateChanges(options); // complete option string from all changed elements
551  console.log("set - condition "+ editor.getItemName()+ ", options="+options);
552  GO4.ExecuteMethod(editor,"UpdateFromUrl",options,function(result) {
553  console.log(result ? "set condition done. " : "set condition FAILED.");
554  if(result) editor.ClearChanges();
555  });
556  })
557  .children(":first") // select first button element, used for images
558  .css('background-image', "url(" + GO4.source_dir + "icons/left.png)");
559 
560 
561  $(id+" .buttonChangeLabel")
562  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
563  .click()
564  .children(":first") // select first button element, used for images
565  .css('background-image', "url(" + GO4.source_dir + "icons/info1.png)");
566 
567  $(id+" .buttonDrawCondition")
568  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
569  .click(function() {
570  // TODO: implement correctly after MDI is improved, need to find out active frame and location of bound histogram
571 
572  if (JSROOT.hpainter) {
573  editor.EvaluateChanges("");
574 
575  if (JSROOT.hpainter.updateOnOtherFrames(editor, editor.cond)) return;
576 
577  JSROOT.hpainter.drawOnSuitableHistogram(editor, editor.cond, editor.cond.fiDim==2);
578 
579  return;
580  }
581 
582  //if (JSROOT.hpainter){
583  //var onlineprop = JSROOT.hpainter.getOnlineProp(editor.getItemName());
584  //var baseurl = onlineprop.server + onlineprop.itemname + "/";
585  var baseurl = editor.getItemName() + "/";
586  var drawurl = baseurl + "draw.htm", editorurl = baseurl + "draw.htm?opt=editor";
587  console.log("draw condition to next window with url="+drawurl);
588  //window.open(drawurl);
589  window.open(drawurl,'_blank');
590  // }
591  // else
592  // {
593  // console.log("hpainter object not found!");
594  // }
595  // problem: we do not have method to get currently selected pad...
596  // var nextid="#"+(editor.divid + 1); // does not work, id is string and not number here
597  // console.log("draw condition to id="+nextid);
598  // GO4.drawGo4Cond(nextid, editor.cond, "");
599 
600 
601  })
602  .children(":first") // select first button element, used for images
603  .css('background-image', "url(" + GO4.source_dir + "icons/chart.png)");
604 
605 
606  $(id+" .buttonClearCondition")
607  .button({text: false, icons: { primary: "ui-icon-blank MyButtonStyle"}})
608  .click(function() {
609  console.log("clearing counters...");
610  var options="&resetcounters=1";
611  GO4.ExecuteMethod(editor, "UpdateFromUrl",options,function(result) {
612  console.log(result ? "reset condition counters done. " : "reset condition counters FAILED.");
613  if (result) {
614  if(JSROOT.hpainter) JSROOT.hpainter.display(editor.getItemName());
615  else console.log("hpainter object not found!");
616  }
617  });
618  })
619  .children(":first") // select first button element, used for images
620  .css('background-image', "url(" + GO4.source_dir + "icons/clear.png)");
621 
622  $(id+" .cut_points").spinner({
623  min: 0,
624  max: 1000,
625  step: 1,
626  //spin: function( event, ui ) {console.log("cut spin has value:"+ui.value);},
627  change: function( event, ui ) {editor.ChangePolygonDimension();//console.log("cut changed.");
628  },
629  stop: function( event, ui ) {editor.ChangePolygonDimension();//console.log("cut spin stopped.");
630  }
631  });
632 
633  $(id+" .cond_ellipse_points").spinner({
634  min: 0,
635  max: 1000,
636  step: 1,
637  //spin: function( event, ui ) {console.log("cut spin has value:"+ui.value);},
638  change: function( event, ui ) {editor.MarkChanged("ellinpts");console.log("ellipse points changed.");
639  },
640  stop: function( event, ui ) {editor.MarkChanged("ellinpts");console.log("ellipse points stopped.");
641  }
642  });
643 
644  this.refreshEditor();
645 
646  if (resolve) resolve(this);
647  else this.DrawingReady();
648 
649  //$(document).tooltip();
650  //$(id).tooltip(); // NOTE: jquery ui tooltips will change title information, currently conflict with jsroot!
651  }
652 
653  GO4.ConditionEditor.prototype.drawEditor = function(divid, resolve) {
654  $("#"+divid)
655  .empty()
656  .load(GO4.source_dir + "html/condeditor.htm", "", () => this.fillEditor(divid, resolve));
657  return this;
658  }
659 
660  if (JSROOT._) {
661  GO4.ConditionEditor.prototype.redrawObject = function(obj/*, opt */) {
662  if (obj._typename != this.cond._typename) return false;
663  this.cond = JSROOT.clone(obj); // does this also work with polygon condition?
664  this.refreshEditor();
665  return true;
666  }
667  } else {
668  // old style, new jsroot does not have RedrawPad for BasePainter
669  GO4.ConditionEditor.prototype.RedrawPad = function(resize) {
670  this.refreshEditor();
671  }
672  // makes sense only in jsroot v5, in v6 should be defined redrawObject
673  GO4.ConditionEditor.prototype.UpdateObject = function(obj) {
674  if (obj._typename != this.cond._typename) return false;
675  this.cond = JSROOT.clone(obj); // does this also work with polygon condition?
676  return true;
677  }
678  }
679 
680  // done from central go4.js or go4canvas.js scripts
681  // jsrp.addDrawFunc({ name: "TGo4WinCond", func: GO4.drawGo4Cond, opt: ";editor" });
682  // jsrp.addDrawFunc({ name: "TGo4PolyCond", func: GO4.drawGo4Cond, opt: ";editor" });
683  // jsrp.addDrawFunc({ name: "TGo4ShapedCond", func: GO4.drawGo4Cond, opt: ";editor" });
684 
685 })(); // function
function JSROOT
Definition: go4canvas.js:17
let BasePainter
GO4 AnalysisStatusEditor prototype MarkChanged
function GO4
Definition: go4canvas.js:17
GO4 ConditionEditor prototype isPolyCond
Definition: condition.js:29