GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4PolyCondPainter.cxx
Go to the documentation of this file.
1 // $Id$
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(nullptr)
24 {
25 }
26 
27 TGo4PolyCondPainter::TGo4PolyCondPainter(const char *name, const char *title) :
28  TGo4ConditionPainter(name,title),
29  fxCutView(nullptr)
30 {
31 }
32 
34 {
36  if (fxCutView) {
37  delete fxCutView;
38  fxCutView = nullptr;
39  }
40 }
41 
42 
44 {
45  if(!gPad) return;
46  TObject *cutinpad = gPad->GetListOfPrimitives()->FindObject(fxCutView);
47 
48  //if(fxCutView && cutinpad && (fxCutView->IsAtExecuteMouseEvent() || fxCutView->IsAtExecuteMouseMenu())) return; // do not repaint during mouse move on polygon
49 
50  if(fxCutView && cutinpad && fxCutView->IsAtExecuteMouseEvent()) return; // do not repaint during mouse move on polygon
51  if(fxCutView && fxCutView->IsAtExecuteMouseMenu()) return;
52 
53  TGo4PolyCond *pconny=dynamic_cast<TGo4PolyCond*>(fxCondition);
54  if(pconny && pconny->IsVisible()) {
55  TCutG *cutg = pconny->GetCut(kFALSE);
56  if(!cutg) return; // case of empty polygon condition
57  // JAM2016: deletion from canvas is suppressed inside Go4 by QtROOT interface. Just create if not already there:
58  if(!fxCutView) {
59  // Only set up new view object if not already there
60  // necessary to change cut interactively (points, colors, etc...)
61  // Since cutg may be deleted from canvas by user.
62  fxCutView = new TGo4PolyCondView(cutg);
63 
64  fxCutView->SetLineWidth(pconny->GetLineWidth());
65  fxCutView->SetLineColor(pconny->GetLineColor());
66  fxCutView->SetLineStyle(pconny->GetLineStyle());
67  fxCutView->SetFillColor(pconny->GetFillColor());
68  fxCutView->SetFillStyle(pconny->GetFillStyle());
69  } else {
70  //if(!fxCutView->IsAtExecuteMouseMenu()) // suppress exchanging point arrays during insert/remove points menu JAM2016
71  fxCutView->SetCut(cutg); // update view if condition was changed manually
72  }
73 
74  fxCutView->SetCondition(pconny); // back-reference for execute event
75  if(!strcmp(opt,"fixstyle")) {
76  // reproduce condition colors always
77  // this mode will prevent the user from changing style interactively
78  fxCutView->SetLineWidth(pconny->GetLineWidth());
79  fxCutView->SetLineColor(pconny->GetLineColor());
80  fxCutView->SetLineStyle(pconny->GetLineStyle());
81  fxCutView->SetFillColor(pconny->GetFillColor());
82  fxCutView->SetFillStyle(pconny->GetFillStyle());
83  }
84  if(!cutinpad) {
85  fxCutView->AppendPad();
86  }
87  }// if(pconny && pconny->IsVisible())
88 else
90 }
91 
93 {
94  if(!fxCutView) return; // JAM2016
95  gROOT->GetListOfCanvases()->RecursiveRemove(fxCutView);
96  // we do not delete view, but restore graphics properties though invisible
97  TString option(opt);
98  if(option.Contains("reset")) {
99  delete fxCutView;
100  fxCutView = nullptr;
101  }
102 }
103 
105 {
106  if(fxCutView) fxCutView->Pop(); // box to front
107  TGo4LabelPainter::DisplayToFront(opt); // label itself will be frontmost
108 }
109 
111 {
112  fxCondition = con;
113  if (fxCutView)
114  fxCutView->SetCondition(dynamic_cast<TGo4PolyCond *>(con));
115 }
Bool_t IsAtExecuteMouseMenu() const
void UnPaintCondition(Option_t *opt="") override
TCutG * GetCut(Bool_t changeowner) override
void SetCondition(TGo4PolyCond *condition)
TGo4Condition * fxCondition
void SetCondition(TGo4Condition *con) override
void SetCut(TCutG *source)
virtual void DisplayToFront(Option_t *opt="")
void DisplayToFront(Option_t *opt="") override
Bool_t IsAtExecuteMouseEvent() const
void PaintCondition(Option_t *opt="") override
TGo4PolyCondView * fxCutView
virtual Bool_t IsVisible() const