ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractObjectStock.h
Go to the documentation of this file.
1 
17 #ifndef _ABSTRACTOBJECTSTOCK_H_
18 #define _ABSTRACTOBJECTSTOCK_H_
19 
20 // seems to affect many others, even THIstPainterStock and others !! should be in *.cxx
21 // boring affects as well controller ! by Canvas, THStock ??
22 //#undef DEBUG
23 
24 #include <iostream>
25 // seems Option_t is a type declared inside
26 #include "Rtypes.h"
27 #include <TObject.h>
28 #include <TAttLine.h>
29 
30 #include "../../utils/Indicator.h"
31 #include "../Hparam_stock.h"
32 
33 class ListDataStockBase;
34 class CommonXAxis;
35 class THStock;
36 
37 // need typedef from DataStock, to delete interface clear now. Here allow access for SetObjectStock
38 //#include "ListObjectStock.h"
39 //typedef double type_value_data;
40 
41 // Strange behaviour for inheriting function in protected
42 // Should check in book, what s the best to use
43 // try different way in ObjectStock with GetExtrema,SetValues, can add other GetDate
44 // \todo make clear derivative of protected function
45 
60 // TObject important for general function,
61 // cannot avoid for function gPad->SetSelected( Object * )
62 // would need to rewrite ( short function ) TPad SetSelected, TCanvas SetSelected
63 // polymorphisme, easy to reuse, logic to derive from TObject but limited to ROOT
65 {
66  protected :
68 
69  // called for DistanceX, what's the best ??
70  // called for Finalize drawing of ObjectLine ? no only CommonXAxis
71  // not for DistancetoPoint THStock call the object
73 
77  bool kPaint;
78 
79  public :
81 
84  virtual ~AbstractObjectStock() {};
85  // should have the same return, but not if pure virtual
87  virtual std::string GetNameObject() const = 0;
88  // not necessary yet, only factory set the name
89  //virtual std::string SetNameObject() const = 0;
90 
92  virtual THStock * GetParent () const { return fParentTHStock;}
93  virtual void SetParent ( THStock *thstock ) {fParentTHStock = thstock;}
94 
96  virtual void SetToPaint( bool k ) { kPaint = k;}
97  virtual bool ToPaint() const { return kPaint;}
98 
100 
102  virtual std::vector<std::string> MakeStringForStatusBar( int /*px*/, int /*py*/ ) const = 0;
103 
104  // When THStock must contain AbstractObjectStock *
105  // needed for THStock::UpdateStock, need the initial size, really ??
106  virtual unsigned int GetSize() const {return 0;}
107  virtual void Resize( unsigned int /*new_size*/ ) {std::cout << "AbstractObjectStock::Resize to overide !" << std::endl;}
108  //virtual void Resize( unsigned int /*new_size*/ ) = 0;
109 
110  // ccould be protected, but problem with derived CandleStock ??
114  // force double here
115  virtual void SetValues( unsigned int bin, std::vector<double> values, double xmin, double ymax, time_t date, unsigned int opt_value = 0) = 0;
116  virtual void GetExtrema( double & /*min*/, double & /*max*/ ) const = 0;
117 
119  // if virtual, need implemented by Candle and Bar, otherwise Candle is abstract !
120  virtual void SetObjectStock( ListDataStockBase * /*ldata*/, CommonXAxis */*fcommon_xaxis_th*/, Hparam_stock_t & /*Hparam_stock*/ ) {} //= 0;
122  // to make virtual
123  virtual void ClearObjectStock() = 0; //{std::cout << "AbstractObjectStock::ClearObjectStock to overide !" << std::endl;} //= 0;
124 
126 
127  // fully implemented in derived class
129  virtual Int_t DistancetoPrimitive( int /*px*/, int /*py*/, AbstractObjectStock** /*obj*/) = 0;//const = 0;
130 
143  virtual int DistancetoPoint(int /*px*/, int /*py*/, double & /*y_value*/, int bin = -1) const = 0; //{return 9999;}
144 
146  virtual void Paint( const Option_t* = "") = 0;
147 
151  virtual void SetLineColorObject(Color_t /*lcolor*/) {
152  std::cout << "SetLineColorObject abstract !" << std::endl;
153  }
154 
155  // print a warning during run-time if not dict for cint
157 };
158 
169 {
171  protected :
174  std::string name_indic;
175 
178  void ComputeBinRange ( ListDataStockBase *ldata, CommonXAxis *fcommon_xaxis_th, Hparam_stock_t & Hparam_stock,
179  unsigned int & xfirst, unsigned int & xlast, int & shift_left );
180 
181  public :
183  // base class paint or not by default, not in this construction
185  IndicatorObjectStock( std::string name) : AbstractObjectStock (), name_indic( name ) {}
187 
188  // base class provides its own name, could Override GetName() from TObject as well
189  // complains for PStockLine, should be overridden
190  // ok compiles now, but should be overiddenn any way
192  // should work for PStockLine, Collection not sure or add something
193  virtual std::string GetNameObject() const { return name_indic; }
194  // new added never called yet ??
195  // ref is not dangerous ?? should not ??
196  virtual void SetNameObject( std::string & new_name ) { name_indic = new_name;}
197 
198  //should be implemented,, not by List and Collection
199  virtual std::vector<std::string> MakeStringForStatusBar( int /*px*/, int /*py*/ ) const {
200  std::cout << "IndicatorStock:: MakeString for status bar to override" << std::endl;
201  std::vector<std::string> toto; return toto;
202  }
203 
204  //virtual unsigned int GetSize() const {return 0;}
205 // virtual void Resize( unsigned int /*new_size*/ ) {
206 // std::cout << "IndicatorObjectStock::Resize to override, do nothing" << std::endl;}
207 
208  // only Indicator ?? or in Abstract ?
209  // need to loop over a list ( only Indicator )
210  // implements abstract function, ok virtual work with ListObjectStock
211  virtual void ClearObjectStock() {
212 #ifdef DEBUG_OBJSTOCK
213  std::cout << "\nIndicatorObjectStock::ClearObjectStock SHOULD NOT BE CALLED, to override\n" << std::endl;
214 #endif
215  }
216 
218  // implements here, or in derived, array could be in derived class
219  // changed unsigned int to void, otherwise return nothing
220  // same than base class...not needed or only here, not in base class
221  /*virtual unsigned int GetSize() const {
222  std::cout << "IndicatorObjectStock::GetSize return 0" << std::endl;
223  return 0;}
224  */
225  //virtual void Resize( Indicator /*indic*/, unsigned int /*new_size*/) {}
226  //virtual void Resize( unsigned int /*new_size*/ ) {}
227 
228  // who called ?? only Factory with Collection only
229  virtual void AddToVecObject ( AbstractObjectStock* /*obj*/) {}
230 
234  virtual void SetLineColorObject(Color_t lcolor) {
235  std::cout << "SetLineColorObject from IndicatorObjectStock, color " << lcolor << std::endl;
236  SetLineColor( lcolor );
237  }
238  // seems fine, to delete
240  //virtual void SetObjectStock( ListDataStockBase * /*ldata*/, CommonXAxis */*fcommon_xaxis_th*/ ) {}
241 };
242 
243 #endif
virtual ~AbstractObjectStock()
virtual default destructor, needed
virtual void SetLineColorObject(Color_t)
virtual void Paint(const Option_t *="")=0
Paint the objet, to overide.
virtual void GetExtrema(double &, double &) const =0
Derive from TH1 will draw the graph.
Definition: THStock.h:59
std::string name_indic
add a name to the base class convenient to get a indicator, can retrieve from the name...
virtual void AddToVecObject(AbstractObjectStock *)
for all indicators, size and if update need to resize
virtual void SetParent(THStock *thstock)
virtual void ClearObjectStock()=0
general function called when drawing
virtual std::string GetNameObject() const =0
pure-virtual access
virtual bool ToPaint() const
return values
Definition: ObjectStock.cxx:37
virtual std::vector< std::string > MakeStringForStatusBar(int, int) const =0
create the string for the StatusBar
Hparam_stock_t Hparam_stock
virtual std::string GetNameObject() const
IndicatorObjectStock(std::string name)
Define a base class for drawing indicator only, they are sorted in ListDataStock object.
void ComputeBinRange(ListDataStockBase *ldata, CommonXAxis *fcommon_xaxis_th, Hparam_stock_t &Hparam_stock, unsigned int &xfirst, unsigned int &xlast, int &shift_left)
set up bin first/ last.
virtual Int_t DistancetoPrimitive(int, int, AbstractObjectStock **)=0
used for selection of object, for const need attention to the pointer
virtual void ClearObjectStock()
general function called when drawing
virtual void SetNameObject(std::string &new_name)
ClassDef(AbstractObjectStock, 1)
bool kPaint
set to true if the object need be draw or not depend on common_xaxis and user input ( slider ) used b...
virtual std::vector< std::string > MakeStringForStatusBar(int, int) const
create the string for the StatusBar
virtual void SetValues(unsigned int bin, std::vector< double > values, double xmin, double ymax, time_t date, unsigned int opt_value=0)=0
more general call for setting the values, even ObjectLine ?? no use/need but maybe if protected probe...
virtual void SetToPaint(bool k)
Public access to kPaint.
virtual void SetObjectStock(ListDataStockBase *, CommonXAxis *, Hparam_stock_t &)
used for from the listdata
Abstract base class for the ListDataStock, for storing base pointers in vectors.
Definition: ListDataStock.h:50
virtual int DistancetoPoint(int, int, double &, int bin=-1) const =0
called by THStock for anchoring.
Define an abstract base class for all objects to be painted in a THStock.
virtual unsigned int GetSize() const
AbstractObjectStock()
default constructor
virtual void Resize(unsigned int)
virtual THStock * GetParent() const
public access to parent THStock
virtual void SetLineColorObject(Color_t lcolor)
called by THStock::SetColor