GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ViewPanel.cpp
Go to the documentation of this file.
1 // $Id: TGo4ViewPanel.cpp 2038 2018-01-08 16:55:38Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum f�r Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 
15 // JAM2016: activate this for global ROOT "escape mode" before redraw (NOT RECOMMENDED)
16 // otherwise, escape mode will reset global arrays of TGraph painter class only
17 //#define GLOBALESCAPE 1
18 
19 
20 
21 #include "TGo4ViewPanel.h"
22 
23 #include <math.h>
24 
25 #include "TH1.h"
26 #include "TH2.h"
27 #include "TH3.h"
28 #include "TVirtualPadEditor.h"
29 #include "TVirtualX.h"
30 #include "RVersion.h"
31 #include "Riostream.h"
32 #include "THStack.h"
33 #include "TGraph.h"
34 #include "TMultiGraph.h"
35 #include "TColor.h"
36 #include "TCanvas.h"
37 #include "TPad.h"
38 #include "TFrame.h"
39 #include "TArrayD.h"
40 #include "TCutG.h"
41 #include "TArrow.h"
42 #include "TList.h"
43 #include "TLatex.h"
44 #include "TPaveStats.h"
45 #include "TPaveLabel.h"
46 #include "TLegend.h"
47 #include "TLegendEntry.h"
48 #include "TStyle.h"
49 #include "TROOT.h"
50 #include "TMath.h"
51 #include "TClass.h"
52 #include "TSystem.h"
53 
54 #include "TGCanvas.h"
55 #include "TGTab.h"
56 
57 #ifndef __NOGO4GED__
58 #include "TGedEditor.h"
59 #endif
60 
61 #include <QMenuBar>
62 #include <QStatusBar>
63 #include <QFileDialog>
64 #include <QTimer>
65 #include <QInputDialog>
66 #include <QToolTip>
67 #include <QTime>
68 #include <QMenu>
69 #include <QtCore/QSignalMapper>
70 
71 #include <QTimer>
72 
73 #include "QRootWindow.h"
74 #include "QRootCanvas.h"
75 #include "QRootApplication.h"
76 
77 #include "TGo4Log.h"
78 #include "TGo4Picture.h"
79 #include "TGo4Fitter.h"
80 #include "TGo4Marker.h"
81 #include "TGo4Condition.h"
82 #include "TGo4WinCond.h"
83 #include "TGo4PolyCond.h"
84 #include "TGo4CondArray.h"
85 #include "TGo4WinCondView.h"
86 #include "TGo4PolyCondView.h"
87 #include "TGo4LockGuard.h"
88 #include "TGo4MdiArea.h"
89 #include "TGo4ASImage.h"
90 #include "TGo4PrintWidget.h"
91 #include "TGo4Proxy.h"
92 #include "TGo4Slot.h"
93 #include "TGo4ObjectProxy.h"
94 #include "TGo4LinkProxy.h"
95 #include "TGo4DrawObjProxy.h"
96 #include "TGo4DrawCloneProxy.h"
97 #include "TGo4Iter.h"
98 #include "TGo4ObjectManager.h"
99 #include "TGo4BrowserProxy.h"
100 #include "TGo4QSettings.h"
101 
102 const char* NoStackDrawOption = "nostack, ";
103 
104 TGo4ViewPanel::TGo4ViewPanel(QWidget *parent, const char* name) :
105  QGo4Widget(parent, name)
106 {
107  setupUi(this);
108 
109  fPanelName = objectName();
110 
111  fxActivePad = 0;
112 
113  fbEditorFrameVisible = false;
115  fxRepaintTimerPad = 0;
116  fxResizeTimerPad = 0;
118  fbFreezeTitle = false;
119  fFreezedTitle = "";
120  fbApplyToAllFlag = false;
121  fbAutoZoomFlag = false;
122  fbCanvasCrosshair = false;
123  fbCanvasEventstatus = false;
124 
125  fbCloneFlag = true;
126  fbModifiedSignalFlag = false;
127  fbLeaveFocusAfterCondEnd = false;
128 
129  // setup of marker editor
130  fbMarkEditorVisible = false;
131  fbTypingMode = true;
132  MarkerPanel->setVisible(false);
134  fiPickCounter = 0;
135  fbPickAgain = false;
136 
137  setWindowTitle(GetPanelName());
138  fxQCanvas->setObjectName(GetPanelName());
139  fxQCanvas->getCanvas()->SetName(GetPanelName());
140 
141 // printf("Resize x %d y %d\n", go4sett->lastPanelSize().width(), go4sett->lastPanelSize().height());
142 // resize(go4sett->lastPanelSize());
143 
144  fSelectMenu = 0;
145  fSelectMap = 0;
146  fxRooteditor = 0;
147  fxPeditor = 0;
148  fDummyHisto = 0;
149 
150  fMenuBar = new QMenuBar(MenuFrame);
151  fMenuBar->setMinimumWidth(50);
152 
153 #if (QT_VERSION >= 0x040600)
154  fMenuBar->setNativeMenuBar(kFALSE); // disable putting this to screen menu. for MAC style WMs
155 #endif
156 
157  QMenu* fileMenu = fMenuBar->addMenu("F&ile");
158  fileMenu->addAction("&Save as...", this, SLOT(SaveCanvas()));
159  fileMenu->addAction("Print...", this, SLOT(PrintCanvas()));
160  fileMenu->addAction("Produce &Picture", this, SLOT(ProducePicture()));
161  fileMenu->addAction("Produce &Graph from markers", this,
162  SLOT(ProduceGraphFromMarkers()));
163 
164 // fileMenu->addAction("Copy to T&Canvas in Memory", this, SLOT(SendToBrowser()));
165 // fileMenu->addAction("&Load marker setup...", this, SLOT(LoadMarkers()));
166 // fileMenu->addAction("Save &marker setup...", this, SLOT(SaveMarkers()));
167  fileMenu->addAction("Cl&ose", this, SLOT(close()));
168 
169  //Edit Menu
170  QMenu* editMenu = fMenuBar->addMenu("&Edit");
171 
172  AddChkAction(editMenu, "Show marker &editor", fbMarkEditorVisible, this,
173  SLOT(SetMarkerPanel()));
174 
175  QAction* act = AddChkAction(editMenu, "Show &ROOT attributes editor",
176  fbEditorFrameVisible, this, SLOT(StartRootEditor()));
177 #ifdef __NOGO4GED__
178  act->setEnabled(false);
179 #else
181 #endif
182 
183  // must get fbCanvasEventstatus from
185  AddChkAction(editMenu, "Show &event status", fbCanvasEventstatus, this,
186  SLOT(ShowEventStatus()));
187 
188  editMenu->addAction("Start &condition editor", this,
189  SLOT(StartConditionEditor()));
190 
191  editMenu->addSeparator();
192  editMenu->addAction("Clear &markers", this, SLOT(ClearAllMarkers()));
193  editMenu->addAction("Clear &pad", this, SLOT(ClearActivePad()));
194  editMenu->addAction("Clear c&anvas", this, SLOT(ClearCanvas()));
195 
196  fSelectMap = new QSignalMapper(this);
197  connect(fSelectMap, SIGNAL(mapped(int)), this,
198  SLOT(SelectMenuItemActivated(int)));
199  fSelectMenu = fMenuBar->addMenu("&Select");
200 
201  fOptionsMap = new QSignalMapper(this);
202  fOptionsMenu = fMenuBar->addMenu("&Options");
203  connect(fOptionsMenu, SIGNAL(aboutToShow()), this,
204  SLOT(AboutToShowOptionsMenu()));
205  connect(fOptionsMap, SIGNAL(mapped(int)), this,
206  SLOT(OptionsMenuItemActivated(int)));
207 
211  AddIdAction(fOptionsMenu, fOptionsMap, "Histogram &Statistics", StatisticsId);
212  AddIdAction(fOptionsMenu, fOptionsMap, "Multiplot &Legend", SetLegendId);
213 
214  fOptionsMenu->addSeparator();
215  AddIdAction(fOptionsMenu, fOptionsMap, "Histogram &Title", SetTitleId);
218  AddIdAction(fOptionsMenu, fOptionsMap, "Draw item name", DrawItemnameId);
219  fOptionsMenu->addSeparator();
220  AddIdAction(fOptionsMenu, fOptionsMap, "&1:1 Coordinate ratio", SetXYRatioOneId);
221  fOptionsMenu->addSeparator();
222  AddIdAction(fOptionsMenu, fOptionsMap, "&X-Axis displays time", AxisTimeDisplayId);
223  AddIdAction(fOptionsMenu, fOptionsMap, "Set X-Axis time format...", SetTimeFormatId);
224  fOptionsMenu->addSeparator();
225  AddIdAction(fOptionsMenu, fOptionsMap, "&Keep Viewpanel Title", FreezeTitleId);
226  AddIdAction(fOptionsMenu, fOptionsMap, "Set &Viewpanel Title...", SetTitleTextId);
227 
228  QCheckBox* box1 = new QCheckBox("Apply to all", MenuFrame);
229  box1->setObjectName("ApplyToAllCheck");
230  connect(box1, SIGNAL(toggled(bool)), this, SLOT(ApplyToAllToggled(bool)));
231 
232  fAutoScaleCheck = new QCheckBox("AutoScale", MenuFrame);
233  fAutoScaleCheck->setObjectName("AutoScaleCheck");
234  connect(fAutoScaleCheck, SIGNAL(toggled(bool)), this, SLOT(AutoScaleToggled(bool)));
235 
236  QHBoxLayout* menugrid = new QHBoxLayout(0/*MenuFrame*/);
237  menugrid->setMargin(0);
238  menugrid->setSpacing(0);
239  menugrid->addWidget(fMenuBar, 10, Qt::AlignLeft);
240  menugrid->addWidget(box1, 1, Qt::AlignRight);
241  menugrid->addWidget(fAutoScaleCheck, 1, Qt::AlignRight);
242 
243  gridLayout->addLayout(menugrid, 0, 0, 1, 2);
244 
245  // status widget
246  CanvasStatus = new QStatusBar(this);
247  gridLayout->addWidget(CanvasStatus, 3, 0, 1, 2);
248  CanvasStatus->setVisible(false);
249 
250  EditorFrame->setVisible(fbEditorFrameVisible);
251 
252  connect(GetQCanvas(), SIGNAL(SelectedPadChanged(TPad*)), this,
253  SLOT(SetActivePad(TPad*)));
254  connect(GetQCanvas(), SIGNAL(PadClicked(TPad*)), this,
255  SLOT(PadClickedSlot(TPad*)));
256  connect(GetQCanvas(), SIGNAL(PadDoubleClicked(TPad*)), this,
257  SLOT(PadDoubleClickedSlot(TPad*)));
258  connect(GetQCanvas(), SIGNAL(MenuCommandExecuted(TObject*, const char*)),
259  this, SLOT(MenuCommandExecutedSlot(TObject*, const char*)));
260  connect(GetQCanvas(), SIGNAL(CanvasLeaveEvent()), this,
261  SLOT(RefreshButtons()));
262  connect(GetQCanvas(), SIGNAL(CanvasUpdated()), this,
263  SLOT(CanvasUpdatedSlot()));
264 }
265 
267 {
268  TGo4LockGuard lock;
269 
270  // prevent problems with root's subeditor cache
271  if (fxPeditor != 0) {
272  fxPeditor->DeleteEditors();
273  delete fxPeditor;
274  fxPeditor = 0;
275  }
276 
277  if (fDummyHisto != 0) {
278  delete fDummyHisto;
279  fDummyHisto = 0;
280  }
281 
282  // we should delete all markers first, while they
283  // have internal reference on the pad, which will be
284  // deleted by the net canvas->Clear() call
286 
287  GetCanvas()->Clear();
288 
289  fxRepaintTimerPad = 0;
290 
292 
293  if (gPad != 0)
294  if (IsPanelPad((TPad*) gPad))
295  gPad = 0;
296 
297  if (gROOT->GetSelectedPad() != 0)
298  if (IsPanelPad((TPad*) gROOT->GetSelectedPad()))
299  gROOT->SetSelectedPad(0);
300 }
301 
303 {
304  fbaPanelName = fPanelName.toLatin1();
305  return fbaPanelName.constData();
306 }
307 
308 void TGo4ViewPanel::SetPanelName(const char* newname)
309 {
310  fPanelName = newname;
311 }
312 
314 {
315  return GetTopSlot(true);
316 }
317 
318 TGo4Slot* TGo4ViewPanel::AddNewSlot(const char* name, TGo4Slot* parent)
319 {
320  if (parent == 0)
321  parent = GetPanelSlot();
322  return new TGo4Slot(parent, name, "title");
323 }
324 
326 {
327  // do nothing
328 }
329 
330 void TGo4ViewPanel::linkedObjectUpdated(const char* linkname, TObject* obj)
331 {
332  if (linkname == 0)
333  return;
334 
335  if (strcmp(linkname, "PadRangeAxisChanged") == 0) {
337  } else if (strcmp(linkname, "PadModified") == 0) {
338  if (IsRedrawBlocked())
339  return;
341  QTimer::singleShot(1, this, SLOT(ProcessPadModifiedSignal()));
342  fbModifiedSignalFlag = true;
343  }
344 }
345 
346 void TGo4ViewPanel::linkedUpdated(TGo4Slot* slot, TObject* obj)
347 {
348  if (slot == 0)
349  return;
350 
351  if (IsRedrawBlocked())
352  return;
353 
354  Int_t kind = GetDrawKind(slot);
355 
356  TGo4Slot* padslot = slot;
357  if (kind != kind_PadSlot)
358  padslot = slot->GetParent();
359 
360  if (((kind > 0) && (kind < 100)) || (kind == kind_Condition)
361  || (kind == kind_Latex) || (kind == kind_Func)) {
362  TGo4Picture* padopt = GetPadOptions(padslot);
363 
364  if (padopt != 0) {
365  padopt->SetContentModified(true);
366  padopt->SetPadModified();
367 
368  // in this small period other objects can come,
369  // therefore only one repaint will be done
371  }
372  }
373 }
374 
375 void TGo4ViewPanel::linkedRemoved(TGo4Slot* slot, TObject* obj)
376 {
377  if (slot == 0)
378  return;
379 
380  if (IsRedrawBlocked())
381  return;
382 
383  int kind = GetDrawKind(slot);
384 
385  if (kind == kind_ThisPad) {
386  TPad* pad = (TPad*) obj;
387  if (pad != 0)
388  PadDeleted(pad);
389  return;
390  }
391 
392  TGo4Slot* padslot = slot;
393  if (kind != kind_PadSlot)
394  padslot = slot->GetParent();
395 
396  CheckObjectsAssigments(GetSlotPad(padslot), padslot);
397 
398  if (((kind > 0) && (kind < 100)) || (kind == kind_Condition)
399  || (kind == kind_Latex) || (kind == kind_Func)) {
401  TGo4Picture* padopt = GetPadOptions(padslot);
402  if (padopt != 0) {
403  padopt->SetPadModified();
405  }
406  }
407 }
408 
409 bool TGo4ViewPanel::IsAcceptDrag(const char * itemname, TClass * cl, int kind)
410 {
411  if (cl == 0)
412  return false;
413  int cando = Browser()->ItemCanDo(itemname);
414  return TGo4BrowserProxy::CanDrawItem(cando)
415  || cl->InheritsFrom(TGo4Condition::Class());
416 }
417 
418 void TGo4ViewPanel::DropOnPad(TPad* pad, const char * itemname, TClass * cl, int kind)
419 {
420  if (cl == 0) return;
421  if (pad == 0) pad = GetCanvas();
422 
423  if (cl->InheritsFrom(TGo4Fitter::Class())) {
424  SetActivePad(pad);
425  EditItem(itemname);
426  return;
427  }
428  int cando = Browser()->ItemCanDo(itemname);
430  && !cl->InheritsFrom(TGo4Condition::Class()))
431  return;
432 
433  if (AddDrawObject(pad, kind_Link, itemname, 0, false, 0) == 0) return;
434 
435  SetActivePad(pad);
436 
438 
439  Browser()->GetBrowserObject(itemname,
440  go4sett->getFetchDataWhenDraw() ? 2 : 1);
441 }
442 
443 // ****************************************************************
444 
446 {
447  TGo4LockGuard lock;
448 
449  // create appropriate entry in OM
450  UpdatePadStatus(GetCanvas(), true);
451 
452  fAutoScaleCheck->setChecked(GetPadOptions(GetCanvas())->IsAutoScale());
453 
454  fxRooteditor = new QRootWindow(EditorFrame, "rootwrapperwindow");
455  QVBoxLayout* gedlayout = new QVBoxLayout(EditorFrame);
456  gedlayout->setContentsMargins(0, 0, 0, 0);
457  gedlayout->addWidget(fxRooteditor);
458 
459  // fMenuBar
460  connect(TGo4MdiArea::Instance(),
461  SIGNAL(panelSignal(TGo4ViewPanel*, TPad*, int)), this,
462  SLOT(panelSlot(TGo4ViewPanel*, TPad*, int)));
463 
464  // printf("Resize again x %d y %d\n", go4sett->lastPanelSize().width(), go4sett->lastPanelSize().height());
465  // resize(go4sett->lastPanelSize());
466 
467  // adjust canvas size before any drawing will be done
468  GetQCanvas()->Resize();
469 
471 
473 
474  //fxQCanvas->Modified();
475 
477 }
478 
480 {
481  fiMouseMode = mode;
482 }
483 
485 {
486  return fiMouseMode;
487 }
488 
490 {
491  TGo4Slot* padslot = GetPadSlot(pad);
492  if (padslot == 0) return QString::null;
493  return QString(padslot->GetPar("::SelMarker"));
494 }
495 
497 {
498  TGo4Slot* padslot = GetPadSlot(pad);
499  if (padslot == 0) return -1;
500  Int_t selindex = -1;
501  if (!padslot->GetIntPar("::SelIndex", selindex)) return -1;
502  return selindex;
503 }
504 
505 TGo4Slot* TGo4ViewPanel::GetSelectedSlot(TPad* pad, int* selkind, TObject** selobj)
506 {
507  if (selkind != 0) *selkind = kind_None;
508  if (selobj != 0) *selobj = 0;
509 
510  TGo4Slot* padslot = GetPadSlot(pad);
511  QString selname = GetSelectedMarkerName(pad);
512  int selindex = GetSelectedMarkerIndex(pad);
513 
514  if ((padslot == 0) || (selname.length() == 0)) return 0;
515 
516  for (int n = 0; n < padslot->NumChilds(); n++) {
517  TGo4Slot* subslot = padslot->GetChild(n);
518  int drawkind = GetDrawKind(subslot);
519  TObject* obj = subslot->GetAssignedObject();
520 
521  if ((drawkind == kind_Link) && (obj != 0)) {
522  if (obj->InheritsFrom(TGo4Condition::Class()))
523  drawkind = kind_Condition;
524  }
525 
526  if ((drawkind == kind_Marker) || (drawkind == kind_Window)
527  || (drawkind == kind_Poly) || (drawkind == kind_Latex)
528  || (drawkind == kind_Arrow) || (drawkind == kind_Condition)) {
529 
530  if ((obj == 0) || (selname != obj->GetName()))
531  continue;
532 
533  if (drawkind == kind_Condition) {
534  TGo4Condition* selcond = dynamic_cast<TGo4Condition*>(obj);
535  if (obj->InheritsFrom(TGo4CondArray::Class())) {
536  TGo4CondArray* arr = (TGo4CondArray*) obj;
537  selcond = 0;
538  if ((selindex >= 0) && (selindex < arr->GetNumber()))
539  selcond = arr->At(selindex);
540  }
541  drawkind = kind_None;
542  obj = selcond;
543  if (selcond != 0)
544  if (selcond->InheritsFrom(TGo4WinCond::Class()))
545  drawkind = kind_Window;
546  else if (selcond->InheritsFrom(TGo4PolyCond::Class()))
547  drawkind = kind_Poly;
548  }
549  if (selkind != 0)
550  *selkind = drawkind;
551  if (selobj != 0)
552  *selobj = obj;
553  return subslot;
554  }
555  }
556  return 0;
557 }
558 
560 {
561  TGo4Slot* slot = GetSelectedSlot(pad, 0, 0);
562  if (slot == 0)
563  return false;
564 
565  return (GetDrawKind(slot) == kind_Condition);
566 }
567 
568 TPad* TGo4ViewPanel::FindPadWithItem(const char* itemname)
569 {
570  TGo4Iter iter(GetPanelSlot(), kTRUE);
571  while (iter.next()) {
572  TGo4Slot* subslot = iter.getslot();
573  int drawkind = GetDrawKind(subslot);
574  if ((drawkind == kind_Link) || (drawkind == kind_Condition) || (drawkind == kind_Latex) || (drawkind == kind_Func)) {
575  const char* linkname = GetLinkedName(subslot);
576  if (linkname != 0)
577  if (strcmp(linkname, itemname) == 0)
578  return GetSlotPad(subslot->GetParent());
579  }
580  }
581  return 0;
582 }
583 
584 const char* TGo4ViewPanel::GetDrawItemName(int itemcnt)
585 {
586  int cnt = 0;
587 
588  TGo4Iter iter(GetPanelSlot(), kTRUE);
589  while (iter.next()) {
590  TGo4Slot* subslot = iter.getslot();
591  int drawkind = GetDrawKind(subslot);
592  if ((drawkind == kind_Link) || (drawkind == kind_Condition)) {
593  const char* linkname = GetLinkedName(subslot);
594  if (linkname != 0) {
595  if (cnt++ == itemcnt) return linkname;
596  }
597  }
598  }
599 
600  return 0;
601 }
602 
603 
604 void TGo4ViewPanel::UndrawItemOnPanel(const char* itemname)
605 {
606  TGo4LockGuard lock;
607 
608  TObjArray delslots;
609 
610  TGo4Iter iter(GetPanelSlot(), kTRUE);
611  while (iter.next()) {
612  TGo4Slot* subslot = iter.getslot();
613  int drawkind = GetDrawKind(subslot);
614  if ((drawkind == kind_Link) || (drawkind == kind_Condition) || (drawkind == kind_Latex) || (drawkind == kind_Func)) {
615  const char* linkname = GetLinkedName(subslot);
616  if ((linkname != 0) && (strcmp(linkname, itemname) == 0)) {
617  delslots.Add(subslot);
618  TGo4Slot* padslot = subslot->GetParent();
619  TGo4Picture* padopt = GetPadOptions(padslot);
620  if (padopt != 0)
621  padopt->SetPadModified();
622  }
623  }
624  }
625  if (delslots.GetLast() >= 0) {
626  delslots.Delete();
628  }
629 }
630 
631 void TGo4ViewPanel::SetSelectedMarker(TPad* pad, const QString& selname,
632  int selindex)
633 {
634  TGo4LockGuard lock;
635 
636  TGo4Slot* padslot = GetPadSlot(pad);
637  if (padslot == 0)
638  return;
639 
640  if (selname.length() == 0)
641  selindex = -1;
642 
643  int oldselindex = GetSelectedMarkerIndex(pad);
644  QString oldselname = GetSelectedMarkerName(pad);
645 
646  TGo4Slot* oldsel = GetSelectedSlot(pad, 0, 0);
647  if (oldsel != 0)
648  SetSpecialDrawOption(oldsel, 0);
649 
650  if (selname.length() > 0)
651  padslot->SetPar("::SelMarker", selname.toLatin1().constData());
652  else
653  padslot->RemovePar("::SelMarker");
654 
655  if (selindex > -1)
656  padslot->SetIntPar("::SelIndex", selindex);
657  else
658  padslot->RemovePar("::SelIndex");
659 
660  int newselkind = 0;
661  TObject* newselobj = 0;
662  TGo4Slot* newselslot = GetSelectedSlot(pad, &newselkind, &newselobj);
663 
664  if ((selindex >= 0) && (newselslot != 0)) {
665  QString drawopt("sel=");
666  drawopt += QString::number(selindex);
667  SetSpecialDrawOption(newselslot, drawopt.toLatin1().constData());
668  }
669 
670  if (((oldselindex != selindex) || (oldselname != selname))
671  && ((oldselindex >= 0) || (selindex >= 0))) {
672  MarkPadModified(pad);
673  ShootRepaintTimer(pad);
674  } else if (newselobj != 0) {
675  // this will bring object to the top
676  newselobj->Pop();
677  // very special case, normally one should not call pad->Update()
678  pad->Update();
679  }
680 
681 }
682 
683 void TGo4ViewPanel::SetSelectedMarkerByMouseClick(TPad* pad, const char* name)
684 {
685  TGo4LockGuard lock;
686 
687  if (!fbMarkEditorVisible) return;
688  TGo4Slot* padslot = GetPadSlot(pad);
689  if (padslot == 0) return;
690 
691  bool find = false;
692 
693  for (int n = 0; n < padslot->NumChilds(); n++) {
694  TGo4Slot* subslot = padslot->GetChild(n);
695  int drawkind = GetDrawKind(subslot);
696  if ((drawkind == kind_Marker) || (drawkind == kind_Window)
697  || (drawkind == kind_Poly)) {
698  TObject* obj = subslot->GetAssignedObject();
699  if ((obj != 0) && (strcmp(obj->GetName(), name) == 0)) {
700  SetSelectedMarker(pad, name, -1);
701  SetActiveObj(pad, drawkind, subslot);
702  find = true;
703  break;
704  }
705  }
706  if (drawkind != kind_Condition) continue;
707  TGo4Condition* cond =
708  dynamic_cast<TGo4Condition*>(subslot->GetAssignedObject());
709  if (cond==0) continue;
710 
711  if (strcmp(cond->GetName(), name) == 0) {
712  SetSelectedMarker(pad, name, -1);
713 
714  if (cond->InheritsFrom(TGo4PolyCond::Class()))
715  drawkind = kind_Poly;
716  else
717  drawkind = kind_Window;
718 
719  SetActiveObj(pad, drawkind, subslot);
720  find = true;
721  break;
722  }
723 
724  TGo4CondArray* arr = dynamic_cast<TGo4CondArray*>(cond);
725  if (arr == 0)
726  continue;
727 
728  for (int ncon = 0; ncon < arr->GetNumber(); ncon++)
729  if (strcmp(arr->At(ncon)->GetName(), name) == 0) {
730  SetSelectedMarker(pad, arr->GetName(), ncon);
731  if (arr->At(ncon)->InheritsFrom(TGo4PolyCond::Class()))
732  drawkind = kind_Poly;
733  else
734  drawkind = kind_Window;
735  SetActiveObj(pad, drawkind, subslot);
736  find = true;
737  break;
738  }
739  }
740  if (find)
741  RefreshButtons();
742 }
743 
745 {
746  TGo4LockGuard lock;
747 
748  int selectedkind;
749  TGo4Slot* selslot = GetSelectedSlot(GetActivePad(), &selectedkind, 0);
750 
751  if (selslot == 0)
752  return;
753 
754  if (selectedkind == kind_Window) {
755  FreezeMode->setChecked(false);
756  RegionB->setChecked(true);
758  } else if (selectedkind == kind_Poly) {
759  FreezeMode->setChecked(false);
760  PolyB->setChecked(true);
762  } else
763  return;
764 
765  MarkPadModified(pad);
766  ShootRepaintTimer(pad);
767 }
768 
769 void TGo4ViewPanel::SwitchMarkerButton(int kind, bool on)
770 {
771  if (!fbTypingMode)
772  return;
774  if (!on) {
776  } else {
777  fiPickCounter = 0;
778  switch (kind) {
779  case kind_Marker:
781  break;
782  case kind_Window:
784  break;
785  case kind_Poly:
787  break;
788  case kind_Latex:
790  break;
791  case kind_Arrow:
793  break;
794  default:
796  break;
797  }
798  int selectedkind;
799  TGo4Slot* selslot = GetSelectedSlot(GetActivePad(), &selectedkind, 0);
800  if (selectedkind != kind)
801  SetSelectedMarker(GetActivePad(), "", -1);
802  }
803 
804  RefreshButtons();
805 }
806 
808 {
810 }
811 
813 {
815 }
816 
818 {
820 }
821 
823 {
825 }
826 
828 {
830 }
831 
833 {
834  if (!fbTypingMode)
835  return;
836  fbPickAgain = on;
837  RefreshButtons();
838 }
839 
841 {
842  TGo4LockGuard lock;
843 
844  MarkerPanel->setVisible(fbMarkEditorVisible);
845  fxQCanvas->setMaskDoubleClick(fbMarkEditorVisible);
846 
847 // if(!fbMarkEditorVisible) return;
848 
849  bool iscondition = IsConditionSelected(GetActivePad());
850 
851  fbTypingMode = false;
852  GetConditionBtn->setVisible(iscondition);
853  InfoConditionBtn->setVisible(iscondition);
854  EditConditionBtn->setVisible(iscondition);
855  SetConditionBtn->setVisible(iscondition);
856  if (iscondition) {
857  TGo4Slot* slot = GetSelectedSlot(GetActivePad(), 0, 0);
858  TGo4Condition* cond =
859  slot == 0 ? 0 : dynamic_cast<TGo4Condition*>(slot->GetAssignedObject());
860  ModifyConditionBtn->setVisible((cond != 0) && (cond->IsChanged() != 0));
861 
862  QString iconname = ":/icons/right.png";
863  QString tooltip = "Refresh condition from analysis";
864  if (!BrowserItemRemote(GetLinkedName(slot))) {
865  iconname = ":/icons/refresh.png";
866  tooltip = "Refresh condition from source";
867  }
868  GetConditionBtn->setIcon(QIcon(iconname));
869  GetConditionBtn->setToolTip(tooltip);
870 
871  } else
872  ModifyConditionBtn->setVisible(false);
873 
874  switch (GetMouseMode()) {
875  case kMouseROOT:
876  CursorB->setChecked(false);
877  RegionB->setChecked(false);
878  LatexB->setChecked(false);
879  DrawB->setChecked(false);
880  PolyB->setChecked(false);
881  break;
882  case kMousePickCursor:
883  CursorB->setChecked(true);
884  RegionB->setChecked(false);
885  LatexB->setChecked(false);
886  DrawB->setChecked(false);
887  PolyB->setChecked(false);
888  break;
889  case kMousePickLimits:
890  CursorB->setChecked(false);
891  RegionB->setChecked(true);
892  LatexB->setChecked(false);
893  DrawB->setChecked(false);
894  PolyB->setChecked(false);
895  break;
896  case kMousePickPolygon:
897  CursorB->setChecked(false);
898  RegionB->setChecked(false);
899  LatexB->setChecked(false);
900  DrawB->setChecked(false);
901  PolyB->setChecked(true);
902  break;
903  case kMousePickLatex:
904  CursorB->setChecked(false);
905  RegionB->setChecked(false);
906  LatexB->setChecked(true);
907  DrawB->setChecked(false);
908  PolyB->setChecked(false);
909  break;
910  case kMouseDraw: // currently, we only draw arrows:
911  CursorB->setChecked(false);
912  RegionB->setChecked(false);
913  LatexB->setChecked(false);
914  DrawB->setChecked(true);
915  PolyB->setChecked(false);
916  break;
917  default:
918  CursorB->setChecked(false);
919  RegionB->setChecked(false);
920  LatexB->setChecked(false);
921  DrawB->setChecked(false);
922  PolyB->setChecked(false);
923  break;
924  }; // switch()
925  FreezeMode->setChecked(fbPickAgain);
926 
927  SelectedMarkerCmb->clear();
928  SelectedMarkerCmb->addItem("new");
929 
930  TGo4Slot* slot = GetPadSlot(GetActivePad());
931  int findindx = -1;
932 
933  QString selname = GetSelectedMarkerName(GetActivePad());
934  int selindex = GetSelectedMarkerIndex(GetActivePad());
935 
936  if (slot != 0)
937  for (int n = 0; n < slot->NumChilds(); n++) {
938  TGo4Slot* subslot = slot->GetChild(n);
939  int drawkind = GetDrawKind(subslot);
940  if ((drawkind == kind_Marker) || (drawkind == kind_Window)
941  || (drawkind == kind_Poly) || (drawkind == kind_Condition)) {
942  TObject* obj = subslot->GetAssignedObject();
943  if (obj == 0)
944  continue;
945 
946  if (obj->InheritsFrom(TGo4CondArray::Class())) {
947  TGo4CondArray* arr = (TGo4CondArray*) obj;
948  for (int ncon = 0; ncon < arr->GetNumber(); ncon++) {
949  TGo4Condition* sub = arr->At(ncon);
950  QString fullname(arr->GetName());
951  fullname += "/Sub";
952  fullname += QString::number(ncon);
953  SelectedMarkerCmb->addItem(fullname);
954 
955  if ((selname == obj->GetName()) && (selindex == ncon))
956  findindx = SelectedMarkerCmb->count() - 1;
957  }
958  } else {
959  SelectedMarkerCmb->addItem(obj->GetName());
960  if (selname == obj->GetName())
961  findindx = SelectedMarkerCmb->count() - 1;
962  }
963  }
964  }
965 
966  if (findindx < 0) {
967  findindx = 0;
968  SetSelectedMarker(GetActivePad(), "", -1);
969  }
970 
971  SelectedMarkerCmb->setCurrentIndex(findindx);
972  DelSelectedMarker->setEnabled((findindx > 0) /*&& !iscondition*/);
973 
974  if (fbMarkEditorVisible) {
975  MarkerPanel->ensurePolished();
976  MarkerPanel->update();
977  MarkerPanel->show();
978  }
979  fbTypingMode = true;
980 }
981 
983 {
984  if (!fbTypingMode)
985  return;
986  if (indx == 0)
987  SetSelectedMarker(GetActivePad(), "", -1);
988  else {
989  QString selname = SelectedMarkerCmb->itemText(indx);
990  int selindex = -1;
991  int p = selname.indexOf("/Sub");
992  if (p > 0) {
993  selindex = selname.mid(p + 4).toInt();
994  selname.truncate(p);
995  } else
996  selindex = -1;
997  SetSelectedMarker(GetActivePad(), selname, selindex);
998  }
999 
1000  int drawkind = 0;
1001  TGo4Slot* slot = GetSelectedSlot(GetActivePad(), &drawkind, 0);
1002 
1003  if ((slot != 0) && (drawkind > 0)) {
1004  SetActiveObj(GetActivePad(), drawkind, slot);
1005  SwitchMarkerButton(drawkind, true);
1006  } else
1008 }
1009 
1011 {
1012  if (!fbTypingMode) return;
1013  TGo4Slot* slot = GetSelectedSlot(GetActivePad(), 0, 0);
1014  if (slot == 0) return;
1015  delete slot;
1016  SetSelectedMarker(GetActivePad(), "", -1);
1017  RedrawPanel(GetActivePad(), true);
1018 }
1019 
1021 {
1023  if (!fbMarkEditorVisible) {
1024  // switch back to normal root mouse when editor is hidden
1027  gROOT->SetEditorMode("");
1028  fiPickCounter = 0;
1029  }
1030  RefreshButtons();
1032 }
1033 
1035 {
1036  if (!fbTypingMode)
1037  return;
1038 
1039  TGo4Slot* slot = GetPadSlot(GetActivePad());
1040  if (slot == 0)
1041  return;
1042 
1043  for (int n = 0; n < slot->NumChilds(); n++) {
1044  TGo4Slot* subslot = slot->GetChild(n);
1045  int drawkind = GetDrawKind(subslot);
1046  TObject* obj = subslot->GetAssignedObject();
1047  if ((drawkind < kind_Condition) || (obj == 0))
1048  continue;
1049  switch (drawkind) {
1050  case kind_Marker:
1051  obj->Print("*");
1052  break;
1053  case kind_Latex:
1054  obj->Print("*");
1055  break;
1056  case kind_Arrow:
1057  obj->Print("go4log");
1058  break;
1059  case kind_Window:
1060  case kind_Poly:
1061  case kind_Condition:
1062  obj->Print("go4log-limits-stats");
1063  break;
1064  }
1065  }
1066 }
1067 
1069 {
1070  TGo4LockGuard lock;
1071 
1072  TPad* pad = IsApplyToAllFlag() ? GetCanvas() : GetActivePad();
1073  if (pad == 0)
1074  pad = GetCanvas();
1075 
1077 
1078  RedrawPanel(pad, true);
1079 }
1080 
1081 void TGo4ViewPanel::ProcessMarkersClear(TPad *pad, bool withsubpads)
1082 {
1083  if (pad == 0) return;
1084 
1090  if (!withsubpads) return;
1091 
1092  TGo4Slot* slot = GetPadSlot(pad);
1093  if (slot == 0) return;
1094 
1095  TGo4Iter iter(slot, true);
1096  while (iter.next()) {
1097  TPad* subpad = GetSlotPad(iter.getslot());
1098  if (subpad != 0)
1099  ProcessMarkersClear(subpad, false);
1100  }
1101 }
1102 
1104 {
1105  TGo4Slot* slot = GetSelectedSlot(GetActivePad(), 0, 0);
1106  if (GetDrawKind(slot) != kind_Condition)
1107  return;
1108  const char* itemname = GetLinkedName(slot);
1109  if (itemname == 0)
1110  return;
1111 
1112  Browser()->GetBrowserObject(itemname, 2);
1113 
1114  RefreshButtons();
1115 }
1116 
1118 {
1119  TGo4Slot* slot = GetSelectedSlot(GetActivePad(), 0, 0);
1120  if (GetDrawKind(slot) != kind_Condition)
1121  return;
1122  const char* itemname = GetLinkedName(slot);
1123  if (itemname != 0)
1124  ShowItemInfo(itemname);
1125 }
1126 
1128 {
1129  TGo4Slot* slot = GetSelectedSlot(GetActivePad(), 0, 0);
1130  if (GetDrawKind(slot) != kind_Condition) return;
1131  const char* itemname = GetLinkedName(slot);
1132  if (itemname != 0)
1133  EditItem(itemname);
1134 }
1135 
1137 {
1138  TGo4Slot* slot = GetSelectedSlot(GetActivePad(), 0, 0);
1139  if (GetDrawKind(slot) != kind_Condition) return;
1140  const char* itemname = GetLinkedName(slot);
1141  if (itemname != 0) {
1142  UpdateItemInAnalysis(itemname);
1143  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(slot->GetAssignedObject());
1144  if(cond!=0) cond->SetChanged(kFALSE);
1145  RefreshButtons();
1146  }
1147 }
1148 
1150 {
1151  QFileDialog fd(this, "Save Markers of active pad into", QString(),
1152  "ROOT file (*.root)");
1153  fd.setFileMode(QFileDialog::AnyFile);
1154  fd.setAcceptMode(QFileDialog::AcceptSave);
1155  if (fd.exec() == QDialog::Accepted) {
1156  QStringList flst = fd.selectedFiles();
1157  if (flst.isEmpty())
1158  return;
1159 
1160  QString filename = flst[0];
1161  if (!filename.endsWith(".root"))
1162  filename.append(".root");
1163 // fxTGo4PreviewPanelSlots->SaveMarkerSetup(filename,"Markersetup");
1164  }
1165 }
1166 
1168 {
1169  QFileDialog fd(this, "Load Marker setup from:", QString(),
1170  "ROOT file (*.root)");
1171  fd.setFileMode(QFileDialog::ExistingFile);
1172  if (fd.exec() == QDialog::Accepted) {
1173  QStringList flst = fd.selectedFiles();
1174  if (flst.isEmpty())
1175  return;
1176  QString filename = flst[0];
1177  }
1178 }
1179 
1181 {
1182  TGo4LockGuard lock;
1183 
1184  if (fxActivePad != pad)
1186 
1187  raise();
1188 
1189  if (pad == 0) {
1190  GetCanvas()->SetSelected(0);
1191  GetCanvas()->SetSelectedPad(0);
1192  GetQCanvas()->Update();
1193  return;
1194  }
1195 
1196  fxActivePad = pad;
1197  fxActivePad->cd();
1198  GetCanvas()->SetSelectedPad(fxActivePad);
1199 
1201 
1202  BlockPanelRedraw(true);
1203  GetQCanvas()->Update();
1204  BlockPanelRedraw(false);
1205 
1207 
1210 }
1211 
1213 {
1214  TGo4LockGuard lock;
1215  SetActivePad(pad);
1216 
1217  if (pad == 0)
1218  return;
1219 
1220  Int_t px = pad->GetEventX();
1221  Int_t py = pad->GetEventY();
1222  Double_t x = pad->PadtoX(pad->AbsPixeltoX(px));
1223  Double_t y = pad->PadtoY(pad->AbsPixeltoY(py));
1224  bool docreate = GetSelectedMarkerName(pad).length() == 0;
1225  bool docheck = false;
1226  bool iscreated = false;
1227 
1228  switch (fiMouseMode) {
1229  case kMouseROOT: {
1230  TObject *obj = GetCanvas()->GetSelected();
1231  if (obj != 0)
1232  if (obj->InheritsFrom(TGo4Marker::Class())
1233  || obj->InheritsFrom(TGo4WinCondView::Class())
1234  || obj->InheritsFrom(TGo4PolyCondView::Class()))
1235  SetSelectedMarkerByMouseClick(pad, obj->GetName());
1236 
1237  break;
1238  }
1239 
1240  case kMousePickCursor: {
1241  // we have a click on our working pad, get coordinates:
1242  gROOT->SetEditorMode("");
1243 
1244  if (docreate) {
1245  TGo4Marker* mark = new TGo4Marker(x, y, 28);
1246  AddMarkerObj(pad, kind_Marker, mark);
1247  Int_t ix = TGo4Marker::GetInstances() - 1;
1248  mark->SetMarkerColor((ix) % 6 + 2);
1249  mark->SetHistogram(GetPadHistogram(pad));
1250  if (!fbPickAgain)
1251  fiMouseMode = kMouseROOT; // reset pick
1252  mark->Draw("");
1253  } else {
1254  TGo4Marker* mark = dynamic_cast<TGo4Marker*>(GetActiveObj(pad, kind_Marker));
1255  if(mark!=0) {
1256  mark->SetX(x);
1257  mark->SetY(y);
1258  }
1259  if (!fbPickAgain) fiMouseMode=kMouseROOT; // reset pick
1260  }
1261  pad->Modified();
1262  pad->Update();
1263 
1264 // RedrawPanel(pad, true);
1265  break;
1266  }
1267 
1268  case kMousePickLimits: {
1269  gROOT->SetEditorMode("");
1270  TGo4WinCond* conny = 0;
1271  Double_t xmin(x), xmax(x), ymin(y), ymax(y);
1272  if (fiPickCounter == 0) {
1273  // pick the first time after enabling limits record:
1274  if (docreate) {
1275  TH1* hist = GetPadHistogram(pad);
1276  bool fbTwoDimRegion = (hist != 0) && (hist->GetDimension() > 1);
1277  int ix = GetNumMarkers(pad, kind_Window);
1278  QString name = "Region " + QString::number(ix + 1);
1279  conny = new TGo4WinCond(name.toLatin1().constData());
1280  iscreated = true;
1281  if (fbTwoDimRegion)
1282  conny->SetValues(0, 0, 0, 0);
1283  else
1284  conny->SetValues(0, 0);
1285  conny->SetLineColor(GetAutoColor(ix%9 + 1));
1286  conny->SetFillColor(GetAutoColor(ix%9 + 1));
1287  conny->SetFillStyle(3002);
1288  conny->SetWorkHistogram(hist);
1289  // adjust two dim region to one dim defaults
1290  conny->SetYRMSDraw(fbTwoDimRegion && conny->IsXRMSDraw());
1291  conny->SetYMeanDraw(fbTwoDimRegion && conny->IsXMeanDraw());
1292  conny->SetYMaxDraw(fbTwoDimRegion && conny->IsXMaxDraw());
1293  AddMarkerObj(pad, kind_Window, conny);
1294  } else
1295  conny = dynamic_cast<TGo4WinCond*>(GetActiveObj(pad, kind_Window));
1296  if(conny==0) return;
1297  fiPickCounter++;
1298  } else
1299  if (fiPickCounter==1) {
1300  conny = dynamic_cast<TGo4WinCond*> (GetActiveObj(pad, kind_Window));
1301  if(conny==0) return;
1302  xmin = conny->GetXLow();
1303  ymin = conny->GetYLow();
1304  fiPickCounter=0;
1306  docheck = true;
1307  } else {
1308  std::cout <<"TGo4ViewPanel:PadClickedSlot() NEVER COME HERE" << std::endl;
1309  return;
1310  }
1311  // do not change original condition dimension
1312  if (conny->GetDimension() > 1)
1313  conny->SetValues(xmin, xmax, ymin, ymax);
1314  else
1315  conny->SetValues(xmin, xmax);
1316 
1317  TGo4Slot* condslot = GetSelectedSlot(pad, 0, 0);
1318  if (GetDrawKind(condslot) == kind_Condition) {
1319  TGo4Condition* maincond =
1320  dynamic_cast<TGo4Condition*>(condslot->GetAssignedObject());
1321  if (maincond!=0) maincond->SetChanged(kTRUE);
1322  }
1323 
1324  conny->SetChanged(kTRUE);
1325  if (iscreated)
1326  conny->Draw("");
1327 
1328  pad->Modified();
1329  pad->Update();
1330  // RedrawPanel(pad, true);
1331  break;
1332  }
1333 
1334  case kMousePickPolygon: {
1335  //std::cout <<"TGo4ViewPanel:PadClickedSlot() in kMousePickPolygon" << std::endl;
1336  gROOT->SetEditorMode("");
1337  TGo4PolyCond* cond = 0;
1338 
1339  if (fiPickCounter == 0) {
1340  // pick the first time after enabling limits record:
1341  if (docreate) {
1342  TH1* hist = GetPadHistogram(pad);
1343  int ix = GetNumMarkers(pad, kind_Poly);
1344  QString name = "Polygon " + QString::number(ix + 1);
1345  cond = new TGo4PolyCond(name.toLatin1().constData());
1346  iscreated = true;
1347  AddMarkerObj(pad, kind_Poly, cond);
1348  cond->SetWorkHistogram(hist);
1349  } else {
1350  cond = dynamic_cast<TGo4PolyCond*>(GetActiveObj(pad, kind_Poly));
1351  // start region from the beginning
1352  if (cond!=0) {
1353  TCutG* cut = cond->GetCut(kTRUE);
1354  delete cut;
1355  }
1356  }
1357  if(cond==0) return;
1358  fiPickCounter++;
1359  } else {
1360  cond = dynamic_cast<TGo4PolyCond*> (GetActiveObj(pad, kind_Poly));
1361  if(cond==0) return;
1362  fiPickCounter++;
1363  }
1364 
1365  if (cond != 0) {
1366  TCutG* cut = cond->GetCut(kFALSE);
1367 
1368  // this insert point in last mouse position
1369  if (cut == 0) {
1370  cut = new TCutG(TGo4PolyCond::NextAvailableName(), 1);
1371  cut->SetPoint(0, x, y);
1372  cond->SetValuesDirect(cut);
1373  } else {
1374  cut->InsertPoint();
1375  }
1376 
1377  cond->SetChanged(kTRUE);
1378 
1379  int ix = GetNumMarkers(pad, kind_Poly);
1380 
1381  cond->SetLineColor(GetAutoColor(ix%9 + 1));
1382  cond->SetFillColor(GetAutoColor(ix%9 + 1));
1383  cond->SetFillStyle(3002);
1384  }
1385 
1386  // mark condition
1387  TGo4Slot* condslot = GetSelectedSlot(pad, 0, 0);
1388  if (GetDrawKind(condslot) == kind_Condition) {
1389  TGo4Condition* maincond =
1390  dynamic_cast<TGo4Condition*>(condslot->GetAssignedObject());
1391  if (maincond!=0) maincond->SetChanged(kTRUE);
1392  }
1393 
1394  if (iscreated)
1395  cond->Draw("");
1396 
1397  pad->Modified();
1398  pad->Update();
1399  // RedrawPanel(pad, true);
1400  break;
1401  }
1402 
1403  case kMousePickLatex: {
1404  gROOT->SetEditorMode("");
1405  if (docreate) {
1406  int ix = GetNumMarkers(pad, kind_Latex);
1407  QString name = QString("Label ") + QString::number(ix + 1);
1408  bool ok;
1409  QString txt = QInputDialog::getText(this,
1410  "Enter new LaTeX label text:", name, QLineEdit::Normal,
1411  QString::null, &ok);
1412  if (ok && (txt.length() > 0)) {
1413  TLatex* latex = new TLatex(x, y, name.toLatin1().constData());
1414  latex->SetName(name.toLatin1().constData());
1415  latex->SetTitle(txt.toLatin1().constData());
1416  AddMarkerObj(pad, kind_Latex, latex);
1417  latex->Draw();
1418  } else {
1420  }
1421  } else {
1422  TLatex* latex = dynamic_cast<TLatex*>(GetActiveObj(pad, kind_Latex));
1423  if(latex!=0) {
1424  latex->SetX(x);
1425  latex->SetY(y);
1426  }
1427  }
1428  if (!fbPickAgain)
1429  fiMouseMode = kMouseROOT; // reset pick
1430 
1431  pad->Modified();
1432  pad->Update();
1433 // RedrawPanel(pad, true);
1434  break;
1435  }
1436 
1437  case kMouseDraw: {
1438  gROOT->SetEditorMode("");
1439  if (fiPickCounter == 0) {
1440  // pick the first time after enabling limits record:
1441  TArrow* arrow = new TArrow(x, y, x, y, 0.02);
1442  AddMarkerObj(pad, kind_Arrow, arrow);
1443  fiPickCounter++;
1444  arrow->Draw("");
1445  } else if (fiPickCounter == 1) {
1446  TArrow* arrow = dynamic_cast<TArrow*>(GetActiveObj(pad, kind_Arrow));
1447  if(arrow!=0) {
1448  arrow->SetX2(x);
1449  arrow->SetY2(y);
1450  }
1451  if(!fbPickAgain) fiMouseMode=kMouseROOT; // reset pick
1452  fiPickCounter=0;
1453  } else {
1454  std::cout <<"TGo4ViewPanel:MouseClick() NEVER COME HERE" << std::endl;
1455  return;
1456  }
1457  // do not change original condition dimension
1458  pad->Modified();
1459  pad->Update();
1460 
1461  // RedrawPanel(pad, true);
1462  break;
1463  }
1464  }
1465 
1466  if (docheck)
1467  CheckActionAtTheEnd(pad);
1468 }
1469 
1471 {
1472  bool goback = true;
1473 
1474 // uncomment this code to have loop mode for array of conditions
1475 
1476 // if(fbPickAgain) {
1477 // QString selname = GetSelectedMarkerName(pad);
1478 // int selindex = GetSelectedMarkerIndex(pad);
1479 // if (selindex>=0) {
1480 // TGo4Slot* slot = GetSelectedSlot(pad, 0, 0);
1481 // TGo4CondArray* arr = 0;
1482 // if (slot!=0)
1483 // arr = dynamic_cast<TGo4CondArray*> (slot->GetAssignedObject());
1484 // if (arr!=0) {
1485 // if (selindex<arr->GetNumber()-1) {
1486 // SetSelectedMarker(pad, selname, selindex+1);
1487 // goback = false;
1488 // }
1489 // else
1490 // SetSelectedMarker(pad, "", -1);
1491 // }
1492 // }
1493 // }
1494  if (goback) {
1496  ServiceCall("ActivateConditionEditor");
1497  fbLeaveFocusAfterCondEnd = false;
1498 // MarkPadModified(pad);
1499 // ShootRepaintTimer(pad);
1500  }
1501 }
1502 
1504 {
1505  bool res = false;
1506  bool needredraw = false; // complete repaint
1507  bool needupdate = false; // only pad update
1508  bool needrefresh = false; // refresh buttons
1509  bool docheck = false;
1510  bool candelete = !IsConditionSelected(pad);
1511 
1512  switch (fiMouseMode) {
1513  case kMousePickLimits: {
1514  if (fiPickCounter > 0) {
1515  TGo4WinCond* cond = dynamic_cast<TGo4WinCond*>(GetActiveObj(pad, kind_Window));
1516  if (cond!=0) {
1517  if (candelete) DeleteDrawObject(pad, cond);
1518  needredraw = true;
1519  }
1520  fiPickCounter = 0;
1522  docheck = true;
1523  }
1524 
1525  res = true;
1526  break;
1527  }
1528 
1529  case kMousePickPolygon: {
1530  if (fiPickCounter>0) {
1531  TGo4PolyCond* cond = dynamic_cast<TGo4PolyCond*> (GetActiveObj(pad,kind_Poly));
1532  if (cond!=0) {
1533  bool delcond = true;
1534  TCutG* cut = cond->GetCut(kFALSE);
1535  if (cut!=0) {
1536  int n = cut->GetN();
1537  Double_t x, y;
1538  cut->GetPoint(0, x, y);
1539  delcond = (n<3);
1540 
1541  if (n>=3)
1542  cut->SetPoint(n, x, y);
1543 
1544  int ix = GetNumMarkers(pad, kind_Poly);
1545  cond->SetLineColor(GetAutoColor(ix%9 + 1));
1546  cond->SetFillColor(GetAutoColor(ix%9 + 1));
1547  cond->SetFillStyle(3002);
1548  }
1549 
1550  if (delcond && candelete) {
1551  DeleteDrawObject(pad, cond);
1552  needredraw = true;
1553  } else {
1554  needupdate = true;
1555  }
1556  }
1558  fiPickCounter = 0;
1559  docheck = true;
1560  }
1561 
1562  needrefresh = true;
1563  res = true;
1564  break;
1565  }
1566 
1567  case kMouseDraw: {
1568  if (fiPickCounter>0) {
1569  TArrow* arrow = dynamic_cast<TArrow*> (GetActiveObj(pad, kind_Arrow));
1570  if (arrow!=0) {
1571  DeleteDrawObject(pad, arrow);
1572  needredraw = true;
1573  }
1574  fiPickCounter = 0;
1576  }
1577  res = true;
1578  break;
1579  }
1580  }
1581  if (needredraw)
1582  RedrawPanel(pad, true);
1583  else {
1584  if (needupdate) {
1585  pad->Modified();
1586  pad->Update();
1587  }
1588  if (needrefresh)
1589  RefreshButtons();
1590  }
1591 
1592  if (docheck)
1593  CheckActionAtTheEnd(pad);
1594 
1595  return res;
1596 }
1597 
1599 {
1600  if (CompleteMarkerEdit(pad)) return;
1601  if (fxDoubleClickTimerPad != 0) return;
1602 
1603  fxDoubleClickTimerPad = pad;
1604  QTimer::singleShot(100, this, SLOT(ProcessPadDoubleClick()));
1605 }
1606 
1607 void TGo4ViewPanel::CanvasDropEventSlot(QDropEvent* event, TPad* pad)
1608 {
1609  emit widgetService(this, service_DropEvent, (const char*) pad, event);
1610 }
1611 
1612 void TGo4ViewPanel::CanvasStatusEventSlot(const char* message)
1613 {
1614  if (CanvasStatus != 0)
1615  CanvasStatus->showMessage(message);
1616 }
1617 
1619 {
1620  if (fxDoubleClickTimerPad == 0) return;
1621 
1622  if (GetNumberOfPads(GetCanvas()) <= 1) {
1623  MoveScale(1,0,0,0);
1625  return;
1626  }
1627 
1628  TGo4Picture pic;
1631 
1632  if (pic.GetNumObjNames() == 0) return;
1633 
1634  TGo4ViewPanel* newpanel = CreateViewPanel();
1635  newpanel->ProcessPictureRedraw("", newpanel->GetCanvas(), &pic);
1636  newpanel->ShootRepaintTimer();
1637 }
1638 
1639 void TGo4ViewPanel::MenuCommandExecutedSlot(TObject* obj, const char* cmdname)
1640 {
1641  TPad* pad = dynamic_cast<TPad*>(obj);
1642  if (pad != 0)
1643  UpdatePadStatus(pad, true);
1644 
1645  Browser()->Scan_gROOT();
1646 
1647  if ((strcmp(cmdname, "UnZoom") == 0) && obj->InheritsFrom(TAxis::Class())) {
1648 
1649  // this code is done specially to treat unzoom in the THStack
1650 
1651  TGo4Iter iter(GetPanelSlot(), kTRUE);
1652  TGo4Slot* subslot = 0;
1653 
1654  do {
1655  if (subslot == 0)
1656  subslot = GetPanelSlot();
1657  else
1658  subslot = iter.getslot();
1659 
1660  TPad* subpad = GetSlotPad(subslot);
1661  if (subpad == 0)
1662  continue;
1663 
1664  TGo4Slot* sislot = GetSuperimposeSlot(subslot);
1665  if (sislot == 0)
1666  continue;
1667 
1668  THStack* hs = dynamic_cast<THStack*>(sislot->GetAssignedObject());
1669  if(hs==0) continue;
1670 
1671  TH1* framehisto = hs->GetHistogram();
1672  if (framehisto == 0) continue;
1673 
1674  if (framehisto->GetXaxis() != obj) continue;
1675 
1676  TIter next(hs->GetHists());
1677  TH1* hs_h1 = 0;
1678  while ((hs_h1 = (TH1*) next()) != 0)
1679  hs_h1->GetXaxis()->UnZoom();
1680 
1681  return;
1682  } while (iter.next());
1683  }
1684 
1685 }
1686 
1688 {
1689  ResizeGedEditor();
1690 }
1691 
1693 {
1694  ServiceCall("SavePanelCanvas");
1695 }
1696 
1698 {
1699  TGo4Picture* pic = new TGo4Picture(GetPanelName(), "Copy of picture");
1700 
1701  MakePictureForPad(pic, GetCanvas(), false);
1702 
1703  SaveObjectInMemory("", pic);
1704 }
1705 
1707 {
1708  // get list of markers here
1709  TObjArray markers;
1711  Int_t npts = markers.GetEntries();
1712  //std::cout <<"Found "<<npts<<" markers in pad" << std::endl;
1713  if (npts == 0)
1714  return;
1715  // create arrays of length
1716  TArrayD x(npts), y(npts);
1717  // copy marker values to array:
1718  for (Int_t j = 0; j < npts; ++j) {
1719  TGo4Marker* mark = dynamic_cast<TGo4Marker*>(markers[j]);
1720  if (mark == 0) {
1721  std::cout << "NEVER COME HERE: no marker at index " << j << std::endl;
1722  return;
1723  }
1724  x[j] = mark->GetX();
1725  y[j] = mark->GetY();
1726  //std::cout <<"Set point "<<j <<" to x="<<x[j]<<", y="<<y[j]<< std::endl;
1727  }
1728 
1729  // create graph from points array:
1730  TString grname = GetPanelName() + TString("-Markergraph");
1731  TGraph* graf = new TGraph(npts, x.GetArray(), y.GetArray());
1732  graf->SetName(grname.Data());
1733  graf->SetMarkerStyle(28);
1734  SaveObjectInMemory("", graf);
1735 }
1736 
1737 void TGo4ViewPanel::MakePictureForPad(TGo4Picture* pic, TPad* pad, bool useitemname)
1738 {
1739  TGo4Picture* padopt = GetPadOptions(pad);
1740  TGo4Slot* slot = GetPadSlot(pad);
1741  if ((padopt == 0) || (slot == 0)) return;
1742 
1743  pic->CopyOptionsFrom(padopt);
1744 
1747 
1748  if (pad == GetCanvas() && fbFreezeTitle)
1749  pic->SetTitle(fFreezedTitle.toLatin1().constData());
1750 
1751  if (!padopt->IsXYRatioOne())
1752  pic->SetFrameAttr(pad);
1753 
1754  int objnamenum = 0;
1755 
1756  for (int n = 0; n < slot->NumChilds(); n++) {
1757  TGo4Slot* subslot = slot->GetChild(n);
1758  int kind = GetDrawKind(subslot);
1759 
1760  if ((kind == kind_Arrow) || (kind == kind_Latex) || (kind == kind_Marker)
1761  || (kind == kind_Window) || (kind == kind_Poly) || (kind == kind_Func)
1762  || (kind == kind_Specials)) {
1763  TObject* obj = subslot->GetAssignedObject();
1764  const char* drawopt = GetSpecialDrawOption(subslot);
1765 
1766  if (obj != 0) {
1767  if (dynamic_cast<TLatex*>(obj) || dynamic_cast<TF1*>(obj)) {
1768  // test here if we have local object or monitored remote one
1769  if (dynamic_cast<TGo4ObjectProxy*>(subslot->GetProxy())) {
1770  // make clone when really needed
1771  pic->AddSpecialObject(obj->Clone(), drawopt);
1772  } else if (dynamic_cast<TGo4LinkProxy*>(subslot->GetProxy())) {
1773  const char* itemname = GetLinkedName(subslot);
1774  if (itemname != 0)
1775  pic->AddObjName(itemname, drawopt);
1776  } else {
1777  TGo4Log::Error("MakePictureForPad NEVER COME HERE, unknown proxy type");
1778  }
1779  } else {
1780  obj = obj->Clone();
1781 
1782  TGo4Marker* mark = dynamic_cast<TGo4Marker*>(obj);
1783  if (mark != 0) mark->DeletePainter();
1784  TGo4Condition* cond = dynamic_cast<TGo4Condition*>(obj);
1785  if (cond != 0) cond->DeletePainter();
1786 
1787  pic->AddSpecialObject(obj, drawopt);
1788  }
1789  }
1790  continue;
1791  }
1792 
1793  if ((kind != kind_Link) && (kind != kind_Condition))
1794  continue;
1795 
1796  const char* drawopt = padopt->GetDrawOption(objnamenum++);
1797 
1798  if (useitemname) {
1799  const char* itemname = GetLinkedName(subslot);
1800  if (itemname != 0)
1801  pic->AddObjName(itemname, drawopt);
1802  } else {
1803  TNamed* nm = dynamic_cast<TNamed*>(subslot->GetAssignedObject());
1804  if (nm!=0) pic->AddObjName(nm->GetName(), drawopt);
1805  }
1806 
1807  Int_t rebinx, rebiny;
1808  if (subslot->GetIntPar("::HasRebinX", rebinx))
1809  pic->SetRebinX(rebinx);
1810  if (subslot->GetIntPar("::HasRebinY", rebiny))
1811  pic->SetRebinY(rebiny);
1812  }
1813 
1814  TObjArray pads;
1815 
1816  for (int n = 0; n < slot->NumChilds(); n++) {
1817  TGo4Slot* subslot = slot->GetChild(n);
1818  TPad* subpad = GetSlotPad(subslot);
1819  if (subpad != 0)
1820  pads.Add(subpad);
1821  }
1822  if (pads.GetLast() < 0)
1823  return;
1824 
1825  double lastx = -1;
1826  int xcnt = 0, sizex = 1, sizey = 1;
1827  for (int n = 0; n <= pads.GetLast(); n++) {
1828  TPad* subpad = (TPad*) pads.At(n);
1829  double mitx = subpad->GetXlowNDC() + subpad->GetWNDC() / 2.;
1830  if (mitx > lastx) {
1831  xcnt++;
1832  lastx = mitx;
1833  } else {
1834  xcnt = 0;
1835  lastx = -1;
1836  }
1837  if (xcnt > sizex)
1838  sizex = xcnt;
1839  }
1840 
1841  while (sizex * sizey <= pads.GetLast())
1842  sizey++;
1843 
1844  pic->SetDivision(sizey, sizex);
1845 
1846  for (int ny = 0; ny < sizey; ny++)
1847  for (int nx = 0; nx < sizex; nx++) {
1848  int indx = ny * sizex + nx;
1849  if (indx > pads.GetLast())
1850  break;
1851  TPad* subpad = (TPad*) pads.At(indx);
1852  MakePictureForPad(pic->Pic(ny, nx), subpad, useitemname);
1853  }
1854 }
1855 
1857 {
1858  TGo4PrintWidget dlg;
1859  if (dlg.exec() != QDialog::Accepted)
1860  return;
1861 
1863 
1864  QString outfile = "~/go4printout.ps";
1865  QString PrnCmd = dlg.GetPrintProg() + " -P " + dlg.GetPrinter() + " "
1866  + outfile;
1867  QString DelCmd = QString("rm -f ") + outfile;
1868 
1869  GetCanvas()->Print(outfile.toLatin1().constData());
1870  gSystem->Exec(PrnCmd.toLatin1().constData());
1871  gSystem->Exec(DelCmd.toLatin1().constData());
1872 }
1873 
1875 {
1876 #ifndef __NOGO4GED__
1878  EditorFrame->setVisible(fbEditorFrameVisible);
1879  if (fbEditorFrameVisible && (fxPeditor == 0)) {
1880  TGo4LockGuard lock;
1882 
1883 #if QT_VERSION > QT_VERSION_CHECK(5,6,0)
1884  // JAM the following is pure empiric. hopefully default denominator won't change in future qt?
1885  double scalefactor=(double) metric(QPaintDevice::PdmDevicePixelRatioScaled)/65536.;
1886  EditorFrame->setMinimumWidth( EditorFrame->minimumWidth()/scalefactor);
1887 #endif
1888  fxRooteditor->SetResizeOnPaint(kFALSE); // disable internal resize on paintEvent, we use ResizeGedEditor
1889  fxRooteditor->SetEditable(); // mainframe will adopt pad editor window
1890  fxPeditor = TVirtualPadEditor::LoadEditor();
1891  fxPeditor->SetGlobal(kFALSE);
1892  fxRooteditor->SetEditable(kFALSE); // back to window manager as root window
1894  } else {
1896  }
1897 
1898  show();
1899  ResizeGedEditor();
1900 #endif
1901 }
1902 
1904 {
1905  TGo4Slot* padslot = GetPadSlot(GetActivePad());
1906  if (padslot == 0)
1907  return;
1908 
1909  for (int n = 0; n < padslot->NumChilds(); n++) {
1910  TGo4Slot* subslot = padslot->GetChild(n);
1911  int drawkind = GetDrawKind(subslot);
1912  if (drawkind != kind_Condition)
1913  continue;
1914  const char* itemname = GetLinkedName(subslot);
1915  if (itemname != 0) {
1916  EditItem(itemname);
1917  return;
1918  }
1919  }
1920 }
1921 
1923 {
1924  if (pad == 0) return;
1925 
1926  double defleft =gStyle->GetPadLeftMargin(); // always refer to ideal margins
1927  double defright =gStyle->GetPadRightMargin();
1928  double deftop =gStyle->GetPadTopMargin();
1929  double defbottom =gStyle->GetPadBottomMargin();
1930 
1931  double dx = fabs(pad->AbsPixeltoX(1) - pad->AbsPixeltoX(0));
1932  double dy = fabs(pad->AbsPixeltoY(1) - pad->AbsPixeltoY(0));
1933  //std::cout <<"-- dx:"<<dx<<", dy:"<<dy<< std::endl;
1934  if ((dx <= 0) || (dy <= 0)) return;
1935  double ratio = dx / dy;
1936  //std::cout <<"-- Ratio is:"<<ratio<< std::endl;
1937  if(fabs(1.0-ratio) < 1.0E-3)
1938  {
1939  //std::cout <<"DO NOT CHANGE!"<< std::endl;
1940  return; // do not change margins again!
1941  }
1942 
1943 
1944  if (ratio < 1.) {
1945 
1946  double left = pad->GetLeftMargin();
1947  double right = pad->GetRightMargin();
1948  double change = (1. - left - right) * (1 - ratio);
1949  //std::cout <<"-- left:"<<left<<", right:"<<right<<", change:"<<change<< std::endl;
1950  double newleft=left + change / 2.;
1951  double newright=right + change / 2.;
1952  double newtop= pad->GetTopMargin();
1953  double newbottom= pad->GetBottomMargin();
1954  //std::cout << " -- newleft"<<newleft<<", newright"<<newright;
1955  //std::cout <<"newtop:"<<newtop<<", newbottom:"<<newbottom<< std::endl;
1956  double shrink=newtop- deftop; // zoom everything consistent to the default margins
1957  if(shrink>newleft-defleft) shrink=newleft-defleft; // avoid exceeding default boundaries
1958  if(shrink>newright-defright) shrink=newright-defright; // avoid exceeding default boundaries
1959 
1960  // now scale all margins up to the point that any margin reaches default margin:
1961  newtop=newtop-shrink;
1962  newbottom=newbottom-shrink;
1963  newleft=newleft-shrink;
1964  newright=newright-shrink;
1965  //std::cout << "after shrink="<<shrink<<" :";
1966  //std::cout << " -- newleft"<<newleft<<", newright"<<newright;
1967  //std::cout <<"newtop:"<<newtop<<", newbottom:"<<newbottom<< std::endl;
1968 
1969  pad->SetLeftMargin(newleft);
1970  pad->SetRightMargin(newright);
1971  pad->SetTopMargin(newtop);
1972  pad->SetBottomMargin(newbottom);
1973  } else {
1974 
1975  double bottom = pad->GetBottomMargin();
1976  double top = pad->GetTopMargin();
1977  double change = (1. - bottom - top) * (1. - 1 / ratio);
1978  //std::cout <<"-- left:"<<left<<", right:"<<right<<", change:"<<change<< std::endl;
1979  double newleft=pad->GetLeftMargin();
1980  double newright=pad->GetRightMargin();
1981  double newtop= top + change / 2.;
1982  double newbottom= bottom + change / 2.;
1983  //std::cout << " -- newleft"<<newleft<<", newright"<<newright;
1984  //std::cout <<"newtop:"<<newtop<<", newbottom:"<<newbottom<< std::endl;
1985  double shrink=newleft - defleft;
1986  if(shrink>newtop-deftop) shrink=newtop-deftop; // avoid exceeding default boundaries
1987  if(shrink>newbottom-defbottom) shrink=newbottom-defbottom; // avoid exceeding default boundaries
1988  // now scale all margins up to the point that any margin reaches default margin:
1989  newtop=newtop - shrink;
1990  newbottom=newbottom -shrink;
1991  newleft=newleft- shrink;
1992  newright=newright - shrink;
1993  //std::cout << "after shrink="<<shrink<<" :";
1994  //std::cout << " -- newleft"<<newleft<<", newright"<<newright;
1995  //std::cout <<"newtop:"<<newtop<<", newbottom:"<<newbottom<< std::endl;
1996 
1997  pad->SetTopMargin(newtop);
1998  pad->SetBottomMargin(newbottom);
1999  pad->SetLeftMargin(newleft);
2000  pad->SetRightMargin(newright);
2001  }
2002 }
2003 
2005 {
2006  if (pad == 0) return;
2007  pad->SetLeftMargin(gStyle->GetPadLeftMargin());
2008  pad->SetRightMargin(gStyle->GetPadRightMargin());
2009  pad->SetTopMargin(gStyle->GetPadTopMargin());
2010  pad->SetBottomMargin(gStyle->GetPadBottomMargin());
2011 }
2012 
2014 {
2015  TPad* pad = GetActivePad();
2016  if (pad == 0)
2017  pad = GetCanvas();
2018 
2019  ClearPad(pad, true, false);
2020 
2021  RedrawPanel(pad, true);
2022 }
2023 
2025 {
2026  // TGo4LockGuard glob;
2027 
2028  ClearPad(GetCanvas(), true, true);
2029 
2031 
2032  RedrawPanel(GetCanvas(), true);
2033 }
2034 
2036 {
2037  TPad* pad = GetActivePad();
2038  if (pad == 0)
2039  pad = GetCanvas();
2040 
2041  TGo4Picture *padopt = GetPadOptions(pad);
2042 
2043  SetIdAction(fOptionsMap, StatisticsId, true, padopt->IsHisStats());
2046  SetIdAction(fOptionsMap, SetTitleId, true, padopt->IsHisTitle());
2048  padopt->IsTitleTime());
2050  padopt->IsTitleDate());
2052  padopt->IsTitleItem());
2055  SetIdAction(fOptionsMap, SetLegendId, true, padopt->IsLegendDraw());
2057  padopt->IsXAxisTimeDisplay());
2059 
2060 }
2061 
2063 {
2064  TGo4LockGuard lock;
2065  if (id == BringToFrontId) {
2069  }
2070  return;
2071  }
2072 
2073  int selected = TGo4Picture::PictureIndex;
2074 
2075  if (id != MasterSelectId)
2076  selected = id - FirstSelectId;
2077 
2078  TGo4Slot* slot = GetPadSlot(GetActivePad());
2079  if (slot == 0)
2080  return;
2081 
2082  int wasselected = GetSelectedObjectIndex(slot);
2083 
2084  SetSelectedObjectIndex(slot, selected);
2085 
2086  if (selected != wasselected) {
2089  }
2090 
2091  if (selected != TGo4Picture::PictureIndex)
2093 }
2094 
2096 {
2098 
2099  fxQCanvas->setShowEventStatus(fbCanvasEventstatus);
2100  CanvasStatus->setVisible(fbCanvasEventstatus);
2101  if (!fbCanvasEventstatus)
2103 }
2104 
2105 void TGo4ViewPanel::UpdatePadStatus(TPad* pad, bool removeitems)
2106 {
2107  if (GetPadSlot(pad) == 0)
2108  return;
2109 
2110  BlockPanelRedraw(true);
2111  ProcessPadStatusUpdate(pad, 0, removeitems);
2112  BlockPanelRedraw(false);
2113 }
2114 
2116  bool removeitems)
2117 {
2118  if (pad == 0)
2119  return;
2120 
2121  TGo4Slot* slot = 0;
2122 
2123  bool setdefaults = false;
2124  if (parent == 0) {
2125  slot = GetPadSlot(pad);
2126  if (slot == 0)
2127  return;
2128  } else {
2129  slot = parent->FindChild(pad->GetName());
2130  // create slot for subpad if not existing
2131  if (slot == 0) {
2132  slot = AddNewSlot(pad->GetName(), parent);
2133  SetDrawKind(slot, kind_PadSlot);
2134  setdefaults = true;
2135  }
2136  }
2137 
2138  SetSlotPad(slot, pad);
2139 
2140  TGo4Picture* padopt = GetPadOptions(slot);
2141 
2142  padopt->SetPadModified();
2143 
2144  bool issubpads = false;
2145 
2146  bool isdupluicate = false;
2147 
2148  // check if pads with duplicate names appears in list.
2149  // Remove first copies. Can appiar by RMB menu Divide call
2150  do {
2151  TObjArray subpads;
2152  isdupluicate = false;
2153  TIter iter(pad->GetListOfPrimitives());
2154  TObject* obj = 0;
2155  while ((obj = iter()) != 0) {
2156  TPad* subpad = dynamic_cast<TPad*>(obj);
2157  if (subpad == 0)
2158  continue;
2159  issubpads = true;
2160  if (subpads.FindObject(subpad->GetName()) != 0)
2161  isdupluicate = true;
2162  if (!isdupluicate)
2163  subpads.Add(subpad);
2164  }
2165  if (isdupluicate) {
2166  pad->GetListOfPrimitives()->RemoveAll(&subpads);
2167  subpads.Delete();
2168  subpads.Compress();
2169  padopt->SetPadModified();
2170  }
2171 
2172  } while (isdupluicate);
2173 
2174  // remove all subslots, which are correspond to non-existing subpads
2175  for (int n = slot->NumChilds() - 1; n >= 0; n--) {
2176  TGo4Slot* subslot = slot->GetChild(n);
2177  TPad* subpad = GetSlotPad(subslot);
2178  if (subpad != 0)
2179  if (pad->GetListOfPrimitives()->FindObject(subpad) == 0)
2180  delete subslot;
2181  else
2182  issubpads = true;
2183  }
2184 
2185  if (setdefaults)
2186  SetPadDefaults(pad);
2187 
2188  if (!issubpads)
2189  return;
2190 
2191  TIter iter(pad->GetListOfPrimitives());
2192  TObjArray removedItems;
2193  TObject* obj = 0;
2194  while ((obj = iter()) != 0) {
2195  TPad* subpad = dynamic_cast<TPad*>(obj);
2196  if (subpad != 0)
2197  ProcessPadStatusUpdate(subpad, slot, removeitems);
2198  else
2199  removedItems.Add(obj);
2200  }
2201 
2202  pad->GetListOfPrimitives()->RemoveAll(&removedItems);
2203 
2204  if (removeitems)
2205  ClearPadItems(slot, 0);
2206 }
2207 
2208 TGo4Slot* TGo4ViewPanel::AddDrawObject(TPad* pad, int kind, const char* itemname,
2209  TObject* obj, bool owner, const char* drawopt)
2210 {
2211  TGo4Slot* padslot = GetPadSlot(pad);
2212 
2213  if (padslot == 0) {
2214  if (owner) delete obj;
2215  return 0;
2216  }
2217 
2218  //std::cout << "Add object = " << (obj ? obj->ClassName() : "---") << " pad = " << pad->GetName() << " kind = " << kind << std::endl;
2219 
2220  // clear only if link is added
2221  if (kind < 100)
2222  ClearPad(pad, false, true);
2223 
2224  TGo4Slot* tgtslot = 0;
2225 
2226  if (kind == kind_Link) {
2227  TClass* cl = Browser()->ItemClass(itemname);
2228  if ((cl != 0) && cl->InheritsFrom(TGo4Condition::Class()))
2229  UndrawItem(itemname);
2230 
2231 // std::cout << "Item " << itemname << " class = " << (cl ? cl->GetName() : "null") << std::endl;
2232 
2233  TGo4Slot* brslot = Browser()->BrowserSlot(itemname);
2234 
2235  if (brslot != 0) {
2236  tgtslot = AddNewSlot(brslot->GetName(), padslot);
2237  SetLinkedName(tgtslot, itemname);
2238  if (fbCloneFlag)
2239  tgtslot->SetProxy(new TGo4DrawCloneProxy(brslot, this));
2240  else
2241  tgtslot->SetProxy(new TGo4LinkProxy(brslot));
2242  }
2243  } else {
2244 
2245  QString newslotname = itemname;
2246  if ((newslotname.length() == 0)
2247  || (padslot->FindChild(newslotname.toLatin1().constData()) != 0)) {
2248  int cnt = 0;
2249  do {
2250  if ((itemname == 0) || (*itemname == 0))
2251  newslotname = "::SpecialObject_";
2252  else
2253  newslotname = itemname;
2254  newslotname += QString::number(cnt++);
2255  } while (padslot->FindChild(newslotname.toLatin1().constData()) != 0);
2256  }
2257  tgtslot = AddNewSlot(newslotname.toLatin1().constData(), padslot);
2258  tgtslot->SetProxy(new TGo4ObjectProxy(obj, owner));
2259  }
2260 
2261  if (tgtslot == 0) return 0;
2262 
2263  if (kind < 100)
2265 
2266  tgtslot->SetPar("::FirstDraw", "true");
2267  SetDrawKind(tgtslot, kind);
2268  SetSpecialDrawOption(tgtslot, drawopt);
2269 
2270  TGo4Picture* padopt = GetPadOptions(padslot);
2271  if (padopt != 0) {
2272  padopt->SetContentModified(true);
2273  padopt->SetPadModified();
2274  if ((kind < 100) && (drawopt != 0))
2275  padopt->SetDrawOption(drawopt, TGo4Picture::PictureIndex);
2276  }
2277 
2278  return tgtslot;
2279 }
2280 
2281 TGo4Slot* TGo4ViewPanel::GetDrawObjectSlot(TPad* pad, const char* name)
2282 {
2283  TGo4Slot* slot = GetPadSlot(pad);
2284 
2285  return slot == 0 ? 0 : slot->FindChild(name);
2286 }
2287 
2288 TObject* TGo4ViewPanel::GetDrawObject(TPad* pad, const char* name)
2289 {
2290  TGo4Slot* subslot = GetDrawObjectSlot(pad, name);
2291 
2292  return subslot == 0 ? 0 : subslot->GetAssignedObject();
2293 }
2294 
2295 void TGo4ViewPanel::DeleteDrawObject(TPad* pad, const char* name)
2296 {
2297  TGo4Slot* padslot = GetPadSlot(pad);
2298 
2299  TGo4Slot* subslot = padslot == 0 ? 0 : padslot->FindChild(name);
2300 
2301  if (subslot != 0) {
2302  delete subslot;
2303  TGo4Picture* padopt = GetPadOptions(padslot);
2304  if (padopt != 0)
2305  padopt->SetPadModified();
2306  }
2307 }
2308 
2309 void TGo4ViewPanel::DeleteDrawObject(TPad* pad, TObject* obj)
2310 {
2311  TGo4Slot* padslot = GetPadSlot(pad);
2312  if (padslot == 0)
2313  return;
2314  for (int n = 0; n < padslot->NumChilds(); n++) {
2315  TGo4Slot* subslot = padslot->GetChild(n);
2316  if (GetDrawKind(subslot) < 0)
2317  continue;
2318  if (subslot->GetAssignedObject() == obj) {
2319  delete subslot;
2320  break;
2321  }
2322  }
2323 }
2324 
2325 void TGo4ViewPanel::CollectSpecialObjects(TPad* pad, TObjArray* objs,
2326  int selectkind)
2327 {
2328  TGo4Slot* slot = GetPadSlot(pad);
2329  if ((slot == 0) || (objs == 0))
2330  return;
2331 
2332  for (int n = 0; n < slot->NumChilds(); n++) {
2333  TGo4Slot* subslot = slot->GetChild(n);
2334  Int_t kind = GetDrawKind(subslot);
2335  if (kind < 0)
2336  continue;
2337  if ((kind != kind_Link) && ((selectkind < 0) || (kind == selectkind))) {
2338  TObject* obj = subslot->GetAssignedObject();
2339  if (obj != 0)
2340  objs->Add(obj);
2341  }
2342  }
2343 }
2344 
2345 bool TGo4ViewPanel::DeleteDrawObjects(TPad* pad, int kindtodelete)
2346 {
2347  TGo4Slot* slot = GetPadSlot(pad);
2348  TGo4Picture* padopt = GetPadOptions(slot);
2349 
2350  if ((slot == 0) || (padopt == 0))
2351  return false;
2352 
2353  bool res = false;
2354 
2355  for (int n = slot->NumChilds() - 1; n >= 0; n--) {
2356  TGo4Slot* subslot = slot->GetChild(n);
2357  Int_t kind = GetDrawKind(subslot);
2358  if (kind < 0)
2359  continue;
2360  if ((kind != kind_Link)
2361  && ((kindtodelete < 0) || (kind == kindtodelete))) {
2362  res = true;
2363  delete subslot;
2364  }
2365  }
2366  if (res)
2367  padopt->SetPadModified();
2368  return true;
2369 }
2370 
2371 void TGo4ViewPanel::SetPadSuperImpose(TPad* pad, bool on)
2372 {
2373  TGo4Picture* padopt = GetPadOptions(pad);
2374  if (padopt != 0) {
2375  padopt->SetSuperimpose(on);
2376  padopt->SetPadModified();
2377  }
2378 }
2379 
2381 {
2382  fbModifiedSignalFlag = false;
2383  if (GetActivePad() == 0)
2384  return;
2385 
2387  GetPadOptions(GetActivePad()), true))
2389 }
2390 
2391 bool TGo4ViewPanel::ScanDrawOptions(TPad* pad, TGo4Slot* padslot,
2392  TGo4Picture* pic, bool onlyscan)
2393 {
2394  TGo4LockGuard lock;
2395 
2396  if ((pad == 0) || (pic == 0) || (padslot == 0))
2397  return false;
2398 
2399  bool optchanged = false;
2400  TObjLink* link = pad->GetListOfPrimitives()->FirstLink();
2401 
2402  while (link != 0) {
2403  const char* clname = link->GetObject()->ClassName();
2404  if ((strcmp(clname, "TFrame") == 0) || (strcmp(clname, "TLegend") == 0)) {
2405 
2406  // comment out, can never be working
2407  //TPaveText* titl = dynamic_cast<TPaveText*>(link->GetObject());
2408  //if (titl &&(strcmp(titl->GetName(),"title")==0))
2409  // pic->SetTitleAttr(titl);
2410 
2411  link = link->Next();
2412  } else
2413  break;
2414  }
2415 
2416  // take draw options from first drawn object
2417  if (link != 0) {
2418 
2419  TString newopt(link->GetOption());
2420  Int_t drawoptindx =
2421  GetSuperimposeSlot(padslot) == 0 ? 0 : TGo4Picture::PictureIndex;
2422  TString oldopt(pic->GetDrawOption(drawoptindx));
2423 
2424  while (newopt.BeginsWith(NoStackDrawOption, TString::kIgnoreCase))
2425  newopt.Remove(0, strlen(NoStackDrawOption));
2426 
2427  if (!oldopt.Contains("asimage"))
2428  if ((newopt.Length() != oldopt.Length())
2429  || (newopt.CompareTo(oldopt, TString::kIgnoreCase) != 0)) {
2430  optchanged = true;
2431  pic->SetDrawOption(newopt.Data(), drawoptindx);
2432  }
2433 
2434  TH1* h1 = dynamic_cast<TH1*>(link->GetObject());
2435  // access axis properties of graphs
2436  if(h1==0) {
2437  TGraph* gr=dynamic_cast<TGraph*> (link->GetObject());
2438  if(gr) h1=gr->GetHistogram();
2439  }
2440 
2441  if (h1 != 0) {
2442  TPaveStats* stats =
2443  dynamic_cast<TPaveStats*>(h1->GetListOfFunctions()->FindObject("stats"));
2444  if (h1->TestBit(TH1::kNoStats)) {
2445  pic->SetHisStats(kFALSE);
2446  } else {
2447  pic->SetHisStats(kTRUE);
2448  pic->SetStatsAttr(stats);
2449  }
2450  // test: set here time display
2451  TAxis* xax = h1->GetXaxis();
2452  pic->SetXAxisAttTime(xax->GetTimeDisplay(), xax->GetTimeFormat() ,TGo4Picture::PictureIndex);
2453  //std::cout <<"Set time attributes to pad options: display:"<<xax->GetTimeDisplay()<<", format:"<< xax->GetTimeFormat()<< std::endl;
2454  }
2455 
2456  }
2457 
2458  if (pad->GetLogx() != pic->GetLogScale(0)) {
2459  pic->SetLogScale(0, pad->GetLogx());
2460  optchanged = true;
2461  }
2462 
2463  if (pad->GetLogy() != pic->GetLogScale(1)) {
2464  pic->SetLogScale(1, pad->GetLogy());
2465  optchanged = true;
2466  }
2467 
2468  if (pad->GetLogz() != pic->GetLogScale(2)) {
2469  pic->SetLogScale(2, pad->GetLogz());
2470  optchanged = true;
2471  }
2472 
2473  if (pad == GetCanvas())
2474  fbCanvasCrosshair = pad->HasCrosshair();
2475 
2476  TPaveText* titl =
2477  dynamic_cast<TPaveText*>(pad->GetListOfPrimitives()->FindObject("title"));
2478  if(titl) {
2479  pic->SetTitleAttr(titl);
2480  optchanged = true;
2481  }
2482 
2483  TObjArray objs, objslots;
2484 
2485  CollectMainDrawObjects(padslot, &objs, &objslots, 0);
2486  ScanObjectsDrawOptions(onlyscan, padslot, &objs, &objslots);
2487 
2488  return optchanged;
2489 }
2490 
2492  TObjArray* objs, TObjArray* objslots)
2493 {
2494  TGo4Picture* pic = GetPadOptions(padslot);
2495 
2496  TPad* pad = GetSlotPad(padslot);
2497  if ((pad != 0) && (pic != 0))
2498  if (padslot->GetPar("::DrawOptAssigned") != 0) {
2500  } else if (!onlyscan) {
2502  padslot->SetPar("::DrawOptAssigned", "1");
2503  }
2504 
2505  if ((padslot == 0) || (pic == 0) || (objs == 0) || (objslots == 0))
2506  return;
2507 
2508  for (int n = 0; n <= objs->GetLast(); n++) {
2509  TObject* obj = objs->At(n);
2510  TGo4Slot* subslot = (TGo4Slot*) objslots->At(n);
2511 
2512  if ((obj == 0) || (subslot == 0))
2513  continue;
2514 
2515  if (subslot->GetPar("::DrawOptAssigned") != 0) {
2516  pic->SetDrawAttributes(obj, n);
2517  } else if (!onlyscan) {
2518  pic->GetDrawAttributes(obj, n);
2519  subslot->SetPar("::DrawOptAssigned", "1");
2520  }
2521  }
2522 }
2523 
2525  TObjArray* objslots, int modifier)
2526 {
2527  // modifier == 0 - no objects can be deleted
2528  // == 1 - objects of same types should be in the list
2529  // == 2 - only last object survive
2530  if ((slot == 0) || (objs == 0))
2531  return;
2532 
2533  TObjArray mainslots;
2534 
2535  int lastobjtype = 0;
2536 
2537  for (int n = 0; n < slot->NumChilds(); n++) {
2538  TGo4Slot* subslot = slot->GetChild(n);
2539  Int_t kind = GetDrawKind(subslot);
2540 
2541  if ((kind <= 0) || (kind >= kind_Additional))
2542  continue;
2543 
2544  TObject* obj = subslot->GetAssignedObject();
2545 
2546  if (obj == 0)
2547  continue;
2548 
2549  int objtype = 0;
2550 
2551  if (obj->InheritsFrom(TH1::Class()))
2552  objtype = 1;
2553  else if (obj->InheritsFrom(TGraph::Class()))
2554  objtype = 2;
2555  else if (obj->InheritsFrom(TMultiGraph::Class()))
2556  objtype = 3;
2557  else if (obj->InheritsFrom(THStack::Class()))
2558  objtype = 4;
2559 
2560  // can happen condition here, which is add as link and not identified as condition yet
2561  // should both be recognized as "main" draw object
2562  if (objtype > 0) {
2563  lastobjtype = objtype;
2564  mainslots.Add(subslot);
2565  }
2566  }
2567 
2568  Bool_t deletesomething = kFALSE;
2569 
2570  for (int n = 0; n <= mainslots.GetLast(); n++) {
2571  TGo4Slot* subslot = (TGo4Slot*) mainslots.At(n);
2572  TObject* obj = subslot->GetAssignedObject();
2573  Int_t objtype = 0;
2574  if (obj->InheritsFrom(TH1::Class()))
2575  objtype = 1;
2576  else if (obj->InheritsFrom(TGraph::Class()))
2577  objtype = 2;
2578  else if (obj->InheritsFrom(TMultiGraph::Class()))
2579  objtype = 3;
2580  else if (obj->InheritsFrom(THStack::Class()))
2581  objtype = 4;
2582 
2583  // check if all main object correspond to type of last object
2584  // if no, delete
2585 
2586  if ((n < mainslots.GetLast())
2587  && ((modifier == 2) || ((modifier == 1) && (lastobjtype != objtype)))) {
2588  delete subslot;
2589  deletesomething = kTRUE;
2590  } else {
2591  objs->Add(obj);
2592  if (objslots != 0)
2593  objslots->Add(subslot);
2594  TGo4DrawCloneProxy* pr =
2595  dynamic_cast<TGo4DrawCloneProxy*>(subslot->GetProxy());
2596  if(pr!=0) {
2597  pr->UpdateTitle();
2598  pr->PerformRebin();
2599  }
2600  }
2601  }
2602 
2603  if (deletesomething)
2604  CleanupGedEditor();
2605 
2606  for (int n = 0; n < slot->NumChilds(); n++) {
2607  TGo4Slot* subslot = slot->GetChild(n);
2608 
2609  Int_t kind = GetDrawKind(subslot);
2610  if ((kind >= kind_Additional) && (kind < kind_Specials)) {
2611  TObject* obj = subslot->GetAssignedObject();
2612  if (obj != 0) {
2613  objs->Add(obj);
2614  if (objslots != 0)
2615  objslots->Add(subslot);
2616  }
2617  }
2618  }
2619 }
2620 
2622  if (indx<0) indx = 0;
2623 
2624  switch (indx % 10) {
2625  case 0: return kBlack;
2626  case 1: return kRed;
2627  case 2: return kGreen;
2628  case 3: return kBlue;
2629  case 4: return kCyan;
2630  case 5: return kOrange;
2631  case 6: return kSpring;
2632  case 7: return kViolet;
2633  case 8: return kPink;
2634  case 9: return kAzure;
2635  }
2636 
2637  return kBlack;
2638 }
2639 
2640 
2642  TGo4Slot* sislot, TGo4Slot* legslot, TObjArray* objs,
2643  TObjArray * objslots, bool showitems)
2644 {
2645  if ((sislot == 0) || (objs == 0) || (padopt == 0)) return 0;
2646  TObject* oldobj = sislot->GetAssignedObject();
2647 
2648  Bool_t ishstack = kFALSE;
2649  Bool_t isgstack = kFALSE;
2650  Bool_t iserror = kFALSE;
2651  Bool_t resetcolors = kFALSE;
2652 
2653  for (int n = 0; n <= objs->GetLast(); n++) {
2654  TObject* obj = objs->At(n);
2655  if (obj->InheritsFrom(TH1::Class()))
2656  ishstack = kTRUE;
2657  else if (obj->InheritsFrom(TGraph::Class()))
2658  isgstack = kTRUE;
2659  else
2660  iserror = kTRUE;
2661  }
2662 
2663  // if error, no superimpose is allowed
2664  if (iserror || (ishstack && isgstack)) {
2665  TGo4Log::Error("Superimpose of multiple objects with different types");
2666  std::cout<< "Superimpose of multiple objects with different types"<< std::endl;
2667  return 0;
2668  }
2669 
2670  if (ishstack) {
2671  THStack* hs = dynamic_cast<THStack*>(oldobj);
2672 
2673  if (hs == 0) {
2674  hs = new THStack(objs->First()->GetName(), objs->First()->GetTitle());
2675  sislot->SetProxy(new TGo4DrawObjProxy(hs, kTRUE, kTRUE));
2676  resetcolors = kTRUE;
2677  } else {
2678  if (hs->GetHists())
2679  hs->GetHists()->Clear();
2680  }
2681 
2682  for (int n = 0; n <= objs->GetLast(); n++) {
2683  TH1* histo = (TH1*) objs->At(n);
2684  TGo4Slot* objslot = (TGo4Slot*) objslots->At(n);
2685 
2686  Int_t kind = GetDrawKind(objslot);
2687  Int_t objindx = padslot->GetIndexOf(objslot); // slot index for object starts from 2
2688 
2689  if (resetcolors || (kind == kind_FitModels) || (objslot->GetPar("::FirstDraw") != 0)) {
2690  histo->SetLineColor(GetAutoColor(n));
2691  if ((go4sett->getDrawLineWidth() > 1) && (histo->GetLineWidth()==1))
2692  histo->SetLineWidth(go4sett->getDrawLineWidth());
2693  }
2694 
2695 
2696 
2697 
2698  histo->GetXaxis()->UnZoom();
2699 
2700  const char* drawopt = padopt->GetDrawOption(n);
2701  if (drawopt == 0)
2702  drawopt = GetSpecialDrawOption(objslot);
2703 
2704  objslot->RemovePar("::FirstDraw");
2705 
2706  hs->Add(histo, drawopt);
2707  }
2708  oldobj = hs;
2709  } else if (isgstack) {
2710  TMultiGraph* mgr = dynamic_cast<TMultiGraph*>(oldobj);
2711  if (mgr == 0) {
2712  mgr = new TMultiGraph(objs->First()->GetName(),
2713  objs->First()->GetTitle());
2714  sislot->SetProxy(new TGo4DrawObjProxy(mgr, kTRUE, kTRUE));
2715  resetcolors = kTRUE;
2716  } else if (mgr->GetListOfGraphs()) {
2717  mgr->GetListOfGraphs()->Clear();
2718  }
2719 
2720  for (int n = 0; n <= objs->GetLast(); n++) {
2721  TGraph* gr = (TGraph*) objs->At(n);
2722  TGo4Slot* objslot = (TGo4Slot*) objslots->At(n);
2723 
2724  Int_t kind = GetDrawKind(objslot);
2725 
2726  TString drawopt = padopt->GetDrawOption(n);
2727  if (drawopt.Length() == 0)
2728  drawopt = GetSpecialDrawOption(objslot);
2729  if (drawopt.Length() == 0)
2730  drawopt = go4sett->getTGraphDrawOpt().toLatin1().constData();
2731 
2732  drawopt.ToLower();
2733 
2734  // suppress multiple drawing of axis for subgraphs
2735  if (n > 0) drawopt.ReplaceAll("a", "");
2736 
2737  Bool_t first_draw = objslot->GetPar("::FirstDraw") != 0;
2738 
2739  Int_t objindx = padslot->GetIndexOf(objslot); // slot index for object starts from 2
2740 
2741  if (resetcolors || (kind == kind_FitModels) || first_draw) {
2742  // use only basic 9 colors
2743  Int_t nextcol = GetAutoColor(((objindx + 7) % 9));
2744  gr->SetLineColor(nextcol);
2745  gr->SetMarkerColor(nextcol);
2746  if ((go4sett->getDrawLineWidth() > 1) && (gr->GetLineWidth()==1))
2747  gr->SetLineWidth(go4sett->getDrawLineWidth());
2748  }
2749 
2750  if (first_draw && (n==0)) {
2751  TAxis *ax = gr->GetXaxis();
2752  if ((ax!=0) && ax->GetTimeDisplay()) {
2753  padopt->SetHisStats(kFALSE);
2754  padopt->SetXAxisTimeDisplay(kTRUE);
2755  padopt->SetXAxisTimeFormat(ax->GetTimeFormat());
2756  }
2757  }
2758 
2759  objslot->RemovePar("::FirstDraw");
2760 
2761  mgr->Add(gr, drawopt.Data());
2762  }
2763  oldobj = mgr;
2764  }
2765 
2766  if ((ishstack || isgstack) && (legslot != 0)) {
2767  TLegend* legend = dynamic_cast<TLegend*>(legslot->GetAssignedObject());
2768 
2769  if (legend == 0) {
2770  double miny = 0.94 - 0.03 * objs->GetLast();
2771  if (miny < 0.6) miny = 0.6; else if (miny>0.92) miny = 0.92;
2772  legend = new TLegend(0.6, miny, 0.95, 0.99);
2773  legend->SetBorderSize(2);
2774  legend->SetName("fitlegend");
2775  legslot->SetProxy(new TGo4ObjectProxy(legend, kTRUE));
2776  } else
2777  legend->Clear();
2778 
2779  for(int n=0;n<=objs->GetLast();n++) {
2780  TObject* stob = objs->At(n);
2781 
2782  const char* objname = stob->GetName();
2783 
2784  if (showitems && (objslots!=0)) {
2785  const char* itemname = GetLinkedName((TGo4Slot*) objslots->At(n));
2786  if (itemname!=0) objname = itemname;
2787  }
2788 
2789  TString ldrawopt = "l";
2790 
2791  if (!ishstack) {
2792  ldrawopt = "";
2793  TString drawopt = padopt->GetDrawOption(n);
2794  drawopt.ToLower();
2795  if (drawopt.Contains("l")) ldrawopt+="l";
2796  if (drawopt.Contains("p")) ldrawopt+="p";
2797  }
2798 
2799  if (ldrawopt.Length()==0) ldrawopt = "l";
2800 
2801  legend->AddEntry(stob, objname, ldrawopt.Data());
2802  }
2803  }
2804 
2805  return oldobj;
2806 }
2807 
2808 void TGo4ViewPanel::Divide(int numX, int numY)
2809 {
2810  TPad* pad = GetActivePad();
2811 
2812  TGo4Slot* padslot = GetPadSlot(pad);
2813  if ((pad == 0) || (padslot == 0)) return;
2814 
2815  ClearPad(pad, true, true);
2816  RedrawPanel(pad, true);
2817 
2818  if ((numX > 1) || (numY > 1)) {
2819  pad->Divide(numX, numY);
2820 
2821  UpdatePadStatus(pad, true);
2822 
2823  RedrawPanel(pad, true);
2824  }
2825 
2826  // note: number of pads will be changed in list of previewpanelstatus by InitPad
2827 // RefreshButtons();
2828 }
2829 
2830 void TGo4ViewPanel::SetSlotPad(TGo4Slot* padslot, TPad* pad)
2831 {
2832  TGo4Slot* tgtslot = padslot->FindChild("::ThisPad");
2833  if (tgtslot == 0)
2834  tgtslot = new TGo4Slot(padslot, "::ThisPad", "Special object");
2835  tgtslot->SetProxy(new TGo4ObjectProxy(pad, kFALSE));
2836  SetDrawKind(tgtslot, kind_ThisPad);
2837  ConnectPad(pad);
2838 
2839  AllocatePadOptions(pad);
2840 }
2841 
2843 {
2844  if (pad == GetCanvas())
2845  return GetPanelSlot();
2846 
2847  TGo4Iter iter(GetPanelSlot(), kTRUE);
2848  while (iter.next()) {
2849  TGo4Slot* subslot = iter.getslot();
2850  if (GetDrawKind(subslot) == kind_PadSlot)
2851  if (GetSlotPad(subslot) == pad)
2852  return subslot;
2853  }
2854  return 0;
2855 }
2856 
2858 {
2859  if (slot == 0)
2860  return 0;
2861 
2862  TGo4Slot* tgtslot = slot->FindChild("::ThisPad");
2863 
2864  return tgtslot == 0 ? 0 : (TPad*) tgtslot->GetAssignedObject();
2865 }
2866 
2868 {
2869  if (padslot == 0)
2870  return false;
2871  for (int n = 0; n < padslot->NumChilds(); n++)
2872  if (GetSlotPad(padslot->GetChild(n)) != 0)
2873  return true;
2874  return false;
2875 }
2876 
2878 {
2879  return IsPadHasSubPads(GetPadSlot(pad));
2880 }
2881 
2883 {
2884  TGo4Picture* padopt = GetPadOptions(pad);
2885  if (padopt != 0)
2886  padopt->SetPadModified();
2887 }
2888 
2890 {
2891  return GetPadSlot(pad) != 0;
2892 }
2893 
2895 {
2896  if (toppad == 0)
2897  toppad = GetCanvas();
2898  int number = 1;
2899  TGo4Iter iter(GetPadSlot(toppad), kTRUE);
2900  while (iter.next()) {
2901  TPad* pad = GetSlotPad(iter.getslot());
2902  if (pad != 0)
2903  number++;
2904  }
2905  return number;
2906 }
2907 
2908 TPad* TGo4ViewPanel::GetSubPad(TPad* toppad, int num, bool onlytoplevel)
2909 {
2910  if (toppad == 0)
2911  toppad = GetCanvas();
2912  TGo4Slot* slot = GetPadSlot(toppad);
2913  if (slot == 0)
2914  return 0;
2915 
2916  int cnt = -1;
2917  if (!onlytoplevel || !IsPadHasSubPads(slot))
2918  cnt++;
2919 
2920  if (num == cnt)
2921  return toppad;
2922 
2923  TGo4Iter iter(slot, kTRUE);
2924  while (iter.next()) {
2925  TGo4Slot* subslot = iter.getslot();
2926  TPad* pad = GetSlotPad(subslot);
2927  if (pad == 0)
2928  continue;
2929  if (!onlytoplevel || !IsPadHasSubPads(subslot))
2930  cnt++;
2931  if (num == cnt)
2932  return pad;
2933  }
2934  return 0;
2935 }
2936 
2937 void TGo4ViewPanel::ProducePadsList(TObjArray* arr, TPad* toppad)
2938 {
2939  if (arr == 0)
2940  return;
2941  if (toppad == 0)
2942  toppad = GetCanvas();
2943 
2944  arr->Add(toppad);
2945 
2946  TGo4Iter iter(GetPadSlot(toppad), kTRUE);
2947  while (iter.next()) {
2948  TPad* pad = GetSlotPad(iter.getslot());
2949  if (pad != 0)
2950  arr->Add(pad);
2951  }
2952 }
2953 
2954 const char* TGo4ViewPanel::GetDrawObjectLinkName(TPad * pad, TObject* obj)
2955 {
2956  TGo4Slot* slot = GetPadSlot(pad);
2957  if ((pad == 0) || (slot == 0) || (obj == 0))
2958  return 0;
2959 
2960  for (int n = 0; n < slot->NumChilds(); n++) {
2961  TGo4Slot* subslot = slot->GetChild(n);
2962  if (subslot->GetAssignedObject() == obj)
2963  return GetLinkedName(subslot);
2964  }
2965  return 0;
2966 }
2967 
2969 {
2970  return padslot == 0 ? 0 : padslot->FindChild("::Superimpose");
2971 }
2972 
2974 {
2975  TGo4Slot* slot = GetPadSlot(pad);
2976  if ((pad == 0) || (slot == 0))
2977  return 0;
2978 
2979  for (int n = 0; n < slot->NumChilds(); n++) {
2980  TGo4Slot* subslot = slot->GetChild(n);
2981  Int_t kind = GetDrawKind(subslot);
2982  if ((kind <= 0) || (kind >= kind_Additional))
2983  continue;
2984  TObject* obj = subslot->GetAssignedObject();
2985  if (obj != 0)
2986  return subslot;
2987  }
2988  return 0;
2989 }
2990 
2992 {
2993  TGo4Slot* slot = GetPadMainObjectSlot(pad);
2994  return slot == 0 ? 0 : slot->GetAssignedObject();
2995 }
2996 
2998 {
2999  return fxQCanvas->getCanvas();
3000 }
3001 
3003 {
3004  return fxQCanvas;
3005 }
3006 
3008 {
3009  return fxActivePad;
3010 }
3011 
3013 {
3014  TGo4Slot* padslot = GetPadSlot(pad);
3015  if (padslot == 0)
3016  return;
3017 
3018  TGo4Slot* tgtslot = padslot->FindChild("::PadOptions");
3019  if (tgtslot == 0) {
3020  tgtslot = new TGo4Slot(padslot, "::PadOptions", "Pad options slot");
3021  TGo4Picture* opt = new TGo4Picture;
3023  tgtslot->SetProxy(new TGo4ObjectProxy(opt, kTRUE));
3024  SetDrawKind(tgtslot, kind_PadOptions);
3025  }
3026 }
3027 
3029 {
3030  return GetPadOptions(GetPadSlot(pad));
3031 }
3032 
3034 {
3035  if (padslot == 0)
3036  return 0;
3037  TGo4Slot* tgtslot = padslot->FindChild("::PadOptions");
3038  return (tgtslot == 0) ? 0 : (TGo4Picture*) tgtslot->GetAssignedObject();
3039 }
3040 
3042 {
3043  TGo4Slot* padslot = GetPadSlot(pad);
3044 
3045  if ((pad == 0) || (padslot == 0))
3046  return 0;
3047 
3048  TObject* obj = 0;
3049 
3050  TGo4Slot* sislot = GetSuperimposeSlot(padslot);
3051  if (sislot != 0)
3052  obj = sislot->GetAssignedObject();
3053 
3054  if (obj == 0)
3055  obj = GetPadMainObject(pad);
3056  if (obj == 0)
3057  return 0;
3058 
3059  if (obj->InheritsFrom(TH1::Class()))
3060  return (TH1*) obj;
3061 
3062  if (obj->InheritsFrom(TGraph::Class())) {
3063  TGraph* gr = dynamic_cast<TGraph*>(obj);
3064  if (gr != 0)
3065  return gr->GetHistogram();
3066  }
3067 
3068  if (obj->InheritsFrom(THStack::Class())) {
3069  THStack* hs = dynamic_cast<THStack*>(obj);
3070  if (hs != 0)
3071  return hs->GetHistogram();
3072  }
3073 
3074  if (obj->InheritsFrom(TMultiGraph::Class())) {
3075  TMultiGraph* mg = dynamic_cast<TMultiGraph*>(obj);
3076  if (mg) {
3077  if (mg->GetHistogram())
3078  return mg->GetHistogram();
3079 
3080  TGraph* gr = 0;
3081  TIter iter(mg->GetListOfGraphs());
3082  while ((gr = (TGraph*) iter()) != 0)
3083  if (gr->GetHistogram())
3084  return gr->GetHistogram();
3085  }
3086  }
3087 
3088  return 0;
3089 }
3090 
3092 {
3093  if (on)
3095  else
3097 }
3098 
3100 {
3101  return fiSkipRedrawCounter > 0;
3102 }
3103 
3105 {
3106  TGo4Slot* slot = GetPadSlot(GetActivePad());
3107  if (slot == 0)
3108  return;
3109 
3110  fSelectMenu->clear();
3111 
3112  TGo4Slot* sislot = GetSuperimposeSlot(slot);
3113 
3114  TObjArray objs, objslots;
3115  CollectMainDrawObjects(slot, &objs, &objslots, 0);
3116 
3117  Int_t nselectitem = 0;
3118 
3119  int selected = GetSelectedObjectIndex(slot);
3120 
3121  if ((selected > objs.GetLast())
3122  || ((selected == TGo4Picture::PictureIndex) && (sislot == 0))) {
3123  SetSelectedObjectIndex(slot, 0);
3124  selected = 0;
3125  }
3126 
3127  if (sislot != 0) {
3128  AddIdAction(fSelectMenu, fSelectMap, "Master object", MasterSelectId);
3129  fSelectMenu->addSeparator();
3130  nselectitem++;
3131  }
3132 
3133  QString capt = GetPanelName();
3134 
3135  QString fulllist = "";
3136  QString selslotname = "";
3137 
3138  for (int n = 0; n <= objslots.GetLast(); n++) {
3139  TGo4Slot* subslot = (TGo4Slot*) objslots.At(n);
3140  AddIdAction(fSelectMenu, fSelectMap, objs.At(n)->GetName(),
3141  FirstSelectId + n);
3142  nselectitem++;
3143 
3144  QString subslotname = subslot->GetName();
3145  if (n == selected) {
3146  subslotname = QString("[") + subslotname + QString("]");
3147  selslotname = subslotname;
3148  }
3149  if (n > 0) fulllist += ", ";
3150  fulllist += subslotname;
3151  }
3152 
3153  if ((selected != TGo4Picture::PictureIndex) && (objslots.GetLast() > 0)
3154  && (selected < objslots.GetLast())) {
3155  fSelectMenu->addSeparator();
3157  QString("Show ") + selslotname + QString(" on top"),
3158  BringToFrontId);
3159  }
3160 
3161  if ((selected == TGo4Picture::PictureIndex) && (fulllist.length() > 0))
3162  fulllist = QString("[") + fulllist + QString("]");
3163 
3164  fSelectMenu->setEnabled(nselectitem > 0);
3165 
3166  if (nselectitem > 0) {
3167  if (selected == TGo4Picture::PictureIndex)
3168  SetIdAction(fSelectMap, MasterSelectId, true, true);
3169  else
3170  SetIdAction(fSelectMap, FirstSelectId + selected, true, true);
3171  }
3172 
3173  if (fulllist.length() > 0) {
3174  capt += ": ";
3175  capt += fulllist;
3176  }
3177 
3178  if (capt.length() > 60) {
3179  capt.truncate(58);
3180  capt += "...";
3181  }
3182 
3183  if (!fbFreezeTitle)
3184  setWindowTitle(capt);
3185 }
3186 
3188 {
3189  if (slot == 0)
3190  return;
3191  if (kind <= 0)
3192  slot->RemovePar("::DrawKind");
3193  else
3194  slot->SetIntPar("::DrawKind", kind);
3195 }
3196 
3197 void TGo4ViewPanel::SetSpecialDrawOption(TGo4Slot* slot, const char* drawopt)
3198 {
3199  if (slot == 0)
3200  return;
3201  if (drawopt != 0)
3202  slot->SetPar("::DrawOpt", drawopt);
3203  else
3204  slot->RemovePar("::DrawOpt");
3205 }
3206 
3208 {
3209  if (slot == 0)
3210  return -1;
3211  Int_t kind;
3212  if (!slot->GetIntPar("::DrawKind", kind))
3213  return -1;
3214  return kind;
3215 }
3216 
3218 {
3219  return (slot == 0) ? 0 : slot->GetPar("::DrawOpt");
3220 }
3221 
3223 {
3224  if (slot != 0)
3225  slot->SetIntPar("::SelectedObject", indx);
3226 }
3227 
3229 {
3230  if (slot == 0)
3231  return 0;
3232  Int_t indx = 0;
3233  if (!slot->GetIntPar("::SelectedObject", indx))
3234  indx = 0;
3235  return indx;
3236 }
3237 
3238 TObject* TGo4ViewPanel::GetSelectedObject(TPad * pad, const char** drawopt)
3239 {
3240  TGo4Slot* slot = GetPadSlot(pad);
3241  TGo4Picture* padopt = GetPadOptions(slot);
3242  if ((slot == 0) || (padopt == 0))
3243  return 0;
3244 
3245  int indx = GetSelectedObjectIndex(slot);
3246 
3247  TGo4Slot* sislot = GetSuperimposeSlot(slot);
3248  if ((sislot != 0) && (indx == TGo4Picture::PictureIndex)) {
3249  if (drawopt != 0)
3250  *drawopt = padopt->GetDrawOption(TGo4Picture::PictureIndex);
3251  return sislot->GetAssignedObject();
3252  }
3253 
3254  TObjArray objs, objslots;
3255  CollectMainDrawObjects(slot, &objs, &objslots, 0);
3256 
3257  if (objs.GetLast() < 0)
3258  return 0;
3259 
3260  if ((indx > objs.GetLast()) || (indx < 0))
3261  indx = 0;
3262 
3263  if (drawopt != 0) {
3264  const char* resopt = padopt->GetDrawOption(indx);
3265  if (resopt == 0)
3266  resopt = GetSpecialDrawOption((TGo4Slot*) objslots.At(indx));
3267 
3268  *drawopt = resopt;
3269  }
3270 
3271  return objs.At(indx);
3272 }
3273 
3275 {
3276  TGo4Slot* slot = GetPadSlot(pad);
3277  TGo4Picture* padopt = GetPadOptions(slot);
3278  if ((slot == 0) || (padopt == 0))
3279  return false;
3280 
3281  int indx = GetSelectedObjectIndex(slot);
3282 
3283  TObjArray objs, objslots;
3284  CollectMainDrawObjects(slot, &objs, &objslots, 0);
3285 
3286  // no sense to shift object which is already at the end
3287  if ((objs.GetLast() <= 0) || (indx == objs.GetLast()))
3288  return false;
3289 
3290  TGo4Slot* selslot = (TGo4Slot*) objslots.At(indx);
3291  TGo4Slot* lastslot = (TGo4Slot*) objslots.Last();
3292 
3293  if (!slot->ShiftSlotAfter(selslot, lastslot))
3294  return false;
3295 
3296  SetSelectedObjectIndex(slot, objs.GetLast());
3297 
3298  return true;
3299 }
3300 
3302 {
3303  if ((pad == 0) || (padslot == 0)) return;
3304 
3305  TObjArray objs, objslots;
3306  CollectMainDrawObjects(padslot, &objs, &objslots, 0);
3307 
3308  int indx = GetSelectedObjectIndex(padslot);
3309  if (indx < 0) indx = 0;
3310 
3311  TH1* selhisto = dynamic_cast<TH1*>((indx <= objs.GetLast()) ? objs.At(indx) : 0);
3312  if (selhisto == 0)
3313  selhisto = GetPadHistogram(pad);
3314 
3315  for (int n = 0; n < padslot->NumChilds(); n++) {
3316  TGo4Slot* subslot = padslot->GetChild(n);
3317  Int_t kind = GetDrawKind(subslot);
3318  TObject* obj = subslot->GetAssignedObject();
3319  if (obj == 0) continue;
3320 
3321  TGo4Marker* mark = 0;
3322  TGo4Condition* cond = 0;
3323 
3324  // reset condition and marker histogram
3325  if ((kind >= kind_Specials) && (kind < kind_Other)) {
3326  if (obj->InheritsFrom(TGo4Condition::Class()))
3327  cond = (TGo4Condition*) obj;
3328  else if (obj->InheritsFrom(TGo4Marker::Class()))
3329  mark = (TGo4Marker*) obj;
3330  } else if (kind == kind_Condition)
3331  cond = dynamic_cast<TGo4Condition*>(obj);
3332 
3333  TH1* oldhisto = 0;
3334 
3335  if (cond != 0)
3336  oldhisto = cond->GetWorkHistogram();
3337  else if (mark != 0)
3338  oldhisto = mark->GetHistogram();
3339 
3340  if (oldhisto != 0)
3341  if (objs.FindObject(oldhisto) == 0)
3342  oldhisto = 0;
3343 
3344  if (oldhisto == 0)
3345  if (cond != 0)
3346  {
3347  //std::cout<< "CheckObjectsAssigments sets work histogram:"<<(long) selhisto<<"("<<selhisto->GetName()<<") to condition:"<<(long) cond<<" ("<<cond->GetName()<<")" << std::endl;
3348  cond->SetWorkHistogram(selhisto);
3349 
3350  }
3351  else if (mark != 0)
3352  mark->SetHistogram(selhisto);
3353  }
3354 }
3355 
3356 void TGo4ViewPanel::SetFreezedTitle(const QString& title)
3357 {
3358  QString mycaption = GetPanelName();
3359  mycaption += ": ";
3360  mycaption += title;
3361  setWindowTitle(mycaption);
3362  fbFreezeTitle = true;
3363  fFreezedTitle = title;
3364 }
3365 
3367 {
3368  if ((pad == 0) || (padslot == 0))
3369  return;
3370 
3371  TGo4Picture* pic = 0;
3372  TGo4Slot* picslot = 0;
3373  TCanvas* canv = 0;
3374  TGo4Slot* canvslot = 0;
3375 
3376  int numcond = 0;
3377 
3378  for (int n = 0; n < padslot->NumChilds(); n++) {
3379  TGo4Slot* subslot = padslot->GetChild(n);
3380  Int_t kind = GetDrawKind(subslot);
3381  if (kind == kind_Condition)
3382  numcond++;
3383 
3384  TObject* obj = subslot->GetAssignedObject();
3385  if (obj == 0)
3386  continue;
3387 
3388  if ((kind < 0) || (kind >= 100))
3389  continue;
3390 
3391  // change drawkind of condition which is drawn as normal object
3392  if (obj->InheritsFrom(TGo4Condition::Class())) {
3393  numcond++;
3394  TGo4Condition* cond = static_cast<TGo4Condition*>(obj);
3395  cond->SetLineColor(GetAutoColor(numcond));
3396  cond->SetFillColor(GetAutoColor(numcond));
3397  cond->SetFillStyle(3444);
3398  SetDrawKind(subslot, kind_Condition);
3399  continue;
3400  }
3401 
3402  if (obj->InheritsFrom(TLatex::Class())) {
3403  SetDrawKind(subslot, kind_Latex);
3404  continue;
3405  }
3406  // JAM test
3407  if (obj->InheritsFrom(TF1::Class())) {
3408  SetDrawKind(subslot, kind_Func);
3409  continue;
3410  }
3411  if (pic == 0) {
3412  pic = dynamic_cast<TGo4Picture*>(obj);
3413  if (pic != 0)
3414  picslot = subslot;
3415  }
3416 
3417  if (canv == 0) {
3418  canv = dynamic_cast<TCanvas*>(obj);
3419  if (canv != 0)
3420  canvslot = subslot;
3421  }
3422  }
3423 
3424  if (pic != 0) {
3425 
3426  ClearPadItems(padslot, picslot);
3427 
3428  // remove all subpads if any but do not remove items while picture is there
3429  ClearPad(pad, false, true);
3430 
3431  ProcessPictureRedraw(GetLinkedName(picslot), pad, pic);
3432 
3433  if (pad == GetCanvas())
3434  SetFreezedTitle(pic->GetTitle());
3435 
3436  // remove picture from the pad
3437  delete picslot;
3438 
3439  return;
3440  }
3441 
3442  if (canv != 0) {
3443  // remove all other
3444  ClearPadItems(padslot, canvslot);
3445 
3446  // remove all subpads if any but do not remove items while picture is there
3447  ClearPad(pad, false, true);
3448 
3449  TVirtualPad* padsav = gPad;
3450 
3451  ProcessCanvasAdopt(pad, canv, GetLinkedName(canvslot));
3452 
3453  if (padsav != 0)
3454  padsav->cd();
3455 
3456  delete canvslot;
3457  }
3458 }
3459 
3460 void TGo4ViewPanel::ProcessPictureRedraw(const char* picitemname, TPad* pad, TGo4Picture* pic)
3461 {
3462  if ((pad == 0) || (pic == 0)) return;
3463 
3464  if (pic->IsDivided()) {
3465  pad->Divide(pic->GetDivX(), pic->GetDivY());
3466 
3467  // this create appropriate entries in the OM
3468  UpdatePadStatus(pad, false);
3469 
3470  for (Int_t posy = 0; posy < pic->GetDivY(); posy++)
3471  for (Int_t posx = 0; posx < pic->GetDivX(); posx++) {
3472  TGo4Picture* sub = pic->FindPic(posy, posx);
3473  if (sub != 0)
3474  ProcessPictureRedraw(picitemname,
3475  (TPad*) pad->GetPad(posy * pic->GetDivX() + posx + 1),
3476  sub);
3477  }
3478 
3479  return;
3480  }
3481 
3482  TGo4Picture* padopt = GetPadOptions(pad);
3483  if (padopt == 0) {
3484  TGo4Log::Error("Internal problem in view panel redraw");
3485  return;
3486  }
3487 
3488  pic->GetFrameAttr(pad); // do it only once, pad preserves automatically
3489 
3491 
3492  SetAutoZoomFlag(pic->IsAutoZoom());
3493 
3494  padopt->CopyOptionsFrom(pic);
3495 
3497 
3498  TGo4BrowserProxy* brcont = Browser();
3499 
3500  Option_t* drawopt = pic->GetDrawOption(TGo4Picture::PictureIndex);
3501  if (drawopt != 0)
3503 
3504  Int_t ndraw = 0;
3505 
3506  for (Int_t n = 0; n < pic->GetNumObjNames(); n++) {
3507  Option_t* drawopt = pic->GetDrawOption(n);
3508  if (drawopt != 0)
3509  pic->SetDrawOption(drawopt, n);
3510 
3511  const char* objname = pic->GetObjName(n);
3512 
3513  TString drawname;
3514 
3515  if (brcont->DefineRelatedObject(picitemname, objname, drawname)) {
3516 
3517  TGo4Slot* slot = AddDrawObject(pad, kind_Link, drawname.Data(), 0, false, 0);
3518 
3519  brcont->GetBrowserObject(drawname.Data(), go4sett->getFetchDataWhenDraw() ? 2 : 1);
3520  ndraw++;
3521 
3522  if (pic->GetRebinX(n) > 1) {
3523  slot->SetIntPar("::DoRebinX", pic->GetRebinX(n));
3524  slot->SetIntPar("::HasRebinX", pic->GetRebinX(n));
3525  }
3526 
3527  if (pic->GetRebinY(n) > 1) {
3528  slot->SetIntPar("::DoRebinY", pic->GetRebinY(n));
3529  slot->SetIntPar("::HasRebinY", pic->GetRebinY(n));
3530  }
3531  }
3532  }
3533 
3534  if (ndraw > 1)
3535  padopt->SetSuperimpose(kTRUE);
3536 
3537  TListIter iter(pic->GetSpecialObjects());
3538  TObject* obj = 0;
3539  while ((obj = iter()) != 0) {
3540  Option_t* drawopt = iter.GetOption();
3541  if (dynamic_cast<TArrow*>(obj) != 0)
3542  AddMarkerObj(pad, kind_Arrow, obj->Clone());
3543  else if (dynamic_cast<TLatex*>(obj) != 0)
3544  AddMarkerObj(pad, kind_Latex, obj->Clone());
3545  else if (dynamic_cast<TGo4Marker*>(obj) != 0)
3546  AddMarkerObj(pad, kind_Marker, obj->Clone());
3547  else if (dynamic_cast<TGo4WinCond*>(obj) != 0)
3548  AddMarkerObj(pad, kind_Window, obj->Clone());
3549  else if (dynamic_cast<TGo4PolyCond*>(obj) != 0)
3550  AddMarkerObj(pad, kind_Poly, obj->Clone());
3551  else if (dynamic_cast<TPaveLabel*>(obj) != 0)
3552  AddDrawObject(pad, kind_Specials, obj->GetName(), obj->Clone(), kTRUE,
3553  drawopt ? drawopt : "br");
3554  else
3555  AddDrawObject(pad, kind_Specials, obj->GetName(), obj->Clone(), kTRUE,
3556  drawopt);
3557  }
3558 
3559  padopt->SetPadModified();
3560 }
3561 
3562 void TGo4ViewPanel::ProcessCanvasAdopt(TPad* tgtpad, TPad* srcpad,
3563  const char* srcpaditemname)
3564 {
3565  if ((tgtpad == 0) || (srcpad == 0)) return;
3566 
3567  TGo4Slot* padslot = GetPadSlot(tgtpad);
3568 
3569  TGo4Picture* padopt = GetPadOptions(tgtpad);
3570 
3571  if ((padopt == 0) || (padslot == 0)) return;
3572 
3573  tgtpad->SetTickx(srcpad->GetTickx());
3574  tgtpad->SetTicky(srcpad->GetTicky());
3575  tgtpad->SetGridx(srcpad->GetGridx());
3576  tgtpad->SetGridy(srcpad->GetGridy());
3577  tgtpad->SetBorderSize(srcpad->GetBorderSize());
3578  tgtpad->SetBorderMode(srcpad->GetBorderMode());
3579  srcpad->TAttLine::Copy(*tgtpad);
3580  srcpad->TAttFill::Copy(*tgtpad);
3581  srcpad->TAttPad::Copy(*tgtpad);
3582 
3583  tgtpad->SetPhi(srcpad->GetPhi());
3584  tgtpad->SetTheta(srcpad->GetTheta());
3585 
3586  int nsubpads = 0, nmain = 0, mainkind = 0;
3587  TObjLink* link = srcpad->GetListOfPrimitives()->FirstLink();
3588  while (link != 0) {
3589  TObject* obj = link->GetObject();
3590  const char* drawopt = link->GetOption();
3591 
3592  TH1* h1 = 0;
3593 
3594  int kind = 0;
3595 
3596  TPad* srcsubpad = dynamic_cast<TPad*>(obj);
3597 
3598  TString itemname = TString::Format("%s/%s", srcpaditemname,
3599  obj->GetName());
3600 
3601  if (srcsubpad != 0) {
3602  nsubpads++;
3603  QString subpadname = tgtpad->GetName();
3604  subpadname += "_";
3605  subpadname += QString::number(nsubpads);
3606 
3607  Double_t xlow, ylow, xup, yup;
3608 
3609  srcsubpad->GetPadPar(xlow, ylow, xup, yup);
3610 
3611  tgtpad->cd();
3612  TPad* tgtsubpad = new TPad(subpadname.toLatin1().constData(),
3613  srcsubpad->GetName(), xlow, ylow, xup, yup);
3614  tgtsubpad->SetNumber(nsubpads);
3615  tgtsubpad->Draw();
3616 
3617  TGo4Slot* subpadslot = AddNewSlot(tgtsubpad->GetName(), padslot);
3618  SetDrawKind(subpadslot, kind_PadSlot);
3619  SetSlotPad(subpadslot, tgtsubpad);
3620 
3621  ProcessCanvasAdopt(tgtsubpad, srcsubpad, itemname.Data());
3622  } else if (dynamic_cast<TGo4Condition*>(obj) != 0) {
3623  TGo4Condition* cond = (TGo4Condition*) obj->Clone();
3624  cond->SetWorkHistogram(0);
3625  AddDrawObject(tgtpad, kind_Condition, cond->GetName(), cond, kTRUE, 0);
3626  } else if (dynamic_cast<TGo4Marker*>(obj) != 0) {
3627  TGo4Marker* mark = (TGo4Marker*) obj->Clone();
3628  mark->SetHistogram(0);
3629  AddDrawObject(tgtpad, kind_Marker, mark->GetName(), mark, kTRUE, 0);
3630  } else if (dynamic_cast<TLatex*>(obj) != 0) {
3631  AddDrawObject(tgtpad, kind_Latex, obj->GetName(), obj->Clone(), kTRUE,
3632  0);
3633  } else if (dynamic_cast<TPaveLabel*>(obj) != 0) {
3634  AddDrawObject(tgtpad, kind_Specials, obj->GetName(), obj->Clone(),
3635  kTRUE, drawopt ? drawopt : "br");
3636  } else if (dynamic_cast<TArrow*>(obj) != 0) {
3637  AddDrawObject(tgtpad, kind_Arrow, obj->GetName(), obj->Clone(), kTRUE,
3638  0);
3639  } else
3640 
3641  if (dynamic_cast<TH1*>(obj) != 0) {
3642  kind = 1;
3643  h1 = (TH1*) obj;
3644  } else
3645 
3646  if (dynamic_cast<TGraph*>(obj) != 0) {
3647  kind = 2;
3648  h1 = ((TGraph*) obj)->GetHistogram();
3649  } else
3650 
3651  if (dynamic_cast<THStack*>(obj) != 0) {
3652  kind = 3;
3653  h1 = ((THStack*) obj)->GetHistogram();
3654  } else
3655 
3656  if (dynamic_cast<TMultiGraph*>(obj) != 0) {
3657  kind = 4;
3658  h1 = ((TMultiGraph*) obj)->GetHistogram();
3659  } else {
3660 // std::cout << tgtpad->GetName() << ": Add other object ???" << obj->GetName() << std::endl;
3661  }
3662 
3663  // only first object is added,
3664  // make superimpose only for histos and graphs
3665  if ((kind > 0) && ((mainkind == 0) || (kind == mainkind) && (kind < 3))) {
3666 
3667  if (drawopt != 0)
3668  padopt->SetDrawOption(drawopt, nmain);
3669 
3670  AddDrawObject(tgtpad, knd_Reference, obj->GetName(), obj, false, 0);
3671 
3672  mainkind = kind;
3673 
3674  if ((h1 != 0) && (nmain == 0)) {
3675  TakeFullRangeFromHisto(h1, padopt, nmain == 0);
3676  Int_t ndim = h1->GetDimension();
3677  TakeSelectedAxisRange(0, padopt, h1->GetXaxis());
3678  if (ndim > 1)
3679  TakeSelectedAxisRange(1, padopt, h1->GetYaxis());
3680  if (ndim > 2)
3681  TakeSelectedAxisRange(2, padopt, h1->GetZaxis());
3682  if (ndim < 3) {
3683  Double_t selmin = h1->GetMinimum();
3684  Double_t selmax = h1->GetMaximum();
3685 
3686  if (selmin < selmax)
3687  padopt->SetRange(ndim, selmin, selmax);
3688 
3689  padopt->SetAutoScale(
3690  !h1->TestBit(TH1::kIsZoomed) || (selmin >= selmax));
3691  }
3692  }
3693 
3694  nmain++;
3695  }
3696 
3697  link = link->Next();
3698  }
3699 
3700  if (nmain > 1)
3701  padopt->SetSuperimpose(kTRUE);
3702 
3703  if (nsubpads == 0)
3704  ScanDrawOptions(srcpad, padslot, padopt, false);
3705 }
3706 
3707 void TGo4ViewPanel::RedrawPanel(TPad* pad, bool force)
3708 {
3709  if (IsRedrawBlocked()) return;
3710 
3711  TGo4LockGuard lock;
3712 
3713  BlockPanelRedraw(true);
3714 
3715  // JAM2016: does this help for some array conflicts in TGraph painter? YES!
3716  // must be done once before pad->Clear in ProcessPadRedraw, so we do it here instead for each subpad
3717 #ifdef GLOBALESCAPE
3718  gROOT->SetEscape();
3719  fxQCanvas->HandleInput(kButton1Up, 0, 0);
3720  fxQCanvas->HandleInput(kMouseMotion, 0, 0); // stolen from TRootEmbeddedCanvas::HandleContainerKey
3721  // SL2016 - one need to reset escape status back, some other functionality (like zooming) may not work
3722  gROOT->SetEscape(kFALSE);
3723 
3724 #else
3725  // JAM 2016: only reset crucial static arrays in TGraph subclasses, do not escape complete root...
3726  // turned out to have strange side effects with TBox which also has static variables reacting on escape flag :(
3727  if(true){ // just for the scope to delete dummy graph on stack
3728  gPad = pad;
3729  Bool_t oldmodified=gPad->IsModified();
3730  TGraph dummy(1);
3731  gROOT->SetEscape();
3732  dummy.ExecuteEvent(kButton1Up, 0, 0); // will reset escape flag internally
3733  gPad->Modified(oldmodified); // probably not necessary, since we only use escape mode in event handler. But who knows what future root brings?
3734  }
3735 #endif
3736 
3737  bool isanychildmodified = false;
3738  bool ispadupdatecalled = false;
3739 
3740  QTime starttm = QTime::currentTime();
3741  bool intime = true;
3742 
3743 
3744  // this loop done to allow consequent update of multi-pad canvas
3745  // each subpad separately redrawn in ProcessPadRedraw() method and
3746  // than pad->Update() is called. If it takes too long,
3747  // loop is finishing and via paint timer will be activated later
3748 
3749  do {
3750  TPad* selpad = TGo4MdiArea::Instance()->GetSelectedPad();
3751 
3752  isanychildmodified = ProcessPadRedraw(pad, force);
3753 
3755 
3756  // here pad->Update should redraw only modified subpad
3757  if (isanychildmodified) {
3758  GetQCanvas()->Update();
3759  ispadupdatecalled = true;
3760  }
3761 
3762  int delay = starttm.msecsTo(QTime::currentTime());
3763  intime = (delay >= 0) && (delay < 100);
3764 
3765  } while (!force && isanychildmodified && intime);
3766 
3767  if (GetActivePad() != 0)
3769 
3770  RefreshButtons();
3771 
3772  // to correctly select active pad, one should call canvas->Update()
3773  if (!ispadupdatecalled)
3774  GetQCanvas()->Update();
3775 
3777 
3778  BlockPanelRedraw(false);
3779 
3780  if (!force && isanychildmodified)
3781  ShootRepaintTimer(pad);
3782 }
3783 
3784 bool TGo4ViewPanel::ProcessPadRedraw(TPad* pad, bool force)
3785 {
3786  TGo4Slot* slot = GetPadSlot(pad);
3787  if (slot == 0) return false;
3788 
3789  TGo4Picture* padopt = GetPadOptions(slot);
3790  if (padopt == 0) return false;
3791 
3792  bool ischilds = false;
3793  bool ischildmodified = false;
3794 
3795  CheckObjectsAssigments(pad, slot);
3796 
3797  CheckForSpecialObjects(pad, slot);
3798 
3799  // this parameter ensure that all pads will be scanned one after another
3800  Int_t lastdrawnpad = 0;
3801  if (!force)
3802  if (!slot->GetIntPar("::LastDrawnPad", lastdrawnpad))
3803  lastdrawnpad = 0;
3804 
3805  Int_t subpadindx = 0;
3806 
3807  // first redraw all subpads
3808  for (int n = 0; n < slot->NumChilds(); n++) {
3809  subpadindx = (n + lastdrawnpad) % slot->NumChilds();
3810  TPad* subpad = GetSlotPad(slot->GetChild(subpadindx));
3811  if (subpad == 0) continue;
3812  ischilds = true;
3813  if (ProcessPadRedraw(subpad, force)) {
3814  ischildmodified = true;
3815  if (!force) break; // break if any of child is modified
3816  }
3817  }
3818 
3819  if (!force && ischildmodified)
3820  slot->SetIntPar("::LastDrawnPad", subpadindx);
3821  else
3822  slot->RemovePar("::LastDrawnPad");
3823 
3824  if (!force && !padopt->IsPadModified())
3825  return ischildmodified;
3826 
3827  bool updatecontent = padopt->IsContentModified();
3828 
3829  padopt->SetPadModified(false);
3830  padopt->SetContentModified(false);
3831 
3832  // do not draw anything else if subpads are there
3833  if (ischilds) return ischildmodified;
3834 
3835  pad->Clear();
3836 
3837  pad->SetCrosshair(fbCanvasCrosshair);
3838  pad->SetLogx(padopt->GetLogScale(0));
3839  pad->SetLogy(padopt->GetLogScale(1));
3840  pad->SetLogz(padopt->GetLogScale(2));
3841 
3842  TObjArray objs, objslots;
3843  CollectMainDrawObjects(slot, &objs, &objslots,
3844  padopt->IsSuperimpose() ? 1 : 2);
3845 
3846  ScanObjectsDrawOptions(false, slot, &objs, &objslots);
3847 
3848  TGo4Slot* sislot = GetSuperimposeSlot(slot);
3849  TGo4Slot* legslot = slot->FindChild("::Legend");
3850  TGo4Slot* asislot = slot->FindChild("::ASImage");
3851 
3852  // if nothing to draw, delete all additional slots and exit
3853  if (objs.GetLast() < 0) {
3854  delete sislot;
3855  delete legslot;
3856  delete asislot;
3857 
3858  RedrawSpecialObjects(pad, slot);
3859 
3861 
3862  // indicate that nothing is happen
3863  return true;
3864  }
3865 
3866  TH2* asihisto = 0;
3867 
3868  TObject* drawobj = 0;
3869 
3870  // Bool_t dosuperimpose = padopt->IsSuperimpose() && (objs.GetLast()>0);
3871  Bool_t dosuperimpose = objs.GetLast() > 0;
3872 
3873  const char* drawopt = padopt->GetDrawOption(0);
3874 
3875  Bool_t doasiimage = (drawopt != 0) && !dosuperimpose &&
3876  objs.Last()->InheritsFrom(TH2::Class());
3877  if (doasiimage)
3878  doasiimage = TString(drawopt).Contains("asimage");
3879 
3880  if (dosuperimpose) {
3881  if (sislot == 0)
3882  sislot = new TGo4Slot(slot, "::Superimpose", "place for superimpose object");
3883  if (padopt->IsLegendDraw()) {
3884  if (legslot == 0)
3885  legslot = new TGo4Slot(slot, "::Legend", "place for legends object");
3886  } else
3887  if (legslot != 0) {
3888  delete legslot;
3889  legslot = 0;
3890  }
3891 
3892  drawobj = ProduceSuperimposeObject(slot, padopt, sislot, legslot, &objs,
3893  &objslots, padopt->IsTitleItem());
3894  if (drawobj == 0)
3895  dosuperimpose = kFALSE;
3896  }
3897 
3898  if (!dosuperimpose) {
3899  if (sislot != 0) {
3900  delete sislot;
3901  sislot = 0;
3902  }
3903  if (legslot != 0) {
3904  delete legslot;
3905  legslot = 0;
3906  }
3907  drawobj = objs.Last();
3908  }
3909 
3910  if (doasiimage) {
3911  asihisto = dynamic_cast<TH2*>(drawobj);
3912  if (asihisto == 0)
3913  doasiimage = false;
3914  else {
3915  if (asislot == 0)
3916  asislot = new TGo4Slot(slot, "::ASImage", "place for Go4 ASI image");
3917  TGo4ASImage* image =
3918  dynamic_cast<TGo4ASImage*>(asislot->GetAssignedObject());
3919  if(image==0) {
3920  image = new TGo4ASImage;
3921  asislot->SetProxy(new TGo4ObjectProxy(image, kTRUE));
3922  updatecontent = true;
3923  }
3924  if (updatecontent)
3925  image->SetHistogramContent(asihisto);
3926 
3927  drawobj = image;
3928  }
3929  }
3930 
3931  if (!doasiimage) {
3932  if (asislot != 0) {
3933  delete asislot;
3934  asislot = 0;
3935  }
3936  }
3937 
3938  gPad = pad; // instead of pad->cd(), while it is redraw frame
3939  if (drawobj != 0) {
3940  bool first_draw = (slot->GetPar("::PadFirstDraw") == 0);
3941  if (first_draw) slot->SetPar("::PadFirstDraw", "true");
3942 
3943  if (drawobj->InheritsFrom(TH1::Class())) {
3944  TH1* h1 = (TH1*) drawobj;
3945  h1->SetBit(kCanDelete, kFALSE);
3946  RedrawHistogram(pad, padopt, h1, updatecontent, first_draw);
3947  } else if (drawobj->InheritsFrom(THStack::Class())) {
3948  THStack* hs = (THStack*) drawobj;
3949  RedrawStack(pad, padopt, hs, dosuperimpose, updatecontent);
3950  } else if (drawobj->InheritsFrom(TGraph::Class())) {
3951  TGraph* gr = (TGraph*) drawobj;
3952  RedrawGraph(pad, padopt, gr, updatecontent, first_draw);
3953  } else if (drawobj->InheritsFrom(TMultiGraph::Class())) {
3954  TMultiGraph* mg = (TMultiGraph*) drawobj;
3955  RedrawMultiGraph(pad, padopt, mg, dosuperimpose, updatecontent);
3956  } else if (dynamic_cast<TGo4ASImage*>(drawobj) != 0) {
3957  TGo4ASImage* ai = (TGo4ASImage*) drawobj;
3958  RedrawImage(pad, padopt, ai, asihisto, updatecontent);
3959  }
3960  }
3961 
3962  if (legslot != 0)
3963  RedrawLegend(pad, padopt, legslot);
3964 
3965  if (!doasiimage)
3966  RedrawSpecialObjects(pad, slot);
3967 
3969 
3970  return true;
3971 }
3972 
3973 void TGo4ViewPanel::RedrawHistogram(TPad *pad, TGo4Picture* padopt, TH1 *his, bool scancontent, bool first_draw)
3974 {
3975  if ((pad == 0) || (padopt == 0) || (his == 0)) return;
3976 
3977  if (scancontent)
3978  TakeFullRangeFromHisto(his, padopt, true);
3979 
3980  TString drawopt(padopt->GetDrawOption(0));
3981  if (drawopt.Length() == 0)
3982  if (his->GetDimension() == 1)
3983  drawopt = go4sett->getTH1DrawOpt().toLatin1().constData();
3984  else if (his->GetDimension() == 2)
3985  drawopt = go4sett->getTH2DrawOpt().toLatin1().constData();
3986  else if (his->GetDimension() == 3)
3987  drawopt = go4sett->getTH3DrawOpt().toLatin1().constData();
3988 
3989  drawopt.ToUpper();
3990 
3991  if (first_draw && (go4sett->getDrawLineWidth() > 1) && (his->GetLineWidth()==1))
3992  his->SetLineWidth(go4sett->getDrawLineWidth());
3993 
3994  // only activate panel defaults if no fill color set by user:
3995  if (first_draw && (go4sett->getDrawFillColor()>0) && (his->GetFillColor()==0))
3996  his->SetFillColor(go4sett->getDrawFillColor());
3997  if (first_draw && (go4sett->getDrawFillStyle()!=1001) && (his->GetFillStyle()==1001))
3998  his->SetFillStyle(go4sett->getDrawFillStyle());
3999 
4000  Int_t nlvl = padopt->GetHisContour();
4001  if (nlvl > 0) his->SetContour(nlvl);
4002 
4003  his->SetStats(padopt->IsHisStats());
4004  his->SetBit(TH1::kNoTitle, !padopt->IsHisTitle());
4005  his->Draw(drawopt.Data());
4006 
4007  SetSelectedRangeToHisto(pad, his, 0, padopt, true);
4008 }
4009 
4010 void TGo4ViewPanel::RedrawStack(TPad *pad, TGo4Picture* padopt, THStack * hs,
4011  bool dosuperimpose, bool scancontent)
4012 {
4013  if ((pad == 0) || (padopt == 0) || (hs == 0)) return;
4014 
4015  if (scancontent) {
4016  TIter iter(hs->GetHists());
4017  TH1 *h1 = 0;
4018  bool first = true;
4019  while ((h1 = (TH1*) iter()) != 0) {
4020  TakeFullRangeFromHisto(h1, padopt, first);
4021  first = false;
4022  }
4023  }
4024 
4025  // never draw statistics with stack
4026 
4027  Int_t drawoptindx = dosuperimpose ? TGo4Picture::PictureIndex : 0;
4028  TString drawopt(padopt->GetDrawOption(drawoptindx));
4029  if (drawopt.Length() == 0)
4030  drawopt = "hist";
4031  if (!drawopt.Contains(NoStackDrawOption, TString::kIgnoreCase))
4032  drawopt.Prepend(NoStackDrawOption);
4033 
4034  hs->Draw(drawopt.Data());
4035  TH1* framehisto = hs->GetHistogram();
4036  if (framehisto == 0) return;
4037 
4038  framehisto->SetStats(false);
4039  framehisto->SetBit(TH1::kNoTitle, !padopt->IsHisTitle());
4040  TH1* h1 = dynamic_cast<TH1*>(hs->GetHists() ? hs->GetHists()->First() : 0);
4041  if (h1!=0) {
4042  hs->SetTitle(h1->GetTitle());
4043  framehisto->SetTitle(h1->GetTitle());
4044  framehisto->GetXaxis()->SetTitle(h1->GetXaxis()->GetTitle());
4045  framehisto->GetYaxis()->SetTitle(h1->GetYaxis()->GetTitle());
4046  framehisto->GetZaxis()->SetTitle(h1->GetZaxis()->GetTitle());
4047  }
4048 
4049  SetSelectedRangeToHisto(pad, framehisto, hs, padopt, false);
4050 }
4051 
4052 void TGo4ViewPanel::RedrawGraph(TPad *pad, TGo4Picture* padopt, TGraph * gr, bool scancontent, bool first_draw)
4053 {
4054  if ((pad == 0) || (padopt == 0) || (gr == 0)) return;
4055 
4056  if (scancontent) {
4057  TakeFullRangeFromGraph(gr, padopt, true);
4058  gr->SetEditable(kFALSE);
4059  }
4060 
4061  TString drawopt = padopt->GetDrawOption(0);
4062 
4063  // when graph drawn for the first time, check if time units used in axis
4064  if (first_draw) {
4065  TAxis *ax = gr->GetXaxis();
4066  if ((ax!=0) && ax->GetTimeDisplay()) {
4067  padopt->SetHisStats(kFALSE);
4068  padopt->SetXAxisTimeDisplay(kTRUE);
4069  padopt->SetXAxisTimeFormat(ax->GetTimeFormat());
4070  if (drawopt.Length() == 0) {
4071  drawopt = go4sett->getTGraphDrawOpt().toLatin1().constData();
4072  padopt->SetDrawOption(drawopt);
4073  }
4074  }
4075  if ((go4sett->getDrawLineWidth() > 1) && (gr->GetLineWidth()==1))
4076  gr->SetLineWidth(go4sett->getDrawLineWidth());
4077 
4078 
4079  // only activate panel defaults if no fill color set by user:
4080  if ((go4sett->getDrawFillColor()>0) && (gr->GetFillColor()==0))
4081  gr->SetFillColor(go4sett->getDrawFillColor());
4082  if ((go4sett->getDrawFillStyle()!=1001) && (gr->GetFillStyle()==1001))
4083  gr->SetFillStyle(go4sett->getDrawFillStyle());
4084 
4085 
4086 
4087  }
4088 
4089  if (drawopt.Length() == 0)
4090  drawopt = go4sett->getTGraphDrawOpt().toLatin1().constData();
4091 
4092  TH1* framehisto = gr->GetHistogram();
4093  if (framehisto == 0) {
4094  gr->Draw(drawopt.Data());
4095  framehisto = gr->GetHistogram();
4096  }
4097  if (framehisto != 0) {
4098  framehisto->SetStats(padopt->IsHisStats());
4099  framehisto->SetBit(TH1::kNoTitle, !padopt->IsHisTitle());
4100  }
4101  gr->Draw(drawopt.Data());
4102 
4103  SetSelectedRangeToHisto(pad, framehisto, 0, padopt, false);
4104 }
4105 
4107  TMultiGraph * mg, bool dosuperimpose, bool scancontent)
4108 {
4109  if ((pad == 0) || (padopt == 0) || (mg == 0)) return;
4110 
4111  TIter iter(mg->GetListOfGraphs());
4112  TGraph *gr(0), *firstgr(0);
4113  bool first = true;
4114  while ((gr = (TGraph*) iter()) != 0) {
4115  if (scancontent) {
4116  gr->SetEditable(kFALSE);
4117  TakeFullRangeFromGraph(gr, padopt, first);
4118  }
4119  if (first)
4120  firstgr = gr;
4121  first = false;
4122  }
4123 
4124  Int_t drawoptindx = dosuperimpose ? TGo4Picture::PictureIndex : 0;
4125  TString drawopt(padopt->GetDrawOption(drawoptindx));
4126  if (drawopt.Length() == 0)
4127  drawopt = go4sett->getTGraphDrawOpt().toLatin1().constData();
4128  if (dosuperimpose)
4129  drawopt = "";
4130 
4131  TH1* framehisto = (dosuperimpose && (firstgr != 0)) ? firstgr->GetHistogram() : mg->GetHistogram();
4132 
4133  if (framehisto == 0) {
4134  // this is workaround to prevent recreation of framehistogram in TMultiGraph::Paint
4135  mg->Draw(drawopt.Data());
4136  framehisto = (dosuperimpose && (firstgr != 0)) ? firstgr->GetHistogram() : mg->GetHistogram();
4137  }
4138 
4139  if (framehisto == 0) {
4140  TGo4Log::Error("Internal problem with MultiGraph drawing - cannot access frame histo");
4141  return;
4142  }
4143 
4144  SetSelectedRangeToHisto(pad, framehisto, 0, padopt, false);
4145 
4146  // try to avoid flicker of range when in fullscale: set range before and after draw
4147  Double_t miny, maxy, selmin, selmax;
4148  if (padopt->GetFullRange(1, miny, maxy) && !padopt->GetRangeY(selmin, selmax)) {
4149  if (padopt->GetLogScale(1)) {
4150  if (maxy <= 0) maxy = 1.;
4151  if ((miny <= 0) || (miny >= maxy)) {
4152  miny = maxy * 1e-4;
4153  if (miny > 1.) miny = 1.;
4154  }
4155  } else {
4156  maxy *= ((maxy>0) ? 1.1 : 0.9);
4157  miny *= ((miny>0) ? 0.9 : 1.1);
4158  }
4159  framehisto->SetMaximum(maxy);
4160  framehisto->SetMinimum(miny);
4161  }
4162 
4163  framehisto->SetStats(kFALSE); // never draw statistics with multigraph
4164  framehisto->SetBit(TH1::kNoTitle, !padopt->IsHisTitle());
4165 
4166  // set title of first TGraph to TMultiGraph and frame histo
4167  if (firstgr != 0) {
4168  mg->SetTitle(firstgr->GetTitle());
4169  framehisto->SetTitle(firstgr->GetTitle());
4170  framehisto->GetXaxis()->SetTitle(firstgr->GetXaxis()->GetTitle());
4171  framehisto->GetYaxis()->SetTitle(firstgr->GetYaxis()->GetTitle());
4172  }
4173 
4174  mg->Draw(drawopt.Data());
4175 }
4176 
4178  TH2* asihisto, bool scancontent)
4179 {
4180  if ((pad == 0) || (padopt == 0) || (im == 0)) return;
4181 
4182  im->SetDrawData(asihisto, this, pad);
4183 
4184  if (scancontent)
4185  TakeFullRangeFromHisto(asihisto, padopt, true);
4186 
4187  TString drawopt(padopt->GetDrawOption(0));
4188 
4189  double uminx, umaxx, uminy, umaxy;
4190  padopt->GetRange(0, uminx, umaxx);
4191  padopt->GetRange(1, uminy, umaxy);
4192  im->SetSelectedRange(uminx, umaxx, uminy, umaxy);
4193 
4194  im->SetPaletteEnabled(drawopt.Contains("Z"));
4195 
4196  im->Draw();
4197 }
4198 
4200  TGo4Slot* legslot)
4201 {
4202  if (legslot == 0) return;
4203  TLegend* legend = dynamic_cast<TLegend*>(legslot->GetAssignedObject());
4204  //legend->SetBit(kCanDelete, kFALSE); // jam2016
4205  if(legend!=0) legend->Draw();
4206 }
4207 
4209 {
4210  if ((pad == 0) || (padslot == 0))
4211  return;
4212 
4213  CheckObjectsAssigments(pad, padslot);
4214 
4215  QString selname = GetSelectedMarkerName(pad);
4216  TObject* selectedobj = 0;
4217  const char* selectdrawopt = 0;
4218  Int_t numtf1=0;
4219  for (int n = 0; n < padslot->NumChilds(); n++) {
4220  TGo4Slot* subslot = padslot->GetChild(n);
4221 
4222  Int_t kind = GetDrawKind(subslot);
4223 
4224  if ((kind < kind_Specials) || (kind >= kind_Other))
4225  continue;
4226 
4227  TObject* obj = subslot->GetAssignedObject();
4228  if (obj == 0)
4229  continue;
4230 
4231  TString drawopt = GetSpecialDrawOption(subslot);
4232  if(obj->InheritsFrom(TF1::Class())){
4233  if(!pad->GetListOfPrimitives()->IsEmpty())
4234  drawopt.Append("LSAME"); // for correct overlay of TF1 objects JAM
4235  TF1* func = dynamic_cast<TF1*>(obj);
4236  Int_t objindx = padslot->GetIndexOf(subslot);
4237  func->SetLineColor(GetAutoColor(((objindx+7) % 9) + 1)); // 9 basic colors for superimpose of tf1, like for other superimpose
4238  }
4239 
4240  if ((selname == obj->GetName()) && (selectedobj == 0)) {
4241  selectedobj = obj;
4242  selectdrawopt = drawopt.Data();
4243  } else {
4244  //obj->SetBit(kCanDelete, kFALSE); // jam2016
4245  obj->Draw(drawopt.Data());
4246  }
4247  }
4248 
4249  // if one has selected object on the pad, one should
4250  // draw it as last to bring it to the front of other
4251  if (selectedobj != 0){
4252  //selectedobj->SetBit(kCanDelete, kFALSE); // jam2016
4253  selectedobj->Draw(selectdrawopt ? selectdrawopt : "");
4254  }
4255 
4256 }
4257 
4259 {
4260  return fbAutoZoomFlag;
4261 }
4262 
4264 {
4265  fbAutoZoomFlag = on;
4266 }
4267 
4269 {
4270  return fbApplyToAllFlag;
4271 }
4272 
4274 {
4275  return fbFreezeTitle;
4276 }
4277 
4279  int value, const char* drawopt)
4280 {
4281  TGo4LockGuard lock;
4282  TGo4Picture* subopt = GetPadOptions(padslot);
4283  if (subopt == 0) return;
4284  switch (kind) {
4285  case 0:
4286  case 1:
4287  case 2: {
4288  int selindx = GetSelectedObjectIndex(padslot);
4289  subopt->SetDrawOption(drawopt, selindx);
4290  subopt->SetPadModified();
4291  break;
4292  }
4293  case 100: {
4294  subopt->SetPadModified();
4295  break;
4296  }
4297  case 101: {
4298  TPad* subpad = GetSlotPad(padslot);
4299  if (subpad != 0) {
4300  subpad->SetFillColor(value);
4301  if (subpad->GetFrame())
4302  subpad->GetFrame()->SetFillColor(value);
4303  }
4304  subopt->SetPadModified();
4305  break;
4306  }
4307  case 16: {
4308  // this is for setting time axis format:
4309  subopt->SetXAxisTimeFormat(drawopt);
4310  subopt->SetPadModified();
4311  break;
4312  }
4313 
4314  default:
4315  subopt->ChangeDrawOption(kind, value);
4316  break;
4317  }
4318 }
4319 
4320 void TGo4ViewPanel::ChangeDrawOption(int kind, int value, const char* drawopt)
4321 {
4322  TGo4LockGuard lock;
4323 
4324  bool scanall = IsApplyToAllFlag();
4325 
4326  if (kind == 100) {
4327  gStyle->SetPalette(value);
4328  scanall = true;
4329  }
4330 
4331  TPad* pad = scanall ? GetCanvas() : GetActivePad();
4332 
4333  if (pad == 0)
4334  pad = GetCanvas();
4335 
4336  TGo4Slot* slot = GetPadSlot(pad);
4337  if (slot == 0) return;
4338 
4339  ChangeDrawOptionForPad(slot, kind, value, drawopt);
4340 
4341  TGo4Iter iter(slot, true);
4342  while (iter.next())
4343  ChangeDrawOptionForPad(iter.getslot(), kind, value, drawopt);
4344 
4345  RedrawPanel(pad, false);
4346 }
4347 
4348 void TGo4ViewPanel::ResetPadFillColors(TPad* pad, int col, TPad* backup)
4349 {
4350  TGo4LockGuard lock;
4351  if (pad == 0)
4352  return;
4353  if(backup) col=backup->GetFillColor();
4354  pad->SetFillColor((Color_t) col);
4355  //pad->Modified(); // for image formats, display window bitmap has to change
4356  //std::cout<<"ResetPadFillColors sets color "<<col<<" to pad "<< (unsigned long) pad<<", name:"<<pad->GetName()<<", backup was "<<backup << std::endl;
4357  TIter iter(pad->GetListOfPrimitives());
4358  TObject* obj = 0;
4359  while ((obj = iter()) != 0) {
4360  TPad* subpad = dynamic_cast<TPad*>(obj);
4361  TFrame* fram = dynamic_cast<TFrame*>(obj);
4362  if (subpad != 0){
4363  //std::cout<<"ResetPadFillColors finds subpad " << (unsigned long) subpad << std::endl;
4364  TPad* backpad=0;
4365  if(backup)
4366  {
4367  backpad=dynamic_cast<TPad*>(backup->GetListOfPrimitives()->FindObject(subpad->GetName()));
4368  // debug only:
4369 // if(backpad)
4370 // {
4371 // col=backpad->GetFillColor();
4372 // std::cout<<"ResetPadFillColors finds backup pad "<<backpad->GetName()<<" with color "<< col << std::endl;
4373 // }
4374  // end debug
4375  }
4376  ResetPadFillColors(subpad, col, backpad);
4377  }
4378  else if (fram != 0)
4379  {
4380  if(backup)
4381  {
4382  TFrame* backframe=dynamic_cast<TFrame*>(backup->GetListOfPrimitives()->FindObject(fram->GetName()));
4383  if(backframe)
4384  {
4385  col=backframe->GetFillColor();
4386  //std::cout<<"ResetPadFillColors finds backup frame "<<backframe->GetName()<<" with color "<< col << std::endl;
4387  }
4388  }
4389  //std::cout<<"ResetPadFillColors sets color "<<col<<" to subframe "<< (unsigned long) fram->GetName()<< std::endl;
4390  fram->SetFillColor((Color_t) col);
4391  }
4392  }
4393 
4394 }
4395 
4396 void TGo4ViewPanel::ClearPad(TPad* pad, bool removeitems, bool removesubpads)
4397 {
4398  TGo4LockGuard lock;
4399 
4400  BlockPanelRedraw(true);
4401  CleanupGedEditor();
4402  ProcessPadClear(pad, removeitems, removesubpads);
4403  if (GetActivePad() == 0)
4405  GetCanvas()->SetSelected(0);
4406  BlockPanelRedraw(false);
4407 }
4408 
4410 {
4411  if (padslot == 0) return;
4412 
4413  for (int n = padslot->NumChilds() - 1; n >= 0; n--) {
4414  TGo4Slot* subslot = padslot->GetChild(n);
4415  int kind = GetDrawKind(subslot);
4416  if ((kind < kind_Permanet) && (subslot != remain)) {
4417  delete subslot;
4418  }
4419  }
4420 }
4421 
4422 void TGo4ViewPanel::ProcessPadClear(TPad * pad, bool removeitems, bool removesubpads)
4423 {
4424  TGo4Slot* slot = GetPadSlot(pad);
4425  TGo4Picture* padopt = GetPadOptions(slot);
4426  if ((slot == 0) || (padopt == 0))
4427  return;
4428 
4429 // padopt->Clear(""); // remove all settings completely
4430  padopt->SetPadModified();
4431 
4432  if (removeitems)
4433  ClearPadItems(slot, 0);
4434 
4435  CheckObjectsAssigments(pad, slot);
4436 
4437  for (int n = slot->NumChilds() - 1; n >= 0; n--) {
4438  TGo4Slot* subslot = slot->GetChild(n);
4439 
4440  TPad* subpad = GetSlotPad(subslot);
4441  if (subpad == 0)
4442  continue;
4443  ProcessPadClear(subpad, removeitems || removesubpads, removesubpads);
4444  if (!removesubpads)
4445  continue;
4446  if (fxActivePad == subpad)
4447  fxActivePad = 0;
4448 
4449  delete subslot;
4450 
4451  pad->GetListOfPrimitives()->Remove(subpad);
4452 
4454 
4455  if (GetCanvas()->GetSelectedPad() == subpad)
4456  GetCanvas()->SetSelectedPad(0);
4457 
4458  delete subpad;
4459  }
4460 
4462 }
4463 
4465 {
4466  TGo4LockGuard lock;
4467 
4468  if (pad == 0) return;
4469  gStyle->SetOptStat(go4sett->getOptStat());
4470  if (go4sett->getOptStatW()>0) gStyle->SetStatW(go4sett->getOptStatW()*0.01);
4471  if (go4sett->getOptStatH()>0) gStyle->SetStatH(go4sett->getOptStatH()*0.01);
4472 
4475 
4476  int fiPadcolorR, fiPadcolorG, fiPadcolorB;
4477  go4sett->getCanvasColor(fiPadcolorR, fiPadcolorG, fiPadcolorB);
4478  int padfillcolor = TColor::GetColor(fiPadcolorR, fiPadcolorG, fiPadcolorB);
4479 
4480  if (padfillcolor != 0) {
4481  // now define associated colors for WBOX shading
4482  // note: root restricts this mechanism to number<50
4483  // we extend it since TGX11ttf expects the shadow color
4484  // the following are copies from TColor code:
4485  Int_t nplanes = 16;
4486  if (gVirtualX)
4487  gVirtualX->GetPlanes(nplanes);
4488  if (nplanes == 0)
4489  nplanes = 16;
4490  TColor *normal = gROOT->GetColor(padfillcolor);
4491  if (normal != 0) {
4492  Float_t h, l, s;
4493  normal->GetHLS(h, l, s);
4494  const char* cname = normal->GetName();
4495  // assign the color numbers and names for shading:
4496  Float_t dr, dg, db, lr, lg, lb;
4497  TColor *dark = gROOT->GetColor(100 + padfillcolor);
4498  if (dark == 0) {
4499  new TColor(100 + padfillcolor, -1, -1, -1,
4500  Form("%s%s", cname, "_dark"));
4501  dark = gROOT->GetColor(100 + padfillcolor);
4502  }
4503  TColor *light = gROOT->GetColor(150 + padfillcolor);
4504  if (light == 0) {
4505  new TColor(150 + padfillcolor, -1, -1, -1,
4506  Form("%s%s", cname, "_bright"));
4507  light = gROOT->GetColor(150 + padfillcolor);
4508  }
4509 
4510  // set dark color
4511  TColor::HLStoRGB(h, 0.7 * l, s, dr, dg, db);
4512  if (dark != 0) {
4513  if (nplanes > 8)
4514  dark->SetRGB(dr, dg, db);
4515  else
4516  dark->SetRGB(0.3, 0.3, 0.3);
4517  }
4518 
4519  // set light color
4520  TColor::HLStoRGB(h, 1.2 * l, s, lr, lg, lb);
4521  if (light != 0) {
4522  if (nplanes > 8)
4523  light->SetRGB(lr, lg, lb);
4524  else
4525  light->SetRGB(0.8, 0.8, 0.8);
4526  }
4527  } else { // if(normal)
4528  TGo4Log::Error("Internal problem in view panel: Could not assign root shadow colors for number %d", padfillcolor);
4529  }
4530  }
4531 
4532  pad->SetCrosshair(fbCanvasCrosshair);
4533  pad->SetFillColor(padfillcolor);
4534 
4536  ShowEventStatus(); // will toggle fbCanvasEventstatus back and show
4537 
4538  TGo4Picture* padopt = GetPadOptions(pad);
4539  if (padopt != 0) {
4541  padopt->SetDrawOption(0, 0);
4542  padopt->SetTitleTime(go4sett->getDrawTimeFlag());
4543  padopt->SetTitleDate(go4sett->getDrawDateFlag());
4544  padopt->SetTitleItem(go4sett->getDrawItemFlag());
4546  }
4547 }
4548 
4550 {
4551  if (pad == 0)
4552  return;
4553  QString output = pad->GetName();
4554  output.append(": ");
4555  TGo4Picture* padopt = GetPadOptions(pad);
4556  if (padopt != 0)
4557  if (padopt->IsSuperimpose())
4558  output.append(" SuperImpose:");
4559 
4560  if (IsApplyToAllFlag())
4561  output.append(" All Pads:");
4562  output.append(" Ready");
4563  if (CanvasStatus != 0)
4564  CanvasStatus->showMessage(output);
4565 }
4566 
4567 void TGo4ViewPanel::MoveScale(int expandfactor, int xaction, int yaction, int zaction)
4568 {
4569  TPad* selpad = IsApplyToAllFlag() ? GetCanvas() : GetActivePad();
4570  if (selpad == 0)
4571  return;
4572 
4573  TGo4Picture* padopt = GetPadOptions(selpad);
4574  if (padopt != 0) {
4575 // padopt->MoveScale(expandfactor, xaction, yaction);
4576 
4577  TObject* padhist = GetPadMainObject(selpad);
4578 
4579  MoveSingleScale(expandfactor, xaction, 0, padopt, padhist);
4580  MoveSingleScale(expandfactor, yaction, 1, padopt, padhist);
4581  MoveSingleScale(expandfactor, zaction, 2, padopt, padhist);
4582  if ((xaction == 0) && (yaction == 0) && (zaction == 0)) {
4583  padopt->ClearRange();
4584  padopt->SetAutoScale(true);
4585  }
4586  padopt->SetPadModified();
4587  }
4588 
4589  if (IsApplyToAllFlag()) {
4590  TGo4Iter iter(GetPadSlot(selpad), kTRUE);
4591  while (iter.next()) {
4592  TPad* subpad = GetSlotPad(iter.getslot());
4593  padopt = GetPadOptions(subpad);
4594  if (padopt == 0) continue;
4595 
4596  TObject* padhist = GetPadMainObject(subpad);
4597 
4598  MoveSingleScale(expandfactor, xaction, 0, padopt, padhist);
4599  MoveSingleScale(expandfactor, yaction, 1, padopt, padhist);
4600  MoveSingleScale(expandfactor, zaction, 2, padopt, padhist);
4601  if ((xaction == 0) && (yaction == 0) && (zaction == 0)) {
4602  padopt->ClearRange();
4603  padopt->SetAutoScale(true);
4604  }
4605  padopt->SetPadModified();
4606  }
4607  }
4608 
4609  RedrawPanel(selpad, false);
4610 }
4611 
4612 void TGo4ViewPanel::MoveSingleScale(int expandfactor, int action, int naxis,
4613  TGo4Picture* padopt, TObject* padobj)
4614 {
4615  if (action <= 0) return;
4616 
4617  double new_umin, new_umax, fmin, fmax, tmin, tmax;
4618  double fact = expandfactor / 100.;
4619 
4620  bool sel = padopt->GetRange(naxis, new_umin, new_umax) && (action!=6);
4621 
4622  padopt->GetFullRange(naxis, fmin, fmax);
4623 
4624  // we use number of dimensions to determine if we have contents
4625  int ndim = padopt->GetFullRangeDim();
4626 
4627  if (!sel || (new_umin >= new_umax)) { new_umin = fmin; new_umax = fmax; }
4628 
4629  double shift = (new_umax - new_umin) * fact;
4630  // protect if changes is out of full axis ranges
4631  if (shift <= 0) return;
4632 
4633  switch (action) {
4634  case 1:
4635  if ((new_umax + shift) > fmax) // SlotShiftL
4636  shift = fmax - new_umax;
4637  new_umin += shift;
4638  new_umax += shift;
4639  break;
4640  case 2:
4641  if (new_umin - shift < fmin) // SlotShiftR
4642  shift = new_umin - fmin;
4643  new_umin -= shift;
4644  new_umax -= shift;
4645  break;
4646  case 3:
4647  if (ndim == 1) {
4648  new_umax -= shift; // Expand 1d upper
4649  if (naxis < 1) // lower only for X
4650  new_umin += shift; // Expand 1d lower X
4651  }
4652  if (ndim == 2) {
4653  new_umax -= shift; // Expand 2d upper
4654  if (naxis < 2) // lower only for X,Y
4655  new_umin += shift; // Expand 1d lower X,Y
4656  }
4657  break;
4658  case 4:
4659  if (ndim == 1) { // Shrink 1d upper
4660  if (naxis < 1) { // X axis
4661  tmax = (-fact * new_umin + (1. - fact) * new_umax)
4662  / (1. - 2. * fact);
4663  tmin = (-fact * new_umax + (1. - fact) * new_umin)
4664  / (1. - 2. * fact); // Shrink 1d X
4665  } else { // content, lower has not been expanded
4666  tmax = (-fact * new_umin + new_umax) / (1. - fact);
4667  tmin = (-fact * new_umax + (1. - fact) * new_umin)
4668  / (1. - 2. * fact); // Shrink 1d X
4669  }
4670  }
4671  if (ndim == 2) {
4672  if (naxis < 2) { // X,Y axis
4673  tmax = (-fact * new_umin + (1. - fact) * new_umax)
4674  / (1. - 2. * fact);
4675  tmin = (-fact * new_umax + (1. - fact) * new_umin)
4676  / (1. - 2. * fact); // Shrink 1d X
4677  } else { // content, lower has not been expanded
4678  tmax = (-fact * new_umin + new_umax) / (1. - fact);
4679  tmin = (-fact * new_umax + (1. - fact) * new_umin)
4680  / (1. - 2. * fact); // Shrink 1d X
4681  }
4682  }
4683  new_umin = tmin;
4684  new_umax = tmax;
4685  if (new_umin < fmin)
4686  new_umin = fmin;
4687  if (new_umax > fmax)
4688  new_umax = fmax;
4689  break;
4690 
4691  case 5: // Auto-zoom
4692  case 6: { // Auto zoom, but ignore selected range
4693  TH1* padhist = dynamic_cast<TH1*>(padobj);
4694 
4695  if (padhist==0) break;
4696 
4697  if (naxis >= ndim) break;
4698 
4699  TAxis* axis = padhist->GetXaxis();
4700  if (naxis==1) axis = padhist->GetYaxis();
4701  if (naxis==2) axis = padhist->GetZaxis();
4702 
4703  // keep selected bins
4704  Int_t sel_l = sel ? axis->GetFirst() : 0;
4705  Int_t sel_r = sel ? axis->GetLast() : axis->GetNbins();
4706 
4707  Int_t firstbin(0), lastbin(0);
4708 
4709  // X axis in case of 1-dim histogram
4710  if ((ndim==1) && (naxis==0)) {
4711  for (Int_t n1 = 1; n1<=padhist->GetNbinsX(); n1++) {
4712  Double_t v = padhist->GetBinContent(n1);
4713  if (TMath::Abs(v)<1e-10) continue;
4714  if ((n1<sel_l) || (n1>sel_r)) continue;
4715  lastbin = n1;
4716  if (firstbin==0) firstbin = n1;
4717  }
4718  }
4719 
4720  // X,Y axis in case of 2-dim histogram
4721  if ((ndim==2) && (naxis<2))
4722  for (Int_t n1 = 1; n1<=padhist->GetNbinsX(); n1++)
4723  for (Int_t n2 = 1; n2<=padhist->GetNbinsY(); n2++) {
4724  Double_t v = padhist->GetBinContent(n1,n2);
4725  if (TMath::Abs(v)<1e-10) continue;
4726  Int_t bin = naxis==0 ? n1 : n2;
4727  if ((bin<sel_l) || (bin>sel_r)) continue;
4728  if ((lastbin==0) || (bin>lastbin)) lastbin = bin;
4729  if ((firstbin==0) || (bin<firstbin)) firstbin = bin;
4730  }
4731 
4732  // X,Y,Z axis in case of 3-dim histogram
4733  if ((ndim==3) && (naxis<3))
4734  for (Int_t n1 = 1; n1<=padhist->GetNbinsX(); n1++)
4735  for (Int_t n2 = 1; n2<=padhist->GetNbinsY(); n2++)
4736  for (Int_t n3 = 1; n3<=padhist->GetNbinsZ(); n3++) {
4737  Double_t v = padhist->GetBinContent(n1,n2,n3);
4738  if (TMath::Abs(v)<1e-10) continue;
4739  Int_t bin = naxis==0 ? n1 : ((naxis==1) ? n2 : n3);
4740  if ((bin<sel_l) || (bin>sel_r)) continue;
4741  if ((lastbin==0) || (bin>lastbin)) lastbin = bin;
4742  if ((firstbin==0) || (bin<firstbin)) firstbin = bin;
4743  }
4744 
4745  if (firstbin>0) {
4746 
4747  if (firstbin >= lastbin) { firstbin--; lastbin++; }
4748 
4749  if (firstbin<=3) firstbin = 1;
4750  if (lastbin >=axis->GetNbins()-3) lastbin = axis->GetNbins();
4751 
4752  Double_t left = axis->GetBinLowEdge(firstbin);
4753  Double_t right = axis->GetBinUpEdge(lastbin);
4754 
4755  Double_t margin = (right - left) * fact;
4756  left -= margin; right += margin;
4757 
4758  if ((left <= new_umin) && (right >= new_umax)) return;
4759 
4760  if (left > new_umin) new_umin = left;
4761  if (right < new_umax) new_umax = right;
4762 
4763  if (action==6) axis->SetRange(firstbin,lastbin);
4764  }
4765 
4766  break;
4767  }
4768 
4769  default:
4770  return;
4771  }
4772 
4773  TakeSelectedAxisRange(naxis, padopt, new_umin, new_umax, false);
4774 
4775  if (naxis == ndim)
4776  if (padopt->GetRange(naxis, new_umin, new_umax))
4777  padopt->SetAutoScale(kFALSE);
4778 }
4779 
4780 void TGo4ViewPanel::TakeFullRangeFromHisto(TH1* h1, TGo4Picture* padopt, bool isfirsthisto)
4781 {
4782  if ((h1 == 0) || (padopt == 0)) return;
4783 
4784  TAxis* xax = h1->GetXaxis();
4785  TAxis* yax = h1->GetYaxis();
4786  TAxis* zax = h1->GetZaxis();
4787  int ndim = h1->GetDimension();
4788 
4789  if (isfirsthisto) {
4790  padopt->SetFullRangeDim(ndim);
4791  padopt->SetFullRange(0, xax->GetBinLowEdge(1),
4792  xax->GetBinUpEdge(xax->GetNbins()));
4793  if (ndim > 1)
4794  padopt->SetFullRange(1, yax->GetBinLowEdge(1),
4795  yax->GetBinUpEdge(yax->GetNbins()));
4796  else
4797  padopt->ClearFullRange(2);
4798 
4799  if (ndim > 2)
4800  padopt->SetFullRange(2, zax->GetBinLowEdge(1),
4801  zax->GetBinUpEdge(zax->GetNbins()));
4802  } else
4803  ndim = padopt->GetFullRangeDim();
4804 
4805  if (ndim >= 3)
4806  return;
4807 
4808  Int_t dimindx = (ndim == 1) ? 1 : 2;
4809 
4810  Double_t minimum = 0, maximum = 0;
4811  Bool_t first = kTRUE;
4812  if (!isfirsthisto) {
4813  padopt->GetFullRange(dimindx, minimum, maximum);
4814  first = kFALSE;
4815  }
4816 
4817  for (Int_t biny = 1; biny <= yax->GetNbins(); biny++)
4818  for (Int_t binx = 1; binx <= xax->GetNbins(); binx++) {
4819  Int_t bin = h1->GetBin(binx, biny);
4820  Double_t value = h1->GetBinContent(bin);
4821  if (first) {
4822  minimum = value;
4823  maximum = value;
4824  first = kFALSE;
4825  }
4826  if (value < minimum)
4827  minimum = value;
4828  else if (value > maximum)
4829  maximum = value;
4830  }
4831 
4832  padopt->SetFullRange(dimindx, minimum, maximum);
4833 }
4834 
4835 void TGo4ViewPanel::TakeFullRangeFromGraph(TGraph * gr, TGo4Picture * padopt, bool isfirst)
4836 {
4837  if ((gr == 0) || (padopt == 0)) return;
4838 
4839  Double_t minx(0), maxx(0), miny(0), maxy(0), xx, yy;
4840  if (isfirst) {
4841  if (gr->GetN() > 0) {
4842  gr->GetPoint(0, minx, miny);
4843  maxx = minx;
4844  maxy = miny;
4845  }
4846  } else {
4847  padopt->GetFullRange(0, minx, maxx);
4848  padopt->GetFullRange(1, miny, maxy);
4849  }
4850 
4851  for (Int_t n = 0; n < gr->GetN(); n++) {
4852  gr->GetPoint(n, xx, yy);
4853  if (xx < minx)
4854  minx = xx;
4855  else if (xx > maxx)
4856  maxx = xx;
4857  if (yy < miny)
4858  miny = yy;
4859  else if (yy > maxy)
4860  maxy = yy;
4861  }
4862 
4863  padopt->SetFullRangeDim(1);
4864  padopt->SetFullRange(0, minx, maxx);
4865  padopt->SetFullRange(1, miny, maxy);
4866  padopt->ClearFullRange(2);
4867 }
4868 
4869 void TGo4ViewPanel::SetSelectedRangeToHisto(TPad* pad, TH1* h1, THStack* hs,
4870  TGo4Picture* padopt, bool isthishisto)
4871 {
4872  // set selected range, stats and title position for histogram
4873 
4874  if ((h1 == 0) || (padopt == 0) || (pad == 0)) return;
4875 
4876  int ndim = padopt->GetFullRangeDim();
4877 
4878  bool autoscale = padopt->IsAutoScale();
4879 
4880  double hmin(0.), hmax(0.), umin, umax;
4881 
4882  TAxis* ax = h1->GetXaxis();
4883 
4884  if (IsAutoZoomFlag() && isthishisto) {
4885  MoveSingleScale(1., 6, 0, padopt, h1);
4886  if (ndim>1) MoveSingleScale(1., 6, 1, padopt, h1);
4887  if (ndim>2) MoveSingleScale(1., 6, 2, padopt, h1);
4888  } else
4889  if (padopt->GetRange(0, umin, umax)) {
4890  // note: go4 range was full visible range of histogram
4891  // in new ROOT automatic shift of ranges can appear,
4892  // to prevent this, center of each bin should be used
4893 
4894  Int_t i1 = ax->FindFixBin(umin);
4895  Int_t i2 = ax->FindFixBin(umax);
4896  if (i1<i2) ax->SetRange(i1,i2);
4897  else { ax->UnZoom(); padopt->ClearRange(0); }
4898  } else {
4899  ax->UnZoom();
4900  }
4901 
4902  TAxis* ay = h1->GetYaxis();
4903 
4904  if (padopt->GetRange(1, umin, umax)) {
4905  if (!autoscale && (ndim == 1)) {
4906  hmin = umin;
4907  hmax = umax;
4908  ay = 0;
4909  }
4910 
4911  // note: go4 range was full visible range of histogram
4912  // in new ROOT automatic shift of ranges can appear,
4913  // to prevent this, center of each bin should be used
4914 
4915  if (ndim>1) {
4916  Int_t i1 = ay->FindFixBin(umin);
4917  Int_t i2 = ay->FindFixBin(umax);
4918  if (i1<i2) { ay->SetRange(i1,i2); ay = 0; }
4919  }
4920  }
4921 
4922  if (ay!=0) {
4923  ay->UnZoom();
4924  padopt->ClearRange(1);
4925  // workaround for the 5.34/11 version
4926  if ((ndim==1) && (h1->GetMinimum()==0) && (h1->GetMaximum()==1)) {
4927  h1->SetMinimum();
4928  h1->SetMaximum();
4929  }
4930  }
4931 
4932  TAxis* az = h1->GetZaxis();
4933  if (padopt->GetRange(2, umin, umax) && (ndim > 1)) {
4934  if (!autoscale && (ndim == 2)) {
4935  hmin = umin;
4936  hmax = umax;
4937  az = 0;
4938  }
4939  // note: go4 range was full visible range of histogram
4940  // in new ROOT automatic shift of ranges can appear,
4941  // to prevent this, center of each bin should be used
4942 
4943  if (ndim>2) {
4944  Int_t i1 = az->FindFixBin(umin);
4945  Int_t i2 = az->FindFixBin(umax);
4946  if (i1<i2) { az->SetRange(i1,i2); az = 0; }
4947  }
4948  }
4949 
4950  if (az!=0) {
4951  az->UnZoom();
4952  padopt->ClearRange(2);
4953  }
4954 
4955  if (hmin != hmax) {
4956  // if scale axis is log, prevent negative values, otherwise
4957  // histogram will not be displayed
4958  if (padopt->GetLogScale(ndim)) {
4959  if (hmax <= 0) hmax = 1.;
4960  if ((hmin <= 0) || (hmin >= hmax)) {
4961  hmin = hmax * 1e-4;
4962  if (hmin > 1.) hmin = 1;
4963  }
4964  }
4965 
4966  h1->SetMinimum(hmin);
4967  h1->SetMaximum(hmax);
4968  h1->SetBit(TH1::kIsZoomed);
4969  if (hs != 0) {
4970  hs->SetMinimum(hmin);
4971  hs->SetMaximum(hmax);
4972  }
4973  } else {
4974  // this is autoscale mode
4975 
4976  if (hs != 0) {
4977 
4978  if (ndim == 1) {
4979  TIter next(hs->GetHists());
4980  TH1* hs_h1 = 0;
4981  while ((hs_h1 = (TH1*) next()) != 0) {
4982  if (padopt->GetRange(0, umin, umax)) {
4983  // note: go4 range was full visible range of histogram
4984  // in new ROOT automatic shift of ranges can appear,
4985  // to prevent this, center of each bin should be used
4986  TAxis* ax = hs_h1->GetXaxis();
4987  Int_t i1 = ax->FindFixBin(umin);
4988  Int_t i2 = ax->FindFixBin(umax);
4989  if (i1<i2) { ax->SetRange(i1,i2); }
4990  else { ax->UnZoom(); padopt->ClearRange(0); }
4991  } else {
4992  hs_h1->GetXaxis()->UnZoom();
4993  }
4994 
4995  hs_h1->GetYaxis()->UnZoom();
4996  hs_h1->SetMinimum();
4997  hs_h1->SetMaximum();
4998  }
4999  }
5000 
5001  hs->SetMinimum();
5002  hs->SetMaximum();
5003  }
5004 
5005  h1->SetMinimum();
5006  h1->SetMaximum();
5007  h1->ResetBit(TH1::kIsZoomed);
5008 
5009  // here one can estimate actual range which will be displayed on canvas
5010 
5011  if (ndim < 3) {
5012 
5013  Double_t selmin = h1->GetMinimum();
5014  Double_t selmax = h1->GetMaximum();
5015 
5016  if (selmin >= selmax) {
5017  padopt->ClearRange(ndim);
5018  } else {
5019  bool islogscale = (ndim == 1) && (padopt->GetLogScale(1) > 0);
5020 
5021  if (islogscale) {
5022  if ((selmin > 0) && (selmax > 0)) {
5023  selmin = TMath::Log10(selmin) + TMath::Log10(0.5);
5024  selmin = TMath::Power(10, selmin);
5025  selmax = TMath::Log10(selmax)
5026  + TMath::Log10(2 * (0.9 / 0.95));
5027  selmax = TMath::Power(10, selmax);
5028  }
5029 
5030  } else {
5031  Double_t yMARGIN = 0.05;
5032 #if ROOT_VERSION_CODE > ROOT_VERSION(5,0,9)
5033  yMARGIN = gStyle->GetHistTopMargin();
5034 #endif
5035  Double_t dymin = yMARGIN * (selmax - selmin);
5036  if ((selmin >= 0) && (selmin - dymin < 0))
5037  selmin = 0;
5038  else
5039  selmin -= dymin;
5040  selmax += yMARGIN * (selmax - selmin);
5041  }
5042 
5043  padopt->SetRange(ndim, selmin, selmax);
5044  }
5045  }
5046  }
5047 
5048  if (padopt->IsHisStats() && isthishisto) {
5049  TPaveStats* stats =
5050  dynamic_cast<TPaveStats*>(h1->GetListOfFunctions()->FindObject("stats"));
5051  if (stats==0) {
5052  stats = new TPaveStats(
5053  gStyle->GetStatX()-gStyle->GetStatW(),
5054  gStyle->GetStatY()-gStyle->GetStatH(),
5055  gStyle->GetStatX(),
5056  gStyle->GetStatY(),"brNDC");
5057  stats->SetParent(h1);
5058  stats->UseCurrentStyle();
5059  stats->SetName("stats");
5060  h1->GetListOfFunctions()->Add(stats);
5061  stats->ConvertNDCtoPad(); // need to bypass TPave init problem
5062  }
5063  padopt->GetStatsAttr(stats);
5064  }
5065 
5066  if (padopt->IsHisTitle() && padopt->HasTitleAttr()) {
5067  TPaveText* titl =
5068  dynamic_cast<TPaveText*>(pad->GetListOfPrimitives()->FindObject("title"));
5069 
5070  if (titl==0) {
5071  titl = new TPaveText(gStyle->GetTitleX()-gStyle->GetTitleW(),
5072  gStyle->GetTitleY()-gStyle->GetTitleH(),
5073  gStyle->GetTitleX(),
5074  gStyle->GetTitleY(),"blNDC");
5075  titl->UseCurrentStyle();
5076  titl->SetFillColor(gStyle->GetTitleFillColor());
5077  titl->SetFillStyle(gStyle->GetTitleStyle());
5078  titl->SetName("title");
5079  titl->SetBorderSize(gStyle->GetTitleBorderSize());
5080  titl->SetTextColor(gStyle->GetTitleTextColor());
5081  titl->SetTextFont(gStyle->GetTitleFont(""));
5082  if (gStyle->GetTitleFont("")%10 > 2)
5083  titl->SetTextSize(gStyle->GetTitleFontSize());
5084  titl->AddText(h1->GetTitle());
5085  titl->SetBit(kCanDelete);
5086  pad->GetListOfPrimitives()->Add(titl);
5087  titl->ConvertNDCtoPad(); // need to bypass TPave init problem
5088  }
5089  padopt->GetTitleAttr(titl);
5090  }
5091 
5092  // add here setting the time format properties:
5093  TAxis* xax = h1->GetXaxis();
5094  xax->SetTimeDisplay(padopt->IsXAxisTimeDisplay());
5095  xax->SetTimeFormat(padopt->GetXAxisTimeFormat());
5096 
5097  // JAM 2016 finally we evaluate the rectangular axis scale property:
5098  //std::cout<< "SetSelectedRangeToHisto - 1:1 is "<< padopt->IsXYRatioOne()<< std::endl;
5099  if (padopt->IsXYRatioOne())
5100  {
5101  RectangularRatio(pad);
5102  }
5103  else
5104  {
5105  DefaultPadMargin(pad);
5106  }
5107 }
5108 
5109 bool TGo4ViewPanel::GetVisibleRange(TPad* pad, int naxis, double& min, double& max)
5110 {
5111  TGo4Picture* padopt = GetPadOptions(pad);
5112  if (padopt == 0) return false;
5113 
5114  int NumDim = padopt->GetFullRangeDim();
5115 
5116  if ((naxis < 0) || (naxis > NumDim)) return false;
5117 
5118  bool res = padopt->GetRange(naxis, min, max);
5119  if (!res || (min >= max))
5120  res = padopt->GetFullRange(naxis, min, max);
5121  return res;
5122 }
5123 
5125  double selmin, double selmax, bool force)
5126 {
5127  if ((selmin == -1.) && (selmax == -1.)) return false;
5128 
5129  double min, max, umin, umax;
5130 
5131  bool full = padopt->GetFullRange(naxis, min, max);
5132  bool sel = padopt->GetRange(naxis, umin, umax);
5133 
5134  if (!full || (min >= max) || (selmin >= selmax)) {
5135  padopt->ClearRange(naxis);
5136  return true;
5137  }
5138 
5139  double delta = (max - min) / 100000.;
5140  bool changed = false;
5141 
5142  if (umin < umax) {
5143  if (fabs(umin - selmin) > delta) {
5144  umin = selmin;
5145  changed = true;
5146  }
5147  if (fabs(umax - selmax) > delta) {
5148  umax = selmax;
5149  changed = true;
5150  }
5151  } else {
5152  umin = selmin;
5153  umax = selmax;
5154  changed = true;
5155  }
5156 
5157  if ((selmin < min + delta) && (selmax > max - delta) && !force) {
5158  padopt->ClearRange(naxis);
5159  } else {
5160  padopt->SetRange(naxis, umin, umax);
5161  }
5162 
5163  return changed;
5164 }
5165 
5166 bool TGo4ViewPanel::TakeSelectedAxisRange(int naxis, TGo4Picture* padopt, TAxis* ax)
5167 {
5168  Double_t selmin, selmax;
5169 
5170  // check if something selected on axis
5171  if (((ax->GetFirst() <= 0) && (ax->GetLast() >= ax->GetNbins() - 1))
5172  || (ax->GetFirst() >= ax->GetLast())) {
5173  selmin = -1111;
5174  selmax = -1111;
5175  } else {
5176  selmin = ax->GetBinCenter(ax->GetFirst());
5177  selmax = ax->GetBinCenter(ax->GetLast());
5178  }
5179 
5180  return TakeSelectedAxisRange(naxis, padopt, selmin, selmax, false);
5181 }
5182 
5184 {
5185  TGo4LockGuard lock;
5186 
5187  TGo4Picture* padopt = GetPadOptions(pad);
5188 
5189  if (IsRedrawBlocked() || (pad == 0) || (padopt == 0)) return;
5190 
5191  // check if we have histogram and can take range from it
5192  TH1* h1 = GetPadHistogram(pad);
5193 
5194  if (h1 != 0) {
5195  Int_t ndim = padopt->GetFullRangeDim();
5196 
5197  TakeSelectedAxisRange(0, padopt, h1->GetXaxis());
5198  if (ndim > 1)
5199  TakeSelectedAxisRange(1, padopt, h1->GetYaxis());
5200  if (ndim > 2)
5201  TakeSelectedAxisRange(2, padopt, h1->GetZaxis());
5202  if (ndim < 3) {
5203 
5204  bool iszoomed = h1->TestBit(TH1::kIsZoomed);
5205 
5206  padopt->SetAutoScale(!iszoomed);
5207  //h1->SetMinimum();
5208  //h1->SetMaximum();
5209 
5210  Double_t selmin = h1->GetMinimum();
5211  Double_t selmax = h1->GetMaximum();
5212 
5213  if (iszoomed) {
5214  padopt->SetRange(ndim, selmin, selmax);
5215  } else if (selmin >= selmax) {
5216  padopt->ClearRange(ndim);
5217  } else {
5218 
5219  bool islogscale = (ndim == 1) && (pad->GetLogy() > 0);
5220 
5221  if (islogscale) {
5222  if ((selmin > 0) && (selmax > 0)) {
5223  selmin = TMath::Log10(selmin) + TMath::Log10(0.5);
5224  selmin = TMath::Power(10, selmin);
5225  selmax = TMath::Log10(selmax)
5226  + TMath::Log10(2 * (0.9 / 0.95));
5227  selmax = TMath::Power(10, selmax);
5228  }
5229 
5230  } else {
5231  Double_t yMARGIN = 0.05;
5232 #if ROOT_VERSION_CODE > ROOT_VERSION(5,0,9)
5233  yMARGIN = gStyle->GetHistTopMargin();
5234 #endif
5235  Double_t dymin = yMARGIN * (selmax - selmin);
5236  if ((selmin >= 0) && (selmin - dymin < 0))
5237  selmin = 0;
5238  else
5239  selmin -= dymin;
5240  selmax += yMARGIN * (selmax - selmin);
5241  }
5242 
5243  padopt->SetRange(ndim, selmin, selmax);
5244  }
5245  }
5246 
5247  // inform that options were changed in panel
5249  return;
5250  }
5251 
5252  Double_t rxmin, rxmax, rymin, rymax;
5253  pad->GetRangeAxis(rxmin, rymin, rxmax, rymax);
5254 
5255  if (pad->GetLogx() > 0) {
5256  rxmin = TMath::Power(10., rxmin);
5257  rxmax = TMath::Power(10., rxmax);
5258  }
5259 
5260  if (pad->GetLogy() > 0) {
5261  rymin = TMath::Power(10., rymin);
5262  rymax = TMath::Power(10., rymax);
5263  }
5264 
5265  PadRangeAxisChanged(pad, rxmin, rxmax, rymin, rymax);
5266 }
5267 
5268 void TGo4ViewPanel::PadRangeAxisChanged(TPad* pad, double rxmin, double rxmax,
5269  double rymin, double rymax)
5270 {
5271  TGo4LockGuard lock;
5272 
5273  if (IsRedrawBlocked() || (pad == 0)) return;
5274 
5275  TGo4Picture* padopt = GetPadOptions(pad);
5276  if (padopt == 0) return;
5277 
5278  TakeSelectedAxisRange(0, padopt, rxmin, rxmax, false);
5279  TakeSelectedAxisRange(1, padopt, rymin, rymax, false);
5280 
5282 }
5283 
5284 void TGo4ViewPanel::GetSelectedRange(int& ndim, bool& autoscale, double& xmin,
5285  double& xmax, double& ymin, double& ymax, double& zmin, double& zmax)
5286 {
5287  ndim = 0;
5288  TGo4Picture* padopt = GetPadOptions(GetActivePad());
5289  if (padopt == 0) return;
5290 
5291  ndim = padopt->GetFullRangeDim();
5292  autoscale = padopt->IsAutoScale();
5293 
5294  GetVisibleRange(GetActivePad(), 0, xmin, xmax);
5295  GetVisibleRange(GetActivePad(), 1, ymin, ymax);
5296  GetVisibleRange(GetActivePad(), 2, zmin, zmax);
5297 }
5298 
5300 {
5301  fbApplyToAllFlag = on;
5302 
5303  QCheckBox* box1 = findChild<QCheckBox*>("ApplyToAllCheck");
5304  if (box1 != 0) box1->setChecked(on);
5305 }
5306 
5307 void TGo4ViewPanel::SetAutoScale(bool on, TPad* selpad)
5308 {
5309  TGo4LockGuard lock;
5310 
5311  bool modified = false;
5312  bool applytoall = false;
5313  bool redraw_immediately = (selpad == 0);
5314 
5315  if (selpad == 0) {
5316  applytoall = IsApplyToAllFlag();
5317  selpad = applytoall ? GetCanvas() : GetActivePad();
5318  }
5319  if (selpad == 0)
5320  return;
5321 
5322  TGo4Picture* padopt = GetPadOptions(selpad);
5323  if (padopt != 0) {
5324  if (on != padopt->IsAutoScale())
5325  padopt->SetPadModified();
5326  padopt->SetAutoScale(on);
5327  modified = modified || padopt->IsPadModified();
5328  }
5329 
5330  if (applytoall) {
5331  TGo4Iter iter(GetPadSlot(selpad), kTRUE);
5332  while (iter.next()) {
5333  TPad* subpad = GetSlotPad(iter.getslot());
5334  padopt = GetPadOptions(subpad);
5335  if (padopt == 0)
5336  continue;
5337  if (on != padopt->IsAutoScale())
5338  padopt->SetPadModified();
5339  padopt->SetAutoScale(on);
5340  modified = modified || padopt->IsPadModified();
5341  }
5342  }
5343 
5344  if (modified && redraw_immediately)
5345  RedrawPanel(selpad, false);
5346 }
5347 
5348 void TGo4ViewPanel::SetSelectedRange(double xmin, double xmax, double ymin,
5349  double ymax, double zmin, double zmax)
5350 {
5351  TGo4LockGuard lock;
5352 
5353  TPad* selpad = IsApplyToAllFlag() ? GetCanvas() : GetActivePad();
5354  if (selpad == 0)
5355  return;
5356 
5357  TGo4Picture* padopt = GetPadOptions(selpad);
5358  if (padopt != 0) {
5359  Int_t ndim = padopt->GetFullRangeDim();
5360 
5361  TakeSelectedAxisRange(0, padopt, xmin, xmax, true);
5362  if (ndim > 1)
5363  TakeSelectedAxisRange(1, padopt, ymin, ymax, true);
5364  if (ndim > 2)
5365  TakeSelectedAxisRange(2, padopt, zmin, zmax, true);
5366  if (!padopt->IsAutoScale()) {
5367  if (ndim == 1)
5368  TakeSelectedAxisRange(1, padopt, ymin, ymax, true);
5369  if (ndim == 2)
5370  TakeSelectedAxisRange(2, padopt, zmin, zmax, true);
5371  }
5372  padopt->SetPadModified();
5373  }
5374 
5375  if (IsApplyToAllFlag()) {
5376  TGo4Iter iter(GetPadSlot(selpad), kTRUE);
5377  while (iter.next()) {
5378  TPad* subpad = GetSlotPad(iter.getslot());
5379  padopt = GetPadOptions(subpad);
5380  if (padopt == 0)
5381  continue;
5382  Int_t ndim = padopt->GetFullRangeDim();
5383  TakeSelectedAxisRange(0, padopt, xmin, xmax, true);
5384  if (ndim > 1)
5385  TakeSelectedAxisRange(1, padopt, ymin, ymax, true);
5386  if (ndim > 2)
5387  TakeSelectedAxisRange(2, padopt, zmin, zmax, true);
5388  if (!padopt->IsAutoScale()) {
5389  if (ndim == 1)
5390  TakeSelectedAxisRange(1, padopt, ymin, ymax, true);
5391  if (ndim == 2)
5392  TakeSelectedAxisRange(2, padopt, zmin, zmax, true);
5393  }
5394 
5395  padopt->SetPadModified();
5396  }
5397  }
5398 
5399  RedrawPanel(selpad, false);
5400 }
5401 
5402 void TGo4ViewPanel::resizeEvent(QResizeEvent * e)
5403 {
5404 
5405  // store size of top widget -
5406  // size of top widget will be restored when new panel is created
5407  go4sett->storePanelSize(parentWidget(), "ViewPanel");
5408  //std::cout<< "TGo4ViewPanel::resizeEvent"<<std::endl;
5409  TPad* selpad = IsApplyToAllFlag() ? GetCanvas() : GetActivePad();
5410  if (selpad == 0)
5411  return;
5412  // only if we are in 1:1 aspect ratio, we might need a redraw here:
5413  TGo4Slot* slot = GetPadSlot(selpad);
5414  if (slot == 0) return;
5415  TGo4Picture* padopt = GetPadOptions(slot);
5416  if (padopt == 0) return;
5417 
5418  if (padopt->IsXYRatioOne())
5419  {
5420  //std::cout<< "TGo4ViewPanel::resizeEvent with ratio :1"<<std::endl;
5421  // note: we need to delay execution of redraw, since resize Event in QtROOT canvas will
5422  // also happen in timer 100ms after us -> new coordinates are not refreshed here!
5423  fxResizeTimerPad=selpad;
5424  QTimer::singleShot(1000, this, SLOT(checkResizeSlot()));
5425  }
5426 }
5427 
5428 
5430 {
5431 #ifndef __NOGO4GED__
5432  TGedEditor* ed = dynamic_cast<TGedEditor*>(fxPeditor);
5433  if ((ed != 0) && fbEditorFrameVisible && fxRooteditor)
5435 #endif
5436 }
5437 
5439 {
5440  if (!fbEditorFrameVisible) return;
5441 
5442 #ifndef __NOGO4GED__
5443  TGedEditor* ed = dynamic_cast<TGedEditor*>(fxPeditor);
5444  if ((ed != 0) && (obj != 0))
5445  if (!obj->InheritsFrom(THStack::Class()) && !obj->InheritsFrom(TMultiGraph::Class())) {
5446  gTQSender = GetCanvas();
5447  ed->SetModel(GetActivePad(), obj, kButton1Down);
5448  }
5449 #endif
5450 }
5451 
5453 {
5454 #ifndef __NOGO4GED__
5455 // std::cout << "TGo4ViewPanel::CleanupGedEditor()" << std::endl;
5456  TGedEditor* ed = dynamic_cast<TGedEditor*>(fxPeditor);
5457  if (ed == 0) return;
5458  if (fDummyHisto == 0) {
5459  fDummyHisto = new TH1I("dummyhisto", "dummyhisto", 100, -10., 10.);
5460  fDummyHisto->FillRandom("gaus", 1000);
5461  fDummyHisto->SetDirectory(0);
5462  fDummyHisto->SetBit(kCanDelete, kFALSE);
5463  }
5464  gTQSender = GetCanvas();
5465  ed->SetModel(0, fDummyHisto, kButton1Down);
5466  ed->SetModel(0, GetCanvas(), kButton1Down);
5467 #endif
5468 }
5469 
5471 {
5473 }
5474 
5476 {
5477  if (IsRepaintTimerActive()) return;
5478 
5479  if (pad == 0) pad = GetCanvas();
5480 
5481  fxRepaintTimerPad = pad;
5483 }
5484 
5486 {
5487  return fxRepaintTimerPad != 0;
5488 }
5489 
5491 {
5492  TPad* pad = fxRepaintTimerPad;
5493  fxRepaintTimerPad = 0;
5494  if (pad != 0)
5495  RedrawPanel(pad, false);
5496 }
5497 
5499 {
5500  TPad* pad = fxResizeTimerPad;
5501  fxResizeTimerPad = 0;
5502  if (pad != 0)
5503  RedrawPanel(pad, true);
5504 }
5505 
5507 {
5508  TGo4Slot* slot = GetPadSlot(pad);
5509  if (slot != 0)
5510  delete slot;
5511 
5512  GetCanvas()->SetSelectedPad(GetCanvas());
5513  GetCanvas()->SetSelected(GetCanvas());
5515 }
5516 
5517 // marker functions
5518 
5519 int TGo4ViewPanel::GetNumMarkers(TPad* pad, int kind)
5520 {
5521  TGo4Slot* slot = GetPadSlot(pad);
5522  if (slot == 0)
5523  return 0;
5524 
5525  int res = 0;
5526 
5527  for (int n = 0; n < slot->NumChilds(); n++) {
5528  TGo4Slot* subslot = slot->GetChild(n);
5529  if (GetDrawKind(subslot) == kind)
5530  res++;
5531  }
5532  return res;
5533 }
5534 
5535 void TGo4ViewPanel::AddMarkerObj(TPad* pad, int kind, TObject* obj)
5536 {
5537  TGo4Slot* padslot = GetPadSlot(pad);
5538  if (padslot == 0) {
5539  delete obj;
5540  return;
5541  }
5542 
5543  QString basename;
5544  switch (kind) {
5545  case kind_Marker:
5546  basename = "Marker";
5547  break;
5548  case kind_Window:
5549  basename = "Window";
5550  break;
5551  case kind_Poly:
5552  basename = "Polygon";
5553  break;
5554  case kind_Latex:
5555  basename = "Latex";
5556  break;
5557  case kind_Arrow:
5558  basename = "Arrow";
5559  break;
5560  default:
5561  basename = "Something";
5562  break;
5563  }
5564 
5565  QString slotname;
5566  int cnt = 0;
5567  do {
5568  slotname = basename + QString::number(cnt++);
5569  } while (padslot->FindChild(slotname.toLatin1().constData()) != 0);
5570 
5571  TGo4Slot* objslot = AddDrawObject(pad, kind, slotname.toLatin1().constData(), obj, true, 0);
5572 
5573  SetActiveObj(pad, kind, objslot);
5574 }
5575 
5576 void TGo4ViewPanel::SetActiveObj(TPad* pad, int kind, TGo4Slot* activeslot)
5577 {
5578  TGo4Slot* slot = GetPadSlot(pad);
5579  if (slot == 0)
5580  return;
5581 
5582  for (int n = 0; n < slot->NumChilds(); n++) {
5583  TGo4Slot* subslot = slot->GetChild(n);
5584  int drawkind = GetDrawKind(subslot);
5585  if (drawkind != kind)
5586  continue;
5587 
5588  if (subslot != activeslot)
5589  subslot->RemovePar("::ActiveMarker");
5590  else
5591  subslot->SetPar("::ActiveMarker", "1");
5592  }
5593 }
5594 
5595 TObject* TGo4ViewPanel::GetActiveObj(TPad* pad, int kind)
5596 {
5597  int selkind;
5598  TObject* selobj;
5599  TGo4Slot* selslot = GetSelectedSlot(pad, &selkind, &selobj);
5600  if ((kind == selkind) && (selobj != 0))
5601  return selobj;
5602 
5603  TGo4Slot* slot = GetPadSlot(pad);
5604  if (slot == 0)
5605  return 0;
5606 
5607  TObject* lastobj = 0;
5608 
5609  for (int n = 0; n < slot->NumChilds(); n++) {
5610  TGo4Slot* subslot = slot->GetChild(n);
5611  int drawkind = GetDrawKind(subslot);
5612  if (drawkind != kind)
5613  continue;
5614 
5615  lastobj = subslot->GetAssignedObject();
5616  if (subslot->GetPar("::ActiveMarker") != 0)
5617  return lastobj;
5618  }
5619 
5620  return lastobj;
5621 }
5622 
5623 QString TGo4ViewPanel::GetActiveObjName(TPad* pad, int kind)
5624 {
5625  TObject* obj = GetActiveObj(pad, kind);
5626  return (obj == 0) ? QString("null") : QString(obj->GetName());
5627 }
5628 
5630 {
5631  TGo4LockGuard lock;
5632  switch (id) {
5633  case CrosshairId: {
5635  GetCanvas()->SetCrosshair(fbCanvasCrosshair);
5636 
5637 #if ROOT_VERSION_CODE < ROOT_VERSION(4,0,8)
5638 
5639  TGo4Iter(GetPadSlot(GetCanvas()), true);
5640  while (iter.next()) {
5641  TPad* subpad = GetSlotPad(iter.getslot());
5642  if (subpad!=0) {
5643  subpad->SetCrosshair(fbCanvasCrosshair);
5644  subpad->Modified();
5645  }
5646  }
5647 #endif
5648 
5649  GetQCanvas()->Modified();
5650  GetQCanvas()->Update();
5652  break;
5653  }
5654 
5655  case FreezeTitleId: {
5657  break;
5658  }
5659 
5660  case AutoZoomId: {
5662  if (fbAutoZoomFlag) RedrawPanel(GetCanvas(), true);
5663  break;
5664  }
5665 
5666  case SetTitleTextId: {
5667  bool ok = false;
5668  QString mycaption = windowTitle();
5669  QString oldtitle = mycaption.remove(fPanelName + ": ");
5670  QString text = QInputDialog::getText(this, GetPanelName(),
5671  "Enter Viewpanel Title:", QLineEdit::Normal, oldtitle, &ok);
5672  if (ok && !text.isEmpty())
5673  SetFreezedTitle(text);
5674  break;
5675  }
5676 
5677  case SetTimeFormatId: {
5678  bool ok = false;
5679  TPad* pad = GetActivePad();
5680  if (pad == 0) pad = GetCanvas();
5681  TGo4Picture *padopt = GetPadOptions(pad);
5682  QString oldfmt = padopt->GetXAxisTimeFormat();
5683  QString text = QInputDialog::getText(this, GetPanelName(),
5684  "Enter Axis time format:", QLineEdit::Normal, oldfmt, &ok);
5685  if (ok && !text.isEmpty()) {
5686  //std::cout <<"changed time format to"<<(const char*)text.toLatin1() << std::endl;
5687  //padopt->SetXAxisTimeFormat(text.toLatin1());
5688  //padopt->SetPadModified();
5689  ChangeDrawOption(id - 1000, 0, text.toLatin1());
5690  }
5691  break;
5692  }
5693 
5694  default:
5695  if (id > 1000) {
5696  QAction* act = SetIdAction(fOptionsMap, id);
5697  bool s = act ? act->isChecked() : false;
5698  ChangeDrawOption(id - 1000, s, 0);
5699  }
5700  break;
5701  }
5702 }
5703 
5705 {
5706 // if (IsRedrawBlocked()) return;
5707 
5708  fbApplyToAllFlag = on;
5709 }
5710 
5712 {
5713  if (IsRedrawBlocked())
5714  return;
5715 
5716  SetAutoScale(on, 0);
5717 }
5718 
5719 void TGo4ViewPanel::panelSlot(TGo4ViewPanel * panel, TPad * pad, int signalid)
5720 {
5721  if (panel != this)
5722  return;
5723 
5724  BlockPanelRedraw(true);
5725 
5726  TGo4Picture* padopt = GetPadOptions(GetActivePad());
5727  if (padopt != 0)
5728  fAutoScaleCheck->setChecked(padopt->IsAutoScale());
5729 
5730  BlockPanelRedraw(false);
5731 }
5732 
5734 {
5735  if (IsRedrawBlocked())
5736  return;
5737 
5738  ChangeDrawOption(11, on, "");
5739 }
virtual void SetMouseMode(int mode)
virtual void ShootRepaintTimer()
bool fbCanvasCrosshair
virtual TObject * GetDrawObject(TPad *pad, const char *name)
virtual void CheckActionAtTheEnd(TPad *pad)
TPad * fxActivePad
virtual bool IsPadHasSubPads(TGo4Slot *padslot)
virtual void SwitchMarkerButton(int kind, bool on)
virtual void SetChanged(Bool_t on)
virtual void linkedRemoved(TGo4Slot *slot, TObject *obj)
virtual void ResetWidget()
virtual void RectangularRatio(TPad *pad)
virtual void PrintCanvas()
void SetRange(Int_t naxis, Double_t min, Double_t max)
void SetTitleTime(Bool_t on=kTRUE)
virtual Double_t GetYLow()
Definition: TGo4WinCond.h:62
void Modified(Bool_t=1)
virtual void linkedUpdated(TGo4Slot *slot, TObject *obj)
bool IsContentModified() const
Bool_t GetIntPar(const char *name, Int_t &value)
Definition: TGo4Slot.cxx:646
Int_t GetDivX()
Definition: TGo4Picture.h:57
virtual void SetPadDefaults(TPad *pad)
QString getTGraphDrawOpt()
virtual void TakeFullRangeFromHisto(TH1 *h1, TGo4Picture *padopt, bool isfirsthisto)
void setPrinterSett(const QString &name, const QString &cmd)
const char * GetXAxisTimeFormat()
virtual const char * GetName() const
Definition: TGo4Marker.h:116
virtual TGo4Slot * GetSuperimposeSlot(TGo4Slot *slot)
virtual void ApplyToAllToggled(bool)
Int_t GetNumObjNames()
QSignalMapper * fOptionsMap
virtual void RedrawImage(TPad *pad, TGo4Picture *padopt, TGo4ASImage *im, TH2 *asihisto, bool scancontent)
void SetAutoZoom(bool on)
bool UpdateItemInAnalysis(const char *itemname, TObject *obj=0)
Definition: QGo4Widget.cpp:383
void SetIntPar(const char *name, Int_t value)
Definition: TGo4Slot.cxx:639
virtual void StartConditionEditor()
virtual const char * GetDrawObjectLinkName(TPad *pad, TObject *obj)
bool getStatBoxVisible()
virtual void SetFreezeMouseMode(bool on)
virtual void MakePictureForPad(TGo4Picture *pic, TPad *pad, bool useitemname)
void AddObjName(const char *name, Option_t *DrawOption=0)
TObject * GetBrowserObject(const char *name, Int_t update=0)
TVirtualPadEditor * fxPeditor
virtual void ActivateInGedEditor(TObject *obj)
virtual void SetDrawKind(TGo4Slot *slot, int kind)
virtual int GetAutoColor(int indx)
virtual void SetActivePad(TPad *pad)
bool fbModifiedSignalFlag
virtual bool IsRedrawBlocked()
void SetProxy(TGo4Proxy *cont)
Definition: TGo4Slot.cxx:313
virtual bool ProcessPadRedraw(TPad *pad, bool force)
void SetDrawData(TH2 *histo, TGo4ViewPanel *panel, TPad *pad)
Definition: TGo4ASImage.cpp:60
virtual void EditConditionBtn_clicked()
TPad * GetSelectedPad()
Definition: TGo4MdiArea.cpp:52
Bool_t IsDivided()
Definition: TGo4Picture.h:59
Int_t GetLogScale(Int_t nscale=0)
virtual void RedrawMultiGraph(TPad *pad, TGo4Picture *padopt, TMultiGraph *mg, bool dosuperimpose, bool scancontent)
QMenu * fSelectMenu
virtual void RedrawStack(TPad *pad, TGo4Picture *padopt, THStack *hs, bool dosuperimpose, bool scancontent)
void getCanvasColor(int &red, int &green, int &blue)
Int_t GetIndexOf(TGo4Slot *child)
Definition: TGo4Slot.cxx:245
virtual QString GetSelectedMarkerName(TPad *pad)
virtual void StartConditionEditing(TPad *pad)
double ScaledHeight()
virtual Int_t IsChanged()
static TString NextAvailableName()
virtual void SetYRMSDraw(Bool_t on)
void CopyOptionsFrom(TGo4Picture *source)
bool fbMarkEditorVisible
virtual bool GetVisibleRange(TPad *pad, int naxis, double &min, double &max)
static bool CanDrawItem(int cando)
TGo4Proxy * GetProxy() const
Definition: TGo4Slot.h:93
static TGo4MdiArea * Instance()
Definition: TGo4MdiArea.cpp:27
virtual Option_t * GetDrawOption()
Definition: TGo4Picture.h:149
virtual TGo4Slot * GetDrawObjectSlot(TPad *pad, const char *name)
QString GetPrintProg()
virtual void PadDoubleClickedSlot(TPad *pad)
const char * GetObjName(Int_t n)
void ConnectPad(TPad *pad)
Definition: QGo4Widget.cpp:233
Int_t GetDimension()
const char * NoStackDrawOption
bool IsAutoScale() const
virtual const char * GetPanelName()
virtual bool IsAutoZoomFlag()
Bool_t IsHisStats() const
virtual Bool_t IsXMeanDraw()
virtual bool ScanDrawOptions(TPad *pad, TGo4Slot *padslot, TGo4Picture *pic, bool onlyscan)
bool getDrawItemFlag()
virtual TObject * GetActiveObj(TPad *pad, int kind)
Bool_t GetTitleAttr(TPaveText *titl)
void storePanelSize(QWidget *w, const QString &kind="ViewPanel")
void SetLinkedName(TGo4Slot *slot, const char *itemname)
Definition: QGo4Widget.cpp:152
virtual void ResizeGedEditor()
Int_t ItemCanDo(const char *name)
void SetHistogram(TH1 *histo)
Definition: TGo4Marker.cxx:77
void SetValuesDirect(TCutG *newcut)
virtual void SaveCanvas()
TGo4Slot * getslot() const
Definition: TGo4Iter.cxx:167
virtual void ProcessMarkersClear(TPad *pad, bool withsubpads)
void CallPanelFunc(int id, TPad *pad=0)
Definition: QGo4Widget.cpp:238
Bool_t GetFullRange(Int_t naxis, Double_t &min, Double_t &max)
virtual void ProduceGraphFromMarkers()
void UndrawItem(const char *itemname)
Definition: QGo4Widget.cpp:329
virtual void GetConditionBtn_clicked()
double ScaledWidth()
const char * GetPar(const char *name) const
Definition: TGo4Slot.cxx:621
Int_t GetRebinY(Int_t index=UndefIndex)
void widgetService(QGo4Widget *editor, int serviceid, const char *str, void *par)
virtual TGo4Slot * GetPanelSlot()
TClass * ItemClass(const char *name)
TGo4Slot * GetTopSlot(bool force=false)
Definition: QGo4Widget.cpp:138
virtual void InfoConditionBtn_clicked()
virtual void AutoScaleToggled(bool)
int l
Definition: f_mbs_status.c:34
void SetEditable(bool on=true)
QAction * AddIdAction(QMenu *menu, QSignalMapper *map, const QString &text, int id, int enabled, int checked)
Definition: QGo4Widget.cpp:419
Bool_t IsXYRatioOne()
Graphic Qt Widget based Canvas.
Definition: QRootCanvas.h:68
virtual void ProducePicture()
virtual const char * GetDrawItemName(int itemcnt=0)
Bool_t GetRangeY(Double_t &min, Double_t &max)
virtual void SetAutoZoomFlag(bool on)
const char * GetLinkedName(const char *linkname)
Definition: QGo4Widget.cpp:157
bool fbLeaveFocusAfterCondEnd
virtual TGo4Slot * GetPadMainObjectSlot(TPad *pad)
virtual void CompleteInitialization()
bool getPadCrosshair()
virtual void ProcessPadDoubleClick()
virtual void RedrawPanel(TPad *pad, bool force)
virtual void MoveScale(int expandfactor, int xaction, int yaction, int zaction)
void SetTitleItem(Bool_t on=kTRUE)
TGo4BrowserProxy * Browser()
Definition: QGo4Widget.cpp:223
virtual void resizeEvent(QResizeEvent *e)
virtual void ClearCanvas()
virtual void Draw(Option_t *opt="")
virtual void DelSelectedMarker_clicked()
void EditItem(const QString &itemname)
Definition: QGo4Widget.cpp:351
virtual void Divide(int numX, int numY)
void SetXAxisTimeFormat(const char *format)
virtual Bool_t IsXRMSDraw()
virtual void PadClickedSlot(TPad *pad)
virtual void StartRootEditor()
TGo4ViewPanel * CreateViewPanel(int ndiv=0)
Definition: QGo4Widget.cpp:303
void ChangeDrawOption(Int_t kind, Int_t value)
QString getTH2DrawOpt()
virtual void SetYMaxDraw(Bool_t on)
TGo4Picture * Pic(Int_t posy, Int_t posx)
virtual void LogMarkerValues()
virtual void SetCursorMode(bool on)
virtual bool IsAcceptDrag(const char *itemname, TClass *cl, int kind)
virtual void CheckForSpecialObjects(TPad *pad, TGo4Slot *padslot)
TH1 * GetHistogram() const
Definition: TGo4Marker.h:113
virtual void TakeFullRangeFromGraph(TGraph *gr, TGo4Picture *padopt, bool isfirst)
virtual void UpdatePanelCaption()
TCutG * GetCut(Bool_t changeowner)
virtual void ShowEventStatus()
QRootWindow * fxRooteditor
virtual QString GetActiveObjName(TPad *pad, int kind)
virtual void SetConditionBtn_clicked()
virtual void UndrawItemOnPanel(const char *itemname)
virtual void DeleteDrawObject(TPad *pad, const char *name)
bool getPadSuperimpose()
bool getDrawTimeFlag()
TObject * GetAssignedObject()
Definition: TGo4Slot.cxx:373
virtual TPad * GetSlotPad(TGo4Slot *slot)
virtual TPad * GetSubPad(TPad *toppad, int num, bool onlytoplevel)
virtual TObject * GetPadMainObject(TPad *pad)
virtual void AboutToShowOptionsMenu()
bool IsAutoZoom() const
Bool_t GetStatsAttr(TPaveStats *stats)
virtual void ProducePadsList(TObjArray *arr, TPad *toppad)
virtual void SetApplyToAllFlag(bool on)
virtual void AllocatePadOptions(TPad *pad)
bool BrowserItemRemote(const char *itemname)
Definition: QGo4Widget.cpp:216
bool IsApplyToAll() const
void SetApplyToAll(bool on)
virtual bool IsConditionSelected(TPad *pad)
virtual bool IsRepaintTimerActive()
virtual const char * GetSpecialDrawOption(TGo4Slot *slot)
void ShowItemInfo(const QString &itemname)
Definition: QGo4Widget.cpp:298
virtual void SetSelectedRange(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
QMenu * fOptionsMenu
virtual void DisplayPadStatus(TPad *pad)
void SetFullRangeDim(Int_t ndim)
Bool_t HasTitleAttr()
virtual void CheckObjectsAssigments(TPad *pad, TGo4Slot *padslot)
virtual void RedrawLegend(TPad *pad, TGo4Picture *padopt, TGo4Slot *legslot)
TGo4Slot * FindChild(const char *name)
Definition: TGo4Slot.cxx:262
void SetDivision(Int_t ndivy, Int_t ndivx)
virtual TGo4Slot * AddNewSlot(const char *name, TGo4Slot *parent)
virtual void Draw(Option_t *opt="")
Definition: TGo4Marker.cxx:104
virtual void SaveMarkers()
virtual Bool_t IsXMaxDraw()
virtual void ProcessCanvasAdopt(TPad *tgtpad, TPad *srcpad, const char *srcitemname)
virtual void SetSelectedMarker(TPad *pad, const QString &selname, int selindex)
void SetStatsAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t optstat=1111, const char *statformat="6.4g", Int_t optfit=1111, const char *fitformat="5.4g")
virtual bool ShiftSelectedObjectToEnd(TPad *pad)
void SetXAxisTimeDisplay(Bool_t on)
virtual QRootCanvas * GetQCanvas()
virtual void checkRepaintSlot()
void SetRebinY(Int_t ngroupy, Int_t index=UndefIndex)
void DeletePainter()
Definition: TGo4Marker.cxx:280
virtual void RedrawHistogram(TPad *pad, TGo4Picture *padopt, TH1 *his, bool scancontent, bool first_draw)
TGo4Slot * GetParent() const
Definition: TGo4Slot.h:58
virtual void PadRangeAxisChanged(TPad *pad)
bool fbEditorFrameVisible
TPad * fxResizeTimerPad
virtual void MarkPadModified(TPad *pad)
void SetResizeOnPaint(bool on=true)
Definition: QRootWindow.h:52
virtual void DropOnPad(TPad *pad, const char *itemname, TClass *cl, int kind)
virtual void UpdatePadStatus(TPad *pad, bool removeitems)
QAction * AddChkAction(QMenu *menu, const QString &text, bool checked, QObject *recv, const char *member)
Definition: QGo4Widget.cpp:407
QStatusBar * CanvasStatus
virtual void SetPolygonMode(bool on)
bool fbCanvasEventstatus
virtual void CleanupGedEditor()
Bool_t ShiftSlotAfter(TGo4Slot *slot, TGo4Slot *after)
Definition: TGo4Slot.cxx:541
virtual void MoveSingleScale(int expandfactor, int action, int naxis, TGo4Picture *opt, TObject *padhist)
virtual void SelectMenuItemActivated(int)
void SetLogScale(Int_t nscale=0, Int_t zn=1)
virtual TGo4Slot * GetPadSlot(TPad *pad)
virtual void SelectedMarkerCmb_activated(int indx)
virtual void ClearPad(TPad *pad, bool removeitems, bool removesubpads)
void ServiceCall(const char *name, void *par=0)
Definition: QGo4Widget.cpp:402
Bool_t GetFrameAttr(TPad *pad)
virtual void SetYMeanDraw(Bool_t on)
virtual TPad * FindPadWithItem(const char *itemname)
virtual void SetSelectedRangeToHisto(TPad *pad, TH1 *h1, THStack *hs, TGo4Picture *padopt, bool ishisto)
virtual int GetNumMarkers(TPad *pad, int kind)
bool IsSuperimpose() const
virtual void PadDeleted(TPad *pad)
TGo4QSettings * go4sett
virtual void linkedObjectUpdated(const char *linkname, TObject *obj)
void RemovePar(const char *name)
Definition: TGo4Slot.cxx:628
static bool IsRootCanvasMenuEnabled()
virtual void SetRegionMode(bool on)
virtual void SetSpecialDrawOption(TGo4Slot *slot, const char *drawopt)
Bool_t GetRange(Int_t naxis, Double_t &min, Double_t &max)
virtual ~TGo4ViewPanel()
virtual void ClearAllMarkers()
virtual void ClearActivePad()
virtual void GetSelectedRange(int &ndim, bool &autoscale, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax)
virtual void RedrawGraph(TPad *pad, TGo4Picture *padopt, TGraph *gr, bool scancontent, bool first_draw)
Bool_t IsXAxisTimeDisplay()
virtual void OptionsMenuItemActivated(int)
bool IsPadModified() const
bool getPadEventStatus()
virtual void Resize(Option_t *option="")
virtual void SetSelectedObjectIndex(TGo4Slot *slot, int indx)
virtual TGo4Picture * GetPadOptions(TPad *pad)
Bool_t DefineRelatedObject(const char *itemname, const char *objectname, TString &objectitem, Int_t mask=3)
virtual Double_t GetXLow()
Definition: TGo4WinCond.h:60
TGo4Slot * BrowserSlot(const char *item)
Int_t GetDivY()
Definition: TGo4Picture.h:58
TH1 * GetWorkHistogram()
QString getTH1DrawOpt()
virtual void SetValues(Double_t low1, Double_t up1)
Int_t GetHisContour() const
TGo4Picture * FindPic(Int_t posy, Int_t posx)
virtual int GetSelectedMarkerIndex(TPad *pad)
void SetHisStats(Bool_t on)
QSignalMapper * fSelectMap
virtual void AddMarkerObj(TPad *pad, int kind, TObject *obj)
bool getFetchDataWhenDraw()
virtual int GetDrawKind(TGo4Slot *slot)
virtual void panelSlot(TGo4ViewPanel *panel, TPad *pad, int signalid)
virtual TObject * ProduceSuperimposeObject(TGo4Slot *padslot, TGo4Picture *padopt, TGo4Slot *sislot, TGo4Slot *legslot, TObjArray *objs, TObjArray *objslots, bool showitems)
void SetSelectedRange(double rxmin, double rxmax, double rymin, double rymax)
Definition: TGo4ASImage.cpp:73
virtual void SetSlotPad(TGo4Slot *padslot, TPad *pad)
QMenuBar * fMenuBar
virtual void SetSelectedMarkerByMouseClick(TPad *pad, const char *name)
QByteArray fbaPanelName
virtual void ProcessPadModifiedSignal()
virtual void CollectMainDrawObjects(TGo4Slot *slot, TObjArray *objs, TObjArray *objslots, int modifier)
void SetFullRange(Int_t naxis, Double_t min, Double_t max)
bool getDrawDateFlag()
QAction * SetIdAction(QSignalMapper *map, int id, int enabled, int checked)
Definition: QGo4Widget.cpp:435
virtual void ScanObjectsDrawOptions(bool onlyscan, TGo4Slot *padslot, TObjArray *objs, TObjArray *objslots)
virtual void ProcessPadStatusUpdate(TPad *pad, TGo4Slot *parent, bool removeitems)
void SetFrameAttr(Double_t left, Double_t top, Double_t right, Double_t bottom)
TGo4ViewPanel(QWidget *parent=0, const char *name=0)
virtual TH1 * GetPadHistogram(TPad *pad)
virtual void SetPadSuperImpose(TPad *pad, bool on)
QString fPanelName
virtual bool TakeSelectedAxisRange(int naxis, TGo4Picture *padopt, double selmin, double selmax, bool force)
virtual void ClearPadItems(TGo4Slot *padslot, TGo4Slot *remain)
QCheckBox * fAutoScaleCheck
Bool_t IsHisTitle() const
virtual void SetLateXMode(bool on)
virtual void RefreshButtons()
QString fFreezedTitle
bool IsLegendDraw() const
void GetDrawAttributes(TObject *obj, Int_t index=UndefIndex)
void SetSuperimpose(bool on)
Int_t NumChilds() const
Definition: TGo4Slot.h:76
void SetWorkHistogram(TH1 *histo)
Bool_t IsTitleDate() const
void SetDrawAttributes(TObject *obj, Int_t index=UndefIndex)
QString getTH3DrawOpt()
static Int_t GetInstances()
Definition: TGo4Marker.h:129
void SetPadModified(bool on=true)
virtual bool IsPanelPad(TPad *pad)
virtual TGo4Slot * GetSelectedSlot(TPad *pad, int *selkind, TObject **selobj)
virtual void BlockPanelRedraw(bool on)
void ClearFullRange(Int_t naxis=-1)
void CallServiceFunc(int id, const char *str=0, void *par=0)
Definition: QGo4Widget.cpp:397
virtual void CanvasDropEventSlot(QDropEvent *event, TPad *pad)
TPad * fxRepaintTimerPad
TPad * fxDoubleClickTimerPad
virtual void SetActiveObj(TPad *pad, int kind, TGo4Slot *activeslot)
TGo4Condition * At(Int_t i)
virtual void CollectSpecialObjects(TPad *pad, TObjArray *objs, int selectkind)
virtual void LoadMarkers()
virtual void RedrawSpecialObjects(TPad *pad, TGo4Slot *padslot)
virtual void SetPanelName(const char *newname)
virtual bool IsApplyToAllFlag()
QString SaveObjectInMemory(const char *foldername, TObject *obj)
Definition: QGo4Widget.cpp:361
void SetAutoScale(bool on)
virtual void ChangeDrawOption(int kind, int value, const char *drawopt)
Int_t GetRebinX(Int_t index=UndefIndex)
Int_t GetFullRangeDim() const
virtual int GetNumberOfPads(TPad *toppad)
void SetPar(const char *name, const char *value)
Definition: TGo4Slot.cxx:609
virtual TPad * GetActivePad()
void SetSelectedPad(TPad *pad)
Definition: TGo4MdiArea.cpp:57
void SetContentModified(bool on=true)
virtual void SetMarkerPanel()
void AddSpecialObject(TObject *obj, Option_t *drawopt=0)
TGo4Slot * GetChild(Int_t n) const
Definition: TGo4Slot.h:77
Bool_t IsTitleItem() const
virtual void SuperImposeToggled(bool)
Bool_t IsTitleTime() const
virtual void DefaultPadMargin(TPad *pad)
void SetTitleDate(Bool_t on=kTRUE)
virtual void ProcessPictureRedraw(const char *picitemname, TPad *pad, TGo4Picture *pic)
virtual void SetDrawingMode(bool on)
void SetRebinX(Int_t ngroupx, Int_t index=UndefIndex)
virtual bool DeleteDrawObjects(TPad *pad, int kindtodelete)
virtual TObject * GetSelectedObject(TPad *pad, const char **drawopt)
virtual void CanvasStatusEventSlot(const char *message)
virtual void SetDrawOption(Option_t *option="")
Definition: TGo4Picture.h:142
virtual void checkResizeSlot()
virtual TCanvas * GetCanvas()
static void Error(const char *text,...)
Definition: TGo4Log.cxx:309
virtual bool IsFreezeTitle()
virtual TGo4Slot * AddDrawObject(TPad *pad, int kind, const char *itemname, TObject *obj, bool owner, const char *drawopt)
virtual void ProcessPadClear(TPad *pad, bool removeitems, bool removesubpads)
void ClearRange(Int_t naxis=-1)
Int_t GetNumber() const
virtual void SetFreezedTitle(const QString &title)
virtual bool CompleteMarkerEdit(TPad *pad)
void SetXAxisAttTime(Bool_t timedisplay, const char *format, Int_t index=UndefIndex)
void SetHistogramContent(TH2 *histo)
Definition: TGo4ASImage.cpp:41
void SetTitleAttr(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t textsize=0.)
virtual int GetMouseMode()
virtual void MenuCommandExecutedSlot(TObject *obj, const char *cmdname)
Bool_t next(Bool_t goesinto=kTRUE)
Definition: TGo4Iter.cxx:45
virtual void ResetPadFillColors(TPad *pad, int col, TPad *backup=0)
virtual int GetSelectedObjectIndex(TGo4Slot *slot)
virtual void CanvasUpdatedSlot()
virtual void ChangeDrawOptionForPad(TGo4Slot *padslot, int kind, int value, const char *drawopt)
virtual void SetAutoScale(bool on, TPad *selpad)
TList * GetSpecialObjects() const
Definition: TGo4Picture.h:249
virtual void Update()