ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ObjectStock.h
Go to the documentation of this file.
1 
11 #ifndef _OBJECTSTOCK_H_
12 #define _OBJECTSTOCK_H_
13 
14 // include all base class
15 #include "AbstractObjectStock.h"
16 #include "EditorObjStock.h"
17 
18 #include <iostream>
19 #include <TLine.h>
20 
21 // declare ROOT types UInt_t
22 #include <Rtypes.h>
23 
24 // need typedef for type_value_data, still here for accessible but interface expects only double for SetValues
25 // to delete
26 //#include "ListObjectStock.h"
27 
35 {
36  protected :
37  //date could be retrieved from Parent, th_common_axis ?? pointer ToListDataStock better ??
38  time_t fdate;
39  // defined as float, other double
40  float fopen, fhigh, flow, fclose;
41  double fxmin, fxmax;
42 
45  std::vector<float> GetValues() const;
46 
47  public :
49  fdate = fopen = fhigh = flow = fclose = fxmin = fxmax = 0; }
50  // need a copy constructor for being in a vector ?? seems not, default is enought
51  //CandleStock( const CandleStock & rhs ) : fdate(rhs.fdate), fopen(rhs.fopen), fhigh(rhs.fhigh),
52  // flow(rhs.flow), fclose(rhs.fclose), fxmin(rhs.fxmin), fxmax(rhs.fxmax) {}
53  virtual ~CandleStock() {}
54 
55  // no name associated to each, could reconstruct on the fly if access to parent ListObjectStock
56  // could use a static const ?? here simple it is fixed
57  virtual std::string GetNameObject() const {return "Jap.C.";}
58  virtual std::vector<std::string> MakeStringForStatusBar( int px, int py ) const;
59 
60  virtual time_t GetDate() const { return fdate;}
61 
63  virtual void SetValues( UInt_t, std::vector<double> values,
64  Double_t xmin, Double_t xmax, time_t date, UInt_t opt_value = 0 );
65  virtual void GetExtrema( double & min, double & max ) const;
66 
68  virtual void ClearObjectStock() { kPaint = false; }
69 
71  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py, AbstractObjectStock** /*obj*/ );// const;
82  virtual Int_t DistancetoPoint(int px, int py, double &yvalue, int bin = -1) const;
83  // new, avoid gPad
84  //virtual Int_t DistancetoPoint(double value_x, double value_y, double & yvalue);
85  void virtual Paint( const Option_t* ="");
86 
87  ClassDef ( CandleStock, 1);
88 };
89 
95  {
96  protected :
97  // can make a copy of data, used ?? or retrieve on the fly ??
98  //could use parent to get the date ?? need more link, but could be good
99  time_t fdate;
100 
101  // new added fref_value,
102  // if true drawn from 0 to fvalue (histo MACD), default = false use gPad->Min ( volume )
103  // could use option to setup this
105  //value of the bar
106  double fvalue;
107  double fxmin, fxmax;
108 
111  std::vector<float> GetValues() const;
112 
113  public :
114  BarStock();
115  BarStock ( bool ref0 );
116  virtual ~BarStock () {}
117  // could use a static const ?? here simple it is fixed
118  virtual std::string GetNameObject() const {return "Bar";}
119  virtual std::vector<std::string> MakeStringForStatusBar( int px, int py ) const;
120 
122  virtual void ClearObjectStock() { kPaint = false; }
123 
124  virtual time_t GetDate() const { return fdate;}
125 
127  virtual void GetExtrema( double & min, double & max ) const;
128  //not all used (bin), but coherent for polymorphisme
129  virtual void SetValues( UInt_t bin, std::vector<double> values, Double_t xmin, Double_t xmax,
130  time_t date, UInt_t opt_value = 0 );
131 
132  virtual int DistancetoPrimitive( int px, int py, AbstractObjectStock** /*obj*/ );// const;
133  virtual int DistancetoPoint(int /*px*/, int /*py*/, double &yvalue, int bin = -1) const;
134  virtual void Paint( const Option_t* = "" );
135 
136  ClassDef( BarStock, 1);
137  };
138 
141 {
142  protected :
143  std::vector<double> plvalues;
145  std::vector<double> fx;
147  std::vector<time_t> dates;
148 
149  //math function, used for status bar only ??, keep Float, could be Double
150  float ExtrapolateYPad ( int px, int bin0, int bin1, float x0, float x1 ) const;
151 
152  // called only by MakeStringForStatusBar, could be private or protected
155  std::vector<float> GetValues( int px, int py, time_t &date ) const;
156 
157  public :
159  { std::cout << "Construtor Default PStockLine" << std::endl;}
160  // need a name, from indicator ??
161  PStockLine( UInt_t size );
162  // maybe not so good...
163  PStockLine( std::string name, unsigned size );
164  virtual ~PStockLine() { std::cout << "Destructor PStockLine" << std::endl;}
165 
166  virtual std::vector<std::string> MakeStringForStatusBar( int px, int py ) const;
167 
168  virtual unsigned int GetSize() const { return plvalues.size(); }
169  virtual void Resize( unsigned int new_size);
170 
172  virtual void GetExtrema( double & min, double & max ) const ;
173  virtual void SetValues( UInt_t bin, std::vector<double> values,
174  Double_t xmin, Double_t xmax, time_t date, UInt_t opt_value=0 );
175 
176 
177 
180  virtual void ClearObjectStock();
181 
182  // always called for selecting the object
183  virtual int DistancetoPrimitive(int px, int py, AbstractObjectStock** obj); // const;
184  int DistancetoPoint( int /*px*/, int py, double & yvalue, int /*bin*/ ) const;
185 
186  void virtual Paint( const Option_t* ="");
187  virtual void SetObjectStock( ListDataStockBase * ldata, CommonXAxis *fcommon_xaxis_th, Hparam_stock_t & Hparam_stock );
188 
189  ClassDef ( PStockLine, 1);
190 };
191 
199 {
200  protected :
202  std::vector<AbstractObjectStock *> vec_object;
203 
204  public :
206  CollectionObjectStock( std::string name ) : IndicatorObjectStock( name ) {}
207  CollectionObjectStock( unsigned int size, std::string name_contained= std::string(), bool ref0 = false );
208  virtual ~CollectionObjectStock();
209 
212  virtual void SetParent( THStock * thstock );
213 
214  // never called, the contained object are called directly
215  //virtual std::vector<std::string> MakeStringForStatusBar( int px, int py ) const;
216 
217  // re-implement IndicatorObjectStock function
218  virtual void AddToVecObject ( AbstractObjectStock * obj );
219 
220 
221  // used ?? seems not, in base ??
222  virtual unsigned int GetSize() const { return vec_object.size(); }
223  virtual void Resize( unsigned int new_size);
224 
225  // cannot make protected, because protected in Abstract
227  virtual void GetExtrema( double & min, double & max ) const ;
228  virtual void SetValues( UInt_t bin, std::vector<double> values,
229  Double_t xmin, Double_t xmax, time_t date, UInt_t opt_value = 0 );
230 
231  //if ListObjectStock should run this one
232  virtual void ClearObjectStock();
233 
234  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py, AbstractObjectStock** obj);
235  // because pure virtual in Abstract
236  virtual int DistancetoPoint(int /*px*/, int /*py*/, double & /*yvalue*/, int /*bin*/ = -1) const
237  { std::cout << "CollectionObjectStock::DistancetoPoint never called " << std::endl; return 9999; }
238 
239  virtual void Paint( const Option_t* = "");
240  virtual void SetObjectStock( ListDataStockBase * ldata, CommonXAxis *fcommon_xaxis_th, Hparam_stock_t & Hparam_stock );
241 
243 };
244 
245 
246 #endif // _OBJECTSTOCK_H_
int DistancetoPoint(int, int py, double &yvalue, int) const
called by THStock for anchoring.
virtual int DistancetoPoint(int, int, double &yvalue, int bin=-1) const
called by THStock for anchoring.
virtual time_t GetDate() const
Definition: ObjectStock.h:124
virtual void GetExtrema(double &min, double &max) const
Definition: ObjectStock.cxx:91
double fvalue
Definition: ObjectStock.h:106
virtual void ClearObjectStock()
Call ClearObject on every objects contained in the collection.
virtual void GetExtrema(double &min, double &max) const
override abstract base function
double fxmax
Definition: ObjectStock.h:41
virtual ~CollectionObjectStock()
virtual void ClearObjectStock()
different from Candle/Bar, delete the PstockLine.
virtual void Paint(const Option_t *="")
Paint the object.
time_t fdate
Definition: ObjectStock.h:99
Derive from TH1 will draw the graph.
Definition: THStock.h:59
virtual void Paint(const Option_t *="")
Paint the objet, to overide.
ClassDef(CandleStock, 1)
std::vector< float > GetValues(int px, int py, time_t &date) const
protected version, used by MakeStringForStatusBar difficult to extrapolate..., need optional bin2 ...
virtual void AddToVecObject(AbstractObjectStock *obj)
for all indicators, size and if update need to resize
virtual void SetObjectStock(ListDataStockBase *ldata, CommonXAxis *fcommon_xaxis_th, Hparam_stock_t &Hparam_stock)
called by , here need to send the correct ldata, but cannot split ldata so need to set up manually ...
Define Base classes for ObjectStock.
float fopen
Definition: ObjectStock.h:40
float fclose
Definition: ObjectStock.h:40
virtual unsigned int GetSize() const
Definition: ObjectStock.h:222
time_t fdate
Definition: ObjectStock.h:38
ClassDef(PStockLine, 1)
virtual std::string GetNameObject() const
pure-virtual access
Definition: ObjectStock.h:118
virtual void GetExtrema(double &min, double &max) const
overide base class
return values
Definition: ObjectStock.cxx:37
std::vector< time_t > dates
easy if date is here, still extrapolate data
Definition: ObjectStock.h:147
float fhigh
Definition: ObjectStock.h:40
std::vector< AbstractObjectStock * > vec_object
slight difference with ListObjectStock, here pointer to object, not object
Definition: ObjectStock.h:202
Hparam_stock_t Hparam_stock
virtual ~PStockLine()
Definition: ObjectStock.h:164
virtual std::string GetNameObject() const
pure-virtual access
Definition: ObjectStock.h:57
Define a base class for drawing indicator only, they are sorted in ListDataStock object.
virtual void GetExtrema(double &min, double &max) const
override the Abstract base class
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py, AbstractObjectStock **obj)
virtual void ClearObjectStock()
Set kPaint to false, keep in memory.
Definition: ObjectStock.h:68
virtual int DistancetoPoint(int, int, double &, int=-1) const
called by THStock for anchoring.
Definition: ObjectStock.h:236
virtual void SetObjectStock(ListDataStockBase *ldata, CommonXAxis *fcommon_xaxis_th, Hparam_stock_t &Hparam_stock)
used for from the listdata
virtual void Paint(const Option_t *="")
realize the painting, not setting the values
bool fref0_value
Definition: ObjectStock.h:104
bool kPaint
set to true if the object need be draw or not depend on common_xaxis and user input ( slider ) used b...
double fxmax
Definition: ObjectStock.h:107
double fxmin
Definition: ObjectStock.h:41
virtual Int_t DistancetoPoint(int px, int py, double &yvalue, int bin=-1) const
specific, called only by ListDataStock do not use bin, but follow the hierarchy pixel better return a...
virtual time_t GetDate() const
Definition: ObjectStock.h:60
virtual std::vector< std::string > MakeStringForStatusBar(int px, int py) const
create the string for the StatusBar
Definition: ObjectStock.cxx:40
float ExtrapolateYPad(int px, int bin0, int bin1, float x0, float x1) const
CollectionObjectStock(std::string name)
Definition: ObjectStock.h:206
virtual ~CandleStock()
Definition: ObjectStock.h:53
std::vector< float > GetValues() const
return the 4 values of a candle use fby MakeStringForStatus and GetExtrema
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py, AbstractObjectStock **)
always called from ListObjectStock, aadd **pointer to overide abstract base, but not used ...
ClassDef(CollectionObjectStock, 1)
virtual int DistancetoPrimitive(int px, int py, AbstractObjectStock **obj)
used for selection of object, for const need attention to the pointer
virtual void SetValues(UInt_t, std::vector< double > values, Double_t xmin, Double_t xmax, time_t date, UInt_t opt_value=0)
implementeation of pure virtual in Abstract, need double here
Definition: ObjectStock.cxx:67
virtual int DistancetoPrimitive(int px, int py, AbstractObjectStock **)
used for selection of object, for const need attention to the pointer
virtual std::vector< std::string > MakeStringForStatusBar(int px, int py) const
create the string for the StatusBar
float flow
Definition: ObjectStock.h:40
virtual void SetParent(THStock *thstock)
different from AbstractObjectStock, broadcast to all, needed ? could set to himself as well ...
virtual std::vector< std::string > MakeStringForStatusBar(int px, int py) const
create the string for the StatusBar
virtual unsigned int GetSize() const
Definition: ObjectStock.h:168
Abstract base class for the ListDataStock, for storing base pointers in vectors.
Definition: ListDataStock.h:50
std::vector< double > fx
x coordinates, middle of the bin for painting
Definition: ObjectStock.h:145
double fxmin
Definition: ObjectStock.h:107
virtual void Paint(const Option_t *="")
Paint one candle.
virtual ~BarStock()
Definition: ObjectStock.h:116
virtual void SetValues(UInt_t bin, std::vector< double > values, Double_t xmin, Double_t xmax, time_t date, UInt_t opt_value=0)
Set the values .
Define an abstract base class for all objects to be painted in a THStock.
std::vector< double > plvalues
Definition: ObjectStock.h:143
virtual void Resize(unsigned int new_size)
std::vector< float > GetValues() const
return 1 one value in a vector used by MakeStringForStatus and GetExtrema
virtual void ClearObjectStock()
set kPaint to false, keep in memory
Definition: ObjectStock.h:122
virtual void SetValues(UInt_t bin, std::vector< double > values, Double_t xmin, Double_t xmax, time_t date, UInt_t opt_value=0)
ClassDef(BarStock, 1)
virtual void Resize(unsigned int new_size)
Draw Jap.
Definition: ObjectStock.h:34
virtual void SetValues(UInt_t bin, std::vector< double > values, Double_t xmin, Double_t xmax, time_t date, UInt_t opt_value=0)