GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4FitPanel.cpp
Go to the documentation of this file.
1 // $Id$
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 fuer 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 #include "TGo4FitPanel.h"
15 
16 #include <iostream>
17 
18 #include <QtCore/QSignalMapper>
19 
20 #include <QMenu>
21 #include <QMenuBar>
22 #include <QDropEvent>
23 #include <QMessageBox>
24 #include <QApplication>
25 #include <QFileDialog>
26 #include <QInputDialog>
27 
28 #include "TStyle.h"
29 #include "TObjArray.h"
30 #include "TString.h"
31 #include "TClass.h"
32 #include "TMath.h"
33 #include "Buttons.h"
34 #include "TH1.h"
35 #include "TCutG.h"
36 #include "TCanvas.h"
37 #include "TPaveStats.h"
38 #include "TLegend.h"
39 #include "TFile.h"
40 
41 #include "TGo4LockGuard.h"
42 #include "TGo4Slot.h"
43 #include "TGo4Fitter.h"
44 #include "TGo4FitterAction.h"
45 #include "TGo4FitterConfig.h"
46 #include "TGo4FitterOutput.h"
47 #include "TGo4FitMinuit.h"
48 #include "TGo4FitAmplEstimation.h"
49 #include "TGo4FitPeakFinder.h"
50 #include "TGo4FitParsList.h"
51 #include "TGo4FitParameter.h"
52 #include "TGo4FitModelPolynom.h"
53 #include "TGo4FitModelGauss1.h"
54 #include "TGo4FitModelGauss2.h"
55 #include "TGo4FitModelGaussN.h"
56 #include "TGo4FitModelFormula.h"
57 #include "TGo4FitModelFunction.h"
58 #include "TGo4FitModelFromData.h"
59 #include "TGo4FitDataHistogram.h"
60 #include "TGo4FitDataGraph.h"
61 #include "TGo4FitDataProfile.h"
62 #include "TGo4FitDataRidge.h"
63 #include "TGo4FitDependency.h"
64 #include "TGo4FitMinuitResult.h"
65 #include "TGo4FitLinearTrans.h"
66 #include "TGo4FitMatrixTrans.h"
67 #include "TGo4Log.h"
68 #include "TGo4ViewPanel.h"
69 #include "TGo4MdiArea.h"
70 #include "TGo4QSettings.h"
71 #include "QFitItem.h"
72 #include "QFitRangeWidget.h"
73 #include "QFitRangeCutWidget.h"
74 #include "QFitParWidget.h"
75 #include "QFitDependencyWidget.h"
76 #include "QFitParCfgWidget.h"
77 #include "QFitDataWidget.h"
78 #include "QFitModelPolynomWidget.h"
79 #include "QFitModelGauss1Widget.h"
80 #include "QFitModelGauss2Widget.h"
81 #include "QFitModelGaussNWidget.h"
82 #include "QFitModelFormulaWidget.h"
84 #include "QFitAmplEstimWidget.h"
85 #include "QFitPeakFinderWidget.h"
86 #include "QFitOutputActionWidget.h"
87 #include "QFitMinuitWidget.h"
88 #include "QFitMinuitResWidget.h"
89 #include "QFitSlotWidget.h"
90 #include "QFitterWidget.h"
91 #include "QFitTableWidget.h"
92 #include "QFitPrintWidget.h"
93 #include "QFitLinearTransWidget.h"
94 #include "QFitMatrixTransWidget.h"
95 #include "TGo4FitGuiTypes.h"
96 #include "TGo4FitGuiArrow.h"
97 
98 TGo4FitPanel::TGo4FitPanel(QWidget *parent, const char *name) : QGo4Widget(parent, name)
99 {
100  setupUi(this);
101 
102  QObject::connect(FitList, &QTreeWidget::customContextMenuRequested, this,
104  QObject::connect(FitList, &QTreeWidget::currentItemChanged, this, &TGo4FitPanel::FitList_currentItemChanged);
105  QObject::connect(Wiz_AddDataBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_AddDataBtn_clicked);
106  QObject::connect(Wiz_DelDataBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_DelDataBtn_clicked);
107  QObject::connect(Wiz_AddModelBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_AddModelBtn_clicked);
108  QObject::connect(Wiz_DelModelBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_DelModelBtn_clicked);
109  QObject::connect(Wiz_CloneModelBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_CloneModelBtn_clicked);
110  QObject::connect(Wiz_ShowAllMod, &QCheckBox::toggled, this, &TGo4FitPanel::Wiz_ShowAllMod_toggled);
111  QObject::connect(Wiz_FitFuncCmb, QOverload<int>::of(&QComboBox::activated), this,
113  QObject::connect(Wiz_FitNameEdt, &QGo4LineEdit::textChanged, this, &TGo4FitPanel::Wiz_FitNameEdt_textChanged);
114  QObject::connect(Wiz_ParTable, &QTableWidget::cellChanged, this, &TGo4FitPanel::Wiz_ParTable_valueChanged);
115  QObject::connect(Wiz_ModelList, &QListWidget::itemDoubleClicked, this, &TGo4FitPanel::Wiz_ModelList_doubleClicked);
116  QObject::connect(Wiz_ModelList, &QListWidget::itemChanged, this, &TGo4FitPanel::Wiz_ModelList_itemChanged);
117  QObject::connect(Wiz_RebuildDataBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_RebuildDataBtn_clicked);
118  QObject::connect(Wiz_DataBufChk, &QCheckBox::toggled, this, &TGo4FitPanel::Wiz_DataBufChk_toggled);
119  QObject::connect(Wiz_UseAmplEstimChk, &QCheckBox::toggled, this, &TGo4FitPanel::Wiz_UseAmplEstimChk_toggled);
120  QObject::connect(Wiz_MigradIterSpin, QOverload<int>::of(&QSpinBox::valueChanged), this,
122  QObject::connect(Wiz_DataSlotsTable, &QTableWidget::customContextMenuRequested, this,
124  QObject::connect(Wiz_DataUseRangeBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_DataUseRangeBtn_clicked);
125  QObject::connect(Wiz_DataClearRangesBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_DataClearRangesBtn_clicked);
126  QObject::connect(Wiz_DrawDataBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_DrawDataBtn_clicked);
127  QObject::connect(MainAttachBtn, &QPushButton::clicked, this, &TGo4FitPanel::MainAttachBtn_clicked);
128  QObject::connect(MainFitBtn, &QPushButton::clicked, this, &TGo4FitPanel::MainFitBtn_clicked);
129  QObject::connect(MainDrawBtn, &QPushButton::clicked, this, &TGo4FitPanel::MainDrawBtn_clicked);
130  QObject::connect(MainFindBtn, &QPushButton::clicked, this, &TGo4FitPanel::MainFindBtn_clicked);
131  QObject::connect(Wiz_DataList, &QListWidget::itemDoubleClicked, this, &TGo4FitPanel::Wiz_DataList_doubleClicked);
132  QObject::connect(Wiz_DataList, &QListWidget::itemClicked, this, &TGo4FitPanel::Wiz_DataListSelect);
133  QObject::connect(Wiz_DataList, &QListWidget::itemChanged, this, &TGo4FitPanel::Wiz_DataListSelect);
134  QObject::connect(Wiz_DataList, &QListWidget::itemPressed, this, &TGo4FitPanel::Wiz_DataListSelect);
135  QObject::connect(Wiz_ModelList, &QListWidget::currentItemChanged, this, &TGo4FitPanel::Wiz_ModelListSelect);
136  QObject::connect(MainParsBtn, &QPushButton::clicked, this, &TGo4FitPanel::MainParsBtn_clicked);
137  QObject::connect(LineParsChk, &QCheckBox::toggled, this, &TGo4FitPanel::LineParsChk_toggled);
138  QObject::connect(ParsTable, &QTableWidget::cellChanged, this, &TGo4FitPanel::ParsTable_valueChanged);
139  QObject::connect(Wiz_ModelBufChk, &QCheckBox::toggled, this, &TGo4FitPanel::Wiz_ModelBufChk_toggled);
140  QObject::connect(Wiz_PFSetupBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_PFSetupBtn_clicked);
141  QObject::connect(Wiz_PFUsePolynChk, &QCheckBox::toggled, this, &TGo4FitPanel::Wiz_PFUsePolynChk_toggled);
142  QObject::connect(Wiz_PFPolynSpin, QOverload<int>::of(&QSpinBox::valueChanged), this,
144  QObject::connect(PF_MinWidthEdt, &QGo4LineEdit::textChanged, this, &TGo4FitPanel::PF_MinWidthEdt_textChanged);
145  QObject::connect(PF_MaxWidthEdt, &QGo4LineEdit::textChanged, this, &TGo4FitPanel::PF_MaxWidthEdt_textChanged);
146  QObject::connect(PF_AmplSlider, &QSlider::valueChanged, this, &TGo4FitPanel::PF_AmplSlider_valueChanged);
147  QObject::connect(PF_AmplSlider, &QSlider::sliderReleased, this, &TGo4FitPanel::PF_AmplSlider_sliderReleased);
148  QObject::connect(PF_WidthEdit, &QGo4LineEdit::textChanged, this, &TGo4FitPanel::PF_WidthEdit_textChanged);
149  QObject::connect(PF_RelNoiseSlider, &QSlider::valueChanged, this, &TGo4FitPanel::PF_RelNoiseSlider_valueChanged);
150  QObject::connect(PF_RelNoiseSlider, &QSlider::sliderReleased, this, &TGo4FitPanel::PF_RelNoiseSlider_sliderReleased);
151  QObject::connect(PF_MinNoiseEdit, &QGo4LineEdit::textChanged, this, &TGo4FitPanel::PF_MinNoiseEdit_textChanged);
152  QObject::connect(PF_SumUpSpin, QOverload<int>::of(&QSpinBox::valueChanged), this,
154  QObject::connect(Smp_PolynomBtn, &QPushButton::clicked, this, &TGo4FitPanel::Smp_PolynomBtn_clicked);
155  QObject::connect(Smp_GaussianBtn, &QPushButton::clicked, this, &TGo4FitPanel::Smp_GaussianBtn_clicked);
156  QObject::connect(Smp_LorenzBtn, &QPushButton::clicked, this, &TGo4FitPanel::Smp_LorenzBtn_clicked);
157  QObject::connect(Smp_ExponentBtn, &QPushButton::clicked, this, &TGo4FitPanel::Smp_ExponentBtn_clicked);
158  QObject::connect(Smp_ClearBtn, &QPushButton::clicked, this, &TGo4FitPanel::Smp_ClearBtn_clicked);
159  QObject::connect(Wiz_MinSetupBtn, &QPushButton::clicked, this, &TGo4FitPanel::Wiz_MinSetupBtn_clicked);
160  QObject::connect(FindersTab, &QTabWidget::currentChanged, this, &TGo4FitPanel::FindersTab_currentChanged);
161  QObject::connect(Wiz_BackgroundChk, &QCheckBox::toggled, this, &TGo4FitPanel::Wiz_BackgroundChk_toggled);
162  QObject::connect(PF_MinWidthEdt, &QGo4LineEdit::returnPressed, this, &TGo4FitPanel::PF_MinWidthEdt_returnPressed);
163  QObject::connect(PF_MaxWidthEdt, &QGo4LineEdit::returnPressed, this, &TGo4FitPanel::PF_MaxWidthEdt_returnPressed);
164  QObject::connect(PF_WidthEdit, &QGo4LineEdit::returnPressed, this, &TGo4FitPanel::PF_WidthEdit_returnPressed);
165  QObject::connect(PF_MinNoiseEdit, &QGo4LineEdit::returnPressed, this, &TGo4FitPanel::PF_MinNoiseEdit_returnPressed);
166 
167  fbFreezeMode = false;
169  fbParsWidgetShown = false;
170 
171  fbNeedConfirmation = go4sett->getBool("/FitPanel/NeedConfirmation", false);
172  fbShowPrimitives = go4sett->getBool("/FitPanel/ShowPrimitives", true);
173  fbSaveWithReferences = go4sett->getBool("/FitPanel/SaveWithReferences", false);
174  fbUseCurrentRange = go4sett->getBool("/FitPanel/UseCurrentRange", true);
175  fbDrawModels = go4sett->getBool("/FitPanel/DrawModels", true);
176  fbDrawComponents = go4sett->getBool("/FitPanel/DrawComponents", false);
177  fbUseSamePanelForDraw = go4sett->getBool("/FitPanel/UseSamePanelForDraw", true);
178  fbDrawBackground = go4sett->getBool("/FitPanel/DrawBackground", false);
179  fbDrawInfoOnPad = go4sett->getBool("/FitPanel/DrawInfoOnPad", false);
180  fbRecalculateGaussWidth = go4sett->getBool("/FitPanel/RecalculateGaussWidth", true);
181  fiIntegralMode = go4sett->getInt("/FitPanel/IntegralMode", 0);
182  fiBuffersUsage = go4sett->getInt("/FitPanel/BuffersUsage", 1);
183 
184  FitList->setContextMenuPolicy(Qt::CustomContextMenu);
185 
186  // fit options part
187  fxWizDataName = "";
188  fxWizModelName = "";
189  fbWizShowAllModels = true;
190  fiWizPageIndex = 0;
191  fbUseAmplEstim = false;
192  fiNumMigradIter = 0;
193 
194  fxCurrentItem = nullptr;
195  fxCurrentItemWidget = nullptr;
196 
197  fxActivePanel = nullptr;
198  fxActivePad = nullptr;
199 
200  fxDrawNewPanel = nullptr;
201  fbDrawPanelCreation = false;
202 
203  QTableWidgetItem *item = new QTableWidgetItem;
204  item->setFlags(item->flags() & ~Qt::ItemIsEditable);
205  Wiz_DataSlotsTable->setItemPrototype(item);
206  Wiz_DataSlotsTable->setContextMenuPolicy(Qt::CustomContextMenu);
207 
209 
210  MenuBar = new QMenuBar(MenuFrame);
211  MenuBar->setMinimumWidth(100);
212  // MenuBar->setFrameShape(QMenuBar::NoFrame);
213  MenuBar->setNativeMenuBar(kFALSE); // disable putting this to screen menu. for MAC style WMs
214 
215  FitterMap = new QSignalMapper(this);
216  FitterMenu = MenuBar->addMenu("&Fitter");
217  QObject::connect(FitterMenu, &QMenu::aboutToShow, this, &TGo4FitPanel::AboutToShowFitterMenu);
218 
219  ViewMap = new QSignalMapper(this);
220  ViewMenu = MenuBar->addMenu("&Tools");
221  QObject::connect(ViewMenu, &QMenu::aboutToShow, this, &TGo4FitPanel::AboutToShowViewMenu);
222 
223  SettMap = new QSignalMapper(this);
224  SettMenu = MenuBar->addMenu("&Settings");
225  QObject::connect(SettMenu, &QMenu::aboutToShow, this, &TGo4FitPanel::AboutToShowSettMenu);
226 
227 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
228  auto signal = QOverload<int>::of(&QSignalMapper::mapped);
229 #else
230  auto signal = &QSignalMapper::mappedInt;
231 #endif
232 
233  QObject::connect(FitterMap, signal, this, &TGo4FitPanel::FitterMenuItemSelected);
234  QObject::connect(ViewMap, signal, this, &TGo4FitPanel::ChangeViewType);
235  QObject::connect(SettMap, signal, this, &TGo4FitPanel::ChangeSettings);
236 
237  AddIdAction(SettMenu, SettMap, "&Confirmation", 1);
238  AddIdAction(SettMenu, SettMap, "&Show primitives", 2);
239  AddIdAction(SettMenu, SettMap, "&Freeze mode", 3);
240  AddIdAction(SettMenu, SettMap, "&Save with objects", 4);
241 
242  SettMenu->addSeparator();
243 
244  AddIdAction(SettMenu, SettMap, "&Use current range", 10);
245  AddIdAction(SettMenu, SettMap, "&Draw model", 11);
246  AddIdAction(SettMenu, SettMap, "Draw &background", 14);
247  AddIdAction(SettMenu, SettMap, "Dra&w components", 12);
248  AddIdAction(SettMenu, SettMap, "Draw on same &pad", 13);
249  AddIdAction(SettMenu, SettMap, "Draw &info on pad", 15);
250 
251  SettMenu->addSeparator();
252 
253  AddIdAction(SettMenu, SettMap, "&No &integral", 17);
254  AddIdAction(SettMenu, SettMap, "&Counts", 18);
255  AddIdAction(SettMenu, SettMap, "&Integral", 19);
256  AddIdAction(SettMenu, SettMap, "&Gauss integral", 20);
257 
258  AddIdAction(SettMenu, SettMap, "Recalculate gauss &widths", 16);
259 
260  SettMenu->addSeparator();
261 
262  AddIdAction(SettMenu, SettMap, "&Do not use buffers", 21);
263  AddIdAction(SettMenu, SettMap, "&Only for data", 22);
264  AddIdAction(SettMenu, SettMap, "&For data and models", 23);
265  AddIdAction(SettMenu, SettMap, "&Individual settings", 24);
266 
267  ItemMenu = nullptr;
268  CurrFitItem = nullptr;
269 
270  Wiz_DataSlotsTable->horizontalHeader()->setStretchLastSection(true);
271  Wiz_ParTable->horizontalHeader()->setStretchLastSection(true);
272 
273  fxWizPars = new TObjArray();
274  fxWizSlots = new TObjArray();
275  fxParsTableList = new TObjArray();
276 
277  fiPaintMode = 0;
278 
279  gridLayout->setContentsMargins(3, 3, 3, 3);
280  gridLayout->setSpacing(1);
282 
283  MenuBar->setMinimumHeight(MenuFrame->height());
284 }
285 
287 {
288  // discards messages from deleted items
289  fbFillingWidget = true;
290 
291  fxCurrentItem = nullptr;
292  FitList->clear();
293 
294  delete fxParsTableList;
295  delete fxWizSlots;
296  delete fxWizPars;
297 
300  CloseDrawPanel();
301 
303 }
304 
305 // *********************** overloaded methods of QGo4Widget **************************
306 
307 bool TGo4FitPanel::IsAcceptDrag(const char *itemname, TClass *cl, int kind)
308 {
309  if (!cl)
310  return false;
311 
312  return (cl->InheritsFrom(TGo4Fitter::Class())) || (cl->InheritsFrom(TH1::Class())) ||
313  (cl->InheritsFrom(TGraph::Class()));
314 }
315 
316 void TGo4FitPanel::DropOnPanel(QDropEvent *event, const char *itemname, TClass *cl, int kind)
317 {
318  if (!cl)
319  return;
320 
321  if (cl->InheritsFrom(TGo4Fitter::Class())) {
322  WorkWithFitter(itemname, nullptr, nullptr);
323  return;
324  }
325 
326  if (!event)
327  return;
328 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
329  QPoint pos = event->pos();
330 #else
331  QPoint pos = event->position().toPoint();
332 #endif
333 
334  QWidget *w = childAt(pos);
335 
336  if (w == Wiz_DataSlotsTable) {
337  QPoint pnt = Wiz_DataSlotsTable->mapFrom(this, pos);
338  QTableWidgetItem *item = Wiz_DataSlotsTable->itemAt(pnt);
339 
340  int nrow = item ? item->row() : -1;
341 
342  if ((nrow < 0) || (nrow > fxWizSlots->GetLast()))
343  return;
344 
345  TGo4FitSlot *slot = dynamic_cast<TGo4FitSlot *>(fxWizSlots->At(nrow));
346 
347  if (!slot)
348  return;
349  if (!slot->IsSuitableClass(cl))
350  return;
351 
352  CreateFitSlotLink(slot, itemname);
353 
355  } else if (w == (QWidget *)FitList->viewport()) {
356  QPoint pnt = FitList->viewport()->mapFrom(this, pos);
357  QFitItem *item = dynamic_cast<QFitItem *>(FitList->itemAt(pnt));
358  if (!item || (item->ObjectType() != FitGui::ot_slot))
359  return;
360 
361  TGo4FitSlot *slot = dynamic_cast<TGo4FitSlot *>(item->Object());
362  if (!slot)
363  return;
364  if (!slot->IsSuitableClass(cl))
365  return;
366 
367  CreateFitSlotLink(slot, itemname);
368 
370  }
371 }
372 
373 void TGo4FitPanel::linkedObjectUpdated(const char *linkname, TObject *obj)
374 {
376 
378 }
379 
381 {
382  RemoveLink("Fitter");
383 }
384 
385 void TGo4FitPanel::linkedObjectRemoved(const char *linkname)
386 {
387  if (strcmp(linkname, "Fitter") == 0) {
388  RemoveAllLinks();
389  fxActivePanel = nullptr;
390  fxActivePad = nullptr;
391  } else {
393  }
394 
396 }
397 
398 void TGo4FitPanel::linkedRemoved(TGo4Slot *slot, TObject *obj) {}
399 
400 void TGo4FitPanel::WorkWithFitter(const char *itemname, TGo4ViewPanel *panel, TPad *pad)
401 {
404  CloseDrawPanel();
406 
407  fxActivePanel = panel;
408  fxActivePad = pad;
409 
411  AddLink(itemname, "Fitter");
412 
413  // just take object
414  GetLinked("Fitter", 2);
415 
417 
419 }
420 
422 {
425  CloseDrawPanel();
427 
428  fxActivePanel = nullptr;
429  fxActivePad = nullptr;
430 
432  AddLink(slot, "Fitter");
433 
434  GetLinked("Fitter");
435 
437 
439 }
440 
441 // **************************** interface to MainGUI ************************
442 
443 void TGo4FitPanel::panelSlot(TGo4ViewPanel *panel, TPad *pad, int signalid)
444 {
445  switch (signalid) {
446  case panel_Activated: {
447  if (!panel || !pad)
448  return;
449 
451  return;
452  if ((panel == fxDrawNewPanel) || fbDrawPanelCreation)
453  return;
454 
455  bool update = fbFreezeMode;
456 
457  if (!update && GetFitter() && (GetFitter()->GetNumData() > 1))
458  update = true;
459 
460  if (WorkingWithPanel() && (panel == ActivePanel()) && (pad == ActivePad()))
461  update = true;
462 
463  if (update) {
469  return;
470  }
471 
474  CloseDrawPanel();
476 
478 
479  fxActivePanel = panel;
480  fxActivePad = pad;
481 
482  if (panel && pad) {
483  TGo4Slot *slot = panel->GetDrawObjectSlot(pad, "::Fitter");
484  AddLink(slot, "Fitter");
485  }
486 
488 
490 
491  break;
492  }
493 
494  case panel_Modified: {
495  if (!WorkingWithPanel() || (panel != ActivePanel()))
496  return;
498  CloseDrawPanel();
504  break;
505  }
506 
507  case panel_Deleted: {
508  if (!panel)
509  return;
510  if (panel == fxDrawNewPanel) {
511  fxDrawNewPanel = nullptr;
512  return;
513  }
514  if (WorkingWithPanel() && (panel == ActivePanel())) {
517  fxActivePanel = nullptr;
518  fxActivePad = nullptr;
519  }
520 
522  break;
523  }
524  }
525 }
526 
527 // ************************ functionality of fitslots classes *****************************
528 
530 {
531  return fxActivePanel && fxActivePad;
532 }
533 
535 {
536  return WorkingWithPanel() ? !ActivePanel()->IsPadHasSubPads(ActivePad()) : false;
537 }
538 
540 {
541  return fxActivePanel;
542 }
543 
545 {
546  return fxActivePad;
547 }
548 
550 {
551  return GetLinkedCast<TGo4Fitter>("Fitter");
552 }
553 
555 {
558  if (!WorkingWithPanel()) {
559  if (fitter) {
560  QString itemname = SaveObjectInMemory("FitPanel", fitter);
561  AddLink(itemname.toLatin1().constData(), "Fitter");
562  }
563  } else {
564  ActivePanel()->DeleteDrawObject(ActivePad(), "::Fitter");
565  TGo4Slot *slot =
566  ActivePanel()->AddDrawObject(ActivePad(), TGo4ViewPanel::kind_Fitter, "::Fitter", fitter, true, nullptr);
567  if (slot)
568  AddLink(slot, "Fitter");
569  }
571  fbParsWidgetShown = false;
572 }
573 
575 {
576  TGo4Fitter *fitter = GetFitter();
577  if (!fitter)
578  return nullptr;
579 
581 
582  return dynamic_cast<TGo4Fitter *>(fitter->Clone());
583 }
584 
586 {
587  if (WorkingWithPanel()) {
589  fxActivePanel = nullptr;
590  fxActivePad = nullptr;
591  }
592 
593  TGo4Fitter *fitter = new TGo4Fitter("Fitter", "Fitter object");
594  SetFitter(fitter);
595 
597 }
598 
600 {
601  TGo4ViewPanel *panel = LastActivePanel();
602  if (!panel || (panel == fxDrawNewPanel))
603  return;
604  TPad *pad = panel->GetActivePad();
605 
607 
609 
610  fxActivePanel = panel;
611  fxActivePad = pad;
612 
613  if (panel && pad) {
614  TGo4Slot *fitterslot = panel->GetDrawObjectSlot(pad, "::Fitter");
615 
616  if (!overwrite && fitterslot)
617  AddLink(fitterslot, "Fitter");
618  }
619 
620  if (overwrite || !GetFitter())
621  SetFitter(CreateFitterFor(panel, pad, "Fitter"));
622 
625 }
626 
627 bool TGo4FitPanel::checkConfirm(const QString &title, const QString &msg)
628 {
629  if (!fbNeedConfirmation)
630  return false;
631  return QMessageBox::information(nullptr, title, msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ==
632  QMessageBox::No;
633 }
634 
636 {
637  if (checkConfirm("Delete fitter", "Are you sure?"))
638  return;
639 
642  CloseDrawPanel();
643 
645 
646  SetFitter(nullptr);
647 
648  if (WorkingWithPanel()) {
649  fxActivePanel = nullptr;
650  fxActivePad = nullptr;
651  }
652 
654 }
655 
657 {
659  CloseDrawPanel();
661 
662  fxActivePanel = nullptr;
663  fxActivePad = nullptr;
664 
667 }
668 
670 {
673 }
674 
676 {
677  TGo4LockGuard lock;
678 
679  TGo4Fitter *clone = CloneFitter();
680 
681  if (clone)
682  SaveObjectInMemory("", clone);
683 }
684 
686 {
687  QTableWidget *tab = ParsTable;
688  if (!tab)
689  return;
690 
691  TGo4Log::Info("Printout of fitter parameters table");
692 
693  QString str("Name");
694  for (int ncol = 0; ncol < tab->columnCount(); ncol++) {
695  str += "\t";
696  str += tab->horizontalHeaderItem(ncol)->text();
697  }
698  TGo4Log::Info(str.toLatin1().constData());
699 
700  for (int nrow = 0; nrow < tab->rowCount(); nrow++) {
701  str = tab->verticalHeaderItem(nrow)->text();
702  for (int ncol = 0; ncol < tab->columnCount(); ncol++) {
703  str += "\t";
704  str += tab->item(nrow, ncol)->text();
705  }
706  TGo4Log::Info(str.toLatin1().constData());
707  }
708 }
709 
711 {
712  TGo4Fitter *fitter = GetFitter();
713  fitter->RememberPars();
714 
715  UpdateStatusBar();
717 }
718 
720 {
721  TGo4LockGuard lock;
722 
723  TGo4Fitter *fitter = GetFitter();
724  if (fitter) {
725  TGo4ViewPanel *panel = LastActivePanel();
726  if (!panel || (panel == fxDrawNewPanel))
727  return;
728  if ((panel != ActivePanel()) || (panel->GetActivePad() != ActivePad())) {
729  TGo4Fitter *clone = (TGo4Fitter *)fitter->Clone();
730  fxActivePanel = panel;
731  fxActivePad = panel->GetActivePad();
732  SetFitter(clone);
735  }
736  } else
737  Fitter_NewForActivePad(false);
738 }
739 
741 {
742  if (!WorkingWithOnlyPad())
743  return;
744 
745  TGo4Fitter *fitter = GetFitter();
746  if (!fitter)
747  return;
748 
749  if (fitter->GetNumData() != 1) {
750  std::cout << " Incorrect data" << std::endl;
751  return;
752  }
753 
755  return;
756 
757  TGo4FitData *data = fitter->GetData(0);
758  if (!data)
759  return;
760 
761  data->ClearRanges();
762  data->SetRange(0, ActivePad()->GetUxmin(), ActivePad()->GetUxmax());
763 
764  fitter->SetMemoryUsage(1);
765 
766  int NumDim = data->DefineDimensions();
767 
768  TGo4FitModel *model = nullptr;
769 
770  switch (nmodel) {
771  case 0: fitter->AddPolynoms(data->GetName(), "Pol", Smp_PolOrderSpin->value(), NumDim); break;
772 
773  case 1: model = CreateModel(20, nullptr, fitter, data); break;
774 
775  case 2: model = CreateModel(24, nullptr, fitter, data); break;
776 
777  case 3: model = CreateModel(25, nullptr, fitter, data); break;
778  }
779 
780  if (model && ((nmodel == 1) || (nmodel == 2)))
781  LocateModel(model, data, false);
782 
783  fbUseAmplEstim = true;
784  fiNumMigradIter = 500;
785 
787 }
788 
790 {
791  TGo4Fitter *fitter = GetFitter();
792  if (!fitter)
793  return;
794 
795  fitter->DeleteAllModels();
796 
799 }
800 
802 {
803  TGo4Fitter *fitter = GetFitter();
804  if (!fitter)
805  return;
806 
807  TGo4FitPeakFinder *finder = GetPeakFinder(true);
808  if (!finder)
809  return;
810 
811  TGo4FitData *data = nullptr;
813  data = Wiz_SelectedData();
814  else
815  data = fitter->GetData(0);
816  if (!data)
817  return;
818 
821 
822  if (fbUseCurrentRange)
824 
825  finder->SetDataName(data->GetName());
826 
827  finder->SetClearModels(kTRUE);
828 
830 
831  UpdateStatusBar("Start peak finder ... ");
832 
833  fitter->DoAction(finder);
834 
835  fbUseAmplEstim = true;
836  fiNumMigradIter = 300;
837 
838  UpdateStatusBar();
839 
840  fiPaintMode = 1;
842 }
843 
845 {
846  TGo4Fitter *fitter = GetFitter();
847  if (!fitter)
848  return;
849 
851 
852  if (fbUseAmplEstim || (fiNumMigradIter > 0)) {
853  TGo4FitPeakFinder *finder = GetPeakFinder(false);
854  Int_t n = 0;
855  while (n < fitter->GetNumActions()) {
856  TGo4FitterAction *action = fitter->GetAction(n);
857  if (action == finder)
858  n++;
859  else
860  fitter->DeleteAction(action);
861  }
862 
863  if (fbUseAmplEstim)
864  fitter->AddAmplEstimation();
865  if (fiNumMigradIter > 0) {
866  TGo4FitMinuit *minuit = new TGo4FitMinuit("Minuit");
867  QString cmd("MIGRAD ");
868  cmd += QString::number(fiNumMigradIter);
869  cmd += " 1";
870  minuit->AddCommand(cmd.toLatin1().constData());
871  fitter->AddAction(minuit);
872  }
873  }
874 
875  if (fitter->GetNumActions() == 0)
876  fitter->AddStandardActions();
877  }
878 
879  if (fbUseCurrentRange)
881 
883 
884  fitter->MemorizePars();
885 
886  UpdateStatusBar("Start fitting ... ");
887 
888  fitter->DoActions();
889 
890  Button_FitterDraw(nullptr);
891 
894  if (!fbShowPrimitives)
895  return;
896  TGo4FitData *data = fitter->GetData(0);
897  PaintModelsFor(fitter, data, nullptr, true);
898  UpdateStatusBar();
899  } else
901 }
902 
904 {
905  TGo4Fitter *fitter = GetFitter();
906  if (!fitter || (!fbDrawModels && !fbDrawComponents && !fbDrawBackground && !fbDrawInfoOnPad)) {
908  return;
909  }
910 
911  bool UseSamePads = fbUseSamePanelForDraw;
912  if (UseSamePads)
913  for (Int_t n = 0; n < fitter->GetNumData(); n++) {
914  TGo4FitData *data = fitter->GetData(n);
915  if (selecteddata && (data != selecteddata))
916  continue;
917  if (data->IsAnyDataTransform()) {
918  UseSamePads = false;
919  }
920 
921  if (!FindPadWhereData(data))
922  UseSamePads = false;
923  }
924 
925  int NeedPads = 1;
926  if (!UseSamePads) {
927  if (!fxDrawNewPanel) {
928  fbDrawPanelCreation = kTRUE;
930  fbDrawPanelCreation = kFALSE;
931  if (!fxDrawNewPanel)
932  return;
933  } else
935 
936  if (!selecteddata)
937  NeedPads = fitter->GetNumData();
938  else
939  NeedPads = 1;
940 
941  if (NeedPads > 1) {
942  int DivX = (int)TMath::Sqrt(NeedPads * 1.);
943  int DivY = DivX;
944  while (DivX * DivY < NeedPads)
945  DivY++;
946  fxDrawNewPanel->Divide(DivX, DivY);
947  }
948  }
949 
950  for (Int_t n = 0; n < fitter->GetNumData(); n++) {
951  TGo4FitData *data = fitter->GetData(n);
952 
953  if (selecteddata && (data != selecteddata))
954  continue;
955 
956  const char *drawopt = nullptr;
957  if (data->GetDataType() == TGo4FitData::dtGraph)
958  drawopt = "L";
959 
960  TGo4ViewPanel *panel = nullptr;
961  TPad *pad = nullptr;
962 
963  if (UseSamePads) {
964  panel = ActivePanel();
965  pad = FindPadWhereData(data);
966  } else {
967  panel = fxDrawNewPanel;
968  pad = fxDrawNewPanel->GetSubPad(nullptr, n, true);
969  }
970  if (!panel || !pad)
971  continue;
972 
974 
975  // disable autoscaling while THStack is not able to automatically
976  // scale only visible region
977  if (UseSamePads)
978  panel->SetAutoScale(false, pad);
979 
980  // panel->DeleteDrawObjects(pad, TGo4ViewPanel::kind_FitInfo);
981  // panel->SetPadSuperImpose(pad, true);
982 
983  panel->ShootRepaintTimer();
984 
985  if (!UseSamePads) {
986  TObject *obj = fitter->CreateDrawObject("Data", data->GetName(), kFALSE);
987  panel->AddDrawObject(pad, TGo4ViewPanel::kind_FitModels, "::Data", obj, true, drawopt);
988  }
989 
990  if (!fbDrawInfoOnPad)
992  else {
993  Double_t x2 = 0.98;
994  Double_t y2 = 0.5;
995  Double_t x1 = x2 - gStyle->GetStatW();
996  Double_t y1 = y2 - gStyle->GetStatH();
997 
998  if (LineParsChk->isChecked()) {
999  x1 = 0.6;
1000  x2 = 0.95;
1001  y1 = 0.8;
1002  y2 = 0.88;
1003  }
1004 
1005  TPaveStats *stats = dynamic_cast<TPaveStats *>(pad->GetPrimitive("stats"));
1006  if (stats) {
1007  x1 = stats->GetX1NDC();
1008  x2 = stats->GetX2NDC();
1009  y2 = stats->GetY1NDC() - 0.03;
1010  y1 = y2 - (stats->GetY2NDC() - stats->GetY1NDC());
1011  if (y1 < 0.02)
1012  y1 = 0.02;
1013  }
1014 
1015  TLegend *leg = dynamic_cast<TLegend *>(pad->GetPrimitive("fitlegend"));
1016  if (leg) {
1017  x1 = leg->GetX1NDC();
1018  x2 = leg->GetX2NDC();
1019  y2 = leg->GetY1NDC() - 0.03;
1020  y1 = y2 - (leg->GetY2NDC() - leg->GetY1NDC());
1021  if (y1 < 0.02)
1022  y1 = 0.02;
1023  }
1024 
1025  TPaveStats *info = dynamic_cast<TPaveStats *>(panel->GetDrawObject(pad, "::FitterPars"));
1026 
1027  bool infocreated = false;
1028 
1029  if (info)
1030  info->Clear("*");
1031  else {
1032  infocreated = true;
1033 
1034  info = new TPaveStats(x1, y1, x2, y2, "brNDC");
1035  info->SetFillColor(gStyle->GetStatColor());
1036  info->SetFillStyle(gStyle->GetStatStyle());
1037  info->SetBorderSize(gStyle->GetStatBorderSize());
1038  info->SetTextFont(gStyle->GetStatFont());
1039  if (gStyle->GetStatFont() % 10 > 2)
1040  info->SetTextSize(gStyle->GetStatFontSize());
1041  info->SetFitFormat(gStyle->GetFitFormat());
1042  info->SetStatFormat(gStyle->GetStatFormat());
1043  info->SetTextColor(gStyle->GetStatTextColor());
1044  info->SetTextAlign(12);
1045  info->SetName("fitinfo");
1046  }
1047 
1048  info->AddText(data->GetName());
1049  info->AddLine(0, 0, 0, 0);
1050 
1051  if (LineParsChk->isChecked())
1052  info->AddText(TString::Format("Line | Ampl | Pos & %s", (fbRecalculateGaussWidth ? "FWHM" : "Width")));
1053 
1054  for (Int_t m = 0; m < fitter->GetNumModel(); m++) {
1055  TGo4FitModel *model = fitter->GetModel(m);
1056  if (!model->IsAssignTo(data->GetName()))
1057  continue;
1058 
1059  if (LineParsChk->isChecked()) {
1060  Double_t ampl, pos, width;
1061 
1062  ampl = model->GetAmplValue();
1063  if (!model->GetPosition(0, pos))
1064  pos = 0.;
1065  if (!model->GetWidth(0, width))
1066  width = 0.;
1067 
1068  bool recalculatew = (model->InheritsFrom(TGo4FitModelGauss1::Class()) ||
1069  model->InheritsFrom(TGo4FitModelGauss2::Class()) ||
1070  model->InheritsFrom(TGo4FitModelGaussN::Class())) &&
1072  double widthk = recalculatew ? 2.3548 : 1.0;
1073 
1074  TString tt = TString::Format("%7s | %s%s | %s%s %s%s", model->GetName(), "%", gStyle->GetStatFormat(),
1075  "%", gStyle->GetStatFormat(), "%", gStyle->GetStatFormat());
1076 
1077  info->AddText(TString::Format(tt.Data(), ampl, pos, width * widthk).Data());
1078  } else {
1079  int maxparlen = 7;
1080  for (Int_t np = 0; np < model->NumPars(); np++) {
1081  int len = strlen(model->GetParFullName(np));
1082  if (len > maxparlen)
1083  maxparlen = len;
1084  }
1085  TString tt = TString::Format("%s%ds = %s%s", "%", maxparlen, "%", gStyle->GetStatFormat());
1086 
1087  for (Int_t np = 0; np < model->NumPars(); np++)
1088  info->AddText(
1089  TString::Format(tt.Data(), model->GetParFullName(np), model->GetPar(np)->GetValue()).Data());
1090  }
1091  }
1092 
1093  if (infocreated)
1094  panel->AddDrawObject(pad, TGo4ViewPanel::kind_FitInfo, "::FitterPars", info, true, nullptr);
1095  }
1096 
1097  if (fbDrawModels) {
1098  TObject *model = fitter->CreateDrawObject("Model", data->GetName(), kTRUE);
1099  panel->AddDrawObject(pad, TGo4ViewPanel::kind_FitModels, "::DataModel", model, true, drawopt);
1100  }
1101 
1102  if (fbDrawBackground) {
1103  TObject *model = fitter->CreateDrawObject("Background", data->GetName(), kTRUE, "Background");
1104  panel->AddDrawObject(pad, TGo4ViewPanel::kind_FitModels, "::Background", model, true, drawopt);
1105  }
1106 
1107  if (fbDrawComponents)
1108  for (Int_t m = 0; m < fitter->GetNumModel(); m++) {
1109  TGo4FitModel *model = fitter->GetModel(m);
1110  if (!model->IsAssignTo(data->GetName()))
1111  continue;
1112  if (model->GetGroupIndex() == 0)
1113  continue;
1114  TObject *comp = fitter->CreateDrawObject(model->GetName(), data->GetName(), kTRUE, model->GetName());
1115  if (!comp)
1116  continue;
1117 
1118  panel->AddDrawObject(pad, TGo4ViewPanel::kind_FitModels, "::FitComponent", comp, true, drawopt);
1119  }
1120  } // data
1121 }
1122 
1124 {
1125  TGo4Fitter *fitter = new TGo4Fitter("Fitter", "Fitter object");
1126  SetFitter(fitter);
1127 
1128  UpdateActivePage();
1129 }
1130 
1132 {
1133  TGo4Fitter *fitter = CreateFitterFor(ActivePanel(), ActivePad(), "Fitter");
1134  if (fitter) {
1135  SetFitter(fitter);
1136  UpdateActivePage();
1137  }
1138 }
1139 
1141 {
1142  if (checkConfirm("Delete fitter", "Are you sure?"))
1143  return;
1144 
1145  RemovePrimitives();
1146 
1147  SetFitter(nullptr);
1148 
1149  UpdateActivePage();
1150 }
1151 
1153 {
1154  TGo4Fitter *fitter = GetFitter();
1155  if (!fitter)
1156  return;
1157 
1158  if (checkConfirm("Clear fitter", "Are you sure?"))
1159  return;
1160 
1161  fitter->Clear();
1162 
1163  UpdateActivePage();
1164 }
1165 
1167 {
1168  TGo4Fitter *fitter = GetFitter();
1169  if (!fitter)
1170  return;
1171 
1172  QString fname(fitter->GetName());
1173  fname += ".root";
1174 
1175  if (ask) {
1176  fname = QFileDialog::getSaveFileName(this, "Save fitter dialog", fname, "Root file (*.root)");
1177  if (fname.isNull())
1178  return;
1179  }
1180 
1182 
1183  TFile f(fname.toLatin1().constData(), "recreate");
1184  fitter->Write();
1185 }
1186 
1188 {
1189  TObject *obj = item->Object();
1190  if (!obj)
1191  return;
1192 
1193  QString str = "*";
1194  bool ok = true;
1195  if (obj->InheritsFrom(TGo4Fitter::Class()))
1196  str = QInputDialog::getText(this, QString("Go4 Fit Panel"), QString("Enter parameters for Print() command"),
1197  QLineEdit::Normal, str, &ok);
1198  if (!ok)
1199  return;
1200 
1201  RemoveItemWidget();
1202  auto widget = new QFitPrintWidget(nullptr, (QString("Print ") + obj->GetName()).toLatin1().constData());
1203 
1204  fxCurrentItemWidget = widget;
1205 
1206  ListStack->addWidget(widget);
1207  widget->SetDrawOption(str);
1208  widget->SetItem(this, item);
1209  ListStack->setCurrentWidget(widget);
1210 }
1211 
1213 {
1214  TGo4FitData *data = dynamic_cast<TGo4FitData *>(item->Object());
1215  if (data)
1216  Button_FitterDraw(data);
1217 }
1218 
1220 {
1221  TGo4FitData *data = dynamic_cast<TGo4FitData *>(item->Object());
1222  TGo4Fitter *fitter = GetFitter();
1223 
1224  if (!data || !fitter)
1225  return;
1226 
1227  if (checkConfirm("Delete data", QString("Are you sure to delete ") + data->GetName()))
1228  return;
1229 
1230  fitter->RemoveData(data->GetName(), kTRUE);
1231 
1233 
1235 
1236  UpdateItem(item->Parent(), true);
1237 
1238  UpdateStatusBar();
1239 }
1240 
1242 {
1243  TGo4Fitter *fitter = GetFitter();
1244  if (!fitter)
1245  return;
1246 
1247  if (checkConfirm("Delete all data", "Are you sure to delete all data objects"))
1248  return;
1249 
1250  fitter->DeleteAllData();
1251 
1253 
1255 
1256  UpdateItem(item, true);
1257 
1258  UpdateStatusBar();
1259 }
1260 
1262 {
1263  if (!item || !item->Parent())
1264  return;
1265  TGo4FitData *data = dynamic_cast<TGo4FitData *>(item->Object());
1266  TGo4Fitter *fitter = GetFitter();
1267 
1268  if (!data || !fitter)
1269  return;
1270 
1271  if (checkConfirm("Delete models", QString("Are you sure to delete models, associated to ") + data->GetName()))
1272  return;
1273 
1274  fitter->DeleteModelsAssosiatedTo(data->GetName());
1275 
1276  QFitItem *mlist = FindItem(nullptr, FitGui::ot_modellist, nullptr);
1277  if (mlist)
1278  UpdateItem(mlist, true);
1279 
1281 
1282  ShowItem(item, false);
1283 
1284  UpdateStatusBar();
1285 }
1286 
1288 {
1289  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
1290 
1291  Cmd_RemoveModel(model);
1292 }
1293 
1295 {
1296  TGo4Fitter *fitter = GetFitter();
1297  if (!model || !fitter)
1298  return;
1299 
1300  if (checkConfirm("Delete model", QString("Are you sure to delete ") + model->GetName()))
1301  return;
1302 
1303  fitter->RemoveModel(model->GetName(), kTRUE);
1304 
1306 
1307  UpdateActivePage();
1308 }
1309 
1311 {
1312  TGo4Fitter *fitter = GetFitter();
1313  if (!fitter)
1314  return;
1315 
1316  if (checkConfirm("Delete all models", "Are you sure to delete all models objects"))
1317  return;
1318 
1319  fitter->DeleteAllModels();
1320 
1322 
1323  UpdateItem(item, true);
1325  UpdateStatusBar();
1326 }
1327 
1329 {
1330  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
1331 
1332  TGo4Fitter *fitter = GetFitter();
1333  if (!fitter || !model)
1334  return;
1335 
1336  fitter->CloneModel(model->GetName());
1337 
1339 
1340  UpdateActivePage();
1341 }
1342 
1344 {
1345  if (item->ObjectType() != FitGui::ot_datalist)
1346  item = item->Parent();
1347  if (item->ObjectType() != FitGui::ot_datalist)
1348  return;
1349 
1350  TGo4Fitter *fitter = GetFitter();
1351  if (!fitter)
1352  return;
1353 
1354  TGo4FitData *data = CreateData(id, nullptr);
1355  if (!data)
1356  return;
1357 
1358  fitter->AddData(data);
1359 
1361 
1362  UpdateItem(item, true);
1363 
1365 
1366  QFitItem *curr = FindItem(data, FitGui::ot_data, item);
1367  if (curr)
1368  FitList->setCurrentItem(curr, QItemSelectionModel::Select);
1369  UpdateStatusBar();
1370 }
1371 
1373 {
1374  if (item->ObjectType() != FitGui::ot_modellist)
1375  item = item->Parent();
1376  if (item->ObjectType() != FitGui::ot_modellist)
1377  return;
1378 
1379  TGo4Fitter *fitter = GetFitter();
1380  if (!fitter)
1381  return;
1382 
1383  TGo4FitModel *model = CreateModel(id, nullptr, fitter, nullptr);
1384  LocateModel(model, nullptr, true);
1385 
1387 
1388  UpdateItem(item, true);
1389 
1391 
1392  QFitItem *curr = FindItem(model, FitGui::ot_model, item);
1393  if (curr)
1394  FitList->setCurrentItem(curr, QItemSelectionModel::Select);
1395  UpdateStatusBar();
1396 }
1397 
1399 {
1400  if (!item)
1401  return;
1402 
1403  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Parent()->Object());
1404  if (!model)
1405  return;
1406 
1407  model->ClearAssignmentTo(item->text(0).toLatin1().constData());
1408 
1410 
1411  UpdateItem(item->Parent(), true);
1412 }
1413 
1415 {
1416  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
1417  if (!model)
1418  return;
1419 
1420  model->ClearAssignments();
1421 
1423 
1424  UpdateItem(item, true);
1425 }
1426 
1428 {
1429  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
1430  TGo4Fitter *fitter = GetFitter();
1431  if (!model || !fitter)
1432  return;
1433 
1434  fitter->AssignModelTo(model->GetName(), nullptr);
1435 
1437 
1438  UpdateItem(item, true);
1439 }
1440 
1442 {
1443  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
1444  TGo4Fitter *fitter = GetFitter();
1445  if (!model || !fitter)
1446  return;
1447 
1448  fitter->AssignModelTo(model->GetName(), fitter->GetDataName(id));
1449 
1451 
1452  UpdateItem(item, true);
1453 }
1454 
1456 {
1457  if (!item)
1458  return;
1459 
1460  Int_t typ = item->ObjectType();
1461 
1462  if ((typ != FitGui::ot_range) && (typ != FitGui::ot_rangecut))
1463  return;
1464 
1465  int num = item->Tag();
1466 
1467  if (num < 0)
1468  return;
1469 
1470  if (checkConfirm("Remove condition", QString("Are you sure to delete condition ") + item->text(0)))
1471  return;
1472 
1473  QFitItem *parent = item->Parent();
1474  TGo4FitComponent *comp = dynamic_cast<TGo4FitComponent *>(parent->Object());
1475 
1476  if (typ == FitGui::ot_range)
1477  comp->RemoveRangeCondition(num);
1478  else
1479  comp->RemoveRangeCut(num);
1480 
1481  UpdateItem(parent, true);
1482 }
1483 
1485 {
1486  if (!item || (item->ObjectType() != FitGui::ot_rangelist))
1487  return;
1488 
1489  if (checkConfirm("Delete conditions", "Are you sure to delete all conditions"))
1490  return;
1491 
1492  TGo4FitComponent *comp = dynamic_cast<TGo4FitComponent *>(item->Object());
1493  comp->ClearRanges();
1494 
1495  UpdateItem(item, true);
1496 }
1497 
1499 {
1500  if (!item || (item->ObjectType() != FitGui::ot_rangelist))
1501  return;
1502 
1503  TGo4FitData *data = nullptr;
1504 
1505  if (item->Object()->InheritsFrom(TGo4FitData::Class())) {
1506  data = dynamic_cast<TGo4FitData *>(item->Object());
1507  } else {
1508  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
1509  TGo4Fitter *fitter = GetFitter();
1510  if (model && fitter)
1511  for (Int_t n = 0; n < model->NumAssigments(); n++) {
1512  data = fitter->FindData(model->AssignmentName(n));
1513  if (data)
1514  break;
1515  }
1516  }
1517  Double_t minx = 0., maxx = 100., miny = 0., maxy = 100;
1518 
1519  TPad *pad = FindPadWhereData(data);
1520  if (pad) {
1521  minx = pad->GetUxmin();
1522  maxx = pad->GetUxmax();
1523  miny = pad->GetUymin();
1524  maxy = pad->GetUymax();
1525  } else if (data) {
1526  data->DefineScaleMinMax(0, minx, maxx);
1527  data->DefineScaleMinMax(1, miny, maxy);
1528  Double_t ddx = 0.1 * (maxx - minx);
1529  minx += ddx;
1530  maxx -= ddx;
1531  Double_t ddy = 0.1 * (maxy - miny);
1532  miny += ddy;
1533  maxy -= ddy;
1534  }
1535 
1536  TGo4FitComponent *comp = dynamic_cast<TGo4FitComponent *>(item->Object());
1537 
1538  if (id == 0)
1539  comp->SetRange(0, minx, maxx);
1540  else if (id == 1)
1541  comp->ExcludeRange(0, minx, maxx);
1542  else if (id == 2)
1543  comp->SetRangeMin(0, minx);
1544  else if (id == 3)
1545  comp->SetRangeMax(0, maxx);
1546  else if (id == 4) {
1547  TString name = TString::Format("Cut%d", comp->GetNumRangeCut());
1548  TCutG *cut = new TCutG(name, 5);
1549  cut->SetTitle("range cut of X and Y axis");
1550  cut->SetPoint(0, minx, miny);
1551  cut->SetPoint(1, maxx, miny);
1552  cut->SetPoint(2, maxx, maxy);
1553  cut->SetPoint(3, minx, maxy);
1554  cut->SetPoint(4, minx, miny);
1555  comp->AddRangeCut(cut);
1556  }
1557 
1558  UpdateItem(item, true);
1559 }
1560 
1562 {
1563  if (!item)
1564  return;
1565  TGo4FitterAction *action = dynamic_cast<TGo4FitterAction *>(item->Object());
1566  TGo4Fitter *fitter = GetFitter();
1567 
1568  if (action && fitter) {
1569  if (checkConfirm("Delete action", QString("Are you sure to delete ") + item->text(0)))
1570  return;
1571 
1572  fitter->DeleteAction(action);
1573  UpdateItem(item->Parent(), true);
1574  }
1575 }
1576 
1578 {
1579  if (!item || !item->Parent())
1580  return;
1581 
1582  TGo4FitterAction *action = dynamic_cast<TGo4FitterAction *>(item->Object());
1583  TGo4Fitter *fitter = GetFitter();
1584 
1585  if (action && fitter) {
1586  fitter->ReplaceAction(action, dir);
1587  QFitItem *parent = item->Parent();
1588  UpdateItem(parent, true);
1589  item = FindItem(action, -1, nullptr);
1590  if (item)
1591  FitList->setCurrentItem(item, QItemSelectionModel::Select);
1592  }
1593 }
1594 
1596 {
1597  TGo4Fitter *fitter = GetFitter();
1598  if (!item || !fitter)
1599  return;
1600 
1601  TGo4FitterAction *action = dynamic_cast<TGo4FitterAction *>(item->Object());
1602  if (!action)
1603  return;
1604 
1605  fitter->DoAction(action);
1606 
1607  if (action->CanChangeFitter()) {
1608  UpdateActivePage();
1609  } else {
1610  UpdateItem(item, true);
1612  }
1613 }
1614 
1616 {
1617  TGo4Fitter *fitter = GetFitter();
1618 
1619  if (!item || !fitter)
1620  return;
1621 
1622  fitter->MemorizePars();
1623 
1624  fitter->DoActions(expert);
1625 
1626  if (expert) {
1627  UpdateActivePage();
1628  } else {
1629  UpdateItem(item, true);
1631  }
1632 }
1633 
1635 {
1636  TGo4Fitter *fitter = GetFitter();
1637  if (!item || (item->ObjectType() != FitGui::ot_actlist) || !fitter)
1638  return;
1639 
1640  if (checkConfirm("Delete output actions", QString("Are you sure to delete all output actions") + item->text(0)))
1641  return;
1642 
1643  fitter->DeleteOutputActions();
1644  UpdateItem(item, true);
1645 }
1646 
1648 {
1649  TGo4Fitter *fitter = GetFitter();
1650  if (!item || (item->ObjectType() != FitGui::ot_actlist) || !fitter)
1651  return;
1652 
1653  if (checkConfirm("Delete all actions", "Are you sure to delete all actions?"))
1654  return;
1655 
1656  fitter->DeleteActions();
1657  UpdateItem(item, true);
1658 }
1659 
1661 {
1662  TGo4Fitter *fitter = GetFitter();
1663  if (!item || (item->ObjectType() != FitGui::ot_actlist) || !fitter)
1664  return;
1665 
1666  switch (id) {
1667  case 0: fitter->AddAction(new TGo4FitterConfig("Config", "Fitter configuration")); break;
1668  case 1: fitter->AddAmplEstimation(); break;
1669  case 2: fitter->AddSimpleMinuit(); break;
1670  case 3: fitter->AddOutputAction("Print", "*"); break;
1671  case 4: fitter->AddAction(new TGo4FitPeakFinder("Finder")); break;
1672  }
1673  UpdateItem(item, true);
1674 }
1675 
1677 {
1678  if (!item || (item->ObjectType() != FitGui::ot_depend))
1679  return;
1680 
1681  TGo4FitDependency *depen = dynamic_cast<TGo4FitDependency *>(item->Object());
1682  TObjArray *lst = dynamic_cast<TObjArray *>(item->Parent()->Object());
1683 
1684  if (!depen || !lst)
1685  return;
1686 
1687  if (checkConfirm("Delete dependency item", QString("Are you sure to delete ") + item->text(0)))
1688  return;
1689 
1690  lst->Remove(depen);
1691  lst->Compress();
1692  delete depen;
1693 
1694  UpdateItem(item->Parent(), true);
1695 }
1696 
1698 {
1699  if (!item)
1700  return;
1701  TObjArray *lst = dynamic_cast<TObjArray *>(item->Object());
1702  if (!lst)
1703  return;
1704 
1705  if (checkConfirm("Delete all", QString("Are you sure to delete all items from ") + item->text(0)))
1706  return;
1707 
1708  lst->Clear();
1709 
1710  UpdateItem(item, true);
1711 }
1712 
1714 {
1715  if (!item)
1716  return;
1717 
1718  TObjArray *lst = dynamic_cast<TObjArray *>(item->Object());
1719  if (!lst)
1720  return;
1721 
1722  if (item->ObjectType() == FitGui::ot_reslist)
1723  lst->Add(new TGo4FitDependency(nullptr, 0.0));
1724  else
1725  lst->Add(new TGo4FitDependency("Par1", 1.0));
1726 
1727  UpdateItem(item, true);
1728 }
1729 
1731 {
1732  if (!item)
1733  return;
1734 
1735  TGo4FitParsList *pars = dynamic_cast<TGo4FitParsList *>(item->Object());
1736  if (!pars)
1737  return;
1738 
1739  pars->MemorizePars();
1740 }
1741 
1743 {
1744  if (!item)
1745  return;
1746 
1747  TGo4FitParsList *pars = dynamic_cast<TGo4FitParsList *>(item->Object());
1748  if (!pars)
1749  return;
1750 
1751  pars->RememberPars();
1752 
1754 
1755  ShowItem(item, false);
1756 }
1757 
1759 {
1760  if (!item)
1761  return;
1762  TGo4FitParsList *pars = dynamic_cast<TGo4FitParsList *>(item->Object());
1763  if (!pars)
1764  return;
1765 
1766  if (checkConfirm("Delete all", "Are you sure to delete all parameters"))
1767  return;
1768 
1769  pars->ClearPars();
1770 
1771  UpdateItem(item, true);
1772 }
1773 
1775 {
1776  if (!item)
1777  return;
1778  TGo4FitParameter *par = dynamic_cast<TGo4FitParameter *>(item->Object());
1779  if (!par)
1780  return;
1781 
1782  par->MemorizeValue();
1783 }
1784 
1786 {
1787  if (!item)
1788  return;
1789  TGo4FitParameter *par = dynamic_cast<TGo4FitParameter *>(item->Object());
1790  if (!par)
1791  return;
1792 
1793  par->RememberValue();
1794 
1795  SetItemText(item, true);
1796 
1797  ShowItem(item, false);
1798 }
1799 
1801 {
1802  if (!item)
1803  return;
1804 
1805  TGo4FitParsList *pars = dynamic_cast<TGo4FitParsList *>(item->Object());
1806  if (!pars)
1807  return;
1808 
1809  TString name;
1810  int num = 0;
1811  do {
1812  name = TString::Format("Par%d", num++);
1813  } while (pars->FindPar(name.Data()));
1814  pars->CreatePar(name.Data(), "additional parameter", 0.);
1815 
1816  UpdateItem(item, true);
1817 }
1818 
1820 {
1821  if (!item)
1822  return;
1823 
1824  TGo4FitParameter *par = dynamic_cast<TGo4FitParameter *>(item->Object());
1825  TGo4FitParsList *pars = dynamic_cast<TGo4FitParsList *>(item->Parent()->Object());
1826  if (!pars || !par)
1827  return;
1828 
1829  if (checkConfirm("Delete parameter", QString("Are you sure to delete ") + par->GetName()))
1830  return;
1831 
1832  pars->RemovePar(par);
1833 
1834  UpdateItem(item->Parent(), true);
1835 }
1836 
1838 {
1839  if (!item)
1840  return;
1841 
1842  TGo4FitMinuitResult *res = dynamic_cast<TGo4FitMinuitResult *>(item->Object());
1843  TGo4FitMinuit *minuit = dynamic_cast<TGo4FitMinuit *>(item->Parent()->Object());
1844  if (!res || !minuit)
1845  return;
1846 
1847  if (checkConfirm("Delete result", QString("Are you sure to delete ") + res->GetName()))
1848  return;
1849 
1850  minuit->RemoveResult(res);
1851  delete res;
1852 
1853  UpdateItem(item->Parent(), true);
1854 }
1855 
1857 {
1858  if (!item)
1859  return;
1860 
1862 
1863  for (int n = 0; n < item->childCount(); n++)
1864  UpdateItem(dynamic_cast<QFitItem *>(item->child(n)), true);
1865 }
1866 
1867 // *************************** fitslots ends ******************************
1868 
1870 {
1871  QFitItem *fititem = dynamic_cast<QFitItem *>(FitList->itemAt(pnt));
1872  if (!fititem)
1873  return;
1874 
1875  QMenu menu;
1876 
1877  if (FillPopupForItem(fititem, &menu)) {
1878  CurrFitItem = fititem;
1879  menu.exec(FitList->viewport()->mapToGlobal(pnt));
1880  CurrFitItem = nullptr;
1881  }
1882 }
1883 
1884 void TGo4FitPanel::FitList_currentItemChanged(QTreeWidgetItem *curr, QTreeWidgetItem *)
1885 {
1886  if (fbFillingWidget)
1887  return;
1888 
1889  QFitItem *fititem = dynamic_cast<QFitItem *>(curr);
1890  if (!fititem)
1891  return;
1892 
1893  ShowItem(fititem, false);
1894  fxCurrentItem = fititem;
1895 
1896  UpdateItemMenu();
1897 }
1898 
1900 {
1901  ViewMenu->clear();
1902 
1906  SetIdAction(ViewMap, fiPanelMode, true, true);
1907 }
1908 
1910 {
1911  if (id != FitGui::pm_None)
1912  fiPanelMode = id;
1913 
1914  fbParsWidgetShown = false;
1915  UpdateActivePage();
1916 }
1917 
1919 {
1920  QWidget *w = PageEmpty;
1921  switch (id) {
1922  case 1: w = PageSimple; break;
1923  case 2: w = PageWizard; break;
1924  case 3: w = PageExtended; break;
1925  case 100: w = PageParameters; break;
1926  }
1927  if (w != WidgetStack->currentWidget())
1928  WidgetStack->setCurrentWidget(w);
1929 }
1930 
1931 void TGo4FitPanel::UpdateStatusBar(const char *info)
1932 {
1933  QString status;
1934  TGo4Fitter *fitter = GetFitter();
1935 
1936  if (info) {
1937  status = info;
1938  } else {
1939  if (WorkingWithPanel()) {
1940  status = QString("Active: ") + ActivePad()->GetName();
1941  if (!WorkingWithOnlyPad())
1942  status += ". Muiltifit";
1943 
1944  } else
1945  status = "Workspace";
1946  if (!fitter)
1947  status += ". No fitter";
1948  else
1949  status = status + ". Fitter: " + fitter->GetName();
1950  }
1951  MainStatusLbl->setText(status);
1952  MainStatusLbl->update();
1953  MainStatusLbl->repaint();
1954 
1955  MainAttachBtn->setEnabled(true);
1956 
1957  if (fbParsWidgetShown) {
1958  MainParsBtn->setText("Back");
1959  MainParsBtn->setToolTip("Back to last selected page");
1960  } else {
1961  MainParsBtn->setText("Pars");
1962  MainParsBtn->setToolTip("Show list of fitter parameters");
1963  }
1964 
1965  if (!fitter) {
1966  MainFitBtn->setEnabled(false);
1967  MainDrawBtn->setEnabled(false);
1968  MainFindBtn->setEnabled(false);
1969  MainParsBtn->setEnabled(false);
1970  } else {
1971  MainFitBtn->setEnabled((fitter->GetNumData() > 0) &&
1972  ((fitter->GetNumModel() > 0) || (fiPanelMode == FitGui::pm_Simple)));
1973  MainDrawBtn->setEnabled(fitter->GetNumData() > 0);
1974  MainFindBtn->setEnabled((fitter->GetNumData() > 0) && (fiPanelMode == FitGui::pm_Wizard) && GetPeakFinder(false));
1975  MainParsBtn->setEnabled(true);
1976  }
1977 }
1978 
1980 {
1981  bool showitem = fiPanelMode == FitGui::pm_Expert;
1982 
1983  QString itemtext;
1984 
1985  if (showitem) {
1986  QFitItem *item = dynamic_cast<QFitItem *>(FitList->currentItem());
1987  if (!item || (item->ObjectType() == FitGui::ot_fitter))
1988  showitem = false;
1989  else
1990  itemtext = item->text(0);
1991  }
1992 
1993  if (showitem) {
1994  if (!ItemMenu) {
1995  ItemMenu = MenuBar->addMenu(itemtext);
1996  QObject::connect(ItemMenu, &QMenu::aboutToShow, this, &TGo4FitPanel::AboutToShowItemMenu);
1997  } else
1998  ItemMenu->setTitle(itemtext);
1999  MenuBar->adjustSize();
2000  } else if (ItemMenu) {
2001  delete ItemMenu;
2002  ItemMenu = nullptr;
2003  }
2004 }
2005 
2007 {
2010  SetIdAction(SettMap, 3, true, fbFreezeMode);
2013 
2015  SetIdAction(SettMap, 11, true, fbDrawModels);
2016  SetIdAction(SettMap, 12, true, fbDrawComponents);
2018  SetIdAction(SettMap, 14, true, fbDrawBackground);
2019  SetIdAction(SettMap, 15, true, fbDrawInfoOnPad);
2021 
2022  SetIdAction(SettMap, 17, true, fiIntegralMode == 0);
2023  SetIdAction(SettMap, 18, true, fiIntegralMode == 1);
2024  SetIdAction(SettMap, 19, true, fiIntegralMode == 2);
2025  SetIdAction(SettMap, 20, true, fiIntegralMode == 3);
2026 
2027  SetIdAction(SettMap, 21, true, fiBuffersUsage == 0);
2028  SetIdAction(SettMap, 22, true, fiBuffersUsage == 1);
2029  SetIdAction(SettMap, 23, true, fiBuffersUsage == 2);
2030  SetIdAction(SettMap, 24, true, fiBuffersUsage == 3);
2031 }
2032 
2034 {
2035  switch (id) {
2036  case 1: fbNeedConfirmation = !fbNeedConfirmation; break;
2037  case 2: fbShowPrimitives = !fbShowPrimitives; break;
2038  case 3: fbFreezeMode = !fbFreezeMode; break;
2039  case 4: fbSaveWithReferences = !fbSaveWithReferences; break;
2040  case 10: fbUseCurrentRange = !fbUseCurrentRange; break;
2041  case 11: fbDrawModels = !fbDrawModels; break;
2042  case 12: fbDrawComponents = !fbDrawComponents; break;
2043  case 13: fbUseSamePanelForDraw = !fbUseSamePanelForDraw; break;
2044  case 14: fbDrawBackground = !fbDrawBackground; break;
2045  case 15: fbDrawInfoOnPad = !fbDrawInfoOnPad; break;
2046  case 16:
2048  UpdateActivePage();
2049  break;
2050  case 17:
2051  fiIntegralMode = 0;
2052  UpdateActivePage();
2053  break;
2054  case 18:
2055  fiIntegralMode = 1;
2056  UpdateActivePage();
2057  break;
2058  case 19:
2059  fiIntegralMode = 2;
2060  UpdateActivePage();
2061  break;
2062  case 20:
2063  fiIntegralMode = 3;
2064  UpdateActivePage();
2065  break;
2066  case 21: fiBuffersUsage = 0; break;
2067  case 22: fiBuffersUsage = 1; break;
2068  case 23: fiBuffersUsage = 2; break;
2069  case 24: fiBuffersUsage = 3; break;
2070  }
2071 
2072  go4sett->setBool("/FitPanel/NeedConfirmation", fbNeedConfirmation);
2073  go4sett->setBool("/FitPanel/ShowPrimitives", fbShowPrimitives);
2074  go4sett->setBool("/FitPanel/SaveWithReferences", fbSaveWithReferences);
2075  go4sett->setBool("/FitPanel/UseCurrentRange", fbUseCurrentRange);
2076  go4sett->setBool("/FitPanel/DrawModels", fbDrawModels);
2077  go4sett->setBool("/FitPanel/DrawComponents", fbDrawComponents);
2078  go4sett->setBool("/FitPanel/UseSamePanelForDraw", fbUseSamePanelForDraw);
2079  go4sett->setBool("/FitPanel/DrawBackground", fbDrawBackground);
2080  go4sett->setBool("/FitPanel/DrawInfoOnPad", fbDrawInfoOnPad);
2081  go4sett->setBool("/FitPanel/RecalculateGaussWidth", fbRecalculateGaussWidth);
2082  go4sett->setInt("/FitPanel/IntegralMode", fiIntegralMode);
2083  go4sett->setInt("/FitPanel/BuffersUsage", fiBuffersUsage);
2084 }
2085 
2087 {
2088  FitterMenu->clear();
2089 
2090  TGo4Fitter *fitter = GetFitter();
2091  TGo4ViewPanel *panel = LastActivePanel();
2092 
2093  QString padname;
2094  if (panel)
2095  padname = QString("panel \"") + panel->windowTitle() + "\"";
2096 
2098  AddIdAction(FitterMenu, FitterMap, "&Create for workspace", 1, true);
2099  AddIdAction(FitterMenu, FitterMap, QString("Create &for ") + padname, 2, (panel != nullptr));
2100  AddIdAction(FitterMenu, FitterMap, "&Delete", 3, (fitter != nullptr));
2101  FitterMenu->addSeparator();
2102 
2103  AddIdAction(FitterMenu, FitterMap, "Save to &browser", 21, (fitter != nullptr));
2105  AddIdAction(FitterMenu, FitterMap, "&Workspace", 23, WorkingWithPanel());
2106  AddIdAction(FitterMenu, FitterMap, "&Update references", 24, (fitter != nullptr));
2107  AddIdAction(FitterMenu, FitterMap, "&Print parameters", 25, (fitter != nullptr) && fbParsWidgetShown);
2108  AddIdAction(FitterMenu, FitterMap, "&Rollback parameters", 26, (fitter != nullptr) && fitter->CanRollbackPars());
2109 
2110  FitterMenu->addSeparator();
2111 
2112  AddIdAction(FitterMenu, FitterMap, "&Close", 99, true);
2113 }
2114 
2116 {
2117  switch (id) {
2118  case 1: Fitter_New(); break;
2119  case 2: Fitter_NewForActivePad(true); break;
2120  case 3: Fitter_Delete(); break;
2121  case 21: Fitter_SaveToBrowser(); break;
2122  case 23: Fitter_UseWorkspace(); break;
2123  case 24: Fitter_UpdateReferences(); break;
2124  case 25: Fitter_PrintParameters(); break;
2125  case 26: Fitter_RollbackParameters(); break;
2126  case 99: parentWidget()->close(); break;
2127  }
2128 }
2129 
2131 {
2132  QFitItem *item = dynamic_cast<QFitItem *>(FitList->currentItem());
2133  if (!ItemMenu || !item)
2134  return;
2135  ItemMenu->clear();
2136  FillPopupForItem(item, ItemMenu);
2137 }
2138 
2140 {
2141  QFitItem *item = CurrFitItem;
2142  if (!item)
2143  item = dynamic_cast<QFitItem *>(FitList->currentItem());
2144  if (!item)
2145  return;
2146 
2147  switch (id) {
2148  case 1: Cmd_DeleteFitter(); break;
2149  case 2: Cmd_ClearFitter(); break;
2150  case 3: Cmd_SaveFitter(false); break;
2151  case 4: Cmd_SaveFitter(true); break;
2152  case 5: Cmd_ItemPrint(item); break;
2153  case 6: Button_FitterDraw(nullptr); break;
2154  case 8: Cmd_CreateFitter(); break;
2155  case 9: Cmd_CreateAppropriateFitter(); break;
2156  case 101: Cmd_DeleteData(item); break;
2157  case 102: Cmd_DeleteAssosiatedModels(item); break;
2158  case 105: Cmd_DrawData(item); break;
2159  case 107: Cmd_DeleteAllData(item); break;
2160  case 108: Wiz_RebuildDataList(); break;
2161  case 201: Cmd_DeleteModel(item); break;
2162  case 202: Cmd_DeleteModels(item); break;
2163  case 203: Cmd_CloneModel(item); break;
2164  case 301: Cmd_ClearAssigments(item); break;
2165  case 302: Cmd_AssignModelToAllData(item); break;
2166  case 303: Cmd_ClearAssigment(item); break;
2167  case 401: Cmd_RemoveRangeCondition(item); break;
2168  case 402: Cmd_RemoveRangeConditions(item); break;
2169  case 403:
2170  case 404:
2171  case 405:
2172  case 406:
2173  case 407: Cmd_AddRangeCondition(item, id - 403); break;
2174  case 501: Cmd_DeleteAction(item); break;
2175  case 502: Cmd_MoveAction(item, -1); break;
2176  case 503: Cmd_MoveAction(item, +1); break;
2177  case 504: Cmd_ExecuteActions(item, false); break;
2178  case 505: Cmd_DeleteActions(item); break;
2179  case 506: Cmd_DeleteOutputActions(item); break;
2180  case 507: Cmd_ExecuteActions(item, true); break;
2181  case 508: Cmd_ExecuteAction(item); break;
2182  case 601: Cmd_DeleteDependency(item); break;
2183  case 602: Cmd_DeleteDependencies(item); break;
2184  case 603: Cmd_AddDependency(item); break;
2185  case 701: Cmd_DeletePars(item); break;
2186  case 702: Cmd_AddNewPar(item); break;
2187  case 703: Cmd_DeletePar(item); break;
2188  case 704: Cmd_MemorizePar(item); break;
2189  case 705: Cmd_RememberPar(item); break;
2190  case 706: Cmd_MemorizePars(item); break;
2191  case 707: Cmd_RememberPars(item); break;
2192  case 801: Cmd_DeleteMinuitResult(item); break;
2193  case 904: Cmd_UpdateAllSlots(item); break;
2194 
2195  default:
2196  if ((id >= 110) && (id < 200))
2197  Cmd_AddNewData(item, id - 110);
2198  else if ((id >= 210) && (id < 300))
2199  Cmd_AddNewModel(item, id - 210);
2200  else if ((id >= 310) && (id < 400))
2201  Cmd_AssignModelToData(item, id - 310);
2202  else if ((id >= 510) && (id < 600))
2203  Cmd_AddNewAction(item, id - 510);
2204  else if ((id >= 1000) && (id < 2000))
2205  ExecutePopupForSlot(item, nullptr, id);
2206  }
2207 }
2208 
2209 void TGo4FitPanel::focusInEvent(QFocusEvent *event)
2210 {
2211  UpdateStatusBar();
2212  QWidget::focusInEvent(event);
2213 }
2214 
2215 void TGo4FitPanel::changeEvent(QEvent *event)
2216 {
2217  if (event->type() == QEvent::ActivationChange)
2218  UpdateStatusBar();
2219  QWidget::changeEvent(event);
2220 }
2221 
2222 // void TGo4FitPanel::windowActivationChange(bool OldActive)
2223 //{
2224 // UpdateStatusBar();
2225 // QWidget::windowActivationChange(OldActive);
2226 // }
2227 
2229 {
2230  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2231  if (finder)
2232  PF_AmplLbl->setText(QString("Threshold: ") + QString::number(finder->Get0MaxAmplFactor() * 100) + "%");
2233  else
2234  PF_AmplLbl->setText("Threshold:");
2235  PF_AmplLbl->adjustSize();
2236 }
2237 
2239 {
2240  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2241 
2242  if (finder)
2243  PF_RelNoiseLbl->setText(QString("Noise factor: ") + QString::number(finder->Get2NoiseFactor()));
2244  else
2245  PF_RelNoiseLbl->setText("Noise factor: ");
2246  PF_RelNoiseLbl->adjustSize();
2247 }
2248 
2250 {
2251  if (fbFillingWidget)
2252  return;
2253  bool ok;
2254  double zn = str.toDouble(&ok);
2255  if (ok) {
2256  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2257  if (finder)
2258  finder->Set0MinWidth(zn);
2259  }
2260 }
2261 
2263 {
2264  if (fbFillingWidget)
2265  return;
2266  bool ok;
2267  double zn = str.toDouble(&ok);
2268  if (ok) {
2269  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2270  if (finder)
2271  finder->Set0MaxWidth(zn);
2272  }
2273 }
2274 
2276 {
2277  if (fbFillingWidget)
2278  return;
2279  bool ok;
2280  double zn = str.toDouble(&ok);
2281  if (ok) {
2282  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2283  if (finder)
2284  finder->Set1LineWidth(zn);
2285  }
2286 }
2287 
2289 {
2290  if (!fbFillingWidget) {
2291  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2292  if (finder)
2293  finder->Set0MaxAmplFactor(1. - zn / 100.);
2294  UpdatePFAmplLbl();
2295  }
2296 }
2297 
2299 {
2300  if (!fbFillingWidget)
2302 }
2303 
2305 {
2306  if (!fbFillingWidget) {
2307  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2308  if (finder)
2309  finder->Set2NoiseFactor((101 - zn) / 10.);
2311  }
2312 }
2313 
2315 {
2316  if (!fbFillingWidget)
2318 }
2319 
2321 {
2322  if (fbFillingWidget)
2323  return;
2324  bool ok;
2325  double zn = str.toDouble(&ok);
2326  if (ok) {
2327  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2328  if (finder)
2329  finder->Set2NoiseMinimum(zn);
2330  }
2331 }
2332 
2334 {
2335  if (!fbFillingWidget) {
2336  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2337  if (finder) {
2338  finder->Set2ChannelSum(num);
2340  }
2341  }
2342 }
2343 
2345 {
2346  TGo4Fitter *fitter = GetFitter();
2347 
2348  fbFillingWidget = true;
2349 
2350  bool updatestack = false, updatepaint = false;
2351 
2352  Wiz_DataList->clear();
2353  if (!fitter)
2354  fxWizDataName = "";
2355  else {
2356  if (!Wiz_SelectedData() && (fitter->GetNumData() > 0)) {
2357  fxWizDataName = fitter->GetDataName(0);
2358  if (fiWizPageIndex < 1)
2359  updatestack = true;
2360  if (fiPaintMode == 0)
2361  updatepaint = true;
2362  }
2363 
2364  int selindx = -1;
2365  for (Int_t n = 0; n < fitter->GetNumData(); n++) {
2366  TGo4FitData *data = fitter->GetData(n);
2367  QListWidgetItem *item = new QListWidgetItem(data->GetName());
2368  if (strcmp(data->GetName(), fxWizDataName.toLatin1().constData()) == 0) {
2369  selindx = n;
2370  item->setSelected(true);
2371  }
2372  Wiz_DataList->addItem(item);
2373  }
2374  if (selindx < 0)
2375  fxWizDataName = "";
2376  }
2378  fbFillingWidget = false;
2379 
2380  if (updatestack) {
2381  fiWizPageIndex = 2;
2383  }
2384  if (updatepaint)
2385  UpdateWizPaint(1);
2386 }
2387 
2389 {
2390  TGo4Fitter *fitter = GetFitter();
2391  TGo4FitData *data = Wiz_SelectedData();
2392 
2393  Wiz_PFSetupBtn->setEnabled(data != nullptr);
2394 
2395  if (!WorkingWithPanel()) {
2396  Wiz_RebuildDataBtn->setVisible(false);
2397  Wiz_AddDataBtn->setVisible(true);
2398  Wiz_DelDataBtn->setVisible(true);
2399  Wiz_AddDataBtn->setEnabled(fitter != nullptr);
2400  Wiz_DelDataBtn->setEnabled(data != nullptr);
2401  } else {
2402  Wiz_RebuildDataBtn->setVisible(true);
2403  Wiz_RebuildDataBtn->setEnabled(fitter != nullptr);
2404  Wiz_AddDataBtn->setVisible(false);
2405  Wiz_DelDataBtn->setVisible(false);
2406  }
2407 }
2408 
2410 {
2411  fbFillingWidget = true;
2412 
2413  Wiz_ModelList->clear();
2414 
2415  TGo4Fitter *fitter = GetFitter();
2416 
2417  Wiz_ShowAllMod->setChecked(fbWizShowAllModels);
2418  int selindx = -1;
2419  if (fitter) {
2420  TGo4FitData *data = Wiz_SelectedData();
2421  int indx = 0;
2422  for (Int_t n = 0; n < fitter->GetNumModel(); n++) {
2423  TGo4FitModel *model = fitter->GetModel(n);
2424  if (data && !fbWizShowAllModels)
2425  if (!model->IsAssignTo(data->GetName()))
2426  continue;
2427 
2428  bool assign = false;
2429  if (data && model->IsAssignTo(data->GetName()))
2430  assign = true;
2431  QListWidgetItem *item = new QListWidgetItem(model->GetName());
2432  item->setCheckState(assign ? Qt::Checked : Qt::Unchecked);
2433  if (strcmp(model->GetName(), fxWizModelName.toLatin1().constData()) == 0) {
2434  selindx = indx;
2435  item->setSelected(true);
2436  }
2437  Wiz_ModelList->addItem(item);
2438  indx++;
2439  }
2440 
2441  if (selindx >= 0)
2442  Wiz_ModelList->setCurrentRow(selindx);
2443 
2444  if (selindx < 0)
2445  fxWizModelName = "";
2446  // else Wiz_ModelList->ensureCurrentVisible();
2447 
2448  } else {
2449  fxWizModelName = "";
2450  }
2451 
2452  if (changestack) {
2453  if (selindx >= 0) {
2454  fiWizPageIndex = 1;
2455  } else if (fiWizPageIndex == 1) {
2456  fiWizPageIndex = 0;
2457  }
2458  }
2459 
2461 
2462  fbFillingWidget = false;
2463 
2464  if (changestack)
2466 }
2467 
2469 {
2470  TGo4Fitter *fitter = GetFitter();
2471  TGo4FitModel *model = Wiz_SelectedModel();
2472 
2473  Wiz_ShowAllMod->setVisible(!WorkingWithOnlyPad());
2474 
2475  if (fitter) {
2476  Wiz_AddModelBtn->setEnabled(true);
2477  Wiz_DelModelBtn->setEnabled(model != nullptr);
2478  Wiz_CloneModelBtn->setEnabled(model != nullptr);
2479  Wiz_ShowAllMod->setEnabled(true);
2480  } else {
2481  Wiz_AddModelBtn->setEnabled(false);
2482  Wiz_DelModelBtn->setEnabled(false);
2483  Wiz_CloneModelBtn->setEnabled(false);
2484  Wiz_ShowAllMod->setEnabled(false);
2485  }
2486 }
2487 
2489 {
2490  fbFillingWidget = true;
2491  TGo4Fitter *fitter = GetFitter();
2492 
2493  int indx = -1;
2494  if (!fitter)
2495  fiWizPageIndex = -1;
2496  else
2497  indx = fiWizPageIndex;
2498 
2499  QWidget *target = nullptr;
2500 
2501  switch (indx) {
2502  case -1: target = Wiz_EmptyPage; break;
2503  case 0: {
2504  target = Wiz_FitterPage;
2505 
2506  int typ = fitter->GetFitFunctionType();
2507  if (typ == TGo4Fitter::ff_user)
2509  Wiz_FitFuncCmb->setCurrentIndex(typ);
2510 
2511  Wiz_UseAmplEstimChk->setChecked(fbUseAmplEstim);
2512  Wiz_MigradIterSpin->setValue(fiNumMigradIter);
2513 
2514  break;
2515  }
2516 
2517  case 1: {
2518  TGo4FitModel *model = Wiz_SelectedModel();
2519  if (!model)
2520  break;
2521 
2522  target = Wiz_ModelPage;
2523 
2524  QString modelinfo;
2525  Wiz_GetModelInfo(model, &modelinfo);
2526  Wiz_ModelInfoLbl->setText(modelinfo);
2527 
2528  Wiz_BackgroundChk->setChecked(model->GetGroupIndex() == 0);
2529 
2530  Wiz_ModelBufChk->setChecked(model->GetUseBuffers());
2531  Wiz_ModelBufChk->setEnabled(fiBuffersUsage == 3);
2532 
2533  FillParsTable(Wiz_ParTable, fitter, model, false, fxWizPars);
2534 
2535  break;
2536  }
2537 
2538  case 2: {
2539  TGo4FitData *data = Wiz_SelectedData();
2540  if (!data)
2541  break;
2542 
2543  target = Wiz_DataPage;
2544 
2545  QString datainfo("Data: ");
2546  datainfo += data->GetName();
2547  datainfo += " of class: ";
2548  datainfo += data->ClassName();
2549  if (fiIntegralMode == 1) {
2550  datainfo += "\nCounts=";
2551  double v = fitter->CalculatesIntegral(data->GetName(), nullptr, kTRUE);
2552  datainfo += QString::number(v);
2553  }
2554  if (fiIntegralMode == 2) {
2555  datainfo += "\nIntegral=";
2556  double v = fitter->CalculatesIntegral(data->GetName(), nullptr, kFALSE);
2557  datainfo += QString::number(v);
2558  }
2559  Wiz_DataInfoLbl->setText(datainfo);
2560 
2561  QString models("Models:");
2562  for (int n = 0; n < fitter->GetNumModel(); n++) {
2563  TGo4FitModel *model = fitter->GetModel(n);
2564  if (model->IsAssignTo(data->GetName())) {
2565  if (models.length() > 45) {
2566  models += " ...";
2567  break;
2568  }
2569  models += " ";
2570  models += model->GetName();
2571  }
2572  }
2573  Wiz_DataModelsLbl->setText(models);
2574 
2575  Wiz_DataBufChk->setChecked((fiBuffersUsage == 1) || (fiBuffersUsage == 2) ||
2576  ((fiBuffersUsage == 3) && data->GetUseBuffers()));
2577  Wiz_DataBufChk->setEnabled(fiBuffersUsage == 3);
2578 
2579  fxWizSlots->Clear();
2580  data->FillSlotList(fxWizSlots);
2581 
2582  Wiz_DataSlotsTable->setRowCount(fxWizSlots->GetLast() + 1);
2583 
2584  for (int n = 0; n <= fxWizSlots->GetLast(); n++) {
2585  TGo4FitSlot *slot = dynamic_cast<TGo4FitSlot *>(fxWizSlots->At(n));
2586  if (!slot)
2587  continue;
2588 
2589  Wiz_DataSlotsTable->setVerticalHeaderItem(n, new QTableWidgetItem(slot->GetName()));
2590  TObject *obj = slot->GetObject();
2591 
2592  if (!obj) {
2593  Wiz_DataSlotsTable->setItem(n, 0, new QTableWidgetItem(" --- "));
2594  Wiz_DataSlotsTable->setItem(n, 1, new QTableWidgetItem(slot->GetClass()->GetName()));
2595  Wiz_DataSlotsTable->setItem(n, 2, new QTableWidgetItem("false"));
2596  } else {
2597  Wiz_DataSlotsTable->setItem(n, 0, new QTableWidgetItem(obj->GetName()));
2598  Wiz_DataSlotsTable->setItem(n, 1, new QTableWidgetItem(obj->ClassName()));
2599  if (slot->GetOwned())
2600  Wiz_DataSlotsTable->setItem(n, 2, new QTableWidgetItem("true"));
2601  else
2602  Wiz_DataSlotsTable->setItem(n, 2, new QTableWidgetItem("false"));
2603  }
2604 
2605  Wiz_DataSlotsTable->setItem(n, 3, new QTableWidgetItem(Wiz_GetSlotSourceInfo(slot)));
2606  }
2607 
2608  Wiz_DataSlotsTable->resizeColumnsToContents();
2609 
2610  Wiz_DataUseRangeBtn->setEnabled(FindPadWhereData(data) != nullptr);
2611  if (data)
2612  Wiz_DataClearRangesBtn->setEnabled(data->IsAnyRangeLimits());
2613  Wiz_DrawDataBtn->setEnabled(data != nullptr);
2614 
2615  break;
2616  }
2617  case 3: {
2618  target = Wiz_PFPage;
2619 
2620  TGo4FitPeakFinder *finder = GetPeakFinder(true);
2621  if (!finder)
2622  break;
2623 
2624  UpdateStatusBar();
2625 
2626  FindersTab->setCurrentIndex(finder->GetPeakFinderType());
2627 
2628  Wiz_PFUsePolynChk->setChecked(finder->GetUsePolynom());
2629  Wiz_PFPolynSpin->setEnabled(finder->GetUsePolynom());
2630  Wiz_PFPolynSpin->setValue(finder->GetPolynomOrder());
2631 
2632  PF_MinWidthEdt->setText(QString::number(finder->Get0MinWidth()));
2633  PF_MaxWidthEdt->setText(QString::number(finder->Get0MaxWidth()));
2634  PF_AmplSlider->setValue(int(100 * (1. - finder->Get0MaxAmplFactor())));
2635  UpdatePFAmplLbl();
2636 
2637  PF_WidthEdit->setText(QString::number(finder->Get1LineWidth()));
2638 
2639  int zn = int(10 * finder->Get2NoiseFactor()); // from 1..100
2640  PF_RelNoiseSlider->setValue(101 - zn);
2642  PF_MinNoiseEdit->setText(QString::number(finder->Get2NoiseMinimum()));
2643  PF_SumUpSpin->setValue(finder->Get2ChannelSum());
2644 
2645  break;
2646  }
2647  }
2648 
2649  if (target)
2650  Wiz_Stack->setCurrentWidget(target);
2651  else
2652  Wiz_Stack->setCurrentWidget(Wiz_EmptyPage);
2653 
2654  fbFillingWidget = false;
2655 }
2656 
2658 {
2659  RemovePrimitives();
2660 
2661  if (!fbShowPrimitives)
2662  return;
2663 
2664  if (mode >= 0)
2665  fiPaintMode = mode;
2666 
2667  TGo4Fitter *fitter = GetFitter();
2668  TGo4FitModel *model = Wiz_SelectedModel();
2669  TGo4FitData *data = Wiz_SelectedData();
2670 
2671  if (fitter && data && (fiPaintMode == 1)) {
2672  TPad *pad = FindPadWhereData(data);
2673 
2674  if (PaintModelsFor(fitter, data, nullptr, false))
2675  for (Int_t n = 0; n < data->GetNumRangeCondition(); n++)
2676  PaintRange(data, n, pad, nullptr);
2677  }
2678 
2679  if (fitter && model && (fiPaintMode == 2)) {
2680  for (Int_t n = 0; n < model->NumAssigments(); n++) {
2681  data = fitter->FindData(model->AssignmentName(n));
2682  if (data && !data->IsAnyDataTransform()) {
2683  TPad *pad = FindPadWhereData(data);
2684  PaintModel(model, pad, nullptr);
2685  }
2686  }
2687  }
2688 }
2689 
2690 void TGo4FitPanel::Wiz_DataListSelect(QListWidgetItem *item)
2691 {
2692  if (fbFillingWidget || !item)
2693  return;
2694  QString name = item->text();
2695 
2696  if ((name == fxWizDataName) && (fiWizPageIndex == 2))
2697  return;
2698  fxWizDataName = name;
2699  fiWizPageIndex = 2;
2701  UpdateWizModelsList(false);
2703  UpdateWizPaint(1);
2704 }
2705 
2706 void TGo4FitPanel::Wiz_ModelListSelect(QListWidgetItem *item)
2707 {
2708  if (fbFillingWidget || !item)
2709  return;
2710 
2711  QString name = item->text();
2712 
2713  bool needupdate = ((name != fxWizModelName) || (fiWizPageIndex != 1));
2714 
2715  fxWizModelName = name;
2716  fiWizPageIndex = 1;
2717 
2718  TGo4Fitter *fitter = GetFitter();
2719  TGo4FitModel *model = Wiz_SelectedModel();
2720  TGo4FitData *data = Wiz_SelectedData();
2721  if (fitter && data && model) {
2722  bool wasassigned = model->IsAssignTo(data->GetName());
2723  bool isassigned = (item->checkState() == Qt::Checked);
2724 
2725  if (wasassigned != isassigned) {
2726  if (wasassigned)
2727  fitter->ClearModelAssignmentTo(model->GetName(), data->GetName());
2728  else
2729  fitter->AssignModelTo(model->GetName(), data->GetName());
2730  needupdate = true;
2731  }
2732  }
2733 
2734  if (needupdate) {
2737  UpdateWizPaint(2);
2738  }
2739 }
2740 
2742 {
2743  if (fbFillingWidget)
2744  return;
2745 
2746  QMenu menu;
2747 
2748  FillDataTypesList(&menu, 0, "wiz_data");
2749 
2750  menu.exec(Wiz_AddDataBtn->mapToGlobal(QPoint(5, 5)));
2751 }
2752 
2754 {
2755  if (fbFillingWidget)
2756  return;
2757 
2758  if (Wiz_RemoveData()) {
2760  UpdateWizModelsList(false);
2761  fiWizPageIndex = 0;
2763  UpdateWizPaint(0);
2764  UpdateStatusBar();
2765  }
2766 }
2767 
2769 {
2770  if (fbFillingWidget)
2771  return;
2772 
2773  QMenu menu;
2774 
2775  FillModelTypesList(&menu, 0, true, "wiz_model");
2776 
2777  menu.exec(Wiz_AddModelBtn->mapToGlobal(QPoint(5, 5)));
2778 }
2779 
2781 {
2782  if (fbFillingWidget)
2783  return;
2784 
2785  TGo4Fitter *fitter = GetFitter();
2786  if (!fitter)
2787  return;
2788 
2789  if (checkConfirm("Delete models", "Are you sure to delete selected models"))
2790  return;
2791 
2792  for (int n = 0; n < Wiz_ModelList->count(); n++) {
2793  if (!Wiz_ModelList->item(n)->isSelected())
2794  continue;
2795  QString name = Wiz_ModelList->item(n)->text();
2796  fitter->RemoveModel(name.toLatin1().constData(), kTRUE);
2797  }
2798 
2799  fxWizModelName = "";
2800  UpdateWizModelsList(true);
2801  UpdateWizPaint(0);
2802  UpdateStatusBar();
2803 }
2804 
2806 {
2807  if (fbFillingWidget)
2808  return;
2809 
2810  TGo4Fitter *fitter = GetFitter();
2811  if (!fitter)
2812  return;
2813 
2814  for (int n = 0; n < Wiz_ModelList->count(); n++) {
2815  if (!Wiz_ModelList->item(n)->isSelected())
2816  continue;
2817  QString name = Wiz_ModelList->item(n)->text();
2818  fitter->CloneModel(name.toLatin1().constData());
2819  }
2820 
2821  fxWizModelName = "";
2822  UpdateWizModelsList(true);
2823  UpdateWizPaint(0);
2824  UpdateStatusBar();
2825 }
2826 
2828 {
2829  if (fbFillingWidget)
2830  return;
2831  fbWizShowAllModels = zn;
2832  UpdateWizModelsList(true);
2833  UpdateWizPaint(2);
2834 }
2835 
2837 {
2838  if (!fbFillingWidget && GetFitter())
2839  GetFitter()->SetFitFunctionType(typ);
2840 }
2841 
2843 {
2844  TGo4Fitter *fitter = GetFitter();
2845  if (fbFillingWidget || !fitter || name.isEmpty())
2846  return;
2847  fitter->SetName(name.toLatin1().constData());
2848 
2849  fiWizPageIndex = 0;
2851  UpdateWizPaint(0);
2852 
2853  UpdateStatusBar();
2854 }
2855 
2857 {
2858  ParsTableChanged(Wiz_ParTable, nrow, ncol, false, fxWizPars, true);
2859 }
2860 
2862 {
2863  TGo4Fitter *fitter = GetFitter();
2864  TGo4FitData *data = Wiz_SelectedData();
2865  if (!data || !fitter)
2866  return;
2867  bool ok = true;
2868  QString newname =
2869  QInputDialog::getText(this, "Change data name", "Input new name", QLineEdit::Normal, data->GetName(), &ok);
2870  if (ok && (newname.length() > 0) && (newname != data->GetName())) {
2871  if (fitter->FindData(newname.toLatin1().constData())) {
2872  QMessageBox::information(this, "Fit panel",
2873  QString("Unable to rename data.\n Name ") + newname + " already exists");
2874  return;
2875  }
2876  fitter->ChangeDataNameInAssignments(data->GetName(), newname.toLatin1().constData());
2877  data->SetName(newname.toLatin1().constData());
2878  fxWizDataName = newname;
2880  UpdateWizPaint(1);
2881  }
2882 }
2883 
2885 {
2886  TGo4Fitter *fitter = GetFitter();
2887  TGo4FitModel *model = Wiz_SelectedModel();
2888  if (!model || !fitter)
2889  return;
2890  bool ok = true;
2891  QString newname =
2892  QInputDialog::getText(this, "Change model name", "Input new name", QLineEdit::Normal, model->GetName(), &ok);
2893  if (ok && (newname.length() > 0) && (newname != model->GetName())) {
2894  if (fitter->FindModel(newname.toLatin1().constData())) {
2895  QMessageBox::information(this, "Fit panel",
2896  QString("Unable to rename model.\n Name ") + newname + " already exists\n");
2897  return;
2898  }
2899  model->SetName(newname.toLatin1().constData());
2900  fxWizModelName = newname;
2901  UpdateWizModelsList(true);
2902  UpdateWizPaint(2);
2903  }
2904 }
2905 
2906 void TGo4FitPanel::Wiz_ModelList_itemChanged(QListWidgetItem *item)
2907 {
2908  if (fbFillingWidget)
2909  return;
2910 
2911  QString name = item->text();
2912 
2913  bool checked = (item->checkState() == Qt::Checked);
2914 
2915  bool needupdate = ((name != fxWizModelName) || (fiWizPageIndex != 1));
2916 
2917  fxWizModelName = name;
2918  fiWizPageIndex = 1;
2919 
2920  TGo4Fitter *fitter = GetFitter();
2921  TGo4FitModel *model = Wiz_SelectedModel();
2922  TGo4FitData *data = Wiz_SelectedData();
2923  if (fitter && data && model) {
2924  bool wasassigned = model->IsAssignTo(data->GetName());
2925 
2926  if (wasassigned != checked) {
2927  if (wasassigned)
2928  fitter->ClearModelAssignmentTo(model->GetName(), data->GetName());
2929  else
2930  fitter->AssignModelTo(model->GetName(), data->GetName());
2931  needupdate = true;
2932  }
2933  }
2934 
2935  if (needupdate) {
2938  UpdateWizPaint(2);
2939  }
2940 }
2941 
2943 {
2945 }
2946 
2948 {
2949  if (fbFillingWidget)
2950  return;
2951  TGo4FitData *data = Wiz_SelectedData();
2952  if (data)
2953  data->SetUseBuffers(zn);
2954 }
2955 
2957 {
2958  if (!fbFillingWidget)
2959  fbUseAmplEstim = chk;
2960 }
2961 
2963 {
2964  if (!fbFillingWidget)
2965  fiNumMigradIter = num;
2966 }
2967 
2969 {
2970  if (fbFillingWidget || !fxWizSlots)
2971  return;
2972 
2973  QTableWidgetItem *item = Wiz_DataSlotsTable->itemAt(pnt);
2974 
2975  int nrow = item ? item->row() : -1;
2976 
2977  if ((nrow < 0) || (nrow > fxWizSlots->GetLast()))
2978  return;
2979 
2980  TGo4FitSlot *slot = dynamic_cast<TGo4FitSlot *>(fxWizSlots->At(nrow));
2981  if (!slot)
2982  return;
2983 
2984  QMenu menu;
2985 
2986  if (FillPopupForSlot(slot, &menu))
2987  menu.exec(Wiz_DataSlotsTable->mapToGlobal(pnt));
2988 }
2989 
2991 {
2992  if (!fbFillingWidget)
2994 }
2995 
2997 {
2998  if (fbFillingWidget)
2999  return;
3000  TGo4FitData *data = Wiz_SelectedData();
3001  if (data) {
3002  data->ClearRanges();
3003  UpdateActivePage();
3004  }
3005 }
3006 
3008 {
3009  if (fbFillingWidget)
3010  return;
3011  if (Wiz_SelectedData())
3013 }
3014 
3016 {
3017  UpdateStatusBar();
3018 
3020 }
3021 
3023 {
3024  QApplication::setOverrideCursor(Qt::WaitCursor);
3025 
3027 
3028  QApplication::restoreOverrideCursor();
3029 }
3030 
3032 {
3033  Button_FitterDraw(nullptr);
3034 }
3035 
3037 {
3038  if (GetFitter())
3040 }
3041 
3043 {
3045 
3046  UpdateActivePage();
3047 }
3048 
3050 {
3051  TGo4Fitter *fitter = GetFitter();
3052  if (!fitter)
3053  return;
3054  fbFillingWidget = true;
3055 
3056  Double_t FF = fitter->GetResultFF();
3057  Int_t NDF = fitter->GetResultNDF();
3058  if ((FF == 0.) && (NDF == 0))
3059  Par_FitterResLbl->hide();
3060  else {
3061  Par_FitterResLbl->setText("Result: Fit func = " + QString::number(FF) + " NDF = " + QString::number(NDF));
3062  Par_FitterResLbl->show();
3063  }
3064 
3065  FillParsTable(ParsTable, fitter, nullptr, LineParsChk->isChecked(), fxParsTableList);
3066  fbFillingWidget = false;
3067 }
3068 
3070 {
3071  if (fbFillingWidget)
3072  return;
3073 
3074  TGo4Fitter *fitter = GetFitter();
3075  if (!fitter)
3076  return;
3077 
3078  fbFillingWidget = true;
3079  FillParsTable(ParsTable, fitter, nullptr, LineParsChk->isChecked(), fxParsTableList);
3080  WidgetStack->setCurrentWidget(PageParameters);
3081  fbFillingWidget = false;
3082 }
3083 
3085 {
3086  if (!fbFillingWidget)
3087  ParsTableChanged(ParsTable, nrow, ncol, LineParsChk->isChecked(), fxParsTableList, false);
3088 }
3089 
3090 void TGo4FitPanel::FillParsTable(QTableWidget *table, TGo4Fitter *fitter, TGo4FitModel *model, bool LinesView,
3091  TObjArray *TableList)
3092 {
3093  if (!table || !fitter || !TableList)
3094  return;
3095 
3096  if (model && LinesView)
3097  return;
3098  TableList->Clear();
3099 
3100  /* for (int nr = 0; nr < table->rowCount(); nr++)
3101  for (int nc = 0; nc < table->columnCount(); nc++) {
3102  QTableWidgetItem* item = table->item(nr,nc);
3103  if (item) {
3104  item->setFlags(item->flags() | Qt::ItemIsEnabled);
3105  if (nc == 0) item->setText("");
3106  }
3107  }
3108  */
3109 
3110  if (LinesView) {
3111  int MaxAxis = 0;
3112  for (Int_t n = 0; n < fitter->GetNumModel(); n++) {
3113  TGo4FitModel *m = fitter->GetModel(n);
3114  if (!m)
3115  continue;
3116  Double_t zn;
3117  for (int naxis = 0; naxis < 10; naxis++)
3118  if (m->GetPosition(naxis, zn) || m->GetWidth(naxis, zn))
3119  MaxAxis = naxis;
3120  }
3121 
3122  int nfcol = (fiIntegralMode > 0) ? 3 : 1;
3123  table->setColumnCount(nfcol + (MaxAxis + 1) * 2);
3124  table->setHorizontalHeaderItem(0, new QTableWidgetItem("Amplitude"));
3125 
3126  QString capt;
3127  switch (fiIntegralMode) {
3128  case 1: capt = "Counts"; break;
3129  case 2: capt = "Integral"; break;
3130  case 3: capt = "Gauss Int"; break;
3131  }
3132  if (!capt.isEmpty()) {
3133  table->setHorizontalHeaderItem(1, new QTableWidgetItem(capt));
3134  table->setHorizontalHeaderItem(2, new QTableWidgetItem("Error"));
3135  }
3136 
3137  for (int naxis = 0; naxis <= MaxAxis; naxis++) {
3138  capt = QString("Position ") + QString::number(naxis);
3139  table->setHorizontalHeaderItem(nfcol + naxis * 2, new QTableWidgetItem(capt));
3141  capt = QString("FWHM ");
3142  else
3143  capt = QString("Sigma ");
3144  capt += QString::number(naxis);
3145  table->setHorizontalHeaderItem(nfcol + 1 + naxis * 2, new QTableWidgetItem(capt));
3146  }
3147 
3148  table->setRowCount(fitter->GetNumModel());
3149 
3150  for (Int_t n = 0; n < fitter->GetNumModel(); n++) {
3151  TGo4FitModel *m = fitter->GetModel(n);
3152  TableList->Add(m);
3153 
3154  bool recalculatew =
3155  (m->InheritsFrom(TGo4FitModelGauss1::Class()) || m->InheritsFrom(TGo4FitModelGauss2::Class()) ||
3156  m->InheritsFrom(TGo4FitModelGaussN::Class())) &&
3158  double widthk = recalculatew ? 2.3548 : 1.0;
3159 
3160  table->setVerticalHeaderItem(n, new QTableWidgetItem(m->GetName()));
3161 
3162  QTableWidgetItem *item0 = new QTableWidgetItem(QString::number(m->GetAmplValue()));
3163 
3164  TGo4FitParameter *amplpar = m->GetAmplPar();
3165  if (!amplpar)
3166  item0->setFlags(item0->flags() & ~Qt::ItemIsEnabled);
3167  table->setItem(n, 0, item0);
3168 
3169  if (fiIntegralMode > 0) {
3170  Double_t v = 0.;
3171  TGo4FitData *data = Wiz_SelectedData();
3172  switch (fiIntegralMode) {
3173  case 1:
3174  if (data)
3175  v = fitter->CalculatesIntegral(data->GetName(), m->GetName(), kTRUE);
3176  else
3177  v = fitter->CalculatesModelIntegral(m->GetName(), kTRUE);
3178  break;
3179  case 2:
3180  if (data)
3181  v = fitter->CalculatesIntegral(data->GetName(), m->GetName(), kFALSE);
3182  else
3183  v = fitter->CalculatesModelIntegral(m->GetName(), kFALSE);
3184  break;
3185  case 3: v = m->Integral(); break;
3186  default: v = 0;
3187  }
3188 
3189  QTableWidgetItem *item1;
3190  if ((v <= 0.) && (fiIntegralMode == 3))
3191  item1 = new QTableWidgetItem("---");
3192  else
3193  item1 = new QTableWidgetItem(QString::number(v));
3194  item1->setFlags(item1->flags() & ~Qt::ItemIsEnabled);
3195  table->setItem(n, 1, item1);
3196 
3197  QTableWidgetItem *item2;
3198  if (!amplpar || (amplpar->GetValue() == 0) || (amplpar->GetError() == 0) ||
3199  ((v <= 0.) && (fiIntegralMode == 3)))
3200  item2 = new QTableWidgetItem("---");
3201  else
3202  item2 = new QTableWidgetItem(QString::number(amplpar->GetError() / amplpar->GetValue() * v));
3203  item2->setFlags(item2->flags() & ~Qt::ItemIsEnabled);
3204  table->setItem(n, 2, item2);
3205  }
3206 
3207  for (int naxis = 0; naxis <= MaxAxis; naxis++) {
3208 
3209  Double_t pos, width;
3210 
3211  QTableWidgetItem *item;
3212 
3213  if (m->GetPosition(naxis, pos)) {
3214  item = new QTableWidgetItem(QString::number(pos));
3215  } else {
3216  item = new QTableWidgetItem("---");
3217  item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
3218  }
3219 
3220  table->setItem(n, nfcol + naxis * 2, item);
3221 
3222  if (m->GetWidth(naxis, width)) {
3223  item = new QTableWidgetItem(QString::number(width * widthk));
3224  } else {
3225  item = new QTableWidgetItem("---");
3226  item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
3227  }
3228  table->setItem(n, nfcol + 1 + naxis * 2, item);
3229  }
3230  }
3231 
3232  } else {
3233 
3234  TGo4FitParsList *pars = !model ? dynamic_cast<TGo4FitParsList *>(fitter) : dynamic_cast<TGo4FitParsList *>(model);
3235  if (!pars)
3236  return;
3237 
3238  for (Int_t n = 0; n < pars->NumPars(); n++)
3239  TableList->Add(pars->GetPar(n));
3240 
3241  table->setColumnCount(6);
3242  table->setHorizontalHeaderItem(0, new QTableWidgetItem("Fixed"));
3243  table->setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
3244  table->setHorizontalHeaderItem(2, new QTableWidgetItem("Error"));
3245  table->setHorizontalHeaderItem(3, new QTableWidgetItem("Epsilon"));
3246  table->setHorizontalHeaderItem(4, new QTableWidgetItem("Min"));
3247  table->setHorizontalHeaderItem(5, new QTableWidgetItem("Max"));
3248 
3249  table->setRowCount(TableList->GetLast() + 1);
3250 
3251  for (Int_t n = 0; n <= TableList->GetLast(); n++) {
3252  TGo4FitParameter *par = dynamic_cast<TGo4FitParameter *>(TableList->At(n));
3253  if (!par)
3254  continue;
3255 
3256  if (model)
3257  table->setVerticalHeaderItem(n, new QTableWidgetItem(par->GetName()));
3258  else
3259  table->setVerticalHeaderItem(n, new QTableWidgetItem(par->GetFullName()));
3260 
3261  QTableWidgetItem *checkitem = new QTableWidgetItem("fix");
3262  checkitem->setCheckState(par->GetFixed() ? Qt::Checked : Qt::Unchecked);
3263  table->setItem(n, 0, checkitem);
3264 
3265  QTableWidgetItem *item = new QTableWidgetItem(QString::number(par->GetValue()));
3266  if (par->GetFixed())
3267  item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
3268  table->setItem(n, 1, item);
3269 
3270  table->setItem(n, 2, new QTableWidgetItem(QString::number(par->GetError())));
3271 
3272  Double_t eps, min, max;
3273  if (par->GetEpsilon(eps))
3274  table->setItem(n, 3, new QTableWidgetItem(QString::number(eps)));
3275  else
3276  table->setItem(n, 3, new QTableWidgetItem(""));
3277 
3278  if (par->GetRange(min, max)) {
3279  table->setItem(n, 4, new QTableWidgetItem(QString::number(min)));
3280  table->setItem(n, 5, new QTableWidgetItem(QString::number(max)));
3281  } else {
3282  table->setItem(n, 4, new QTableWidgetItem(""));
3283  table->setItem(n, 5, new QTableWidgetItem(""));
3284  }
3285  }
3286  }
3287  table->resizeColumnsToContents();
3288  table->resizeRowsToContents();
3289 
3290  // table->verticalHeader()->adjustHeaderSize();
3291  // table->horizontalHeader()->adjustHeaderSize();
3292 }
3293 
3294 void TGo4FitPanel::ParsTableChanged(QTableWidget *table, int nrow, int ncol, bool LinesView, TObjArray *TableList,
3295  bool updatepaint)
3296 {
3297  if (fbFillingWidget || !table || !TableList)
3298  return;
3299 
3300  if ((nrow < 0) || (nrow > TableList->GetLast()))
3301  return;
3302 
3303  if (LinesView) {
3304  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(TableList->At(nrow));
3305  if (!model)
3306  return;
3307 
3308  bool recalculatew =
3309  (model->InheritsFrom(TGo4FitModelGauss1::Class()) || model->InheritsFrom(TGo4FitModelGauss2::Class()) ||
3310  model->InheritsFrom(TGo4FitModelGaussN::Class())) &&
3312  double widthk = recalculatew ? 2.3548 : 1.0;
3313 
3314  bool ok = false;
3315  double zn = table->item(nrow, ncol)->text().toDouble(&ok);
3316  if (!ok)
3317  return;
3318 
3319  if (ncol == 0)
3320  model->SetAmplValue(zn);
3321  else {
3322  int nfcol = (fiIntegralMode > 0) ? 2 : 1;
3323  int naxis = (ncol - nfcol) / 2;
3324  if ((ncol - nfcol) % 2 == 0)
3325  model->SetPosition(naxis, zn);
3326  else
3327  model->SetWidth(naxis, zn / widthk);
3328  }
3329 
3330  } else {
3331 
3332  TGo4FitParameter *par = dynamic_cast<TGo4FitParameter *>(TableList->At(nrow));
3333  if (!par)
3334  return;
3335 
3336  switch (ncol) {
3337  case 0: {
3338  if (table->item(nrow, 0)->checkState() == Qt::Checked)
3339  par->SetFixed(kTRUE);
3340  else if (table->item(nrow, 0)->checkState() == Qt::Unchecked)
3341  par->SetFixed(kFALSE);
3342  if (par->GetFixed())
3343  table->item(nrow, 1)->setFlags(table->item(nrow, 1)->flags() & ~Qt::ItemIsEnabled);
3344  else
3345  table->item(nrow, 1)->setFlags(table->item(nrow, 1)->flags() | Qt::ItemIsEnabled);
3346  break;
3347  }
3348  case 1: {
3349  if (par->GetFixed())
3350  break;
3351  bool ok = false;
3352  double zn = table->item(nrow, 1)->text().toDouble(&ok);
3353  if (ok) {
3354  par->SetValue(zn);
3355  if (updatepaint)
3356  UpdateWizPaint(2);
3357  }
3358  break;
3359  }
3360  case 2: {
3361  if (par->GetFixed())
3362  break;
3363  bool ok = false;
3364  double zn = table->item(nrow, 2)->text().toDouble(&ok);
3365  if (ok)
3366  par->SetError(zn);
3367  break;
3368  }
3369  case 3: {
3370  bool ok = false;
3371  double zn = table->item(nrow, 3)->text().toDouble(&ok);
3372  if (ok)
3373  par->SetEpsilon(zn);
3374  break;
3375  }
3376  case 4:
3377  case 5: {
3378  std::cout << "Changing col " << ncol << std::endl;
3379 
3380  bool ok = false;
3381  bool range_changed = false;
3382  double zn = table->item(nrow, ncol)->text().toDouble(&ok);
3383  if (ok) {
3384 
3385  bool changemin = false;
3386  bool changemax = false;
3387 
3388  Double_t min, max;
3389  if (!par->GetRange(min, max)) {
3390  double vvv = par->GetValue();
3391  if (ncol == 4) {
3392  min = zn;
3393  if (min < vvv)
3394  max = 2 * vvv - min;
3395  else
3396  max = min;
3397  changemax = true;
3398  } else {
3399  max = zn;
3400  if (max > vvv)
3401  min = 2 * vvv - max;
3402  else
3403  min = max;
3404  changemin = true;
3405  }
3406  } else if (ncol == 4) {
3407  min = zn;
3408  if (max < min) {
3409  max = min;
3410  changemax = true;
3411  }
3412  } else if (ncol == 5) {
3413  max = zn;
3414  if (min > max) {
3415  min = max;
3416  changemin = true;
3417  }
3418  }
3419  par->SetRange(min, max);
3420  range_changed = true;
3421  fbFillingWidget = true;
3422  if (changemin)
3423  table->item(nrow, 4)->setText(QString::number(min));
3424  if (changemax)
3425  table->item(nrow, 5)->setText(QString::number(max));
3426  fbFillingWidget = false;
3427  } else {
3428  if (table->item(nrow, ncol)->text().isEmpty() && table->item(nrow, 9 - ncol)->text().isEmpty()) {
3429  par->ClearRange();
3430  range_changed = true;
3431  }
3432  }
3433 
3434  // reset first columns of pars list when we touch range values
3435  if (range_changed) {
3436  fbFillingWidget = true;
3437  table->item(nrow, 0)->setCheckState(par->GetFixed() ? Qt::Checked : Qt::Unchecked);
3438  if (par->GetFixed())
3439  table->item(nrow, 1)->setFlags(table->item(nrow, 1)->flags() & ~Qt::ItemIsEnabled);
3440  else
3441  table->item(nrow, 1)->setFlags(table->item(nrow, 1)->flags() | Qt::ItemIsEnabled);
3442  table->item(nrow, 1)->setText(QString::number(par->GetValue()));
3443  fbFillingWidget = false;
3444  }
3445 
3446  break;
3447  }
3448  }
3449  }
3450 }
3451 
3453 {
3454  if (fbFillingWidget)
3455  return;
3456  TGo4FitModel *model = Wiz_SelectedModel();
3457  if (model)
3458  model->SetUseBuffers(zn);
3459 }
3460 
3462 {
3464  return;
3465 
3466  fiWizPageIndex = 3;
3468  UpdateWizPaint(1);
3469 }
3470 
3472 {
3473  if (fbFillingWidget)
3474  return;
3475 
3476  TGo4FitPeakFinder *finder = GetPeakFinder(true);
3477  if (finder)
3478  finder->SetUsePolynom(zn);
3479 
3480  Wiz_PFPolynSpin->setEnabled(zn);
3481 }
3482 
3484 {
3485  if (fbFillingWidget)
3486  return;
3487 
3488  TGo4FitPeakFinder *finder = GetPeakFinder(true);
3489  if (finder)
3490  finder->SetPolynomOrder(zn);
3491 }
3492 
3494 {
3495  Button_SimpleFit(0);
3496 }
3497 
3499 {
3500  Button_SimpleFit(1);
3501 }
3502 
3504 {
3505  Button_SimpleFit(2);
3506 }
3507 
3509 {
3510  Button_SimpleFit(3);
3511 }
3512 
3514 {
3516 }
3517 
3519 {
3520  if (fbFillingWidget)
3521  return;
3522 
3523  fiWizPageIndex = 0;
3525  UpdateWizPaint(0);
3526 }
3527 
3529 {
3530  if (fbFillingWidget)
3531  return;
3532 
3533  TGo4FitPeakFinder *finder = GetPeakFinder(true);
3534  if (finder)
3535  finder->SetPeakFinderType(FindersTab->currentIndex());
3536 }
3537 
3539 {
3540  if (fbFillingWidget)
3541  return;
3542 
3543  TGo4FitModel *model = Wiz_SelectedModel();
3544  if (model) {
3545  if (chk)
3546  model->SetBackgroundGroupIndex();
3547  else
3548  model->SetGroupIndex(-1);
3549  }
3550 }
3551 
3553 {
3554  if (!fbFillingWidget)
3556 }
3557 
3559 {
3560  if (!fbFillingWidget)
3562 }
3563 
3565 {
3566  if (!fbFillingWidget)
3568 }
3569 
3571 {
3572  if (!fbFillingWidget)
3574 }
3575 
3576 TGo4Fitter *TGo4FitPanel::CreateFitterFor(TGo4ViewPanel *panel, TPad *pad, const char *name)
3577 {
3578  if (!panel || !pad)
3579  return nullptr;
3580 
3581  TGo4Fitter *fitter = new TGo4Fitter(name, "Fitter object");
3582 
3583  CreateDataFor(panel, pad, fitter);
3584 
3585  fitter->AddStandardActions();
3586 
3587  fitter->SetMemoryUsage(3);
3588 
3590 
3591  return fitter;
3592 }
3593 
3594 void TGo4FitPanel::CreateDataFor(TGo4ViewPanel *panel, TPad *pad, TGo4Fitter *fitter)
3595 {
3596  if (!fitter || !panel || !pad)
3597  return;
3598 
3599  int npads = panel->GetNumberOfPads(pad);
3600 
3601  for (Int_t n = 0; n < npads; n++) {
3602  TPad *subpad = panel->GetSubPad(pad, n, false);
3603  if (panel->IsPadHasSubPads(subpad))
3604  continue;
3605  TObject *obj = panel->GetPadMainObject(subpad);
3606  if (!obj)
3607  continue;
3608 
3609  TGo4FitData *data = nullptr;
3610 
3611  if (obj->InheritsFrom(TH1::Class()))
3612  data = new TGo4FitDataHistogram(fitter->FindNextName("Data", 0, kFALSE));
3613  else if (obj->InheritsFrom(TGraph::Class()))
3614  data = new TGo4FitDataGraph(fitter->FindNextName("Data", 0, kFALSE));
3615 
3616  if (data)
3617  fitter->AddData(data);
3618  }
3619 }
3620 
3622 {
3623  int select = fiPanelMode;
3624  if (!GetFitter())
3625  select = FitGui::pm_None;
3626 
3627  if (fbParsWidgetShown && (select != FitGui::pm_None))
3628  select = 100;
3629 
3630  switch (select) {
3631  case FitGui::pm_None: break;
3632  case FitGui::pm_Simple: UpdateSimplePage(); break;
3633  case FitGui::pm_Wizard: UpdateWizardPage(); break;
3634  case FitGui::pm_Expert: UpdateExtendedPage(); break;
3635  case 100: {
3636  FillParsWidget();
3637  if (fiPanelMode == FitGui::pm_Wizard) {
3638  RemovePrimitives();
3639  UpdateWizPaint(-1);
3640  }
3641  break;
3642  }
3643  }
3644 
3645  ShowPanelPage(select);
3646  UpdateStatusBar();
3647  UpdateItemMenu();
3648 }
3649 
3651 {
3652  RemovePrimitives();
3653 
3654  PaintFitter(GetFitter(), nullptr, true);
3655 
3656  UpdateStatusBar();
3657 }
3658 
3660 {
3661  RemovePrimitives();
3662 
3663  TGo4Fitter *fitter = GetFitter();
3664  fbFillingWidget = true;
3665  if (fitter)
3666  Wiz_FitNameEdt->setText(QString(fitter->GetName()));
3667  else
3668  Wiz_FitNameEdt->setText(QString(""));
3669  fbFillingWidget = false;
3670 
3672 
3673  UpdateWizModelsList(false);
3674 
3676 
3677  UpdateWizPaint(-1);
3678 
3679  UpdateStatusBar();
3680 }
3681 
3683 {
3684  RemoveItemWidget();
3685 
3686  RemovePrimitives();
3687 
3688  fbFillingWidget = true;
3689  FitList->clear();
3690  FitList->setSortingEnabled(false);
3691  fbFillingWidget = false;
3692 
3693  TGo4Fitter *fitter = GetFitter();
3694  if (!fitter) {
3695  new QFitItem(this, FitList->invisibleRootItem(), nullptr, FitGui::ot_empty, FitGui::wt_none, FitGui::mt_empty);
3696  } else {
3697  QFitItem *fitteritem = new QFitItem(this, FitList->invisibleRootItem(), fitter, FitGui::ot_fitter,
3699  fitteritem->setExpanded(true);
3700  FitList->setCurrentItem(fitteritem, QItemSelectionModel::Select);
3701  ShowItem(fitteritem, false);
3702  }
3703 
3704  UpdateItemMenu();
3705 
3706  UpdateStatusBar();
3707 }
3708 
3710 {
3711  if (!WorkingWithPanel())
3712  return;
3713 
3714  TGo4Fitter *fitter = GetFitter();
3715  if (!fitter)
3716  return;
3717 
3718  for (Int_t n = 0; n < fitter->NumSlots(); n++) {
3719  TPad *pad = FindPadForSlot(fitter->GetSlot(n));
3720  if (!pad)
3721  continue;
3724  }
3725 }
3726 
3727 void TGo4FitPanel::AddItemAction(QMenu *menu, const QString &name, int id, const QString &handler)
3728 {
3729  if (handler.isEmpty())
3730  menu->addAction(name, [this, id]() { ItemMenuItemSelected(id); });
3731  else if (handler == "wiz_model")
3732  menu->addAction(name, [this, id]() { Wiz_CreateNewModel(id); });
3733  else if (handler == "wiz_data")
3734  menu->addAction(name, [this, id]() { Wiz_CreateNewData(id); });
3735 }
3736 
3738 {
3739  if (!item || !menu)
3740  return false;
3741 
3742  if (item->PopupMenuType() == FitGui::mt_empty) {
3743  AddItemAction(menu, "Create empty fitter", 8);
3744  if (WorkingWithPanel())
3745  AddItemAction(menu, "Create appropriate fitter", 9);
3746  }
3747 
3748  if (item->PopupMenuType() == FitGui::mt_fitter) {
3749  AddItemAction(menu, "Delete fitter", 1);
3750  AddItemAction(menu, "Clear fitter", 2);
3751  AddItemAction(menu, "Save fitter", 3);
3752  AddItemAction(menu, "Save fitter as ...", 4);
3753  AddItemAction(menu, "Print ...", 5);
3754  AddItemAction(menu, "Draw", 6);
3755  AddItemAction(menu, "Memorize parameters", 706);
3756  AddItemAction(menu, "Remember parameters", 707);
3757  }
3758 
3759  if (item->PopupMenuType() == FitGui::mt_data) {
3760  if (!WorkingWithPanel())
3761  AddItemAction(menu, QString("Remove ") + item->Object()->GetName(), 101);
3762  AddItemAction(menu, "Remove associated models", 102);
3763  AddItemAction(menu, "Draw", 105);
3764  AddItemAction(menu, "Print", 5);
3765  }
3766 
3767  if (item->PopupMenuType() == FitGui::mt_datalist) {
3768  if (WorkingWithPanel()) {
3769  AddItemAction(menu, "Rebuild data list", 108);
3770  } else {
3771  AddItemAction(menu, "Delete all data", 107);
3772  FillDataTypesList(menu, 110);
3773  }
3774  }
3775 
3776  if (item->PopupMenuType() == FitGui::mt_model) {
3777  AddItemAction(menu, QString("Remove ") + item->Object()->GetName(), 201);
3778  AddItemAction(menu, "Clone", 203);
3779  AddItemAction(menu, "Print", 5);
3780  }
3781 
3782  if (item->PopupMenuType() == FitGui::mt_modellist) {
3783  AddItemAction(menu, "Delete all models", 202);
3784  FillModelTypesList(menu, 210, true);
3785  }
3786 
3787  if (item->PopupMenuType() == FitGui::mt_asslist) {
3788  TGo4Fitter *fitter = GetFitter();
3789  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
3790  if (fitter && model) {
3791  AddItemAction(menu, "Clear all assignments", 301);
3792  AddItemAction(menu, "Assign to all data", 302);
3793  menu->addSeparator();
3794  for (Int_t n = 0; n < fitter->GetNumData(); n++)
3795  if (!model->IsAssignTo(fitter->GetDataName(n)))
3796  AddItemAction(menu, QString("Assign to: ") + fitter->GetDataName(n), 310 + n);
3797  }
3798  }
3799 
3800  if (item->PopupMenuType() == FitGui::mt_ass)
3801  AddItemAction(menu, QString("Clear assignment to ") + item->text(0), 303);
3802 
3803  if (item->PopupMenuType() == FitGui::mt_range)
3804  AddItemAction(menu, "Remove range condition", 401);
3805 
3806  if (item->PopupMenuType() == FitGui::mt_rangecut)
3807  AddItemAction(menu, "Remove range condition", 401);
3808 
3809  if (item->PopupMenuType() == FitGui::mt_rangelist) {
3810  TGo4FitComponent *comp = dynamic_cast<TGo4FitComponent *>(item->Object());
3811  if (comp) {
3812  if (comp->IsAnyRangeLimits()) {
3813  AddItemAction(menu, "Clear all ranges", 402);
3814  menu->addSeparator();
3815  }
3816  AddItemAction(menu, "Include new range", 403);
3817  AddItemAction(menu, "Exclude new range", 404);
3818  AddItemAction(menu, "Add left bound", 405);
3819  AddItemAction(menu, "Add right bound", 406);
3820  menu->addSeparator();
3821  AddItemAction(menu, "Add range cut", 407);
3822  }
3823  }
3824 
3825  if (item->PopupMenuType() == FitGui::mt_action) {
3826  AddItemAction(menu, "Delete action", 501);
3827  AddItemAction(menu, "Move action up", 502);
3828  AddItemAction(menu, "Move action down", 503);
3829  AddItemAction(menu, "Print", 5);
3830  AddItemAction(menu, "Execute", 508);
3831  }
3832 
3833  if (item->PopupMenuType() == FitGui::mt_actlist) {
3834  TGo4Fitter *fitter = dynamic_cast<TGo4Fitter *>(item->Object());
3835  if (fitter) {
3836  if (fitter->GetNumActions() > 0) {
3837  AddItemAction(menu, "Execute norm actions", 504);
3838  AddItemAction(menu, "Execute all actions", 507);
3839  AddItemAction(menu, "Delete all actions", 505);
3840  AddItemAction(menu, "Delete output actions", 506);
3841  menu->addSeparator();
3842  }
3843  AddItemAction(menu, "Add config", 510);
3844  AddItemAction(menu, "Add peak finder", 514);
3845  AddItemAction(menu, "Add amplitude estimation", 511);
3846  AddItemAction(menu, "Add minuit", 512);
3847  AddItemAction(menu, "Add output", 513);
3848  }
3849  }
3850 
3851  if (item->PopupMenuType() == FitGui::mt_depend)
3852  AddItemAction(menu, "Delete item", 601);
3853 
3854  if (item->PopupMenuType() == FitGui::mt_deplist) {
3855  AddItemAction(menu, "Delete all items", 602);
3856  AddItemAction(menu, "Insert new item", 603);
3857  }
3858 
3859  if (item->PopupMenuType() == FitGui::mt_newpars) {
3860  AddItemAction(menu, "Delete all items", 701);
3861  AddItemAction(menu, "Insert new item", 702);
3862  }
3863 
3864  if (item->PopupMenuType() == FitGui::mt_parcfg)
3865  AddItemAction(menu, "Delete item", 703);
3866 
3867  if (item->PopupMenuType() == FitGui::mt_par) {
3868  AddItemAction(menu, "Memorize value", 704);
3869  AddItemAction(menu, "Restore value", 705);
3870  }
3871 
3872  if ((item->PopupMenuType() == FitGui::mt_parslist)) {
3873  AddItemAction(menu, "Memorize parameters", 706);
3874  AddItemAction(menu, "Remember parameters", 707);
3875  }
3876 
3877  if (item->PopupMenuType() == FitGui::mt_minuitres) {
3878  AddItemAction(menu, "Delete result entry", 801);
3879  AddItemAction(menu, "Print", 5);
3880  }
3881 
3882  if (item->PopupMenuType() == FitGui::mt_slot) {
3883  TGo4FitSlot *slot = dynamic_cast<TGo4FitSlot *>(item->Object());
3884  if (slot)
3885  FillPopupForSlot(slot, menu);
3886  }
3887 
3888  if (item->PopupMenuType() == FitGui::mt_allslots) {
3889  TGo4Fitter *fitter = dynamic_cast<TGo4Fitter *>(item->Object());
3890  if (fitter)
3891  AddItemAction(menu, "Update slots from sources", 904);
3892  }
3893 
3894  return !menu->isEmpty();
3895 }
3896 
3898 {
3899  if (!slot || !menu)
3900  return false;
3901 
3902  if (!slot->GetOwned() && slot->IsObject())
3903  AddItemAction(menu, "Clone object in slot", 1000);
3904 
3905  if (slot->IsObject())
3906  AddItemAction(menu, "Clear object in slot", 1001);
3907 
3908  if (FindPadForSlot(slot))
3909  AddItemAction(menu, QString("Update from ") + Wiz_GetSlotSourceInfo(slot), 1002);
3910 
3911  if (!menu->isEmpty())
3912  menu->addSeparator();
3913 
3914  if (slot->GetConnectedSlot())
3915  AddItemAction(menu, "Brake connection to slot", 1004);
3916 
3917  TGo4Fitter *fitter = GetFitter();
3918  if (fitter)
3919  for (Int_t n = 0; n < fitter->NumSlots(); n++) {
3920  TGo4FitSlot *sl = fitter->GetSlot(n);
3921  if (slot->CanConnectToSlot(sl) && (slot->GetConnectedSlot() != sl))
3922  AddItemAction(menu, QString("Connect to ") + sl->GetFullName(), 1400 + n);
3923  }
3924 
3925  if (!menu->isEmpty())
3926  menu->addSeparator();
3927 
3928  if (slot->GetClass() == TGo4FitData::Class())
3929  FillDataTypesList(menu, 1100);
3930  else if (slot->GetClass() == TGo4FitModel::Class())
3931  FillModelTypesList(menu, 1200, false);
3932  else if (slot->GetClass() == TGo4FitAxisTrans::Class()) {
3933  AddItemAction(menu, TGo4FitLinearTrans::Class()->GetName(), 1300);
3934  AddItemAction(menu, TGo4FitMatrixTrans::Class()->GetName(), 1301);
3935  }
3936 
3937  return !menu->isEmpty();
3938 }
3939 
3941 {
3942  if (item)
3943  slot = dynamic_cast<TGo4FitSlot *>(item->Object());
3944 
3945  TGo4Fitter *fitter = GetFitter();
3946  if (!slot || !fitter)
3947  return;
3948 
3949  switch (id) {
3950  case 1000: {
3951  TObject *newobj = slot->CloneObject();
3952  slot->SetObject(newobj, kTRUE);
3953  break;
3954  }
3955 
3956  case 1001: {
3957  if (checkConfirm("Clear slot", QString("Are you sure to clear object from slot ") + slot->GetName()))
3958  return;
3959 
3960  fitter->ClearSlot(slot, kFALSE);
3961 
3962  if (item)
3963  for (Int_t i = 0; i < fitter->NumSlots(); i++) {
3964  QFitItem *sitem = FindItem(fitter->GetSlot(i), FitGui::ot_slot, nullptr);
3965  if (sitem)
3966  UpdateItem(sitem, true);
3967  }
3968 
3969  break;
3970  }
3971 
3972  case 1002: {
3973  UpdateObjectReferenceInSlot(slot, false);
3974  break;
3975  }
3976 
3977  case 1004: {
3978  slot->ClearConnectionToSlot();
3979  break;
3980  }
3981 
3982  default: {
3983  TObject *obj = nullptr;
3984  if ((id >= 1100) && (id < 1200))
3985  obj = CreateData(id - 1100, "Data");
3986  else if ((id >= 1200) && (id < 1300))
3987  obj = CreateModel(id - 1200, "Model", nullptr, nullptr);
3988  else if (id == 1300)
3989  obj = new TGo4FitLinearTrans("Trans", "Linear axis transformation");
3990  else if (id == 1301)
3991  obj = new TGo4FitMatrixTrans("Trans", "Matrix axis transformation");
3992  else if (id >= 1400) {
3993  TGo4FitSlot *sl = fitter->GetSlot(id - 1400);
3994  slot->ConnectToSlot(sl);
3995  break;
3996  }
3997  if (obj)
3998  slot->SetObject(obj, kTRUE);
3999  }
4000  }
4001 
4002  if (item) {
4003  ShowItem(item, false);
4004  UpdateItem(item, true);
4005  item->setExpanded(true);
4006  } else
4007  UpdateActivePage();
4008 }
4009 
4010 void TGo4FitPanel::UpdateItem(QFitItem *item, bool trace)
4011 {
4012  if (!item)
4013  return;
4014 
4015  if (fxCurrentItem)
4016  if (fxCurrentItem->FindInParents(item))
4017  RemoveItemWidget();
4018 
4019  while (item->childCount() > 0)
4020  delete item->child(0);
4021 
4022  SetItemText(item, false);
4023 
4024  switch (item->ObjectType()) {
4025  case FitGui::ot_empty: break;
4026  case FitGui::ot_datalist: {
4027  TGo4Fitter *fitter = dynamic_cast<TGo4Fitter *>(item->Object());
4028  if (fitter)
4029  for (Int_t n = fitter->GetNumData() - 1; n >= 0; n--)
4030  new QFitItem(this, item, fitter->GetData(n), FitGui::ot_data, FitGui::wt_data, FitGui::mt_data,
4031  FitGui::gt_data, n);
4032  break;
4033  }
4034  case FitGui::ot_data: {
4035  TGo4FitData *data = dynamic_cast<TGo4FitData *>(item->Object());
4036  if (!data)
4037  break;
4038 
4039  FillSlotsList(item, data->GetSlotList(), data);
4040 
4042 
4044 
4045  break;
4046  }
4047  case FitGui::ot_modellist: {
4048  TGo4Fitter *fitter = dynamic_cast<TGo4Fitter *>(item->Object());
4049  if (fitter)
4050  for (Int_t n = fitter->GetNumModel() - 1; n >= 0; n--)
4051  new QFitItem(this, item, fitter->GetModel(n), FitGui::ot_model, DefineModelWidgetType(fitter->GetModel(n)),
4053  break;
4054  }
4055  case FitGui::ot_model: {
4056  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
4057  if (!model)
4058  break;
4059 
4060  FillSlotsList(item, model->GetSlotList(), model);
4061 
4063 
4064  new QFitItem(this, item, model, FitGui::ot_rangelist, FitGui::wt_none, FitGui::mt_rangelist, FitGui::gt_ranges);
4065 
4066  new QFitItem(this, item, model, FitGui::ot_asslist, FitGui::wt_none, FitGui::mt_asslist, FitGui::gt_none);
4067 
4068  break;
4069  }
4070  case FitGui::ot_parslist: FillParsList(item); break;
4071  case FitGui::ot_par: break;
4072  case FitGui::ot_parcfg: break;
4073  case FitGui::ot_asslist: {
4074  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
4075  if (model)
4076  for (Int_t n = model->NumAssigments() - 1; n >= 0; n--)
4078  break;
4079  }
4080  case FitGui::ot_ass: break;
4081  case FitGui::ot_rangelist: {
4082  TGo4FitComponent *comp = dynamic_cast<TGo4FitComponent *>(item->Object());
4083  if (comp) {
4084  for (Int_t n = comp->GetNumRangeCut() - 1; n >= 0; n--)
4085  new QFitItem(this, item, comp->GetRangeCut(n), FitGui::ot_rangecut, FitGui::wt_rangecut,
4087  for (Int_t n = comp->GetNumRangeCondition() - 1; n >= 0; n--)
4089  }
4090  break;
4091  }
4092  case FitGui::ot_range: break;
4093  case FitGui::ot_rangecut: break;
4094  case FitGui::ot_actlist: {
4095  TGo4Fitter *fitter = dynamic_cast<TGo4Fitter *>(item->Object());
4096  if (!fitter)
4097  break;
4098  for (Int_t n = fitter->GetNumActions() - 1; n >= 0; n--) {
4099  TGo4FitterAction *action = fitter->GetAction(n);
4100  int ot = FitGui::ot_action, wt = FitGui::wt_named;
4101  if (action->InheritsFrom(TGo4FitterConfig::Class()))
4102  ot = FitGui::ot_config;
4103  else if (action->InheritsFrom(TGo4FitAmplEstimation::Class())) {
4104  ot = FitGui::ot_amplest;
4105  wt = FitGui::wt_amplest;
4106  } else if (action->InheritsFrom(TGo4FitPeakFinder::Class())) {
4107  ot = FitGui::ot_peakfinder;
4108  wt = FitGui::wt_peakfinder;
4109  } else if (action->InheritsFrom(TGo4FitterOutput::Class())) {
4110  ot = FitGui::ot_output;
4111  wt = FitGui::wt_output;
4112  } else if (action->InheritsFrom(TGo4FitMinuit::Class())) {
4113  ot = FitGui::ot_minuit;
4114  wt = FitGui::wt_minuit;
4115  }
4116 
4117  new QFitItem(this, item, action, ot, wt, FitGui::mt_action);
4118  }
4119  break;
4120  }
4121  case FitGui::ot_action: break;
4122  case FitGui::ot_amplest: break;
4123  case FitGui::ot_peakfinder: break;
4124  case FitGui::ot_output: break;
4125  case FitGui::ot_config: {
4126  TGo4FitterConfig *cfg = dynamic_cast<TGo4FitterConfig *>(item->Object());
4127  if (!cfg)
4128  break;
4134  break;
4135  }
4136  case FitGui::ot_minuit: {
4137  TGo4FitMinuit *minuit = dynamic_cast<TGo4FitMinuit *>(item->Object());
4138  if (!minuit)
4139  break;
4140  for (Int_t n = minuit->GetNumResults() - 1; n >= 0; n--)
4141  new QFitItem(this, item, minuit->GetResult(n), FitGui::ot_minuitres, FitGui::wt_minuitres,
4143  break;
4144  }
4145  case FitGui::ot_parinitlist: FillDependencyList(item); break;
4146  case FitGui::ot_pardeplist: FillDependencyList(item); break;
4147  case FitGui::ot_reslist: FillDependencyList(item); break;
4148  case FitGui::ot_depend: break;
4149  case FitGui::ot_newpars: FillParsList(item); break;
4150  case FitGui::ot_parscfg: {
4151  TGo4FitParsList *pars = dynamic_cast<TGo4FitParsList *>(item->Object());
4152  if (!pars)
4153  return;
4154  for (Int_t n = pars->NumPars() - 1; n >= 0; n--)
4156  break;
4157  }
4158  case FitGui::ot_minuitres: break;
4159  case FitGui::ot_slot: {
4160  TGo4FitSlot *slot = dynamic_cast<TGo4FitSlot *>(item->Object());
4161  if (!slot)
4162  break;
4163 
4164  TObject *obj = slot->GetObject();
4165  if (!obj)
4166  break;
4167 
4168  if (obj->InheritsFrom(TGo4FitData::Class()))
4169  new QFitItem(this, item, obj, FitGui::ot_data, FitGui::wt_data, FitGui::mt_none);
4170  else
4171 
4172  if (obj->InheritsFrom(TGo4FitModel::Class()))
4173  new QFitItem(this, item, obj, FitGui::ot_model, DefineModelWidgetType(obj), FitGui::mt_none);
4174  else
4175 
4176  if (obj->InheritsFrom(TGo4FitLinearTrans::Class()))
4178  else
4179 
4180  if (obj->InheritsFrom(TGo4FitMatrixTrans::Class()))
4182  else
4183 
4184  if (obj->InheritsFrom(TGo4FitAxisTrans::Class()))
4186  else
4187 
4188  new QFitItem(this, item, obj, FitGui::ot_none, FitGui::wt_none, FitGui::mt_none);
4189 
4190  break;
4191  }
4192  case FitGui::ot_fitter: {
4193  TGo4Fitter *fitter = dynamic_cast<TGo4Fitter *>(item->Object());
4194  if (!fitter)
4195  break;
4196 
4197  new QFitItem(this, item, fitter, FitGui::ot_results, FitGui::wt_table);
4202  break;
4203  }
4204  case FitGui::ot_trans: FillParsList(item); break;
4205  case FitGui::ot_lintrans: FillParsList(item); break;
4206  case FitGui::ot_matrtrans: FillParsList(item); break;
4207  case FitGui::ot_results: break;
4208  case FitGui::ot_allslots: {
4209  TGo4Fitter *fitter = dynamic_cast<TGo4Fitter *>(item->Object());
4210  if (fitter)
4211  FillSlotsList(item, fitter->GetSlotList(), nullptr);
4212  break;
4213  }
4214  }
4215 
4216  if (trace && item->Object()) {
4217  QFitItem *topitem = GetFitterItem();
4218  if (!topitem)
4219  return;
4220 
4221  QTreeWidgetItemIterator iter(topitem);
4222 
4223  while (*iter) {
4224  QFitItem *it = dynamic_cast<QFitItem *>(*iter);
4225  if (it && (it != item) && (item->ObjectType() == it->ObjectType()) && (item->Object() == it->Object()))
4226  UpdateItem(it, false);
4227  ++iter;
4228  }
4229  }
4230 }
4231 
4232 void TGo4FitPanel::SetItemText(QFitItem *item, bool trace)
4233 {
4234  if (!item)
4235  return;
4236  QString text;
4237  if (item->Object())
4238  text = item->Object()->GetName();
4239  switch (item->ObjectType()) {
4240  case FitGui::ot_empty: text = "empty"; break;
4241  case FitGui::ot_datalist: text = "Data"; break;
4242  case FitGui::ot_data: break;
4243  case FitGui::ot_modellist: text = "Models"; break;
4244  case FitGui::ot_model: break;
4245  case FitGui::ot_parslist: text = "Parameters"; break;
4246  case FitGui::ot_par:
4247  case FitGui::ot_parcfg: {
4248  TGo4FitParameter *par = dynamic_cast<TGo4FitParameter *>(item->Object());
4249  if (par)
4250  text += " = " + QString::number(par->GetValue());
4251  break;
4252  }
4253  case FitGui::ot_asslist: text = "Assigments"; break;
4254  case FitGui::ot_ass: {
4255  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(item->Object());
4256  if (model)
4257  text = model->AssignmentName(item->Tag());
4258  break;
4259  }
4260  case FitGui::ot_rangelist: text = "Ranges"; break;
4261  case FitGui::ot_range: {
4262  TGo4FitComponent *comp = dynamic_cast<TGo4FitComponent *>(item->Object());
4263  if (!comp || (item->Tag() < 0) || (item->Tag() >= comp->GetNumRangeCondition()))
4264  break;
4265 
4266  Int_t typ, naxis;
4267  Double_t left, right;
4268  comp->GetRangeCondition(item->Tag(), typ, naxis, left, right);
4269  text = QString::number(naxis) + ": ";
4270 
4271  switch (typ) {
4272  case 0: text += "[" + QString::number(left) + "..." + QString::number(right) + "]"; break;
4273  case 1: text += "... " + QString::number(left) + "] [" + QString::number(right) + " ..."; break;
4274  case 2: text += "[" + QString::number(left) + " ..."; break;
4275  case 3: text += "... " + QString::number(right) + "]"; break;
4276  }
4277  break;
4278  }
4279  case FitGui::ot_rangecut: break;
4280  case FitGui::ot_actlist: text = "Actions"; break;
4281  case FitGui::ot_action: break;
4282  case FitGui::ot_amplest: break;
4283  case FitGui::ot_peakfinder: break;
4284  case FitGui::ot_output: break;
4285  case FitGui::ot_config: break;
4286  case FitGui::ot_minuit: break;
4287  case FitGui::ot_parinitlist: text = "Initialization"; break;
4288  case FitGui::ot_pardeplist: text = "Dependency"; break;
4289  case FitGui::ot_reslist: text = "Results"; break;
4290  case FitGui::ot_depend: {
4291  TGo4FitDependency *depen = dynamic_cast<TGo4FitDependency *>(item->Object());
4292  if (!depen)
4293  break;
4294  if (depen->IsResultDepend())
4295  text = "Res" + QString::number(item->Tag());
4296  else
4297  text = depen->GetParameter().Data();
4298  text += " = ";
4299  if (depen->IsInitValue())
4300  text += QString::number(depen->GetInitValue());
4301  else
4302  text += depen->GetExpression().Data();
4303  break;
4304  }
4305  case FitGui::ot_newpars: text = "New pars"; break;
4306  case FitGui::ot_parscfg: text = "Pars setup"; break;
4307  case FitGui::ot_minuitres: break;
4308  case FitGui::ot_slot: break;
4309  case FitGui::ot_fitter: break;
4310  case FitGui::ot_trans: break;
4311  case FitGui::ot_lintrans: break;
4312  case FitGui::ot_matrtrans: break;
4313  case FitGui::ot_results: text = "Results"; break;
4314  case FitGui::ot_allslots: text = "Objects"; break;
4315  }
4316 
4317  item->setText(0, text);
4318 
4319  if (trace && item->Object()) {
4320  QFitItem *topitem = GetFitterItem();
4321  if (!topitem)
4322  return;
4323 
4324  QTreeWidgetItemIterator iter(topitem);
4325 
4326  while (*iter) {
4327  QFitItem *it = dynamic_cast<QFitItem *>(*iter);
4328  if (it && (it != item) && (item->ObjectType() == it->ObjectType()) && (item->Object() == it->Object()) &&
4329  (item->Tag() == it->Tag()))
4330  it->setText(0, text);
4331  ++iter;
4332  }
4333  }
4334 }
4335 
4337 {
4338  if (!parent)
4339  parent = GetFitterItem();
4340 
4341  if (!parent) {
4342  std::cout << "Did not found " << std::endl;
4343  return;
4344  }
4345 
4346  QTreeWidgetItemIterator iter(parent);
4347 
4348  while (*iter) {
4349  QFitItem *item = dynamic_cast<QFitItem *>(*iter);
4350  if (item && (item->ObjectType() == typ))
4351  UpdateItem(item, false);
4352  ++iter;
4353  }
4354 }
4355 
4357 {
4358  QFitItem *item = dynamic_cast<QFitItem *>(FitList->topLevelItem(0));
4359  if (item && (item->ObjectType() == FitGui::ot_fitter))
4360  return item;
4361  return nullptr;
4362 }
4363 
4364 QFitItem *TGo4FitPanel::FindItem(TObject *obj, int ObjectType, QFitItem *parent)
4365 {
4366  if (!parent)
4367  parent = GetFitterItem();
4368 
4369  QTreeWidgetItemIterator iter(parent);
4370 
4371  while (*iter) {
4372  QFitItem *item = dynamic_cast<QFitItem *>(*iter);
4373  if (item)
4374  if (!obj || (item->Object() == obj))
4375  if ((ObjectType == FitGui::ot_none) || (ObjectType == item->ObjectType()))
4376  return item;
4377  ++iter;
4378  }
4379  return nullptr;
4380 }
4381 
4382 bool TGo4FitPanel::ShowItem(QFitItem *item, bool force)
4383 {
4384  if (force)
4385  RemoveItemWidget();
4386 
4387  bool gr = false;
4388 
4389  RemovePrimitives();
4390  if (fbShowPrimitives)
4391  gr = ShowItemAsGraph(item, force);
4392 
4393  bool txt = ShowItemAsText(item, force);
4394 
4395  return gr || txt;
4396 }
4397 
4399 {
4400 
4401  QFitItem *widgetitem = item->DefineWidgetItem();
4402 
4403  QFitWidget *oldwidget = dynamic_cast<QFitWidget *>(fxCurrentItemWidget);
4404  if (oldwidget && (oldwidget->GetItem() == widgetitem)) {
4405  oldwidget->FillWidget();
4406  return true;
4407  }
4408 
4409  RemoveItemWidget();
4410 
4411  QFitWidget *widget = nullptr;
4412 
4413  if (!widgetitem)
4414  return true;
4415 
4416  QWidget *owner = nullptr;
4417 
4418  switch (widgetitem->WidgetType()) {
4419  case FitGui::wt_par: widget = new QFitParWidget(owner, "Parameter"); break;
4420  case FitGui::wt_range: widget = new QFitRangeWidget(owner, "Range"); break;
4421  case FitGui::wt_rangecut: widget = new QFitRangeCutWidget(owner, "Range cut"); break;
4422  case FitGui::wt_data: widget = new QFitDataWidget(owner, "Data object"); break;
4423  case FitGui::wt_model: widget = new QFitModelWidget(owner, "Model"); break;
4424  case FitGui::wt_polynom: widget = new QFitModelPolynomWidget(owner, "Polynom"); break;
4425  case FitGui::wt_gauss1: widget = new QFitModelGauss1Widget(owner, "Gauss1"); break;
4426  case FitGui::wt_gauss2: widget = new QFitModelGauss2Widget(owner, "Gauss2"); break;
4427  case FitGui::wt_gaussn: widget = new QFitModelGaussNWidget(owner, "GaussN"); break;
4428  case FitGui::wt_formula: widget = new QFitModelFormulaWidget(owner, "Formula"); break;
4429  case FitGui::wt_function: widget = new QFitModelFunctionWidget(owner, "Function"); break;
4430  case FitGui::wt_amplest: widget = new QFitAmplEstimWidget(owner, "Amplitude estimation"); break;
4431  case FitGui::wt_peakfinder: widget = new QFitPeakFinderWidget(owner, "Peak finder"); break;
4432  case FitGui::wt_output: widget = new QFitOutputActionWidget(owner, "Fitter output"); break;
4433  case FitGui::wt_minuit: widget = new QFitMinuitWidget(owner, "Minuit"); break;
4434  case FitGui::wt_minuitres: widget = new QFitMinuitResWidget(owner, "Minuit result"); break;
4435  case FitGui::wt_depend: widget = new QFitDependencyWidget(owner, "Dependency"); break;
4436  case FitGui::wt_parcfg: widget = new QFitParCfgWidget(owner, "Parameter configuration"); break;
4437  case FitGui::wt_slot: widget = new QFitSlotWidget(owner, "Slot for external object"); break;
4438  case FitGui::wt_fitter: widget = new QFitterWidget(owner, "Fitter"); break;
4439  case FitGui::wt_named: widget = new QFitNamedWidget(owner, "Named object"); break;
4440  case FitGui::wt_table: widget = new QFitTableWidget(owner, "Table"); break;
4441  case FitGui::wt_lintrans: widget = new QFitLinearTransWidget(owner, "Simple transform"); break;
4442  case FitGui::wt_matrtrans: widget = new QFitMatrixTransWidget(owner, "Matrix transform"); break;
4443  }
4444 
4445  if (widget) {
4446  fxCurrentItemWidget = widget;
4447  widget->SetItem(this, widgetitem);
4448  ListStack->addWidget(widget);
4449  ListStack->setCurrentWidget(widget);
4450  }
4451 
4452  return true;
4453 }
4454 
4456 {
4457  if (!item)
4458  return false;
4459 
4460  QFitItem *gritem = item->DefineGraphItem();
4461 
4462  if (!gritem)
4463  return false;
4464 
4465  TGo4Fitter *fitter = GetFitter();
4466  if (!fitter)
4467  return false;
4468 
4469  if (gritem->GraphType() == FitGui::gt_fitter) {
4470  PaintFitter(fitter, gritem, false);
4471  return true;
4472  }
4473 
4474  if (gritem->GraphType() == FitGui::gt_data) {
4475  TGo4FitData *data = dynamic_cast<TGo4FitData *>(gritem->Object());
4476 
4477  if (data)
4478  PaintModelsFor(fitter, data, gritem->Parent()->Parent(), false);
4479 
4480  return data != nullptr;
4481  }
4482 
4483  if (gritem->GraphType() == FitGui::gt_model) {
4484  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(gritem->Object());
4485  if (!model)
4486  return false;
4487  bool draw = false;
4488  for (Int_t n = 0; n < model->NumAssigments(); n++) {
4489  TGo4FitData *data = fitter->FindData(model->AssignmentName(n));
4490  if (PaintModel(model, FindPadWhereData(data), gritem))
4491  draw = true;
4492  }
4493  return draw;
4494  }
4495 
4496  if (gritem->GraphType() == FitGui::gt_ass) {
4497  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(gritem->Parent()->Parent()->Object());
4498  if (model) {
4499  TGo4FitData *data = fitter->FindData(gritem->text(0).toLatin1().constData());
4500  if (PaintModel(model, FindPadWhereData(data), gritem->Parent()->Parent()))
4501  return true;
4502  }
4503  }
4504 
4505  if (gritem->GraphType() == FitGui::gt_range) {
4506  TGo4FitComponent *comp = dynamic_cast<TGo4FitComponent *>(gritem->Parent()->Object());
4507  if (!comp)
4508  return false;
4509  int nrange = gritem->Tag();
4510  if (PaintRange(comp, nrange, FindPadWhereComp(comp), gritem))
4511  return true;
4512  }
4513 
4514  if (gritem->GraphType() == FitGui::gt_ranges) {
4515  TGo4FitComponent *comp = dynamic_cast<TGo4FitComponent *>(gritem->Object());
4516  if (!comp)
4517  return false;
4518 
4519  TPad *pad = FindPadWhereComp(comp);
4520  if (pad) {
4521  for (int nrange = 0; nrange < comp->GetNumRangeCondition(); nrange++) {
4522  QFitItem *child = dynamic_cast<QFitItem *>(gritem->child(nrange));
4523  if (!child)
4524  return false;
4525  PaintRange(comp, nrange, pad, child);
4526  }
4527  return true;
4528  }
4529  }
4530 
4531  return false;
4532 }
4533 
4535 {
4536  fxCurrentItem = nullptr;
4537  if (fxCurrentItemWidget) {
4538  ListStack->removeWidget(fxCurrentItemWidget);
4539  delete fxCurrentItemWidget;
4540  fxCurrentItemWidget = nullptr;
4541  }
4542 }
4543 
4545 {
4546  if (item && (fxCurrentItem == item))
4547  RemoveItemWidget();
4548 }
4549 
4551 {
4552  if (!item)
4553  return;
4554  TGo4FitParsList *pars = dynamic_cast<TGo4FitParsList *>(item->Object());
4555  if (!pars)
4556  return;
4557  for (Int_t n = pars->NumPars() - 1; n >= 0; n--)
4558  new QFitItem(this, item, pars->GetPar(n), FitGui::ot_par, FitGui::wt_par, FitGui::mt_par);
4559 }
4560 
4561 void TGo4FitPanel::FillSlotsList(QFitItem *parent, const TObjArray *lst, TObject *owner)
4562 {
4563  if (!parent || !lst)
4564  return;
4565  for (Int_t n = lst->GetLast(); n >= 0; n--) {
4566  TGo4FitSlot *slot = dynamic_cast<TGo4FitSlot *>(lst->At(n));
4567  if (slot && ((slot->GetOwner() == owner) || !owner))
4568  new QFitItem(this, parent, slot, FitGui::ot_slot, FitGui::wt_slot, FitGui::mt_slot);
4569  }
4570 }
4571 
4573 {
4574  if (!parent)
4575  return;
4576 
4577  TObjArray *lst = dynamic_cast<TObjArray *>(parent->Object());
4578  if (lst)
4579  for (Int_t n = lst->GetLast(); n >= 0; n--)
4580  new QFitItem(this, parent, lst->At(n), FitGui::ot_depend, FitGui::wt_depend, FitGui::mt_depend,
4581  FitGui::gt_none, n);
4582 }
4583 
4584 void TGo4FitPanel::FillModelTypesList(QMenu *menu, int id, bool extend, const QString &handler)
4585 {
4586  if (!menu->isEmpty())
4587  menu->addSeparator();
4588  if (extend) {
4589  AddItemAction(menu, "Add gaussian", id + 20, handler);
4590  AddItemAction(menu, "Add lorenzian", id + 24, handler);
4591  AddItemAction(menu, "Add exponent", id + 25, handler);
4592  AddItemAction(menu, "Add 1-order polynom", id + 21, handler);
4593  AddItemAction(menu, "Add 3-order polynom", id + 22, handler);
4594  AddItemAction(menu, "Add 7-order polynom", id + 23, handler);
4595  menu->addSeparator();
4596  }
4597 
4598  AddItemAction(menu, QString("Make ") + TGo4FitModelPolynom::Class()->GetName(), id + 0, handler);
4599  AddItemAction(menu, QString("Make ") + TGo4FitModelGauss1::Class()->GetName(), id + 1, handler);
4600  AddItemAction(menu, QString("Make ") + TGo4FitModelGauss2::Class()->GetName(), id + 2, handler);
4601  AddItemAction(menu, QString("Make ") + TGo4FitModelGaussN::Class()->GetName(), id + 3, handler);
4602  AddItemAction(menu, QString("Make ") + TGo4FitModelFormula::Class()->GetName(), id + 4, handler);
4603  AddItemAction(menu, QString("Make ") + TGo4FitModelFunction::Class()->GetName(), id + 5, handler);
4604  AddItemAction(menu, QString("Make ") + TGo4FitModelFromData::Class()->GetName(), id + 6, handler);
4605 }
4606 
4607 void TGo4FitPanel::FillDataTypesList(QMenu *menu, int id, const QString &handler)
4608 {
4609  if (!menu->isEmpty())
4610  menu->addSeparator();
4611  AddItemAction(menu, QString("Make ") + TGo4FitDataHistogram::Class()->GetName(), id + 0, handler);
4612  AddItemAction(menu, QString("Make ") + TGo4FitDataGraph::Class()->GetName(), id + 1, handler);
4613  AddItemAction(menu, QString("Make ") + TGo4FitDataProfile::Class()->GetName(), id + 2, handler);
4614  AddItemAction(menu, QString("Make ") + TGo4FitDataRidge::Class()->GetName(), id + 3, handler);
4615 }
4616 
4617 void TGo4FitPanel::PaintFitter(TGo4Fitter *fitter, QFitItem *item, bool update)
4618 {
4619  if (fitter)
4620  for (Int_t nd = 0; nd < fitter->GetNumData(); nd++)
4621  PaintModelsFor(fitter, fitter->GetData(nd), item, update);
4622 }
4623 
4624 bool TGo4FitPanel::PaintModel(TGo4FitModel *model, TPad *pad, QFitItem *item)
4625 {
4626  if (!model || !pad || !fbShowPrimitives)
4627  return false;
4628 
4629  TH1 *histo = ActivePanel()->GetPadHistogram(pad);
4630  if (!histo || (histo->GetDimension() != 1))
4631  return false;
4632 
4633  Double_t pos, width, ampl;
4634 
4635  if (model->GetPosition(0, pos)) {
4636 
4637  Int_t nbin = histo->GetXaxis()->FindBin(pos);
4638  ampl = histo->GetBinContent(nbin);
4639 
4640  Double_t limit = pad->GetUymin() * .7 + pad->GetUymax() * .3;
4641  if (ampl < limit)
4642  ampl = limit;
4643 
4644  TGo4FitGuiArrow *arr = new TGo4FitGuiArrow(0.01, ">");
4645  arr->SetLineColor(2);
4646  arr->SetLineWidth(1);
4647  arr->SetItem(item, this);
4648 
4649  TGo4FitGuiArrow *warr = nullptr;
4650  if (model->GetWidth(0, width)) {
4651  warr = new TGo4FitGuiArrow(0.01, "<|>");
4652  warr->SetLineColor(2);
4653  warr->SetLineWidth(1);
4654  warr->SetForWidth(model, arr);
4655  warr->SetItem(item, this);
4656  }
4657 
4658  arr->SetForPosition(model, warr, ampl);
4659  arr->Locate();
4660 
4661  ActivePanel()->AddDrawObject(pad, TGo4ViewPanel::kind_FitArrows, "::Model_VArrow", arr, true, nullptr);
4662 
4663  if (warr) {
4664  warr->Locate();
4665  ActivePanel()->AddDrawObject(pad, TGo4ViewPanel::kind_FitArrows, "::Model_HArrow", warr, true, nullptr);
4666  }
4667 
4669  }
4670 
4671  return true;
4672 }
4673 
4674 bool TGo4FitPanel::PaintModelsFor(TGo4Fitter *fitter, TGo4FitData *data, QFitItem *item, bool update)
4675 {
4676  if (!fitter || !data)
4677  return false;
4678 
4679  if (data->IsAnyDataTransform())
4680  return false;
4681 
4682  for (Int_t nm = 0; nm < fitter->GetNumModel(); nm++) {
4683  TGo4FitModel *model = fitter->GetModel(nm);
4684  if (model->IsAssignTo(data->GetName()))
4685  PaintModel(model, FindPadWhereData(data), item);
4686  }
4687 
4688  return true;
4689 }
4690 
4691 bool TGo4FitPanel::PaintRange(TGo4FitComponent *comp, int nrange, TPad *pad, QFitItem *item)
4692 {
4693  if (!comp || !pad || !fbShowPrimitives)
4694  return false;
4695 
4696  TH1 *histo = ActivePanel()->GetPadHistogram(pad);
4697 
4698  if (!histo || (histo->GetDimension() != 1))
4699  return false;
4700 
4701  double range = 0.1 * (histo->GetXaxis()->GetXmax() - histo->GetXaxis()->GetXmin());
4702 
4703  double ampl = (0.07 + nrange * 0.02) * (histo->GetMaximum() - histo->GetMinimum()) + histo->GetMinimum();
4704 
4705  double size = 0.015;
4706 
4707  Int_t typ, naxis;
4708  Double_t left, right;
4709 
4710  comp->GetRangeCondition(nrange, typ, naxis, left, right);
4711 
4712  if (naxis != 0)
4713  return false;
4714 
4715  TGo4FitGuiArrow *arr = nullptr;
4716 
4717  switch (typ) {
4718  case 0: arr = new TGo4FitGuiArrow(size, "<|>"); break;
4719  case 1: arr = new TGo4FitGuiArrow(size, "-><-"); break;
4720  case 2: arr = new TGo4FitGuiArrow(size, "<"); break;
4721  case 3: arr = new TGo4FitGuiArrow(size, ">"); break;
4722  }
4723 
4724  if (arr) {
4725  arr->SetLineColor(3);
4726  arr->SetLineWidth(3);
4727  arr->SetForRange(comp, nrange, ampl, range);
4728  arr->SetItem(item, this);
4729  arr->Locate();
4730 
4731  ActivePanel()->AddDrawObject(pad, TGo4ViewPanel::kind_FitArrows, "::Range_Arrow", arr, true, nullptr);
4732 
4734  }
4735  return arr != nullptr;
4736 }
4737 
4739 {
4740  TGo4Fitter *fitter = GetFitter();
4741  if (!fitter)
4742  return nullptr;
4743  for (Int_t n = 0; n < fitter->GetNumActions(); n++) {
4744  TGo4FitPeakFinder *finder = dynamic_cast<TGo4FitPeakFinder *>(fitter->GetAction(n));
4745  if (finder)
4746  return finder;
4747  }
4748 
4749  if (autocreate) {
4750  TGo4FitPeakFinder *finder = new TGo4FitPeakFinder("Finder", nullptr, kTRUE, 1);
4751  finder->SetPeakFinderType(2);
4752  fitter->AddActionAt(finder, 0);
4753  return finder;
4754  }
4755 
4756  return nullptr;
4757 }
4758 
4760 {
4761  TGo4Fitter *fitter = GetFitter();
4762  return !fitter ? nullptr : fitter->FindData(fxWizDataName.toLatin1().constData());
4763 }
4764 
4766 {
4767  TGo4Fitter *fitter = GetFitter();
4768  return !fitter ? nullptr : fitter->FindModel(fxWizModelName.toLatin1().constData());
4769 }
4770 
4772 {
4773  TGo4Fitter *fitter = GetFitter();
4774  TGo4FitModel *model = nullptr;
4775  if (fitter) {
4776  auto data = Wiz_SelectedData();
4777  model = CreateModel(id, nullptr, fitter, data);
4778  LocateModel(model, data, true);
4779  }
4780 
4781  if (model)
4782  fxWizModelName = model->GetName();
4783  UpdateWizModelsList(true);
4784  if (Wiz_SelectedModel())
4785  UpdateWizPaint(2);
4786  UpdateStatusBar();
4787 }
4788 
4790 {
4791  TGo4Fitter *fitter = GetFitter();
4792  if (!fitter)
4793  return;
4794 
4795  TGo4FitData *data = CreateData(id, nullptr);
4796  if (!data)
4797  return;
4798 
4799  fitter->AddData(data);
4800 
4802 
4803  fxWizDataName = data->GetName();
4804  fiWizPageIndex = 2;
4806  UpdateWizModelsList(false);
4808  UpdateWizPaint(1);
4809  UpdateStatusBar();
4810 }
4811 
4813 {
4814  TGo4Fitter *fitter = GetFitter();
4815  if (!fitter)
4816  return;
4817  if (fitter->GetNumData() > 0)
4818  if (checkConfirm("Rebuild data list", "Remove all current data?"))
4819  return;
4820 
4821  fitter->DeleteAllData();
4822  CreateDataFor(ActivePanel(), ActivePad(), fitter);
4823 
4825  UpdateActivePage();
4826 }
4827 
4829 {
4830  TGo4Fitter *fitter = GetFitter();
4831  TGo4FitData *data = Wiz_SelectedData();
4832  if (!data || !fitter)
4833  return false;
4834 
4835  if (checkConfirm("Delete data", QString("Are you sure to delete ") + data->GetName()))
4836  return false;
4837 
4838  fitter->RemoveData(data->GetName(), kTRUE);
4839 
4840  fxWizDataName = "";
4841 
4843 
4844  return true;
4845 }
4846 
4848 {
4849  if (!WorkingWithPanel())
4850  return;
4851 
4852  TGo4FitData *data = Wiz_SelectedData();
4853  TPad *pad = FindPadWhereData(data);
4854  if (!pad || !data)
4855  return;
4856 
4857  double xmin, xmax;
4858  if (ActivePanel()->GetVisibleRange(pad, 0, xmin, xmax))
4859  data->SetRange(0, xmin, xmax);
4860 
4861  UpdateActivePage();
4862 }
4863 
4865 {
4866  TGo4Fitter *fitter = GetFitter();
4867  if (!fitter || !ActivePanel())
4868  return;
4869 
4870  for (int n = 0; n < fitter->GetNumData(); n++) {
4871  TGo4FitData *data = fitter->GetData(n);
4872  TPad *pad = FindPadWhereData(data);
4873 
4874  if (pad && data) {
4875  data->ClearRanges();
4876  double xmin, xmax;
4877  if (ActivePanel()->GetVisibleRange(pad, 0, xmin, xmax))
4878  data->SetRange(0, xmin, xmax);
4879  }
4880  }
4881 }
4882 
4884 {
4885  if (!model || !info)
4886  return;
4887  *info = "Model: ";
4888  *info += model->GetName();
4889  *info += " of class: ";
4890  *info += model->ClassName();
4891 
4892  if (model->InheritsFrom(TGo4FitModelFormula::Class())) {
4893  TGo4FitModelFormula *formula = dynamic_cast<TGo4FitModelFormula *>(model);
4894  if (formula) {
4895  *info += "\nFormula: ";
4896  *info += formula->GetExpression();
4897  }
4898  }
4899 
4900  if (model->InheritsFrom(TGo4FitModelFunction::Class())) {
4901  TGo4FitModelFunction *func = dynamic_cast<TGo4FitModelFunction *>(model);
4902  if (func) {
4903  *info += "\nFunction: ";
4904  *info += func->GetFunctionName();
4905  *info += " from: ";
4906  *info += func->GetLibraryName();
4907  }
4908  }
4909  if (fiIntegralMode > 0) {
4910  int mode = fiIntegralMode;
4911 
4912  if ((mode == 1) || (mode == 2)) {
4913  TGo4Fitter *fitter = GetFitter();
4914  TGo4FitData *data = Wiz_SelectedData();
4915  if (data)
4916  if (!model->IsAssignTo(data->GetName()))
4917  data = nullptr;
4918  if (data && fitter) {
4919  if (mode == 1)
4920  *info += "\nCounts=";
4921  else
4922  *info += "\nIntegral=";
4923  double v = fitter->CalculatesIntegral(data->GetName(), model->GetName(), (mode == 1));
4924  *info += QString::number(v);
4925  }
4926  }
4927 
4928  if (mode == 3) {
4929  double v = model->Integral();
4930  if (v > 0) {
4931  *info += "\nGauss integral=";
4932  *info += QString::number(v);
4933  }
4934  }
4935  }
4936 }
4937 
4939 {
4940  QString res = "";
4941  if (!slot)
4942  return res;
4943 
4944  if (!slot->GetObject()) {
4945  res = "none";
4946  } else if (slot->GetOwned()) {
4947  res = "internal object";
4948  } else if (WorkingWithPanel()) {
4949  TPad *pad = FindPadForSlot(slot);
4950  if (!pad)
4951  res = "reference without pad";
4952  else {
4953  res = "Panel: ";
4954  res += ActivePanel()->objectName();
4955  if (ActivePanel()->GetCanvas() != pad) {
4956  res += " pad: ";
4957  res += pad->GetName();
4958  }
4959  }
4960  } else {
4961  int slotindex = GetPadIndexForSlot(slot);
4962  QString linkname = QString("FitSlotLink_%1").arg(slotindex);
4963  const char *itemname = GetLinkedName(linkname.toLatin1().constData());
4964  if (itemname)
4965  res = itemname;
4966  else
4967  res = "reference to external object";
4968  }
4969 
4970  return res;
4971 }
4972 
4974 {
4975  TGo4Fitter *fitter = GetFitter();
4976 
4977  if (!arr || !fitter)
4978  return;
4979 
4980  bool ismodified = false;
4981  for (Int_t n = 0; n < fitter->NumSlots(); n++) {
4982  TPad *pad = FindPadForSlot(fitter->GetSlot(n));
4983  if (!pad)
4984  continue;
4985 
4986  TObjArray lst;
4988 
4989  bool res = false;
4990  for (Int_t k = 0; k <= lst.GetLast(); k++) {
4991  TGo4FitGuiArrow *a = dynamic_cast<TGo4FitGuiArrow *>(lst[k]);
4992  if (!a)
4993  continue;
4994  if (a->Locate())
4995  res = true;
4996  }
4997  if (res) {
4998  ActivePanel()->MarkPadModified(pad);
4999  ismodified = true;
5000  }
5001  }
5002  if (ismodified)
5004 
5005  if (fiPanelMode == FitGui::pm_Expert) {
5006  if ((arr->GetType() == TGo4FitGuiArrow::at_pos) || (arr->GetType() == TGo4FitGuiArrow::at_width))
5008 
5009  if (arr->GetType() == TGo4FitGuiArrow::at_range)
5010  SetItemText(arr->GetItem(), true);
5011 
5012  QFitWidget *current = dynamic_cast<QFitWidget *>(fxCurrentItemWidget);
5013  if (current)
5014  current->FillWidget();
5015  }
5016 
5017  if (fiPanelMode == FitGui::pm_Wizard) {
5018  if (fbParsWidgetShown)
5019  FillParsWidget();
5020  else
5022  }
5023 }
5024 
5026 {
5027  if (!arr)
5028  return;
5029  TGo4FitModel *model = arr->GetModel();
5030  if (!model)
5031  return;
5032 
5033  if (fiPanelMode == FitGui::pm_Expert) {
5034  QFitItem *item = FindItem(model, FitGui::ot_model, nullptr);
5035  if (item)
5036  Cmd_DeleteModel(item);
5037  } else
5038  Cmd_RemoveModel(model);
5039 }
5040 
5042 {
5043  TGo4Fitter *fitter = GetFitter();
5044  if (!slot || !fitter)
5045  return -1;
5046 
5047  int indx = -1;
5048  for (int n = 0; n < fitter->NumSlots(); n++) {
5049  TGo4FitSlot *subslot = fitter->GetSlot(n);
5050  bool needpad = !subslot->GetOwned() && (subslot->GetClass()->InheritsFrom(TH1::Class()) ||
5051  subslot->GetClass()->InheritsFrom(TGraph::Class()));
5052  if (needpad)
5053  indx++;
5054  if (slot == subslot)
5055  return needpad ? indx : -1;
5056  }
5057  return -1;
5058 }
5059 
5061 {
5062  if (!WorkingWithPanel())
5063  return nullptr;
5064  int indx = GetPadIndexForSlot(slot);
5065  return (indx < 0) ? nullptr : ActivePanel()->GetSubPad(ActivePad(), indx, true);
5066 }
5067 
5069 {
5070  TGo4Fitter *fitter = GetFitter();
5071  if (!fitter)
5072  return nullptr;
5073  for (Int_t n = 0; n < fitter->NumSlots(); n++) {
5074  TGo4FitSlot *slot = fitter->GetSlot(n);
5075  if (slot->GetOwner() != data)
5076  continue;
5077  TPad *pad = FindPadForSlot(slot);
5078  if (pad)
5079  return pad;
5080  }
5081  return nullptr;
5082 }
5083 
5085 {
5086  TGo4Fitter *fitter = GetFitter();
5087  if (!fitter || !model)
5088  return nullptr;
5089 
5090  for (Int_t n = 0; n < model->NumAssigments(); n++) {
5091  TGo4FitData *data = fitter->FindData(model->AssignmentName(n));
5092  TPad *pad = FindPadWhereData(data);
5093  if (pad)
5094  return pad;
5095  }
5096  return nullptr;
5097 }
5098 
5100 {
5101  if (!comp)
5102  return nullptr;
5103  if (comp->InheritsFrom(TGo4FitData::Class()))
5104  return FindPadWhereData(dynamic_cast<TGo4FitData *>(comp));
5105  else
5106  return FindPadWhereModel(dynamic_cast<TGo4FitModel *>(comp));
5107 }
5108 
5109 TGo4FitData *TGo4FitPanel::CreateData(int id, const char *name)
5110 {
5111  TString dataname;
5112 
5113  if (!name) {
5114  TGo4Fitter *fitter = GetFitter();
5115  if (!fitter)
5116  return nullptr;
5117  dataname = fitter->FindNextName("Data", 0, kFALSE);
5118  } else
5119  dataname = name;
5120 
5121  switch (id) {
5122  case 0: return new TGo4FitDataHistogram(dataname);
5123  case 1: return new TGo4FitDataGraph(dataname);
5124  case 2: return new TGo4FitDataProfile(dataname);
5125  case 3: return new TGo4FitDataRidge(dataname);
5126  }
5127  return nullptr;
5128 }
5129 
5130 TGo4FitModel *TGo4FitPanel::CreateModel(int id, const char *namebase, TGo4Fitter *fitter, TGo4FitData *data)
5131 {
5132  TString NameBase;
5133 
5134  if (fitter)
5135  if (!data && (fitter->GetNumData() > 0))
5136  data = fitter->GetData(0);
5137  Int_t NumDim = 0;
5138  if (data)
5139  NumDim = data->DefineDimensions();
5140  if (NumDim <= 0)
5141  NumDim = 1;
5142 
5143  Int_t order = 0;
5144  switch (id) {
5145  case 20: // gaussian
5146  switch (NumDim) {
5147  case 1: id = 1; break;
5148  case 2: id = 2; break;
5149  default: id = 3; break;
5150  }
5151  break;
5152  case 21:
5153  order = 1;
5154  id = 7;
5155  break; // polynom 1
5156  case 22:
5157  order = 3;
5158  id = 7;
5159  break; // polynom 3
5160  case 23:
5161  order = 7;
5162  id = 7;
5163  break; // polynom 7
5164  }
5165 
5166  if (namebase)
5167  NameBase = namebase;
5168  else
5169  switch (id) {
5170  case 0: NameBase = "Pol"; break;
5171  case 1:
5172  case 2:
5173  case 3: NameBase = "Gauss"; break;
5174  case 4: NameBase = "Form"; break;
5175  case 5: NameBase = "Func"; break;
5176  case 6: NameBase = "FromData"; break;
5177  case 7: NameBase = "Pol"; break;
5178  case 24: NameBase = "Lor"; break;
5179  case 25: NameBase = "Exp"; break;
5180  default: NameBase = "Model";
5181  }
5182 
5183  TString ModelName;
5184 
5185  if (fitter && (id != 7))
5186  ModelName = fitter->FindNextName(NameBase.Data(), 0);
5187  else
5188  ModelName = NameBase;
5189 
5190  TGo4FitModel *model = nullptr;
5191 
5192  switch (id) {
5193  case 0: model = new TGo4FitModelPolynom(ModelName); break;
5194  case 1: model = new TGo4FitModelGauss1(ModelName); break;
5195  case 2: model = new TGo4FitModelGauss2(ModelName); break;
5196  case 3: model = new TGo4FitModelGaussN(ModelName, NumDim < 3 ? 3 : NumDim); break;
5197  case 4: model = new TGo4FitModelFormula(ModelName); break;
5198  case 5: model = new TGo4FitModelFunction(ModelName); break;
5199  case 6: model = new TGo4FitModelFromData(ModelName); break;
5200  case 7: fitter->AddPolynoms(data ? data->GetName() : nullptr, NameBase.Data(), order, NumDim); break;
5201  case 24: {
5202  TGo4FitModelFormula *formula = new TGo4FitModelFormula(ModelName, "1./(1.+sq((x-Pos)/Width))", 2, kTRUE);
5203  formula->SetParsNames("Ampl", "Pos", "Width");
5204  formula->SetPosParIndex(0, 0);
5205  formula->SetWidthParIndex(0, 1);
5206  model = formula;
5207  break;
5208  }
5209  case 25: {
5210  model = new TGo4FitModelFormula(ModelName, "exp(Koef*x)", 1, kTRUE);
5211  model->SetParsNames("Ampl", "Koef");
5212  break;
5213  }
5214  }
5215 
5216  if (fitter && model) {
5217  if (data)
5218  model->AssignToData(data->GetName());
5219  fitter->AddModel(model);
5220  }
5221 
5222  return model;
5223 }
5224 
5225 void TGo4FitPanel::LocateModel(TGo4FitModel *model, TGo4FitData *data, bool usepad)
5226 {
5227  TGo4Fitter *fitter = GetFitter();
5228 
5229  if (!fitter || !model)
5230  return;
5231 
5232  if (!data)
5233  for (int n = 0; n <= model->NumAssigments(); n++) {
5234  data = fitter->FindData(model->AssignmentName(n));
5235  if (!usepad || FindPadWhereData(data))
5236  break;
5237  }
5238  if (!data)
5239  return;
5240 
5241  if (!usepad && data->DefineDimensions() != 1)
5242  usepad = true;
5243 
5244  if (usepad) {
5245  TPad *pad = FindPadWhereData(data);
5246  if (pad) {
5247  model->SetPosition(0, (pad->GetUxmin() + pad->GetUxmax()) / 2.);
5248  model->SetWidth(0, TMath::Abs(pad->GetUxmax() - pad->GetUxmin()) * .05);
5249  model->SetPosition(1, (pad->GetUymin() + pad->GetUymax()) / 2.);
5250  model->SetWidth(1, TMath::Abs(pad->GetUymax() - pad->GetUymin()) * .05);
5251  }
5252  } else {
5253  Double_t mid, width;
5254  if (fitter->CalculatesMomentums(data->GetName(), kTRUE, kTRUE, mid, width)) {
5255  model->SetPosition(0, mid);
5256  model->SetWidth(0, width);
5257  }
5258  }
5259 }
5260 
5262 {
5263  if (!obj)
5264  return FitGui::wt_none;
5265  if (obj->InheritsFrom(TGo4FitModelPolynom::Class()))
5266  return FitGui::wt_polynom;
5267  if (obj->InheritsFrom(TGo4FitModelGauss1::Class()))
5268  return FitGui::wt_gauss1;
5269  if (obj->InheritsFrom(TGo4FitModelGauss2::Class()))
5270  return FitGui::wt_gauss2;
5271  if (obj->InheritsFrom(TGo4FitModelGaussN::Class()))
5272  return FitGui::wt_gaussn;
5273  if (obj->InheritsFrom(TGo4FitModelFormula::Class()))
5274  return FitGui::wt_formula;
5275  if (obj->InheritsFrom(TGo4FitModelFunction::Class()))
5276  return FitGui::wt_function;
5277  if (obj->InheritsFrom(TGo4FitModel::Class()))
5278  return FitGui::wt_model;
5279  return FitGui::wt_none;
5280 }
5281 
5282 void TGo4FitPanel::CreateFitSlotLink(TGo4FitSlot *slot, const char *itemname)
5283 {
5284  if (!slot || !itemname)
5285  return;
5286 
5287  int slotindex = GetPadIndexForSlot(slot);
5288 
5289  if (slotindex < 0)
5290  return;
5291 
5292  QString linkname = QString("FitSlotLink_%1").arg(slotindex);
5293 
5294  RemoveLink(linkname.toLatin1().constData());
5295 
5296  AddLink(itemname, linkname.toLatin1().constData());
5297 
5298  GetLinked(linkname.toLatin1().constData(), 1);
5299 
5300  UpdateObjectReferenceInSlot(slot, false);
5301 }
5302 
5304 {
5305  if (!slot)
5306  return true;
5307 
5308  if (slot->GetOwned())
5309  return true;
5310 
5311  bool res = true;
5312 
5313  TObject *obj = nullptr;
5314 
5315  if (WorkingWithPanel()) {
5316 
5317  TPad *pad = FindPadForSlot(slot);
5318 
5319  TGo4Slot *objslot = ActivePanel()->GetPadMainObjectSlot(pad);
5320  obj = !objslot ? nullptr : objslot->GetAssignedObject();
5321 
5322  if (obj && createlink) {
5323  TString linkname = "data_";
5324  linkname += slot->GetName();
5325  AddLink(objslot, linkname);
5326  }
5327  } else {
5328  int slotindex = GetPadIndexForSlot(slot);
5329  QString linkname = QString("FitSlotLink_%1").arg(slotindex);
5330  obj = GetLinked(linkname.toLatin1().constData());
5331  }
5332 
5333  if (!obj)
5334  res = false;
5335  if (!obj || !slot->IsSuitable(obj))
5336  slot->SetObject(nullptr, kFALSE);
5337  else
5338  slot->SetObject(obj, kFALSE);
5339 
5340  return res;
5341 }
5342 
5344 {
5345  TGo4Fitter *fitter = GetFitter();
5346  if (!fitter)
5347  return false;
5348 
5349  bool res = true;
5350 
5351  // remove all links, responsible to data connection,
5352  // which are started with "data_"
5353  // std::cout << "UpdateObjectReferenceInSlots(). Remove all links " << std::endl;
5354  if (WorkingWithPanel())
5355  RemoveLinksMasked("data_");
5356 
5357  // here new links will be create, which are connect widget with datasources
5358  for (Int_t n = 0; n < fitter->NumSlots(); n++) {
5359  TGo4FitSlot *slot = fitter->GetSlot(n);
5360  if (slot->GetClass()->InheritsFrom(TH1::Class()) || slot->GetClass()->InheritsFrom(TGraph::Class()))
5361  res = res && UpdateObjectReferenceInSlot(slot, true);
5362  }
5363 
5364  // std::cout << "UpdateObjectReferenceInSlots() done res = " << res << std::endl;
5365 
5366  return res;
5367 }
5368 
5370 {
5371  if (!WorkingWithPanel())
5372  return;
5373 
5374  TGo4Fitter *fitter = GetFitter();
5375  if (!fitter)
5376  return;
5377 
5378  for (Int_t n = 0; n < fitter->NumSlots(); n++) {
5379  TGo4FitSlot *slot = fitter->GetSlot(n);
5380 
5381  if (slot->GetClass()->InheritsFrom(TH1::Class()) || slot->GetClass()->InheritsFrom(TGraph::Class()))
5382  if (!slot->GetOwned())
5383  slot->SetObject(nullptr, kFALSE);
5384  }
5385 }
5386 
5388 {
5389  if (!WorkingWithPanel())
5390  return;
5391 
5392  TGo4Fitter *fitter = GetFitter();
5393  if (!fitter)
5394  return;
5395 
5396  bool res = false;
5397 
5398  for (Int_t n = 0; n < fitter->NumSlots(); n++) {
5399  TPad *pad = FindPadForSlot(fitter->GetSlot(n));
5400  if (!pad)
5401  continue;
5403  res = true;
5405  res = true;
5406  }
5407  if (res)
5409 }
5410 
5412 {
5413  if (fxDrawNewPanel) {
5415  fxDrawNewPanel = nullptr;
5416  }
5417 }
5418 
5420 {
5421  if (!w)
5422  return;
5423  TObject *obj = w->GetObject();
5424  if (!obj)
5425  return;
5426 
5427  w->ClassNameLbl->setText(QString("Class name: ") + obj->ClassName());
5428  w->ClassNameLbl->adjustSize();
5429  w->NameEdt->setText(obj->GetName());
5430  w->TitleEdt->setText(obj->GetTitle());
5431  TNamed *n = dynamic_cast<TNamed *>(obj);
5432  w->NameEdt->setReadOnly(!n);
5433  w->TitleEdt->setReadOnly(!n);
5434 
5435  TGo4FitNamed *go4n = dynamic_cast<TGo4FitNamed *>(obj);
5436  if (go4n && go4n->GetOwner())
5437  w->FullNameLbl->setText(QString("Full name: ") + go4n->GetFullName());
5438  else
5439  w->FullNameLbl->setText("");
5440  w->FullNameLbl->adjustSize();
5441 
5442  QFitModelWidget *mw = dynamic_cast<QFitModelWidget *>(w);
5443  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(obj);
5444  if (mw && model) {
5445  mw->AmplChk->setChecked(model->GetAmplPar() != nullptr);
5446  mw->AmplChk->setEnabled(model->CanAmplTouch());
5447  mw->BuffersChk->setChecked(model->GetUseBuffers());
5448  mw->GroupSpin->setValue(model->GetGroupIndex());
5449  }
5450 }
5451 
5453 {
5454  if (!w)
5455  return;
5456  QFitItem *item = w->GetItem();
5457  if (!item || !newname || (strlen(newname) == 0))
5458  return;
5459  TNamed *obj = dynamic_cast<TNamed *>(item->Object());
5460  if (!obj)
5461  return;
5462 
5463  if (item->ObjectType() == FitGui::ot_slot)
5464  return;
5465 
5466  if (item->ObjectType() == FitGui::ot_par)
5467  if (item->Parent())
5468  if (item->Parent()->ObjectType() == FitGui::ot_parslist) {
5469  TGo4FitParsList *pars = dynamic_cast<TGo4FitParsList *>(item->Parent()->Object());
5470  if (pars->FindPar(newname))
5471  return;
5472  }
5473 
5474  if (item->ObjectType() == FitGui::ot_data)
5475  if (item->Parent())
5476  if (item->Parent()->ObjectType() == FitGui::ot_datalist) {
5477  TGo4Fitter *fitter = GetFitter();
5478  if (!fitter || (fitter->FindData(newname)))
5479  return;
5480  fitter->ChangeDataNameInAssignments(obj->GetName(), newname);
5482  }
5483 
5484  if (item->ObjectType() == FitGui::ot_model)
5485  if (item->Parent())
5486  if (item->Parent()->ObjectType() == FitGui::ot_modellist) {
5487  TGo4Fitter *fitter = GetFitter();
5488  if (!fitter || (fitter->FindModel(newname)))
5489  return;
5490  }
5491 
5492  obj->SetName(newname);
5493 
5494  w->SetWidgetItemText(true);
5495 
5496  TGo4FitNamed *go4n = dynamic_cast<TGo4FitNamed *>(obj);
5497  if (go4n && go4n->GetOwner())
5498  w->FullNameLbl->setText(QString("Full name: ") + go4n->GetFullName());
5499  else
5500  w->FullNameLbl->setText("");
5501  w->FullNameLbl->adjustSize();
5502 }
5503 
5504 void TGo4FitPanel::ChangeObjectTitle(QFitNamedWidget *w, const char *newtitle)
5505 {
5506  if (!w)
5507  return;
5508  TNamed *n = dynamic_cast<TNamed *>(w->GetObject());
5509  if (n)
5510  n->SetTitle(newtitle);
5511 }
5512 
5513 void TGo4FitPanel::ChangeModelPar(QFitModelWidget *w, int npar, int value)
5514 {
5515  if (!w)
5516  return;
5517  TGo4FitModel *model = dynamic_cast<TGo4FitModel *>(w->GetObject());
5518  if (!model)
5519  return;
5520  switch (npar) {
5521  case 0: {
5522  if (model->CanAmplTouch()) {
5523  bool res = false;
5524  if (value != 0)
5525  res = model->MakeAmpl();
5526  else
5527  res = model->RemoveAmpl();
5528  if (res)
5530  }
5531  break;
5532  }
5533 
5534  case 1: {
5535  model->SetUseBuffers(value != 0);
5536  break;
5537  }
5538 
5539  case 2: {
5540  model->SetGroupIndex(value);
5541  break;
5542  }
5543  }
5544 }
void SetParsNames(const char *name0="Par0", const char *name1="Par1", const char *name2="Par2", const char *name3="Par3", const char *name4="Par4", const char *name5="Par5", const char *name6="Par6", const char *name7="Par7", const char *name8="Par8", const char *name9="Par9")
Double_t GetValue() const
virtual void ShootRepaintTimer()
Bool_t DefineScaleMinMax(Int_t naxis, Double_t &min, Double_t &max)
virtual bool ShowItem(QFitItem *item, bool force)
Int_t GetNumData() const
Definition: TGo4Fitter.h:123
virtual TObject * GetDrawObject(TPad *pad, const char *name)
virtual bool IsPadHasSubPads(TGo4Slot *padslot)
virtual void MainFindBtn_clicked()
virtual void Cmd_RememberPar(QFitItem *item)
virtual TGo4FitData * Wiz_SelectedData()
virtual void MainAttachBtn_clicked()
Double_t CalculatesIntegral(const char *DataName, const char *ModelName=nullptr, Bool_t OnlyCounts=kFALSE)
Definition: TGo4Fitter.cxx:894
Bool_t GetUsePolynom() const
TGo4FitParsList & GetParsCfg()
virtual void Cmd_AddNewData(QFitItem *item, int id)
virtual void ArrowChanged(TGo4FitGuiArrow *arr)
virtual void UpdateWizModelsList(bool changestack)
Bool_t GetUseBuffers() const
virtual void Button_SimpleClear()
virtual void Cmd_AddDependency(QFitItem *item)
virtual void PF_MinWidthEdt_returnPressed()
virtual void UpdatePFAmplLbl()
bool fbDrawBackground
Definition: TGo4FitPanel.h:316
void SetUseBuffers(Bool_t iUse)
bool fbSaveWithReferences
Definition: TGo4FitPanel.h:322
virtual void Smp_PolynomBtn_clicked()
void SetMemoryUsage(Int_t iMemoryUsage)
Definition: TGo4Fitter.cxx:70
TCutG * GetRangeCut(Int_t n) const
QLabel * FullNameLbl
virtual TPad * FindPadForSlot(TGo4FitSlot *slot)
virtual void Cmd_DrawData(QFitItem *item)
TObjArray & GetResults()
void RemoveResult(TGo4FitMinuitResult *res)
Bool_t IsResultDepend() const
void DoAction(TGo4FitterAction *Action)
virtual void Cmd_DeleteAllData(QFitItem *item)
TGo4FitSlot * GetSlot(Int_t nslot)
virtual void SetItem(TGo4FitPanel *panel, QFitItem *iItem)
Definition: QFitWidget.cpp:38
bool FindInParents(QFitItem *item)
Definition: QFitItem.cpp:67
virtual void Cmd_AddRangeCondition(QFitItem *item, int id)
void ClearAssignments()
TGo4FitMinuitResult * GetResult(Int_t indx) const
QMenu * SettMenu
Definition: TGo4FitPanel.h:294
void ClearRanges(Int_t naxis=-1)
void Set2NoiseFactor(Double_t factor)
virtual void Cmd_DeleteDependencies(QFitItem *item)
virtual bool UpdateObjectReferenceInSlot(TGo4FitSlot *slot, bool createlink)
virtual TGo4Fitter * CloneFitter()
virtual void Cmd_MemorizePar(QFitItem *item)
Int_t NumPars() override
QCheckBox * BuffersChk
void SetFitFunctionType(Int_t iFitFunctionType)
Definition: TGo4Fitter.h:80
virtual TPad * FindPadWhereModel(TGo4FitModel *model)
void AddAmplEstimation(Int_t NumIters=1)
Definition: TGo4Fitter.cxx:726
virtual void Fitter_UpdateReferences()
virtual void Button_WorkWithPanel()
Double_t Get0MinWidth() const
virtual void UpdateWizardPage()
Int_t GetNumRangeCut() const
virtual void Wiz_RebuildDataBtn_clicked()
virtual void Wiz_ModelBufChk_toggled(bool zn)
void DeleteAction(TGo4FitterAction *action)
virtual void RemoveFitterLink()
const char * GetLibraryName() const
virtual void RemoveItemWidget()
static void Info(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:294
bool fbUseSamePanelForDraw
Definition: TGo4FitPanel.h:317
virtual void UpdatePFRelNoiseLbl()
Bool_t GetEpsilon(Double_t &eps) const
virtual void PF_WidthEdit_returnPressed()
virtual void WorkWithFitterInSlot(TGo4Slot *slot)
TGo4FitModel * FindModel(const char *ModelName)
Definition: TGo4Fitter.cxx:205
TGo4FitParameter * CreatePar(const char *ParName, const char *Title, Double_t iValue=0)
void ClearModelAssignmentTo(const char *ModelName, const char *DataName=nullptr)
Definition: TGo4Fitter.cxx:482
void SetRangeMin(Int_t naxis, Double_t value)
static TGo4MdiArea * Instance()
Definition: TGo4MdiArea.cpp:26
virtual TGo4Slot * GetDrawObjectSlot(TPad *pad, const char *name)
virtual void SetItemText(QFitItem *item, bool trace)
virtual void ChangeObjectName(QFitNamedWidget *w, const char *newname)
virtual void Cmd_DeleteOutputActions(QFitItem *item)
virtual void Cmd_DeleteDependency(QFitItem *item)
void AddPolynoms(const char *DataName, const char *NamePrefix, Int_t MaxOrder=1, Int_t NumAxis=1, Int_t GroupIndex=0)
Definition: TGo4Fitter.cxx:323
void ClearConnectionToSlot()
Definition: TGo4FitSlot.cxx:83
virtual void Cmd_DeleteActions(QFitItem *item)
virtual void Smp_ClearBtn_clicked()
virtual void Fitter_New()
TGo4FitParameter * GetPar(Int_t n)
virtual void Cmd_DeleteModels(QFitItem *item)
void AssignToData(const char *DataName, Double_t RatioValue=1., Bool_t FixRatio=kFALSE)
virtual void Wiz_DataListSelect(QListWidgetItem *)
bool fbNeedConfirmation
Definition: TGo4FitPanel.h:309
virtual void UpdateWizPaint(int mode)
virtual Bool_t CanAmplTouch()
virtual void Button_PeakFinder()
bool fbDrawComponents
Definition: TGo4FitPanel.h:315
Bool_t IsObject() const
Definition: TGo4FitSlot.h:187
void AddCommand(const char *iCommand)
virtual void MemorizePars()
virtual void Wiz_CreateNewModel(int id)
Int_t GetPolynomOrder() const
virtual void FillSlotsList(QFitItem *parent, const TObjArray *lst, TObject *owner)
bool fbDrawInfoOnPad
Definition: TGo4FitPanel.h:318
virtual TPad * ActivePad()
void AddAction(TGo4FitterAction *Action)
void SetDataName(const char *name)
QFitItem * fxCurrentItem
Definition: TGo4FitPanel.h:307
virtual Bool_t SetPosition(Int_t naxis, Double_t pos)
virtual void UpdateWizModelsBtns()
virtual void UpdateWizDataBtns()
virtual void ClearObjectReferenceInSlots()
void linkedObjectRemoved(const char *linkname) override
Int_t GetPeakFinderType() const
virtual void Wiz_DataList_doubleClicked(QListWidgetItem *)
virtual void Fitter_SaveToBrowser()
void SetForRange(TGo4FitComponent *Comp, Int_t num, Double_t rangey, Double_t shiftx)
virtual TGo4Fitter * GetFitter()
virtual void Wiz_ModelListSelect(QListWidgetItem *)
virtual void CreateDataFor(TGo4ViewPanel *panel, TPad *pad, TGo4Fitter *fitter)
void SetForPosition(TGo4FitModel *model, TGo4FitGuiArrow *forwidth, Double_t iLineAmpl)
QSignalMapper * ViewMap
Definition: TGo4FitPanel.h:293
virtual void Wiz_AddModelBtn_clicked()
virtual Double_t Integral()
virtual void Wiz_ShowAllMod_toggled(bool zn)
Int_t GetNumRangeCondition() const
virtual void Smp_GaussianBtn_clicked()
virtual void Cmd_DeletePar(QFitItem *item)
virtual QString Wiz_GetSlotSourceInfo(TGo4FitSlot *slot)
virtual void Wiz_TakeCurrentRange()
void ClearAssignmentTo(const char *DataName)
void linkedObjectUpdated(const char *linkname, TObject *obj) override
virtual void ClosePanel()
const char * GetFullName()
virtual Bool_t IsAnyDataTransform() const
virtual void FitterMenuItemSelected(int id)
virtual void Cmd_DeleteData(QFitItem *item)
virtual void LocateModel(TGo4FitModel *model, TGo4FitData *data, bool usepad)
TObject * CloneObject(const char *newname=nullptr)
void AssignModelTo(const char *ModelName, const char *DataName, Double_t RatioValue=1., Bool_t FixRatio=kFALSE)
Definition: TGo4Fitter.cxx:467
TObjArray * fxWizSlots
Definition: TGo4FitPanel.h:301
Int_t Get2ChannelSum() const
const char * GetLinkedName(const char *linkname)
Definition: QGo4Widget.cpp:153
Double_t Get2NoiseMinimum() const
bool checkConfirm(const QString &title, const QString &msg)
QSignalMapper * SettMap
Definition: TGo4FitPanel.h:295
virtual void Cmd_AddNewAction(QFitItem *item, int id)
virtual TGo4Slot * GetPadMainObjectSlot(TPad *pad)
void ClearSlot(TGo4FitSlot *slot, Bool_t NonOwned)
void SetAmplValue(Double_t iAmpl)
void Set2NoiseMinimum(Double_t min)
TObjArray * fxWizPars
Definition: TGo4FitPanel.h:300
void AddItemAction(QMenu *menu, const QString &name, int id, const QString &handler="")
virtual void Fitter_PrintParameters()
const char * AssignmentName(Int_t n)
Definition: TGo4FitModel.h:129
virtual void Wiz_GetModelInfo(TGo4FitModel *model, QString *info)
TGo4FitData * RemoveData(const char *DataName, Bool_t IsDel=kFALSE)
Definition: TGo4Fitter.cxx:175
virtual void UpdateItemMenu()
virtual ~TGo4FitPanel()
virtual void PF_MinNoiseEdit_returnPressed()
void ReplaceAction(TGo4FitterAction *action, Int_t dir)
void DeleteAllData()
Definition: TGo4Fitter.cxx:192
QCheckBox * AmplChk
void changeEvent(QEvent *event) override
QFitItem * DefineWidgetItem()
Definition: QFitItem.cpp:45
virtual void Wiz_DataSlotsTable_contextMenuRequested(const QPoint &pnt)
TGo4FitModel * RemoveModel(const char *ModelName, Bool_t IsDel=kFALSE)
Definition: TGo4Fitter.cxx:414
virtual void ClearCanvas()
void GetRangeCondition(Int_t n, Int_t &typ, Int_t &naxis, Double_t &left, Double_t &right) const
void SetPeakFinderType(Int_t typ)
virtual void PaintFitter(TGo4Fitter *fitter, QFitItem *item, bool update)
virtual void Cmd_DeletePars(QFitItem *item)
virtual void Divide(int numX, int numY)
virtual void ChangeViewType(int id)
virtual void Cmd_UpdateAllSlots(QFitItem *item)
virtual void Cmd_CreateFitter()
TObject * GetLinked(const char *linkname, int updatelevel=0)
Definition: QGo4Widget.cpp:172
QGo4LineEdit * TitleEdt
virtual bool UpdateObjectReferenceInSlots()
TGo4ViewPanel * CreateViewPanel(int ndiv=0)
Definition: QGo4Widget.cpp:297
const char * GetExpression() const
QString fxWizDataName
Definition: TGo4FitPanel.h:324
Bool_t IsAssignTo(const char *DataName) const
Definition: TGo4FitModel.h:141
virtual void Button_SimpleFit(int nmodel)
TGo4FitPanel(QWidget *parent=nullptr, const char *name=nullptr)
virtual void AboutToShowViewMenu()
bool fbParsWidgetShown
Definition: TGo4FitPanel.h:313
Double_t Get0MaxWidth() const
void DeleteModelsAssosiatedTo(const char *DataName)
Definition: TGo4Fitter.cxx:440
Double_t GetError() const
bool getBool(const QString &name, bool def=true)
void SetForWidth(TGo4FitModel *model, TGo4FitGuiArrow *forposition)
virtual void UpdateExtendedPage()
virtual void ChangeModelPar(QFitModelWidget *w, int npar, int value)
TObjArray * fxParsTableList
Definition: TGo4FitPanel.h:302
virtual void Cmd_ClearFitter()
int PopupMenuType() const
Definition: QFitItem.h:31
virtual void DeleteDrawObject(TPad *pad, const char *name)
virtual bool ShowItemAsText(QFitItem *item, bool force)
Double_t Get1LineWidth() const
virtual void FillNamedWidget(QFitNamedWidget *w)
virtual TGo4Fitter * CreateFitterFor(TGo4ViewPanel *panel, TPad *pad, const char *name)
TGo4FitData * AddData(TGo4FitData *d)
Definition: TGo4Fitter.cxx:119
virtual Bool_t GetPosition(Int_t naxis, Double_t &pos)
virtual TGo4FitData * CreateData(int id, const char *name)
void RemoveAllLinks(bool blockreset=true)
Definition: QGo4Widget.cpp:196
virtual void MainDrawBtn_clicked()
static QAction * SetIdAction(QSignalMapper *map, int id, int enabled=-1, int checked=-1)
Definition: QGo4Widget.cpp:440
virtual void FillDataTypesList(QMenu *menu, int id, const QString &handler="")
TObject * GetAssignedObject()
Definition: TGo4Slot.cxx:356
virtual TPad * GetSubPad(TPad *toppad, int num, bool onlytoplevel)
virtual TObject * GetPadMainObject(TPad *pad)
virtual Int_t NumPars()
virtual void Cmd_DeleteAction(QFitItem *item)
virtual void Fitter_RollbackParameters()
virtual void Cmd_MoveAction(QFitItem *item, int dir)
const TObjArray * GetSlotList(Bool_t ForceUpdate=kFALSE)
QWidget * fxCurrentItemWidget
Definition: TGo4FitPanel.h:308
virtual void Cmd_RemoveModel(TGo4FitModel *model)
void setBool(const QString &name, bool value=true)
QMenu * ItemMenu
Definition: TGo4FitPanel.h:296
virtual void PF_MinWidthEdt_textChanged(const QString &str)
virtual void SetWidgetItemText(bool trace)
Definition: QFitWidget.cpp:92
void Set0MaxWidth(Double_t max)
virtual Bool_t CanChangeFitter() const
virtual void Smp_LorenzBtn_clicked()
TClass * GetClass() const
Definition: TGo4FitSlot.h:61
virtual void Cmd_ExecuteActions(QFitItem *item, bool expert)
virtual bool Wiz_RemoveData()
virtual bool ShowItemAsGraph(QFitItem *item, bool force)
virtual void Cmd_RemoveRangeCondition(QFitItem *item)
void Set0MaxAmplFactor(Double_t factor)
virtual void UpdateWizDataList()
virtual bool PaintRange(TGo4FitComponent *comp, int nrange, TPad *pad, QFitItem *item)
virtual void UpdateStatusBar(const char *info=nullptr)
virtual void PF_MaxWidthEdt_returnPressed()
void SetPosParIndex(Int_t naxis, Int_t indx=-1)
virtual int GetPadIndexForSlot(TGo4FitSlot *slot)
virtual void Button_PerformFit()
const char * GetFunctionName() const
TGo4FitSlot * GetConnectedSlot() const
Definition: TGo4FitSlot.h:123
int ObjectType() const
Definition: QFitItem.h:29
QGo4LineEdit * NameEdt
virtual void Wiz_DelDataBtn_clicked()
void ChangeDataNameInAssignments(const char *oldname, const char *newname)
Definition: TGo4Fitter.cxx:494
virtual TPad * FindPadWhereData(TGo4FitData *data)
virtual void FillWidget()
Definition: QFitWidget.cpp:62
TObjArray & GetParsDepend()
void SetRange(Int_t naxis, Double_t min, Double_t max)
Bool_t IsAnyRangeLimits() const
virtual bool PaintModel(TGo4FitModel *model, TPad *pad, QFitItem *item)
virtual void Button_FitterDraw(TGo4FitData *selecteddata)
virtual void Wiz_FitNameEdt_textChanged(const QString &name)
virtual void DropOnPanel(QDropEvent *event, const char *itemname, TClass *cl, int kind)
Bool_t GetRange(Double_t &min, Double_t &max) const
bool fbFillingWidget
Definition: TGo4FitPanel.h:298
void RemoveLink(const char *linkname, bool blockreset=true)
Definition: QGo4Widget.cpp:188
Double_t GetInitValue() const
virtual void Cmd_ItemPrint(QFitItem *item)
Bool_t RemovePar(const char *name)
void Set2ChannelSum(Int_t sum)
Bool_t SetObject(TObject *iObject, Bool_t iOwned=kFALSE, Bool_t CheckClass=kTRUE)
virtual void MarkPadModified(TPad *pad)
virtual void PF_WidthEdit_textChanged(const QString &str)
const char * GetParFullName(Int_t n)
virtual void Wiz_ParTable_valueChanged(int nrow, int ncol)
QFitItem * GetItem() const
virtual void Cmd_DeleteMinuitResult(QFitItem *item)
TGo4FitModel * GetModel(Int_t n)
Definition: TGo4Fitter.cxx:200
TPad * fxActivePad
Definition: TGo4FitPanel.h:304
int getInt(const QString &name, int def=0)
Double_t CalculatesModelIntegral(const char *ModelName, Bool_t OnlyCounts=kFALSE)
Definition: TGo4Fitter.cxx:927
Bool_t IsSuitable(TObject *obj) const
Definition: TGo4FitSlot.cxx:92
virtual void Fitter_UseWorkspace()
void SetItem(QFitItem *item, TGo4FitPanel *panel)
virtual void Wiz_ModelList_itemChanged(QListWidgetItem *)
virtual void DeleteModelWithPrimit(TGo4FitGuiArrow *arr)
virtual TGo4ViewPanel * ActivePanel()
virtual void Wiz_PFSetupBtn_clicked()
Int_t GetGroupIndex() const
Definition: TGo4FitModel.h:119
virtual TGo4FitModel * Wiz_SelectedModel()
virtual void Wiz_DataBufChk_toggled(bool zn)
virtual void PF_SumUpSpin_valueChanged(int num)
int WidgetType() const
Definition: QFitItem.h:30
virtual void PF_RelNoiseSlider_valueChanged(int zn)
virtual void Fitter_NewForActivePad(bool overwrite)
TGo4FitParameter * FindPar(const char *ParName)
QSignalMapper * FitterMap
Definition: TGo4FitPanel.h:291
TGo4QSettings * go4sett
virtual void PF_MaxWidthEdt_textChanged(const QString &str)
virtual void Wiz_AddDataBtn_clicked()
Bool_t GetFixed() const
Double_t GetResultFF() const
virtual void SetFitter(TGo4Fitter *)
virtual void Cmd_ClearAssigments(QFitItem *item)
virtual void Cmd_SaveFitter(bool ask)
virtual void Cmd_ExecuteAction(QFitItem *item)
void AddRangeCut(TCutG *cut, Bool_t exclude=kFALSE)
void focusInEvent(QFocusEvent *event) override
virtual void Cmd_RememberPars(QFitItem *item)
virtual QFitItem * FindItem(TObject *obj, int ObjectType, QFitItem *parent)
virtual void UpdateItem(QFitItem *item, bool trace)
virtual void AboutToShowItemMenu()
virtual Bool_t SetWidth(Int_t naxis, Double_t width)
TString FindNextName(const char *Head, Int_t start, Bool_t isModel=kTRUE)
virtual bool FillPopupForSlot(TGo4FitSlot *slot, QMenu *menu)
void FillSlotList(TSeqCollection *list) override
virtual TPad * FindPadWhereComp(TGo4FitComponent *comp)
void SetRangeMax(Int_t naxis, Double_t value)
virtual void Cmd_DeleteAssosiatedModels(QFitItem *item)
virtual void PF_RelNoiseSlider_sliderReleased()
virtual void UpdateItemsOfType(int typ, bool allitems=false)
Definition: QFitWidget.cpp:98
virtual void ChangeObjectTitle(QFitNamedWidget *w, const char *newtitle)
virtual void PF_AmplSlider_sliderReleased()
const TString & GetParameter() const
virtual void Wiz_CreateNewData(int id)
Int_t GetNumModel() const
Definition: TGo4Fitter.h:178
virtual void MainFitBtn_clicked()
TGo4FitData * GetData(Int_t n)
Definition: TGo4Fitter.cxx:104
TGo4ViewPanel * fxActivePanel
Definition: TGo4FitPanel.h:303
void SetGroupIndex(Int_t index=-1)
Definition: TGo4FitModel.h:109
virtual Bool_t GetWidth(Int_t naxis, Double_t &width)
QFitItem * DefineGraphItem()
Definition: QFitItem.cpp:56
TObject * CreateDrawObject(const char *ObjName, const char *DataName, Bool_t IsModel=kFALSE, const char *ModelName=nullptr)
Definition: TGo4Fitter.cxx:935
Int_t NumAssigments() const
Definition: TGo4FitModel.h:124
virtual void Wiz_BackgroundChk_toggled(bool chk)
TObject * Object() const
Definition: QFitItem.h:27
QMenu * FitterMenu
Definition: TGo4FitPanel.h:290
virtual void Cmd_MemorizePars(QFitItem *item)
void SetUsePolynom(Bool_t use)
virtual void CloseDrawPanel()
virtual TObject * GetObject()
Definition: QFitWidget.cpp:50
TGo4ViewPanel * LastActivePanel()
Definition: QGo4Widget.cpp:338
bool fbUseAmplEstim
Definition: TGo4FitPanel.h:328
TNamed * GetOwner()
Definition: TGo4FitNamed.h:63
Int_t GetFitFunctionType() const
Definition: TGo4Fitter.h:85
Int_t DefineDimensions()
QFitItem * Parent() const
Definition: QFitItem.h:35
virtual void PF_MinNoiseEdit_textChanged(const QString &str)
virtual void Wiz_UseAmplEstimChk_toggled(bool chk)
virtual void LineParsChk_toggled(bool)
virtual void Wiz_DataUseRangeBtn_clicked()
virtual void FillParsWidget()
virtual void Wiz_DrawDataBtn_clicked()
static QAction * AddIdAction(QMenu *menu, QSignalMapper *map, const QString &text, int id, int enabled=-1, int checked=-1)
Definition: QGo4Widget.cpp:413
virtual void MainParsBtn_clicked()
void SetValue(Double_t iValue)
virtual void ExecutePopupForSlot(QFitItem *item, TGo4FitSlot *slot, int id)
virtual bool PaintModelsFor(TGo4Fitter *fitter, TGo4FitData *data, QFitItem *item, bool update)
virtual void ItemMenuItemSelected(int id)
virtual void Wiz_MigradIterSpin_valueChanged(int num)
virtual void AboutToShowSettMenu()
void RemoveRangeCut(Int_t n)
virtual TH1 * GetPadHistogram(TPad *pad)
virtual void Cmd_AddNewPar(QFitItem *item)
virtual void RememberPars()
Bool_t ConnectToSlot(TGo4FitSlot *slot)
Definition: TGo4FitSlot.cxx:58
virtual void panelSlot(TGo4ViewPanel *, TPad *, int)
virtual void UpdateWizStackWidget()
virtual void FitList_currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)
virtual void Wiz_PFPolynSpin_valueChanged(int zn)
virtual void Wiz_UseSelectedRange()
TGo4FitterAction * GetAction(Int_t num)
void RemoveRangeCondition(Int_t n)
virtual void Wiz_DelModelBtn_clicked()
virtual void Cmd_CloneModel(QFitItem *item)
virtual void UpdateActivePage()
virtual void Wiz_FitFuncCmb_activated(int typ)
void Set1LineWidth(Double_t width)
virtual void Cmd_DeleteModel(QFitItem *item)
const char * GetDataName(Int_t n)
Definition: TGo4Fitter.cxx:109
QFitItem * CurrFitItem
Definition: TGo4FitPanel.h:286
virtual void Wiz_PFUsePolynChk_toggled(bool zn)
virtual TGo4FitPeakFinder * GetPeakFinder(bool autocreate)
virtual bool CanRollbackPars()
Bool_t IsInitValue() const
virtual void UpdateSimplePage()
Int_t GetType() const
void SetClearModels(Bool_t clear)
virtual bool FillPopupForItem(QFitItem *item, QMenu *menu)
virtual void UpdateItemsOfType(int typ, QFitItem *parent=nullptr)
virtual void Fitter_Delete()
virtual QFitItem * GetItem()
Definition: QFitWidget.cpp:45
virtual void FillDependencyList(QFitItem *parent)
void SetEpsilon(Double_t iEpsilon)
virtual void FitItemDeleted(QFitItem *item)
virtual void ParsTable_valueChanged(int nrow, int ncol)
virtual void ParsTableChanged(QTableWidget *table, int nrow, int ncol, bool LinesView, TObjArray *TableList, bool updatepaint)
Int_t GetNumResults() const
Definition: TGo4FitMinuit.h:91
TGo4FitModel * AddModel(TGo4FitModel *m)
Definition: TGo4Fitter.cxx:210
void SetWidthParIndex(Int_t naxis, Int_t indx=-1)
void SetSaveFlagForObjects(Int_t iSaveFlag, const char *PlaceName=nullptr)
Int_t GetDataType() const
Definition: TGo4FitData.h:63
virtual void RemovePrimitives()
bool IsAcceptDrag(const char *itemname, TClass *cl, int kind) override
void AddLink(const char *itemname, const char *linkname)
Definition: QGo4Widget.cpp:117
virtual TGo4FitModel * CreateModel(int id, const char *namebase, TGo4Fitter *fitter, TGo4FitData *data)
TGo4FitModel * CloneModel(const char *ModelName, const char *NewName=nullptr)
Definition: TGo4Fitter.cxx:391
virtual void CreateFitSlotLink(TGo4FitSlot *slot, const char *itemname)
Bool_t MakeAmpl(Bool_t isFixed=kFALSE)
virtual void PF_AmplSlider_valueChanged(int zn)
virtual bool WorkingWithPanel()
virtual void CollectSpecialObjects(TPad *pad, TObjArray *objs, int selectkind)
Double_t Get2NoiseFactor() const
virtual void Wiz_MinSetupBtn_clicked()
TGo4FitterOutput * AddOutputAction(const char *Action, const char *Option=nullptr)
virtual void RemoveDrawObjects()
virtual void FillParsTable(QTableWidget *table, TGo4Fitter *fitter, TGo4FitModel *model, bool LinesView, TObjArray *TableList)
TGo4FitModel * GetModel() const
virtual QFitItem * GetFitterItem()
TObject * GetObject() const
int Tag() const
Definition: QFitItem.h:33
QString SaveObjectInMemory(const char *foldername, TObject *obj)
Definition: QGo4Widget.cpp:355
virtual bool WorkingWithOnlyPad()
virtual void Cmd_ClearAssigment(QFitItem *item)
TGo4FitParsList & GetParsNew()
QLabel * ClassNameLbl
void SetBackgroundGroupIndex()
Definition: TGo4FitModel.h:114
virtual void FindersTab_currentChanged(int)
int GraphType() const
Definition: QFitItem.h:32
void setInt(const QString &name, int value=0)
virtual int GetNumberOfPads(TPad *toppad)
virtual void Wiz_RebuildDataList()
virtual TPad * GetActivePad()
Bool_t GetOwned() const
Definition: TGo4FitSlot.h:160
virtual void AboutToShowFitterMenu()
Bool_t CalculatesMomentums(const char *DataName, Bool_t UseRanges, Bool_t SubstractModels, Double_t &first, Double_t &second)
Definition: TGo4Fitter.cxx:813
Double_t Get0MaxAmplFactor() const
QSpinBox * GroupSpin
virtual int DefineModelWidgetType(TObject *obj)
QMenu * ViewMenu
Definition: TGo4FitPanel.h:292
bool fbShowPrimitives
Definition: TGo4FitPanel.h:310
virtual void Smp_ExponentBtn_clicked()
bool fbRecalculateGaussWidth
Definition: TGo4FitPanel.h:320
virtual bool DeleteDrawObjects(TPad *pad, int kindtodelete)
QMenuBar * MenuBar
Definition: TGo4FitPanel.h:289
void AddActionAt(TGo4FitterAction *Action, Int_t indx)
void ExcludeRange(Int_t naxis, Double_t min, Double_t max)
void SetFixed(Bool_t iFixed)
virtual void FillParsList(QFitItem *item)
Int_t GetNumActions() const
virtual void Cmd_CreateAppropriateFitter()
virtual void Cmd_AddNewModel(QFitItem *item, int id)
virtual void FitList_customContextMenuRequested(const QPoint &)
TGo4FitData * FindData(const char *DataName)
Definition: TGo4Fitter.cxx:114
virtual void Wiz_DataClearRangesBtn_clicked()
void SetPolynomOrder(Int_t order)
void RemoveLinksMasked(const char *startedwith=nullptr, bool blockreset=true)
Definition: QGo4Widget.cpp:204
void DoActions(Bool_t AllowFitterChange=kFALSE, TObjArray *Actions=nullptr)
virtual TGo4Slot * AddDrawObject(TPad *pad, int kind, const char *itemname, TObject *obj, bool owner, const char *drawopt)
bool fbDrawPanelCreation
Definition: TGo4FitPanel.h:306
void linkedRemoved(TGo4Slot *slot, TObject *obj) override
virtual void WorkWithFitter(const char *itemname, TGo4ViewPanel *panel, TPad *pad)
void Set0MinWidth(Double_t min)
QString fxWizModelName
Definition: TGo4FitPanel.h:325
virtual void ChangeSettings(int id)
virtual void ShowPanelPage(int id)
virtual void Cmd_DeleteFitter()
const TString & GetExpression() const
void Clear(Option_t *option="") override
Definition: TGo4Fitter.cxx:97
void SetRange(Double_t iRangeMin, Double_t iRangeMax)
virtual void Wiz_ModelList_doubleClicked(QListWidgetItem *)
virtual void Wiz_CloneModelBtn_clicked()
Bool_t IsSuitableClass(TClass *cl) const
bool fbWizShowAllModels
Definition: TGo4FitPanel.h:326
virtual void Cmd_AssignModelToData(QFitItem *item, int id)
TGo4ViewPanel * fxDrawNewPanel
Definition: TGo4FitPanel.h:305
void panelSignal(TGo4ViewPanel *, TPad *, int)
virtual void FillModelTypesList(QMenu *menu, int id, bool extend, const QString &handler="")
bool fbUseCurrentRange
Definition: TGo4FitPanel.h:323
string msg
Definition: go4init.py:11
void AddStandardActions()
Definition: TGo4Fitter.cxx:731
void SetError(Double_t iError)
TObjArray & GetParsInit()
TGo4FitParameter * GetAmplPar()
void DeleteAllModels()
Definition: TGo4Fitter.cxx:459
virtual void SetAutoScale(bool on, TPad *selpad)
virtual void Cmd_RemoveRangeConditions(QFitItem *item)
Bool_t CanConnectToSlot(TGo4FitSlot *slot)
Definition: TGo4FitSlot.cxx:70
virtual void Cmd_AssignModelToAllData(QFitItem *item)