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