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

/Go4GUI/TGo4PreviewPanel.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 #include <iostream.h>
00017 
00018 void TGo4PreviewPanel::init()
00019 
00020 {
00021    // TGo4LockGuard glob;
00022     //setAutoMask(false);
00023 //    setWFlags(Qt::WType_TopLevel);
00024     char SlotName[256];
00025     char StatusName[256];
00026     fbTypingMode=true;
00027     fbFreezeTitle=false;
00028     fbMarkEditorVisible=false;
00029     fbEditorFrameVisible=false;
00030     fbNeedsMemSync=false; // for automatic sync of new histograms from canvas popup
00031     fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00032     snprintf(SlotName,255,"%s%s",name(),"_Slots" );
00033     snprintf(StatusName,255,"%s%s",name(),"_Status" );
00034     fxTGo4PreviewPanelSlots = (TGo4PreviewPanelSlots *) fxTGo4GUIRegistry->GetSlotClass(SlotName);
00035     if(fxTGo4PreviewPanelSlots !=0) {
00036        fxTGo4PreviewPanelSlots->SetGUI(this);
00037     }else{
00038        fxTGo4PreviewPanelSlots = new TGo4PreviewPanelSlots (SlotName, name(), this);
00039     }
00040     
00041     fxTGo4PreviewPanelStatus = (TGo4PreviewPanelStatus *)  fxTGo4PreviewPanelSlots->GetStatus();
00042 
00043     setCaption( trUtf8( name(), "" ) );
00044 
00045     fxTGo4WorkSpace= dynamic_cast <TGo4WorkSpace *> (parentWidget());
00046 
00047     connect(C,SIGNAL(SelectedPadChanged(TPad*)),this,SLOT(SetActivePad(TPad*)));
00048     connect(C,SIGNAL(DropToPad(TPad *)),this,SLOT(DropToPadAction(TPad *)));
00049     connect(C,SIGNAL(PadClicked(TPad *)),this,SLOT(ClickOnPad(TPad *)));
00050 
00051     ActivePad=(TPad *)C->GetCanvas();
00052     SetCrosshairDefault(false);   // property maybe overwritten in Mainwindow slot
00053     SetPadFillColor(18); // property maybe overwritten in Mainwindow slot
00054     InitPad(ActivePad);
00055     ApplyToAll =false;
00056     fbRepaintEnabled=true;
00057 //    menubar
00058     menubar = new QMenuBar( this, "menubar" );
00059     menubar->setFrameShape(QFrame::NoFrame);
00060     //File Menu
00061     FileMenu = new QPopupMenu( this );
00062     menubar->insertItem( "F&ile",FileMenu); // avoid conflict with mainwindow shortcut!
00063     FileMenu->insertItem("&Save as...", this, SLOT(SaveCanvas()));
00064     FileMenu->insertItem("&Print...", this, SLOT(PrintCanvas()));
00065     FileMenu->insertItem("Copy to T&Canvas in Memory", this, SLOT(SendToBrowser()));
00066     FileMenu->insertItem("&Load marker setup...", this, SLOT(LoadMarkers()));
00067     FileMenu->insertItem("Save &marker setup...", this, SLOT(SaveMarkers()));
00068     FileMenu->insertItem("Cl&ose", this, SLOT(close()));
00069 
00070     //Edit Menu
00071     EditMenu = new QPopupMenu( this );
00072     menubar->insertItem( "&Edit",EditMenu);
00073     ShowMarkEditorId = EditMenu->insertItem("Show Marker &editor", this, SLOT(SetMarkerPanel()));
00074     EditMenu->setItemChecked(ShowMarkEditorId, fbMarkEditorVisible);
00075     ShowRootEditorId =EditMenu->insertItem("Show &ROOT Attributes Editor", this, SLOT(StartEditor()));
00076     EditMenu->setItemChecked(ShowRootEditorId, false);
00077     EditMenu->insertItem("&Condition Editor...", this, SLOT(StartConditionEditor()));
00078     EditMenu->insertSeparator();
00079     EditMenu->insertItem("&1:1 coordinates ratio", this, SLOT(RectangularRatio()));
00080     EditMenu->insertItem("&Default pad margins", this, SLOT(DefaultPadMargin()));
00081     EditMenu->insertSeparator();
00082     EditMenu->insertItem("Clear &Markers", this, SLOT(ClearAllMarkers()));
00083 //    EditMenu->insertItem("Clear Pad", this, SLOT(ClearPad()));
00084     EditMenu->insertItem("Clear &Pad", this, SLOT(ClearAllPads()));
00085     EditMenu->insertItem("Clear C&anvas", this, SLOT(ClearCanvas()));
00086 
00087     //Options Menu
00088     OptionsMenu = new QPopupMenu( this );
00089     menubar->insertItem( "&Options",OptionsMenu);
00090     connect(OptionsMenu, SIGNAL(aboutToShow()), this, SLOT(AboutToShowOptionsMenu()));
00091 
00092     EventStatusId = OptionsMenu->insertItem("&Event Status", this, SLOT(ShowEventStatus()));
00093     OptionsMenu->setItemChecked(EventStatusId, false);
00094     CrosshairId = OptionsMenu->insertItem("&Crosshair", this, SLOT(SetCrosshair()));
00095     StatisticsId = OptionsMenu->insertItem("Histogram &Statistics", this, SLOT(SetStatistics()));
00096     TitleId = OptionsMenu->insertItem("Histogram &Title", this, SLOT(SetHistoTitle()));
00097     LegendId = OptionsMenu->insertItem("Multiplot &Legend", this, SLOT(SetLegend()));
00098     FreezeTitleId = OptionsMenu->insertItem("&Keep Viewpanel Title", this, SLOT(SetFreezeTitle()));
00099     OptionsMenu->setItemChecked(FreezeTitleId, false);
00100     OptionsMenu->insertItem("Set &Viewpanel Title...", this, SLOT(SetViewpanelTitle()));
00101     SuperImposeId = OptionsMenu->insertItem("Super &Impose", this, SLOT(SetSuperImpose()));
00102     ApplytoAllId = OptionsMenu->insertItem("Apply to &All Pads", this, SLOT(SetApplyToAll()));
00103     OptionsMenu->setItemChecked(ApplytoAllId, false);
00104     ApplyToAllflag= false;
00105     
00106     
00107     
00108     CanvasStatus= new QStatusBar(this, "Canvas Status");
00109     TGo4PreviewPanelLayout->addWidget( CanvasStatus,2, 0 );
00110     fxTGo4WorkSpace->NewViewPanel(this);
00111     C->setName(name());
00112     C->GetCanvas()->SetName(name());
00113     MarkerPanel->setRadioButtonExclusive(false);
00114     MarkerPanel->setExclusive(false);
00115     
00116     fxRooteditor= new TQRootWindow(EditorFrame,"rootwrapperwindow");
00117     
00118     QVBoxLayout* gedlayout = new QVBoxLayout(EditorFrame);
00119     if (fxRooteditor) gedlayout->addWidget(fxRooteditor);
00120     EditorFrame->polish();
00121     EditorFrame->update();
00122     EditorFrame->show();
00123     EditorFrame->setShown(fbEditorFrameVisible);
00124     RefreshButtons();
00125     DisplayPadStatus(ActivePad);
00126 }
00127 
00128 void TGo4PreviewPanel::AboutToShowOptionsMenu() 
00129 {
00130    bool superImpose, showhistostats, showhistotitle, crosshair, legend;
00131 //   bool crosshairdefault=false; // get this from mainwindow later
00132     
00133    TGo4PadOptions *fxOptions= fxTGo4PreviewPanelStatus->GetPadOptions(ActivePad);
00134    if(fxOptions==0){
00135       superImpose = false;
00136       showhistostats = true;
00137       showhistotitle = true;
00138       crosshair = fbCrosshairDefault;
00139       legend = true;
00140       fxTGo4PreviewPanelStatus->SetPadDrawOption(ActivePad,"",superImpose);
00141       fxTGo4PreviewPanelStatus->SetPadHistogramStats(ActivePad,showhistostats);
00142       fxTGo4PreviewPanelStatus->SetPadHistogramTitle(ActivePad,showhistotitle);
00143       fxTGo4PreviewPanelStatus->SetPadCrosshair(ActivePad,crosshair);
00144       fxTGo4PreviewPanelStatus->SetPadLegend(ActivePad, legend);
00145     } else {
00146       superImpose = fxOptions->DragAddOption();
00147       showhistostats = fxOptions->IsHisStats();
00148       showhistotitle = fxOptions->IsHisTitle();
00149       crosshair = fxOptions->IsCrosshair();
00150       legend = fxOptions->IsLegendDraw();
00151     }
00152     OptionsMenu->setItemChecked(SuperImposeId, superImpose);
00153     OptionsMenu->setItemChecked(StatisticsId, showhistostats);
00154     OptionsMenu->setItemChecked(TitleId, showhistotitle);
00155     OptionsMenu->setItemChecked(CrosshairId, crosshair);
00156     OptionsMenu->setItemChecked(LegendId, legend);
00157 }
00158 
00159 void TGo4PreviewPanel::InitPad( TPad * pad )
00160 {
00161     if(pad==0) return;
00162     //cout <<"InitPad for "<<pad << endl;
00163     fxTGo4PreviewPanelStatus->SetPadDrawOption(pad,"hist",FALSE );
00164     pad->SetCrosshair(fbCrosshairDefault);
00165     fxTGo4PreviewPanelStatus->SetPadCrosshair(pad,fbCrosshairDefault);
00166     pad->SetFillColor(fiPadFillColor);
00167 }
00168 
00169 void TGo4PreviewPanel::PrintCanvas()
00170 {
00171       // TGo4LockGuard glob;
00172    TGo4PrintWidget fxPrint;
00173    if (!fxPrint.exec()) return; 
00174    QString PdefName= fxPrint.GetPrinter();
00175    QString PdefProg = fxPrint.GetPrintProg();
00176    TCanvas *fxCanvas = C->GetCanvas();
00177    fxCanvas->Print("~/go4printout.ps");
00178    QString PrnCmd = PdefProg;
00179    PrnCmd.append(" -P ");
00180    PrnCmd.append(PdefName);
00181    PrnCmd.append(" ~/go4printout.ps");
00182    gSystem->Exec(PrnCmd.data());
00183    gSystem->Exec("rm -f ~/go4printout.ps");
00184 }
00185 
00186 void TGo4PreviewPanel::StartEditor()
00187 {
00188 //cout <<"TGo4PreviewPanel::StartEditor()" << endl;
00189 fbEditorFrameVisible = !EditMenu->isItemChecked(ShowRootEditorId);
00190 EditMenu->setItemChecked(ShowRootEditorId,fbEditorFrameVisible);
00191 EditorFrame->setShown(fbEditorFrameVisible);
00192 //EditorFrame->setUpdatesEnabled(false);
00193 C->GetCanvas()->cd(); // assign this canvas to the editor
00194 fxTGo4PreviewPanelSlots->BuildPadEditor(fxRooteditor);
00195 //repaint();
00196 //EditorFrame->setUpdatesEnabled(true);
00197 //EditorFrame->repaint(false);
00198 //polish();
00199 //update();
00200 //show();
00201 }
00202 
00203 void TGo4PreviewPanel::RectangularRatio() 
00204 {
00205    TPad *pad = GetActivePad();
00206    if (pad==0) return;
00207  
00208    double dx = fabs(pad->AbsPixeltoX(1) - pad->AbsPixeltoX(0));
00209    double dy = fabs(pad->AbsPixeltoY(1) - pad->AbsPixeltoY(0));
00210 
00211    if ((dx<=0) || (dy<=0)) return;
00212    
00213    double ratio = dx / dy;
00214    
00215    if (ratio<1.) {
00216      double left = pad->GetLeftMargin();
00217      double right = pad->GetRightMargin();
00218      double change = (1.-left-right)*(1-ratio);
00219      pad->SetLeftMargin(left+change/2.);
00220      pad->SetRightMargin(right+change/2.);
00221    } else {
00222      double bottom = pad->GetBottomMargin();
00223      double top = pad->GetTopMargin();
00224      double change = (1.-bottom-top)*(1.-1/ratio);
00225      pad->SetTopMargin(top + change/2.);
00226      pad->SetBottomMargin(bottom + change/2.);
00227    }
00228    
00229    RedrawPad(pad); 
00230 }
00231 
00232 void TGo4PreviewPanel::DefaultPadMargin()
00233 {
00234    TPad *pad = GetActivePad();
00235    if (pad==0) return;
00236    
00237    pad->SetLeftMargin(gStyle->GetPadLeftMargin());
00238    pad->SetRightMargin(gStyle->GetPadRightMargin());
00239    pad->SetTopMargin(gStyle->GetPadTopMargin());
00240    pad->SetBottomMargin(gStyle->GetPadBottomMargin());
00241 
00242    RedrawPad(pad); 
00243 }
00244 
00245 
00246 void TGo4PreviewPanel::ClearPad()
00247 {
00248    // TGo4LockGuard glob;
00249    TPad *Pad=GetActivePad();
00250    fxTGo4PreviewPanelStatus->RemoveSubPads(Pad);
00251    ClearLegend(Pad,true); 
00252    Pad->Clear();
00253    Pad->Update();
00254    fxTGo4PreviewPanelSlots->InformUpdatePad(Pad);
00255 }
00256 /*
00257 void TGo4PreviewPanel::ClearAllPads()
00258 {
00259 // TGo4LockGuard glob;
00260    TCanvas* can = C->GetCanvas();
00261    TList* primlist = can->GetListOfPrimitives();
00262    if(primlist==0) return;
00263    TIterator* liter = primlist->MakeIterator();
00264    TObject* next=0;
00265    while((next=liter->Next())!=0) {
00266      if(next->InheritsFrom("TPad")) {
00267          TPad* subpad=dynamic_cast<TPad*>(next);
00268          fxTGo4PreviewPanelStatus->RemoveSubPads(subpad); // will also remove subsubpads...
00269          //fxTGo4PreviewPanelSlots->ClearAllLabels(subpad);
00270       }
00271    }
00272    delete liter;
00273    fxTGo4PreviewPanelSlots->ClearLegend(0); // remove all legends, since we would lose legends of subsubpads anyway
00274    C->Clear("D"); // this will not delete direct subpads, but subsubpads!
00275                  // therefore we removed the subsubpads from status above...
00276    C->Update();
00277 }
00278 */
00279 
00280 void TGo4PreviewPanel::ProcessPadClear(TPad * pad)
00281 {
00282    if (pad==0) return; 
00283 
00284    Bool_t isanysubpad = kFALSE;
00285    TIter iter(pad->GetListOfPrimitives());
00286    TObject* next = 0;
00287    while((next=iter()) !=0 ) {
00288       TPad* subpad=dynamic_cast<TPad*>(next);
00289       if (subpad!=0) {
00290          ProcessPadClear(subpad);
00291          isanysubpad = kTRUE;   
00292       }
00293    }
00294    if (!isanysubpad) {
00295      fxTGo4PreviewPanelSlots->ClearAllLabels(pad);
00296      fxTGo4PreviewPanelSlots->ClearLegend(pad, kTRUE);
00297      pad->Clear();
00298      pad->Update();
00299      fxTGo4PreviewPanelSlots->InformUpdatePad(pad);
00300    }
00301 }
00302 
00303 void TGo4PreviewPanel::ClearAllPads()
00304 {
00305    TPad* pad = GetActivePad(); 
00306    ProcessPadClear(pad);
00307    ActivePad = 0;
00308    if (pad!=GetActivePad()) SetActivePad(pad);
00309 }
00310 
00311 void TGo4PreviewPanel::ClearCanvas()
00312 {
00313    // TGo4LockGuard glob;
00314    fxTGo4PreviewPanelSlots->InformUpdatePad(0);   
00315    fxTGo4PreviewPanelSlots->ClearAllLabels(0);
00316    fxTGo4PreviewPanelSlots->ClearLegend(0);
00317    C->Clear();   
00318    fxTGo4PreviewPanelStatus->ResetPadOptionsList();
00319    ActivePad=GetCanvas();
00320    InitPad(ActivePad);
00321    ActivePad=0; // emulate change of active pad to have menus updated
00322    SetActivePad(GetCanvas());
00323    C->Update();   
00324    RefreshButtons();
00325 }
00326 
00327 bool TGo4PreviewPanel::GetShowEventStatus()
00328 {
00329    // TGo4LockGuard glob;
00330    return OptionsMenu->isItemChecked(EventStatusId);
00331 }
00332 
00333 void TGo4PreviewPanel::ShowEventStatus()
00334 {
00335    // TGo4LockGuard glob;
00336    bool s = !OptionsMenu->isItemChecked(EventStatusId);
00337    OptionsMenu->setItemChecked(EventStatusId,s);
00338    C->SetShowEventStatus(s);
00339    if(!s)   DisplayPadStatus(ActivePad);
00340 }
00341 void TGo4PreviewPanel::DisplayEventStatus(const char *Message)
00342 {
00343    // TGo4LockGuard glob;
00344    CanvasStatus->message(Message);
00345 }
00346 
00347 void TGo4PreviewPanel::ChangeSuperImpose(bool superimpose) 
00348 {
00349    TPad* SelectedPad = GetActivePad();
00350    if(!ApplyToAllPads()) {
00351        fxTGo4PreviewPanelStatus->SetPadDrawOption(SelectedPad, "hist", superimpose);
00352     } else {
00353        TObject *entry=0;
00354        TRefArray *ListOfPads = new TRefArray;
00355        ListOfPads->AddAll(GetListOfPads());
00356        TIter Padlistiter(ListOfPads);
00357        while((entry= Padlistiter.Next()) !=0) {
00358           TPad *pad=dynamic_cast <TPad *>(entry);
00359           fxTGo4PreviewPanelStatus->SetPadDrawOption(pad, "hist", superimpose);
00360        }
00361        ListOfPads->Clear("nodelete");
00362        delete ListOfPads; 
00363         
00364     }
00365     DisplayPadStatus(SelectedPad);
00366 }
00367 
00368 
00369 void TGo4PreviewPanel::SetSuperImpose() 
00370 {
00371    // TGo4LockGuard glob;
00372    bool s = !OptionsMenu->isItemChecked(SuperImposeId);
00373    ChangeSuperImpose(s);
00374 }
00375 
00376 void TGo4PreviewPanel::SetApplyToAll()
00377 {
00378    // TGo4LockGuard glob;
00379    bool s = !OptionsMenu->isItemChecked(ApplytoAllId);
00380    OptionsMenu->setItemChecked(ApplytoAllId,s);
00381 //    TPad *RootSelectedPad=dynamic_cast <TPad *>(gROOT->GetSelectedPad());
00382 //     fxTGo4PreviewPanelStatus->SetPadDrawOption(RootSelectedPad,"hist",s);
00383      ApplyToAllflag=s;
00384     DisplayPadStatus(ActivePad);
00385 }
00386 
00387 
00388 void TGo4PreviewPanel::SetStatistics() 
00389 {
00390    bool s = !OptionsMenu->isItemChecked(StatisticsId);
00391    TPad* activepad=GetActivePad();
00392    if(!ApplyToAllPads()) {
00393       fxTGo4PreviewPanelStatus->SetPadHistogramStats(activepad,s);
00394       TH1* his=GetPadHistogram(activepad);
00395       if(his) his->SetStats(s);
00396       activepad->Modified();
00397       activepad->Update();
00398    } else {
00399      TObject *entry=0;     
00400      TRefArray *ListOfPads = new TRefArray;
00401      ListOfPads->AddAll(GetListOfPads());
00402      TIter Padlistiter(ListOfPads);
00403      while((entry= Padlistiter.Next()) !=0) {
00404         TPad *pad=dynamic_cast <TPad *>(entry);
00405         fxTGo4PreviewPanelStatus->SetPadHistogramStats(pad,s);
00406         TH1* his=GetPadHistogram(pad);
00407         if(his) his->SetStats(s);
00408         pad->Modified();
00409         pad->Update();
00410      }
00411      ListOfPads->Clear("nodelete");
00412      delete ListOfPads;
00413    }
00414 }
00415 
00416 void TGo4PreviewPanel::SetHistoTitle()
00417 {
00418    bool s = !OptionsMenu->isItemChecked(TitleId);
00419    TPad* activepad=GetActivePad();
00420    if(!ApplyToAllPads()) {
00421       fxTGo4PreviewPanelStatus->SetPadHistogramTitle(activepad,s);
00422       Redraw();
00423    } else {
00424       TObject *entry=0;
00425       TRefArray *ListOfPads = new TRefArray;
00426       ListOfPads->AddAll(GetListOfPads());
00427       TIter Padlistiter(ListOfPads);      
00428       while((entry= Padlistiter.Next()) !=0) {
00429          TPad *pad=dynamic_cast <TPad *>(entry);
00430          fxTGo4PreviewPanelStatus->SetPadHistogramTitle(pad,s);
00431          SetActivePad(pad);
00432          Redraw();
00433       }
00434       SetActivePad(activepad);
00435       GetCanvas()->Update();
00436       ListOfPads->Clear("nodelete");
00437       delete ListOfPads;
00438    }
00439 }
00440 
00441 void TGo4PreviewPanel::SetLegend()
00442 {
00443     bool s = !OptionsMenu->isItemChecked(LegendId);
00444     TPad* activepad = GetActivePad();
00445     if(!ApplyToAllPads()) {
00446        fxTGo4PreviewPanelStatus->SetPadLegend(activepad,s);
00447        Redraw();
00448     } else {
00449        TObject *entry=0;
00450        TRefArray *ListOfPads = new TRefArray;
00451        ListOfPads->AddAll(GetListOfPads());
00452        TIter Padlistiter(ListOfPads);       
00453        while((entry= Padlistiter.Next()) !=0) {
00454          TPad *pad = dynamic_cast <TPad *>(entry);
00455          if (pad!=0) {
00456             fxTGo4PreviewPanelStatus->SetPadLegend(pad,s);
00457             SetActivePad(pad);
00458             Redraw();
00459          }
00460        }
00461        SetActivePad(activepad);
00462        GetCanvas()->Update();
00463        ListOfPads->Clear("nodelete");
00464        delete ListOfPads;
00465     }
00466 }
00467 void TGo4PreviewPanel::SetCrosshair()
00468 {
00469    bool s = !OptionsMenu->isItemChecked(CrosshairId);
00470 
00471    #if __GO4ROOTVERSION__ < 40008
00472 
00473    TPad* activepad=GetActivePad();
00474    if(!ApplyToAllPads()) {
00475       fxTGo4PreviewPanelStatus->SetPadCrosshair(activepad,s);
00476    } else {
00477       TObject *entry=0;
00478        TRefArray *ListOfPads = new TRefArray;
00479        ListOfPads->AddAll(GetListOfPads());
00480        TIter Padlistiter(ListOfPads);
00481       while((entry= Padlistiter.Next()) !=0) {
00482          TPad *pad = dynamic_cast <TPad *>(entry);
00483          if (pad!=0)
00484             fxTGo4PreviewPanelStatus->SetPadCrosshair(pad,s);
00485       }
00486       ListOfPads->Clear("nodelete");
00487       delete ListOfPads;
00488    }
00489    
00490    #else
00491    
00492       fxTGo4PreviewPanelStatus->SetPadCrosshair(GetCanvas(),s);
00493    
00494    #endif
00495 }
00496 
00497 void TGo4PreviewPanel::destroy()
00498 {
00499     TGo4LockGuard glob;
00500     fxTGo4GUIRegistry->UnRegisterClass(fxTGo4PreviewPanelSlots,fxTGo4PreviewPanelStatus);
00501     fxTGo4WorkSpace->DelViewPanel(this);
00502     delete menubar;
00503     delete  fxTGo4PreviewPanelSlots;
00504 }
00505 
00506 
00507 void TGo4PreviewPanel::closeEvent( QCloseEvent* ce )
00508 {
00509    // TGo4LockGuard glob;
00510     // clean up possible images here before Qt deletes Canvas::
00511     TObject *entry=0;
00512     TRefArray *ListOfPads = new TRefArray;
00513     ListOfPads->AddAll(GetListOfPads());
00514     TIter Padlistiter(ListOfPads);
00515     while((entry= Padlistiter.Next()) !=0)
00516         {
00517 //            cout << name()<<"::closeEvent scanning padentry: "<<entry<<" ,"<<entry->GetName()<<", class: "<<entry->IsA()->GetName();
00518 //            cout <<" UID:"<<ListOfPads->GetUID(ListOfPads->IndexOf(entry)) << endl;
00519             TPad *pad=dynamic_cast <TPad *>(entry);
00520             #ifdef __GO4USEASIMAGE__
00521             TGo4ASImage* im=GetPadImage(pad);
00522             if(im) delete im;
00523             #endif
00524         }
00525     ListOfPads->Clear("nodelete");
00526     delete ListOfPads;
00527     ce->accept();
00528     delete this;
00529 }
00530 
00531 
00532 void TGo4PreviewPanel::dragMoveEvent( QDragMoveEvent* )
00533 {
00534  //cout<<"TGo4PreviewPanel::dragMoveEvent( QDragMoveEvent * )"<<endl;
00535 }
00536 
00537 void TGo4PreviewPanel::dropEvent( QDropEvent *Event )
00538 {
00539    // TGo4LockGuard glob;
00540    QString str;
00541    if ( QTextDrag::decode( Event, str ) ) {
00542       return;
00543    }
00544 }
00545 
00546 void TGo4PreviewPanel::dragEnterEvent( QDragEnterEvent *e )
00547 {
00548    // TGo4LockGuard glob;
00549     if ( QTextDrag::canDecode( e ))   {
00550 
00551    e->accept();
00552     }
00553 
00554 }
00555 
00556 
00557 void TGo4PreviewPanel::Redraw() {
00558    RedrawPad(GetActivePad());
00559 }
00560 
00561 void TGo4PreviewPanel::RedrawPad(TPad *CanvasSelectedPad) {
00562     // TGo4LockGuard glob;
00563     if (CanvasSelectedPad==0) return;
00564     fxTGo4PreviewPanelSlots->ScanMarkers(CanvasSelectedPad);
00565     TH1 *h1=0;
00566     THStack *hs=0;
00567     TGraph *gr=0;
00568     TMultiGraph *mg=0;
00569     TGo4ASImage *ai=0;
00570     TObject *entry = 0;
00571     TIter iter(CanvasSelectedPad->GetListOfPrimitives());
00572     while((entry = iter()) != 0) {
00573        if (entry->InheritsFrom("TH1")){
00574           h1 = dynamic_cast<TH1*> (entry);
00575        } else
00576        if(entry->InheritsFrom("THStack")) {
00577          hs = dynamic_cast<THStack*> (entry);
00578        } else
00579        if(entry->InheritsFrom("TGraph") && !entry->InheritsFrom("TCutG")) {
00580           // suppress cutgs for the condition editor case
00581           gr = dynamic_cast<TGraph*> (entry);
00582        } else
00583        if(entry->InheritsFrom("TMultiGraph")){
00584           mg = dynamic_cast<TMultiGraph*> (entry);
00585        } 
00586 #ifdef __GO4USEASIMAGE__      
00587        else if(entry->InheritsFrom("TGo4ASImage")){
00588          ai = dynamic_cast<TGo4ASImage*> (entry);
00589        }
00590 #endif
00591 
00592     } // while
00593 
00594     bool cross = fxTGo4PreviewPanelStatus->GetPadCrosshair(CanvasSelectedPad);
00595     CanvasSelectedPad->SetCrosshair(cross);
00596 
00597     if(mg!=0) {
00598       RedrawMultiGraph(mg,CanvasSelectedPad);
00599     } else
00600     if(gr!=0) {
00601       RedrawGraph(gr,CanvasSelectedPad);
00602     } else
00603     if(ai!=0) {
00604       RedrawImage(ai,CanvasSelectedPad);
00605     } else
00606     if(h1!=0) {
00607       h1->SetBit(kCanDelete,0);
00608       RedrawHistogram(h1,CanvasSelectedPad);
00609     } else
00610     if(hs!=0) {
00611       RedrawStack(hs,CanvasSelectedPad);
00612     }
00613     CanvasSelectedPad->Update();
00614 }
00615 
00616 
00617 void TGo4PreviewPanel::RedrawHistogram( TH1 * his, TPad * pad )
00618 {
00619 if(his==0 || pad==0) return;
00620 gROOT->SetSelectedPad(pad);
00621 QString poptions=fxTGo4PreviewPanelStatus->GetPadStringDrawOption(pad);
00622 #ifdef __GO4USEASIMAGE__
00623 
00624 if(poptions.contains("asimage",false) && his->InheritsFrom("TH2"))
00625     // non case sensitive
00626     {
00627         //cout <<"RedrawHistogram with asi" << endl;
00628         TH2* map=dynamic_cast<TH2*>(his);
00629         TGo4ASImage* pic=new TGo4ASImage(map);
00630         // scale setup of image is done in ctor
00631         pad->Clear();
00632         pic->Draw();
00633         UpdatePad(pad, his, false); // copy range to padoptions, but  not draw style.
00634     }
00635 else
00636 #endif //__GO4USEASIMAGE__ 
00637     {
00638         //cout <<"RedrawHistogram normal" << endl;
00639         bool histostats=fxTGo4PreviewPanelStatus->GetPadHistogramStats(pad);
00640         his->SetStats(histostats);
00641         bool histotitle=fxTGo4PreviewPanelStatus->GetPadHistogramTitle(pad);
00642         his->SetBit(TH1::kNoTitle,!histotitle);
00643         his->Draw(poptions.ascii());
00644         UpdatePad(pad, his, true); // copy range to padoptions and draw style.
00645     }
00646 }
00647 
00648 void TGo4PreviewPanel::RedrawImage( TGo4ASImage * im, TPad * pad )
00649 {
00650 #ifdef __GO4USEASIMAGE__
00651 
00652 if(im==0 || pad==0) return;
00653 gROOT->SetSelectedPad(pad);
00654 QString poptions=fxTGo4PreviewPanelStatus->GetPadStringDrawOption(pad);
00655 if(poptions.contains("asimage",false)) // non case sensitive
00656     {
00657          //cout <<"RedrawImage with asi" << endl;
00658          im->Draw();
00659          pad->Update();
00660          fxTGo4PreviewPanelSlots->RedrawAllLabels(pad);
00661     }
00662 else
00663     {
00664        //cout <<"RedrawImage as histogram" << endl;
00665        ClearPad();
00666        // check here if histogram is still in browser?
00667        // otherwise, user may have deleted it already, dead pointer!
00668        TH2* histo=im->GetHistogram();
00669        TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
00670        if(mw->CheckHistogram(im->GetName(),histo))
00671            {
00672                im->SetHistogramRanges(histo);
00673                delete im;
00674                RedrawHistogram(histo,pad);
00675            }
00676     }
00677 #else
00678     return; // dummy for QtSlots
00679 #endif
00680 }
00681 
00682 
00683 void TGo4PreviewPanel::RedrawGraph( TGraph * gr, TPad * pad )
00684 {
00685 if(gr==0 || pad==0) return;
00686 gROOT->SetSelectedPad(pad);
00687 QString PadOptions;
00688     // note that string options for TGraph are different than for TH1
00689     // for the moment, we do not use padoptions here!
00690 PadOptions.prepend(" \"AP,");
00691 PadOptions.append("\"");
00692 bool histostats=fxTGo4PreviewPanelStatus->GetPadHistogramStats(pad);
00693 bool histotitle=fxTGo4PreviewPanelStatus->GetPadHistogramTitle(pad);
00694 TH1* framehisto=gr->GetHistogram();
00695 framehisto->SetStats(histostats);
00696 framehisto->SetBit(TH1::kNoTitle,!histotitle);
00697 gr->Draw(PadOptions.data());
00698 fxTGo4PreviewPanelSlots->RedrawAllLabels(pad);
00699 //pad->Update();
00700 }
00701 
00702 void TGo4PreviewPanel::RedrawStack( THStack * hs, TPad * pad )
00703 {
00704    if(hs==0 || pad==0) return;
00705    gROOT->SetSelectedPad(pad);
00706    QString PadOptions = fxTGo4PreviewPanelStatus->GetPadStringDrawOption(pad);
00707    PadOptions.prepend(" \"nostack ,");
00708    PadOptions.append("\"");
00709 // change of statistics and title visibility:
00710    bool histostats = false; // never draw statistics with stack
00711    fxTGo4PreviewPanelStatus->SetPadHistogramStats(pad,histostats);
00712    bool histotitle = fxTGo4PreviewPanelStatus->GetPadHistogramTitle(pad);
00713    bool legend = fxTGo4PreviewPanelStatus->GetPadLegend(pad);
00714    TH1* framehisto=hs->GetHistogram();
00715    framehisto->SetStats(histostats);
00716    framehisto->SetBit(TH1::kNoTitle,!histotitle);
00717    hs->Draw(PadOptions.data());
00718    if(legend) fxTGo4PreviewPanelSlots->DrawLegend(pad,hs);
00719          else fxTGo4PreviewPanelSlots->ClearLegend(pad);
00720    fxTGo4PreviewPanelSlots->RedrawAllLabels(pad);
00721 //pad->Update();
00722 }
00723 
00724 void TGo4PreviewPanel::RedrawMultiGraph( TMultiGraph * mg, TPad * pad )
00725 {
00726    if(mg==0 || pad==0) return;
00727    gROOT->SetSelectedPad(pad);
00728    QString PadOptions;
00729     // note that string options for TGraph are different than for TH1
00730     // for the moment, we do not use padoptions here!
00731    PadOptions.prepend(" \"AP,");
00732    PadOptions.append("\"");
00733    bool histostats = false; // never draw statistics with multigraph
00734    fxTGo4PreviewPanelStatus->SetPadHistogramStats(pad,histostats);
00735    bool histotitle = fxTGo4PreviewPanelStatus->GetPadHistogramTitle(pad);
00736    bool legend = fxTGo4PreviewPanelStatus->GetPadLegend(pad);
00737    TH1* framehisto = mg->GetHistogram();
00738    framehisto->SetStats(histostats);
00739    framehisto->SetBit(TH1::kNoTitle,!histotitle);
00740    mg->Draw(PadOptions.data());
00741    if(legend) fxTGo4PreviewPanelSlots->DrawLegend(pad,mg);
00742          else fxTGo4PreviewPanelSlots->ClearLegend(pad); 
00743    fxTGo4PreviewPanelSlots->RedrawAllLabels(pad);
00744 //pad->Update();
00745 }
00746 
00747 
00748 void TGo4PreviewPanel::ClearLegend( TPad * pad, bool del )
00749 {
00750     fxTGo4PreviewPanelSlots->ClearLegend(pad,del); 
00751 }
00752 
00753 
00754 
00755 
00756 void TGo4PreviewPanel::Divide( int X, int Y )
00757 {
00758     // TGo4LockGuard glob;
00759 if(ActivePad!=0)
00760     {
00761         //cout <<"Divide to "<<X<<","<<Y << endl;
00762         fxTGo4PreviewPanelStatus->RemoveSubPads(ActivePad);
00763         // remove subpads wil not cleanup labels of this pad:
00764         fxTGo4PreviewPanelSlots->ClearAllLabels(ActivePad); 
00765         fxTGo4PreviewPanelSlots->ClearLegend(ActivePad, kTRUE);
00766         ActivePad->Clear();
00767         if(!(X==1 && Y==1)) // this would create pad on whole canvas 
00768             {
00769             ActivePad->Divide(X, Y);       
00770             for(int No=0; No<= X*Y;No++)
00771                 {
00772                     TPad* sub=dynamic_cast<TPad*>(ActivePad->GetPad(No));
00773                     InitPad(sub);
00774                 }
00775             }
00776         ActivePad->Update();
00777        // note: number of pads will be changed in list of previewpanelstatus by InitPad     
00778        RefreshButtons();
00779     }
00780 }
00781 
00782 TCanvas *TGo4PreviewPanel::GetCanvas()
00783 {
00784    // TGo4LockGuard glob;
00785     return C->GetCanvas();
00786 }
00787 
00788 void TGo4PreviewPanel::SaveCanvas()
00789 {
00790    TCanvas* thiscanvas = C->GetCanvas();
00791 //   Color_t oldfillcol = thiscanvas->GetFillColor();
00792    QFileDialog* fd = new QFileDialog( this, "Save Canvas", TRUE );
00793    QString fdCaption = "Save ";
00794    fdCaption.append(name());
00795    fdCaption.append("  As");
00796    fd->setCaption(fdCaption);
00797    QString EPS ="Encapsulated Post Script (*.eps)";
00798    QString PS ="Post Script (*.ps)";
00799    QString GIF="GIF Format  (*.gif)";
00800    QString CXXM="C++ Macro (*.C)";
00801    QString ROOTM="root file (*.root)";
00802    fd->setMode( QFileDialog::AnyFile );
00803    fd->setName( "Save Canvas ");
00804    fd->setFilter(EPS);
00805    fd->addFilter(PS);
00806    fd->addFilter(GIF);
00807    fd->addFilter(CXXM);
00808    fd->addFilter(ROOTM);
00809    if ( fd->exec() == QDialog::Accepted ) {
00810        QString filename = fd->selectedFile();
00811        QString filter = fd->selectedFilter();
00812        if(filter==EPS) {
00813           if (!filename.endsWith(".eps")) filename.append(".eps");
00814        } else 
00815        if(filter==PS) {
00816           if (!filename.endsWith(".ps")) filename.append(".ps");
00817        } else 
00818        if(filter==GIF) {
00819           if (!filename.endsWith(".gif")) filename.append(".gif");
00820        } else 
00821        if(filter==CXXM) {
00822           if (!filename.endsWith(".C")) filename.append(".C");
00823        } else 
00824        if (filter==ROOTM) {
00825           if (!filename.endsWith(".root")) filename.append(".root");
00826           //TCanvas* thiscanvas= (TCanvas*) thiscanvas->Clone();
00827           fxTGo4PreviewPanelSlots->ResetFillColors(thiscanvas,0);
00828           //
00829           // plain root browser might not know the go4 color numbers
00830          // canvas always saved with white background!
00831        }
00832     
00833        TString oldname = thiscanvas->GetName();
00834        thiscanvas->SetName("Canvas");
00835        thiscanvas->Print(filename.data());
00836        
00837        thiscanvas->SetName(oldname);
00838        fxTGo4PreviewPanelStatus->RefreshListOfPads(); // after saving canvas rebuild pad refarray with new object ids
00839    }
00840    
00841    delete fd;
00842 }
00843 
00844 
00845 TGo4PadOptions * TGo4PreviewPanel::GetPadOptions( TPad *SelectedPad )
00846 {
00847    // TGo4LockGuard glob;
00848     return  (fxTGo4PreviewPanelStatus->GetPadOptions(SelectedPad) );
00849 }
00850 
00851 void TGo4PreviewPanel::ExpandShiftX(int NewX1,int NewX2, TPad *RootSelectedPad, TH1* h1)
00852 {
00853    // TGo4LockGuard glob;
00854    h1->GetXaxis()->SetRange(NewX1,NewX2);
00855 #ifdef __GO4USEASIMAGE__
00856     TGo4ASImage* im=GetPadImage(RootSelectedPad);
00857     if(im) im->SetZoom(dynamic_cast<TH2*>(h1));
00858 #endif
00859    RootSelectedPad->Modified();
00860    RootSelectedPad->PaintModified();
00861    RootSelectedPad->Update();
00862 
00863 }
00864 
00865 void TGo4PreviewPanel::ExpandShiftY(int NewY1,int NewY2, TPad *RootSelectedPad, TH1* h1)
00866 {
00867    // TGo4LockGuard glob;
00868 // new: treat case of 1d histogram for zoom tools:      
00869 if(NewY1==NewY2) NewY2=NewY1+1;
00870 if(h1->GetDimension()==1)
00871     {
00872         bool autoscale=false;
00873         TGo4PadOptions *padoptions = fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
00874         if(padoptions) autoscale=padoptions->GetAutoScale();
00875         if(!autoscale)
00876             {
00877                 h1->SetMinimum(NewY1);
00878                 h1->SetMaximum(NewY2);
00879             }
00880     }
00881 else
00882     {
00883         h1->GetYaxis()->SetRange(NewY1,NewY2);
00884 #ifdef __GO4USEASIMAGE__
00885         TGo4ASImage* im=GetPadImage(RootSelectedPad);
00886         if(im) im->SetZoom(dynamic_cast<TH2*>(h1));
00887 #endif    
00888     }
00889    RootSelectedPad->Modified();
00890    RootSelectedPad->PaintModified();
00891    RootSelectedPad->Update();
00892 }
00893 
00894 void TGo4PreviewPanel::SlotShiftL(int expandfactor)
00895 {
00896    // TGo4LockGuard glob;
00897    TPad *RootSelectedPad=GetActivePad();
00898    Int_t Xfirst;
00899    Int_t Xlast;
00900    Int_t Ymin;
00901    Int_t Ymax;
00902    if(RootSelectedPad!=0){
00903       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
00904       if(fxTGo4PadOptions!=0){
00905          fxTGo4PadOptions->GetHistogramFullRange(Xfirst, Xlast, Ymin,Ymax);
00906       }
00907       TH1* h1=GetPadHistogram(RootSelectedPad);
00908       if(h1!=0){
00909          Int_t first    = h1->GetXaxis()->GetFirst();
00910          Int_t last     = h1->GetXaxis()->GetLast();
00911          Int_t Delta    = (last-first);
00912          Int_t Shift    = Delta*expandfactor/100;
00913          if(Shift<2) Shift=2; // minimum motion
00914          Int_t NewX1    = first+ Shift/2;
00915          Int_t NewX2    = last+ Shift/2;
00916          if(NewX2 > Xlast){
00917             NewX1=Xlast-Delta;
00918             NewX2=Xlast;
00919          }
00920          ExpandShiftX(NewX1,NewX2,RootSelectedPad,h1);
00921       }
00922    }
00923 }
00924 
00925 void TGo4PreviewPanel::SlotShiftR(int expandfactor)
00926 {
00927    // TGo4LockGuard glob;
00928    TPad *RootSelectedPad=GetActivePad();
00929    Int_t Xfirst;
00930    Int_t Xlast;
00931    Int_t Ymin;
00932    Int_t Ymax;
00933    if(RootSelectedPad!=0){
00934       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
00935       if(fxTGo4PadOptions!=0){
00936          fxTGo4PadOptions->GetHistogramFullRange(Xfirst, Xlast, Ymin,Ymax);
00937       }
00938       TH1* h1=GetPadHistogram(RootSelectedPad);
00939       if (h1!=0){
00940          Int_t first   = h1->GetXaxis()->GetFirst();
00941          Int_t last    = h1->GetXaxis()->GetLast();
00942          Int_t Delta   =(last-first);
00943          Int_t Shift   = Delta*expandfactor/100;
00944          if(Shift<2) Shift=2; // minimum motion
00945          Int_t NewX1= first-Shift/2;
00946          Int_t NewX2= last-Shift/2;
00947          if(NewX1 < Xfirst){
00948             NewX1=Xfirst;
00949             NewX2=Xfirst+Delta;
00950          }
00951          ExpandShiftX(NewX1,NewX2,RootSelectedPad,h1);
00952       }
00953    }
00954 
00955 }
00956 
00957 void TGo4PreviewPanel::SlotShiftU(int expandfactor)
00958 {
00959    // TGo4LockGuard glob;
00960    TPad *RootSelectedPad=GetActivePad();
00961    Int_t Xfirst;
00962    Int_t Xlast;
00963    Int_t Ymin;
00964    Int_t Ymax;
00965    if(RootSelectedPad!=0){
00966       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
00967       if(fxTGo4PadOptions!=0){
00968          fxTGo4PadOptions->GetHistogramFullRange(Xfirst, Xlast, Ymin,Ymax);
00969       }
00970       TH1* h1=GetPadHistogram(RootSelectedPad);
00971       if (h1!=0){
00972          Int_t Yfirst,Ylast; 
00973          if(h1->GetDimension()==1)
00974              {
00975                 Yfirst   = h1->GetMinimum();
00976                 Ylast    = h1->GetMaximum();
00977              }
00978          else
00979              {
00980                 Yfirst   = h1->GetYaxis()->GetFirst();
00981                 Ylast    = h1->GetYaxis()->GetLast();
00982              }
00983          Int_t Delta=(Ylast-Yfirst);
00984          Int_t Shift   = Delta*expandfactor/100;
00985          if(Shift<2) Shift=2; // minimum motion
00986          Int_t NewY1= Yfirst-Shift/2;
00987          Int_t NewY2= Ylast-Shift/2;         
00988          if(NewY1 < Ymin){
00989             NewY1=Ymin;
00990             NewY2=Ymin+Delta;
00991          }
00992          
00993          ExpandShiftY(NewY1,NewY2,RootSelectedPad, h1);
00994       }
00995    }
00996 }
00997 
00998 void TGo4PreviewPanel::SlotShiftD(int expandfactor)
00999 {
01000    // TGo4LockGuard glob;
01001    TPad *RootSelectedPad=GetActivePad();
01002    Int_t Xfirst;
01003    Int_t Xlast;
01004    Int_t Ymin;
01005    Int_t Ymax;
01006    if(RootSelectedPad!=0){
01007       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
01008       if(fxTGo4PadOptions!=0){
01009          fxTGo4PadOptions->GetHistogramFullRange(Xfirst, Xlast, Ymin,Ymax);
01010       }
01011       TH1* h1=GetPadHistogram(RootSelectedPad);
01012       if(h1!=0){
01013          Int_t Yfirst,Ylast;
01014          if(h1->GetDimension()==1)
01015              {
01016                 Yfirst   = h1->GetMinimum();
01017                 Ylast    = h1->GetMaximum();
01018              }
01019          else
01020              {
01021                 Yfirst   = h1->GetYaxis()->GetFirst();
01022                 Ylast    = h1->GetYaxis()->GetLast();
01023              }
01024          Int_t Delta=Ylast-Yfirst;
01025          Int_t Shift   = Delta*expandfactor/100;
01026          if(Shift<2) Shift=2; // minimum motion
01027          Int_t NewY1= Yfirst+Shift/2;
01028          Int_t NewY2= Ylast+Shift/2;         
01029          if(NewY2 > Ymax) {
01030             NewY2=Ymax;
01031             NewY1=Ymax-Delta;
01032          }
01033          ExpandShiftY(NewY1,NewY2,RootSelectedPad, h1);
01034       }
01035    }
01036 }
01037 
01038 void TGo4PreviewPanel::SlotExpandX(int expandfactor)
01039 {
01040    // TGo4LockGuard glob;
01041    TPad *RootSelectedPad=GetActivePad();
01042    Int_t Xfirst;
01043    Int_t Xlast;
01044    Int_t Ymin;
01045    Int_t Ymax;
01046    if(RootSelectedPad!=0){
01047       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
01048       if(fxTGo4PadOptions!=0){
01049          fxTGo4PadOptions->GetHistogramFullRange(Xfirst, Xlast, Ymin,Ymax);
01050       }
01051       TH1* h1=GetPadHistogram(RootSelectedPad);
01052       if (h1!=0){
01053          Int_t first   = h1->GetXaxis()->GetFirst();
01054          Int_t last    = h1->GetXaxis()->GetLast();
01055          Int_t Shift   = (last-first)*expandfactor/100;
01056          if(Shift<2) Shift=2; // minimum motion
01057          Int_t NewX1= first+Shift/2;
01058          Int_t NewX2= last-Shift/2;         
01059          if(NewX1> NewX2){
01060             NewX1=NewX2;
01061          }
01062          ExpandShiftX(NewX1,NewX2,RootSelectedPad,h1);
01063       }
01064    }
01065 
01066 }
01067 
01068 void TGo4PreviewPanel::SlotExpandY(int expandfactor)
01069 {
01070    // TGo4LockGuard glob;
01071    TPad *RootSelectedPad=GetActivePad();
01072    Int_t Xfirst;
01073    Int_t Xlast;
01074    Int_t Ymin;
01075    Int_t Ymax;
01076    if(RootSelectedPad!=0){
01077       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
01078       if(fxTGo4PadOptions!=0){
01079          fxTGo4PadOptions->GetHistogramFullRange(Xfirst, Xlast, Ymin,Ymax);
01080       }
01081       TH1* h1=GetPadHistogram(RootSelectedPad);
01082       if(h1!=0){
01083          Int_t Yfirst,Ylast;
01084          if(h1->GetDimension()==1)
01085              {
01086                 Yfirst   = h1->GetMinimum();
01087                 Ylast    = h1->GetMaximum();
01088              }
01089          else
01090              {
01091                 Yfirst   = h1->GetYaxis()->GetFirst();
01092                 Ylast    = h1->GetYaxis()->GetLast();
01093              }
01094          Int_t Shift   = (Ylast-Yfirst)*expandfactor/100;
01095          //if(Shift<2) Shift=2; // minimum motion
01096          Int_t NewY1= Yfirst+Shift/2;
01097          Int_t NewY2= Ylast-Shift/2;
01098          if(NewY1>= NewY2){
01099             NewY1=NewY2-1;
01100          }
01101          ExpandShiftY(NewY1,NewY2,RootSelectedPad, h1);
01102       }
01103    }
01104 }
01105 
01106 void TGo4PreviewPanel::SlotUExpandX(int expandfactor)
01107 {
01108    // TGo4LockGuard glob;
01109    TPad *RootSelectedPad=GetActivePad();
01110    Int_t Xfirst;
01111    Int_t Xlast;
01112    Int_t Ymin;
01113    Int_t Ymax;
01114    if(RootSelectedPad!=0){
01115       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
01116       if(fxTGo4PadOptions!=0){
01117          fxTGo4PadOptions->GetHistogramFullRange(Xfirst, Xlast, Ymin,Ymax);
01118       }
01119       TH1* h1=GetPadHistogram(RootSelectedPad);
01120       if (h1!=0){
01121          Int_t first   = h1->GetXaxis()->GetFirst();
01122          Int_t last    = h1->GetXaxis()->GetLast();
01123          Int_t Shift   = (last-first)*expandfactor/100;
01124          if(Shift<2) Shift=2; // minimum motion
01125          Int_t NewX1= first-Shift/2;
01126          Int_t NewX2= last+Shift/2;
01127          if(NewX1 <= Xfirst) {
01128             NewX1=Xfirst;
01129          }
01130          if(NewX2 >= Xlast){
01131             NewX2=Xlast;
01132          }
01133          ExpandShiftX(NewX1,NewX2,RootSelectedPad,h1);
01134       }
01135    }
01136 }
01137 
01138 void TGo4PreviewPanel::SlotUExpandY(int expandfactor)
01139 {
01140    // TGo4LockGuard glob;
01141    TPad *RootSelectedPad=GetActivePad();
01142    Int_t Xfirst;
01143    Int_t Xlast;
01144    Int_t Ymin;
01145    Int_t Ymax;
01146    if(RootSelectedPad!=0){
01147       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
01148       if(fxTGo4PadOptions!=0){
01149          fxTGo4PadOptions->GetHistogramFullRange(Xfirst, Xlast, Ymin,Ymax);
01150       }
01151       TH1* h1=GetPadHistogram(RootSelectedPad);
01152       if(h1!=0){
01153          Int_t Yfirst,Ylast;
01154          if(h1->GetDimension()==1)
01155              {
01156                 Yfirst   = h1->GetMinimum();
01157                 Ylast    = h1->GetMaximum();
01158              }
01159          else
01160              {
01161                 Yfirst   = h1->GetYaxis()->GetFirst();
01162                 Ylast    = h1->GetYaxis()->GetLast();
01163              }         
01164          Int_t Shift   = (Ylast-Yfirst)*expandfactor/100;
01165          if(Shift<2) Shift=2; // minimum motion
01166          Int_t NewY1= Yfirst-Shift/2;
01167          Int_t NewY2= Ylast+Shift/2;
01168          if(NewY1 < Ymin) {
01169             NewY1=Ymin;
01170          }
01171          if(NewY2 > Ymax){
01172             NewY2=Ymax;
01173          }
01174          ExpandShiftY(NewY1,NewY2,RootSelectedPad, h1);
01175       }
01176    }
01177 }
01178 
01179 TPad * TGo4PreviewPanel::GetActivePad()
01180 {
01181    // TGo4LockGuard glob;
01182    if(ActivePad==0) {
01183       int NoOfPads=0;
01184       TPad *CanvasSelectedPad=0;
01185 
01186       TCanvas* ThisCanvas= C->GetCanvas();
01187 
01188       TPad* RootSelectedPad=dynamic_cast <TPad *>(gROOT->GetSelectedPad());
01189 
01190       TIter iter(ThisCanvas->GetListOfPrimitives());
01191       TObject *entry = 0;
01192       while((entry= iter()) !=0) {
01193           if(entry->InheritsFrom("TPad")){
01194             TPad* FoundPad=dynamic_cast <TPad *>(entry);
01195             NoOfPads++;
01196             if(FoundPad==RootSelectedPad){
01197               CanvasSelectedPad=FoundPad;
01198             }
01199           }
01200       }
01201       if(NoOfPads==0 && CanvasSelectedPad==0)   CanvasSelectedPad =(TPad *) ThisCanvas;
01202       ActivePad =CanvasSelectedPad;
01203       //return CanvasSelectedPad;
01204     } 
01205     return ActivePad;
01206 }
01207 
01208 TH1 * TGo4PreviewPanel::GetPadHistogram( TPad *Pad)
01209 {
01210    // TGo4LockGuard glob;
01211     if(Pad==0) return 0;
01212     TObject *entry;
01213     TIterator* Padlistiter ;
01214     TH1 *h1=0;
01215     THStack *hs=0;
01216     TGraph *Gr=0;
01217     TMultiGraph* mg=0;
01218     TGo4ASImage* im=0;
01219    TList* primcopy=new TList;
01220    primcopy->AddAll(Pad->GetListOfPrimitives()); // buffer primitive list access
01221    Padlistiter = primcopy->MakeIterator();
01222    while((entry= Padlistiter->Next()) !=0) {
01223        if (entry->InheritsFrom("TH1")){
01224          h1 = dynamic_cast<TH1*> (entry);
01225       }else if(entry->InheritsFrom("THStack")){
01226          hs = dynamic_cast<THStack*> (entry);
01227       }else if(entry->InheritsFrom("TGraph")){
01228          if (dynamic_cast<TCutG*>(entry))
01229                 Gr=0; // suppress getting polycondview volatile cuts
01230            else
01231                 Gr = dynamic_cast<TGraph*> (entry);
01232        }else if(entry->InheritsFrom("TMultiGraph")){
01233          mg = dynamic_cast<TMultiGraph*> (entry);
01234        }
01235 #ifdef __GO4USEASIMAGE__
01236        else if(entry->InheritsFrom("TGo4ASImage")){
01237          im = dynamic_cast<TGo4ASImage*> (entry);
01238        }
01239 #endif   
01240    }
01241    delete Padlistiter;
01242    primcopy->Clear("nodelete");
01243    delete primcopy; 
01244     if(im)
01245         {
01246 #ifdef __GO4USEASIMAGE__
01247             h1=im->GetHistogram();
01248             TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
01249             if(!mw->CheckHistogram(im->GetName(),h1))
01250                 h1=0;// reset image histogram if not existing anymore
01251             else
01252                 im->SetHistogramRanges(dynamic_cast<TH2*>(h1)); // update model from view
01253             //cout <<"GetPadHistogram found histogram of image:"<<h1 << endl;
01254 #endif // __GO4USEASIMAGE__
01255         }
01256    if(h1==0  && hs!=0){
01257       h1=hs->GetHistogram();
01258    }else if(h1==0  && Gr!=0){
01259       h1=Gr->GetHistogram();
01260    }else if(h1==0  && mg!=0){
01261       h1=mg->GetHistogram();
01262    }
01263    return h1;
01264 
01265 }
01266 
01267 
01268 THStack * TGo4PreviewPanel::GetPadTHStack( TPad *Pad )
01269 {
01270    // TGo4LockGuard glob;
01271 if(Pad==0) return 0;
01272     TObject *entry;
01273     TIterator* Padlistiter ;
01274     THStack *hs=0;
01275    TList* primcopy=new TList;
01276    primcopy->AddAll(Pad->GetListOfPrimitives()); // buffer primitive list access
01277    Padlistiter = primcopy->MakeIterator();
01278    while((entry= Padlistiter->Next()) !=0) {
01279       if(entry->InheritsFrom("THStack")){
01280          hs = dynamic_cast<THStack*> (entry);
01281       }
01282    }
01283    delete Padlistiter;
01284    primcopy->Clear("nodelete");
01285    delete primcopy; 
01286    return hs;
01287 }
01288 
01289 TGraph * TGo4PreviewPanel::GetPadTGraph( TPad *Pad )
01290 {
01291    // TGo4LockGuard glob;
01292    if(Pad==0) return 0;
01293    TObject *entry;
01294    TIterator* Padlistiter ;
01295    TGraph *Gr=0;
01296    TList* primcopy=new TList;
01297    primcopy->AddAll(Pad->GetListOfPrimitives()); // buffer primitive list access
01298    Padlistiter = primcopy->MakeIterator();
01299    while((entry= Padlistiter->Next()) !=0) {
01300       if(entry->InheritsFrom("TGraph")){
01301          Gr = dynamic_cast<TGraph*> (entry);
01302       }
01303    }
01304    delete Padlistiter;
01305     primcopy->Clear("nodelete");
01306    delete primcopy; 
01307    return Gr;
01308 }
01309 
01310 TGo4ASImage* TGo4PreviewPanel::GetPadImage( TPad * pad )
01311 {
01312 #ifdef __GO4USEASIMAGE__
01313 if(pad==0) return 0;    
01314 // TGo4LockGuard glob;
01315    TObject *entry;
01316    TIterator* Padlistiter ;
01317    TGo4ASImage* im=0;
01318    TList* primcopy=new TList;
01319    primcopy->AddAll(pad->GetListOfPrimitives()); 
01320    Padlistiter = primcopy->MakeIterator();
01321    while((entry= Padlistiter->Next()) !=0) {
01322       if(entry->InheritsFrom("TGo4ASImage")){
01323          im = dynamic_cast<TGo4ASImage*> (entry);
01324       }
01325    }
01326    delete Padlistiter;
01327    primcopy->Clear("nodelete");
01328    delete primcopy; 
01329    return im;
01330 #else
01331    return 0; // dummy for Qt Slots
01332 #endif    
01333 }
01334 
01335 
01336 void TGo4PreviewPanel::UpdatePad( TPad *Pad, TH1 *h ,bool updateoptions)
01337 {
01338   // TGo4LockGuard glob;
01339   fxTGo4PreviewPanelSlots->UpdatePad(Pad, h, true, updateoptions);
01340   fxTGo4PreviewPanelSlots->RedrawAllLabels(Pad);
01341 }
01342 
01343 void TGo4PreviewPanel::UpdatePad( TPad *Pad, THStack *hs )
01344 {
01345    // TGo4LockGuard glob;
01346   fxTGo4PreviewPanelSlots->UpdatePad(Pad, hs ); 
01347   RedrawStack(hs,Pad); // draw legend, suppress histogram statistics box
01348   
01349 }
01350 
01351 void TGo4PreviewPanel::UpdatePad( TPad * Pad, TMultiGraph * mg )
01352 {
01353   fxTGo4PreviewPanelSlots->UpdatePad(Pad, mg->GetHistogram()); 
01354   RedrawMultiGraph(mg,Pad); // draw legend, suppress histogram statistics box
01355  
01356 }
01357 
01358 void TGo4PreviewPanel::XaxisStyle( int t)
01359 {
01360    // TGo4LockGuard glob;
01365 //    double xmin=0, xmax=0, ymin=0, ymax=0, zmin=0, zmax=0;
01366 //    GetRanges(xmin,xmax,ymin,ymax,zmin,zmax);
01367    TPad* activepad=GetActivePad();
01368 //   if(t>0 && xmin<=0)
01369 //        {
01370 //            double xnewmin=(xmax-xmin)/1000;
01371 //            SetXRange(xnewmin,xmax);
01372 //        }
01373     if(activepad)
01374         {
01375             activepad->SetLogx(t);
01376             activepad->Modified();
01377             activepad->Update();
01378             activepad->Modified();
01379             activepad->Update(); // second update is for label connector
01380         }
01381 }
01382 
01383 void TGo4PreviewPanel::YaxisStyle( int t)
01384 {
01385    // TGo4LockGuard glob;
01390 // if autoscale is not set!
01391 //   double xmin=0, xmax=0, ymin=0, ymax=0, zmin=0, zmax=0;
01392 //    GetRanges(xmin,xmax,ymin,ymax, zmin, zmax);
01393 //   THStack *hs=GetPadTHStack(activepad);
01394 //    double ynewmin=(ymax-ymin)/1000;
01395 //    if(hs && t>0 && hs->GetMinimum()<=0)
01396 //        {
01397 //            hs->SetMinimum(ynewmin);
01398 //            SetYRange(ynewmin,ymax);
01399 //        }
01400 //    else if(t>0 && ymin<=0)
01401 //        {
01402 //            SetYRange(ynewmin,ymax);
01403 //        }
01404 
01405    TPad* activepad = GetActivePad();
01406    
01407    if (activepad==0) return;
01408 
01409    if ((t>0) && !GetAutoScaleOption()) {
01410       TH1* h1 = GetPadHistogram(activepad);
01411       if ((h1!=0) && !h1->InheritsFrom("TH2") && 
01412            !h1->InheritsFrom("TH3")) {
01413          Double_t ymin = h1->GetMinimum();
01414          Double_t ymax = h1->GetMaximum();
01415          if ((ymin==0) && (ymax>0)) {
01416             ymin = 1.; 
01417             if (ymin>0.01*ymax) ymin = 0.01*ymax;
01418             h1->SetMinimum(ymin); 
01419             h1->SetMaximum(ymax); 
01420          }
01421       }
01422    }
01423        
01424    activepad->SetLogy(t);
01425    activepad->Modified();
01426    activepad->Update();
01427    activepad->Modified();
01428    activepad->Update(); // second update is for label connector
01429 }
01430 
01431 void TGo4PreviewPanel::ZaxisStyle( int t)
01432 {
01433    // TGo4LockGuard glob;
01434    TPad *RootSelectedPad=GetActivePad();
01435    TH1* h1=GetPadHistogram(RootSelectedPad);
01436    if(h1!=0){
01437       Int_t first   = h1->GetZaxis()->GetFirst();
01438       Int_t last    = h1->GetZaxis()->GetLast();
01439       if(first > 0 && last > 0)   {
01440          if(RootSelectedPad!=0){
01441             RootSelectedPad->SetLogz(t);
01442             RootSelectedPad->Modified();
01443             RootSelectedPad->Update();
01444          }
01445       }
01446    }
01447 }
01448 
01449 
01450 
01451 
01452 void TGo4PreviewPanel::mouseDoubleClickEvent( QMouseEvent *e )
01453 {
01454     // TGo4LockGuard glob;
01455    if(fxTGo4PreviewPanelStatus->GetNoOfPads()>1){
01456         QPoint Pos;
01457       TObject *object=0;
01458       char SlotName[256];
01459       char PanelName[256];
01460       int i=0;
01461       TPad *pad;
01462       THStack *THS;
01463       TH1 *Th1;
01464       TGo4PreviewPanel *fxPanel;
01465       char buffer[256];
01466       char buffer1[256];
01467       Pos = e->pos();
01468          pad = GetCanvas()->Pick(Pos.x(), Pos.y(), object);
01469         if(dynamic_cast<TCutG*>(GetPadTGraph(pad))) return;
01470             // for polygon condition in pad: doubleclick needed for editor
01471       Th1 =GetPadHistogram(pad);
01472       if(Th1!=0){
01473          do {
01474             snprintf(PanelName,255,"%s %d %s","V ",i++," :");
01475             snprintf(SlotName,255,"%s%s",PanelName,"_Slots");
01476          }while(fxTGo4GUIRegistry->GetSlotClass(SlotName)!=0);
01477 
01478             TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
01479          fxPanel=mw->ViewPanelSlot();
01480          THS = GetPadTHStack(pad);
01481          if (THS==0){
01482             Th1 =GetPadHistogram(pad);
01483             fxPanel->GetCanvas()->cd();
01484             Th1->Draw(fxTGo4PreviewPanelStatus->GetPadStringDrawOption(pad));
01485             fxPanel->UpdatePad((TPad *)(fxPanel->GetCanvas()), Th1 ,true);
01486          }else if(THS!=0){
01487             fxPanel->GetCanvas()->cd();
01488             snprintf(buffer,255,"%s","\"nostack ,");
01489             snprintf(buffer,255,"%s",fxTGo4PreviewPanelStatus->GetPadStringDrawOption(pad));
01490             strcat(buffer, buffer1);
01491             strcat(buffer,"\"");
01492              THS->Draw(buffer);
01493             fxPanel->UpdatePad((TPad *)(fxPanel->GetCanvas()), THS);
01494          }
01495       }
01496    }
01497 }
01498 
01499 TGo4QRootCanvas * TGo4PreviewPanel::GetQCanvas()
01500 {
01501    // TGo4LockGuard glob;
01502     return C;
01503 }
01504 
01505 
01506 
01507 void TGo4PreviewPanel::SetActivePad( TPad *Pad )
01508 {
01509     // TGo4LockGuard glob;
01510     if ((ActivePad != Pad) && (Pad!=0)) {
01511        ActivePad = Pad;
01512        ActivePad->cd();
01513        DisplayPadStatus(ActivePad);
01514        fxTGo4WorkSpace->ActivePadChanged(this, ActivePad);
01515     }
01516 }
01517 
01518 void TGo4PreviewPanel::DropToPadAction(TPad *Pad)
01519 {
01520    fxTGo4WorkSpace->ActivePadChanged(this,Pad);
01521     fxTGo4PreviewPanelSlots->RedrawAllLabels(Pad);
01522 }
01523 
01524 void TGo4PreviewPanel::Draw( TObject *, TPad *) //Obj, Pad
01525 {
01526    // TGo4LockGuard glob;
01527    //C->DrawHist((TH1 *) (Obj), Pad);
01528 }
01529 
01530 void TGo4PreviewPanel::ResizeAll()
01531 {
01532     // TGo4LockGuard glob;
01533 TPad *RootSelectedPad=GetActivePad();
01534 if(RootSelectedPad!=0)
01535     {
01536     TH1* h1=GetPadHistogram(RootSelectedPad);
01537     if (h1)
01538         {
01539         h1->GetXaxis()->UnZoom();
01540         h1->GetYaxis()->UnZoom();
01541         #ifdef __GO4USEASIMAGE__
01542         TGo4ASImage* im=GetPadImage(RootSelectedPad);
01543         if(im) im->SetZoom(dynamic_cast<TH2*>(h1));
01544         #endif
01545         }
01546     RootSelectedPad->Modified();
01547     RootSelectedPad->PaintModified();
01548     RootSelectedPad->Update();
01549     }
01550 }
01551 
01552 
01553 
01554 
01555 int  TGo4PreviewPanel::GetNoOfPads()
01556 {
01557     return fxTGo4PreviewPanelStatus->GetNoOfPads();    
01558 }
01559 
01560 
01561 
01562 bool TGo4PreviewPanel::ApplyToAllPads()
01563 {
01564    // TGo4LockGuard glob;
01565     return ApplyToAllflag;
01566 }
01567 
01568 TCutG * TGo4PreviewPanel::GetTCutG()
01569 {
01570     // TGo4LockGuard glob;
01571     TObject *entry=0;
01572     TIterator* Padlistiter=0 ;
01573     TCutG *CG=0;
01574     TPad *Pad=GetActivePad();
01575     TList *ListOfPadPrimatives = Pad->GetListOfPrimitives();
01576     Padlistiter = ListOfPadPrimatives->MakeIterator();
01577    while((entry= Padlistiter->Next()) !=0) {
01578       if(entry->InheritsFrom("TCutG")){
01579          CG = dynamic_cast<TCutG *> (entry);
01580       }
01581    }
01582    delete Padlistiter;
01583    return CG;
01584 }
01585 void TGo4PreviewPanel::SendToBrowser()
01586 {
01587    TGo4BrowserSlots *fxBrowser   = (TGo4BrowserSlots *) fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots");
01588    gROOT->SetBatch(true); // prevent popup of buffer canvas
01589    TCanvas *fxC=new TCanvas(); 
01590    C->InsertCanvas(C->GetCanvas(), fxC, false); 
01591     //better than Clone, because of UID handling; do not create draw options in mother viewpanel!
01592    fxC->SetName(caption().data());
01593    //fxTGo4PreviewPanelStatus->RefreshListOfPads(); // after saving canvas rebuild pad refarray with new object ids
01594    TGo4CanvasWrapper* cwrap=new TGo4CanvasWrapper(fxC); // canvas is not TNamed, we have to wrap it!
01595    fxBrowser->AddLocalObject(cwrap);
01596    //cwrap->SetCanvas(0);// change ownership of canvas back to us
01597    delete cwrap;
01598    gROOT->SetBatch(false);
01599 
01600 }
01601 
01602 
01603 void TGo4PreviewPanel::InsertCanvas(TCanvas *fxCanvas)
01604 {
01605    C->InsertCanvas(fxCanvas, GetActivePad());
01606 }
01607 
01608 void TGo4PreviewPanel::SetXRange( double Xmin, double Xmax)
01609 {
01610     TPad *RootSelectedPad=GetActivePad();
01611    TH1* h1=GetPadHistogram(RootSelectedPad);
01612    if(h1!=0){
01613       h1->GetXaxis()->SetRangeUser(Xmin,Xmax);
01614       RootSelectedPad->Modified();
01615       RootSelectedPad->PaintModified();
01616       RootSelectedPad->Update();
01617       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
01618       if(fxTGo4PadOptions)
01619         fxTGo4PadOptions->SetUxRange(Xmin,Xmax);
01620 
01621    }
01622 }
01623 
01624 void TGo4PreviewPanel::SetYRange( double Ymin, double Ymax)
01625 {
01626     TPad *RootSelectedPad=GetActivePad();
01627     //TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
01628     //bool autoscale=fxTGo4PadOptions->GetAutoScale();
01629    TH1* h1=GetPadHistogram(RootSelectedPad);
01630    if(h1!=0){
01631         if(!h1->InheritsFrom("TH2") && !h1->InheritsFrom("TH3"))
01632              {
01633                 // 1d histograms: range for autoscale defined by Minimum
01634                          h1->SetMinimum(Ymin);
01635                          h1->SetMaximum(Ymax);
01636              }
01637         h1->GetYaxis()->SetRangeUser(Ymin,Ymax);
01638       RootSelectedPad->Modified();
01639       RootSelectedPad->PaintModified();
01640       RootSelectedPad->Update();
01641       TGo4PadOptions *fxTGo4PadOptions=fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
01642       if(fxTGo4PadOptions)
01643         fxTGo4PadOptions->SetUyRange(Ymin,Ymax);
01644 
01645    }
01646 }
01647 
01648 void TGo4PreviewPanel::SetAutoScaleOption( bool AutoScale)
01649 {
01650 TPad *activepad=GetActivePad();
01651 if(!ApplyToAllPads())
01652     {
01653         TGo4PadOptions *padoptions=fxTGo4PreviewPanelStatus->GetPadOptions(activepad);
01654         if(padoptions)
01655             padoptions->SetAutoScale(AutoScale);
01656         if(AutoScale)
01657             {
01658             // unzoom y in case of 1d histograms::
01659             TH1* padhis=GetPadHistogram(activepad);
01660             if(padhis && !padhis->InheritsFrom("TH2") && !padhis->InheritsFrom("TH3"))
01661                 {
01662                    padhis->SetMinimum();
01663                    padhis->SetMaximum();
01664                 }
01665             activepad->Modified();
01666             activepad->Update();
01667             }
01668     }
01669 else
01670     {
01671         TObject *entry=0;
01672 //       TList *ListOfPads = new TList;
01673 //       ListOfPads->SetOwner(kFALSE);
01674 //       ListOfPads->AddAll(GetListOfPads());
01675 //       TIter Padlistiter(ListOfPads);
01676        TRefArray *ListOfPads = new TRefArray;
01677        ListOfPads->AddAll(GetListOfPads());
01678        TIter Padlistiter(ListOfPads);
01679         while((entry= Padlistiter.Next()) !=0)
01680             {
01681                 TPad *pad=dynamic_cast <TPad *>(entry);
01682                 TGo4PadOptions *padoptions=fxTGo4PreviewPanelStatus->GetPadOptions(pad);
01683                 if(padoptions)
01684                     padoptions->SetAutoScale(AutoScale);
01685                 if(AutoScale)
01686                     {
01687                     // unzoom y in case of 1d histograms::
01688                     TH1* padhis=GetPadHistogram(pad);
01689                     if(padhis && !padhis->InheritsFrom("TH2") && !padhis->InheritsFrom("TH3"))
01690                         {
01691                            padhis->SetMinimum();
01692                            padhis->SetMaximum();
01693                         }
01694                     pad->Modified();
01695                     pad->Update();
01696                     }
01697             }
01698         SetActivePad(activepad);
01699         GetCanvas()->Update();
01700         ListOfPads->Clear("nodelete");
01701         delete ListOfPads;
01702     }
01703 }
01704 
01705 bool TGo4PreviewPanel::GetPadRanges(TPad *pad,  double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax) {
01706 // for the moment we take range from pad/histogram
01707 // later rely on padoptions only?
01708    bool changed = false;
01709 
01710    TH1* h1 = GetPadHistogram(pad);
01711    if(h1) {
01712       TAxis* xax = h1->GetXaxis();
01713       TAxis* yax = h1->GetYaxis();
01714       TAxis* zax = h1->GetZaxis();
01715       if(h1->InheritsFrom("TH3"))
01716           {
01717            xmin = xax->GetBinLowEdge(xax->GetFirst());
01718            xmax = xax->GetBinUpEdge(xax->GetLast());
01719            ymin = yax->GetBinLowEdge(yax->GetFirst());
01720            ymax = yax->GetBinUpEdge(yax->GetLast());
01721            zmin = zax->GetBinLowEdge(zax->GetFirst());
01722            zmax = zax->GetBinUpEdge(zax->GetLast());
01723            changed = (xax->GetFirst() > 1) || (xax->GetLast() < xax->GetNbins()) ||
01724                    (yax->GetFirst() > 1) || (yax->GetLast() < yax->GetNbins()) ||
01725                    (zax->GetFirst() > 1) || (zax->GetLast() < zax->GetNbins()) ;
01726 
01727           }
01728       else if (h1->InheritsFrom("TH2"))
01729           {
01730              xmin = xax->GetBinLowEdge(xax->GetFirst());
01731              xmax = xax->GetBinUpEdge(xax->GetLast());
01732              ymin = yax->GetBinLowEdge(yax->GetFirst());
01733              ymax = yax->GetBinUpEdge(yax->GetLast());
01734              zmin = h1->GetMinimum();
01735              zmax = h1->GetMaximum();
01736          changed = (xax->GetFirst() > 1) || (xax->GetLast() < xax->GetNbins()) ||
01737                    (yax->GetFirst() > 1) || (yax->GetLast() < yax->GetNbins());
01738 
01739       } else
01740       if(h1->InheritsFrom("TH1")) {
01741          xmin = xax->GetBinLowEdge(xax->GetFirst());
01742          xmax = xax->GetBinUpEdge(xax->GetLast());
01743             //xmin=pad->GetUxmin();
01744             //xmax=pad->GetUxmax();
01745          ymin = h1->GetMinimum();
01746          ymax = h1->GetMaximum();
01747          changed = (xax->GetFirst() > 1) || (xax->GetLast() < xax->GetNbins());
01748        }
01749     } else {
01750        // no histogram there: use padoption ranges
01751        TGo4PadOptions *padoptions = fxTGo4PreviewPanelStatus->GetPadOptions(pad);
01752        if(padoptions)
01753            {
01754                padoptions->GetUxRange(xmin,xmax);
01755                padoptions->GetUyRange(ymin,ymax);
01756                padoptions->GetUzRange(zmin,zmax);
01757            }
01758    }
01759    return changed;
01760 }
01761 
01762 void TGo4PreviewPanel::GetRanges( double &xmin, double &xmax, double &ymin, double &ymax , double &zmin, double &zmax) {
01763 // access to ranges of the active pad:
01764    GetPadRanges(GetActivePad(), xmin, xmax, ymin, ymax, zmin, zmax);
01765 }
01766 
01767 
01768 void TGo4PreviewPanel::SetScaleRange( double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, bool autoscale) {
01769    TPad *activepad=GetActivePad();
01770    if(!ApplyToAllPads()) {  // single pad
01771       SetPadScaleRange(activepad,xmin,xmax,ymin,ymax,zmin, zmax, autoscale);
01772    } else {
01773       
01774       QApplication::setOverrideCursor( Qt::WaitCursor );
01775       TObject* entry=0;
01776       TRefArray *ListOfPads = new TRefArray;
01777        ListOfPads->AddAll(GetListOfPads());
01778        TIter Padlistiter(ListOfPads);
01779       while((entry= Padlistiter.Next()) !=0) {
01780          TPad *pad=dynamic_cast <TPad *>(entry);
01781          SetPadScaleRange(pad,xmin,xmax,ymin,ymax,zmin,zmax,autoscale);
01782       }// while
01783       ListOfPads->Clear("nodelete");
01784       delete ListOfPads;
01785       SetActivePad(activepad);
01786       GetCanvas()->Update();
01787       QApplication::restoreOverrideCursor();
01788    } // if(!fxTGo4PreviewPanel->ApplyToAllPads())
01789 fxTGo4WorkSpace->ActivePadChanged(this, activepad);
01790 }
01791 
01792 
01793 void TGo4PreviewPanel::SetPadScaleRange( TPad * pad, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, bool autoscale) {
01794    TGo4PadOptions *padoptions = fxTGo4PreviewPanelStatus->GetPadOptions(pad);
01795    if(padoptions)
01796     {
01797        padoptions->SetAutoScale(autoscale);
01798        padoptions->SetUxRange(xmin,xmax);
01799        padoptions->SetUyRange(ymin,ymax);
01800        padoptions->SetUzRange(zmin,zmax);
01801     }
01802    TH1* h1=GetPadHistogram(pad);
01803    if(h1) {
01804       h1->GetXaxis()->SetRangeUser(xmin,xmax);
01805       h1->GetYaxis()->SetRangeUser(ymin,ymax);
01806       h1->GetZaxis()->SetRangeUser(zmin,zmax);
01807       Int_t dimension=h1->GetDimension();
01808       //if(!h1->InheritsFrom("TH2") && !h1->InheritsFrom("TH3")) {
01809       if(!autoscale)
01810           {
01811             if(dimension==1)
01812                 {
01813                     h1->SetMinimum(ymin);
01814                     h1->SetMaximum(ymax);
01815                 }
01816             else if(dimension==2)
01817                 {
01818                     h1->SetMinimum(zmin);
01819                     h1->SetMaximum(zmax);
01820                 }
01821             else
01822                 {
01823                     h1->SetMinimum();
01824                     h1->SetMaximum();
01825                 }
01826           }
01827       else
01828           {
01829             h1->SetMinimum();
01830             h1->SetMaximum();
01831           }
01832       //}
01833 #ifdef __GO4USEASIMAGE__
01834       TGo4ASImage* im=GetPadImage(pad);
01835       if(im) im->SetZoom(dynamic_cast<TH2*>(h1));
01836 #endif
01837       pad->Modified();
01838       pad->PaintModified();
01839       pad->Update();
01840    }
01841 }
01842 
01843 bool TGo4PreviewPanel::GetAutoScaleOption()
01844 {
01845     TPad *RootSelectedPad = GetActivePad();
01846     TGo4PadOptions *fxTGo4PadOptions = fxTGo4PreviewPanelStatus->GetPadOptions(RootSelectedPad);
01847     if(fxTGo4PadOptions)
01848         return (fxTGo4PadOptions->GetAutoScale());
01849     else
01850         return true;
01851 }
01852 
01853 
01854 void TGo4PreviewPanel::SetZRange(double  , double ) //Zmin, Zmax
01855 {
01856 
01857 }
01858 
01859 double TGo4PreviewPanel::GetXmin()
01860 {
01861 return 0;
01862 }
01863 
01864 double TGo4PreviewPanel::GetXmax()
01865 {
01866 return 0;
01867 }
01868 
01869 double TGo4PreviewPanel::GetYmin()
01870 {
01871 return 0;
01872 }
01873 
01874 double TGo4PreviewPanel::GetYmax()
01875 {
01876 return 0;
01877 }
01878 
01879 
01880 double TGo4PreviewPanel::GetZmin()
01881 {
01882 return 0;
01883 }
01884 
01885 double TGo4PreviewPanel::GetZmax()
01886 {
01887 return 0;
01888 }
01889 
01890 
01891 TRefArray *  TGo4PreviewPanel::GetListOfPads()
01892 {
01893    return fxTGo4PreviewPanelStatus->GetListOfPads();
01894 }
01895 
01896 
01897 
01898 void TGo4PreviewPanel::StartConditionEditor()
01899 {
01900     TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
01901     mw->ConditionEditSlot(0,this);
01902 }
01903 
01904 
01905 void TGo4PreviewPanel::enterEvent( QEvent * e )
01906 {
01908     if(fbEditorFrameVisible
01909          && fxTGo4WorkSpace->GetLastActiveViewPanel()==this)
01910         {
01911              bool isimage=false;
01912              const char* drawopt = fxTGo4PreviewPanelStatus->GetPadStringDrawOption(ActivePad);
01913              if ((drawopt!=0) && (strstr(drawopt,"asimage")))
01914                 isimage=true; // if we have asimage before, root editor can not change that style
01915                               // supress overriding the padoption drawstyle then  
01916              TH1* his = GetPadHistogram(ActivePad);
01917              fxTGo4PreviewPanelSlots->UpdatePad(ActivePad,his,true,!isimage);
01918              bool crosshair = ActivePad->HasCrosshair();
01919              fxTGo4PreviewPanelStatus->SetPadCrosshair(ActivePad,crosshair);                
01920              fxTGo4WorkSpace->ActivePadChanged(this, ActivePad);
01921         }
01923     EnablePolymarker(fxTGo4PreviewPanelStatus->GetNoOfPads()==1);
01925     //fxTGo4PreviewPanelStatus->CleanupPadLists(GetCanvas()); // test
01926     QWidget::enterEvent(e);
01927 }
01928 
01929 void TGo4PreviewPanel::leaveEvent( QEvent * e )
01930 {
01931     #if __GO4ROOTVERSION__ < 40301   
01932     fxTGo4PreviewPanelSlots->CleanupPadEditor(); //avoid confusion of root TGedEditor cache between different viewpanels
01933     #endif
01934     QWidget::leaveEvent(e);
01935 }
01936 
01937 void TGo4PreviewPanel::resizeEvent( QResizeEvent * e )
01938 {
01939 //cout <<"Resize event previewpanel " << endl;
01940    TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
01941    mw->RememberViewpanelSize(this);
01942    QWidget::resizeEvent(e);
01943 }
01944 
01945 void TGo4PreviewPanel::DisplayPadStatus( TPad * pad )
01946 {
01947    QString output=pad->GetName();
01948    output.append(": ");
01949    TGo4PadOptions *fxOptions= fxTGo4PreviewPanelStatus->GetPadOptions(pad);
01950    if(fxOptions!=0) {
01951        bool superImpose = fxOptions->DragAddOption();
01952        if (superImpose) output.append(" SuperImpose:");
01953        if (ApplyToAllPads())output.append(" All Pads:");
01954    }
01955    output.append(" Ready");
01956    CanvasStatus->message(output);
01957 }
01958 
01959 
01960 void TGo4PreviewPanel::SetCrosshairDefault( bool on )
01961 {
01962     fbCrosshairDefault=on;
01963 }
01964 
01965 void TGo4PreviewPanel::SetPadFillColor( int num )
01966 {
01967     fiPadFillColor=num;
01968 }
01969 
01970 TGo4PreviewPanelStatus* TGo4PreviewPanel::GetStatus() {
01971    return fxTGo4PreviewPanelStatus;
01972 }
01973 
01974 TGo4PreviewPanelSlots* TGo4PreviewPanel::GetSlots() {
01975    return fxTGo4PreviewPanelSlots;
01976 }
01977 
01978 
01979 void TGo4PreviewPanel::ClickOnPad( TPad * pad )
01980 {
01981     SetActivePad(pad);// for user convenience, left button or mid button will change focus
01982     if(fbNeedsMemSync)
01983     {
01984         // case after root right mouse menu has been invoked
01986         TGo4BrowserSlots *fxBrowser   = (TGo4BrowserSlots *) fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots");
01987         if(fxBrowser) fxBrowser->SynchronizeWithMemory();
01988         fbNeedsMemSync=false;
01990         fxTGo4PreviewPanelStatus->UpdateSubPads(GetCanvas());    
01991         //fxTGo4PreviewPanelStatus->CleanupPadLists(GetCanvas()); //   
01992         EnablePolymarker(fxTGo4PreviewPanelStatus->GetNoOfPads()==1);
01993     }
01994     fxTGo4PreviewPanelSlots->MouseClick(pad);
01995     
01996     fxTGo4WorkSpace->PadClicked(this,pad);
01997 }
01998 
01999 
02000 void TGo4PreviewPanel::SetCursorMode( bool on )
02001 {
02002 if(!fbTypingMode) return;
02003 if(on)
02004         fxTGo4PreviewPanelSlots->SetMouseMode(kMousePickCursor);
02005 else
02006         fxTGo4PreviewPanelSlots->SetMouseMode(kMouseROOT);
02007 RefreshButtons();
02008 }
02009 
02010 
02011 void TGo4PreviewPanel::SetRegionMode( bool on )
02012 {
02013 if(!fbTypingMode) return;
02014 if(on)
02015     {
02016         fxTGo4PreviewPanelSlots->SetMouseMode(kMousePickLimits);
02017         fxTGo4PreviewPanelSlots->ResetPickCounter();
02018     }
02019 else
02020     {
02021         fxTGo4PreviewPanelSlots->SetMouseMode(kMouseROOT);
02022     }
02023 RefreshButtons();
02024 }
02025 
02026 void TGo4PreviewPanel::SetPolygonMode( bool on )
02027 {
02028 if(!fbTypingMode) return;
02029 if(on)
02030     {    
02031         fxTGo4PreviewPanelSlots->SetMouseMode(kMousePickPolygon);
02032         fxTGo4PreviewPanelSlots->ResetPickCounter();
02033     }
02034 else
02035     {
02036         fxTGo4PreviewPanelSlots->SetMouseMode(kMouseROOT);
02037     }
02038 RefreshButtons();
02039 }
02040 
02041 void TGo4PreviewPanel::SetLateXMode( bool on )
02042 {
02043 if(!fbTypingMode) return;
02044 if(on)
02045     fxTGo4PreviewPanelSlots->SetMouseMode(kMousePickLatex);
02046 else
02047     fxTGo4PreviewPanelSlots->SetMouseMode(kMouseROOT);
02048 RefreshButtons();
02049 }
02050 
02051 
02052 void TGo4PreviewPanel::SetDrawingMode( bool on )
02053 {
02054 if(!fbTypingMode) return;
02055 if(on)
02056     fxTGo4PreviewPanelSlots->SetMouseMode(kMouseDraw);
02057 else
02058     fxTGo4PreviewPanelSlots->SetMouseMode(kMouseROOT);
02059 RefreshButtons();
02060 }
02061 
02062 
02063 
02064 void TGo4PreviewPanel::SetFreezeMouseMode( bool on )
02065 {
02066 if(!fbTypingMode) return;
02067 fxTGo4PreviewPanelSlots->SetPickAgain(on);
02068 if(on)
02069     {
02070         // set default mode if no go4 mousemode selected:
02071         if(fxTGo4PreviewPanelSlots->GetMouseMode()==kMouseROOT)
02072             fxTGo4PreviewPanelSlots->SetMouseMode(kMousePickCursor);
02073     }
02074 else
02075     {
02076         fxTGo4PreviewPanelSlots->SetMouseMode(kMouseROOT);
02077     }
02078 RefreshButtons();
02079 }
02080 
02081 
02082 void TGo4PreviewPanel::SetNewMarkerMode( bool on )
02083 {
02084 if(!fbTypingMode) return;
02085 fxTGo4PreviewPanelSlots->SetCreateNewMarker(on);
02086 RefreshButtons();
02087 }
02088 
02089 
02090 void TGo4PreviewPanel::RefreshButtons()
02091 {
02092 MarkerPanel->setShown(fbMarkEditorVisible);
02093 if(!fbMarkEditorVisible) return;
02094 fbTypingMode=false;
02095 PolyB->setDisabled(fxTGo4PreviewPanelStatus->GetNoOfPads()>1);
02096 QString activename;
02097 bool createnewmarker=fxTGo4PreviewPanelSlots->IsCreateNewMarker();
02098 switch(fxTGo4PreviewPanelSlots->GetMouseMode())
02099     {
02100     case kMouseROOT:
02101         CursorB->setOn(false);
02102         RegionB->setOn(false);
02103         LatexB->setOn(false);
02104         DrawB->setOn(false);
02105         PolyB->setOn(false);
02106         activename="ROOT Mouse";
02107         break;
02108 
02109     case kMousePickCursor:
02110         CursorB->setOn(true);
02111         RegionB->setOn(false);
02112         LatexB->setOn(false);
02113         DrawB->setOn(false);
02114         PolyB->setOn(false);
02115         if(createnewmarker)
02116            activename="new marker";
02117         else
02118            activename=fxTGo4PreviewPanelSlots->GetActiveMarkerName(GetActivePad());
02119         break;
02120 
02121     case kMousePickLimits:
02122         CursorB->setOn(false);
02123         RegionB->setOn(true);
02124         LatexB->setOn(false);
02125         DrawB->setOn(false);
02126         PolyB->setOn(false);
02127         if(createnewmarker)
02128             activename="new window";
02129         else
02130             activename=fxTGo4PreviewPanelSlots->GetActiveRegionName(GetActivePad());
02131         break;
02132 
02133     case kMousePickPolygon:
02134         CursorB->setOn(false);
02135         RegionB->setOn(false);
02136         LatexB->setOn(false);
02137         DrawB->setOn(false);
02138         PolyB->setOn(true);
02139         if(createnewmarker)
02140             activename="new polygon";
02141         else
02142             activename=fxTGo4PreviewPanelSlots->GetActivePolygonName(GetActivePad());
02143         break;
02144 
02145 
02146     case kMousePickLatex:
02147         CursorB->setOn(false);
02148         RegionB->setOn(false);
02149         LatexB->setOn(true);
02150         DrawB->setOn(false);
02151         PolyB->setOn(false);
02152         if(createnewmarker)
02153            activename="new latex";
02154         else
02155             activename=fxTGo4PreviewPanelSlots->GetActiveLatexName(GetActivePad());
02156         break;
02157 
02158     case kMouseDraw:
02159         // currently, we only draw arrows:
02160         CursorB->setOn(false);
02161         RegionB->setOn(false);
02162         LatexB->setOn(false);
02163         DrawB->setOn(true);
02164         PolyB->setOn(false);
02165         activename="draw arrow";
02166         break;
02167 
02168     case kMouseSelectObject:
02169         // this is the case directly after rootmouse selected one of our objects
02170         activename="selected: ";
02171         activename.append(fxTGo4PreviewPanelSlots->GetSelectedName());
02172         fxTGo4PreviewPanelSlots->SetMouseMode(kMouseROOT);
02173         break;
02174 
02175     case kMouseConditionEditor:
02176         CursorB->setOn(false);
02177         RegionB->setOn(false);
02178         LatexB->setOn(false);
02179         DrawB->setOn(false);
02180         PolyB->setOn(false);
02181         activename="Condition editor";
02182         break;
02183 
02184     default:
02185         CursorB->setOn(false);
02186         RegionB->setOn(false);
02187         LatexB->setOn(false);
02188         DrawB->setOn(false);
02189         PolyB->setOn(false);
02190         activename="no mousemode!";
02191         break;
02192 
02193     }; // switch()
02194 ActiveLabel->setText(activename);
02195 FreezeMode->setChecked(fxTGo4PreviewPanelSlots->IsPickAgain());
02196 NewMarkerMode->setChecked(createnewmarker);
02197 polish();
02198 update();
02199 show();
02200 fbTypingMode=true;
02201 }
02202 
02203 
02204 void TGo4PreviewPanel::SetMarkerPanel()
02205 {
02206 fbMarkEditorVisible= !EditMenu->isItemChecked(ShowMarkEditorId);
02207 EditMenu->setItemChecked(ShowMarkEditorId, fbMarkEditorVisible);
02208 if(!fbMarkEditorVisible)
02209     { 
02210          // switch back to normal root mouse when editor is hidden
02211         fxTGo4PreviewPanelSlots->SetMouseMode(kMouseROOT);
02212         gROOT->SetEditorMode("");
02213         fxTGo4PreviewPanelSlots->ResetPickCounter();
02214     }
02215 RefreshButtons();
02216 }
02217  
02218 
02219 
02220 
02221 void TGo4PreviewPanel::LogMarkerValues()
02222 {
02223 fxTGo4PreviewPanelSlots->ScanMarkers(GetActivePad());
02224 fxTGo4PreviewPanelSlots->LogMarkers("go4log");
02225 }
02226 
02227 
02228 void TGo4PreviewPanel::ClearAllMarkers()
02229 {
02230 TPad* activepad=GetActivePad();
02231 if(!ApplyToAllPads()) 
02232     {
02233       fxTGo4PreviewPanelSlots->ClearAllLabels(activepad);
02234       activepad->Modified();
02235       activepad->Update();
02236     } 
02237 else 
02238     {
02239       TObject *entry=0;
02240 //      TList *ListOfPads = new TList;
02241 //      ListOfPads->SetOwner(kFALSE);
02242 //      ListOfPads->AddAll(GetListOfPads());
02243 //      TIter Padlistiter(ListOfPads);
02244       TRefArray *ListOfPads = new TRefArray;
02245        ListOfPads->AddAll(GetListOfPads());
02246        TIter Padlistiter(ListOfPads);      
02247       while((entry= Padlistiter.Next()) !=0) {
02248          TPad *pad=dynamic_cast <TPad *>(entry);         
02249          pad->cd(); // needed for UnDraw of conditions...
02250          fxTGo4PreviewPanelSlots->ClearAllLabels(pad);
02251          pad->Modified();
02252          pad->Update();
02253       }
02254       activepad->cd();
02255       ListOfPads->Clear("nodelete");
02256       delete ListOfPads;
02257    }
02258 }
02259 
02260 
02261 void TGo4PreviewPanel::SaveMarkers()
02262 {
02263     QFileDialog* fd = new QFileDialog( this, "Save Markers", TRUE );
02264     fd->setCaption("Save Markers of active pad into ");
02265     fd->setMode( QFileDialog::AnyFile);
02266     fd->setName( "Save to file: ");
02267     fd->setFilter( "ROOT file (*.root)");
02268     if ( fd->exec() == QDialog::Accepted ) {
02269        QString filename = fd->selectedFile();
02270        if (!filename.endsWith(".root")) filename.append(".root");
02271        fxTGo4PreviewPanelSlots->SaveMarkerSetup(filename,"Markersetup");
02272     }
02273     delete fd;
02274 }
02275 
02276 void TGo4PreviewPanel::LoadMarkers()
02277 {
02278     QFileDialog* fd = new QFileDialog( this, "Load Markers", TRUE );
02279     fd->setCaption("Load Marker setup from:");
02280     fd->setMode( QFileDialog::ExistingFile );
02281     fd->setName( "Load from file: ");
02282     fd->setFilter( "ROOT file (*.root)");
02283     if ( fd->exec() == QDialog::Accepted ) {
02284         QString filename = fd->selectedFile();
02285         fxTGo4PreviewPanelSlots->LoadMarkerSetup(filename,"Markersetup");
02286     }
02287     delete fd;
02288 }
02289 
02290 
02291 void TGo4PreviewPanel::SyncRootMemory()
02292 {
02293 fbNeedsMemSync=true;
02294 }
02295 
02296 
02297 void TGo4PreviewPanel::SetViewpanelTitle()
02298 {
02299 bool ok=false;
02300 QString mycaption=caption();
02301 QString oldtitle=mycaption.remove(name());
02302 QString text = QInputDialog::getText(
02303             name(), "Enter Viewpanel Title:", QLineEdit::Normal,
02304             oldtitle, &ok, this );
02305 if ( ok && !text.isEmpty() )
02306     {
02307     // user entered something and pressed OK
02308        mycaption=name();
02309        mycaption.append(text);
02310        setCaption(mycaption);
02311        fbFreezeTitle=kTRUE; // automatic freeze when user sets title
02312        OptionsMenu->setItemChecked(FreezeTitleId,fbFreezeTitle);
02313     }
02314 else
02315     {
02316         // user entered nothing or pressed Cancel
02317     }
02318 }
02319 
02320 
02321 bool TGo4PreviewPanel::IsFreezeTitle()
02322 {
02323 return fbFreezeTitle;
02324 }
02325 
02326 
02327 void TGo4PreviewPanel::SetFreezeTitle()
02328 {
02329 fbFreezeTitle = !OptionsMenu->isItemChecked(FreezeTitleId);
02330 OptionsMenu->setItemChecked(FreezeTitleId,fbFreezeTitle);
02331 }
02332 
02333 
02334 void TGo4PreviewPanel::UpdateMarkersHistogram()
02335 {
02336 // called by TGo4QItem before updating the pad (e.g. monitoring mode)
02337 //fxTGo4PreviewPanelSlots->SetMarkersHistogram();
02338 //fxTGo4PreviewPanelSlots->SetRegionsHistogram();
02339 fxTGo4PreviewPanelSlots->SetPolygonsHistogram();
02340 }
02341 
02342 
02343 void TGo4PreviewPanel::EnablePolymarker( bool on )
02344 {
02345 PolyB->setDisabled(!on); 
02346 if( !on && fxTGo4PreviewPanelSlots->GetMouseMode()==kMousePickPolygon)
02347     fxTGo4PreviewPanelSlots->SetMouseMode(kMouseROOT); // prevent polygon edit in subpads
02348  
02349 }
02350 
02351 //----------------------------END OF GO4 SOURCE FILE ---------------------

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