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

/Go4QtBaseWidgets/TGo4QPicItem.cpp

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 "TGo4QPicItem.h"
00017 
00018 #include "TROOT.h"
00019 #include "TPad.h"
00020 #include "TCanvas.h"
00021 #include "TText.h"
00022 #include "TDatime.h"
00023 
00024 #include "Go4CommandsAnalysis/TGo4ComGetPicture.h"
00025 #include "Go4CommandsAnalysis/TGo4ComGetObject.h"
00026 #include "Go4StatusBase/TGo4Picture.h"
00027 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00028 #include "Go4GUI/TGo4PadOptions.h"
00029 #include "Go4GUI/TGo4PreviewPanel.h"
00030 #include "Go4GUI/TGo4QRootCanvas.h"
00031 #include "Go4GUI/TGo4MonitoredListSlots.h"
00032 #include "Go4ConditionsBase/TGo4Condition.h"
00033 
00034 TGo4QPicItem::TGo4QPicItem( QListViewItem* parent, const QString & text, const QString & text1,  const QString & text2)
00035    :TGo4QTHItem (parent, "picture.png", text, text1, text2)
00036 {
00037 }
00038 
00039 TGo4QPicItem::TGo4QPicItem( QListView* parent, const QString & text, const QString & text1,  const QString & text2)
00040    :TGo4QTHItem (parent, "picture.png", text, text1, text2)
00041 {
00042 }
00043 
00044 TGo4QPicItem::~TGo4QPicItem(){}
00045 
00046 void TGo4QPicItem::ItemDBkRemote()
00047 {
00048    GetRemoteObj();
00049 }
00050 
00051 void TGo4QPicItem::DrawSubPic(TGo4PreviewPanel *panel, TPad* pad, TGo4Picture* pic) {
00052    if ((panel==0) || (pad==0) || (pic==0)) return;
00053    if (pic->IsDivided()) {
00054       panel->SetActivePad(pad);
00055       panel->Divide(pic->GetDivX(), pic->GetDivY());
00056       for(Int_t posy=0; posy<pic->GetDivY(); posy++)
00057          for(Int_t posx=0; posx<pic->GetDivX(); posx++) {
00058            TGo4Picture* sub = pic->FindPic(posy,posx);
00059            if (sub) DrawSubPic(panel,  (TPad*) pad->GetPad(posy*pic->GetDivX() + posx + 1), sub);
00060        }
00061    } else {
00062      TGo4PadOptions *padopt = panel->GetPadOptions(pad);
00063      if (padopt!=0) {
00064 //        Option_t* drawopt = pic->GetDrawOption();
00065 //        if (drawopt!=0) padopt->setHisDrawStyle(drawopt);
00066 
00067         Int_t hds = pic->GetHistDrawStyle();
00068         if (hds>=0) padopt->SetHisDrawStyle(hds);
00069 
00070         Int_t hes = pic->GetHistErrorStyle();
00071         if (hes>=0) padopt->SetHisErrorStyle(hes);
00072 
00073         Int_t hcs = pic->GetHistCoordStyle();
00074         if (hcs>=0) padopt->SetHisCoordStyle(hcs);
00075 
00076         padopt->SetHisXStyle(pic->GetLogScale(0));
00077         padopt->SetHisYStyle(pic->GetLogScale(1));
00078         padopt->SetHisZStyle(pic->GetLogScale(2));
00079 
00080         Double_t min,max;
00081         if (pic->GetRangeX(min,max)) padopt->SetUxRange(min,max);
00082         if (pic->GetRangeY(min,max)) padopt->SetUyRange(min,max);
00083      }
00084 
00085      pic->GetLineAtt(dynamic_cast<TAttLine*> (pad), TGo4Picture::PictureIndex);
00086      pic->GetFillAtt(dynamic_cast<TAttFill*> (pad), TGo4Picture::PictureIndex);
00087      pic->GetMarkerAtt(dynamic_cast<TAttMarker*> (pad), TGo4Picture::PictureIndex);
00088 
00089      for (Int_t n=0; n<pic->GetNumObjNames(); n++) {
00090 
00091         Option_t* drawopt = pic->GetDrawOption(n);
00092         if ((drawopt!=0) && (padopt!=0))
00093            padopt->setHisDrawStyle(drawopt);
00094 
00095         const char* objname = pic->GetObjName(n);
00096 
00097         TObject* obj = pic->FindObject(objname);
00098 
00099         if ((obj!=0) && obj->InheritsFrom(TGo4Condition::Class())) continue;
00100 
00101         bool isany = false;
00102 
00103         if (InFileBrowser() || InMemoryBrowser() || InMonitoringList()) {
00104            TGo4QItem* item = dynamic_cast<TGo4QItem*> (listView()->findItem(objname, 0));
00105            if (item!=0) {
00106               //pad->cd();
00107               //panel->SetActivePad(pad);
00108 
00109               TObject* workobj = item->GetWorkObject();
00110               if (workobj) {
00111                  pic->GetLineAtt(dynamic_cast<TAttLine*> (workobj), n);
00112                  pic->GetFillAtt(dynamic_cast<TAttFill*> (workobj), n);
00113                  pic->GetMarkerAtt(dynamic_cast<TAttMarker*> (workobj), n);
00114               }
00115 
00116               item->DrawObj(panel,pad);
00117               isany = true;
00118            } else if (InFileBrowser()) {
00119               pad->cd(); 
00120               if (obj!=0) {
00121                  pic->GetLineAtt(dynamic_cast<TAttLine*> (obj), n);
00122                  pic->GetFillAtt(dynamic_cast<TAttFill*> (obj), n);
00123                  pic->GetMarkerAtt(dynamic_cast<TAttMarker*> (obj), n);
00124                  obj->Draw();
00125               }
00126               isany = true;
00127            } else if (InMemoryBrowser()) {
00128               TGo4ComGetObject* com = new TGo4ComGetObject(objname);
00129               fxTGo4GUIRegistry->SubmitCommand(com, objname, 0, kFALSE, panel->GetQCanvas(), pad);
00130               isany = true;
00131            } else if (InMonitoringList()) {
00132               TGo4ComGetObject* com = new TGo4ComGetObject(objname);
00133               fxTGo4GUIRegistry->SubmitCommand(com, objname, 
00134                                                    fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots"), kTRUE);
00135               // note: AddObject with target viewpanel and pad is not yet implemented
00136               // for monitored list slot; so no automatic replot if deleted. 
00137               // At least we can achieve a refetch into the list here JA
00138               isany = true;
00139            }
00140            
00141         }
00142 
00143         if (isany) break; // exclude superimposing of objects !!!!!!
00144      }
00145 
00146      for (Int_t n=0; n<pic->GetNumObjNames(); n++) {
00147         const char* objname = pic->GetObjName(n);
00148         TObject* obj = pic->FindObject(objname);
00149         if (obj!=0) {
00150           if(padopt && obj->InheritsFrom(TGo4Condition::Class())) {
00151             padopt->SetCondition(dynamic_cast<TGo4Condition*>(obj));
00152           }
00153         }
00154      }
00155    }
00156 }
00157 
00158 void TGo4QPicItem::DrawObj(TGo4PreviewPanel *viewpanel, TPad* currentpad)
00159 {
00160    TGo4Picture *Pic = GetPic();
00161    if (Pic==0) return;
00162    if(!AssignDrawPanel(viewpanel,currentpad)) return;
00163 
00164    if(currentpad)
00165       fxDrawPanel->SetActivePad(currentpad); // need this to clear pad
00166    fxDrawPanel->ClearPad();
00167    DrawSubPic(fxDrawPanel, (TPad*) Pic->DrawHeader(fxDrawPad), Pic);
00168    TGo4QRootCanvas* go4qrootc=fxDrawPanel->GetQCanvas();
00169    go4qrootc->CreateDrawOptions(fxDrawPad); // picture setup defines pad options
00171    if(!fxDrawPanel->IsFreezeTitle())
00172    {
00173       QString Vtitle = fxDrawPanel->name();
00174       Vtitle.append(Pic->GetName());
00175       fxDrawPanel->setCaption(Vtitle);
00176       fxDrawPanel->SetFreezeTitle();
00177    }
00178 }
00179 
00180 void TGo4QPicItem::GetOnlineObj()
00181 {
00182     TGo4MonitoredListSlots* fxTGo4MonitoredListSlots;
00183     fxTGo4MonitoredListSlots=dynamic_cast <TGo4MonitoredListSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots"));
00184     TGo4ComGetPicture* com = new TGo4ComGetPicture(text(0).data());
00185    fxTGo4GUIRegistry->SubmitCommand(com,text(0).data(), fxTGo4MonitoredListSlots, kTRUE);
00186 }
00187 
00188 void TGo4QPicItem::UpdateOnline(TObject* obj)
00189 {
00190    return; // disable this; histograms will update themselves
00191    TGo4Picture* monpic = GetPic();
00192    if(monpic)
00193       {
00194         TGo4Picture* pic = dynamic_cast<TGo4Picture*>(obj);
00195         //if (pic) monpic->UpdateObjectsContentFrom(pic, (entry!=0) ? Pad : 0);
00196         if (pic) monpic->UpdateFrom(pic);
00197         UpdateDrawPad();
00198       }
00199 }
00200 
00201 void TGo4QPicItem::GetRemoteObj()
00202 {
00203    TGo4ComGetPicture *com= new TGo4ComGetPicture(text(0).data());
00204    fxTGo4GUIRegistry->SubmitCommand(com,text(0).data());
00205 }
00206 
00207 void TGo4QPicItem::AddToMonitorList() {
00208    ScanPictureForObjRef(GetPic(), true);
00209 }
00210 
00211 void TGo4QPicItem::AddToMemoryList() {
00212    ScanPictureForObjRef(GetPic(), false);
00213 }
00214 
00215 
00216 TGo4Picture* TGo4QPicItem::GetPic() {
00217    return dynamic_cast <TGo4Picture*> (GetWorkObject());
00218 }
00219 
00220 void TGo4QPicItem::ScanPictureForObjRef(TGo4Picture* pic, bool tomonitor) {
00221    if (pic==0) return;
00222    if (pic->IsDivided()) {
00223       for(Int_t posx=0; posx<pic->GetDivX(); posx++)
00224          for(Int_t posy=0; posy<pic->GetDivY(); posy++)
00225             ScanPictureForObjRef(pic->FindPic(posy,posx), tomonitor);
00226    } else {
00227       for (Int_t n=0; n<pic->GetNumObjNames(); n++) {
00228          const char* objname = pic->GetObjName(n);
00229 
00230          if (pic->FindObject(objname)) continue;
00231 
00232          TGo4ComGetObject* com = new TGo4ComGetObject(objname);
00233          if (tomonitor)
00234             fxTGo4GUIRegistry->SubmitCommand(com, objname, fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots"), kTRUE);
00235          else
00236             fxTGo4GUIRegistry->SubmitCommand(com, objname);
00237       }
00238    }
00239 }
00240 
00241 
00242 
00243 
00244 
00245 //----------------------------END OF GO4 SOURCE FILE ---------------------

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