00001 // $Id: TGo4PolyCondPainter.cxx 478 2009-10-29 12:26:09Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #include "TGo4PolyCondPainter.h" 00015 00016 #include "TVirtualPad.h" 00017 #include "TList.h" 00018 #include "TROOT.h" 00019 00020 #include "TGo4PolyCondView.h" 00021 #include "TGo4PolyCond.h" 00022 00023 TGo4PolyCondPainter::TGo4PolyCondPainter() : 00024 TGo4ConditionPainter(), 00025 fxCutView(0) 00026 { 00027 } 00028 00029 TGo4PolyCondPainter::TGo4PolyCondPainter(const char* name, const char* title) : 00030 TGo4ConditionPainter(name,title), 00031 fxCutView(0) 00032 { 00033 } 00034 00035 TGo4PolyCondPainter::~TGo4PolyCondPainter() 00036 { 00037 UnPaintCondition(); 00038 if (fxCutView!=0) { 00039 delete fxCutView; 00040 fxCutView = 0; 00041 } 00042 } 00043 00044 00045 void TGo4PolyCondPainter::PaintCondition(Option_t* opt) 00046 { 00047 if(gPad==0) return; 00048 TGo4PolyCond* pconny=dynamic_cast<TGo4PolyCond*>(fxCondition); 00049 if(pconny && pconny->IsVisible()) { 00050 TCutG* cutg=pconny->GetCut(kFALSE); 00051 if(cutg==0) return; // case of empty polygon condition 00052 if(fxCutView==0 || gPad->GetListOfPrimitives()->FindObject(fxCutView)==0) { 00053 // Only set up new view object if not already there 00054 // necessary to change cut interactively (points, colors, etc...) 00055 // Since cutg may be deleted from canvas by user. 00056 fxCutView = new TGo4PolyCondView(cutg); 00057 fxCutView->SetLineWidth(pconny->GetLineWidth()); 00058 fxCutView->SetLineColor(pconny->GetLineColor()); 00059 fxCutView->SetLineStyle(pconny->GetLineStyle()); 00060 fxCutView->SetFillColor(pconny->GetFillColor()); 00061 fxCutView->SetFillStyle(pconny->GetFillStyle()); 00062 } else 00063 fxCutView->SetCut(cutg); // update view if condition was changed manually 00064 fxCutView->SetCondition(pconny); // backreference for execute event 00065 if(!strcmp(opt,"fixstyle")) { 00066 // reproduce condition colors always 00067 // this mode will prevent the user from changing style interactively 00068 fxCutView->SetLineWidth(pconny->GetLineWidth()); 00069 fxCutView->SetLineColor(pconny->GetLineColor()); 00070 fxCutView->SetLineStyle(pconny->GetLineStyle()); 00071 fxCutView->SetFillColor(pconny->GetFillColor()); 00072 fxCutView->SetFillStyle(pconny->GetFillStyle()); 00073 } 00074 if(gPad->GetListOfPrimitives()->FindObject(fxCutView)==0) 00075 { 00076 fxCutView->AppendPad(); 00077 } 00078 }// if(pconny && pconny->IsVisible()) 00079 else 00080 UnPaintCondition(); 00081 } 00082 00083 void TGo4PolyCondPainter::UnPaintCondition(Option_t* opt) 00084 { 00085 gROOT->GetListOfCanvases()->RecursiveRemove(fxCutView); 00086 // we do not delete view, but restore graphics properties though invisible 00087 TString option(opt); 00088 if(option.Contains("reset")) { 00089 delete fxCutView; 00090 fxCutView=0; 00091 } 00092 } 00093 00094 void TGo4PolyCondPainter::DisplayToFront(Option_t* opt) 00095 { 00096 if(fxCutView) fxCutView->Pop(); // box to front 00097 TGo4LabelPainter::DisplayToFront(opt); // label itself will be frontmost 00098 } 00099 00100 00101 00102 void TGo4PolyCondPainter::SetCondition(TGo4Condition* con) 00103 { 00104 fxCondition=con; 00105 if(fxCutView) 00106 fxCutView->SetCondition(dynamic_cast<TGo4PolyCond*>(con)); 00107 }