GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4PolyCondPainter.cxx
Go to the documentation of this file.
1 // $Id: TGo4PolyCondPainter.cxx 1855 2016-02-29 12:56:48Z adamczew $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4PolyCondPainter.h"
15 
16 #include "TVirtualPad.h"
17 #include "TList.h"
18 #include "TROOT.h"
19 
20 #include "TGo4PolyCondView.h"
21 #include "TGo4PolyCond.h"
22 
25  fxCutView(0)
26 {
27 }
28 
29 TGo4PolyCondPainter::TGo4PolyCondPainter(const char* name, const char* title) :
30  TGo4ConditionPainter(name,title),
31  fxCutView(0)
32 {
33 }
34 
36 {
38  if (fxCutView!=0) {
39  //std::cout <<"TGo4PolyCondPainter dtor deletes cut view "<< (long)fxCutView << std::endl;
40  delete fxCutView;
41  fxCutView = 0;
42  }
43 }
44 
45 
47 {
48  if(gPad==0) return;
49  TObject* cutinpad=gPad->GetListOfPrimitives()->FindObject(fxCutView);
50  //std::cout<<"TGo4PolyCondPainter::PaintCondition with fxCutView "<<(long) fxCutView<<", gPad="<<(long) gPad<<", isatexecutemousevent="<<(fxCutView?fxCutView->IsAtExecuteMouseEvent():0)<<", cutinpad="<< (long)cutinpad;
51  //std::cout<<", Threadid="<< (long) pthread_self()<< std::endl;
52 
53  //if(fxCutView && cutinpad && (fxCutView->IsAtExecuteMouseEvent() || fxCutView->IsAtExecuteMouseMenu())) return; // do not repaint during mouse move on polygon
54 
55  if(fxCutView && cutinpad && fxCutView->IsAtExecuteMouseEvent()) return; // do not repaint during mouse move on polygon
56  if(fxCutView && fxCutView->IsAtExecuteMouseMenu()) return;
57 
58  TGo4PolyCond* pconny=dynamic_cast<TGo4PolyCond*>(fxCondition);
59  if(pconny && pconny->IsVisible()) {
60  TCutG* cutg=pconny->GetCut(kFALSE);
61  if(cutg==0) return; // case of empty polygon condition
62  // JAM2016: deletion from canvas is supressed inside Go4 by QtROOT interface. Just create if not already there:
63  if(fxCutView==0) {
64  // Only set up new view object if not already there
65  // necessary to change cut interactively (points, colors, etc...)
66  // Since cutg may be deleted from canvas by user.
67  fxCutView = new TGo4PolyCondView(cutg);
68 
69  fxCutView->SetLineWidth(pconny->GetLineWidth());
70  fxCutView->SetLineColor(pconny->GetLineColor());
71  fxCutView->SetLineStyle(pconny->GetLineStyle());
72  fxCutView->SetFillColor(pconny->GetFillColor());
73  fxCutView->SetFillStyle(pconny->GetFillStyle());
74  } else {
75  //if(!fxCutView->IsAtExecuteMouseMenu()) // supress exchanging point arrays during insert/remove points menu JAM2016
76  fxCutView->SetCut(cutg); // update view if condition was changed manually
77  }
78 
79  fxCutView->SetCondition(pconny); // backreference for execute event
80  if(!strcmp(opt,"fixstyle")) {
81  // reproduce condition colors always
82  // this mode will prevent the user from changing style interactively
83  fxCutView->SetLineWidth(pconny->GetLineWidth());
84  fxCutView->SetLineColor(pconny->GetLineColor());
85  fxCutView->SetLineStyle(pconny->GetLineStyle());
86  fxCutView->SetFillColor(pconny->GetFillColor());
87  fxCutView->SetFillStyle(pconny->GetFillStyle());
88  }
89  if(cutinpad==0)
90  {
91  //std::cout <<"TGo4PolyCondPainter::PaintCondition appends to pad "<< (long)fxCutView << std::endl;
92  fxCutView->AppendPad();
93  }
94  }// if(pconny && pconny->IsVisible())
95 else
97 }
98 
100 {
101  if(fxCutView==0) return; // JAM2016
102  gROOT->GetListOfCanvases()->RecursiveRemove(fxCutView);
103  //std::cout <<"TGo4PolyCondPainter::UnPaintCondition removes cut view "<< (long)fxCutView << std::endl;
104  // we do not delete view, but restore graphics properties though invisible
105  TString option(opt);
106  if(option.Contains("reset")) {
107  //std::cout <<"TGo4PolyCondPainter::UnPaintCondition with reset deletes cut view"<< (long)fxCutView << std::endl;
108  delete fxCutView;
109  fxCutView=0;
110  }
111 }
112 
114 {
115 if(fxCutView) fxCutView->Pop(); // box to front
116 TGo4LabelPainter::DisplayToFront(opt); // label itself will be frontmost
117 }
118 
119 
120 
122 {
123  fxCondition=con;
124  if(fxCutView)
125  fxCutView->SetCondition(dynamic_cast<TGo4PolyCond*>(con));
126 }
virtual void DisplayToFront(Option_t *opt="")
void SetCondition(TGo4PolyCond *condition)
TGo4Condition * fxCondition
virtual void UnPaintCondition(Option_t *opt="")
TCutG * GetCut(Bool_t changeowner)
Bool_t IsAtExecuteMouseEvent()
virtual Bool_t IsVisible()
Bool_t IsAtExecuteMouseMenu()
virtual void PaintCondition(Option_t *opt="")
void SetCut(TCutG *source)
virtual void SetCondition(TGo4Condition *con)
virtual void DisplayToFront(Option_t *opt="")
TGo4PolyCondView * fxCutView