GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4PolyCondPainter.cxx
Go to the documentation of this file.
1 // $Id: TGo4PolyCondPainter.cxx 2746 2020-04-16 09:10:17Z linev $
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 fuer 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 "TROOT.h"
18 
19 #include "TGo4PolyCondView.h"
20 
23  fxCutView(0)
24 {
25 }
26 
27 TGo4PolyCondPainter::TGo4PolyCondPainter(const char* name, const char* title) :
28  TGo4ConditionPainter(name,title),
29  fxCutView(0)
30 {
31 }
32 
34 {
36  if (fxCutView!=0) {
37  //std::cout <<"TGo4PolyCondPainter dtor deletes cut view "<< (long)fxCutView << std::endl;
38  delete fxCutView;
39  fxCutView = 0;
40  }
41 }
42 
43 
45 {
46  if(gPad==0) return;
47  TObject* cutinpad=gPad->GetListOfPrimitives()->FindObject(fxCutView);
48  //std::cout<<"TGo4PolyCondPainter::PaintCondition with fxCutView "<<(long) fxCutView<<", gPad="<<(long) gPad<<", isatexecutemousevent="<<(fxCutView?fxCutView->IsAtExecuteMouseEvent():0)<<", cutinpad="<< (long)cutinpad;
49  //std::cout<<", Threadid="<< (long) pthread_self()<< std::endl;
50 
51  //if(fxCutView && cutinpad && (fxCutView->IsAtExecuteMouseEvent() || fxCutView->IsAtExecuteMouseMenu())) return; // do not repaint during mouse move on polygon
52 
53  if(fxCutView && cutinpad && fxCutView->IsAtExecuteMouseEvent()) return; // do not repaint during mouse move on polygon
54  if(fxCutView && fxCutView->IsAtExecuteMouseMenu()) return;
55 
56  TGo4PolyCond* pconny=dynamic_cast<TGo4PolyCond*>(fxCondition);
57  if(pconny && pconny->IsVisible()) {
58  TCutG* cutg=pconny->GetCut(kFALSE);
59  if(cutg==0) return; // case of empty polygon condition
60  // JAM2016: deletion from canvas is supressed inside Go4 by QtROOT interface. Just create if not already there:
61  if(fxCutView==0) {
62  // Only set up new view object if not already there
63  // necessary to change cut interactively (points, colors, etc...)
64  // Since cutg may be deleted from canvas by user.
65  fxCutView = new TGo4PolyCondView(cutg);
66 
67  fxCutView->SetLineWidth(pconny->GetLineWidth());
68  fxCutView->SetLineColor(pconny->GetLineColor());
69  fxCutView->SetLineStyle(pconny->GetLineStyle());
70  fxCutView->SetFillColor(pconny->GetFillColor());
71  fxCutView->SetFillStyle(pconny->GetFillStyle());
72  } else {
73  //if(!fxCutView->IsAtExecuteMouseMenu()) // supress exchanging point arrays during insert/remove points menu JAM2016
74  fxCutView->SetCut(cutg); // update view if condition was changed manually
75  }
76 
77  fxCutView->SetCondition(pconny); // backreference for execute event
78  if(!strcmp(opt,"fixstyle")) {
79  // reproduce condition colors always
80  // this mode will prevent the user from changing style interactively
81  fxCutView->SetLineWidth(pconny->GetLineWidth());
82  fxCutView->SetLineColor(pconny->GetLineColor());
83  fxCutView->SetLineStyle(pconny->GetLineStyle());
84  fxCutView->SetFillColor(pconny->GetFillColor());
85  fxCutView->SetFillStyle(pconny->GetFillStyle());
86  }
87  if(cutinpad==0)
88  {
89  //std::cout <<"TGo4PolyCondPainter::PaintCondition appends to pad "<< (long)fxCutView << std::endl;
90  fxCutView->AppendPad();
91  }
92  }// if(pconny && pconny->IsVisible())
93 else
95 }
96 
98 {
99  if(fxCutView==0) return; // JAM2016
100  gROOT->GetListOfCanvases()->RecursiveRemove(fxCutView);
101  //std::cout <<"TGo4PolyCondPainter::UnPaintCondition removes cut view "<< (long)fxCutView << std::endl;
102  // we do not delete view, but restore graphics properties though invisible
103  TString option(opt);
104  if(option.Contains("reset")) {
105  //std::cout <<"TGo4PolyCondPainter::UnPaintCondition with reset deletes cut view"<< (long)fxCutView << std::endl;
106  delete fxCutView;
107  fxCutView=0;
108  }
109 }
110 
112 {
113  if(fxCutView) fxCutView->Pop(); // box to front
114  TGo4LabelPainter::DisplayToFront(opt); // label itself will be frontmost
115 }
116 
118 {
119  fxCondition = con;
120  if (fxCutView)
121  fxCutView->SetCondition(dynamic_cast<TGo4PolyCond *>(con));
122 }
virtual void DisplayToFront(Option_t *opt="")
void SetCondition(TGo4PolyCond *condition)
virtual Bool_t IsVisible()
TGo4Condition * fxCondition
virtual void UnPaintCondition(Option_t *opt="")
TCutG * GetCut(Bool_t changeowner)
Bool_t IsAtExecuteMouseEvent()
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