33 fcommon_xaxis_th = 0 ;
42 TH1(name,title, size_axis ,(Float_t *)0), fcommon_xaxis_th(0)
45 std::cout <<
"Constructor THStock name and title and size only " << size_axis << std::endl;
59 TH1(name,title,ldata->GetSize(),(Float_t *)0)
62 std::cout <<
"\n\tEntry constructor THStock with ldata argument " << std::endl;
63 std::cout <<
"name " << name <<
" title " << title << std::endl;
69 std::cout <<
"In constructor get size xaxis " << GetXaxis()->
GetNbins() << std::endl;
85 std::cout <<
"Destructeur THStock " << std::endl;
101 std::cout <<
"\nEntry THStock::Copy\n" << std::endl;
109 std::cout <<
"\n\t THStock::DrawCopy " << std::endl;
110 TString opt = option;
113 if (gPad && !opt.Contains(
"same")) gPad->Clear();
116 newth->SetDirectory(0);
117 newth->SetBit(kCanDelete);
118 newth->AppendPad(option);
125 #ifdef DEBUG_OBJSTOCK
126 std::cout <<
"\n\tTHStock SetCommonXAxis " << new_xaxis << std::endl;
134 #ifdef DEBUG_OBJSTOCK
135 std::cout <<
"Entry THStock::operator= " << std::endl;
147 #ifdef DEBUG_OBJSTOCK
148 std::cout <<
"Entry THStock::GetListDataStock fullname " << std::endl;
151 std::cout <<
" name first " << (*it).first->
GetName() << std::endl;
152 if ( (*it).first->GetName() == shortname ) {
153 std::cout <<
"Found shortname" << std::endl;
167 for (
cit_pair it = it1; it != it2; ++it ) {
170 if ( (*it).first !=
nullptr ) {
183 #ifdef DEBUG_OBJSTOCK
184 std::cout <<
"\n\tTHStock::AddPairToVector" << std::endl;
185 std::cout <<
" ldata name " << ldata->
GetName() << std::endl;
188 std::pair< ListDataStockBase*, IndicatorObjectStock* > tmp_pair;
193 unsigned int size = 0;
195 std::cout <<
"size " << size << std::endl;
204 std::cout <<
"object is null " << std::endl;
214 object-> SetParent(
this );
217 tmp_pair = std::make_pair ( ldata,
object );
222 #ifdef DEBUG_OBJSTOCK
223 std::cout <<
"AddPair ldata/object " << ldata <<
" " <<
object << std::endl;
224 std::cout <<
"After push_back size " <<
vect_pair_obj.size() << std::endl;
233 #ifdef DEBUG_OBJSTOCK
234 std::cout <<
"\n\tTHStock::Add (ObjectLine ) obj_stock " << obj_stock << std::endl;
235 std::cout <<
"this->GetName() " << this->GetName() << std::endl;
237 std::cout <<
"obj X0 X1 " << obj_stock->
GetX0() <<
" " << obj_stock->
GetX1() << std::endl;
238 std::cout <<
"obj Y0 Y1 " << obj_stock->
GetY0() <<
" " << obj_stock->
GetY1() << std::endl;
243 vect_pair_obj.push_back( std::make_pair<ListDataStockBase*,AbstractObjectStock*>(
nullptr,obj_stock) );
244 #ifdef DEBUG_OBJSTOCK
245 std::cout <<
"After push_back size " <<
vect_pair_obj.size() << std::endl;
261 #ifdef DEBUG_OBJSTOCK
262 std::cout <<
"Entry AnchorToIndicator with object " << std::endl;
263 std::cout <<
" enum EStageDraw " << kDraw << std::endl;
264 std::cout <<
"px/py " << px <<
" / " << py << std::endl;
267 double y_anchor = -1;
268 double dist_y_anchor = 9999;
272 std::cout <<
"dist_y_anchor " << dist_y_anchor <<
"y_anchor " << y_anchor << std::endl;
277 obj_line->
SetY0( y_anchor );
280 obj_line->
SetY1( y_anchor );
295 #ifdef DEBUG_OBJSTOCK
296 std::cout <<
"Entry THStock::UpdateObjectStock() " << std::endl;
298 unsigned int size_ldata, size_object;
305 #ifdef DEBUG_OBJSTOCK
306 if ( ((*it_p).first) != nullptr ) {
307 std::cout <<
"ldata_name / size " << ((*it_p).first)->GetName() <<
" " << ((*it_p).first)->GetSize() << std::endl;
308 std::cout <<
"pointer to ldata " << (*it_p).first << std::endl;
310 std::cout <<
"size object "<< ((*it_p).second)->GetSize() << std::endl;
314 if ( ((*it_p).first) != nullptr ) {
315 size_ldata = ((*it_p).first)->GetSize();
316 std::cout <<
"sizeldata " << size_ldata << std::endl;
318 std::cout <<
"ObjectLine size = 0 " << std::endl;
321 size_object = ((*it_p).second)->GetSize();
327 if ( size_ldata > size_object ) {
329 std::cout <<
"need to resize ObjectStock to " << size_ldata <<
" Call Factory::Resize()" << std::endl;
330 new_size = size_ldata - size_object;
331 std::cout <<
" send to resize new_size " << new_size << std::endl;
334 ((*it_p).second)->Resize( new_size );
342 unsigned int nb_paint = 0;
344 if ( ((*it).second )->ToPaint() ) {
354 #ifdef DEBUG_OBJSTOCK
355 std::cout <<
"Entry THStock::HideNameListData fullname " << fullname <<
" toDelete " << toDelete << std::endl;
362 if ( (*it).first ==
nullptr ) {
363 std::cout <<
"found nullptr THStock::HideNameListData in to solve later " << std::endl;
364 std::cout <<
"case RSI " << std::endl;
365 std::cout <<
"name object " << ( (*it).second )->GetNameObject() << std::endl;
367 ( (*it).second )->SetToPaint(
false );
368 ( (*it).second )->ClearObjectStock();
372 if ( ( (*it).first )->GetFullName() == fullname ) {
375 ( (*it).second )->SetToPaint(
false );
378 ((*it).second)->ClearObjectStock();
382 std::cout <<
"THStock::HideNameListData option toDelete " << std::endl;
384 delete ( (*it).second );
390 std::cout <<
"THStock::HideNameListData not found" << std::endl;
395 #ifdef DEBUG_OBJSTOCK
396 std::cout <<
"Entry THStock::ShowNameListData " << fullname << std::endl;
401 if ( (*it).first ==
nullptr ) {
403 ((*it).second)->SetToPaint(
true );
404 std::cout <<
"nullptr case RSI " << std::endl;
408 if ( ( (*it).first )->GetFullName() == fullname ) {
409 ((*it).second)->SetToPaint(
true );
410 #ifdef DEBUG_OBJSTOCK
411 std::cout <<
"fund return true" << std::endl;
420 #ifdef DEBUG_OBJSTOCK
421 std::cout <<
"Entry THStock::SetColor " << color << std::endl;
422 std::cout <<
"ldata->GetName() " << ldata->
GetName() << std::endl;
427 std::cout << (*it).first << std::endl;
429 if ( (*it).first ==
nullptr )
432 if ( (*it).first == ldata ) {
438 if ( ((*it).second)->InheritsFrom(
"PStockLine") ) {
439 std::cout <<
"SetLineColor " << TColor::GetColor( color ) << std::endl;
440 ((*it).second)->SetLineColorObject( TColor::GetColor( color ) );
442 std::cout <<
"found return " << std::endl;
452 #ifdef DEBUG_OBJSTOCK
453 std::cout <<
"Entry THStock::SetColor " << color << std::endl;
454 std::cout <<
"TColor::GetColor( color ) " << TColor::GetColor( color ) << std::endl;
455 std::cout <<
"With fullname " << fname << std::endl;
463 if ( (*it).first ==
nullptr )
466 if ( (*it).first->GetFullName() == fname ) {
470 if ( ((*it).second)->InheritsFrom(
"PStockLine") ) {
473 ((
PStockLine*) ((*it).second))->SetLineColorObject( TColor::GetColor( color ) );
475 #ifdef DEBUG_OBJSTOCK
476 std::cout <<
"found return " << std::endl;
490 #ifdef DEBUG_OBJSTOCK
491 std::cout <<
"Entry THStock::GetDateFromBin bin " << bin << std::endl;
500 #ifdef DEBUG_OBJSTOCK
501 std::cout <<
"ldata " << ldata <<
" " << ldata->
GetName() << std::endl;
511 #ifdef DEBUG_OBJSTOCK
512 std::cout <<
"Entry THStock::GetBinFromPixel px " << px << std::endl;
555 #ifdef DEBUG_OBJSTOCK
556 std::cout <<
"\n\tEntry THStock::GetObjectExtrema " << std::endl;
569 if ( (*it).second->ToPaint() ) {
570 (*it).second->GetExtrema( min, max );
572 if ( max > ymax ) ymax = max;
573 if ( min < ymin ) ymin = min;
576 #ifdef DEBUG_OBJSTOCK
577 std::cout <<
"will return ymin " << ymin <<
" ymax " << ymax << std::endl;
590 Int_t dist_objstock = 9999;
597 if ( !((*it).second)->ToPaint() ) {
598 #ifdef DEBUG_OBJSTOCK
599 std::cout <<
"ToPaint false"<< std::endl;
609 if ( tmp_object == 0 ) {
610 #ifdef DEBUG_OBJSTOCK
611 std::cout <<
"\nYES CALLED ! tmp_object is null, continue\n" << std::endl;
615 if ( dist_objstock <= dist ) {
617 dist = dist_objstock;
634 #ifdef DEBUG_OBJSTOCK
635 std::cout <<
"Entry THStock::DistancetoPoint" << std::endl;
638 Int_t dist_objstock = 9999;
645 std::cout <<
"bin_x0 " << bin_x0 << std::endl;
650 if ( !((*it).second)->ToPaint() ) {
658 if ( indic_anchor_obj !=
nullptr ) {
663 dist_objstock = ((*it).second)->
DistancetoPoint( px, py, yvalue_tmp, bin_x0 );
666 if ( dist_objstock <= dist ) {
667 dist = dist_objstock;
669 std::cout <<
"set new dist " << dist <<
" yvalue " << yvalue << std::endl;
678 #ifdef DEBUG_OBJSTOCK
679 std::cout <<
"Exit THStock::DistancetoPoint final dist " << dist <<
" yvalue " << yvalue << std::endl;
688 #ifdef DEBUG_OBJSTOCK
689 std::cout <<
"\n\tEntry THStock::PaintObjectStock new version " << std::endl;
700 object = (*it).second;
707 #ifdef DEBUG_OBJSTOCK
708 std::cout <<
"ToPaint is False " << std::endl;
722 #ifdef DEBUG_OBJSTOCK
723 std::cout <<
"\n\tEntry THStock::SetObjectStock new version " << std::endl;
724 std::cout <<
" size of vect_pair " <<
vect_pair_obj.size() << std::endl;
735 object = (*it).second;
739 #ifdef DEBUG_OBJSTOCK
740 if ( ldata !=
nullptr ) {
741 std::cout <<
"Call ClearObjectStcok and SetObjectStock on " << ldata->
GetName() << std::endl;
743 std::cout <<
"pointer ldata is nullptr, it is a line objectstock " << std::endl;
757 object->ClearObjectStock();
virtual void Paint(const Option_t *="")=0
Paint the objet, to overide.
Derive from TH1 will draw the graph.
"Clever" enumeration of the ListDataStock type : StockCSV, Volume, EMA, BOLL,...
void SetObjectStock(Hparam_stock_t &Hparam_stock) const
set the object, need Hparam_stock here
ClassImp(THStock) THStock
unsigned int GetNTHStockToPaint() const
return the number of object to paint called by CanvasStock, but Why ?? want bool ??
static IndicatorObjectStock * CreateObjectStock(Indicator indic, std::string full_name_indic, unsigned int size, THStock *parent, std::string opt_string=std::string())
create indicator object
void AnchorToIndicator(const int &px, const int &py, ObjectLine *obj_line, FactoryObjectStock::EStageDraw kDraw)
set px, py to the closest indicator point
virtual void Add(ObjectLine *obj_stock)
call by Factory, specific to drawable line
virtual bool ToPaint() const
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
Use a policy PolicyChronologic, default VecNoChronologic.
void GetObjectExtrema(Double_t &ymin, Double_t &ymax) const
broadcast the call to all object
void PaintObjectStock(const Option_t *option="")
called from THisPainter when Hparam_sock has been completed
double GetX0() const
wrapper functions to fline, need public for all ??
Hparam_stock_t Hparam_stock
std::vector< std::pair< ListDataStockBase *, AbstractObjectStock * > >::const_iterator cit_pair
static Indicator GetIndicator(const std::string &str_name)
Constructor with a string label.
Define a base class for drawing indicator only, they are sorted in ListDataStock object.
Int_t GetBinFromPixel(Int_t px, Int_t &total_bin) const
called by ObjectStock, for StatusBar
std::vector< std::pair< ListDataStockBase *, AbstractObjectStock * > > vect_pair_obj
for storing pair<ListDataStock,ObjectStock>
virtual void AddPairToVector(ListDataStockBase *ldata)
create a IndicatorStock and add a new pair
virtual THStock * DrawCopy(Option_t *option="") const
ListDataStockBase * GetFirstListData() const
Get the first inserted ListDataStock, by THistPainterStock, needeed for size should add check...
std::vector< std::pair< ListDataStockBase *, AbstractObjectStock * > >::iterator it_pair
typedef for iterators
std::string Time_tToString(const time_t &time, const bool b_hour)
Return a string representing the date All times are expressed in the localtime.
void SetColor(ListDataStockBase *ldata, Pixel_t color) const
2 versions one with ldata or with fullname
time_t GetDateFromBin(Int_t bin) const
called by ObjectLine need the date from a bin
virtual void Copy(TObject &hnew) const
void SetCommonXAxis(CommonXAxis *new_xaxis)
called by CanvasStock to set a common axis for all thstock
CommonXAxis * fcommon_xaxis_th
pointer to the CommonXAxis Constructor and ownership done by CanvasStock
virtual unsigned int GetSize() const =0
Return the size of the vector.
static const int DIST_ANCHOR
maybe modifiable later
std::string GetName() const
ListDataStockBase * GetListDataStock(std::string fullname) const
want to retrieve from which pad is the fullname, call by CanvasStock
Abstract base class for the ListDataStock, for storing base pointers in vectors.
Int_t DistancetoPrimitive(Int_t px, Int_t py, TObject **obj)
call by THistPainterStock, broadcast call to all objects.
void HideNameListData(std::string fullname, bool toDelete)
called by CanvasStock
Define an abstract base class for all objects to be painted in a THStock.
Float_t fsize_title
size depend on the layout, used by THsitPainterStock
void ShowNameListData(std::string fullname) const
EStageDraw
define stages for drawing
virtual void UpdateObjectStock()
to redefine
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
const T & ChronologicAt(const unsigned int offset) const
Get the nth element in a chronological order.
THStock & operator=(const THStock &ht)
assignement operator tested ?? needed by dictionary ??