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

/Go4GUI/TGo4PreviewPanelSlots.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 "TGo4PreviewPanelSlots.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TH1.h"
00021 #include "TH2.h"
00022 #include "TArrow.h"
00023 #include "THStack.h"
00024 #include "TMultiGraph.h"
00025 #include "TCanvas.h"
00026 #include "TFrame.h"
00027 #include "TAxis.h"
00028 #include "TLatex.h"
00029 #include "TLegend.h"
00030 #include "TLegendEntry.h"
00031 #include "TKey.h"
00032 #include "TFile.h"
00033 #include "TProcessID.h"
00034 #include "TGLabel.h"
00035 
00036 #include "qstring.h"
00037 #include "qinputdialog.h"
00038 
00039 #include "qtroot/interface/tqrootwindow.h"
00040 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00041 #include "Go4ConditionsBase/TGo4WinCond.h"
00042 #include "Go4ConditionsBase/TGo4WinCondView.h"
00043 #include "Go4ConditionsBase/TGo4PolyCond.h"
00044 #include "Go4ConditionsBase/TGo4PolyCondView.h"
00045 #include "Go4ConditionsBase/TGo4Marker.h"
00046 #include "TGo4PadOptions.h"
00047 #include "TGo4MarkerSetup.h"
00048 #include "TGo4PreviewPanelStatus.h"
00049 #include "Go4FitGUI/TGo4FitPanelSlots.h"
00050 #include "Go4FitGUI/TGo4FitGUIArrow.h"
00051 #include "TGo4PreviewPanel.h"
00052 
00054 #if __GO4ROOTVERSION__ > 40006
00055 #include "TVirtualPadEditor.h"
00056 #endif
00057 
00058 
00059 TGo4PreviewPanelSlots::TGo4PreviewPanelSlots(const char * name, const char * title, TGo4PreviewPanel * p)
00060                        :TGo4SlotsBaseClass(name , title), fxTGo4PreviewPanel (p),
00061                       fiMouseMode(kMouseROOT), fuPickCounter(0),
00062                       fbTwoDimRegion(kFALSE) ,fbPickAgain(kFALSE), fbCreateNewMarker(kTRUE)
00063 #if __GO4ROOTVERSION__ > 40006
00064                       , fxPeditor(0)
00065 #endif
00066 {
00067    // TGo4LockGuard Global;
00068       char StatusName[256];
00069    fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00070    snprintf(StatusName,255,"%s%s",title,"_Status" );
00071    fxTGo4PreviewPanelStatus= new TGo4PreviewPanelStatus((Text_t *)StatusName,(Text_t *) title);
00072    fxTGo4PreviewPanelStatus->SetSlots(this);
00073    fxTGo4GUIRegistry->RegisterSlotClass(this, fxTGo4PreviewPanelStatus, p);
00074    fxMarkerList= new TList;
00075    gROOT->GetListOfCleanups()->Add(fxMarkerList);
00076    fxRegionList= new TList;
00077    gROOT->GetListOfCleanups()->Add(fxRegionList);
00078    fxPolygonList= new TList;
00079    gROOT->GetListOfCleanups()->Add(fxPolygonList);
00080    fxLateXList= new TList;
00081    fxLateXCleanups= new TList;
00082    gROOT->GetListOfCleanups()->Add(fxLateXCleanups);
00083    fxArrowList= new TList;
00084    fxArrowCleanups= new TList;
00085    gROOT->GetListOfCleanups()->Add(fxArrowCleanups);
00086    fxLegendCleanups= new TList;
00087    gROOT->GetListOfCleanups()->Add(fxLegendCleanups);
00088 
00089 }
00090 
00091 TGo4Status * TGo4PreviewPanelSlots::GetStatus()
00092 {
00093    return fxTGo4PreviewPanelStatus;
00094 }
00095 
00096 void TGo4PreviewPanelSlots::SetGUI(TGo4PreviewPanel *GUI )
00097 {
00098    fxTGo4PreviewPanel = GUI;
00099    fxTGo4GUIRegistry->GuiIsChanged(this, GUI);
00100 }
00101 
00102 void TGo4PreviewPanelSlots::DivideCanvas(int X, int Y)
00103 {
00104    // TGo4LockGuard Global;
00105     fxTGo4PreviewPanel->Divide(X,Y);
00106 }
00107 TCanvas *TGo4PreviewPanelSlots::GetCanvas()
00108 {
00109    return fxTGo4PreviewPanel->GetCanvas();
00110 }
00111 TGo4PreviewPanelSlots::~TGo4PreviewPanelSlots()
00112 {
00113 
00114    // TGo4LockGuard Global;
00115    fxMarkerList->Delete();
00116    gROOT->GetListOfCleanups()->Remove(fxMarkerList);
00117    delete fxMarkerList;
00118    fxRegionList->Delete();
00119    gROOT->GetListOfCleanups()->Remove(fxRegionList);
00120    delete fxRegionList;
00121    fxPolygonList->Delete();
00122    gROOT->GetListOfCleanups()->Remove(fxPolygonList);
00123    delete fxPolygonList;
00124    gROOT->GetListOfCleanups()->Remove(fxLateXCleanups);
00125    delete fxLateXCleanups;
00126    fxLateXList->Delete();
00127    delete fxLateXList;
00128    gROOT->GetListOfCleanups()->Remove(fxArrowCleanups);
00129    delete fxArrowCleanups;
00130    fxArrowList->Delete();
00131    delete fxArrowList;
00132    fxLegendCleanups->Delete();
00133    gROOT->GetListOfCleanups()->Remove(fxLegendCleanups);
00134    delete fxLegendCleanups;
00135 #if __GO4ROOTVERSION__ > 40006
00136    if(fxPeditor) fxPeditor->DeleteEditors(); // prevent problems with root's subeditor cache
00137    delete fxPeditor;   
00138 #endif
00139    //delete fxEditorFrame;
00140    delete fxTGo4PreviewPanelStatus;
00141 }
00142 
00143 void TGo4PreviewPanelSlots::UpdatePad(TPad *Pad, TH1 *h1, Bool_t updatemarkers, Bool_t updateoptions)
00144 {
00145    // TGo4LockGuard Global;
00146    Int_t Ymin;
00147    Int_t Ymax;
00148    Int_t Xmin;
00149    Int_t Xmax;
00150    QString Vtitle;
00151    if(h1!=0){
00152       Xmin   = 1 ;
00153       Xmax   = h1->GetNbinsX();
00154       if(h1->InheritsFrom("TH2")){
00155          Ymin   = 1;
00156          Ymax   = ((TH2 *)h1)->GetNbinsY();
00157       }else {
00158          Ymin   =(Int_t) h1->GetMinimum();
00159          Ymax   =(Int_t) (1.1 *(h1->GetMaximum()));
00160      }
00161       fxTGo4PreviewPanelStatus->SetPadDrawOption(Pad, Xmin, Xmax, Ymin, Ymax);
00162       //cout << "TGo4PreviewPanelSlots sees " << h1->GetDrawOption() << endl;
00163       if(updateoptions)
00164          fxTGo4PreviewPanelStatus->SetPadDrawOption(Pad, h1->GetDrawOption());
00165       if(!fxTGo4PreviewPanel->IsFreezeTitle())
00166          {
00167             Vtitle= fxTGo4PreviewPanel->name();
00168             Vtitle.append(h1->GetName());
00169             fxTGo4PreviewPanel->setCaption(Vtitle);
00170          }
00171    }else{
00172       if(updateoptions) fxTGo4PreviewPanelStatus->SetPadDrawOption(Pad,"");
00173    }
00174    if(updatemarkers) {
00175       ScanMarkers(Pad);
00176       SetMarkersHistogram();
00177       SetRegionsHistogram();
00178       SetPolygonsHistogram();
00179    }
00180    
00181    InformUpdatePad(Pad);   
00182 }
00183 
00184 
00185 void TGo4PreviewPanelSlots::UpdatePad(TPad *Pad, THStack *h1, Bool_t updatemarkers)
00186 {
00187    // TGo4LockGuard Global;
00188    Int_t Ymin=0;
00189    Int_t Ymax=0;
00190    Int_t Xmin=0;
00191    Int_t Xmax=0;
00192    QString Vtitle;
00193    if(h1!=0)
00194       {
00195          if(h1->GetHists()->GetSize()>0) // check for non empty stack
00196             {
00197                Xmin   = 1 ;
00198                Xmax   = h1->GetXaxis()->GetNbins();
00199                Ymin   = (Int_t) h1->GetMinimum();
00200                Ymax   = (Int_t) (1.1 *(h1->GetMaximum()));
00201             }
00202          fxTGo4PreviewPanelStatus->SetPadDrawOption(Pad, Xmin, Xmax, Ymin, Ymax);
00203          fxTGo4PreviewPanelStatus->SetPadDrawOption(Pad, h1->GetDrawOption());
00204          if(!fxTGo4PreviewPanel->IsFreezeTitle())
00205             {
00206                Vtitle= fxTGo4PreviewPanel->name();
00207                Vtitle.append(h1->GetTitle());
00208                Vtitle.append(" : ");
00209                fxTGo4PreviewPanel->setCaption(Vtitle);
00210             }
00211       }
00212    else
00213       {
00214          fxTGo4PreviewPanelStatus->SetPadDrawOption(Pad,"");
00215       } // if(h1!=0)
00216    if(updatemarkers) 
00217       {
00218          ScanMarkers(Pad);
00219          SetMarkersHistogram();
00220          SetRegionsHistogram();
00221          SetPolygonsHistogram();
00222       }      
00223    InformUpdatePad(Pad);   
00224 }
00225 
00226 void TGo4PreviewPanelSlots::InformUpdatePad(TPad *Pad)
00227 {
00228    TGo4FitPanelSlots* fitslts = dynamic_cast<TGo4FitPanelSlots*> 
00229       (fxTGo4GUIRegistry->GetSlotClass("TGo4FitPanelSlots"));
00230    if (fitslts!=0) {
00231      if (Pad==0) 
00232         fitslts->ViewPanelRemoved(fxTGo4PreviewPanel);
00233      else   
00234         fitslts->ViewPanelPadUpdate(fxTGo4PreviewPanel, Pad);
00235    }
00236 }
00237 
00238 void TGo4PreviewPanelSlots::AddObject(TNamed* obj, TQRootCanvas *c, TPad *p) 
00239 {
00240    if (obj==0) return;
00241 
00242    if ((fxTGo4PreviewPanel==0) || (p==0)) return;
00243 
00244    if (obj->InheritsFrom(TGo4Condition::Class())) {
00245       TGo4PadOptions* opt = fxTGo4PreviewPanelStatus->GetPadOptions(p);
00246       if (opt)
00247         opt->SetCondition(dynamic_cast<TGo4Condition*> (obj));
00248    }
00249 
00250 }
00251 
00252 void TGo4PreviewPanelSlots::MouseClick(TPad* pad)
00253 {
00254 //SetMarkersHistogram();
00255 //SetRegionsHistogram();
00256 //SetPolygonsHistogram();
00257 if(pad && pad==gPad)
00258    {
00259       Bool_t ok=kFALSE;
00260       Int_t px = 0;
00261       Int_t py = 0;
00262       Double_t x = 0;
00263       Double_t y = 0;
00264       Double_t xmin = 0;
00265       Double_t xmax = 0;
00266       Double_t ymin = 0;
00267       Double_t ymax = 0;
00268       Int_t ix=0;
00269       TH1* hist;
00270       TGo4Marker* mark=0;
00271       TGo4WinCond* conny=0;
00272       TLatex* latex=0;
00273       TString name;
00274       switch(fiMouseMode)
00275          {
00276          case kMouseROOT:
00277             //gROOT->cd(); // set root memory as dir for creating secondary histograms
00278             gROOT->SetEditorMode("");
00279             ActivateSelectedObject(pad);            
00280             break;
00281 
00282          case kMouseConditionEditor:
00283             // in this mode, picks are controlled from condition editor
00284             break;
00285 
00286          case kMousePickCursor:
00287             // we have a click on our working pad, get coordinates:
00288             gROOT->SetEditorMode("");
00289             px = pad->GetEventX();
00290             py = pad->GetEventY();
00291             x  = pad->PadtoX(pad->AbsPixeltoX(px));
00292             y  = pad->PadtoY(pad->AbsPixeltoY(py));
00293 
00294             if(IsCreateNewMarker())
00295                {
00296                   mark=new TGo4Marker(x,y,28);
00297                   fxMarkerList->Add(mark);
00298                   ix=TGo4Marker::GetInstances()-1;
00299                   mark->SetMarkerColor((ix)%6 +2);
00300                   mark->SetHistogram(fxTGo4PreviewPanel->GetPadHistogram(pad));
00301                   mark->Draw();
00302                }
00303             else
00304                {
00305                   mark= GetActiveMarker(pad);
00306                   if(mark)
00307                      {
00308                         mark->SetX(x);
00309                         mark->SetY(y);
00310                      }
00311                }
00312             pad->Modified();
00313             pad->Update();
00314             if(!IsPickAgain()) fiMouseMode=kMouseROOT; // reset pick
00315             break;
00316 
00317          case kMousePickLimits:
00318             gROOT->SetEditorMode("");
00319             px = pad->GetEventX();
00320             py = pad->GetEventY();
00321             x  = pad->PadtoX(pad->AbsPixeltoX(px));
00322             y  = pad->PadtoY(pad->AbsPixeltoY(py));
00323             if(fuPickCounter==0)
00324                {
00325                    // pick the first time after enabling limits record:
00326                   if(IsCreateNewMarker())
00327                      {
00328                         hist=fxTGo4PreviewPanel->GetPadHistogram(pad);
00329                         fbTwoDimRegion=(hist && hist->GetDimension()>1);
00330                         ix=fxRegionList->GetSize();
00331                         name="Region ";
00332                         name+=ix;
00333                         conny=new TGo4WinCond(name.Data());
00334                         if(fbTwoDimRegion)
00335                            conny->SetValues(0,0,0,0);
00336                         else
00337                            conny->SetValues(0,0);
00338                         conny->SetLineColor((ix)%6 +2);
00339                         conny->SetFillColor((ix)%6 +2);
00340                         conny->SetFillStyle(3002);
00341                         fxRegionList->Add(conny);
00342                         conny->SetWorkHistogram(hist);
00343                         conny->SetYRMSDraw(fbTwoDimRegion  && conny->IsXRMSDraw()); // adjust two dim region to one dim defaults
00344                         conny->SetYMeanDraw(fbTwoDimRegion && conny->IsXMeanDraw());
00345                         conny->SetYMaxDraw(fbTwoDimRegion && conny->IsXMaxDraw());
00346                         conny->Draw();
00347                      }
00348                   else
00349                      {
00350                         conny= GetActiveRegion(pad);
00351                      }
00352                   if(conny==0) return;
00353                   xmin=x;
00354                   xmax=x; //xmax=conny->GetXUp();
00355                   ymin=y;
00356                   ymax=y; //ymax=conny->GetYUp();
00357                   fuPickCounter++;
00358                }
00359             else if (fuPickCounter==1)
00360                {
00361                   conny= GetActiveRegion(pad);
00362                   if(conny==0) return;
00363                   xmin=conny->GetXLow();
00364                   xmax=x;
00365                   ymin=conny->GetYLow();
00366                   ymax=y;
00367                   if(!IsPickAgain()) fiMouseMode=kMouseROOT; // reset pick
00368                   fuPickCounter=0;
00369                }
00370             else
00371                {
00372                   cout <<"TGo4PreviewPanelSlots::Click() NEVER COME HERE" << endl;
00373                   return;
00374                }
00375             if(conny->GetDimension()>1) // do not change original condition dimension
00376                conny->SetValues(xmin,xmax,ymin,ymax);
00377             else
00378                conny->SetValues(xmin,xmax);
00379             break;
00380 
00381          case kMousePickLatex:
00382             gROOT->SetEditorMode("");
00383             ScanMarkers(pad);
00384             px = pad->GetEventX();
00385             py = pad->GetEventY();
00386             x  = pad->PadtoX(pad->AbsPixeltoX(px));
00387             y  = pad->PadtoY(pad->AbsPixeltoY(py));
00388             if(IsCreateNewMarker())
00389                {
00390                   ix=fxLateXList->GetSize();
00391                   name="Label ";
00392                   name+=ix;
00393                   latex=new TLatex(x,y,name.Data());
00394                   latex->SetName(name.Data());
00395                   AddLatex(latex,pad);
00396                   latex->Draw();
00397                   name = (const char*) QInputDialog::getText(
00398                           "Enter new LaTeX label text:",
00399                           name.Data(),
00400                           QLineEdit::Normal, QString::null, &ok);
00401                   if ( ok && !name.IsNull() )
00402                      latex->SetTitle(name.Data()); // user entered something and pressed OK
00403                }
00404             else
00405                {
00406                   latex=GetActiveLatex(pad);
00407                   if(latex)
00408                      {
00409                         latex->SetX(x);
00410                         latex->SetY(y);
00411                      }
00412                }
00413             pad->Modified();
00414             pad->Update();
00415             if(!IsPickAgain()) fiMouseMode=kMouseROOT;
00416             break;
00417 
00418 
00419          case kMousePickPolygon:
00420             if(fuPickCounter==0) gROOT->SetEditorMode("CutG");
00421             fuPickCounter++;
00422             if(gROOT->GetEditorMode()!=kCutG)
00423                {
00424                   // after final doubleclick, root will reset mode!
00425                   if(IsCreateNewMarker())
00426                         ScanCutG(pad); // this will create new polycond
00427                   else
00428                         ScanCutG(pad,GetActivePolygon(pad));  
00429                   fuPickCounter=0;
00430                   if(!IsPickAgain()) fiMouseMode=kMouseROOT; 
00431                }
00432             break;
00433 
00434          case kMouseDraw:
00435             gROOT->SetEditorMode("Arrow");
00436             if(!IsPickAgain())
00437                fiMouseMode=kMouseROOT;
00438             ScanMarkers(pad);
00439             break;
00440 
00441          default:
00442             break;
00443 
00444       } // switch(fiMouseMode)
00445    fxTGo4PreviewPanel->RefreshButtons();
00446    } //if(pad==gPad)
00447 
00448 }
00449 
00450 void TGo4PreviewPanelSlots::ScanMarkers(TVirtualPad* pad)
00451 {
00452    if(pad==0) return;
00453    TObject *entry = 0;
00454    TList* primcopy=new TList;
00455    primcopy->AddAll(pad->GetListOfPrimitives());
00456    TIter iter(primcopy); // work on copy of primitives list, since Add method might draw inside iterator!
00457    //TIter iter(pad->GetListOfPrimitives());
00458    while((entry = iter()) != 0)  {
00459       if(entry->InheritsFrom("TLatex")) {
00460          // scan for latex labels that were created with rmb
00461          // register these as a clone, since Clear will delete original in root
00462          //cout <<"ScanMarkers found latex "<<entry->GetName()<< ":"<<entry << endl;
00463          TLatex* latex=dynamic_cast<TLatex*> (entry);
00464          AddLatex(latex, pad, kTRUE); 
00465          
00466        } else 
00467        if (entry->InheritsFrom("TArrow")) {
00468           //cout <<"ScanMarkers found arrow "<<entry->GetName() << endl;
00469           TArrow* arr = dynamic_cast<TArrow*> (entry);
00470           AddArrow(arr, pad, kTRUE);
00471        } else 
00472        if(entry->InheritsFrom("TGo4Marker")) {
00473           //cout <<"ScanMarkers found marker "<<entry->GetName() << endl;
00474           TGo4Marker* mark=dynamic_cast<TGo4Marker*> (entry);
00475           AddMarker(mark, pad, kFALSE);
00476        } else 
00477        if(entry->InheritsFrom("TGo4WinCond")) {
00478           //cout <<"ScanMarkers found window "<<entry->GetName() << endl;
00479           TGo4WinCond* conny=dynamic_cast<TGo4WinCond*> (entry);
00480           AddRegion(conny, pad, kFALSE);
00481        } else 
00482        if(entry->InheritsFrom("TGo4PolyCond")) {
00483           //cout <<"ScanMarkers found polygon "<<entry->GetName() << endl;
00484           TGo4PolyCond* conny=dynamic_cast<TGo4PolyCond*> (entry);
00485           AddPolygon(conny, pad, kFALSE);
00486        }   
00487          
00489 // in principle; however, since insertCanvas clones all primitives,
00490 // the references in loaded legend are wrong, thus causing double
00491 // entries in DrawLegend after next add of superimposed histo . To be solved later... JA
00492 //       else if(entry->InheritsFrom("TLegend"))
00493 //         {
00494 //            TLegend* leg=dynamic_cast<TLegend*> (entry);
00495 //            TLegend* oldleg=0;
00496 //            TGo4PadOptions* pop=fxTGo4PreviewPanelStatus->GetPadOptions((TPad*)pad);
00497 //            if(pop) 
00498 //               {
00499 //                  oldleg=pop->GetLegend();       
00500 //                  if(oldleg!=leg) 
00501 //                     {
00502 //                        pop->SetLegend(leg);
00503 //                        if(fxLegendCleanups->Remove(oldleg)) delete oldleg;
00504 //                        fxLegendCleanups->AddLast(leg);
00505 //                     }
00506 //               }
00507 //         }
00508 
00509    } // while
00510 primcopy->Clear("nodelete");
00511 delete primcopy;
00512 }
00513 
00514 
00515 void TGo4PreviewPanelSlots::ScanCutG(TVirtualPad* pad, TGo4PolyCond* toupdate)
00516 {
00517 if(pad==0) return;
00518 TVirtualPad* padsav=gPad;
00519 pad->cd();
00520 TObject *entry = 0;
00521 TList* primlist=pad->GetListOfPrimitives();
00522 TIter iter(primlist);
00523 TCutG* CG=0;
00524 TCutG* newcut=0;
00525 while((entry = iter()) != 0)
00526    {
00527       if(entry->InheritsFrom("TCutG"))
00528             {
00529                CG = dynamic_cast<TCutG *> (entry);
00530                if(CG && CG->GetLineColor()==1)
00531                   {
00532                      // root always (?) sets color of new edited cut to black
00533                      // our old cuts are never black! ergo:
00534                      newcut=CG;
00535                      break;
00536                   }
00537             }
00538    }
00539 if (newcut)
00540    {
00541       TH1* hist=fxTGo4PreviewPanel->GetPadHistogram((TPad*)pad);         
00542       TGo4PolyCond* conny=0;
00543       if(toupdate)
00544          { 
00545             conny=toupdate;
00546             conny->SetValues(newcut);
00547          }
00548       else
00549          {
00550             Int_t ix=fxPolygonList->GetSize();
00551             TString name="Polygon ";
00552             name+=ix;                     
00553             conny=new TGo4PolyCond(name.Data());
00554             conny->SetValues(newcut); // do this before setting new colors!
00555             conny->SetLineColor((ix)%6 +2);
00556             conny->SetFillColor((ix)%6 +2);
00557             conny->SetFillStyle(3002); 
00558             fxPolygonList->AddLast(conny);
00559          }         
00560       delete newcut;                 
00561       conny->SetWorkHistogram(hist);      
00562       if(toupdate==0) conny->Draw();         
00563    }
00564 padsav->cd();
00565 }
00566 
00567 Bool_t TGo4PreviewPanelSlots::AddLatex(TLatex* lax, TVirtualPad* pad, Bool_t clone)
00568 {
00569 if(lax==0 || pad==0) return kTRUE;
00570 // do we already have this latex in our list?
00571 TVirtualPad* padsav=gPad;
00572 pad->cd();
00573 Bool_t alreadythere=kFALSE;
00574 TIterator* liter=fxLateXList->MakeIterator();
00575 TObject* ob=0;
00576 TGo4LateXEntry* lentry=0;
00577 while((ob=liter->Next())!=0)
00578 {
00579    lentry=dynamic_cast<TGo4LateXEntry*>(ob);
00580    if(lax==lentry->GetLateX())
00581       {
00582          lentry->fxPad=pad;
00583          alreadythere=kTRUE;
00584          break;
00585       }
00586 }
00587 delete liter;
00588 if(!alreadythere)
00589    {
00590       TLatex* novum=lax;
00591       if(clone)
00592         {
00593             novum= (TLatex*) lax->Clone();
00594             delete lax; // we continue working on the clone
00595             novum->Draw();
00596         }
00597       fxLateXList->AddLast( new TGo4LateXEntry(novum,pad));
00598       fxLateXCleanups->AddLast(novum);
00599 
00600    }
00601 padsav->cd();
00602 return alreadythere;
00603 }
00604 
00605 Bool_t TGo4PreviewPanelSlots::AddArrow(TArrow* arr, TVirtualPad* pad, Bool_t clone)
00606 {
00607 if(arr==0 || pad==0) return kTRUE;
00608 
00609 // supress stealing arrows from fitgui
00610 if (dynamic_cast<TGo4FitGUIArrow*>(arr)!=0) return kTRUE;
00611 // if(arr->InheritsFrom("TGo4FitGUIArrow")) return;
00612  
00613 // do we already have this latex in our list?
00614 TVirtualPad* padsav=gPad;
00615 pad->cd();
00616 Bool_t alreadythere=kFALSE;
00617 TIterator* liter=fxArrowList->MakeIterator();
00618 TObject* ob=0;
00619 TGo4ArrowEntry* arentry=0;
00620 while((ob=liter->Next())!=0)
00621 {
00622    arentry=dynamic_cast<TGo4ArrowEntry*>(ob);
00623    if(arr==arentry->GetArrow())
00624       {
00625          arentry->fxPad=pad;
00626          alreadythere=kTRUE;
00627          break;
00628       }
00629 }
00630 delete liter;
00631 if(!alreadythere)
00632    {
00633       TArrow* novum=arr;
00634       if(clone)
00635         {
00636             novum= (TArrow*) arr->Clone();
00637             delete arr; // we continue working on the clone
00638             novum->Draw();
00639         }
00640       fxArrowList->AddLast( new TGo4ArrowEntry(novum,pad));
00641       fxArrowCleanups->AddLast(novum);
00642 
00643    }
00644 padsav->cd();
00645 return alreadythere;
00646 }
00647 
00648 Bool_t TGo4PreviewPanelSlots::AddMarker(TGo4Marker* mk, TVirtualPad* pad, Bool_t clone)
00649 {
00650 if(mk==0 || pad==0) return kTRUE;
00651 // do we already have this marker in our list?
00652 TVirtualPad* padsav=gPad;
00653 pad->cd();
00654 Bool_t alreadythere=kFALSE;
00655 TIterator* liter=fxMarkerList->MakeIterator();
00656 TObject* ob=0;
00657 TGo4Marker* old=0;
00658 while((ob=liter->Next())!=0)
00659 {
00660    old=dynamic_cast<TGo4Marker*>(ob);
00661    if(mk==old)
00662       {
00663          alreadythere=kTRUE;
00664          break;
00665       }
00666 }
00667 delete liter;
00668 if(!alreadythere)
00669    {
00670       TGo4Marker* novum=mk;
00671       if(clone)
00672         {
00673             novum= (TGo4Marker*) mk->Clone();
00674             delete mk; // we continue working on the clone
00675             novum->Draw();
00676         }
00677       fxMarkerList->AddLast(novum);
00678 
00679    }
00680 padsav->cd();
00681 return alreadythere;
00682 }
00683 
00684 Bool_t TGo4PreviewPanelSlots::AddRegion(TGo4WinCond* con, TVirtualPad* pad, Bool_t clone)
00685 {
00686 if(con==0 || pad==0) return kTRUE;
00687 // test if this region belongs to condition editor:
00688 if(con->IsOwnedByEditor()) return kTRUE;
00689 // do we already have this in our list?
00690 TVirtualPad* padsav=gPad;
00691 pad->cd();
00692 Bool_t alreadythere=kFALSE;
00693 TIterator* liter=fxRegionList->MakeIterator();
00694 TObject* ob=0;
00695 TGo4WinCond* old=0;
00696 while((ob=liter->Next())!=0)
00697 {
00698    old=dynamic_cast<TGo4WinCond*>(ob);
00699    if(con==old)
00700       {
00701          alreadythere=kTRUE;
00702          break;
00703       }
00704 }
00705 delete liter;
00706 if(!alreadythere)
00707    {
00708       TGo4WinCond* novum=con;
00709       if(clone)
00710         {
00711             novum= (TGo4WinCond*) con->Clone();
00712             delete con; // we continue working on the clone
00713             novum->Draw();
00714         }
00715       fxRegionList->AddLast(novum);
00716    }
00717 padsav->cd();
00718 return alreadythere;
00719 }
00720 
00721 
00722 Bool_t TGo4PreviewPanelSlots::AddPolygon(TGo4PolyCond* con, TVirtualPad* pad, Bool_t clone)
00723 {
00724 if(con==0 || pad==0) return kTRUE;
00725 // test if this region belongs to condition editor:
00726 if(con->IsOwnedByEditor()) return kTRUE;
00727 // do we already have this in our list?
00728 TVirtualPad* padsav=gPad;
00729 pad->cd();
00730 Bool_t alreadythere=kFALSE;
00731 TIterator* liter=fxPolygonList->MakeIterator();
00732 TObject* ob=0;
00733 TGo4PolyCond* old=0;
00734 while((ob=liter->Next())!=0)
00735 {
00736    old=dynamic_cast<TGo4PolyCond*>(ob);
00737    if(con==old)
00738       {
00739          alreadythere=kTRUE;
00740          break;
00741       }
00742 }
00743 delete liter;
00744 if(!alreadythere)
00745    {
00746       TGo4PolyCond* novum=con;
00747       if(clone)
00748         {
00749             novum= (TGo4PolyCond*) con->Clone();
00750             delete con; // we continue working on the clone
00751             novum->Draw();
00752         }
00753       fxPolygonList->AddLast(novum);
00754    }
00755 padsav->cd();
00756 return alreadythere;
00757 }
00758 
00759 
00760 
00761 
00762 void TGo4PreviewPanelSlots::ActivateSelectedObject(TVirtualPad* pad)
00763 {
00764 if(pad==0) return;
00765 TObject* selected=pad->GetSelected();
00766 if(selected)
00767    {
00768       if(selected->InheritsFrom("TGo4Marker"))
00769          {
00770             TIterator* liter=fxMarkerList->MakeIterator();
00771             TObject* ob=0;
00772             while((ob=liter->Next())!=0)
00773                {
00774                   if(ob==selected)
00775                      {
00776                         fxMarkerList->Remove(ob);
00777                         fxMarkerList->AddLast(ob);
00778                         fiMouseMode=kMouseSelectObject;
00779                         fxSelectedName=selected->GetName();
00780                         break;
00781                      }
00782                }
00783             delete liter;
00784          }
00785       else if (selected->InheritsFrom("TGo4WinCondView"))
00786          {
00787             TGo4WinCondView* conview=dynamic_cast<TGo4WinCondView*>(selected);
00788             TObject* conny=conview->GetCondition();
00789             TIterator* liter=fxRegionList->MakeIterator();
00790             TObject* ob=0;
00791             while((ob=liter->Next())!=0)
00792                {
00793                   if(ob==conny)
00794                      {
00795                         fxRegionList->Remove(ob);
00796                         fxRegionList->AddLast(ob);
00797                         fiMouseMode=kMouseSelectObject;
00798                         fxSelectedName=selected->GetName();
00799                         break;
00800                      }
00801                }
00802             delete liter;
00803 
00804 
00805          }
00806       else if (selected->InheritsFrom("TGo4PolyCondView"))
00807          {
00808             TGo4PolyCondView* conview=dynamic_cast<TGo4PolyCondView*>(selected);
00809             TObject* conny=conview->GetCondition();
00810             TIterator* liter=fxPolygonList->MakeIterator();
00811             TObject* ob=0;
00812             while((ob=liter->Next())!=0)
00813                {
00814                   if(ob==conny)
00815                      {
00816                         fxPolygonList->Remove(ob);
00817                         fxPolygonList->AddLast(ob);
00818                         fiMouseMode=kMouseSelectObject;
00819                         fxSelectedName=selected->GetName();
00820                         break;
00821                      }
00822                }
00823             delete liter;
00824 
00825 
00826          }   
00827          
00828       else if (selected->InheritsFrom("TLatex"))
00829          {
00830             TIter liter(fxLateXList);
00831             TObject* ob=0;
00832             while((ob=liter())!=0)
00833                {
00834                   TGo4LateXEntry* latexref=dynamic_cast<TGo4LateXEntry*>(ob);
00835                   if(selected==latexref->fxObject)
00836                      {
00837                         fxLateXList->Remove(ob);
00838                         fxLateXList->AddLast(ob);
00839                         fiMouseMode=kMouseSelectObject;
00840                         fxSelectedName=selected->GetTitle();
00841                         break;
00842                      }
00843                } // while
00844          }
00845       else
00846          {
00847             // not one of our objects
00848          }
00849 
00850    }
00851 
00852 }
00853 
00854 TGo4Marker* TGo4PreviewPanelSlots::GetActiveMarker(TVirtualPad* )
00855 {
00856    return (TGo4Marker*) fxMarkerList->Last();
00857 }
00858 
00859 const Text_t* TGo4PreviewPanelSlots::GetActiveMarkerName(TVirtualPad* pad)
00860 {
00861    TGo4Marker* act=GetActiveMarker(pad);
00862    if(act)
00863       return act->GetName();
00864    else
00865       return 0;
00866 }
00867 
00868 TGo4WinCond* TGo4PreviewPanelSlots::GetActiveRegion(TVirtualPad* )
00869 {
00870   return (TGo4WinCond*) fxRegionList->Last();
00871 }
00872 
00873 const Text_t* TGo4PreviewPanelSlots::GetActiveRegionName(TVirtualPad* pad)
00874 {
00875    TGo4WinCond* act=GetActiveRegion(pad);
00876    if(act)
00877       return act->GetName();
00878    else
00879       return 0;
00880 }
00881 
00882 TGo4PolyCond* TGo4PreviewPanelSlots::GetActivePolygon(TVirtualPad* )
00883 {
00884   return (TGo4PolyCond*) fxPolygonList->Last();
00885 }
00886 
00887 const Text_t* TGo4PreviewPanelSlots::GetActivePolygonName(TVirtualPad* pad)
00888 {
00889    TGo4PolyCond* act=GetActivePolygon(pad);
00890    if(act)
00891       return act->GetName();
00892    else
00893       return 0;
00894 }
00895 
00896 
00897 TLatex* TGo4PreviewPanelSlots::GetActiveLatex(TVirtualPad* pad)
00898 {
00899 // we search for latest latex object on the working pad pad
00900 TLatex* latex=0;
00901 TObject* ob=0;
00902 TIter liter(fxLateXList, kIterBackward);
00903 while((ob=liter())!=0)
00904    {
00905       TGo4LateXEntry* latexref=dynamic_cast<TGo4LateXEntry*>(ob);
00906       if(pad==latexref->fxPad)
00907          {
00908             latex= latexref->GetLateX();
00909             break;
00910          }
00911    } // while
00912 return latex;
00913 }
00914 
00915 const Text_t* TGo4PreviewPanelSlots::GetActiveLatexName(TVirtualPad* pad)
00916 {
00917    TLatex* act=GetActiveLatex(pad);
00918    if(act)
00919       return act->GetTitle(); // latex text is root title, not name
00920    else
00921       return 0;
00922 }
00923 
00924 void TGo4PreviewPanelSlots::SetRegionsHistogram()
00925 {
00926 TPad* workpad=0;
00927 TH1* hist=0;
00928 TIter liter(fxRegionList);
00929 TObject* ob=0;
00930 TGo4Condition* con=0;
00931 while((ob=liter.Next())!=0)
00932    {
00933       con=dynamic_cast<TGo4Condition*>(ob);
00934       workpad= (TPad*) con->GetDrawPad();
00935       hist=fxTGo4PreviewPanel->GetPadHistogram(workpad);
00936       con->SetWorkHistogram(hist);
00937       //cout <<"SetRegionsHistogram for"<<con->GetName() << endl;
00938    }
00939 }
00940 
00941 
00942 void TGo4PreviewPanelSlots::SetPolygonsHistogram()
00943 {
00944 TPad* workpad=0;
00945 TH1* hist=0;
00946 TIter liter(fxPolygonList);
00947 TObject* ob=0;
00948 TGo4Condition* con=0;
00949 while((ob=liter.Next())!=0)
00950    {
00951       con=dynamic_cast<TGo4Condition*>(ob);
00952       workpad= (TPad*) con->GetDrawPad();
00953       hist=fxTGo4PreviewPanel->GetPadHistogram(workpad);
00954       con->SetWorkHistogram(hist);
00955       //cout <<"SetPolygonsHistogram for"<<con->GetName() << endl;
00956    }
00957 }
00958 
00959 void TGo4PreviewPanelSlots::SetMarkersHistogram()
00960 {
00961 TPad* workpad=0;
00962 TH1* hist=0;
00963 TIter liter(fxMarkerList);
00964 TObject* ob=0;
00965 TGo4Marker* mark=0;
00966 while((ob=liter.Next())!=0)
00967    {
00968       mark=dynamic_cast<TGo4Marker*>(ob);
00969       workpad=(TPad*) mark->GetDrawPad();
00970       hist=fxTGo4PreviewPanel->GetPadHistogram(workpad);
00971       mark->SetHistogram(hist);
00972       //cout <<"SetMarkersHistogram for"<<mark->GetName() << endl;
00973    }
00974 
00975 }
00976 
00977 void TGo4PreviewPanelSlots::RedrawAllLabels(TVirtualPad* pad) {
00978   if(pad==0) return;
00979   ScanMarkers(pad); // make sure to redraw most recently drawn labels
00980   
00981   TVirtualPad* padsav=gPad;
00982   gPad=pad;
00983   TIterator* liter=fxMarkerList->MakeIterator();
00984   TObject* ob=0;
00985   TGo4Marker* mark=0;
00986   while((ob=liter->Next())!=0)  {
00987      mark=dynamic_cast<TGo4Marker*>(ob);
00988      if(gPad==mark->GetDrawPad()) mark->Draw(); // only restor if this was
00989                                               // the original draw pad
00990   }
00991   delete liter;
00992   // window conditions:
00993   liter=fxRegionList->MakeIterator();
00994   TGo4Condition* con=0;
00995   while((ob=liter->Next())!=0) {
00996      con=dynamic_cast<TGo4Condition*>(ob);
00997      if(gPad==con->GetDrawPad()) con->Draw(); // condition checks if already in primitives list
00998    }
00999    delete liter;
01000 
01001    // polygon conditions:
01002    liter=fxPolygonList->MakeIterator();
01003    while((ob=liter->Next())!=0) {
01004       con=dynamic_cast<TGo4Condition*>(ob);
01005       if(gPad==con->GetDrawPad()) con->Draw();// condition checks if already in primitives list
01006    }
01007    delete liter;
01008 
01009    // list of latexes:
01010    liter=fxLateXList->MakeIterator();
01011    TGo4LateXEntry* lentry=0;
01012    while((ob=liter->Next())!=0) {
01013       lentry=dynamic_cast<TGo4LateXEntry*>(ob);
01014       if(gPad==lentry->fxPad) {
01015          TLatex* latex=lentry->GetLateX();
01016          if(fxLateXCleanups->FindObject(latex))// only redraw if latex still there
01017             {
01018                //cout <<"Redraw latex:"<<latex<< " - "<<latex->GetTitle() << endl;
01019                if(gPad->GetListOfPrimitives()->FindObject(latex)==0)
01020                   latex->Draw(); // avoid double entries in list of primitives!
01021             }
01022          else
01023             {
01024                fxLateXList->Remove(ob); // clean list of references
01025                //cout <<"## Removed latex object: "<<ob<< endl;
01026                liter->Reset();
01027             }
01028       }
01029    }
01030    delete liter;
01031 
01032 // list of arrows:
01033    liter=fxArrowList->MakeIterator();
01034    TGo4ArrowEntry* arentry=0;
01035    while((ob=liter->Next())!=0) {
01036       arentry=dynamic_cast<TGo4ArrowEntry*>(ob);
01037       if(gPad==arentry->fxPad)
01038       {
01039          TArrow* arr=arentry->GetArrow();
01040          if(fxArrowCleanups->FindObject(arr))// only redraw if latex still there
01041             {
01042                //cout <<"Redraw arrow:"<<arr<< " - "<<arr->GetTitle() << endl;
01043                if(gPad->GetListOfPrimitives()->FindObject(arr)==0)
01044                   arr->Draw(); // avoid double entry in primitives list
01045             }
01046          else
01047             {
01048                fxArrowList->Remove(ob); // clean list of references
01049                //cout <<"## Removed arrow object: "<<ob<< endl;
01050                liter->Reset();
01051             }
01052       }
01053    }
01054    delete liter;
01055 
01056    pad->Modified();
01057    pad->Update();
01058    gPad=padsav;
01059 }
01060 
01061 void TGo4PreviewPanelSlots::ClearAllLabels(TVirtualPad* pad)
01062 {
01063 ScanMarkers(pad); // update list to delete most recently created labels
01064 //------- list of cursor markers: ----------------
01065 TIterator* liter=fxMarkerList->MakeIterator();
01066 TObject* ob=0;
01067 TGo4Marker* mark=0;
01068 while((ob=liter->Next())!=0)
01069 {
01070    mark=dynamic_cast<TGo4Marker*>(ob);
01071    if(pad == 0 || pad==mark->GetDrawPad())
01072       {
01073          fxMarkerList->Remove(mark);
01074          delete mark;
01075          liter->Reset();
01076       }
01077 }
01078 delete liter;
01079 //------- list of window regions: ----------------
01080 liter=fxRegionList->MakeIterator();
01081 TGo4Condition* con=0;
01082 while((ob=liter->Next())!=0)
01083 {
01084    con=dynamic_cast<TGo4Condition*>(ob);
01085    if(pad==0 || pad==con->GetDrawPad())
01086       {
01087          fxRegionList->Remove(con);
01088          delete con;
01089          liter->Reset();
01090       }
01091 }
01092 delete liter;
01093 
01094 //------- list of polygon regions: ----------------
01095 liter=fxPolygonList->MakeIterator();
01096 while((ob=liter->Next())!=0)
01097 {
01098    con=dynamic_cast<TGo4Condition*>(ob);
01099    if(pad==0 || pad==con->GetDrawPad())
01100       {
01101          fxPolygonList->Remove(con);
01102          delete con;
01103          liter->Reset();
01104       }
01105 }
01106 delete liter;
01107 
01108 //------- list of latexes: -----------------------
01109 liter=fxLateXList->MakeIterator();
01110 TGo4LateXEntry* lentry=0;
01111 while((ob=liter->Next())!=0)
01112 {
01113    lentry=dynamic_cast<TGo4LateXEntry*>(ob);
01114    if(pad==0 || pad==lentry->fxPad)
01115       {
01116          fxLateXList->Remove(lentry);
01117          if(fxLateXCleanups->Remove(lentry->GetLateX()))
01118                      delete lentry->GetLateX(); // only delete if still in root
01119          lentry->fxObject=0; // prevent lentry dtor deleting the latex again
01120          delete lentry;
01121          liter->Reset();
01122       }
01123 }
01124 delete liter;
01125 
01126 //------- list of arrows: -----------------------
01127 liter=fxArrowList->MakeIterator();
01128 TGo4ArrowEntry* arentry=0;
01129 while((ob=liter->Next())!=0)
01130 {
01131    arentry=dynamic_cast<TGo4ArrowEntry*>(ob);
01132    if(pad==0 || pad==arentry->fxPad)
01133       {
01134          fxArrowList->Remove(arentry);
01135          if(fxArrowCleanups->Remove(arentry->GetArrow()))
01136                   delete arentry->GetArrow(); // only delete if still in root
01137          arentry->fxObject=0;
01138          delete arentry;
01139          liter->Reset();
01140       }
01141 }
01142 delete liter;
01143 
01144 }
01145 
01146 void TGo4PreviewPanelSlots::DrawLegend(TVirtualPad* pad, TObject* ob)
01147 {
01148 if(pad==0 || ob==0) return;
01149 TVirtualPad* padsav=gPad;
01150 gPad=pad;   
01151 THStack* st=dynamic_cast<THStack*>(ob);
01152 TMultiGraph* mg=dynamic_cast<TMultiGraph*>(ob);
01153 TList* hlist=0;
01154 TString doption;
01155 //TString header=ob->GetName();
01156 if(st)
01157    {
01158       //cout <<"Legend for stack" << endl;      
01159       hlist=st->GetHists();
01160       doption="l";    
01161    }
01162 else if (mg)
01163    {
01164       //cout <<"Legend for multigraph" << endl;
01165       hlist=mg->GetListOfGraphs();
01166       doption="p"; 
01167    }
01168 else
01169    {
01170       //cout <<"No Legend for "<<ob->IsA()->GetName() << endl;
01171    } // if(st) etc
01173 if(hlist) 
01174    {
01176       TLegend* leg=0;
01177       TGo4PadOptions* pop=fxTGo4PreviewPanelStatus->GetPadOptions((TPad*)pad);
01178       if(pop) leg=pop->GetLegend();      
01179       if(leg==0 || fxLegendCleanups->FindObject(leg)==0)
01180          {
01181             // first creation, or existing legend was deleted by root user
01182             leg=new TLegend(0.6,0.6,0.89,0.89); //(0.4,0.6,0.7,0.89)
01183             if(pop) pop->SetLegend(leg);
01184             fxLegendCleanups->AddLast(leg);
01185             //leg->SetHeader(header.Data());
01186          }
01187       else
01188          {
01189           // might clear the label here?  
01190          }
01191       TList* leglist=leg->GetListOfPrimitives();
01192       TObject* lob=0;
01193       TLegendEntry* lentry=0;
01194       TIter liter(leglist);      
01195       TObject* stob=0;      
01196       TIter stiter(hlist);
01197       while((stob=stiter.Next())!=0)
01198          {
01199             // test if this object has already entry in existing legend:
01200             bool alreadythere=false;
01201             while((lob=liter.Next())!=0)
01202                {
01203                   lentry=dynamic_cast<TLegendEntry*>(lob);
01204                   if(lentry->GetObject()==stob)
01205                      {
01206                         alreadythere=true;
01207                         break;  
01208                      }  
01209                }
01210             if(!alreadythere)
01211                leg->AddEntry(stob,stob->GetName(),doption.Data());
01212          }
01213       leg->Draw();
01214    } // if(hlist)      
01215 pad->Modified();
01216 pad->Update();
01217 gPad=padsav;
01218 }
01219 
01220 void TGo4PreviewPanelSlots::ClearLegend(TVirtualPad* pad, Bool_t del)
01221 {
01222 if(pad==0)
01223    {
01224     // this mode deletes every label in list, for clear canvas functions:  
01225     fxLegendCleanups->Delete();   
01226    }
01227 else
01228    {
01229    // remove label from given pad. Eventually delete it if del is true
01230    TList* primlist = pad->GetListOfPrimitives();
01231    TIterator* liter=primlist->MakeIterator();
01232    TObject* ob=0;
01233    TLegend* leg=0;
01234    while((ob=liter->Next())!=0)
01235    {
01236       // note: existing legend is not in list of primitives anymore after stack draw!
01237       // just for the principle...
01238       leg=dynamic_cast<TLegend*>(ob);
01239       if(leg)
01240          {
01241             primlist->Remove(leg);
01242             liter->Reset();
01243          }
01244    }
01245    delete liter;
01247    // because after Draw of Stack, legend is removed from primlist by root!
01248    if(del)
01249       {
01250            leg=0; 
01251            TGo4PadOptions* pop=fxTGo4PreviewPanelStatus->GetPadOptions((TPad*)pad);     
01252            if(pop)
01253             { 
01254                leg=pop->GetLegend(); 
01255                pop->SetLegend(0);
01256             }
01257            if(fxLegendCleanups->Remove(leg)) delete leg;
01258       }
01259    pad->Modified();
01260    pad->Update();
01261    }
01262 }
01263 
01264 
01265 void TGo4PreviewPanelSlots::LogMarkers(Option_t* opt)
01266 {
01267 //---------- cursor markers:
01268 TIterator* markers=fxMarkerList->MakeIterator();
01269 TObject* ob=0;
01270 while((ob=markers->Next())!=0)
01271 {
01272    ob->Print(opt);
01273 }
01274 delete markers;
01275 //---------- window regions:
01276 TString option=opt;
01277 option+="-limits-stats";
01278 TIterator* regions=fxRegionList->MakeIterator();
01279 while((ob=regions->Next())!=0)
01280 {
01281    ob->Print(option.Data());
01282 }
01283 delete regions;
01284 
01285 //---------- polygon regions:
01286 regions=fxPolygonList->MakeIterator();
01287 while((ob=regions->Next())!=0)
01288 {
01289    ob->Print(option.Data());
01290 }
01291 delete regions;
01292 
01293 //----------- latex labels:
01294 TIterator* latexts=fxLateXCleanups->MakeIterator();
01295 while((ob=latexts->Next())!=0)
01296 {
01297    ob->Print(opt);
01298 }
01299 delete latexts;
01300 //----------- arrows :
01301 TIterator* arrows=fxArrowCleanups->MakeIterator();
01302 while((ob=arrows->Next())!=0)
01303 {
01304    ob->Print(opt);
01305 }
01306 delete arrows;
01307 
01308 
01309 
01310 }
01311 
01312 void TGo4PreviewPanelSlots::BuildPadEditor(TQRootWindow* qtframe)
01313 {
01314 #if __GO4ROOTVERSION__ > 40006
01315 if(qtframe==0) return;
01316 if(fxPeditor!=0) return;
01317 qtframe->SetEditable(); // mainframe will adopt pad editor window
01318 fxPeditor=TVirtualPadEditor::LoadEditor();
01319 qtframe->SetEditable(0);// back to window manager as root window         
01320 
01322 //TGVButtonGroup *bg = new TGVButtonGroup(qtframe->GetRootFrame()); 
01323 //TGRadioButton* rb= new TGRadioButton(bg,"click for test");
01324 //TGTextButton *button1 = new TGTextButton(bg,"some text");         
01325 //TGTextButton *button2 = new TGTextButton(bg,"another text");  
01326 //qtframe->AddSubFrame(bg);
01327 
01328 
01329 
01330 #endif
01331    // 31002
01332 }
01333 
01334 
01335 
01336 void TGo4PreviewPanelSlots::CleanupPadEditor()
01337 {
01338 #if __GO4ROOTVERSION__ > 40006
01339 if(fxPeditor) fxPeditor->DeleteEditors();
01340 #endif
01341    // 31002   
01342 }
01343 
01344 
01345 
01346 void TGo4PreviewPanelSlots::SaveMarkerSetup(const Text_t* filename, const Text_t* statusname, TVirtualPad* pad)
01347 {
01348 TFile outfile(filename, "UPDATE");
01349 TGo4MarkerSetup* state=CreateMarkerSetup(pad);
01350 if(statusname) state->SetName(statusname);
01351 outfile.cd();
01352 state->Write();
01353 outfile.Close();
01354 delete state;
01355 }
01356 
01357 void TGo4PreviewPanelSlots::LoadMarkerSetup(const Text_t* filename, const Text_t* statusname, TVirtualPad* pad)
01358 {
01359 TFile infile(filename, "READ");
01360 TGo4MarkerSetup* state=0;
01361 if(statusname)
01362    {
01363       state= dynamic_cast<TGo4MarkerSetup*>(infile.FindObjectAny(statusname));
01364    }
01365 else
01366    {
01367       TKey* kee=0;
01368       TIter iter(infile.GetListOfKeys());
01369       while ( ( kee=dynamic_cast<TKey*>(iter()) ) !=0 )
01370          {
01371             state = dynamic_cast<TGo4MarkerSetup*>(kee->ReadObj());
01372             if (state) break; // we take first status in file, disregarding its name...
01373          }
01374    }
01375 SetMarkerSetup(state,pad);
01376 TGo4PolyCond::CleanupSpecials(); 
01377 }
01378 
01379 TGo4MarkerSetup* TGo4PreviewPanelSlots::CreateMarkerSetup(TVirtualPad* viewpad)
01380 {
01381 //TVirtualPad* padsav=gPad;
01382 TVirtualPad* pad=viewpad;
01383 if(pad==0) pad= fxTGo4PreviewPanel->GetActivePad();
01384 ScanMarkers(pad); // make sure to redraw most recently drawn labels
01385 TGo4MarkerSetup* state= new TGo4MarkerSetup(GetName());
01386 
01387 // markers:
01388 TIterator* liter=fxMarkerList->MakeIterator();
01389 TObject* ob=0;
01390 TGo4Marker* mark=0;
01391 while((ob=liter->Next())!=0)
01392 {
01393    mark=dynamic_cast<TGo4Marker*>(ob);
01394    if(pad==mark->GetDrawPad())
01395          state->fxMarkerList->Add(mark->Clone()); // only save current pad objects
01396 }
01397 delete liter;
01398 
01399 // window conditions:
01400 liter=fxRegionList->MakeIterator();
01401 TGo4Condition* con=0;
01402 while((ob=liter->Next())!=0)
01403 {
01404    con=dynamic_cast<TGo4Condition*>(ob);
01405    if(pad==con->GetDrawPad())
01406       state->fxRegionList->Add(con->Clone());
01407 }
01408 delete liter;
01409 
01410 // polygon conditions:
01411 liter=fxPolygonList->MakeIterator();
01412 while((ob=liter->Next())!=0)
01413 {
01414    con=dynamic_cast<TGo4Condition*>(ob);
01415    if(pad==con->GetDrawPad())
01416       state->fxPolygonList->Add(con->Clone());
01417 }
01418 delete liter;
01419 
01420 // list of latexes:
01421 liter=fxLateXList->MakeIterator();
01422 TGo4LateXEntry* lentry=0;
01423 while((ob=liter->Next())!=0)
01424 {
01425    lentry=dynamic_cast<TGo4LateXEntry*>(ob);
01426    if(pad==lentry->fxPad && fxLateXCleanups->FindObject(lentry->GetLateX()))
01427                state->fxLateXList->Add(lentry->Clone()); // only clone if label is still there
01428 }
01429 // list of arrows:
01430 liter=fxArrowList->MakeIterator();
01431 TGo4ArrowEntry* arentry=0;
01432 while((ob=liter->Next())!=0)
01433 {
01434    arentry=dynamic_cast<TGo4ArrowEntry*>(ob);
01435    if(pad==arentry->fxPad && fxArrowCleanups->FindObject(arentry->GetArrow()))
01436                state->fxArrowList->Add(arentry->Clone());
01437 }
01438 delete liter;
01439 //if(padsav) padsav->cd();
01440 return state;
01441 }
01442 
01443 void TGo4PreviewPanelSlots::SetMarkerSetup(TGo4MarkerSetup* state, TVirtualPad* viewpad)
01444 {
01445 if(state==0) return;
01446 TVirtualPad* padsav=gPad;
01447 TVirtualPad* pad=viewpad;
01448 if(pad==0) pad= fxTGo4PreviewPanel->GetActivePad();
01449 pad->cd();
01450 TH1* hist=fxTGo4PreviewPanel->GetPadHistogram((TPad*) pad);
01451 // first delete old markers on work pad:
01452 ClearAllLabels(pad);
01453 
01455 TIterator* liter=state->fxMarkerList->MakeIterator();
01456 TObject* ob=0;
01457 while((ob=liter->Next())!=0)
01458 {
01459    TGo4Marker* mark=dynamic_cast<TGo4Marker*>(ob->Clone());
01460    fxMarkerList->Add(mark);
01461    mark->SetHistogram(hist);
01462    mark->Draw();
01463 }
01464 delete liter;
01465 
01467 //gROOT->GetListOfCleanups()->Add(fxRegionList);
01468 liter=state->fxRegionList->MakeIterator();
01469 while((ob=liter->Next())!=0)
01470 {
01471    TGo4Condition* con=dynamic_cast<TGo4Condition*>(ob->Clone());
01472    fxRegionList->Add(con);
01473    con->SetWorkHistogram(hist);
01474    con->Draw();
01475 }
01476 delete liter;
01477 
01479 liter=state->fxPolygonList->MakeIterator();
01480 while((ob=liter->Next())!=0)
01481 {
01482    TGo4Condition* con=dynamic_cast<TGo4Condition*>(ob->Clone());
01483    fxPolygonList->Add(con);
01484    con->SetWorkHistogram(hist);
01485    con->Draw();
01486 }
01487 delete liter;
01488 
01489 
01491 liter=state->fxLateXList->MakeIterator();
01492 while((ob=liter->Next())!=0)
01493 {
01494    TGo4GraphicEntry* gx= (TGo4GraphicEntry*) ob->Clone();
01495    TObject* lax=gx->fxObject;
01496    fxLateXList->AddLast(gx);
01497    fxLateXCleanups->Add(lax);
01498    gx->fxPad=pad;
01499    lax->Draw();
01500 }
01501 delete liter;
01503 liter=state->fxArrowList->MakeIterator();
01504 while((ob=liter->Next())!=0)
01505 {
01506    TGo4GraphicEntry* gx= (TGo4GraphicEntry*) ob->Clone();
01507    TObject* arrow=gx->fxObject;
01508    fxArrowList->AddLast(gx);
01509    fxArrowCleanups->Add(arrow);
01510    gx->fxPad=pad;
01511    arrow->Draw();
01512 }
01513 delete liter;
01514 pad->Modified();
01515 pad->Update();
01516 if(padsav) padsav->cd();
01517 }
01518 
01519 void TGo4PreviewPanelSlots::ResetFillColors(TVirtualPad* pad, Color_t col)
01520 {
01521 if(pad==0) return;
01522 pad->SetFillColor(col);
01523 TList* primlist=pad->GetListOfPrimitives();
01524 TIterator* piter=primlist->MakeIterator();
01525 TObject*ob=0;
01526 while((ob=piter->Next())!=0)
01527    {
01528       TPad* subpad=dynamic_cast<TPad*>(ob);
01529       TFrame* fram=dynamic_cast<TFrame*>(ob);
01530       if(subpad)
01531          ResetFillColors(subpad,col);
01532       else if(fram)
01533          fram->SetFillColor(col);
01534    }
01535    delete piter;
01536 }
01537 
01538 
01539 
01540 
01541 
01542 //----------------------------END OF GO4 SOURCE FILE ---------------------

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