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