11 #include "../utils/FullName.h"
19 TCanvas( name, ww, wh, winid ), fcommon_xaxis_cs(0)
21 #ifdef DEBUG_CONT_FRAME
22 std::cout <<
" Entry Constructor CanvasStock name " << name <<
" winid " << winid << std::endl;
29 #ifdef DEBUG_CONT_FRAME
30 std::cout <<
"just created axis, size " << fcommon_xaxis_cs->GetNbins() << std::endl;
35 TVirtualHistPainter::SetPainter(
"THistPainterStock");
40 TCanvas( name, title, ww, wh ), fcommon_xaxis_cs(0)
42 #ifdef DEBUG_CONT_FRAME
43 std::cout <<
" Entry Constructor Not Embedded CanvasStock name " << name << std::endl;
52 TVirtualHistPainter::SetPainter(
"THistPainterStock");
71 #ifdef DEBUG_CONT_FRAME
72 std::cout <<
"Destructor default CanvasStock" << std::endl;
77 std::vector<THStock*>::iterator it;
104 #ifdef DEBUG_CONT_FRAME
105 std::cout <<
"Entry CanvasStock::GetNPadToPaint() vecTHStock size " <<
vecTHStock.size() << std::endl;
107 UInt_t nbpad_topaint = 0;
110 for (
unsigned int i=0; i <
vecTHStock.size(); i++ ) {
114 if (
vecTHStock[i]->GetNTHStockToPaint() > 0 ) {
119 #ifdef DEBUG_CONT_FRAME
120 std::cout <<
" CanvasStock::GetNPadToPaint nbpad_topaint " << nbpad_topaint << std::endl;
122 return nbpad_topaint;
135 if ( counter == npad ) {
136 std::cout <<
"will delete thstock " << (*it_vec)->GetName() << std::endl;
144 std::cout <<
"CanvasStock::DeleteOneTHStock nbpad not found" << std::endl;
161 #ifdef DEBUG_CONT_FRAME
162 std::cout <<
"\n\tEntry CanvasStock:UpdateTHStock " << std::endl;
167 int new_size =
vecTHStock[0]-> GetFirstListData()->GetSize();
168 #ifdef DEBUG_CONT_FRAME
169 std::cout <<
"new_size of the first ldata " << new_size << std::endl;
185 for (
unsigned int i = 0; i <
vecTHStock.size(); i++ ) {
195 #ifdef DEBUG_CONT_FRAME
196 std::cout <<
"\n\tEnd CanvasStock::UpdateTHStock() " << std::endl;
205 #ifdef DEBUG_CONT_FRAME
206 std::cout <<
" Entry CanvasStock::SetRangeCommonAxis MinPosd " << MinPos <<
" MaxPos " << MaxPos << std::endl;
210 std::cout <<
" fcommon_xaxis_cs is not found, return " << std::endl;
218 #ifdef DEBUG_CONT_FRAME
219 std::cout <<
"set integer min " << (Int_t) (MinPos * ( ((Double_t)nbbin) /100. )) <<
220 " max " << (Int_t)(MaxPos * ( ((Double_t)nbbin) /100. )) << std::endl;
224 fcommon_xaxis_cs->
GetXAxis()->SetRange ( (Int_t) (MinPos * ( ((Double_t)nbbin) /100. )), (Int_t)(MaxPos * ( ((Double_t)nbbin) /100. )) );
227 #ifdef DEBUG_CONT_FRAME
228 std::cout <<
"Now com. Xaxis is correctly setup ??" << std::endl;
237 #ifdef DEBUG_CONT_FRAME
238 std::cout <<
"CanvasStock::UpdateCommonAxis" << std::endl;
240 std::cout <<
"new_size " << new_size << std::endl;
252 if ( old_size != new_size ) {
257 if ( max == old_size )
269 #ifdef DEBUG_CONT_FRAME
270 std::cout <<
"CanvasStock::ShowListData" << fullname << std::endl;
273 bool toRecreate =
false;
287 std::cout <<
"GetNTHStockToPaint nb_topaint == 0 recreate pad" << std::endl;
290 GetPad( npad )->Modified();
296 #ifdef DEBUG_CONT_FRAME
299 std::cout <<
" Entry CanvasStock::HideListData " << fullname <<
" npad " << npad <<
" toDelete " << toDelete << std::endl;
311 #ifdef DEBUG_CONT_FRAME
312 std::cout <<
" nb_topaint " << nb_topaint << std::endl;
316 if ( nb_topaint == 0) {
317 #ifdef DEBUG_CONT_FRAME
318 std::cout <<
"nb_topaint == 0 or to delete " << std::endl;
327 #ifdef DEBUG_CONT_FRAME
329 std::cout <<
"Need to recreate the pad " << std::endl;
336 #ifdef DEBUG_CONT_FRAME
337 std::cout <<
"nothing to delete and nb_topaint > 0, just call pad->Modified() " << std::endl;
339 GetPad( npad )->Modified();
346 #ifdef DEBUG_CONT_FRAME
347 std::cout <<
"\n\tCanvasStock::AddListDataStockToMap" << std::endl;
349 std::string name_listdata = p_listdata->
GetName();
351 bool first_pad =
false;
352 bool create_ths =
false;
354 #ifdef DEBUG_CONT_FRAME
355 std::cout <<
"name list_data " << name_listdata << std::endl;
356 std::cout <<
"name canvas stock " << GetName() << std::endl;
362 #ifdef DEBUG_CONT_FRAME
363 std::cout <<
"original GetNbPad() nb_pad " << nb_pad << std::endl;
367 std::vector <std::string> split_string;
368 std::string title_canvas;
380 title_canvas = split_string[1] +
" " + split_string[2];
381 #ifdef DEBUG_CONT_FRAME
382 std::cout <<
" nb_pad==0 title_canvas " << title_canvas << std::endl;
394 title_canvas = split_string[0];
395 if ( title_canvas.size() > 4 ) {
397 title_canvas.erase( 4, title_canvas.size()-4 );
398 title_canvas.replace( 3, 1,
"." );
399 #ifdef DEBUG_CONT_FRAME
400 std::cout <<
" size " << title_canvas.size() << std::endl;
401 std::cout <<
" nb_pad >= 1, title_canvas " << title_canvas << std::endl;
409 if ( forcepad !=0 ) {
410 #ifdef DEBUG_CONT_FRAME
411 std::cout <<
"forcepad to pad " << forcepad << std::endl;
424 if ( (indic_str.compare(1,2,
"MA",0,2)==0) || ( indic_str.compare(
"BOLL")==0) ) {
425 #ifdef DEBUG_CONT_FRAME
426 std::cout <<
"Will add *MA/BOLL to selected pad" << std::endl;
429 SetSelectedPad( ( (
TPad*) gPad ) ) ;
432 nb_pad = gPad->GetSelectedPad()->GetNumber();
433 #ifdef DEBUG_CONT_FRAME
434 std::cout <<
" gPad name " << gPad->GetName() << std::endl;
435 std::cout <<
" selcted name " << gPad->GetSelectedPad()->GetName() << std::endl;
436 std::cout <<
" gPad number " << gPad->GetNumber() << std::endl;
437 std::cout <<
" selected number " << gPad->GetSelectedPad()->GetNumber() << std::endl;
445 #ifdef DEBUG_CONT_FRAME
446 std::cout <<
"nbpad default New nb_pad " << nb_pad << std::endl;
459 #ifdef DEBUG_CONT_FRAME
460 std::cout <<
"Will create a new THStock " << std::endl;
462 std::cout <<
"name THStock " << name_listdata << std::endl;
473 ths =
new THStock( name_listdata.c_str(), title_canvas.c_str(), p_listdata->
GetSize() );
477 #ifdef DEBUG_CONT_FRAME
478 std::cout <<
"\nnot the first pad, set commonaxis right now!\n " << std::endl;
487 ths->
Add ( p_listdata );
492 ths->GetXaxis()->Set ( p_listdata->
GetSize(), (Double_t)0.0, (Double_t)1.0 );
494 #ifdef DEBUG_CONT_FRAME
495 std::cout <<
"p_lisdata size " << p_listdata->
GetSize() << std::endl;
496 std::cout <<
"ths get axis size " << ths->GetXaxis()->GetNbins() << std::endl;
506 ths->GetYaxis()->SetLabelSize(0.05);
507 ths->GetXaxis()->SetLabelSize(0.06);
516 #ifdef DEBUG_CONT_FRAME
517 std::cout <<
"not a new first pad " << std::endl;
520 ths->GetYaxis()->SetLabelSize ( 0.12 );
528 #ifdef DEBUG_CONT_FRAME
529 std::cout <<
"Add to existing THStock" << std::endl;
532 int nb_pad2 = gPad->GetSelectedPad()->GetNumber();
533 #ifdef DEBUG_CONT_FRAME
534 std::cout <<
"Add nb_pad2 " << nb_pad2 << std::endl;
537 #ifdef DEBUG_CONT_FRAME
538 std::cout <<
"ths GetName() " << ths->GetName() << std::endl;
540 ths->
Add ( p_listdata );
548 #ifdef DEBUG_CONT_FRAME
549 std::cout <<
"SetAxis of ths " << std::endl;
553 #ifdef DEBUG_CONT_FRAME
554 std::cout <<
"ths false, no axis to assign " << std::endl;
560 #ifdef DEBUG_CONT_FRAME
561 std::cout <<
"Return CreateNPad and CanvasStock::AddListDataStokpMap nb_pad " << nb_pad << std::endl;
607 #ifdef DEBUG_CONT_FRAME
608 std::cout <<
"Entry CanvasStock::CreateNPad" << std::endl;
609 std::cout <<
" name " << gPad->GetName() << std::endl;
610 std::cout <<
" classname " << gPad->ClassName() << std::endl;
611 std::cout <<
" nbpad " <<
vecTHStock.size() << std::endl;
617 Int_t nchname = strlen(GetName())+6;
618 char *name =
new char [nchname];
624 Double_t x1,y1,x2,y2;
627 Double_t margin = 0.001;
634 #ifdef DEBUG_CONT_FRAME
635 std::cout <<
" nbpad (vecTHStock.size()) " << nbpad << std::endl;
636 std::cout <<
" nb_padtopaint " << nb_padtopaint << std::endl;
653 for ( UInt_t i = 1; i <= nbpad; i++ ) {
660 #ifdef DEBUG_CONT_FRAME
661 std::cout <<
" GetNTHStockToPaint == 0, continue " << std::endl;
670 if ( (count==1) && (nb_padtopaint == 1) ) {
680 else if ( (count==1) && (nb_padtopaint==2) ) {
690 else if ( (count==1) && (nb_padtopaint==3) ) {
699 else if ( (count==1) && (nb_padtopaint >3)) {
705 dy = rest / ( nb_padtopaint - 1 );
710 else if ( count > 1 ) {
712 y2 = rest - (count-2)*dy - margin;
713 y1 = y2 - dy + 2*margin;
722 snprintf(name,nchname,
"%s_%d",GetName(),count);
725 pad =
new TPadStock( name, name, x1, y1, x2, y2, -1);
729 pad->SetNumber(count);
731 pad->SetRightMargin(0.02);
754 #ifdef DEBUG_CONT_FRAME
755 std::cout <<
"Exit CanvasStock::CreateNPad() count " << count << std::endl;
763 #ifdef DEBUG_CONT_FRAME
764 std::cout <<
"npad " << npad << std::endl;
765 std::cout <<
"fullname " << fullname << std::endl;
766 std::cout <<
"color " << color << std::endl;
767 std::cout <<
"(Pixel_t)color " << (Pixel_t)color << std::endl;
775 ths->SetColor ( fullname, (Pixel_t)color );
778 GetPad( npad )->Modified();
788 #ifdef DEBUG_CONT_FRAME
789 std::cout <<
" CanvasStock::UpdateAllPad(), marked as modified only, but do not update anything" << std::endl;
793 if (!fPrimitives) return ;
797 TObjOptLink *lnk = 0;
798 lnk = (TObjOptLink*)fPrimitives->FirstLink();
800 obj = lnk->GetObject();
805 ((
TPad*)obj)->Modified();
809 lnk = (TObjOptLink*)lnk->Next();
830 std::cout <<
"===================\nShowMap CanvasStock" << std::endl;
831 std::cout <<
"Size " <<
vecTHStock.size() << std::endl;
833 for ( UInt_t nb_th = 0; nb_th <
vecTHStock.size(); nb_th++ ) {
834 std::cout <<
"Name " <<
vecTHStock[nb_th]->GetName() << std::endl;
CanvasStock()
used this constructor ?? may be usefull for test code ?? I/ O need default constructor anyway ...
void SetColor(UInt_t npad, std::string fullname, unsigned long color)
new version with fname, really Needed ?? GetPad ( nb_pad ) from Controller not so good...
Owns a vector of THStock.
Derive from TH1 will draw the graph.
std::vector< THStock * >::iterator it_vthstock
define typedef for the vector
unsigned int GetNTHStockToPaint() const
return the number of object to paint called by CanvasStock, but Why ?? want bool ??
void DeleteOneTHStock(Int_t npad)
delete a complete Pad
ClassImp(CanvasStock) CanvasStock
void UpdateAllPad()
group function to update all thstock
virtual void Add(ObjectLine *obj_stock)
call by Factory, specific to drawable line
virtual ~CanvasStock()
destructor
void PrintVector()
for info
CanvasStock used to represent THStock.
Indicator GetIndicator(const std::string &sname)
Extract the indicator from a frame name.
Int_t AddListDataStockToMap(ListDataStockBase *, Int_t npad=0)
Add a ListDataStock, decide if new pad is created Add a pointeur to the new ListDataStock now decides...
Overload TPad Because ExecuteEvent not overloaded by CanvasStock.
CommonXAxis * fcommon_xaxis_cs
owns a common axis
void SetRangeCommonAxis(Double_t MinPos, Double_t MaxPos)
interface to CommonXaxis.
void SetSizeTitle(Float_t new_size)
void SetCommonXAxis(TAxis *xaxis)
void SetCommonXAxis(CommonXAxis *new_xaxis)
called by CanvasStock to set a common axis for all thstock
virtual unsigned int GetSize() const =0
Return the size of the vector.
std::string GetName() const
Abstract base class for the ListDataStock, for storing base pointers in vectors.
UInt_t GetNPadToPaint() const
function to return the number of pad needed
std::vector< THStock * > vecTHStock
store the THStocks.
void CreateNPad()
clean all and recreate all pads, can improve
void HideNameListData(std::string fullname, bool toDelete)
called by CanvasStock
void HideListData(std::string fullname, Int_t npad, bool toDelete=false)
Used for showing listdatastock indicator.
void ShowNameListData(std::string fullname) const
void splitline(const std::string &str, const std::string &delimiters, std::vector< std::string > &tokens)
splitline
void UpdateCommonAxis(int new_size)
Resize CommonXaxis, increase size of the axis Update the range (bins) of the Axis (fFirst...
void UpdateTHStock()
to redefine
void ShowListData(std::string fullname, Int_t npad)
Used for Hide and Delete, with option.