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

/Go4GUI/TGo4CreateNewHistogramSlots.cxx

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 #include "TGo4CreateNewHistogramSlots.h"
00017 
00018 #include "TH1.h"
00019 #include "TH2.h"
00020 #include "TH3.h"
00021 
00022 #include "qlineedit.h"
00023 #include "qstring.h"
00024 #include "qbuttongroup.h"
00025 
00026 #include "Go4CommandsAnalysis/TGo4ComCreateHistogram.h"
00027 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00028 #include "TGo4BrowserSlots.h"
00029 #include "TGo4CreateHisDefaults.h"
00030 #include "TGo4CreateNewHistogramStatus.h"
00031 #include "TGo4CreateNewHistogram.h"
00032 
00033 TGo4CreateNewHistogramSlots::TGo4CreateNewHistogramSlots(const char * name, const char * title, TGo4CreateNewHistogram * p)
00034                  :TGo4SlotsBaseClass(name , title), fxGUI(p)
00035 {
00036 // TGo4LockGuard Global;
00037 
00038    fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00039    fxTGo4CreateNewHistogramStatus= new TGo4CreateNewHistogramStatus("TGo4CreateNewHistogramStatus", "Test Status 1");
00040       fxTGo4GUIRegistry->RegisterSlotClass(this, fxTGo4CreateNewHistogramStatus, p);
00041 
00042 }
00043 
00044 void TGo4CreateNewHistogramSlots::SetAsDefaultValues(int HisTypNo)
00045 {
00046       TGo4CreateHisDefaults *fxTGo4CreateHisDefaults =fxTGo4CreateNewHistogramStatus->GetCreateHisDefaults();
00047 
00048     if( fxTGo4CreateHisDefaults==0) {
00049        fxTGo4CreateHisDefaults= new  TGo4CreateHisDefaults(fxGUI->HisName->text().data(), fxGUI->HisTitle->text().data());
00050       fxTGo4CreateNewHistogramStatus->SetCreateHisDefaults(fxTGo4CreateHisDefaults);
00051     }
00052    fxTGo4CreateHisDefaults->SetName(fxGUI->HisName->text().data());
00053     fxTGo4CreateHisDefaults->SetTitle(fxGUI->HisTitle->text().data());
00054     fxTGo4CreateHisDefaults->SetHisDefaults(HisTypNo,  fxGUI->XNoOfBins->text().toInt(),  fxGUI->YNoOfBins->text().toInt(),
00055                                   fxGUI->ZNoOfBins->text().toInt(),
00056               fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong(),
00057               fxGUI->Ymin->text().toLong(), fxGUI->Ymax->text().toLong(),
00058               fxGUI->Zmin->text().toLong(), fxGUI->Zmax->text().toLong()     );
00059 
00060 }
00061 
00062 
00063 void TGo4CreateNewHistogramSlots::GetDefaultsValues(int HisTypNo)
00064 {
00065    int Type=HisTypNo;
00066    int NoOfBinsX=fxGUI->XNoOfBins->text().toInt();
00067    int NoOfBinsY=fxGUI->YNoOfBins->text().toInt();
00068    int NoOfBinsZ=fxGUI->ZNoOfBins->text().toInt();
00069    long minX =fxGUI->Xmin->text().toLong();
00070    long maxX=fxGUI->Xmax->text().toLong();
00071    long minY =fxGUI->Ymin->text().toLong();
00072    long maxY=fxGUI->Ymax->text().toLong();
00073    long minZ=fxGUI->Zmin->text().toLong();
00074    long maxZ=fxGUI->Zmax->text().toLong();
00075 
00076       TGo4CreateHisDefaults *fxTGo4CreateHisDefaults =fxTGo4CreateNewHistogramStatus->GetCreateHisDefaults();
00077     if( fxTGo4CreateHisDefaults!=0) {
00078       fxTGo4CreateHisDefaults->GetHisDefaults(Type, NoOfBinsX, NoOfBinsY, NoOfBinsZ, minX, maxX,minY, maxY,minZ,maxZ);
00079       fxGUI->HisName->setText(fxTGo4CreateHisDefaults->GetName());
00080       fxGUI->HisTitle->setText(fxTGo4CreateHisDefaults->GetTitle());
00081     }
00082 
00083      fxGUI->SetHistoType(Type);
00084 //    fxGUI->HistoType(Type);
00085 
00086     QString string;
00087     string = string.setNum(NoOfBinsX);
00088     fxGUI->XNoOfBins->setText(string);
00089 
00090     string = string.setNum(NoOfBinsY);
00091     fxGUI->YNoOfBins->setText(string);
00092 
00093     string = string.setNum(NoOfBinsZ);
00094     fxGUI->ZNoOfBins->setText(string);
00095 
00096     string = string.setNum(minX);
00097     fxGUI->Xmin->setText(string);
00098 
00099     string = string.setNum(minY);
00100     fxGUI->Ymin->setText(string);
00101 
00102     string = string.setNum(minZ);
00103     fxGUI->Zmin->setText(string);
00104 
00105     string = string.setNum(maxX);
00106     fxGUI->Xmax->setText(string);
00107 
00108     string = string.setNum(maxY);
00109     fxGUI->Ymax->setText(string);
00110 
00111     string = string.setNum(maxZ);
00112     fxGUI->Zmax->setText(string);
00113 
00114 }
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124 void TGo4CreateNewHistogramSlots::CreateLocalHist(int HisTypNo)
00125 {
00126    TDirectory* savdir=gDirectory;
00127    gROOT->cd(); // make sure that new object does not belong to last file!
00128    TGo4BrowserSlots *fxTGo4BrowserSlots= (TGo4BrowserSlots *) fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots");
00129    TH1* newhisto=0;
00130    switch(HisTypNo)
00131    {
00132        case 1:    //TH1S
00133             newhisto = new TH1S((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00134                 fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong());
00135              break;
00136        case 2:    //TH1D
00137             newhisto = new TH1D((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00138                 fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong());
00139              break;
00140 
00141        case 3:    //TH1F
00142             newhisto = new TH1F((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00143              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong());
00144              break;
00145 
00146        case 4:    //TH1I
00147             newhisto = new TH1I((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00148              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong());
00149              break;
00150 
00151        case 5:    //TH2S
00152             newhisto = new TH2S((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00153              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong(),
00154              fxGUI->YNoOfBins->text().toInt()  , fxGUI->Ymin->text().toLong(), fxGUI->Ymax->text().toLong());
00155              break;
00156        case 6:    //TH2D
00157             newhisto = new TH2D((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00158              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong(),
00159              fxGUI->YNoOfBins->text().toInt()  , fxGUI->Ymin->text().toLong(), fxGUI->Ymax->text().toLong());
00160              break;
00161 
00162        case 7:    //TH2F
00163             newhisto = new TH2F((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00164              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong(),
00165              fxGUI->YNoOfBins->text().toInt()  , fxGUI->Ymin->text().toLong(), fxGUI->Ymax->text().toLong());
00166              break;
00167        case 8:    //TH2I
00168             newhisto = new TH2I((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00169              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong(),
00170              fxGUI->YNoOfBins->text().toInt()  , fxGUI->Ymin->text().toLong(), fxGUI->Ymax->text().toLong());
00171              break;
00172 
00173 
00174        case 9:    //TH3S
00175              newhisto = new TH3S((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00176              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong(),
00177              fxGUI->YNoOfBins->text().toInt()  , fxGUI->Ymin->text().toLong(), fxGUI->Ymax->text().toLong(),
00178              fxGUI->ZNoOfBins->text().toInt()  , fxGUI->Zmin->text().toLong(), fxGUI->Zmax->text().toLong());
00179              break;
00180 
00181        case 10:    //TH3D
00182              newhisto = new TH3D((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00183              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong(),
00184              fxGUI->YNoOfBins->text().toInt()  , fxGUI->Ymin->text().toLong(), fxGUI->Ymax->text().toLong(),
00185              fxGUI->ZNoOfBins->text().toInt()  , fxGUI->Zmin->text().toLong(), fxGUI->Zmax->text().toLong());
00186              break;
00187        case 11:    //TH3F
00188              newhisto = new TH3F((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00189              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong(),
00190              fxGUI->YNoOfBins->text().toInt()  , fxGUI->Ymin->text().toLong(), fxGUI->Ymax->text().toLong(),
00191              fxGUI->ZNoOfBins->text().toInt()  , fxGUI->Zmin->text().toLong(), fxGUI->Zmax->text().toLong());
00192              break;
00193        case 12:    //TH3I
00194              newhisto = new TH3I((const char *) fxGUI->HisName->text(),(const char*) fxGUI->HisTitle->text(),
00195              fxGUI->XNoOfBins->text().toInt()  , fxGUI->Xmin->text().toLong(), fxGUI->Xmax->text().toLong(),
00196              fxGUI->YNoOfBins->text().toInt()  , fxGUI->Ymin->text().toLong(), fxGUI->Ymax->text().toLong(),
00197              fxGUI->ZNoOfBins->text().toInt()  , fxGUI->Zmin->text().toLong(), fxGUI->Zmax->text().toLong());
00198              break;
00199        default:
00200         break;
00201    }
00202 if(newhisto) newhisto->SetDirectory(gROOT);
00203 fxTGo4BrowserSlots->AddLocalObject(newhisto);
00204 delete newhisto; // AddLocalObject will clone, so we must clean our original!
00205 savdir->cd();
00206 }
00207 
00208 
00209 
00210 
00211 void TGo4CreateNewHistogramSlots::CreateRemoteHis(int Type,const char* HisName,const char* HisTitle,
00212       int XNoOfBins,long Xmin,long Xmax,
00213       int YNoOfBins,long Ymin,long Ymax,
00214          int ZNoOfBins,long Zmin,long Zmax)
00215 {
00216    // TGo4LockGuard Global;
00217 
00218    TGo4ComCreateHistogram *fxCreatHis= new TGo4ComCreateHistogram();
00219 
00220    fxCreatHis->SetHistogramName(HisName);
00221    fxCreatHis->SetHistogramTitle(HisTitle);
00222 
00223    switch(Type)
00224    {
00225        case 1:    //TH1S
00226             fxCreatHis->SetObjectClassName("TH1S");
00227             fxCreatHis->SetDimension(1);
00228             fxCreatHis->SetXbins(XNoOfBins);
00229             fxCreatHis->SetXmin(Xmin);
00230             fxCreatHis->SetXmax(Xmax);
00231 
00232              break;
00233 
00234 
00235        case 2:    //TH1D
00236 
00237             fxCreatHis->SetObjectClassName("TH1D");
00238             fxCreatHis->SetDimension(1);
00239             fxCreatHis->SetXbins(XNoOfBins);
00240             fxCreatHis->SetXmin(Xmin);
00241             fxCreatHis->SetXmax(Xmax);
00242              break;
00243 
00244          case 3:    //TH1F
00245 
00246             fxCreatHis->SetObjectClassName("TH1F");
00247             fxCreatHis->SetDimension(1);
00248             fxCreatHis->SetXbins(XNoOfBins);
00249             fxCreatHis->SetXmin(Xmin);
00250             fxCreatHis->SetXmax(Xmax);
00251 
00252              break;
00253       case 4:    //TH1I
00254 
00255             fxCreatHis->SetObjectClassName("TH1I");
00256             fxCreatHis->SetDimension(1);
00257             fxCreatHis->SetXbins(XNoOfBins);
00258             fxCreatHis->SetXmin(Xmin);
00259             fxCreatHis->SetXmax(Xmax);
00260 
00261              break;
00262        case 5:    //TH2S
00263 
00264             fxCreatHis->SetObjectClassName("TH2S");
00265             fxCreatHis->SetDimension(2);
00266             fxCreatHis->SetXbins(XNoOfBins);
00267             fxCreatHis->SetXmin(Xmin);
00268             fxCreatHis->SetXmax(Xmax);
00269 
00270             fxCreatHis->SetYbins(YNoOfBins);
00271             fxCreatHis->SetYmin(Ymin);
00272             fxCreatHis->SetYmax(Ymax);
00273 
00274              break;
00275 
00276        case 6:    //TH2D
00277 
00278             fxCreatHis->SetObjectClassName("TH2D");
00279             fxCreatHis->SetDimension(2);
00280             fxCreatHis->SetXbins(XNoOfBins);
00281             fxCreatHis->SetXmin(Xmin);
00282             fxCreatHis->SetXmax(Xmax);
00283 
00284             fxCreatHis->SetYbins(YNoOfBins);
00285             fxCreatHis->SetYmin(Ymin);
00286             fxCreatHis->SetYmax(Ymax);
00287 
00288              break;
00289 
00290 
00291        case 7:    //TH2F
00292 
00293             fxCreatHis->SetObjectClassName("TH2F");
00294             fxCreatHis->SetDimension(2);
00295             fxCreatHis->SetXbins(XNoOfBins);
00296             fxCreatHis->SetXmin(Xmin);
00297             fxCreatHis->SetXmax(Xmax);
00298 
00299             fxCreatHis->SetYbins(YNoOfBins);
00300             fxCreatHis->SetYmin(Ymin);
00301             fxCreatHis->SetYmax(Ymax);
00302 
00303              break;
00304 
00305        case 8:    //TH2I
00306 
00307             fxCreatHis->SetObjectClassName("TH2I");
00308             fxCreatHis->SetDimension(2);
00309             fxCreatHis->SetXbins(XNoOfBins);
00310             fxCreatHis->SetXmin(Xmin);
00311             fxCreatHis->SetXmax(Xmax);
00312 
00313             fxCreatHis->SetYbins(YNoOfBins);
00314             fxCreatHis->SetYmin(Ymin);
00315             fxCreatHis->SetYmax(Ymax);
00316 
00317              break;
00318 
00319 
00320 
00321        case 9:    //TH3S
00322             fxCreatHis->SetObjectClassName("TH3S");
00323             fxCreatHis->SetDimension(3);
00324             fxCreatHis->SetXbins(XNoOfBins);
00325             fxCreatHis->SetXmin(Xmin);
00326             fxCreatHis->SetXmax(Xmax);
00327 
00328             fxCreatHis->SetYbins(YNoOfBins);
00329             fxCreatHis->SetYmin(Ymin);
00330             fxCreatHis->SetYmax(Ymax);
00331 
00332             fxCreatHis->SetZbins(ZNoOfBins);
00333             fxCreatHis->SetZmin(Zmin);
00334             fxCreatHis->SetZmax(Zmax);
00335 
00336              break;
00337 
00338        case 10:    //TH3D
00339 
00340             fxCreatHis->SetObjectClassName("TH3D");
00341             fxCreatHis->SetDimension(3);
00342             fxCreatHis->SetXbins(XNoOfBins);
00343             fxCreatHis->SetXmin(Xmin);
00344             fxCreatHis->SetXmax(Xmax);
00345 
00346             fxCreatHis->SetYbins(YNoOfBins);
00347             fxCreatHis->SetYmin(Ymin);
00348             fxCreatHis->SetYmax(Ymax);
00349 
00350             fxCreatHis->SetZbins(ZNoOfBins);
00351             fxCreatHis->SetZmin(Zmin);
00352             fxCreatHis->SetZmax(Zmax);
00353 
00354              break;
00355 
00356        case 11:    //TH3F
00357             fxCreatHis->SetObjectClassName("TH3F");
00358             fxCreatHis->SetDimension(3);
00359             fxCreatHis->SetXbins(XNoOfBins);
00360             fxCreatHis->SetXmin(Xmin);
00361             fxCreatHis->SetXmax(Xmax);
00362 
00363             fxCreatHis->SetYbins(YNoOfBins);
00364             fxCreatHis->SetYmin(Ymin);
00365             fxCreatHis->SetYmax(Ymax);
00366 
00367             fxCreatHis->SetZbins(ZNoOfBins);
00368             fxCreatHis->SetZmin(Zmin);
00369             fxCreatHis->SetZmax(Zmax);
00370 
00371              break;
00372        case 12:    //TH3I
00373             fxCreatHis->SetObjectClassName("TH3I");
00374             fxCreatHis->SetDimension(3);
00375             fxCreatHis->SetXbins(XNoOfBins);
00376             fxCreatHis->SetXmin(Xmin);
00377             fxCreatHis->SetXmax(Xmax);
00378 
00379             fxCreatHis->SetYbins(YNoOfBins);
00380             fxCreatHis->SetYmin(Ymin);
00381             fxCreatHis->SetYmax(Ymax);
00382 
00383             fxCreatHis->SetZbins(ZNoOfBins);
00384             fxCreatHis->SetZmin(Zmin);
00385             fxCreatHis->SetZmax(Zmax);
00386 
00387              break;
00388 
00389 
00390        default:
00391         break;
00392    }
00393 
00394    fxTGo4GUIRegistry->SubmitCommand(fxCreatHis);
00395 
00396 }
00397 
00398 
00399 void TGo4CreateNewHistogramSlots::SetGUI(TGo4CreateNewHistogram *GUI )
00400 {
00401    // TGo4LockGuard Global;
00402       fxGUI= GUI;
00403    fxTGo4GUIRegistry->GuiIsChanged(this, GUI);
00404 }
00405 
00406 TGo4Status * TGo4CreateNewHistogramSlots::GetStatus()
00407 {
00408    return fxTGo4CreateNewHistogramStatus;
00409 }
00410 TGo4CreateNewHistogramSlots::~TGo4CreateNewHistogramSlots()
00411 {
00412    delete fxTGo4CreateNewHistogramStatus;
00413 }
00414 
00415 
00416 
00417 
00418 
00419 
00420 
00421 //----------------------------END OF GO4 SOURCE FILE ---------------------

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