GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4WinCondView.cxx
Go to the documentation of this file.
1 // $Id: TGo4WinCondView.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 "TGo4WinCondView.h"
15 
16 #include "RVersion.h"
17 #include "Buttons.h"
18 #include "TPad.h"
19 
20 #include "TGo4WinCond.h"
21 
22 TGo4WinCondView::TGo4WinCondView(Double_t x1,Double_t y1,Double_t x2,Double_t y2)
23  :TBox(x1,y1,x2,y2), fbExecutesMouseEvent(kFALSE), fxWinCondition(0)
24 {
25  SetBit(kMustCleanup);
26  //SetBit(kCanDelete, kFALSE);
27 }
28 
30  : TBox(),fbExecutesMouseEvent(kFALSE),fxWinCondition(0)
31 {
32  SetBit(kMustCleanup);
33  //SetBit(kCanDelete, kFALSE);
34 }
35 
37 {
38 }
39 
40 
41 void TGo4WinCondView::Paint(Option_t* opt)
42 {
43 if(fxWinCondition) TBox::Paint(opt);
44 // we have a valid condition set from painter. Otherwise,
45 // suppress painting of condition view without owner. This case
46 // happens after insert canvas in go4 (separate cloning
47 // of lists of primitive members), thus leading to a
48 // second "ghost condition box"
49 
50 }
51 void TGo4WinCondView::ExecuteEvent(Int_t event, Int_t px, Int_t py)
52 {
53 // note: This method is never called in ROOT>=4.03/02 when
54 // logscale is enabled on pad.
55 // So no mouse modifications of condition possible
56 // TO BE INVESTIGATED! JA
57 if(gPad==0) return;
58 
59 if(event==kButton1Down && fxWinCondition)
60 {
61  fbExecutesMouseEvent=kTRUE; // only lock painting if we really touch the box JAM
62 }
63 
64 TBox::ExecuteEvent(event,px,py);
65 if(event==kButton1Up && fxWinCondition)
66  {
67  Pop(); // do condition under edit into foreground, for condarray
68  fxWinCondition->ResetLabel("pop"); // always pop our label to foreground
69  // here we update the condition values if necessary:
70  Double_t epsilon=fxWinCondition->GetUpdateEpsilon();
71  Double_t xmin=0;
72  Double_t xmax=0;
73  Double_t ymin=0;
74  Double_t ymax=0;
75  Int_t dim=0;
76  fxWinCondition->GetValues(dim,xmin,xmax,ymin, ymax);
77 
78  // note: newer root versions treat log scale correctly in TBox
79 #if ROOT_VERSION_CODE < ROOT_VERSION(4,3,2)
80  Double_t X1 = gPad->PadtoX(GetX1()); // regard the log scale!
81  Double_t X2 = gPad->PadtoX(GetX2());
82  Double_t Y1 = gPad->PadtoY(GetY1());
83  Double_t Y2 = gPad->PadtoY(GetY2());
84 #else
85  Double_t X1 = GetX1();
86  Double_t X2 = GetX2();
87  Double_t Y1 = GetY1();
88  Double_t Y2 = GetY2();
89 #endif
90  if(dim>1)
91  {
92  // check if update is needed:
93  if((TMath::Abs(xmin-X1) > epsilon) ||
94  (TMath::Abs(xmax-X2) > epsilon) ||
95  (TMath::Abs(ymin-Y1) > epsilon) ||
96  (TMath::Abs(ymax-Y2) > epsilon) )
97  {
98  //std::cout <<"ExecuteEvent modified 2d condition with colors, epsilon="<<epsilon << std::endl;
99  fxWinCondition->SetValues(X1, X2, Y1, Y2 );
100  fxWinCondition->SetLineColor(GetLineColor());
101  fxWinCondition->SetLineWidth(GetLineWidth());
102  fxWinCondition->SetLineStyle(GetLineStyle());
103  fxWinCondition->SetFillColor(GetFillColor());
104  fxWinCondition->SetFillStyle(GetFillStyle());
105  fxWinCondition->SetChanged(kTRUE);
106  }
107  }
108  else
109  {
110  if((TMath::Abs(xmin-X1) > epsilon) ||
111  (TMath::Abs(xmax-X2) > epsilon) )
112  {
113  //std::cout <<"ExecuteEvent modified 1d condition with colors, epsilon="<<epsilon << std::endl;
114  fxWinCondition->SetValues(X1, X2);
115  fxWinCondition->SetLineColor(GetLineColor());
116  fxWinCondition->SetLineWidth(GetLineWidth());
117  fxWinCondition->SetLineStyle(GetLineStyle());
118  fxWinCondition->SetFillColor(GetFillColor());
119  fxWinCondition->SetFillStyle(GetFillStyle());
120  fxWinCondition->SetChanged(kTRUE);
121  }
122  }// if(dim>1)
123  fbExecutesMouseEvent=kFALSE; // only release execute event lock when we finish the move JAM
124 
125  } // if(event==...)
126 }
127 
128 const char* TGo4WinCondView::GetName() const
129 {
130  if(fxWinCondition)
131  return (fxWinCondition->GetName());
132  else
133  return 0;
134 }
135 
136 
137 void TGo4WinCondView::SetName(const char* nam)
138 {
139  if(fxWinCondition) fxWinCondition->SetName(nam);
140 }
141 
142 void TGo4WinCondView::SetToLimits(Double_t x1, Double_t x2, Double_t y1, Double_t y2)
143 {
144 if(fxWinCondition==0) return;
146  fxWinCondition->SetValues(x1,x2,y1,y2);
147 else
148  fxWinCondition->SetValues(x1,x2);
149 }
150 
151 
153 {
155 }
156 
158 {
160 }
161 
163 {
165 }
166 
168 {
170 }
171 
173 {
175 }
176 
178 {
180 }
181 
183 {
185 }
186 
188 {
190 }
191 
193 {
195 }
196 
198 {
200 }
201 
202 
203 void TGo4WinCondView::SetNumFormat(const char* fmt)
204 {
206 }
207 
208 
209 //void TGo4WinCondView::DeleteRegion()
210 //{
211 // if(fxWinCondition && !fxWinCondition->IsOwnedByEditor())
212 // {
213 // fxWinCondition->Delete("");
214 // }
215 //}
216 
218 {
220 }
221 
223 {
225 }
226 
Double_t GetUpdateEpsilon()
virtual void SetChanged(Bool_t on)
void SetYRMSDraw(Bool_t on)
TGo4WinCond * fxWinCondition
virtual void SetLimitsDraw(Bool_t on)
void SetToLimits(Double_t x1, Double_t x2, Double_t y1=0, Double_t y2=0)
virtual void SetYRMSDraw(Bool_t on)
Int_t GetDimension()
virtual void SetLabelNumFormat(const char *fmt)
void SetName(const char *nam)
virtual void GetValues(Int_t &dim, Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2)
void SetCMaxDraw(Bool_t on)
virtual void Paint(Option_t *opt="")
virtual void SetXMaxDraw(Bool_t on)
virtual void SetYMaxDraw(Bool_t on)
void SetYMaxDraw(Bool_t on)
virtual void SetIntDraw(Bool_t on)
void SetXRMSDraw(Bool_t on)
virtual void SetYMeanDraw(Bool_t on)
virtual void SetValues(Double_t low1, Double_t up1)
void SetLabelDraw(Bool_t on)
virtual ~TGo4WinCondView()
void ResetLabel(Option_t *opt="reset")
void SetXMaxDraw(Bool_t on)
virtual void SetXMeanDraw(Bool_t on)
const char * GetName() const
Bool_t fbExecutesMouseEvent
void SetIntDraw(Bool_t on)
virtual void SetLabelDraw(Bool_t on)
void SetLimitsDraw(Bool_t on)
void SetYMeanDraw(Bool_t on)
virtual void SetXRMSDraw(Bool_t on)
void SetXMeanDraw(Bool_t on)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
void SetNumFormat(const char *fmt="%.4E")
virtual void SetCMaxDraw(Bool_t on)