GSI Object Oriented Online Offline (Go4) GO4-6.4.5
Loading...
Searching...
No Matches
TGo4FitGuiArrow.cpp
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 "TGo4FitGuiArrow.h"
15
16#include "Buttons.h"
17#include "TMath.h"
18
19#include "TGo4FitPanel.h"
20#include "TGo4FitModel.h"
21#include "TGo4ViewPanel.h"
22
24 TArrow(), fxType(at_none), fxModel(nullptr), fxOther(nullptr), fdLineAmpl(0.), fxComp(nullptr), fiRangeNum(0),
25 fdRangeY(0.), fdShiftX(0.), fxItem(nullptr), fxPanel(nullptr)
26{
27}
28
29TGo4FitGuiArrow::TGo4FitGuiArrow(Float_t arrowsize, Option_t *option) :
30 TArrow(0.,0.,0.,0.,arrowsize,option), fxType(at_none), fxModel(nullptr), fxOther(nullptr), fdLineAmpl(0.), fxComp(nullptr), fiRangeNum(0),
31 fdRangeY(0.), fdShiftX(0.), fxItem(nullptr), fxPanel(nullptr)
32{
33}
34
35TGo4FitGuiArrow::TGo4FitGuiArrow(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Float_t arrowsize, Option_t *option) :
36 TArrow(x1,y1,x2,y2,arrowsize,option), fxType(at_none), fxModel(nullptr), fxOther(nullptr), fdLineAmpl(0.), fxComp(nullptr), fiRangeNum(0),
37 fdRangeY(0.), fdShiftX(0.), fxItem(nullptr), fxPanel(nullptr)
38{
39}
40
44
45void TGo4FitGuiArrow::SetForPosition(TGo4FitModel *model, TGo4FitGuiArrow* forwidth, Double_t iLineAmpl)
46{
47 fxType = at_pos;
48 fxModel = model;
49 fxOther = forwidth;
50 fdLineAmpl = iLineAmpl;
51}
52
54{
56 fxModel = model;
57 fxOther = forposition;
58}
59
60void TGo4FitGuiArrow::SetForRange(TGo4FitComponent *Comp, Int_t num, Double_t rangey, Double_t shiftx)
61{
63 fxComp = Comp;
64 fiRangeNum = num;
65 fdRangeY = rangey;
66 fdShiftX = shiftx;
67}
68
70{
71 fxItem = item;
72 fxPanel = panel;
73}
74
76{
77 Double_t x1 = GetX1(), x2 = GetX2(), y1 = GetY1(), y2 = GetY2();
78
79 switch (fxType) {
80 case at_pos:
81 Double_t pos;
82 if (fxModel->GetPosition(0,pos)) {
83 SetX1(pos); SetX2(pos); SetY1(fdLineAmpl/2); SetY2(fdLineAmpl);
84 }
85 break;
86 case at_width:
87 Double_t width, ppp;
88 if ((fxModel->GetWidth(0,width)) && (fxModel->GetPosition(0,ppp))) {
89 SetX1(ppp-width); SetX2(ppp+width);
90 SetY1(fxOther->GetY1());
91 SetY2(fxOther->GetY1());
92 }
93 break;
94 case at_range:
95 Int_t typ, naxis;
96 Double_t left, right;
97 fxComp->GetRangeCondition(fiRangeNum, typ, naxis, left, right);
98 switch (typ) {
99 case 0: SetX1(left); SetX2(right); break;
100 case 1: SetX1(left); SetX2(right); break;
101 case 2: SetX1(left); SetX2(left+fdShiftX); break;
102 case 3: SetX1(right-fdShiftX); SetX2(right); break;
103 }
104 SetY1(fdRangeY); SetY2(fdRangeY);
105
106 break;
107 }
108
109 return (x1 != GetX1()) || (x2 != GetX2()) || (y1 != GetY1()) || (y2 != GetY2());
110}
111
112Bool_t TGo4FitGuiArrow::IsAssignTo(TObject *obj)
113{
114 return obj && ((obj == fxModel) || (obj == fxComp));
115}
116
117void TGo4FitGuiArrow::Delete(Option_t *option)
118{
119 if ((fxType==at_pos) && fxPanel)
120 fxPanel->DeleteModelWithPrimit(this);
121}
122
123void TGo4FitGuiArrow::ExecuteEvent(Int_t event, Int_t px, Int_t py)
124{
125 TArrow::ExecuteEvent(event,px,py);
126
127 if (event == kButton1Up)
129}
130
132{
133 switch (fxType) {
134
135 case at_pos: {
136 fxModel->SetPosition(0, GetX2());
137 fdLineAmpl = (GetY1() > GetY2()) ? GetY1() : GetY2();
138 if (fxPanel)
139 fxPanel->ArrowChanged(this);
140 break;
141 }
142
143 case at_width: {
144 Double_t width = 0;
145 fxModel->GetWidth(0, width);
146 Double_t pos = fxOther->GetX2();
147
148 Double_t w0 = (GetX2() - GetX1()) / 2;
149 Double_t w1 = pos - GetX1();
150 Double_t w2 = GetX2() - pos;
151
152 if (TMath::Abs(w0 - width) > 1e-10) {
153 Double_t w = width;
154 if (TMath::Abs(w1 - width) > 1e-10)
155 w = w1;
156 else
157 w = w2;
158 if (w > 0) {
159 width = w;
160 fxModel->SetWidth(0, width);
161 if (fxPanel)
162 fxPanel->ArrowChanged(this);
163 }
164 }
165 break;
166 }
167
168 case at_range: {
169 Int_t typ, naxis;
170 Double_t left, right;
171 fxComp->GetRangeCondition(fiRangeNum, typ, naxis, left, right);
172
173 left = GetX1() < GetX2() ? GetX1() : GetX2();
174 right = GetX1() > GetX2() ? GetX1() : GetX2();
175
176 fxComp->SetRangeCondition(fiRangeNum, typ, naxis, left, right);
177
178 if (fxPanel)
179 fxPanel->ArrowChanged(this);
180
181 break;
182 }
183 }
184}
185
186#ifdef __GO4WEB__
187Bool_t TGo4FitGuiArrow::Notify()
188{
191
192 return TObject::Notify();
193}
194#endif
Basic abstract class, combining common properties of data and model.
TGo4FitGuiArrow * fxOther
void SetForRange(TGo4FitComponent *Comp, Int_t num, Double_t rangey, Double_t shiftx)
Bool_t IsAssignTo(TObject *obj)
void SetForWidth(TGo4FitModel *model, TGo4FitGuiArrow *forposition)
void SetItem(QFitItem *item, TGo4FitPanel *panel)
void Delete(Option_t *option="") override
TGo4FitComponent * fxComp
TGo4FitModel * fxModel
TGo4FitPanel * fxPanel
void SetForPosition(TGo4FitModel *model, TGo4FitGuiArrow *forwidth, Double_t iLineAmpl)
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
virtual ~TGo4FitGuiArrow()
Basic abstract class for representing model components of fitted data.
virtual TGo4ViewPanel * ActivePanel()
virtual bool IsWebCanvas() const