ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
THStock.h
Go to the documentation of this file.
1 
10 #ifndef ROOT_THStock
11 #define ROOT_THStock
12 
13 #include <TH1.h>
14 
15 // need Factory to pass the stage when drawing
16 //#include "AbstractObjectStock.h"
17 //#include "ObjectLine.h"
18 
19 // import almost all ObjectStock, only for Factory::Drawstage
20 #include "FactoryObjectStock.h"
21 
22 //#include "TObject.h" // stupid only for Pixel_t
23 #include <TPad.h>
24 
25 // should be moved to ObjectStock ? or stay with THistPainter ? moved as well ?
26 #include "../Hparam_stock.h"
27 // still include other file in the library, certainly to move into ObjectStock
28 #include "../Hoption_stock.h"
29 // for test maybe good later, not used
30 //#include <Hoption.h>
31 
32 #include "../../src_cpp/ListDataStock.h" //why class not working, template ??
33 
34 // works like this for rootcint, otherwise no class found ?? strange
35 class CommonXAxis;
36 // why need to give ./ for rootcint ?
37 #include "../CommonXAxis.h"
38 /*
39 class AbstractObjectStock;
40 class ObjectLine;
41 class IndicatorObjectStock;
42 */
43 
59 class THStock : public TH1
60 {
61  private:
62 
64  typedef std::vector< std::pair<ListDataStockBase*, AbstractObjectStock*> >::iterator it_pair;
65  typedef std::vector< std::pair<ListDataStockBase*, AbstractObjectStock*> >::const_iterator cit_pair;
66 
68  static const int DIST_ANCHOR = 15;
69 
71  std::vector< std::pair<ListDataStockBase*, AbstractObjectStock*> > vect_pair_obj;
72 
76 
78  Float_t fsize_title;
79 
80  //call to factory should be in controller ??
82  virtual void AddPairToVector ( ListDataStockBase * ldata );
83 
84  public:
86  THStock();
87  THStock ( const char* name, const char* title, int size );
88  THStock ( const char* name, const char* title, ListDataStockBase * ldata );
89  THStock ( const THStock& ht );
90  virtual ~THStock();
92  THStock& operator=(const THStock& ht);
93 
94  //feature used by copy constructor (and other?)
95  virtual void Copy(TObject& hnew) const;
96  virtual THStock* DrawCopy(Option_t* option = "") const;
97 
98  // could be inlined, keep in function for output debug
100  void SetCommonXAxis( CommonXAxis * new_xaxis );
102 
103  void SetSizeTitle (Float_t new_size) {
104  //std::cout << "SetSizeTitle " << new_size << std::endl;
105  fsize_title = new_size; }
106  Float_t GetSizeTitle () const { return fsize_title; }
107 
108  // used ?? seems not !! to delete
109  // std::string GetNameListData ( const AbstractObjectStock * obj );
110 
111  // new version to keep, is old now to delete
112  //virtual void DeleteOneStock ( Int_t npad );
113 
118  ListDataStockBase * GetListDataStock ( std::string fullname ) const;
119 
121  unsigned int GetSizeVectPair() const { return vect_pair_obj.size(); }
123  virtual void UpdateObjectStock(); // unsigned int new_size ); //( int new_size );
124  // why cannot compile make_pair with Abstract ??
126  virtual void Add ( ObjectLine * obj_stock );
128  virtual void Add ( ListDataStockBase * ldata ) {
129 #ifdef DEBUG_CONT_FRAME
130  std::cout << "THStock::Add (ListDataStockBase *)" << std::endl;
131 #endif
132  AddPairToVector ( ldata );
133  }
134 
136  double GetXPadFromBin( int bin) { return gPad->XtoPad( fcommon_xaxis_th->GetXAxis()->GetBinCenter(bin) ) ;}
140  unsigned int GetNTHStockToPaint () const;
141 
142  // convenient for only drawing 1 THStock from interpreter, script...
143  // here no problem with CAC40_DAY and DJ_DAY
145  void HideNameListData ( std::string fullname, bool toDelete );
146  void ShowNameListData ( std::string fullname ) const;
147 
149  void SetColor ( ListDataStockBase * ldata, Pixel_t color ) const;
151  void SetColor ( std::string fullname, Pixel_t color ) const;
152 
153 
155  time_t GetDateFromBin ( Int_t bin ) const;
156  // not used anymore
157  //Int_t GetBinFromDate ( time_t date, Hparam_stock_t &Hparam_stock ) const;
159  Int_t GetBinFromPixel ( Int_t px, Int_t &total_bin ) const;
162  // do not like reference bin2 with default ??
163  // should regroup with other methods
164  time_t GetDateBinFromPixel ( Int_t px, Int_t py, Int_t &bin, Int_t &bin2 ) const;
165 
167  void GetObjectExtrema( Double_t & ymin, Double_t & ymax ) const;
169  void AnchorToIndicator( const int & px, const int & py, ObjectLine * obj_line, FactoryObjectStock::EStageDraw kDraw );
170 
172 
178  // if override problem with const ?? to check
179  Int_t DistancetoPrimitive(Int_t px, Int_t py, TObject** obj);
184  Int_t DistancetoPoint(Int_t px, Int_t py, Double_t &yvalue ) const;
186  void PaintObjectStock (const Option_t* option = "" );
189 
190  // need for dictionary or use LinkDef ??
191  ClassDef(THStock,0);
192 };
193 
194 #endif /* ROOT_THStock */
double GetXPadFromBin(int bin)
Xvalue of the bin center, called by PStockLine to Extrapolate values.
Definition: THStock.h:136
Derive from TH1 will draw the graph.
Definition: THStock.h:59
void SetObjectStock(Hparam_stock_t &Hparam_stock) const
set the object, need Hparam_stock here
Definition: THStock.cxx:720
unsigned int GetNTHStockToPaint() const
return the number of object to paint called by CanvasStock, but Why ?? want bool ??
Definition: THStock.cxx:340
ClassDef(THStock, 0)
THStock()
Constructors.
unsigned int GetSizeVectPair() const
get size of the container
Definition: THStock.h:121
void AnchorToIndicator(const int &px, const int &py, ObjectLine *obj_line, FactoryObjectStock::EStageDraw kDraw)
set px, py to the closest indicator point
Definition: THStock.cxx:259
virtual void Add(ObjectLine *obj_stock)
call by Factory, specific to drawable line
Definition: THStock.cxx:231
CommonXAxis * GetCommonXAxis()
Definition: THStock.h:101
Int_t DistancetoPoint(Int_t px, Int_t py, Double_t &yvalue) const
used by anchor to find a Yvalue is close and anchor to it
Definition: THStock.cxx:632
void GetObjectExtrema(Double_t &ymin, Double_t &ymax) const
broadcast the call to all object
Definition: THStock.cxx:553
void PaintObjectStock(const Option_t *option="")
called from THisPainter when Hparam_sock has been completed
Definition: THStock.cxx:686
Hparam_stock_t Hparam_stock
std::vector< std::pair< ListDataStockBase *, AbstractObjectStock * > >::const_iterator cit_pair
Definition: THStock.h:65
virtual void Add(ListDataStockBase *ldata)
copy from diff, ok was missing, called by CanvasStock
Definition: THStock.h:128
Int_t GetBinFromPixel(Int_t px, Int_t &total_bin) const
called by ObjectStock, for StatusBar
Definition: THStock.cxx:509
std::vector< std::pair< ListDataStockBase *, AbstractObjectStock * > > vect_pair_obj
for storing pair<ListDataStock,ObjectStock>
Definition: THStock.h:71
virtual void AddPairToVector(ListDataStockBase *ldata)
create a IndicatorStock and add a new pair
Definition: THStock.cxx:181
virtual THStock * DrawCopy(Option_t *option="") const
Definition: THStock.cxx:107
ListDataStockBase * GetFirstListData() const
Get the first inserted ListDataStock, by THistPainterStock, needeed for size should add check...
Definition: THStock.cxx:161
std::vector< std::pair< ListDataStockBase *, AbstractObjectStock * > >::iterator it_pair
typedef for iterators
Definition: THStock.h:64
void SetColor(ListDataStockBase *ldata, Pixel_t color) const
2 versions one with ldata or with fullname
Definition: THStock.cxx:418
time_t GetDateFromBin(Int_t bin) const
called by ObjectLine need the date from a bin
Definition: THStock.cxx:488
void SetSizeTitle(Float_t new_size)
Definition: THStock.h:103
Float_t GetSizeTitle() const
Definition: THStock.h:106
TAxis * GetXAxis()
Definition: CommonXAxis.h:54
virtual void Copy(TObject &hnew) const
Definition: THStock.cxx:99
void SetCommonXAxis(CommonXAxis *new_xaxis)
called by CanvasStock to set a common axis for all thstock
Definition: THStock.cxx:123
CommonXAxis * fcommon_xaxis_th
pointer to the CommonXAxis Constructor and ownership done by CanvasStock
Definition: THStock.h:75
static const int DIST_ANCHOR
maybe modifiable later
Definition: THStock.h:68
ListDataStockBase * GetListDataStock(std::string fullname) const
want to retrieve from which pad is the fullname, call by CanvasStock
Definition: THStock.cxx:145
virtual ~THStock()
Definition: THStock.cxx:82
Abstract base class for the ListDataStock, for storing base pointers in vectors.
Definition: ListDataStock.h:50
Factory for all Object.
Int_t DistancetoPrimitive(Int_t px, Int_t py, TObject **obj)
call by THistPainterStock, broadcast call to all objects.
Definition: THStock.cxx:581
void HideNameListData(std::string fullname, bool toDelete)
called by CanvasStock
Definition: THStock.cxx:352
Float_t fsize_title
size depend on the layout, used by THsitPainterStock
Definition: THStock.h:78
void ShowNameListData(std::string fullname) const
Definition: THStock.cxx:393
for all ObjectLines
Definition: ObjectLine.h:33
EStageDraw
define stages for drawing
virtual void UpdateObjectStock()
to redefine
Definition: THStock.cxx:293
time_t GetDateBinFromPixel(Int_t px, Int_t py, Int_t &bin, Int_t &bin2) const
return both the date and two bins called only ObjectLine::GetValues
Definition: THStock.cxx:531
THStock & operator=(const THStock &ht)
assignement operator tested ?? needed by dictionary ??
Definition: THStock.cxx:132