ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractObjectStock.cxx
Go to the documentation of this file.
1 
8 #include "AbstractObjectStock.h"
9 
10 #include "THStock.h"
11 
12 // For ROOT dictionary
14 
15 // this function is set up in the header file !
16 // just need to include THStock in the header
17 // could be deleted...all the file !
19 {
20 /*
21 #ifdef DEBUG
22  std::cout << "Entry Constructor AbstractObjectStock " << std::endl; // fname << std::endl;
23 #endif
24 */
25  kPaint = true;
26  fParentTHStock=0;
27 }
28 
29 // less ambitious, just regroup the computation but keeps Hparam_stock for test
31  unsigned int & xfirst, unsigned int & xlast, int & shift_left )
32 {
33 #ifdef DEBUG_OBJSTOCK
34  std::cout << "\n Entry IndicatorObjectStock::ComputeBinRange " << std::endl;
35  std::cout << "Compare Hparam.xlast " << Hparam_stock.xlast << std::endl;
36  std::cout << "Faxis->GetLast() " << fcommon_xaxis_th->GetLast() << std::endl;
37  std::cout << "Compare Hparam.xfirst " << Hparam_stock.xfirst << std::endl;
38  std::cout << "Faxis->GetFirst() " << fcommon_xaxis_th->GetFirst() << std::endl;
39 #endif
40 
41  // not modified, not needed here
42  xlast = Hparam_stock.xlast;
43 
44  // xlast as computed in THistPainterStock, not recomputed after
45  // for the moment, not dependent of the listdata, common on Hparam_stock
46  //if ( Hparam_stock.shift_futur > 0 ) {
47  // Hparam_stock.xlast = TMath::Min ( Hparam_stock.xlast, size_data_listd + Hparam_stock.shift_left );}
48 
49  //seems fine with fcommon_xaxis
50  xfirst = fcommon_xaxis_th->GetFirst();
51 
52  // for sure dependent on the ldata, needed here
53  unsigned int size_data = ldata->GetSize();
54  // can access from common_xaxis
55  unsigned int size_axis = fcommon_xaxis_th->GetNbins();
56  // or Hparam_stock.shift_futur is in fcommon_axis as well maybe not needed ??
57  shift_left = size_axis - size_data - fcommon_xaxis_th->GetShift();
58 
59 #ifdef DEBUG_OBJSTOCK
60  std::cout << "First assign xfirst/xlast " << xfirst << " " << xlast << std::endl;
61  std::cout << "shift_left " << shift_left << std::endl;
62 #endif
63 
64  // original method, never override the value of Hparam_stock.xfirst
65  xfirst = Hparam_stock.xfirst + shift_left;
66 
67  //modify xfirst if the begin slider is > 1
68  if ( Hparam_stock.xfirst > 1 ) {
69 #ifdef DEBUG_OBJSTOCK
70  std::cout << " > 1 modify xfirst" << std::endl;
71  std::cout << "tmp xfirst " << xfirst << std::endl;
72 #endif
73  xfirst = xfirst - ( Hparam_stock.xfirst - 1 );
74  // Assure not larger than the axis
75  // seems good...
76  xfirst = TMath::Max ( (int)xfirst, (int)Hparam_stock.xfirst );
77 #ifdef DEBUG_OBJSTOCK
78  } else {
79  std::cout << "xfirst not modified " << std::endl;
80 #endif
81  }
82 
83 #ifdef DEBUG_OBJSTOCK
84  std::cout << "used GetShift() " << fcommon_xaxis_th->GetShift() << std::endl;
85  std::cout << "will return xfirst/xlast " << xfirst << " " << xlast << std::endl;
86  std::cout << "will return shift_left " << shift_left << std::endl;
87 #endif
88 
89 }
90 
91 // too ambitious, try to cover all cases without Hparam, will spend lots of time to debug
92 /*
93 void IndicatorObjectStock::ComputeBinRange_test ( ListDataStockBase *ldata, CommonXAxis *fcommon_xaxis_th,
94  unsigned int & xfirst, unsigned int & xlast, int & shift_left )
95 {
96 #ifdef DEBUG
97  std::cout << "\n Entry IndicatorObjectStock::ComputeBinRange " << std::endl;
98 #endif
99 
100  xfirst = fcommon_xaxis_th->GetFirst();
101  xlast = fcommon_xaxis_th->GetLast();
102  // problem with approximation in fXaxis->GetBinLowEdge(last)+fXaxis->GetBinWidth(last);
103  // no access to xmax here
104  //if ( ( ( Hparam_stock.xmax < ((Double_t)1.0001)) && ( Hparam_stock.xmax > ((Double_t)0.9999) ) ) && ( Hparam_stock.shift_futur > 0 ) ) {
105  // here strange way to do, but maybe the best ??
106  //Hparam_stock.xlast -= Hparam_stock.shift_futur;
107 
108 
109 
110  // for sure dependent on the ldata, needed here
111  unsigned int size_data = ldata->GetSize();
112  // can access from common_xaxis
113  unsigned int size_candle = fcommon_xaxis_th->GetNbins();
114  // or Hparam_stock.shift_futur is in fcommon_axis as well maybe not needed ??
115  //int shift_left = size_candle - size_data - Hparam_stock.shift_futur;
116  shift_left = size_candle - size_data - fcommon_xaxis_th->GetShift();
117 
118 #ifdef DEBUG
119  std::cout << "First assign xfirst/xlast " << xfirst << " " << xlast << std::endl;
120  std::cout << "shift_left " << shift_left << std::endl;
121 #endif
122 
123  // not sure of the algorithm here
124  unsigned int copy_xfirst = xfirst;
125  // now special case
126  xfirst = xfirst + shift_left;
127 
128  //modify xfirst if needed, which case ??
129  if ( copy_xfirst > 1 ) {
130  std::cout << " > 1 modify xfirst" << std::endl;
131  xfirst = xfirst - ( copy_xfirst - 1 );
132  // Assure not larger than the axis
133  // yes cannot use Hparam.xfirst if there is a shift_left
134  // seems good
135  xfirst = TMath::Max ( xfirst, copy_xfirst );
136  }
137 
138  // modify xlast, because GetLast takes into account the futur
139  // need access to Hparam_stock.xmax, to know if the slider is seeing futur
140  // not enougth, need to know the position of the last slider
141  if ( ( fcommon_xaxis_th->GetShift() > 0 ) && ( fcommon_xaxis_th->GetNbins() > size_data ) ) {
142  xlast -= fcommon_xaxis_th->GetShift();
143  }
144 
145 
146 #ifdef DEBUG
147  std::cout << "used GetShift() " << fcommon_xaxis_th->GetShift() << std::endl;
148  std::cout << "will return xfirst/xlast " << xfirst << " " << xlast << std::endl;
149  std::cout << " shift_left " << shift_left << std::endl;
150 #endif
151 
152  return;
153 }
154 */
ClassImp(AbstractObjectStock) AbstractObjectStock
Define Base classes for ObjectStock.
Hparam_stock_t Hparam_stock
Int_t GetLast()
Definition: CommonXAxis.h:79
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.
class for drawing graph
virtual unsigned int GetSize() const =0
Return the size of the vector.
Abstract base class for the ListDataStock, for storing base pointers in vectors.
Definition: ListDataStock.h:50
Int_t GetNbins()
Definition: CommonXAxis.h:77
Int_t GetShift() const
Definition: CommonXAxis.h:71
Define an abstract base class for all objects to be painted in a THStock.
Int_t GetFirst()
Definition: CommonXAxis.h:78