Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4FitGUI/TGo4FitPanel.ui.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 /****************************************************************************
00017 ** ui.h extension file, included from the uic-generated form implementation.
00018 **
00019 ** If you wish to add, delete or rename slots use Qt Designer which will
00020 ** update this file, preserving your code. Create an init() slot in place of
00021 ** a constructor, and a destroy() slot in place of a destructor.
00022 *****************************************************************************/
00023 
00024 #include <iostream.h>
00025 
00026 static const char* SelectedXPM[]={
00027 "12 12 5 1",
00028 "# c #000000",
00029 "a c #ffffff",
00030 "c c #808080",
00031 "b c #c0c0c0",
00032 ". c None",
00033 "############",
00034 "#aaaaaaaaaa#",
00035 "#aaaaaaa##a#",
00036 "#aaaaaaa##a#",
00037 "#aaaaaa##aa#",
00038 "#a##aaa##aa#",
00039 "#a##aa##aaa#",
00040 "#aa##a##aaa#",
00041 "#aa####aaaa#",
00042 "#aaa##aaaaa#",
00043 "#aaaaaaaaaa#",
00044 "############"};
00045 
00046 static const char* UnselectedXPM[]={
00047 "12 12 5 1",
00048 "# c #000000",
00049 "a c #ffffff",
00050 "c c #808080",
00051 "b c #c0c0c0",
00052 ". c None",
00053 "############",
00054 "#aaaaaaaaaa#",
00055 "#aaaaaaaaaa#",
00056 "#aaaaaaaaaa#",
00057 "#aaaaaaaaaa#",
00058 "#aaaaaaaaaa#",
00059 "#aaaaaaaaaa#",
00060 "#aaaaaaaaaa#",
00061 "#aaaaaaaaaa#",
00062 "#aaaaaaaaaa#",
00063 "#aaaaaaaaaa#",
00064 "############"};
00065 
00066 
00067 #include "Go4Fit/TGo4FitModelGauss1.h"
00068 #include "Go4Fit/TGo4FitModelGauss2.h"
00069 #include "Go4Fit/TGo4FitModelGaussN.h"
00070 
00071 
00072 void TGo4FitPanel::init()
00073 {
00074     TGo4LockGuard Global;
00075 
00076     setAcceptDrops(TRUE);
00077     fxRegistry = TGo4GUIRegistry::Instance();
00078     fxSlots = dynamic_cast<TGo4FitPanelSlots*> (fxRegistry->GetSlotClass("TGo4FitPanelSlots"));
00079     if(fxSlots==0) fxSlots = new TGo4FitPanelSlots ("TGo4FitPanelSlots" , "Slot Class for Qt GUI", this);
00080               else fxSlots->SetGUI(this);
00081 
00082     fxStatus = dynamic_cast <TGo4FitPanelStatus *> (fxSlots->GetStatus());
00083 
00084     MenuBar = new QMenuBar( this, "menubar" );
00085     MenuBar->setFrameShape(QFrame::NoFrame);
00086 
00087     FitterMenu = new QPopupMenu( this );
00088     MenuBar->insertItem( "&Fitter",FitterMenu);
00089     connect(FitterMenu, SIGNAL(aboutToShow()), this, SLOT(AboutToShowFitterMenu()) );
00090 
00091     ViewMenu = new QPopupMenu( this );
00092     MenuBar->insertItem( "&Tools",ViewMenu);
00093     connect(ViewMenu, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu()) );
00094 
00095     SettMenu = new QPopupMenu( this );
00096     MenuBar->insertItem( "&Settings", SettMenu);
00097     connect(SettMenu, SIGNAL(aboutToShow()), this, SLOT(AboutToShowSettMenu()) );
00098 
00099     SettMenu->insertItem("&Confirmation", this, SLOT(ChangeSettings(int)), 0, 1);
00100     SettMenu->insertItem("&Show primitives", this, SLOT(ChangeSettings(int)), 0, 2);
00101     SettMenu->insertItem("&Freeze mode", this, SLOT(ChangeSettings(int)), 0, 3);
00102     SettMenu->insertItem("&Save with objects", this, SLOT(ChangeSettings(int)), 0, 4);
00103 
00104     SettMenu->insertSeparator();
00105 
00106     SettMenu->insertItem("&Use current range", this, SLOT(ChangeSettings(int)), 0, 10);
00107     SettMenu->insertItem("&Draw model", this, SLOT(ChangeSettings(int)), 0, 11);
00108     SettMenu->insertItem("Draw &background", this, SLOT(ChangeSettings(int)), 0, 14);
00109     SettMenu->insertItem("Dra&w components", this, SLOT(ChangeSettings(int)), 0, 12);
00110     SettMenu->insertItem("Draw on same &pad", this, SLOT(ChangeSettings(int)), 0, 13);
00111     SettMenu->insertItem("Draw &info on pad", this, SLOT(ChangeSettings(int)), 0, 15);
00112     
00113     SettMenu->insertSeparator();
00114 
00115     SettMenu->insertItem("&No &integral", this, SLOT(ChangeSettings(int)), 0, 17);
00116     SettMenu->insertItem("&Counts", this, SLOT(ChangeSettings(int)), 0, 18);
00117     SettMenu->insertItem("&Integral", this, SLOT(ChangeSettings(int)), 0, 19);
00118     SettMenu->insertItem("&Gauss integral", this, SLOT(ChangeSettings(int)), 0, 20);
00119 
00120     SettMenu->insertItem("Recalculate gauss &widths", this, SLOT(ChangeSettings(int)), 0, 16);
00121 
00122     SettMenu->insertSeparator();
00123 
00124     SettMenu->insertItem("&Do not use buffers", this, SLOT(ChangeSettings(int)), 0, 21);
00125     SettMenu->insertItem("&Only for data", this, SLOT(ChangeSettings(int)), 0, 22);
00126     SettMenu->insertItem("&For data and models", this, SLOT(ChangeSettings(int)), 0, 23);
00127     SettMenu->insertItem("&Individual settings", this, SLOT(ChangeSettings(int)), 0, 24);
00128 
00129     ItemMenu = 0;
00130 
00131     fxWizPars = new TObjArray();
00132     fxWizSlots = new TObjArray();
00133     fxParsTableList = new TObjArray();
00134 
00135     fiPaintMode = 0;
00136 
00137     TGo4FitPanelLayout->setMargin(3);
00138     TGo4FitPanelLayout->setSpacing(1);
00139 
00140     fxSlots->ActivateByFitter(0);
00141 }
00142 
00143 void TGo4FitPanel::destroy()
00144 {
00145     TGo4LockGuard Global;
00146 
00147     TGo4MainWindow* w = dynamic_cast<TGo4MainWindow*> (fxRegistry->GetMainWindow());
00148     if (w) w->CloseFitPanel();
00149 
00150     delete fxParsTableList;
00151     delete fxWizSlots;
00152     delete fxWizPars;
00153     delete fxSlots;
00154 }
00155 
00156 // **************************** interface to MainGUI ************************
00157 
00158 void TGo4FitPanel::ActivateByFitter( TGo4Fitter * Fitter) {
00159    TGo4LockGuard Global;
00160 
00161    if(fxSlots)
00162      fxSlots->ActivateByFitter(Fitter);
00163 }
00164 
00165 void TGo4FitPanel::DropFitterOnPanel(TGo4Fitter* Fitter, TGo4PreviewPanel* Panel)
00166 {
00167    if (fxSlots)
00168      fxSlots->Fitter_DropToPanel(Fitter, Panel);
00169 }
00170 
00171 
00172 void TGo4FitPanel::SetViewPanel(TGo4PreviewPanel* Panel) {
00173   TGo4LockGuard Global;
00174 
00175   if (Panel)
00176     fxSlots->ActivePadSelected(Panel, Panel->GetActivePad());
00177 }
00178 
00179 void TGo4FitPanel::SelectedPadChange(TGo4PreviewPanel* Panel) {
00180    TGo4LockGuard Global;
00181 
00182   if (Panel==0) return;
00183 }
00184 
00185 void TGo4FitPanel::PanelRemoved(TGo4PreviewPanel* Panel) {
00186   TGo4LockGuard Global;
00187 
00188   if (fxSlots && Panel)
00189      fxSlots->ViewPanelRemoved(Panel);
00190 }
00191 
00192 void TGo4FitPanel::PadUpdated(TGo4PreviewPanel* Panel, TPad* Pad) {
00193   TGo4LockGuard Global;
00194 
00195   if ((Panel==0) || (Pad==0)) return;
00196 }
00197 
00198 // ************************ end of interface to MainGUI *****************************
00199 
00200 
00201 void TGo4FitPanel::closeEvent( QCloseEvent *ce )
00202 {
00203     TGo4LockGuard Global;
00204 
00205     ce->accept();
00206     delete this;
00207 }
00208 
00209 void TGo4FitPanel::FitList_contextMenuRequested( QListViewItem * item, const QPoint & pnt, int )
00210 {
00211    TGo4LockGuard Global;
00212 
00213    QFitItem* fititem = dynamic_cast<QFitItem*> (item);
00214    if (fititem==0) return;
00215 
00216    QPopupMenu menu(0,"ListPopup");
00217 
00218    if (fxSlots->FillPopupForItem(fititem,&menu)) {
00219       int id =  menu.exec(pnt);
00220       fxSlots->ExecPopupForItem(fititem, id /*, menu.text(id) */);
00221    }
00222 }
00223 
00224 
00225 void TGo4FitPanel::FitList_currentChanged( QListViewItem * item)
00226 {
00227    TGo4LockGuard Global;
00228 
00229    fxSlots->ListItemClicked(item);
00230 }
00231 
00232 void TGo4FitPanel::AboutToShowViewMenu() {
00233   TGo4LockGuard Global;
00234 
00235   ViewMenu->clear();
00236 
00237   ViewMenu->insertItem("&Simple", this, SLOT(ChangeViewType(int)), 0, 1);
00238   ViewMenu->insertItem("&Wizard", this, SLOT(ChangeViewType(int)), 0, 2);
00239   ViewMenu->insertItem("&Expert", this, SLOT(ChangeViewType(int)), 0, 3);
00240 
00241   ViewMenu->setItemChecked(fxStatus->SelectedWidgetID(), TRUE);
00242 }
00243 
00244 
00245 void TGo4FitPanel::ChangeViewType(int id) {
00246   TGo4LockGuard Global;
00247 
00248   fxSlots->ChangeActivePage(id);
00249 }
00250 
00251 void TGo4FitPanel::ShowPanelPage( int id ) {
00252    TGo4LockGuard Global;
00253 
00254    QWidget* w = PageEmpty;
00255    switch(id) {
00256       case 1: w = PageSimple; break;
00257       case 2: w = PageWizard; break;
00258       case 3: w = PageExtended; break;
00259       case 100: w = PageParameters; break;
00260    }
00261    if (w!=WidgetStack->visibleWidget())
00262      WidgetStack->raiseWidget(w);
00263 }
00264 
00265 void TGo4FitPanel::UpdateStatusBar(const char* info) {
00266    TGo4LockGuard Global;
00267 
00268    QString status;
00269    TGo4Fitter* fitter = fxSlots->GetFitter();
00270 
00271    if (info!=0) status=info; else {
00272        if (fxSlots->WorkingWithPanel()) {
00273           status = QString("Pad ") + fxSlots->ActivePad()->GetName() +
00274                            " in panel " + fxSlots->ActiveViewPanel()->name();
00275           if (!fxSlots->WorkingWithOnlyPad())
00276             status += ". Muiltifit";
00277 
00278        } else status = "Workspace";
00279        if (fitter==0) status+=".  No fitter";
00280                  else status = status + ". Fitter: "+fitter->GetName();
00281    }
00282    MainStatusLbl->setText(status);
00283    MainStatusLbl->update();
00284    MainStatusLbl->repaint();
00285 
00286    MainAttachBtn->setEnabled(TRUE);
00287 
00288    QToolTip::remove(MainParsBtn);
00289    if (fxStatus->ParsWidgetShown()) {
00290      MainParsBtn->setText("Back");
00291      QToolTip::add(MainParsBtn, "Back to last selected page");
00292    } else {
00293      MainParsBtn->setText("Pars");
00294      QToolTip::add(MainParsBtn, "Show list of fitter parameters");
00295    }
00296    
00297    if (fitter==0) {
00298      MainFitBtn->setEnabled(FALSE);
00299      MainDrawBtn->setEnabled(FALSE);
00300      MainFindBtn->setEnabled(FALSE);
00301      MainParsBtn->setEnabled(FALSE);
00302    } else {
00303      MainFitBtn->setEnabled((fitter->GetNumData()>0) &&
00304            ((fitter->GetNumModel()>0) || fxStatus->SimpleWidgetSelected()));
00305      MainDrawBtn->setEnabled(fitter->GetNumData()>0);
00306      MainFindBtn->setEnabled((fitter->GetNumData()>0) && fxStatus->WizWidgetSelected()
00307                              && fxSlots->FitOptions()->GetPeakFinder(kFALSE));
00308      MainParsBtn->setEnabled(TRUE);
00309    }
00310 }
00311 
00312 void TGo4FitPanel::UpdateItemMenu() {
00313   TGo4LockGuard Global;
00314 
00315   bool showitem = fxStatus->ExtendedWidgetSelected();
00316 
00317   QString itemtext;
00318 
00319   if (showitem) {
00320     QFitItem* item = dynamic_cast<QFitItem*> (FitList->currentItem());
00321     if ((item==0) || (item->ObjectType()==TGo4FitPanelSlots::ot_fitter)) showitem = FALSE; else
00322        itemtext = item->text(0);
00323   }
00324 
00325   if (showitem) {
00326     if (ItemMenu==0) {
00327       ItemMenu = new QPopupMenu(this);
00328       MenuBar->insertItem( itemtext, ItemMenu, 111);
00329       connect(ItemMenu, SIGNAL(aboutToShow()), this, SLOT(AboutToShowItemMenu()) );
00330     } else MenuBar->changeItem(111, itemtext);
00331   } else
00332     if (ItemMenu!=0) {
00333       MenuBar->removeItem(111);
00334       delete ItemMenu;
00335       ItemMenu = 0;
00336     }
00337 }
00338 
00339 void TGo4FitPanel::AboutToShowSettMenu() {
00340   TGo4LockGuard Global;
00341 
00342   SettMenu->setItemChecked(1,fxStatus->NeedConfirmation());
00343   SettMenu->setItemChecked(2,fxStatus->ShowPrimitives());
00344   SettMenu->setItemChecked(3,fxStatus->FreezeMode());
00345   SettMenu->setItemChecked(4,fxStatus->SaveWithReferences());
00346   SettMenu->setItemVisible(4, fxStatus->ExtendedWidgetSelected());
00347 
00348   SettMenu->setItemChecked(10,fxStatus->UseCurrentRange());
00349   SettMenu->setItemChecked(11,fxStatus->DrawModels());
00350   SettMenu->setItemChecked(12,fxStatus->DrawComponents());
00351   SettMenu->setItemChecked(13,fxStatus->UseSamePanelForDraw());
00352   SettMenu->setItemChecked(14,fxStatus->DrawBackground());
00353   SettMenu->setItemChecked(15,fxStatus->DrawInfoOnPad());
00354   SettMenu->setItemChecked(16,fxStatus->RecalculateGaussWidth());
00355   
00356   SettMenu->setItemChecked(17,fxStatus->IntegralMode()==0);
00357   SettMenu->setItemChecked(18,fxStatus->IntegralMode()==1);
00358   SettMenu->setItemChecked(19,fxStatus->IntegralMode()==2);
00359   SettMenu->setItemChecked(20,fxStatus->IntegralMode()==3);
00360 
00361   SettMenu->setItemChecked(21,fxStatus->BuffersUsage()==0);
00362   SettMenu->setItemChecked(22,fxStatus->BuffersUsage()==1);
00363   SettMenu->setItemChecked(23,fxStatus->BuffersUsage()==2);
00364   SettMenu->setItemChecked(24,fxStatus->BuffersUsage()==3);
00365 
00366 }
00367 
00368 void TGo4FitPanel::ChangeSettings(int id) {
00369   TGo4LockGuard Global;
00370 
00371   fxSlots->ChangeSettings(id);
00372 }
00373 
00374 void TGo4FitPanel::AboutToShowFitterMenu() {
00375    TGo4LockGuard Global;
00376 
00377    FitterMenu->clear();
00378 
00379    TGo4Fitter* fitter = fxSlots->GetFitter();
00380    TGo4WorkSpace* space = dynamic_cast<TGo4WorkSpace*> (fxRegistry->GetCentralWindow());
00381    TGo4PreviewPanel* Panel = space==0 ? 0 : space->GetLastActiveViewPanel();
00382 
00383    bool samepad = Panel==0 ? FALSE : fxSlots->WorkingWithPanel() &&
00384      (Panel==fxSlots->ActiveViewPanel()) && (Panel->GetActivePad()==fxSlots->ActivePad());
00385 
00386    QString padname;
00387 //   if (Panel)
00388 //     padname = QString(Panel->GetActivePad()->GetName()) + " in panel " + Panel->name();
00389    if (Panel) padname = QString("panel \"") + Panel->caption() + "\""; 
00390 
00391    if (fxStatus->ExtendedWidgetSelected())
00392      FitterMenu->insertItem("&Create for workspace", this, SLOT(FitterMenuItemSelected(int)), 0, 1);
00393    FitterMenu->insertItem("Create &for "+padname, this, SLOT(FitterMenuItemSelected(int)), 0, 2);
00394    FitterMenu->insertItem("&Delete", this, SLOT(FitterMenuItemSelected(int)), 0, 3);
00395    FitterMenu->insertSeparator();
00396 
00397 //   FitterMenu->insertItem("&Copy to pad "+padname, this, SLOT(FitterMenuItemSelected(int)), 0, 11);
00398 //   FitterMenu->insertItem("&Move to pad "+padname, this, SLOT(FitterMenuItemSelected(int)), 0, 12);
00399 //   FitterMenu->insertItem("&Copy to workspace", this, SLOT(FitterMenuItemSelected(int)), 0, 13);
00400 //   FitterMenu->insertItem("&Move to workspace", this, SLOT(FitterMenuItemSelected(int)), 0, 14);
00401 //   FitterMenu->insertSeparator();
00402 
00403    FitterMenu->insertItem("Save to &browser", this, SLOT(FitterMenuItemSelected(int)), 0, 21);
00404 //   FitterMenu->insertItem("Save to &file", this, SLOT(FitterMenuItemSelected(int)), 0, 22);
00405    if (fxStatus->ExtendedWidgetSelected())
00406       FitterMenu->insertItem("&Workspace", this, SLOT(FitterMenuItemSelected(int)), 0, 23);
00407    FitterMenu->insertItem("&Update references", this, SLOT(FitterMenuItemSelected(int)), 0, 24);
00408    FitterMenu->insertItem("&Print parameters", this, SLOT(FitterMenuItemSelected(int)), 0, 25);
00409    FitterMenu->insertItem("&Rollback parameters", this, SLOT(FitterMenuItemSelected(int)), 0, 26);
00410 
00411    FitterMenu->insertSeparator();
00412 
00413    FitterMenu->insertItem("&Close", this, SLOT(FitterMenuItemSelected(int)), 0, 99);
00414 
00415    FitterMenu->setItemEnabled(1, TRUE);
00416    FitterMenu->setItemEnabled(2, (Panel!=0));
00417    FitterMenu->setItemEnabled(3, (fitter!=0));
00418 
00419    FitterMenu->setItemEnabled(11, (fitter!=0) && (Panel!=0) && !samepad);
00420    FitterMenu->setItemEnabled(12, (fitter!=0) && (Panel!=0) && !samepad);
00421    FitterMenu->setItemEnabled(13, (fitter!=0) && fxSlots->WorkingWithPanel());
00422    FitterMenu->setItemEnabled(14, (fitter!=0) && fxSlots->WorkingWithPanel());
00423 
00424    FitterMenu->setItemEnabled(21, (fitter!=0));
00425    FitterMenu->setItemEnabled(22, (fitter!=0));
00426    FitterMenu->setItemEnabled(23, fxSlots->WorkingWithPanel());
00427    FitterMenu->setItemEnabled(24, (fitter!=0));
00428    FitterMenu->setItemEnabled(25, (fitter!=0) && fxStatus->ParsWidgetShown());
00429    FitterMenu->setItemEnabled(26, (fitter!=0) && fitter->CanRollbackPars());
00430 
00431    FitterMenu->setItemEnabled(99, TRUE);
00432 }
00433 
00434 void TGo4FitPanel::FitterMenuItemSelected(int id) {
00435    TGo4LockGuard Global;
00436 
00437    switch (id) {
00438       case 1: fxSlots->Fitter_New(); break;
00439       case 2: fxSlots->Fitter_NewForActivePad(TRUE); break;
00440       case 3: fxSlots->Fitter_Delete(); break;
00441       case 11: fxSlots->Fitter_MoveCopy(FALSE, TRUE); break;
00442       case 12: fxSlots->Fitter_MoveCopy(TRUE, TRUE); break;
00443       case 13: fxSlots->Fitter_MoveCopy(FALSE, FALSE); break;
00444       case 14: fxSlots->Fitter_MoveCopy(TRUE, FALSE); break;
00445       case 21: fxSlots->Fitter_SaveToBrowser(); break;
00446       case 22: fxSlots->Fitter_SaveToFile(); break;
00447       case 23: fxSlots->Fitter_UseWorkspace(); break;
00448       case 24: fxSlots->Fitter_UpdateReferences(); break;
00449       case 25: fxSlots->Fitter_PrintParameters(); break;
00450       case 26: fxSlots->Fitter_RollbackParameters(); break;
00451       case 99: close(); break;
00452    }
00453 }
00454 
00455 void TGo4FitPanel::AboutToShowItemMenu() {
00456   TGo4LockGuard Global;
00457 
00458   if (ItemMenu==0) return;
00459   QFitItem* item = dynamic_cast<QFitItem*> (FitList->currentItem());
00460   if (item==0) return;
00461   ItemMenu->clear();
00462   if (!fxSlots->FillPopupForItem(item,ItemMenu)) return;
00463   for(uint n=0;n<ItemMenu->count();n++) {
00464      int id = ItemMenu->idAt(n);
00465      ItemMenu->connectItem(id, this, SLOT(ItemMenuItemSelected(int)));
00466   }
00467 }
00468 
00469 void TGo4FitPanel::ItemMenuItemSelected(int id) {
00470    TGo4LockGuard Global;
00471 
00472    QFitItem* item = dynamic_cast<QFitItem*> (FitList->currentItem());
00473    if (item==0) return;
00474    fxSlots->ExecPopupForItem(item, id /*, ItemMenu->text(id) */);
00475 }
00476 
00477 void TGo4FitPanel::focusInEvent( QFocusEvent* event) {
00478   TGo4LockGuard Global;
00479 
00480   UpdateStatusBar(0);
00481   QWidget::focusInEvent(event);
00482 }
00483 
00484 void TGo4FitPanel::windowActivationChange( bool OldActive) {
00485    TGo4LockGuard Global;
00486 
00487    UpdateStatusBar(0);
00488    QWidget::windowActivationChange(OldActive);
00489 }
00490 
00491 void TGo4FitPanel::dragEnterEvent( QDragEnterEvent * Event ) {
00492     TGo4LockGuard Global;
00493 
00494     fxSlots->DragEnterEvent(Event);
00495 }
00496 
00497 void TGo4FitPanel::dragMoveEvent(QDragMoveEvent * Event) {
00498   TGo4LockGuard Global;
00499 
00500   bool ignore = TRUE;
00501   if (QTextDrag::canDecode(Event)) {
00502     QWidget* w = childAt(Event->pos(), TRUE);
00503 
00504     if (w == (QWidget*)FitList->viewport()) {
00505       QPoint pnt = FitList->viewport()->mapFrom(this, Event->pos());
00506       QFitItem* item = dynamic_cast<QFitItem*> (FitList->itemAt(pnt));
00507       if (item) {
00508         fxSlots->DragMoveEvent(item->Object(), item->ObjectType(), Event);
00509         ignore = FALSE;
00510       }
00511     } else
00512 
00513     if ((w == Wiz_DataSlotsTable->viewport())) {
00514       QPoint pnt = Wiz_DataSlotsTable->viewport()->mapFrom(this, Event->pos());
00515       pnt = Wiz_DataSlotsTable->viewportToContents(pnt);
00516       int nrow = Wiz_DataSlotsTable->rowAt(pnt.y());
00517 
00518       if ((nrow>=0) && (nrow<=fxWizSlots->GetLast())) {
00519         TGo4FitSlot* slot = dynamic_cast<TGo4FitSlot*> (fxWizSlots->At(nrow));
00520         if (slot) {
00521           fxSlots->DragMoveEvent(slot, TGo4FitPanelSlots::ot_slot, Event);
00522           ignore = FALSE;
00523         }
00524        }
00525      } else
00526 
00527      if ((w==PageEmpty) || (w==PageEmptyLbl)) {
00528        fxSlots->DragMoveEvent(0, TGo4FitPanelSlots::ot_empty, Event);
00529        ignore = FALSE;
00530      } else
00531 
00532      if (w == Wiz_DataList->viewport()) {
00533        fxSlots->DragMoveEvent(0, TGo4FitPanelSlots::ot_wizdatalist, Event);
00534        ignore = FALSE;
00535      }
00536     }
00537   if (ignore) Event->ignore();
00538 }
00539 
00540 void TGo4FitPanel::dropEvent( QDropEvent * Event ) {
00541    TGo4LockGuard Global;
00542 
00543    QWidget* w = childAt(Event->pos(), TRUE);
00544 
00545    if(w==(QWidget*)FitList->viewport()) {
00546       QPoint pnt = FitList->viewport()->mapFrom(this, Event->pos());
00547       QFitItem* item = dynamic_cast<QFitItem*> (FitList->itemAt(pnt));
00548       if (item)
00549         fxSlots->DropEvent(item->Object(), item->ObjectType(), Event, item);
00550    } else
00551    if (w == Wiz_DataSlotsTable->viewport()) {
00552       QPoint pnt = Wiz_DataSlotsTable->viewport()->mapFrom(this, Event->pos());
00553       pnt = Wiz_DataSlotsTable->viewportToContents(pnt);
00554       int nrow = Wiz_DataSlotsTable->rowAt(pnt.y());
00555 
00556       if ((nrow>=0) && (nrow<=fxWizSlots->GetLast())) {
00557         TGo4FitSlot* slot = dynamic_cast<TGo4FitSlot*> (fxWizSlots->At(nrow));
00558         if (slot)
00559           fxSlots->DropEvent(slot, TGo4FitPanelSlots::ot_slot, Event);
00560       }
00561    } else
00562    if ((w==PageEmpty) || (w==PageEmptyLbl)) {
00563      fxSlots->DropEvent(0, TGo4FitPanelSlots::ot_empty, Event);
00564    } else
00565    if (w == Wiz_DataList->viewport())
00566      fxSlots->DropEvent(0, TGo4FitPanelSlots::ot_wizdatalist, Event);
00567 }
00568 
00569 void TGo4FitPanel::SetFillingWidget(bool zn) {
00570   fbFillingWidget = zn;
00571 }
00572 
00573 bool TGo4FitPanel::IsFillingWidget() {
00574    return fbFillingWidget;
00575 }
00576 
00577 void TGo4FitPanel::UpdatePFAmplLbl() {
00578    TGo4LockGuard Global;
00579 
00580    TGo4FitPeakFinder* finder = fxSlots->FitOptions() ? fxSlots->FitOptions()->GetPeakFinder() : 0;
00581    if (finder)
00582      PF_AmplLbl->setText(QString("Threshold: ")+QString::number(finder->Get0MaxAmplFactor()*100)+"%");
00583    else
00584      PF_AmplLbl->setText("Threshold:");
00585    PF_AmplLbl->adjustSize();
00586 }
00587 
00588 void TGo4FitPanel::UpdatePFRelNoiseLbl() {
00589    TGo4LockGuard Global;
00590 
00591    TGo4FitPeakFinder* finder = fxSlots->FitOptions() ? fxSlots->FitOptions()->GetPeakFinder() : 0;
00592 
00593    if (finder)
00594      PF_RelNoiseLbl->setText(QString("Noise factor: ")+QString::number(finder->Get2NoiseFactor()));
00595    else
00596      PF_RelNoiseLbl->setText("Noise factor: ");
00597    PF_RelNoiseLbl->adjustSize();
00598 }
00599 
00600 void TGo4FitPanel::PF_MinWidthEdt_textChanged( const QString & str )
00601 {
00602   TGo4LockGuard Global;
00603 
00604   if (IsFillingWidget()) return;
00605   bool ok;
00606   double zn = str.toDouble(&ok);
00607   if (fxSlots->FitOptions() && ok) {
00608     TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
00609     if (finder) finder->Set0MinWidth(zn);
00610   }
00611 }
00612 
00613 
00614 void TGo4FitPanel::PF_MaxWidthEdt_textChanged( const QString & str )
00615 {
00616   TGo4LockGuard Global;
00617 
00618   if (IsFillingWidget()) return;
00619   bool ok;
00620   double zn = str.toDouble(&ok);
00621   if (fxSlots->FitOptions() && ok) {
00622     TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
00623     if (finder) finder->Set0MaxWidth(zn);
00624   }
00625 }
00626 
00627 
00628 void TGo4FitPanel::PF_WidthEdit_textChanged( const QString & str)
00629 {
00630   TGo4LockGuard Global;
00631 
00632   if (IsFillingWidget()) return;
00633   bool ok;
00634   double zn = str.toDouble(&ok);
00635   if (fxSlots->FitOptions() && ok) {
00636     TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
00637     if (finder) finder->Set1LineWidth(zn);
00638   }
00639 }
00640 
00641 void TGo4FitPanel::PF_AmplSlider_valueChanged( int zn )
00642 {
00643   TGo4LockGuard Global;
00644 
00645   if (!IsFillingWidget() && fxSlots->FitOptions()) {
00646      TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
00647      if (finder) finder->Set0MaxAmplFactor(1.-zn/100.);
00648      UpdatePFAmplLbl();
00649   }
00650 }
00651 
00652 void TGo4FitPanel::PF_AmplSlider_sliderReleased()
00653 {
00654   TGo4LockGuard Global;
00655 
00656   if (!IsFillingWidget() && fxSlots)
00657     fxSlots->Button_PeakFinder();
00658 }
00659 
00660 void TGo4FitPanel::PF_RelNoiseSlider_valueChanged( int zn )
00661 {
00662   TGo4LockGuard Global;
00663 
00664   if (!IsFillingWidget() && fxSlots->FitOptions()) {
00665      TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
00666      if (finder) finder->Set2NoiseFactor((101-zn)/10.);
00667      UpdatePFRelNoiseLbl();
00668   }
00669 }
00670 
00671 void TGo4FitPanel::PF_RelNoiseSlider_sliderReleased()
00672 {
00673   TGo4LockGuard Global;
00674 
00675   if (!IsFillingWidget() && fxSlots)
00676     fxSlots->Button_PeakFinder();
00677 }
00678 
00679 void TGo4FitPanel::PF_MinNoiseEdit_textChanged( const QString & str)
00680 {
00681   TGo4LockGuard Global;
00682 
00683   if (IsFillingWidget()) return;
00684   bool ok;
00685   double zn = str.toDouble(&ok);
00686   if (fxSlots->FitOptions() && ok) {
00687     TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
00688     if (finder) finder->Set2NoiseMinimum(zn);
00689   }
00690 }
00691 
00692 
00693 void TGo4FitPanel::PF_SumUpSpin_valueChanged( int num)
00694 {
00695   TGo4LockGuard Global;
00696 
00697   if (!IsFillingWidget() && fxSlots->FitOptions()) {
00698     TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
00699     if (finder) {
00700        finder->Set2ChannelSum(num);
00701        fxSlots->Button_PeakFinder();
00702     }
00703   }
00704 }
00705 
00706 
00707 void TGo4FitPanel::UpdateWizDataList() {
00708   TGo4LockGuard Global;
00709 
00710    if (fxSlots->FitOptions()==0) return;
00711 
00712    TGo4Fitter* fitter = fxSlots->GetFitter();
00713 
00714    SetFillingWidget(TRUE);
00715 
00716    bool updatestack = FALSE, updatepaint = FALSE;
00717 
00718    Wiz_DataList->clear();
00719    if (fitter==0) fxSlots->FitOptions()->SetWizDataName("");
00720    else {
00721      if ((fxSlots->FitOptions()->GetWizData()==0) && (fitter->GetNumData()>0)) {
00722        fxSlots->FitOptions()->SetWizDataName(fitter->GetDataName(0));
00723        if (fxSlots->FitOptions()->WizPageIndex()<1) updatestack = TRUE;
00724        if (fiPaintMode==0) updatepaint = TRUE;
00725      }
00726 
00727      int selindx = -1;
00728      for(Int_t n=0;n<fitter->GetNumData();n++) {
00729        TGo4FitData* data = fitter->GetData(n);
00730        Wiz_DataList->insertItem(data->GetName());
00731        if (strcmp(data->GetName(), fxSlots->FitOptions()->GetWizDataName())==0) selindx = n;
00732      }
00733      Wiz_DataList->setSelected(selindx, TRUE);
00734      if (selindx<0) fxSlots->FitOptions()->SetWizDataName("");
00735                else Wiz_DataList->setSelected(selindx, TRUE);
00736    }
00737    UpdateWizDataBtns();
00738    SetFillingWidget(FALSE);
00739 
00740    if (updatestack) {
00741       fxSlots->FitOptions()->WizPageIndex() = 2;
00742       UpdateWizStackWidget();
00743    }
00744    if (updatepaint)
00745      UpdateWizPaint(1);
00746 
00747 }
00748 
00749 void TGo4FitPanel::UpdateWizDataBtns() {
00750   TGo4LockGuard Global;
00751 
00752    TGo4Fitter* fitter = fxSlots->GetFitter();
00753    if ((fitter==0) || (fxSlots->FitOptions()==0)) return;
00754    TGo4FitData* data = fxSlots->FitOptions()->GetWizData();
00755 
00756    Wiz_PFSetupBtn->setEnabled(data!=0);
00757 
00758    if (!fxSlots->WorkingWithPanel()) {
00759      Wiz_RebuildDataBtn->setShown(FALSE);
00760      Wiz_AddDataBtn->setShown(TRUE);
00761      Wiz_DelDataBtn->setShown(TRUE);
00762      Wiz_AddDataBtn->setEnabled(fitter!=0);
00763      Wiz_DelDataBtn->setEnabled(data!=0);
00764    } else {
00765      Wiz_RebuildDataBtn->setShown(TRUE);
00766      Wiz_RebuildDataBtn->setEnabled(fitter!=0);
00767      Wiz_AddDataBtn->setShown(FALSE);
00768      Wiz_DelDataBtn->setShown(FALSE);
00769    }
00770 }
00771 
00772 void TGo4FitPanel::UpdateWizModelsList(bool changestack) {
00773   TGo4LockGuard Global;
00774 
00775     SetFillingWidget(TRUE);
00776 
00777     Wiz_ModelList->clear();
00778     if (fxSlots->FitOptions()) {
00779 
00780         TGo4Fitter* fitter = fxSlots->GetFitter();
00781 
00782         Wiz_ShowAllMod->setChecked(fxSlots->FitOptions()->WizShowAllModels());
00783         int selindx = -1;
00784         if(fitter) {
00785            TGo4FitData* data = fxSlots->FitOptions()->GetWizData();
00786            int indx = 0;
00787            for(Int_t n=0;n<fitter->GetNumModel();n++) {
00788               TGo4FitModel* model = fitter->GetModel(n);
00789               if (data && !fxSlots->FitOptions()->WizShowAllModels())
00790                 if (!model->IsAssignTo(data->GetName())) continue;
00791 
00792               bool assign = FALSE;
00793               if (data && model->IsAssignTo(data->GetName())) assign = TRUE;
00794               if (assign) Wiz_ModelList->insertItem(QPixmap(SelectedXPM), model->GetName());
00795                      else Wiz_ModelList->insertItem(QPixmap(UnselectedXPM), model->GetName());
00796 
00797               if (strcmp(model->GetName(), fxSlots->FitOptions()->GetWizModelName())==0) selindx = indx;
00798               indx++;
00799            }
00800            Wiz_ModelList->setSelected(selindx, TRUE);
00801 
00802            if (selindx<0) fxSlots->FitOptions()->SetWizModelName("");
00803                      else Wiz_ModelList->ensureCurrentVisible();
00804 
00805         } else fxSlots->FitOptions()->SetWizModelName("");
00806        if (changestack)
00807          if (selindx>=0) fxSlots->FitOptions()->WizPageIndex() = 1; else
00808           if (fxSlots->FitOptions()->WizPageIndex()==1) fxSlots->FitOptions()->WizPageIndex() = 0;
00809     }
00810 
00811     UpdateWizModelsBtns();
00812     SetFillingWidget(FALSE);
00813     if(changestack)
00814       UpdateWizStackWidget();
00815 }
00816 
00817 void TGo4FitPanel::UpdateWizModelsBtns() {
00818   TGo4LockGuard Global;
00819 
00820    Wiz_AddModelBtn->setEnabled(FALSE);
00821    Wiz_DelModelBtn->setEnabled(FALSE);
00822    Wiz_ShowAllMod->setEnabled(FALSE);
00823 
00824    if (fxSlots->FitOptions()==0) return;
00825 
00826    TGo4Fitter* fitter = fxSlots->GetFitter();
00827    TGo4FitModel* model = fxSlots->FitOptions()->GetWizModel();
00828 //   TGo4FitData* data = fxSlots->FitOptions()->GetWizData();
00829 
00830    Wiz_ShowAllMod->setShown(!fxSlots->WorkingWithOnlyPad());
00831 
00832    if (fitter) {
00833       Wiz_AddModelBtn->setEnabled(TRUE);
00834       Wiz_DelModelBtn->setEnabled(model!=0);
00835       Wiz_ShowAllMod->setEnabled(TRUE);
00836 
00837    } else {
00838       Wiz_AddModelBtn->setEnabled(FALSE);
00839       Wiz_DelModelBtn->setEnabled(FALSE);
00840       Wiz_ShowAllMod->setEnabled(FALSE);
00841    }
00842 }
00843 
00844 void TGo4FitPanel::UpdateWizStackWidget() {
00845     TGo4LockGuard Global;
00846 
00847     SetFillingWidget(TRUE);
00848     TGo4Fitter* fitter = fxSlots->GetFitter();
00849 
00850     int indx = -1;
00851     if (fxSlots->FitOptions())
00852       if (fitter==0) fxSlots->FitOptions()->WizPageIndex() = -1;
00853                 else indx = fxSlots->FitOptions()->WizPageIndex();
00854 
00855     QWidget* target = 0;
00856 
00857     switch (indx) {
00858        case -1:
00859           target = Wiz_EmptyPage;
00860           break;
00861        case 0: {
00862           target = Wiz_FitterPage;
00863 
00864           int typ = fitter->GetFitFunctionType();
00865           if (typ==TGo4Fitter::ff_user) typ = TGo4Fitter::ff_least_squares;
00866           Wiz_FitFuncCmb->setCurrentItem(typ);
00867 
00868           Wiz_UseAmplEstimChk->setChecked(fxSlots->FitOptions()->UseAmplEstim());
00869           Wiz_MigradIterSpin->setValue(fxSlots->FitOptions()->NumMigradIter());
00870 
00871           break; 
00872        }
00873        
00874        case 1: {
00875           TGo4FitModel* model = fxSlots->FitOptions()->GetWizModel();
00876           if (model==0) break;
00877 
00878           target = Wiz_ModelPage;
00879 
00880           QString modelinfo;
00881           fxSlots->Wiz_GetModelInfo(model, &modelinfo);
00882           Wiz_ModelInfoLbl->setText(modelinfo);
00883 
00884           Wiz_BackgroundChk->setChecked(model->GetGroupIndex()==0);
00885 
00886           Wiz_ModelBufChk->setChecked(model->GetUseBuffers());
00887           Wiz_ModelBufChk->setEnabled(fxStatus->BuffersUsage()==3);
00888 
00889           FillParsTable(Wiz_ParTable, fitter, model, FALSE, fxWizPars);
00890 
00891           break; 
00892        }
00893 
00894        case 2: {
00895          TGo4FitData* data = fxSlots->FitOptions()->GetWizData();
00896          if (data==0) break;
00897 
00898          target = Wiz_DataPage;
00899 
00900          QString datainfo("Data: ");
00901          datainfo += data->GetName();
00902          datainfo += "  of class: ";
00903          datainfo += data->ClassName();
00904          if (fxStatus->IntegralMode()==1) {
00905             datainfo += "\nCounts=";
00906             double v = fitter->CalculatesIntegral(data->GetName(),0,kTRUE);
00907             datainfo += QString::number(v);  
00908          }
00909          if (fxStatus->IntegralMode()==2) {
00910             datainfo += "\nIntegral=";
00911             double v = fitter->CalculatesIntegral(data->GetName(),0,kFALSE);
00912             datainfo += QString::number(v);  
00913          }
00914          Wiz_DataInfoLbl->setText(datainfo);
00915 
00916          QString models("Models:");
00917          for(int n=0;n<fitter->GetNumModel();n++) {
00918             TGo4FitModel* model = fitter->GetModel(n);
00919             if (model->IsAssignTo(data->GetName())) {
00920                if (models.length()>45) {
00921                   models += " ...";
00922                   break; 
00923                }
00924                models += " ";
00925                models += model->GetName();
00926             }
00927          }
00928          Wiz_DataModelsLbl->setText(models);
00929 
00930          Wiz_DataBufChk->setChecked(
00931            (fxStatus->BuffersUsage()==1) || (fxStatus->BuffersUsage()==2) ||
00932            ((fxStatus->BuffersUsage()==3) && data->GetUseBuffers()));
00933          Wiz_DataBufChk->setEnabled(fxStatus->BuffersUsage()==3);
00934 
00935          fxWizSlots->Clear();
00936          data->FillSlotList(fxWizSlots);
00937 
00938          Wiz_DataSlotsTable->setNumRows(fxWizSlots->GetLast()+1);
00939 
00940          for(int n=0;n<=fxWizSlots->GetLast();n++) {
00941            TGo4FitSlot* slot = dynamic_cast<TGo4FitSlot*> (fxWizSlots->At(n));
00942            if (slot==0) continue;
00943 
00944            Wiz_DataSlotsTable->verticalHeader()->setLabel(n, slot->GetName());
00945            TObject* obj = slot->GetObject();
00946 
00947            if (obj==0) {
00948               Wiz_DataSlotsTable->setText(n, 0, " --- ");
00949               Wiz_DataSlotsTable->setText(n, 1, slot->GetClass()->GetName());
00950               Wiz_DataSlotsTable->setText(n, 2, "false");
00951            } else {
00952               Wiz_DataSlotsTable->setText(n, 0, obj->GetName());
00953               Wiz_DataSlotsTable->setText(n, 1, obj->ClassName());
00954               if (slot->GetOwned()) Wiz_DataSlotsTable->setText(n, 2, "true");
00955                                else Wiz_DataSlotsTable->setText(n, 2, "false");
00956            }
00957 
00958            QString info;
00959            fxSlots->Wiz_GetSlotSourceInfo(slot, &info);
00960            Wiz_DataSlotsTable->setText(n, 3, info);
00961          }
00962 
00963          for(int n=0;n<=3;n++)
00964            Wiz_DataSlotsTable->adjustColumn(n);
00965 
00966          Wiz_DataUseRangeBtn->setEnabled(fxSlots->Wiz_DataHasPad());
00967          if (data)
00968            Wiz_DataClearRangesBtn->setEnabled(data->IsAnyRangeLimits());
00969          Wiz_DrawDataBtn->setEnabled(data!=0);
00970 
00971          break; 
00972       }
00973       case 3: {
00974          target = Wiz_PFPage;
00975 
00976          TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
00977          if (finder==0) break;
00978          
00979          UpdateStatusBar(0);
00980 
00981          FindersTab->setCurrentPage(finder->GetPeakFinderType());
00982 
00983          Wiz_PFUsePolynChk->setChecked(finder->GetUsePolynom());
00984          Wiz_PFPolynSpin->setEnabled(finder->GetUsePolynom());
00985          Wiz_PFPolynSpin->setValue(finder->GetPolynomOrder());
00986 
00987          PF_MinWidthEdt->setText(QString::number(finder->Get0MinWidth()));
00988          PF_MaxWidthEdt->setText(QString::number(finder->Get0MaxWidth()));
00989          PF_AmplSlider->setValue(int(100*(1.-finder->Get0MaxAmplFactor())));
00990          UpdatePFAmplLbl();
00991 
00992          PF_WidthEdit->setText(QString::number(finder->Get1LineWidth()));
00993 
00994          int zn = int(10*finder->Get2NoiseFactor());  // from 1..100
00995          PF_RelNoiseSlider->setValue(101 - zn);
00996          UpdatePFRelNoiseLbl();
00997          PF_MinNoiseEdit->setText(QString::number(finder->Get2NoiseMinimum()));
00998          PF_SumUpSpin->setValue(finder->Get2ChannelSum());
00999 
01000          break; 
01001       }
01002     }
01003 
01004     if (target) Wiz_Stack->raiseWidget(target);
01005            else Wiz_Stack->raiseWidget(Wiz_EmptyPage);
01006 
01007     SetFillingWidget(FALSE);
01008 }
01009 
01010 void TGo4FitPanel::SetWizPaint(int mode) {
01011   TGo4LockGuard Global;
01012   if (mode>=0) fiPaintMode = mode;
01013 }
01014 
01015 void TGo4FitPanel::UpdateWizPaint(int mode) {
01016     TGo4LockGuard Global;
01017 
01018     fxSlots->Wiz_ClearPaint();
01019 
01020     if (fxSlots->FitOptions()==0) return;
01021 
01022     if (mode>=0) fiPaintMode = mode;
01023 
01024     TGo4FitModel* model = fxSlots->FitOptions()->GetWizModel();
01025     TGo4FitData* data = fxSlots->FitOptions()->GetWizData();
01026 
01027     if (data && (fiPaintMode==1)) fxSlots->Wiz_PaintData();
01028     if (model && (fiPaintMode==2)) fxSlots->Wiz_PaintModel();
01029 }
01030 
01031 void TGo4FitPanel::Wiz_DataListSelect(int indx)
01032 {
01033   TGo4LockGuard Global;
01034 
01035   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01036   QString name = Wiz_DataList->text(indx);
01037 
01038   if ( (name==fxSlots->FitOptions()->GetWizDataName()) &&
01039        (fxSlots->FitOptions()->WizPageIndex() == 2) ) return;
01040   fxSlots->FitOptions()->SetWizDataName(name);
01041   fxSlots->FitOptions()->WizPageIndex() = 2;
01042   UpdateWizDataBtns();
01043   UpdateWizModelsList(FALSE);
01044   UpdateWizStackWidget();
01045   UpdateWizPaint(1);
01046 
01047 }
01048 
01049 void TGo4FitPanel::Wiz_DataList_highlighted( int indx)
01050 {
01051   TGo4LockGuard Global;
01052 
01053   Wiz_DataListSelect(indx);
01054 }
01055 
01056 void TGo4FitPanel::Wiz_ModelListSelect(int indx, bool ontext)
01057 {
01058   TGo4LockGuard Global;
01059 
01060   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01061 
01062   QString name = Wiz_ModelList->text(indx);
01063 
01064   bool needupdate = ( (name != fxSlots->FitOptions()->GetWizModelName()) ||
01065                       (fxSlots->FitOptions()->WizPageIndex() != 1) );
01066 
01067   fxSlots->FitOptions()->SetWizModelName(name);
01068   fxSlots->FitOptions()->WizPageIndex() = 1;
01069 
01070   if (!ontext) {
01071 
01072     TGo4Fitter* fitter = fxSlots->GetFitter();
01073     TGo4FitModel* model = fxSlots->FitOptions()->GetWizModel();
01074     TGo4FitData* data = fxSlots->FitOptions()->GetWizData();
01075     if ((fitter!=0) && (data!=0) && (model!=0)) {
01076        bool wasassigned = model->IsAssignTo(data->GetName());
01077        if (wasassigned) model->ClearAssignmentTo(data->GetName());
01078                    else model->AssignToData(data->GetName());
01079 
01080       SetFillingWidget(TRUE);
01081       if (!wasassigned) Wiz_ModelList->changeItem(QPixmap(SelectedXPM), model->GetName(), indx);
01082                    else Wiz_ModelList->changeItem(QPixmap(UnselectedXPM), model->GetName(), indx);
01083       Wiz_ModelList->setSelected(indx, TRUE);
01084       SetFillingWidget(FALSE);
01085       needupdate = TRUE;
01086     }
01087   }
01088 
01089   if (needupdate) {
01090     UpdateWizModelsBtns();
01091     UpdateWizStackWidget();
01092     UpdateWizPaint(2);
01093   }
01094 }
01095 
01096 void TGo4FitPanel::Wiz_ModelList_highlighted(int indx)
01097 {
01098   TGo4LockGuard Global;
01099 
01100   Wiz_ModelListSelect(indx, TRUE);
01101 }
01102 
01103 
01104 void TGo4FitPanel::Wiz_AddDataBtn_clicked()
01105 {
01106   TGo4LockGuard Global;
01107 
01108    if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01109    QPopupMenu menu(0,"WizPopup");
01110 
01111    fxSlots->Wiz_PrepareDataTypeList(&menu);
01112    int id =  menu.exec(Wiz_AddDataBtn->mapToGlobal(QPoint(5,5)));
01113    TGo4FitData* data = fxSlots->Wiz_CreateNewData(id);
01114    if (data) {
01115      fxSlots->FitOptions()->SetWizDataName(data->GetName());
01116      fxSlots->FitOptions()->WizPageIndex() = 2;
01117      UpdateWizDataList();
01118      UpdateWizModelsList(FALSE);
01119      UpdateWizStackWidget();
01120      UpdateWizPaint(1);
01121      UpdateStatusBar(0);
01122    }
01123 }
01124 
01125 
01126 void TGo4FitPanel::Wiz_DelDataBtn_clicked()
01127 {
01128   TGo4LockGuard Global;
01129 
01130   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01131 
01132   if (fxSlots->Wiz_RemoveData()) {
01133     UpdateWizDataList();
01134     UpdateWizModelsList(FALSE);
01135     fxSlots->FitOptions()->WizPageIndex() = 0;
01136     UpdateWizStackWidget();
01137     UpdateWizPaint(0);
01138     UpdateStatusBar(0);
01139   }
01140 }
01141 
01142 
01143 void TGo4FitPanel::Wiz_AddModelBtn_clicked()
01144 {
01145   TGo4LockGuard Global;
01146 
01147    if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01148    QPopupMenu menu(0,"WizPopup");
01149 
01150    fxSlots->Wiz_PrepareModelTypeList(&menu);
01151    int id =  menu.exec(Wiz_AddModelBtn->mapToGlobal(QPoint(5,5)));
01152    TGo4FitModel* model = fxSlots->Wiz_CreateNewModel(id);
01153    if (model) fxSlots->FitOptions()->SetWizModelName(model->GetName());
01154    UpdateWizModelsList(TRUE);
01155    if(fxSlots->FitOptions()->GetWizModel())  UpdateWizPaint(2);
01156    UpdateStatusBar(0);
01157 }
01158 
01159 
01160 void TGo4FitPanel::Wiz_DelModelBtn_clicked()
01161 {
01162   TGo4LockGuard Global;
01163 
01164   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01165 
01166   TGo4Fitter* fitter = fxSlots->GetFitter();
01167   if (fitter==0) return;
01168 
01169   if(fxStatus->NeedConfirmation())
01170     if ( QMessageBox::information(0,"Delete models",
01171        QString("Are you sure to delete selected models"),
01172        QMessageBox::Yes, QMessageBox::No) == QMessageBox::No ) return;
01173 
01174   for(uint n=0; n<Wiz_ModelList->count();n++) {
01175      if (!Wiz_ModelList->isSelected(n)) continue;
01176      QString name = Wiz_ModelList->text(n);
01177      fitter->RemoveModel(name, kTRUE);
01178   }
01179 
01180   fxSlots->FitOptions()->SetWizModelName("");
01181   UpdateWizModelsList(TRUE);
01182   UpdateWizPaint(0);
01183   UpdateStatusBar(0);
01184 }
01185 
01186 void TGo4FitPanel::Wiz_ShowAllMod_toggled(bool zn)
01187 {
01188   TGo4LockGuard Global;
01189 
01190   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01191   fxSlots->FitOptions()->WizShowAllModels() = zn;
01192   UpdateWizModelsList(TRUE);
01193   UpdateWizPaint(2);
01194 }
01195 
01196 
01197 void TGo4FitPanel::Wiz_FitFuncCmb_activated( int typ)
01198 {
01199   TGo4LockGuard Global;
01200 
01201   if (!IsFillingWidget() && fxSlots->GetFitter())
01202     fxSlots->GetFitter()->SetFitFunctionType(typ);
01203 }
01204 
01205 
01206 void TGo4FitPanel::Wiz_FitNameEdt_textChanged( const QString & name)
01207 {
01208   TGo4LockGuard Global;
01209 
01210   TGo4Fitter* fitter = fxSlots->GetFitter();
01211   if(IsFillingWidget() || (fitter==0) || (name.length()==0) || (fxSlots->FitOptions()==0)) return;
01212   fitter->SetName(name);
01213 
01214   fxSlots->FitOptions()->WizPageIndex() = 0;
01215   UpdateWizStackWidget();
01216   UpdateWizPaint(0);
01217 
01218   UpdateStatusBar(0);
01219 }
01220 
01221 
01222 void TGo4FitPanel::Wiz_ParTable_valueChanged( int nrow, int ncol)
01223 {
01224   TGo4LockGuard Global;
01225 
01226   ParsTableChanged(Wiz_ParTable, nrow, ncol, FALSE, fxWizPars, TRUE);
01227 }
01228 
01229 
01230 void TGo4FitPanel::Wiz_DataList_doubleClicked( QListBoxItem * )
01231 {
01232   TGo4LockGuard Global;
01233 
01234   if (fxSlots->FitOptions()==0) return;
01235   TGo4Fitter* fitter = fxSlots->GetFitter();
01236   TGo4FitData* data = fxSlots->FitOptions()->GetWizData();
01237   if ((data==0) || (fitter==0)) return;
01238   bool ok;
01239   QString newname = QInputDialog::getText("Change data name", "Input new name", QLineEdit::Normal, data->GetName(), &ok, this);
01240   if (ok && (newname.length()>0) && (newname!=data->GetName())) {
01241      if (fitter->FindData(newname)) {
01242        QMessageBox::information(this, "Fit panel", "Unable to rename data.\n Name " +
01243                                 newname + " already exists","return");
01244        return;
01245      }
01246      fitter->ChangeDataNameInAssignments(data->GetName(), newname);
01247      data->SetName(newname);
01248      fxSlots->FitOptions()->SetWizDataName(newname);
01249      UpdateWizDataList();
01250      UpdateWizPaint(1);
01251   }
01252 }
01253 
01254 
01255 void TGo4FitPanel::Wiz_ModelList_doubleClicked( QListBoxItem * )
01256 {
01257   TGo4LockGuard Global;
01258 
01259   if (fxSlots->FitOptions()==0) return;
01260   TGo4Fitter* fitter = fxSlots->GetFitter();
01261   TGo4FitModel* model = fxSlots->FitOptions()->GetWizModel();
01262   if ((model==0) || (fitter==0)) return;
01263   bool ok;
01264   QString newname = QInputDialog::getText("Change model name", "Input new name", QLineEdit::Normal, model->GetName(), &ok, this);
01265   if (ok && (newname.length()>0) && (newname!=model->GetName())) {
01266      if (fitter->FindModel(newname)) {
01267        QMessageBox::information(this, "Fit panel", QString("Unable to rename model.\n Name ")+
01268                                 newname + " already exists\n", "Return");
01269        return;
01270      }
01271      model->SetName(newname);
01272      fxSlots->FitOptions()->SetWizModelName(newname);
01273 //     Wiz_ModelList->changeItem(newname, Wiz_ModelList->index(item));
01274 
01275      UpdateWizModelsList(TRUE);
01276      UpdateWizPaint(2);
01277    }
01278 }
01279 
01280 void TGo4FitPanel::Wiz_RebuildDataBtn_clicked()
01281 {
01282   TGo4LockGuard Global;
01283 
01284   fxSlots->Wiz_RebuildDataList();
01285 }
01286 
01287 void TGo4FitPanel::Wiz_DataBufChk_toggled( bool zn)
01288 {
01289   TGo4LockGuard Global;
01290 
01291   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01292   TGo4FitData* data = fxSlots->FitOptions()->GetWizData();
01293   if (data) data->SetUseBuffers(zn);
01294 }
01295 
01296 
01297 void TGo4FitPanel::Wiz_UseAmplEstimChk_toggled( bool chk)
01298 {
01299   TGo4LockGuard Global;
01300 
01301    if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01302    fxSlots->FitOptions()->UseAmplEstim() = chk;
01303 }
01304 
01305 
01306 void TGo4FitPanel::Wiz_MigradIterSpin_valueChanged( int num)
01307 {
01308   TGo4LockGuard Global;
01309 
01310    if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01311    fxSlots->FitOptions()->NumMigradIter() = num;
01312 }
01313 
01314 
01315 void TGo4FitPanel::Wiz_DataSlotsTable_contextMenuRequested( int nrow, int ncol, const QPoint& pnt )
01316 {
01317   TGo4LockGuard Global;
01318 
01319   if (IsFillingWidget() || (fxWizSlots==0)) return;
01320 
01321   if ((nrow<0) || (ncol<0) || (nrow>fxWizSlots->GetLast())) return;
01322 
01323   TGo4FitSlot* slot = dynamic_cast<TGo4FitSlot*> (fxWizSlots->At(nrow));
01324   if (slot==0) return;
01325 
01326   QPopupMenu menu(0,"SlotPopup");
01327 
01328   if (fxSlots->FillPopupForSlot(slot,&menu)) {
01329     int id =  menu.exec(pnt);
01330     fxSlots->ExecutePopupForSlot(0, slot, id /*, menu.text(id) */);
01331   }
01332 }
01333 
01334 void TGo4FitPanel::Wiz_DataUseRangeBtn_clicked()
01335 {
01336   TGo4LockGuard Global;
01337 
01338   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01339 
01340   fxSlots->Wiz_UseSelectedRange();
01341 }
01342 
01343 
01344 void TGo4FitPanel::Wiz_DataClearRangesBtn_clicked()
01345 {
01346   TGo4LockGuard Global;
01347 
01348   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01349   TGo4FitData* data = fxSlots->FitOptions()->GetWizData();
01350   if (data) {
01351      data->ClearRanges();
01352      fxSlots->UpdateActivePage();
01353   }
01354 }
01355 
01356 
01357 void TGo4FitPanel::Wiz_DrawDataBtn_clicked()
01358 {
01359   TGo4LockGuard Global;
01360 
01361   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01362   if (fxSlots->FitOptions()->GetWizData())
01363     fxSlots->Button_FitterDraw(fxSlots->FitOptions()->GetWizData());
01364 }
01365 
01366 void TGo4FitPanel::MainAttachBtn_clicked()
01367 {
01368   TGo4LockGuard Global;
01369 
01370   UpdateStatusBar(0);
01371 
01372   fxSlots->Button_WorkWithPanel();
01373 }
01374 
01375 void TGo4FitPanel::MainFitBtn_clicked()
01376 {
01377    TGo4LockGuard Global;
01378 
01379    QApplication::setOverrideCursor( Qt::WaitCursor );
01380    
01381    fxSlots->Button_PerformFit();
01382    
01383    QApplication::restoreOverrideCursor();
01384 }
01385 
01386 void TGo4FitPanel::MainDrawBtn_clicked()
01387 {
01388   TGo4LockGuard Global;
01389 
01390   fxSlots->Button_FitterDraw();
01391 }
01392 
01393 
01394 void TGo4FitPanel::MainFindBtn_clicked()
01395 {
01396   TGo4LockGuard Global;
01397 
01398    if (fxSlots->GetFitter()==0) return;
01399    fxSlots->Button_PeakFinder();
01400 }
01401 
01402 
01403 void TGo4FitPanel::Wiz_DataList_clicked( QListBoxItem * )
01404 {
01405   TGo4LockGuard Global;
01406 
01407   Wiz_DataListSelect(Wiz_DataList->currentItem());
01408 }
01409 
01410 
01411 void TGo4FitPanel::Wiz_DataList_pressed( QListBoxItem * )
01412 {
01413   TGo4LockGuard Global;
01414 
01415   Wiz_DataListSelect(Wiz_DataList->currentItem());
01416 }
01417 
01418 
01419 void TGo4FitPanel::Wiz_DataList_selected( int indx)
01420 {
01421   TGo4LockGuard Global;
01422 
01423   Wiz_DataListSelect(indx);
01424 }
01425 
01426 
01427 void TGo4FitPanel::Wiz_ModelList_selected( int indx)
01428 {
01429   TGo4LockGuard Global;
01430 
01431   Wiz_ModelListSelect(indx, TRUE);
01432 }
01433 
01434 
01435 void TGo4FitPanel::MainParsBtn_clicked()
01436 {
01437   TGo4LockGuard Global;
01438 
01439   fxStatus->ParsWidgetShown() = !fxStatus->ParsWidgetShown();
01440 
01441   fxSlots->UpdateActivePage();
01442 }
01443 
01444 void TGo4FitPanel::FillParsWidget() {
01445   TGo4Fitter* fitter = fxSlots->GetFitter();
01446   if (fitter==0) return;
01447   SetFillingWidget(TRUE);
01448 
01449   Double_t FF = fitter->GetResultFF();
01450   Int_t NDF = fitter->GetResultNDF();
01451   if ((FF==0) && (NDF==0)) Par_FitterResLbl->hide();
01452   else {
01453     Par_FitterResLbl->setText("Result: Fit func = " + QString::number(FF) +
01454                                     "  NDF = " + QString::number(NDF));
01455     Par_FitterResLbl->show();
01456   }
01457 
01458   FillParsTable(ParsTable, fitter, 0, LineParsChk->isChecked(), fxParsTableList);
01459   SetFillingWidget(FALSE);
01460 }
01461 
01462 void TGo4FitPanel::LineParsChk_toggled(bool)
01463 {
01464   TGo4LockGuard Global;
01465 
01466   if (IsFillingWidget()) return;
01467 
01468   TGo4Fitter* fitter = fxSlots->GetFitter();
01469   if (fitter==0) return;
01470   SetFillingWidget(TRUE);
01471   FillParsTable(ParsTable, fitter, 0, LineParsChk->isChecked(), fxParsTableList);
01472   WidgetStack->raiseWidget(PageParameters);
01473   SetFillingWidget(FALSE);
01474 }
01475 
01476 
01477 void TGo4FitPanel::ParsTable_valueChanged( int nrow, int ncol)
01478 {
01479   TGo4LockGuard Global;
01480 
01481   if (IsFillingWidget()) return;
01482 
01483   ParsTableChanged(ParsTable, nrow, ncol, LineParsChk->isChecked(), fxParsTableList, FALSE);
01484 }
01485 
01486 
01487 void TGo4FitPanel::FillParsTable(QTable* table, TGo4Fitter* fitter, TGo4FitModel* model, bool LinesView, TObjArray* TableList) {
01488    if ((table==0) || (fitter==0) || (TableList==0)) return;
01489 
01490    if (model && LinesView) return;
01491    TableList->Clear();
01492 
01493    for (int n=0;n<table->numRows();n++) table->clearCell(n, 0);
01494 
01495    for (int nr=0;nr<table->numRows();nr++)
01496      for (int nc=0;nc<table->numCols();nc++)
01497        if (table->item(nr,nc))
01498           table->item(nr,nc)->setEnabled(TRUE);
01499 
01500    if (LinesView) {
01501      int MaxAxis = 0;
01502      for (Int_t n=0; n<fitter->GetNumModel();n++) {
01503         TGo4FitModel* m = fitter->GetModel(n);
01504         if (m==0) continue;
01505         Double_t zn;
01506         for (int naxis=0;naxis<10;naxis++)
01507           if (m->GetPosition(naxis,zn) || m->GetWidth(naxis,zn)) MaxAxis = naxis;
01508      }
01509 
01510      int nfcol = (fxStatus->IntegralMode()>0) ? 2 : 1;
01511      table->setNumCols(nfcol+(MaxAxis+1)*2);
01512      table->horizontalHeader()->setLabel(0,"Amplitude");
01513      if (fxStatus->IntegralMode()==1)
01514         table->horizontalHeader()->setLabel(1,"Counts");
01515      else if (fxStatus->IntegralMode()==2)   
01516         table->horizontalHeader()->setLabel(1,"Integral");
01517      else if (fxStatus->IntegralMode()==3)   
01518         table->horizontalHeader()->setLabel(1,"Gauss Int");
01519 
01520      for (int naxis=0;naxis<=MaxAxis;naxis++) {
01521         QString capt = QString("Position ") + QString::number(naxis);
01522         table->horizontalHeader()->setLabel(nfcol + naxis*2, capt);
01523         if (fxStatus->RecalculateGaussWidth())
01524           capt = QString("FWHM ");
01525         else
01526           capt = QString("Sigma ");
01527         capt += QString::number(naxis);
01528         table->horizontalHeader()->setLabel(nfcol+1 + naxis*2, capt);
01529      }
01530 
01531      table->setNumRows(fitter->GetNumModel());
01532 
01533      for (Int_t n=0; n<fitter->GetNumModel();n++) {
01534         TGo4FitModel* m = fitter->GetModel(n);
01535         TableList->Add(m);
01536 
01537         bool recalculatew = (m->InheritsFrom(TGo4FitModelGauss1::Class()) ||
01538                              m->InheritsFrom(TGo4FitModelGauss2::Class()) ||
01539                              m->InheritsFrom(TGo4FitModelGaussN::Class())) &&
01540                              fxStatus->RecalculateGaussWidth();
01541         double widthk = recalculatew ? 2.3548 : 1.0;
01542 
01543         table->verticalHeader()->setLabel(n, m->GetName());
01544         table->setText(n, 0, QString::number(m->GetAmplValue()));
01545         table->item(n,0)->setEnabled(m->GetAmplPar());
01546 
01547         if (fxStatus->IntegralMode()>0) {
01548            Double_t v = 0.;
01549            TGo4FitData* data = fxSlots->FitOptions() ? fxSlots->FitOptions()->GetWizData() : 0;
01550            switch (fxStatus->IntegralMode()) {
01551               case 1: 
01552                  if (data!=0)
01553                    v = fitter->CalculatesIntegral(data->GetName(), m->GetName(), kTRUE); 
01554                  else
01555                    v = fitter->CalculatesModelIntegral(m->GetName(), kTRUE); 
01556                  break;
01557               case 2: 
01558                  if (data!=0)
01559                    v = fitter->CalculatesIntegral(data->GetName(), m->GetName(), kFALSE); 
01560                  else
01561                    v = fitter->CalculatesModelIntegral(m->GetName(), kFALSE); 
01562                  break;
01563               case 3: v = m->Integral(); break;
01564               default: v = 0;
01565            } 
01566            if ((v<=0.) && (fxStatus->IntegralMode()==3)) 
01567              table->setText(n, 1, "---");
01568            else 
01569              table->setText(n, 1, QString::number(v));
01570            table->item(n,1)->setEnabled(FALSE);
01571         }
01572 
01573         for (int naxis=0;naxis<=MaxAxis;naxis++) {
01574 
01575             Double_t pos, width;
01576 
01577             if (m->GetPosition(naxis,pos)) {
01578               table->setText(n, nfcol+naxis*2, QString::number(pos));
01579               table->item(n, nfcol+naxis*2)->setEnabled(TRUE);
01580             } else {
01581               table->setText(n, nfcol+naxis*2, "---");
01582               table->item(n, nfcol+naxis*2)->setEnabled(FALSE);
01583             }
01584 
01585             if (m->GetWidth(naxis,width)) {
01586                table->setText(n, nfcol+1+naxis*2, QString::number(width*widthk));
01587                table->item(n, nfcol+1+naxis*2)->setEnabled(TRUE);
01588             } else {
01589               table->setText(n, nfcol+1+naxis*2, "---");
01590               table->item(n, nfcol+1+naxis*2)->setEnabled(FALSE);
01591             }
01592         }
01593      }
01594 
01595    } else {
01596 
01597      TGo4FitParsList* pars = (model==0) ? dynamic_cast<TGo4FitParsList*> (fitter) :
01598                                           dynamic_cast<TGo4FitParsList*> (model);
01599      if (pars==0) return;
01600 
01601      for(Int_t n=0; n<pars->NumPars();n++)
01602        TableList->Add(pars->GetPar(n));
01603 
01604      table->setNumCols(6);
01605      table->horizontalHeader()->setLabel(0,"Fixed");
01606      table->horizontalHeader()->setLabel(1,"Value");
01607      table->horizontalHeader()->setLabel(2,"Error");
01608      table->horizontalHeader()->setLabel(3,"Epsilon");
01609      table->horizontalHeader()->setLabel(4,"Min");
01610      table->horizontalHeader()->setLabel(5,"Max");
01611 
01612      table->setNumRows(TableList->GetLast()+1);
01613 
01614      for(Int_t n=0;n<=TableList->GetLast();n++) {
01615        TGo4FitParameter* par = dynamic_cast<TGo4FitParameter*> (TableList->At(n));
01616        if (par==0) continue;
01617 
01618        if (model) table->verticalHeader()->setLabel(n, par->GetName());
01619              else table->verticalHeader()->setLabel(n, par->GetFullName());
01620 
01621        QCheckTableItem* checkitem = new QCheckTableItem(table, "fix");
01622        checkitem->setChecked(par->GetFixed());
01623        table->setItem(n, 0, checkitem);
01624 
01625        table->setText(n, 1, QString::number(par->GetValue()));
01626        table->item(n,1)->setEnabled(!par->GetFixed());
01627 
01628        table->setText(n, 2, QString::number(par->GetError()));
01629 
01630        Double_t eps, min, max;
01631        if (par->GetEpsilon(eps)) table->setText(n, 3, QString::number(eps));
01632                             else table->setText(n, 3, "");
01633 
01634 
01635        if (par->GetRange(min,max)) {
01636          table->setText(n, 4, QString::number(min));
01637          table->setText(n, 5, QString::number(max));
01638        } else {
01639          table->setText(n, 4, "");
01640          table->setText(n, 5, "");
01641        }
01642      }
01643    }
01644 
01645    for(int n=0;n<table->numCols();n++)
01646      table->adjustColumn(n);
01647 
01648    table->verticalHeader()->adjustHeaderSize();
01649    table->horizontalHeader()->adjustHeaderSize();
01650 }
01651 
01652 void TGo4FitPanel::ParsTableChanged(QTable* table, int nrow, int ncol, bool LinesView, TObjArray* TableList, bool updatepaint) {
01653    if (IsFillingWidget() || (table==0) || (TableList==0)) return;
01654 
01655    if ((nrow<0) || (nrow>TableList->GetLast())) return;
01656 
01657    if (LinesView) {
01658       TGo4FitModel* model = dynamic_cast<TGo4FitModel*> (TableList->At(nrow));
01659       if (model==0) return;
01660 
01661       bool recalculatew = (model->InheritsFrom(TGo4FitModelGauss1::Class()) ||
01662                            model->InheritsFrom(TGo4FitModelGauss2::Class()) ||
01663                            model->InheritsFrom(TGo4FitModelGaussN::Class())) &&
01664                            fxStatus->RecalculateGaussWidth();
01665       double widthk = recalculatew ? 2.3548 : 1.0;
01666 
01667       bool ok = FALSE;
01668       double zn = table->text(nrow, ncol).toDouble(&ok);
01669       if (!ok) return;
01670 
01671       if (ncol==0) model->SetAmplValue(zn); else {
01672          int nfcol = (fxStatus->IntegralMode()>0) ? 2 : 1;
01673          int naxis = (ncol-nfcol) /2;
01674          if ((ncol-nfcol) % 2 == 0) model->SetPosition(naxis, zn);
01675                                else model->SetWidth(naxis, zn/widthk);
01676       }
01677 
01678    } else {
01679 
01680        TGo4FitParameter* par = dynamic_cast<TGo4FitParameter*> (TableList->At(nrow));
01681        if (par==0) return;
01682 
01683        switch (ncol) {
01684          case 0: {
01685            QCheckTableItem* checkitem = dynamic_cast<QCheckTableItem*> ( table->item(nrow,0));
01686            if (checkitem) par->SetFixed(checkitem->isChecked());
01687            table->item(nrow,1)->setEnabled(!par->GetFixed());
01688            break; }
01689          case 1: {
01690            if (par->GetFixed()) break;
01691            bool ok = FALSE;
01692            double zn = table->text(nrow,1).toDouble(&ok);
01693            if (ok) {
01694              par->SetValue(zn);
01695              if (updatepaint) UpdateWizPaint(2);
01696            }
01697            break; }
01698          case 2: {
01699            if (par->GetFixed()) break;
01700            bool ok = FALSE;
01701            double zn = table->text(nrow,2).toDouble(&ok);
01702            if (ok) par->SetError(zn);
01703            break; }
01704          case 3: {
01705            bool ok = FALSE;
01706            double zn = table->text(nrow,3).toDouble(&ok);
01707            if (ok) par->SetEpsilon(zn);
01708            break; }
01709          case 4:
01710          case 5: {
01711            bool ok = FALSE;
01712            double zn = table->text(nrow, ncol).toDouble(&ok);
01713            if(ok) {
01714              Double_t min, max;
01715              bool changemin = false;
01716              bool changemax = false;
01717              if (!par->GetRange(min,max)) {
01718                 max = zn; changemin = (ncol!=4);
01719                 min = zn; changemax = (ncol!=5);
01720              } else
01721              if (ncol==4) { 
01722                min = zn; 
01723                if (max<min) { max = min; changemax = true; }
01724              } else
01725              if (ncol==5) { 
01726                max = zn; 
01727                if (min>max) { min = max; changemin = true; }
01728              }
01729              cout << "Set range " << min << "  " << max << endl;
01730              par->SetRange(min,max);
01731              SetFillingWidget(TRUE);
01732              if (changemin)
01733                table->setText(nrow, 4, QString::number(min));
01734              if (changemax)
01735                table->setText(nrow, 5, QString::number(max));
01736              SetFillingWidget(FALSE);
01737            } else {
01738              if ((table->text(nrow, ncol).length()==0) && 
01739                  (table->text(nrow, 9-ncol).length()==0)) {
01740                     par->ClearRange();
01741                     cout << "Clear range for " << par->GetName() << endl; 
01742                  }
01743                  
01744            }
01745            break; }
01746        }
01747    }
01748 }
01749 
01750 
01751 void TGo4FitPanel::Wiz_ModelBufChk_toggled( bool zn)
01752 {
01753   TGo4LockGuard Global;
01754 
01755   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01756   TGo4FitModel* model = fxSlots->FitOptions()->GetWizModel();
01757   if (model) model->SetUseBuffers(zn);
01758 }
01759 
01760 
01761 void TGo4FitPanel::Wiz_PFSetupBtn_clicked()
01762 {
01763   TGo4LockGuard Global;
01764 
01765   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01766 
01767   if (fxSlots->FitOptions()->GetWizData()==0) return;
01768   fxSlots->FitOptions()->WizPageIndex() = 3;
01769   UpdateWizStackWidget();
01770   UpdateWizPaint(1);
01771 }
01772 
01773 
01774 void TGo4FitPanel::Wiz_PFUsePolynChk_toggled( bool zn )
01775 {
01776   TGo4LockGuard Global;
01777 
01778   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01779 
01780   TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
01781   if (finder) finder->SetUsePolynom(zn);
01782 
01783   Wiz_PFPolynSpin->setEnabled(zn);
01784 }
01785 
01786 
01787 void TGo4FitPanel::Wiz_PFPolynSpin_valueChanged( int zn )
01788 {
01789   TGo4LockGuard Global;
01790 
01791   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01792 
01793   TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
01794   if (finder) finder->SetPolynomOrder(zn);
01795 }
01796 
01797 
01798 
01799 void TGo4FitPanel::Smp_PolynomBtn_clicked()
01800 {
01801   TGo4LockGuard Global;
01802 
01803   fxSlots->Button_SimpleFit(0);
01804 }
01805 
01806 
01807 void TGo4FitPanel::Smp_GaussianBtn_clicked()
01808 {
01809   TGo4LockGuard Global;
01810 
01811   fxSlots->Button_SimpleFit(1);
01812 }
01813 
01814 
01815 void TGo4FitPanel::Smp_LorenzBtn_clicked()
01816 {
01817   TGo4LockGuard Global;
01818 
01819   fxSlots->Button_SimpleFit(2);
01820 }
01821 
01822 
01823 void TGo4FitPanel::Smp_ExponentBtn_clicked()
01824 {
01825   TGo4LockGuard Global;
01826 
01827   fxSlots->Button_SimpleFit(3);
01828 }
01829 
01830 
01831 void TGo4FitPanel::Smp_ClearBtn_clicked()
01832 {
01833   TGo4LockGuard Global;
01834 
01835   fxSlots->Button_SimpleClear();
01836 }
01837 
01838 
01839 void TGo4FitPanel::Wiz_MinSetupBtn_clicked()
01840 {
01841   TGo4LockGuard Global;
01842 
01843   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01844 
01845   fxSlots->FitOptions()->WizPageIndex() = 0;
01846   UpdateWizStackWidget();
01847   UpdateWizPaint(0);
01848 }
01849 
01850 
01851 void TGo4FitPanel::FindersTab_currentChanged( QWidget * )
01852 {
01853   TGo4LockGuard Global;
01854 
01855   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01856 
01857   TGo4FitPeakFinder* finder = fxSlots->FitOptions()->GetPeakFinder();
01858   if (finder)
01859     finder->SetPeakFinderType(FindersTab->currentPageIndex());
01860 
01861 }
01862 
01863 
01864 void TGo4FitPanel::Wiz_ModelList_clicked( QListBoxItem * item, const QPoint & pnt)
01865 {
01866   TGo4LockGuard Global;
01867 
01868   if (item==0) return;
01869 
01870   QRect rect = Wiz_ModelList->itemRect(item);
01871   QPoint pnt2 = Wiz_ModelList->viewport()->mapFromGlobal(pnt);
01872 
01873   Wiz_ModelListSelect(Wiz_ModelList->currentItem(), (pnt2.x() - rect.left()) >=15 );
01874 }
01875 
01876 
01877 void TGo4FitPanel::Wiz_BackgroundChk_toggled( bool chk)
01878 {
01879   TGo4LockGuard Global;
01880 
01881   if (IsFillingWidget() || (fxSlots->FitOptions()==0)) return;
01882 
01883   TGo4FitModel* model = fxSlots->FitOptions()->GetWizModel();
01884   if (model)
01885     if (chk) model->SetBackgroundGroupIndex();
01886         else model->SetGroupIndex(-1);
01887 }
01888 
01889 
01890 void TGo4FitPanel::PF_MinWidthEdt_returnPressed()
01891 {
01892   TGo4LockGuard Global;
01893 
01894   if (!IsFillingWidget() && fxSlots)
01895     fxSlots->Button_PeakFinder();
01896 }
01897 
01898 
01899 void TGo4FitPanel::PF_MaxWidthEdt_returnPressed()
01900 {
01901   TGo4LockGuard Global;
01902 
01903   if (!IsFillingWidget() && fxSlots)
01904     fxSlots->Button_PeakFinder();
01905 }
01906 
01907 
01908 void TGo4FitPanel::PF_WidthEdit_returnPressed()
01909 {
01910   TGo4LockGuard Global;
01911 
01912   if (!IsFillingWidget() && fxSlots)
01913     fxSlots->Button_PeakFinder();
01914 }
01915 
01916 
01917 void TGo4FitPanel::PF_MinNoiseEdit_returnPressed()
01918 {
01919   TGo4LockGuard Global;
01920 
01921   if (!IsFillingWidget() && fxSlots)
01922     fxSlots->Button_PeakFinder();
01923 }
01924 
01925 void TGo4FitPanel::ParsTable_contextMenuRequested(int nrow, int ncol, const QPoint &)
01926 {
01927 }
01928 
01929 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:58 2005 for Go4-v2.10-5 by doxygen1.2.15