ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ObjectLine.h
Go to the documentation of this file.
1 
13 #ifndef _OBJECTLINE_H_
14 #define _OBJECTLINE_H_
15 
16 #include "AbstractObjectStock.h"
17 // to see how to integrate better, own definition in ObjectLine as well
18 #include "EditorObjStock.h"
19 
20 #include "TypeObjectLine.h"
21 
22 // could be in implementation if really needed
23 #include <iostream>
24 // declare ROOT types UInt_t, should suppress as more as possible
25 //#include <Rtypes.h>
26 #include <TLine.h>
27 
33 class ObjectLine : public AbstractObjectStock, public TAttLine
34 {
35  protected :
36 
38  std::string name_line;
39 
40  // Line [-inf,+inf], kHalfLine1 [point,+inf], kHalfLine2 [-inf, point], kSegment[point,point]
41  // could be in EditorObject, takes memory here ! or in TypeLine.h, no
42  // no memory, just better encapsulation if not needed form outside, here only used by the ObjectLine
43  enum ModeLine { kLine = 0, kHalfLine1 = 1, kHalfLine2 = 2, kSegment = 3 };
44 
49 
51  TLine *fline;
52 
53  // protected function used by the constructor,
54  // simple wrapper to construct the line
55  void InitLine( double x0, double y0, double x1, double y1 );
56 
59  virtual std::vector<float> GetValues( int px, int py, time_t &date ) const;
60 
61  public :
62  // default constructor, not used yet
63  ObjectLine();
65  // miss something to get the reference ??
66  //ObjectLine ( TypeLine & tline, double valuey0 );
67  ObjectLine ( TypeLine tline, double valuey0 );
69  // should replace mode as well, not clear which one in this function
70  ObjectLine( double x0, double y0, double x1, double y1 ); // Int_t kMode );
72  virtual ~ObjectLine() {
73 #ifdef DEBUG_OBJSTOCK
74  std::cout << "Destructor ObjectLine" << std::endl;
75 #endif
76  delete fline; fline = 0;
77  }
78 
79  // as for indicator not present in abstract base
80  virtual std::string GetNameObject() const { return name_line; }
81  // new added not used yet
82  virtual void SetNameObject ( std::string & name ) { name_line = name; }
83 
84  // to define, maybe override in derived
85  /*
86  virtual std::vector<std::string> MakeStringForStatusBar( int px, int py ) const {
87  std::vector<std::string> vec_string;
88  vec_string.push_back("toto1");
89  vec_string.push_back("toto2");
90  return vec_string;
91  }*/
92 
94  // should not be public, but protected ??
95  double GetX0() const { return fline->GetX1();}
96  double GetX1() const { return fline->GetX2();}
97  double GetY0() const { return fline->GetY1();}
98  double GetY1() const { return fline->GetY2();}
99  // could receive double and translate to double for ROOT
100  void SetX0(double x0) { fline->SetX1(x0);}
101  void SetX1(double x1) { fline->SetX2(x1);}
102  void SetY0(double y0) { fline->SetY1(y0);}
103  void SetY1(double y1) { fline->SetY2(y1);}
104 
105  // pure virtual in AbstractObjectStock, but never used here !
106  // maybe can implement it ??
107  virtual void SetValues( unsigned int, std::vector<double>, double, double, time_t, UInt_t=0) {}
108 
109  // graphical function, need to redirect now, needed for interation with graphical editor
110  virtual Width_t GetLineWidth() const { return fline->GetLineWidth(); }
111  virtual Color_t GetLineColor() const { return fline->GetLineColor(); }
112  virtual Style_t GetLineStyle() const { return fline->GetLineStyle(); }
113  virtual void SetLineWidth(Width_t lwidth) { fline->SetLineWidth(lwidth); }
114  virtual void SetLineColor(Color_t color) { fline->SetLineColor(color); }
115  virtual void SetLineStyle(Style_t lstyle) { fline->SetLineStyle( lstyle ); }
116 
118  // deal with Modeline
119  virtual Int_t GetModeLine() const {return fModeLine;}
120  virtual bool IsLine() { if (fModeLine==kLine) return true; else return false;}
121  virtual bool IsHalfLine1() { if (fModeLine==kHalfLine1) return true; else return false;}
122  virtual bool IsHalfLine2() { if (fModeLine==kHalfLine2) return true; else return false;}
123  virtual bool IsSegment() { if (fModeLine==kSegment) return true; else return false;}
124 
125  //virtual void GetModekLine() { return fModeLine; std::cout << "Get kLine" << endl; }
126  // *TOGGLE* not working
127  virtual void SetModekLine() { fModeLine= kLine; std::cout << "Set kLine" << std::endl; } // *MENU*
128  virtual void SetModekHalfLine1() { fModeLine= kHalfLine1; std::cout << "Set kHalfLine1" << std::endl; } // *MENU*
129  virtual void SetModekHalfLine2() { fModeLine= kHalfLine2; std::cout << "Set kHalfLine2" << std::endl; } // *MENU*
130  virtual void SetModekSegment() { fModeLine= kSegment; std::cout << "Set kSegment" << std::endl; } // *MENU*
131 
132  //deal with TypeLine
133  virtual TypeLine GetTypeLine() const {return fTypeLine;}
134  virtual bool IsSupport() const { return (fTypeLine==TypeLine::kSupport) ? true : false;}
135  virtual bool IsTendance() const { return (fTypeLine==TypeLine::kTendance) ? true : false;}
136 
137  // default for all GetExtrama do nothing
138  virtual void GetExtrema( double & /*min*/, double & /*max*/ ) const {
139  // //min = max = GetY0();
140  /* std::cout << "ObjectLine::GetExtrema do nothing " << std::endl; */}
141 
142  virtual void Resize( unsigned int /*new_size*/ ) {
143 #ifdef DEBUG_OBJSTOCK
144  std::cout << "ObjectLine::Resize to nothing" << std::endl;
145 #endif
146  }
147 
148  //virtual Int_t DistancetoPrimitive(Int_t px, Int_t py); //, TObject** obj );
149  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py, AbstractObjectStock ** obj );
150  // cannot anchor to an ObjectLine
151  virtual int DistancetoPoint(int /*px*/, int /*py*/, double &/*yvalue*/, int /*bin*/ = -1) const
152  { /*std::cout << "CollectionObjectStock::DistancetoPoint " << std::endl;*/ return 9999; }
153 
154  // ldata, not used here, done for compilation
155  virtual void SetObjectStock( ListDataStockBase * /*ldata*/, CommonXAxis */*fcommon_xaxis_th*/, Hparam_stock_t & /*Hparam_stock*/ ) {
156  /*std::cout << "ObjectLine::SetObjectStock to override or make a default " << std::endl;*/
157  }
158  virtual void Paint( const Option_t* ="");
159 
160  // slot, neeeded for interaction here or in Tendance ?
161  virtual void ExecuteEvent(Int_t /*event*/, Int_t /*px*/, Int_t /*py*/) {}
162 
163  ClassDef ( ObjectLine, 1);
164 };
165 
179 {
180  public :
183  // from a user point of view, name is good to extend base
185  // here assign directly the name, maybe better way ?? will see
186  ObjectLineIndicator ( std::string name, double value );
187  virtual ~ObjectLineIndicator() {}
188 
190  virtual std::vector<std::string> MakeStringForStatusBar( int px, int py ) const;
191 
193  virtual void GetExtrema( double & min, double & max ) const { min = max = GetY0();
194  /*std::cout << "ObjectLineIndicator::GetExtrema " << GetY0() << std::endl;*/}
195 
197  virtual void ClearObjectStock() {
198 #ifdef DEBUG_OBJSTOCK
199  std::cout << "ObjectLineIndicator::ClearObjectStock, do nothing " << std::endl;
200 #endif
201  } //=0
204  virtual void SetObjectStock( ListDataStockBase * /*ldata*/, CommonXAxis */*fcommon_xaxis_th*/, Hparam_stock_t & /*Hparam_stock*/ );
205 
206  // no interaction with them, cannot move it
207  virtual void ExecuteEvent(Int_t /*event*/, Int_t /*px*/, Int_t /*py*/) {
208 #ifdef DEBUG_OBJSTOCK
209  std::cout << "ObjectLineIndicator::ExecuteEvent, do nothing " << std::endl;
210 #endif
211  }
212 
213  // except for printing name in status bar
214  // but can use the base class for this...
215  //virtual Int_t DistancetoPrimitive(Int_t px, Int_t py); //, TObject** obj );
216  //virtual Int_t DistancetoPrimitive(Int_t px, Int_t py, AbstractObjectStock ** obj );
217 
219 };
220 
231 {
232  protected :
236  double coeff_d, origin;
237 
241  double valueY0, valueY1;
242 
244  time_t ftbegin, ftend;
247 
249  void RecalcCoeff_origin ( double x0, double x1);
252  virtual double GetXBorder( double y ) const;
254  virtual double ExtrapolateYPad ( double ) const;
255 
256  public :
259  valueY0(0.), valueY1(0.), ftbegin(0), ftend(0),fbin_begin(0),fbin_end(0) {}
261  ObjectLineTendance ( TypeLine & tline, double valueX, double valueY );
262  virtual ~ObjectLineTendance() {}
263 
267  void FinaliseDrawableLine( CommonXAxis *fcommon_xaxis_th );
268 
270  double GetCoeffD() const { return coeff_d; }
271  void SetCoeffD ( double & new_coeff ) { coeff_d = new_coeff; }
272  double GetOrigin() const { return origin; }
273  void SetOrigin ( double & x, double & y );
274  // a lot called by THStock.cxx, could be in Object, in Set for instance
275  //needed because ftime and fline are private, should check the order x1 < x2
276  time_t GetTimeBegin() const {return ftbegin;}
277  time_t GetTimeEnd() const {return ftend;}
278  Int_t GetBinBegin() const {return fbin_begin;}
279  Int_t GetBinEnd() const {return fbin_end;}
280 
281  void SetTimeT0 ( time_t begin ) { ftbegin = begin; }
282  void SetTimeT1 ( time_t end ) { ftend = end; }
283  virtual void SetTimes ( time_t begin, time_t end ) { ftbegin = begin; ftend = end; }
284  void SetBinBegin( Int_t bin_x0 ) { fbin_begin = bin_x0; }
285  void SetBinEnd ( Int_t bin_x1 ) { fbin_end = bin_x1; }
286  void SetBins ( Int_t bin_x0, Int_t bin_x1 ) { fbin_begin = bin_x0; fbin_end = bin_x1; }
287  void SetInitValuesY() { valueY0 = fline->GetY1(); valueY1 = fline->GetY2(); }
288 
289  // used only when creating the line, was used in TCreateObject only at this time
290  // and when MoveObjectStock is called, maybe public ?? not if Factory
291  void InitCoeff_origin( double x0, double x1, double y0, double y1 );
292 
293  // Should provide simple function, for moving
294 
295  virtual std::vector<std::string> MakeStringForStatusBar( int px, int py ) const;
296  virtual void ClearObjectStock() {
297 #ifdef DEBUG_OBJSTOCK
298  std::cout << "ObjectLineTendance::ClearObjectStock" << std::endl;
299 #endif
300  }
301  virtual void SetObjectStock( ListDataStockBase * /*ldata*/, CommonXAxis */*fcommon_xaxis_th*/, Hparam_stock_t & /*Hparam_stock*/ );
302  void virtual Paint( const Option_t* ="");
303 
304  // here want interaction with the line, only class to be drawable, movable
306  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
308  virtual void MoveObjectLine( bool kdir ); //, kModeMove kmove );
309 
311 };
312 
317 #endif //_OBJECTLINE_H_
void SetY0(double y0)
Definition: ObjectLine.h:102
virtual Int_t GetModeLine() const
Definition: ObjectLine.h:119
double coeff_d
most general for drawing a line, y = ax + b and moving as well, rotate a, translate b ! a and b not f...
Definition: ObjectLine.h:236
virtual void SetLineStyle(Style_t lstyle)
Definition: ObjectLine.h:115
virtual Color_t GetLineColor() const
Definition: ObjectLine.h:111
virtual void ClearObjectStock()
general function called when drawing
Definition: ObjectLine.h:296
virtual std::string GetNameObject() const
pure-virtual access
Definition: ObjectLine.h:80
time_t GetTimeBegin() const
Definition: ObjectLine.h:276
ObjectLineIndicator()
constructors
Definition: ObjectLine.h:182
double GetY1() const
Definition: ObjectLine.h:98
virtual TypeLine GetTypeLine() const
Definition: ObjectLine.h:133
virtual void SetModekLine()
Definition: ObjectLine.h:127
virtual std::vector< float > GetValues(int px, int py, time_t &date) const
used by MakeStringForStatusBar only base in ObjectLine should be very simple
Definition: ObjectLine.cxx:95
virtual void GetExtrema(double &, double &) const
Definition: ObjectLine.h:138
virtual void SetObjectStock(ListDataStockBase *, CommonXAxis *, Hparam_stock_t &)
implements a easy way for this case only set to xmin xmax
Definition: ObjectLine.cxx:208
time_t GetTimeEnd() const
Definition: ObjectLine.h:277
ClassDef(ObjectLineIndicator, 1)
ModeLine fModeLine
kLine, kSegment, kHalfSegment0, kHalfSegment1
Definition: ObjectLine.h:46
Define Base classes for ObjectStock.
virtual void ExecuteEvent(Int_t, Int_t, Int_t)
Definition: ObjectLine.h:207
virtual bool IsHalfLine1()
Definition: ObjectLine.h:121
virtual bool IsTendance() const
Definition: ObjectLine.h:135
double valueY0
save initial values, y's overridden if Lines Y initial values , no overloaded by line->SetY, here stay constant associated to fbin_begin/fend
Definition: ObjectLine.h:241
virtual Style_t GetLineStyle() const
Definition: ObjectLine.h:112
TLine * fline
use composition TLine*, valable for all derived class
Definition: ObjectLine.h:51
void SetBins(Int_t bin_x0, Int_t bin_x1)
Definition: ObjectLine.h:286
virtual ~ObjectLineIndicator()
Definition: ObjectLine.h:187
virtual void SetValues(unsigned int, std::vector< double >, double, double, time_t, UInt_t=0)
Definition: ObjectLine.h:107
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py, AbstractObjectStock **obj)
Definition: ObjectLine.cxx:126
virtual Width_t GetLineWidth() const
Definition: ObjectLine.h:110
virtual void SetLineWidth(Width_t lwidth)
Definition: ObjectLine.h:113
virtual void SetModekHalfLine2()
Definition: ObjectLine.h:129
void InitCoeff_origin(double x0, double x1, double y0, double y1)
Definition: ObjectLine.cxx:272
virtual void SetNameObject(std::string &name)
Definition: ObjectLine.h:82
virtual void SetModekSegment()
Definition: ObjectLine.h:130
double GetOrigin() const
Definition: ObjectLine.h:272
void SetCoeffD(double &new_coeff)
Definition: ObjectLine.h:271
virtual void Paint(const Option_t *="")
Paint the objet, to overide.
Definition: ObjectLine.cxx:563
virtual void MoveObjectLine(bool kdir)
pass the direction ( positive, negative ) to extend
Definition: ObjectLine.cxx:836
double GetCoeffD() const
member functions specific
Definition: ObjectLine.h:270
void SetTimeT1(time_t end)
Definition: ObjectLine.h:282
virtual std::vector< std::string > MakeStringForStatusBar(int px, int py) const
specific output for ObjectLineIndicator
Definition: ObjectLine.cxx:183
double GetX0() const
wrapper functions to fline, need public for all ??
Definition: ObjectLine.h:95
virtual void ExecuteEvent(Int_t, Int_t, Int_t)
Definition: ObjectLine.h:161
virtual ~ObjectLineTendance()
Definition: ObjectLine.h:262
virtual void SetObjectStock(ListDataStockBase *, CommonXAxis *, Hparam_stock_t &)
used for from the listdata
Definition: ObjectLine.cxx:413
ClassDef(ObjectLine, 1)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Make all drawable modification, move by mouse and arrow.
Definition: ObjectLine.cxx:575
void SetBinEnd(Int_t bin_x1)
Definition: ObjectLine.h:285
virtual bool IsSupport() const
Definition: ObjectLine.h:134
void InitLine(double x0, double y0, double x1, double y1)
virtual void ClearObjectStock()
for the moment do nothing
Definition: ObjectLine.h:197
virtual bool IsLine()
Definition: ObjectLine.h:120
virtual void Paint(const Option_t *="")
Paint the objet, to overide.
Definition: ObjectLine.cxx:144
virtual void SetLineColor(Color_t color)
Definition: ObjectLine.h:114
virtual void SetTimes(time_t begin, time_t end)
Definition: ObjectLine.h:283
time_t ftbegin
set up once fbegin/fend, for update/save may be used
Definition: ObjectLine.h:244
TypeLine fTypeLine
TypeLine, enum : kNone, kSupport, kTendance, kFibo.
Definition: ObjectLine.h:48
virtual double GetXBorder(double y) const
specific for extrapolation return X value where border is crossed
Definition: ObjectLine.cxx:291
void SetOrigin(double &x, double &y)
Definition: ObjectLine.cxx:366
virtual double ExtrapolateYPad(double) const
extrapolate y fom line equation
Definition: ObjectLine.cxx:303
double GetY0() const
Definition: ObjectLine.h:97
virtual void Resize(unsigned int)
Definition: ObjectLine.h:142
void SetBinBegin(Int_t bin_x0)
Definition: ObjectLine.h:284
Used for free drawing of support/tendance Add a general line description with coeef_d and origin : y ...
Definition: ObjectLine.h:230
virtual std::vector< std::string > MakeStringForStatusBar(int px, int py) const
create the string for the StatusBar
Definition: ObjectLine.cxx:377
void FinaliseDrawableLine(CommonXAxis *fcommon_xaxis_th)
set up all data member after drawing.
Definition: ObjectLine.cxx:315
Abstract base class for the ListDataStock, for storing base pointers in vectors.
Definition: ListDataStock.h:50
void SetY1(double y1)
Definition: ObjectLine.h:103
virtual void SetObjectStock(ListDataStockBase *, CommonXAxis *, Hparam_stock_t &)
used for from the listdata
Definition: ObjectLine.h:155
std::string name_line
add a name, absent in AbstractObjectStock
Definition: ObjectLine.h:38
virtual int DistancetoPoint(int, int, double &, int=-1) const
called by THStock for anchoring.
Definition: ObjectLine.h:151
virtual ~ObjectLine()
destructor, should delete TLine explicitely
Definition: ObjectLine.h:72
void SetTimeT0(time_t begin)
Definition: ObjectLine.h:281
ClassDef(ObjectLineTendance, 1)
virtual bool IsHalfLine2()
Definition: ObjectLine.h:122
void SetX0(double x0)
Definition: ObjectLine.h:100
virtual void SetModekHalfLine1()
Definition: ObjectLine.h:128
Define an abstract base class for all objects to be painted in a THStock.
Int_t GetBinBegin() const
Definition: ObjectLine.h:278
double GetX1() const
Definition: ObjectLine.h:96
virtual void GetExtrema(double &min, double &max) const
return a constant value, could be in base ObjectLine
Definition: ObjectLine.h:193
virtual bool IsSegment()
Definition: ObjectLine.h:123
for all ObjectLines
Definition: ObjectLine.h:33
TypeLine
c++ 11 style, used by both EditorObjectStock and ObjectLine cannot make dictionary with enum class ! ...
void SetX1(double x1)
Definition: ObjectLine.h:101
Line for drawing with indicator, eg, RSI 30-70 Could be in Collection or in THStock They are fixed : ...
Definition: ObjectLine.h:178
void RecalcCoeff_origin(double x0, double x1)
mathematical functions
Definition: ObjectLine.cxx:245
ObjectLineTendance()
default constructor
Definition: ObjectLine.h:258
Int_t GetBinEnd() const
Definition: ObjectLine.h:279
int fbin_begin
memorize bin_x0, bin_x1, easier with slide
Definition: ObjectLine.h:246