Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4PolyCondPainter.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE 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 "TGo4PolyCondPainter.h"
00017 
00018 #include "TVirtualPad.h"
00019 #include "TList.h"
00020 #include "TROOT.h"
00021 
00022 #include "TGo4PolyCondView.h"
00023 #include "TGo4PolyCond.h"
00024 
00025 TGo4PolyCondPainter::TGo4PolyCondPainter() :
00026    TGo4ConditionPainter(),
00027    fxCutView(0)
00028 {
00029 }
00030 
00031 TGo4PolyCondPainter::TGo4PolyCondPainter(const char* name, const char* title) :
00032    TGo4ConditionPainter(name,title),
00033    fxCutView(0)
00034 {
00035 }
00036 
00037 TGo4PolyCondPainter::~TGo4PolyCondPainter()
00038 {
00039    UnPaintCondition();
00040    if (fxCutView!=0) {
00041       delete fxCutView;
00042       fxCutView = 0;
00043    }
00044 }
00045 
00046 
00047 void TGo4PolyCondPainter::PaintCondition(Option_t* opt)
00048 {
00049    if(gPad==0) return;
00050    TGo4PolyCond* pconny=dynamic_cast<TGo4PolyCond*>(fxCondition);
00051    if(pconny && pconny->IsVisible()) {
00052       TCutG* cutg=pconny->GetCut(kFALSE);
00053       if(cutg==0) return; // case of empty polygon condition
00054       if(fxCutView==0 || gPad->GetListOfPrimitives()->FindObject(fxCutView)==0) {
00055          // Only set up new view object if not already there
00056          // necessary to change cut interactively (points, colors, etc...)
00057          // Since cutg may be deleted from canvas by user.
00058          fxCutView = new TGo4PolyCondView(cutg);
00059          fxCutView->SetLineWidth(pconny->GetLineWidth());
00060          fxCutView->SetLineColor(pconny->GetLineColor());
00061          fxCutView->SetLineStyle(pconny->GetLineStyle());
00062          fxCutView->SetFillColor(pconny->GetFillColor());
00063          fxCutView->SetFillStyle(pconny->GetFillStyle());
00064       } else
00065          fxCutView->SetCut(cutg); // update view if condition was changed manually
00066       fxCutView->SetCondition(pconny); // backreference for execute event
00067       if(!strcmp(opt,"fixstyle")) {
00068          // reproduce condition colors always
00069          // this mode will prevent the user from changing style interactively
00070          fxCutView->SetLineWidth(pconny->GetLineWidth());
00071          fxCutView->SetLineColor(pconny->GetLineColor());
00072          fxCutView->SetLineStyle(pconny->GetLineStyle());
00073          fxCutView->SetFillColor(pconny->GetFillColor());
00074          fxCutView->SetFillStyle(pconny->GetFillStyle());
00075       }
00076       if(gPad->GetListOfPrimitives()->FindObject(fxCutView)==0)
00077       {
00078          fxCutView->AppendPad();
00079       }
00080    }// if(pconny && pconny->IsVisible())
00081 else
00082    UnPaintCondition();
00083 }
00084 
00085 void TGo4PolyCondPainter::UnPaintCondition(Option_t* opt)
00086 {
00087    gROOT->GetListOfCanvases()->RecursiveRemove(fxCutView);
00088    // we do not delete view, but restore graphics properties though invisible
00089    TString option(opt);
00090    if(option.Contains("reset")) {
00091       delete fxCutView;
00092       fxCutView=0;
00093    }
00094 }
00095 
00096 void TGo4PolyCondPainter::DisplayToFront(Option_t* opt)
00097 {
00098 if(fxCutView) fxCutView->Pop(); // box to front
00099 TGo4LabelPainter::DisplayToFront(opt); // label itself will be frontmost
00100 }
00101 
00102 
00103 
00104 void TGo4PolyCondPainter::SetCondition(TGo4Condition* con)
00105 {
00106     fxCondition=con;
00107     if(fxCutView)
00108        fxCutView->SetCondition(dynamic_cast<TGo4PolyCond*>(con));
00109 }
00110 
00111 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:07 2008 for Go4-v3.04-1 by  doxygen 1.4.2