ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MainIndicatorTHStockFrame.cxx
Go to the documentation of this file.
1 
9 #include "../Controllers/MainControllerIndicatorTHStock.h"
10 #include "IndicatorFrame.h"
11 #include "THStockFrame.h"
12 
13 // nicer graph for doxygen, because included by MainControllerIndicatorTHStock.h but lose its meaning !
14 //#include "THStockFrame.h"
15 // needed for signal ?? certainly ! not sure and seems to compile without !
16 #include "../ObjectStock/EditorObjStock.h"
17 #include "../ObjectStock/AbstractObjectStock.h"
18 
19 // add exception, could be in a base class of View
20 #include "../GUIException.h"
21 #include "../TransientFrame.h"
22 
23 //For ROOT dictionnary, necessary to get the slot working ??
25 
26 // all declared static, not a problem because all common to all classes
27 // make a namespace, better than global, or set as private variable of the class (like GUIMainFrame)
29 const char * MainIndicatorTHStockFrame::xpms[] = {
30  "./pictures/support.xpm",
31  "./pictures/tendance.xpm",
32  "./pictures/ancre.xpm",
33  "./pictures/realtime.xpm",
34  0
35 };
36 
38 const char * MainIndicatorTHStockFrame::tips[] = {
39  "Support/Resistance",
40  "Line Tendance",
41  "Anchor",
42  "Real Time",
43  //"Other..", fibo
44  0
45 };
46 
48 const char * MainIndicatorTHStockFrame::ListTimeScaleLabel[] = { "INST", "M5", "M10", "M30", "H1", "DAY", "WEEK", "MONTH", "TRIM", "YEAR" };
49 
51 // first is x,y perfect, third is date, is exactly the good size with date+hour
52 Int_t MainIndicatorTHStockFrame::statbar_parts[] = {17, 12, 15, 56};
53 
54 
56  std::string name_frame, UInt_t w,UInt_t h ) :
57 TGMainFrame( p, w, h), fcontroller ( parent_control )
58 {
59 #ifdef DEBUG_CONT_FRAME
60  std::cout << "\n\tConstructor MainIndicatorTHStockFrame h= " << h << " w " << w << std::endl;
61  std::cout << "Value of the parent frame " << p << std::endl;
62  std::cout << "Value of the parent controller " << parent_control << std::endl;
63  std::cout << "name_frame " << name_frame << std::endl;
64 #endif
65 
66  SetName( name_frame.c_str() );
67  // all child frame should be deleted in destructor, or when calling Cleanup()
68  // see CloseWindow
69  SetCleanup ( kDeepCleanup );
70 
71  if ( p == 0 ) {
72 #ifdef DEBUG_CONT_FRAME
73  std::cout << "p == 0, create a kMainFrame " << std::endl;
74 #endif
75  //ChangeOptions, no effect
76  //frame->ChangeOptions((frame->GetOptions()& ~kVerticalFrame)| kHorizontalFrame);
77  // do not change anything, make independent if p == 0., that's all !
78  //ChangeOptions( (GetOptions() & ~kChildFrame)| kMainFrame );
79  //try other option for correct fit with screen
80  // not a problem with the main frame, scale to the screen exactly
81  // but inside do not rescale, problem seems really not form here
82  //ChangeOptions( (GetOptions() & ~kFixedWidth )| kFitWidth );
83  //ChangeOptions( (GetOptions() & ~kFixedHeight )| kFitHeight );
84  //std::cout << "Option kMainFrame has been setup " << std::endl;
85 
86  SetWindowName("IndependentMainFrame");
87 
88  // need something for clean closing, ok call the correct function
89  Connect("CloseWindow()", "MainIndicatorTHStockFrame", this, "CloseWindow()");
90  }
91 
93 
94  // create vertical layout for main drawing
95  // VMain really necessary ?? this is already a Vertical one !!
96  TGVerticalFrame *fVMain = new TGVerticalFrame( this , 120, h );
97  AddFrame( fVMain, new TGLayoutHints( kLHintsLeft | kLHintsExpandX | kLHintsExpandY ,2,2,2,2));
98 
99  // first make the toolbar bar and text box, inside fVMain
100  CreateToolBar( fVMain );
101 
102  // then creates findic_thstock, new one, belong to fVMain
103  TGHorizontalFrame * fHIndicTHStock = new TGHorizontalFrame( this, 100, h);
104  fVMain->AddFrame( fHIndicTHStock, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY , 2, 2, 2, 2) );
105 
106  // draw inside fHIndicTHStock, theses frame need to be in *.h to retrieve easily
107  fVframe_indicator = new TGVerticalFrame ( fHIndicTHStock, 120, h);
108  fHIndicTHStock->AddFrame(fVframe_indicator, new TGLayoutHints( kLHintsExpandY , 2, 2, 2, 2) );
109  // THStockFrame, MainTHStockFrame could be the name
110  fHframe_c_stock = new TGHorizontalFrame( fHIndicTHStock, 100, h);
111  fHIndicTHStock->AddFrame( fHframe_c_stock, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY , 2, 2, 2, 2) );
112 
113  // creates status bar
114  fStatusBar = new TGStatusBar(fVMain, 50, 10, kHorizontalFrame);
115  fStatusBar->SetParts (statbar_parts, 4);
116  //fStatusBar->Draw3DCorner(kFALSE);
117  fVMain->AddFrame (fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX,0,0,2,0) );
118 
119 #ifdef DEBUG_CONT_FRAME
120  std::cout << "Newly created " << std::endl;
121  std::cout << "fHframe_c_stock " << fHframe_c_stock << std::endl;
122  std::cout << "fVframe_indicator " << fVframe_indicator << std::endl;
123  //right to do this, object not yet created, seems ok get findic_thstock !
124  std::cout << "MainIndicatorTHStockFrame this " << this << std::endl;
125 #endif
126  // selection works, but cannot HideFrame yet here
127  fComboTime->Select(15);
128  fComboIndic->Select(20);
129 }
130 
132 {
133 #ifdef DEBUG_CONT_FRAME
134  std::cout << "Destructor MainIndicatorTHStockFrame " << std::endl;
135 #endif
136  fcontroller = 0;
137  // should delete all subframes, ok done with solved bug
138  // a priori done with the Cleanup call
139  Cleanup();
140  std::cout << "End destructor MainIndicatorTHStockFrame " << std::endl;
141 }
142 
143 // strange because want to kill himself, what happens when coming back from the function ? CloseWindow ok ?
144 // better would be a signal to GUIMainController ?
146 {
147 #ifdef DEBUG_CONT_FRAME
148  std::cout << "Entry MainIndicatorTHStockFrame::CloseWindow() this " << this << std::endl;
149  std::cout << "this " << this << " name controller " << GetName() << std::endl;
150 #endif
151  // avoid to be called 2 times, see TGMAinFrame.CloseWindow()
152  DontCallClose();
153  // call function of the controller, will pass to GUIMainController
155  // will call the destructor of this class
156  TGMainFrame::CloseWindow();
157 }
158 // need the frame to which to paint
160 {
161 #ifdef DEBUG_CONT_FRAME
162  std::cout << "Entry MainIndicatorTHStockFrame::CreateToolBar " << std::endl;
163 #endif
164  //no need to be outside, it was THE bug, no value for the first loop
165  int separator_gtool=5;
166  //same for the other ??
167  char tmp[50];
168 
169  // here maybe many could be only intern to the function, not saved as member
170 
171  // creation of a horizontal bar to include toolbar, combo box and research text
172  // the size is not takken into account
173  fHframe_toolbar= new TGHorizontalFrame( fVMain, 100 , 40);
174  fVMain->AddFrame( fHframe_toolbar, new TGLayoutHints( kLHintsLeft | kLHintsExpandX ,2,2,2,2) );
175  // creation of a toolbar object as a child of main frame
176  ftoolbar = new TGToolBar( fHframe_toolbar, 520, 160);
177  //connect
178  ftoolbar->Connect( "Clicked( Int_t )", "MainIndicatorTHStockFrame", this, "HandleToolBar( Int_t )" );
179  //good place for kLHintsCenterY
180  fHframe_toolbar->AddFrame( ftoolbar, new TGLayoutHints( kLHintsCenterY | kLHintsExpandY , 2, 20, 2, 2) );
181 
183  //Fill TGToolBar
184  ToolBarData_t ftoolbd[6];
185  for (int i = 0; i < 4; i++) {
186  // filling the ToolBarData_t with information
187  ftoolbd[i].fPixmap = xpms[i]; // icon file
188  ftoolbd[i].fTipText = tips[i]; // tool tip text
189 
190  //Lines, anchor and RealTime
191  if ( (i==0) || (i==1) || ( i==2) || (i==3) )
192  ftoolbd[i].fStayDown = kTRUE; // buttons stay pressed
193  else
194  ftoolbd[i].fStayDown = kFALSE; // button behavior if clicked
195 
196  ftoolbd[i].fId = i+1; // button id
197  ftoolbd[i].fButton = NULL; // button pointer
198 
199  // Make a test, keep this, should handle the message not fHframe_toolbar
200  // test seem to work, but see later make strict
201  separator_gtool = 1;
202  if ( i == 3 ) separator_gtool = 25;
203  ftoolbar->AddButton( fHframe_toolbar, &ftoolbd[i], separator_gtool);
204  } //end loop for
205 
206  //std::cout << "TGtoolBar GetHeight " << ftoolbar->GetHeight() << std::endl;
207 
209  fLabelSearch = new TGLabel ( fHframe_toolbar, "Search" );
210  //do not work here ...
211  //fLabelSearch->SetHeight(100);
212  fHframe_toolbar->AddFrame( fLabelSearch, new TGLayoutHints( kLHintsCenterY | kLHintsExpandY , 0, 5, 2, 2) );
213 
214  fTextResearch = new TGTextEntry ( fHframe_toolbar, "", kTextSearch);
215  //signal TabPressed(), ReturnPressed(), TextChanged
216  // respond to return, but no response, not implemented, only Validation is implemented !!
217  fTextResearch->Connect("ReturnPressed()","MainIndicatorTHStockFrame",this,"HandleButtons(Int_t)");
218  fHframe_toolbar->AddFrame( fTextResearch, new TGLayoutHints( kLHintsCenterY, 5, 5, 2, 2) );
219  fTextResearch->Resize(70, 20);
220 
222  // combo box layout hints
223  fComboTime = new TGComboBox( fHframe_toolbar, kChoiceTime ); //100 );
224  fHframe_toolbar->AddFrame( fComboTime, new TGLayoutHints( kLHintsCenterY, 2, 2, 2, 2 ) );
225 
226  for (int i = 0; i < 10; i++) {
227  sprintf(tmp, ListTimeScaleLabel[i], i+10);
228  fComboTime->AddEntry(tmp, i+10);
229  }
230  fComboTime->Resize(70, 20);
231  //select default, DAY
232  //fComboTime->Select(15);
233 
234  fComboTime->Connect( "Selected(Int_t, Int_t )", "MainIndicatorTHStockFrame", this, "HandleComboBox( Int_t, Int_t )");
235 
237  std::vector<std::string> tmp_indic= Indicator::GetListAllIndicator();
238 
239  fComboIndic = new TGComboBox( fHframe_toolbar, kChoiceIndic ); //101 );
240  // try the expand Y, ok effect
241  fHframe_toolbar->AddFrame(fComboIndic ,new TGLayoutHints( kLHintsCenterY | kLHintsExpandY | kLHintsLeft ) );
242 
243  for ( unsigned int i=0; i < tmp_indic.size(); i++ ) {
244  fComboIndic->AddEntry( tmp_indic[i].c_str(), i+20 );
245  }
246  fComboIndic->Resize(100,20);
247  //fComboIndic->Select(20);
248  fComboIndic->Connect( "Selected(Int_t, Int_t )", "MainIndicatorTHStockFrame", this, "HandleComboBox( Int_t, Int_t )");
249 
251  fParamEntry[0] = new TGTextEntry ( fHframe_toolbar, "", kParamEntry0);
252  fHframe_toolbar->AddFrame( fParamEntry[0], new TGLayoutHints( kLHintsCenterY, 5, 5, 2, 2) );
253  fParamEntry[0]->SetAlignment ( kTextRight );
254  fParamEntry[0]->Resize(40,20);
255  fHframe_toolbar->HideFrame( fParamEntry[0] );
256 
257  fParamEntry[1] = new TGTextEntry ( fHframe_toolbar, "", kParamEntry1);
258  fHframe_toolbar->AddFrame( fParamEntry[1], new TGLayoutHints( kLHintsCenterY, 5, 5, 2, 2) );
259  fParamEntry[1]->SetAlignment ( kTextRight );
260  fParamEntry[1]->Resize(40,20);
261  fHframe_toolbar->HideFrame( fParamEntry[1] );
262 
263  fParamEntry[2] = new TGTextEntry ( fHframe_toolbar, "", kParamEntry2);
264  fHframe_toolbar->AddFrame( fParamEntry[2], new TGLayoutHints( kLHintsCenterY, 5, 5, 2, 2) );
265  fParamEntry[2]->SetAlignment ( kTextRight );
266  fParamEntry[2]->Resize(40,20);
267  fHframe_toolbar->HideFrame( fParamEntry[2] );
268 
270  //TGCheckButton *check_to_add_canvas = new TGCheckButton(p, "Event Status",1);
271  check_to_add_canvas = new TGCheckButton( fHframe_toolbar, "New CS", kAddCanvas );
272  check_to_add_canvas->Connect("Clicked()","MainIndicatorTHStockFrame",this,"HandleButtons(Int_t)");
273  fHframe_toolbar->AddFrame( check_to_add_canvas, new TGLayoutHints( kLHintsCenterY | kLHintsLeft , 5,2,2,2) );
274 
275  check_to_make_main = new TGCheckButton( fHframe_toolbar, "New Frame", kMakeMain );
276  check_to_make_main->Connect("Clicked()","MainIndicatorTHStockFrame",this,"HandleButtons(Int_t)");
277  fHframe_toolbar->AddFrame( check_to_make_main, new TGLayoutHints( kLHintsCenterY | kLHintsLeft , 5,2,2,2) );
278 
279  //check_to_add_canvas->SetState(kButtonDown);
280  //check_to_add_canvas->SetState( kButtonDown );
281 
282  //button of validation of previous widget
283  fValidB = new TGTextButton ( fHframe_toolbar, "&Valid", kValidB );
284  fValidB->Connect("Clicked()", "MainIndicatorTHStockFrame", this, "HandleButtons(Int_t)");
285  fHframe_toolbar->AddFrame ( fValidB, new TGLayoutHints( kLHintsCenterY | kLHintsExpandY | kLHintsRight, 1,1,3,3) );
286 
288  TGHorizontal3DLine *line_separator = new TGHorizontal3DLine(fVMain);
289  fVMain->AddFrame(line_separator, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
290 }
291 
292 // keep same idea, but more general, may add option for the stock
294 {
295 #ifdef DEBUG_CONT_FRAME
296  std::cout << "Entry Reset Entries" << std::endl;
297 #endif
298 
299  std::vector<std::string> tmp_indic= Indicator::GetListAllIndicator();
300  Int_t nb_param = 0;
301  bool b_default = false;
302  std::vector<int> default_values;
303 
304  // always set off the check button
305  check_to_add_canvas->SetState(kButtonUp);
306  check_to_make_main->SetState(kButtonUp);
307 
308  // get indicator for the ComboBox
309  Indicator indic = Indicator::GetIndicator( tmp_indic[ fComboIndic->GetSelected() - 20 ] );
310 
311  nb_param = indic.nb_param();
312  b_default = indic.HasDefaultValues();
313 
314  //std::cout << "nb_param " << nb_param << " has default values " << b_default << std::endl;
315  if ( b_default ) {
316  default_values = indic.GetDefaultValues();
317  //std::cout << "has default values " << std::endl;
318  } /*else {
319  std::cout << "no default values " << std::endl;
320  }*/
321 
322  //reset all to hide, here need nothing
323 #ifdef DEBUG_CONT_FRAME
324  std::cout << "Hide all fParamEntry" << std::endl;
325 #endif
326  for ( int i=0; i < 3; i++ )
327  fHframe_toolbar->HideFrame( fParamEntry[i] );
328 
329  //set entry param and default values if exists
330  // can have param, but no default values
331  if ( nb_param > 0 ) {
332  for ( int i=0; i< nb_param; i ++ ) {
333  //std::cout << "ShowFrame fParamEntry[i]" << i << std::endl;
334  fHframe_toolbar->ShowFrame( fParamEntry[i] );
335  // working or if i < size
336  if ( b_default )
337  fParamEntry[i]->SetText( (Utils::toString<Float_t>(default_values[i])).c_str(), false );
338  }
339  }
340 }
341 
343 {
344 #ifdef DEBUG_CONT_FRAME
345  std::cout << " \n\t Entry MainIndicatorTHStockFrame::ExtractInfoForValidation" << std::endl;
346  std::cout << " pointer to fcontroller " << fcontroller << std::endl;
347  //std::cout << "fStatusBar " << fStatusBar << std::endl;
348 #endif
349  // to extract from toolbar
350  std::string namestock;
351  std::string tmscl_str;
352  std::string indic_str;
353  std::vector<std::string> tmp_indic= Indicator::GetListAllIndicator();
354 
355  // Get namestock
356  namestock = fTextResearch->GetText();
357  std::cout << "name stock: " << namestock << std::endl;
358  // Get TimeScale
359  tmscl_str = ListTimeScaleLabel[ fComboTime->GetSelected() - 10 ];
360  //Get Indicator
361  indic_str = tmp_indic[ fComboIndic->GetSelected() - 20 ];
362  //std::cout << " indic_str " << tmscl_str << std::endl;
363 
364  longname = namestock+ '_' + tmscl_str + '_' + indic_str;
365  // May add parameters to reconstruct fullname
366  if ( fHframe_toolbar->IsVisible ( fParamEntry[0] ) ) {
367  longname += '_' + Utils::toString<const char *> ( fParamEntry[0]->GetText() );
368  }
369  if ( fHframe_toolbar->IsVisible ( fParamEntry[1] ) ) {
370  longname += '_' + Utils::toString<const char *> ( fParamEntry[1]->GetText() );
371  }
372  if ( fHframe_toolbar->IsVisible ( fParamEntry[2] ) ) {
373  longname += '_' + Utils::toString<const char *>( fParamEntry[2]->GetText() );
374  }
375 
376 #ifdef DEBUG_CONT_FRAME
377  std::cout << "End Extract fullname " << longname << std::endl;
378 #endif
379 }
380 
382 {
383 #ifdef DEBUG_CONT_FRAME
384  std::cout << " Entry MainIndicatorTHStockFrame::HandleButtons(Int_t id) " << std::endl;
385 #endif
386 
387  // Handle all buttons of this class
388  TGButton *btn;
389  if (id == -1) {
390  //TGButton *btn = (TGButton *) gTQSender;
391  btn = (TGButton *) gTQSender;
392  id = btn->WidgetId();
393  //std::cout << "get btn->widgetid " << id << std::endl;
394  }
395 
396  switch (id) {
397  //could be apart
398  case kTextSearch:
399  //std::cout << "Return in text search id: " << id << std::endl;
400  //std::cout << "text search: " << ((TGTextEntry *)btn)->GetText() << std::endl;
401  break;
402 
403  case kAddCanvas:
404  //std::cout << "kAddCanvas state " << btn->IsOn() << std::endl;
405  break;
406 
407  case kMakeMain:
408  //std::cout << "kMakeMain state " << btn->IsOn() << std::endl;
409  break;
410 
411  case kValidB:
412 #ifdef DEBUG_CONT_FRAME
413  std::cout << "Valid button has been pressed, will call MainControllerIndicatorTHStockFrame::Validation " << std::endl;
414 #endif
415  std::string longname;
416  ExtractInfoForValidation( longname );
417 
418  // validation may encounter various exception laoding stock, computing TA...
419  // easy to call from here and get all (otherwise call controller, which call an other controller function)
420  // now get an exception
421  try {
422  // only one controller for a MainIndicatorFrame
423  fcontroller->Validation( longname );
424  // here should deal with GUIExeption
425  } catch ( const GUIException & e ) {
426 #ifdef DEBUG_EXCEPT
427  std::cout << "\nMainIndicatorTHStockFrame:Caugth GUIException from HandleButton " << std::endl;
428  // ok send the correct initial message
429  std::cout << "what(): " << e.what() << std::endl;
430 #endif
431  // could clean the label, or reset to default here
432 
433  //new TransFrameError( fClient->GetRoot(), this, const_cast<GUIException &>(e) );
434  new TransFrameError( fClient->GetRoot(), this, e );
435 
436  }
437  //std::cout << "End of Validation " << std::endl;
438  //std::cout << "fStatusBar " << fStatusBar << std::endl;
439  break;
440  }
441 #ifdef DEBUG_CONT_FRAME
442  std::cout << " Exit MainIndicatorTHStockFrame::HandleButtons(Int_t id) " << std::endl;
443 #endif
444 }
445 
446 void MainIndicatorTHStockFrame::HandleComboBox(Int_t widgetId, Int_t id)
447 {
448 #ifdef DEBUG_CONT_FRAME
449  std::cout << "Entry HandleComboBox " << std::endl;
450  std::cout << "widget " << widgetId << " id " << id << std::endl;
451 #endif
452 
453  // used before, no need anymore, simpler to read the new value
454  // TGComboBox *tg=(TGComboBox *)gTQSender;
455 
456  // keep only id, need to refer to the tab
457  switch ( widgetId ) {
458  //deal only with TimeScale, nothing to do
459  case kChoiceTime:
460  //std::cout << "text " << ListTimeScaleLabel[id-10] << std::endl;
461  break;
462  //deal with indicator, need to set nb parameters and default values
463  case kChoiceIndic:
464  // modification done alone
465 #ifdef DEBUG_CONT_FRAME
466  std::cout << "Modify ChoiceIndic ResetEntries" << std::endl;
467 #endif
468  // can use the entry in the function
469  ResetEntries();
470  break;
471  } // end switch
472 
473 }
474 
475 // Handle Line/Resistance, RealTime,...
477 {
478 #ifdef DEBUG_CONT_FRAME
479  std::cout << "Entry HandleToolBar id " << id << std::endl;
480 #endif
481  //virtual TGButton* GetButton(Int_t id) const
482  TGButton * but = ftoolbar->GetButton(id);
483 
484  switch ( id ) {
485  case 1:
486  {
487 #ifdef DEBUG_CONT_FRAME
488  std::cout << " Support/Resistance " << std::endl;
489 #endif
490  //first try, should call constructor
491  //EditorObjStock *feditor;
492  //std::cout << "feditor status " << feditor->GetStatus() << std::endl;
493  //EditorObjStock *feditor= EditorObjStock::getInstance();
494  // moved to pure static methods
495  if ( but->IsDown() ) {
496 #ifdef DEBUG_CONT_FRAME
497  std::cout << " IsDown, EditorObject set to Support " << std::endl;
498 #endif
499  //feditor->SetMode("Support");
500  EditorObjStock::SetMode("Support");
501  } else {
502 #ifdef DEBUG_CONT_FRAME
503  std::cout << " IsUp, EditorObject set to None " << std::endl;
504 #endif
505  //feditor->SetMode("None");
506  EditorObjStock::SetMode("None");
507  }
508  //std::cout << "feditor status " << feditor->GetStatus() << std::endl;
509  // need an EditorGetMode which return a string
510  //std::cout << "GetMode " << EditorObjStock::GetMode() << std::endl;
511  }
512  break;
513  case 2:
514  {
515  //EditorObjStock *feditor= EditorObjStock::getInstance();
516  if ( but->IsDown() ) {
517 #ifdef DEBUG_CONT_FRAME
518  std::cout << " IsDown, run EditorObject " << std::endl;
519 #endif
520  //feditor->SetMode("Tendance");
521  EditorObjStock::SetMode("Tendance");
522  } else {
523  //feditor->SetMode("None");
524  EditorObjStock::SetMode("None");
525  }
526  }
527  break;
528  case 3:
529  {
530  //EditorObjStock *feditor= EditorObjStock::getInstance();
531  if ( but->IsDown() ) {
532 #ifdef DEBUG_CONT_FRAME
533  std::cout << " IsDown, run EditorObject Anchor " << std::endl;
534 #endif
536  //EditorObjStock::SetMode("Anchor");
537  } else {
538 #ifdef DEBUG_CONT_FRAME
539  std::cout << "IsUp Disable Anchor" << std::endl;
540 #endif
541  EditorObjStock::SetAnchor( false );
542  //feditor->SetMode("None");
543  //EditorObjStock::SetMode("None");
544  }
545  }
546  break;
547  case 4:
548  {/*
549  std::cout << " Real Time " << std::endl;
550  if ( but->IsDown() ) {
551  std::cout << " IsDown, run RealTime " << std::endl;
552  frealtime->Start(10000);
553  }
554  else {
555  std::cout << " Is Not Down, stop RealTime " << std::endl;
556  frealtime->Stop();
557  }
558  */
559  }
560  break;
561  }//end case
562  //could test if both button Support and Tendance are down, only one or delete !
563  //...
564 }
565 
566 void MainIndicatorTHStockFrame::SetStatusBar( std::vector<std::string> & vec_str_text )
567 {
568 /*
569 #ifdef DEBUG_CONT_FRAME
570  std::cout << "Entry MainIndicatorTHStockFrame::SetStatusBar " << std::endl;
571  // works give the function, but not the class
572  //std::cout << "Entry " << typeid(*this).name() << "::" << __func__ << std::endl;
573  // g++ dependent, in capital letter ! for function does not change anything
574  // pretty function is the keyword, all arguments are showed
575  std::cout << "Entry pretty_function " << __PRETTY_FUNCTION__ << "::" << __FUNCTION__ << std::endl;
576  //std::cout << "size vec_str_text " << vec_str_text.size() << std::endl;
577 #endif
578 */
579  unsigned int size_entry = vec_str_text.size();
580  unsigned int i = 0;
581 
582  // can clean all entries here, easier for caller, but only EventInfo for the moment
583  // seems not the good one to call
584  //fStatusBar->Clear();
585 
586  // can make a loop over the entry
587  // make a test on the size ?? should do it
588  for ( i = 0; i < size_entry; ++i ) {
589  fStatusBar->SetText( vec_str_text[i].c_str(),i);
590  }
591  // set up to four if size_entry is smaller < 4, with empty
592  for ( unsigned int j = i;j <4; j++ )
593  fStatusBar->SetText("",j);
594 
595 }
596 
597 // More complexe, than thinking, how is it called ? do not reproduce...
598 // called 3 times, if a Candle Stock is selected with
599 // - Pad Event 53
600 // - CandleStock event 52
601 // - CandleStock event 51
602 // should test in an example, from TGFrame.cxx
603 // signalslist = (TList*)el->fFrame->GetListOfSignals();
604 // TList *lsl = (TList *)gROOT->GetListOfSpecials()->FindObject("ListOfSlots");
605 
606 // Slot, from TCanvasStock, should send string to Controller which will decide
607 // ok can get it from here, increase dependence with EditorObject, avoid if this is done from IndicatorFrame
608 // anyway only one active, and it here, here could choose ( send to MainController or GUIMainController )
609 
610 // advantage here centralize, may have different type than THStock with who to interact, shorter path for the signal
611 // disadvantage : need EditorObject, need slot so Dictionary, need full access to parent controller ( better than THStockFrame->Controller->MainController. )
612 void MainIndicatorTHStockFrame::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
613 {
614 /*
615 #ifdef DEBUG_CONT_FRAME
616  std::cout << "Entry MainIndicatorTHStockFrame::EventInfo" << std::endl;
617  //std::cout << "selected " << selected << std::endl;
618  //std::cout << " event " << event << std::endl;
619  std::cout << " selected->ClassName " << selected->ClassName() << std::endl;
620  std::cout << " selected->GetName " << selected->GetName() << std::endl;
621 #endif
622 */
623  std::vector < std::string > vec_str_text;
624  std::string text_str0, text_str1, text_str2, text_str3;
625  // for all dates
626  time_t date = 0;
627  std::string indic_str;
628 
629  text_str0 = Utils::toString( selected->GetObjectInfo(px,py) );
630  //std::cout << "text_str0 " << text_str0 << std::endl;
631  // return TObject if no dictionnary
632  text_str1 = Utils::toString( selected->ClassName() );
633  //std::cout << "text_str1 " << text_str1 << std::endl;
634  vec_str_text.push_back( text_str0 );
635  vec_str_text.push_back( text_str1 );
636 
637  //Printing values
638  std::vector<Float_t> values;
639  std::vector<std::string> add_strings;
640  //std::cout << "Before test selected " << std::endl;
641 
642  AbstractObjectStock * obj_stock = 0;
643 
644  // need to test if the cast is correct, could be a pad or something else
645  obj_stock = dynamic_cast<AbstractObjectStock *>(selected);
646  //std::cout << "obj_stock " << obj_stock << std::endl;
647 
648  // set dates and values in the last two cases
649  if ( obj_stock != 0 ) {
650  // more general
651  add_strings = obj_stock->MakeStringForStatusBar( px, py );
652  //std::cout << "add_strings[0] " << add_strings[0] << std::endl;
653  vec_str_text.push_back( add_strings[0] );
654  vec_str_text.push_back( add_strings[1] );
655  }
656  // here can set status bar directly, no need to send to controller
657  SetStatusBar( vec_str_text );
658  //std::cout << "After MainIndicator SetText " << std::endl;
659 }
660 
661 
static const char * ListTimeScaleLabel[]
for TimeScale ComboxBox
TGVerticalFrame * fVframe_indicator
frame for all indicators
Controller for a dual frame containing Indicator+THStock(s).
static std::vector< std::string > GetListAllIndicator()
Get a list of all indicator's label.
Definition: Indicator.cpp:57
"Clever" enumeration of the ListDataStock type : StockCSV, Volume, EMA, BOLL,...
Definition: Indicator.h:29
MainControllerIndicatorTHStock * fcontroller
pointer to the parent controller
void ResetEntries()
reset all widget entries, may add options
int nb_param() const
Nb of parameters necessary to be computed.
Definition: Indicator.cpp:68
void CreateToolBar(TGVerticalFrame *fVMain)
void EventInfo(Int_t, Int_t px, Int_t py, TObject *selected)
Called after DistancetoPrimitive for the selection of "objects" Done by the system, appends after a gPad->SetSelected( obj_stock ) in THistPainterStock::DtP.
bool HasDefaultValues() const
Test functions if default values are provided.
Definition: Indicator.cpp:83
virtual const char * what() const noexcept
Definition: GUIException.h:37
MainIndicatorTHStockFrame(const TGWindow *p, MainControllerIndicatorTHStock *parent_control, std::string name_frame, UInt_t w, UInt_t h)
Constructor, create only generic frames to design the output, but empty inserted in a generic frames ...
Independent frame, could be kMainFrame or kChild Frame which group one MainIndicatorFrame and THStock...
void DeleteIndicatorTHstock()
Delete all couples of frames and thstocks Call by MainControllerIndicatorStock::CloseWindow() ...
return values
Definition: ObjectStock.cxx:37
ClassImp(MainIndicatorTHStockFrame) const char *MainIndicatorTHStockFrame
For ToolBar, define pictures *.xpm.
virtual std::vector< std::string > MakeStringForStatusBar(int, int) const =0
create the string for the StatusBar
TGTextButton * fValidB
Validation button, after update of search and combo.
static Indicator GetIndicator(const std::string &str_name)
Constructor with a string label.
Definition: Indicator.cpp:234
TGLabel * fLabelSearch
For selection and validation of a new indicator.
void ExtractInfoForValidation(std::string &longname)
Extract symbol, timescale, indicator and paramaters from input.
std::string toString(const T &t)
Definition: Utils.h:69
Frame contains Indicator and THStock.
void SetAnchor(bool kbool)
void Validation(std::string fullname)
Load stock or indicator after pressing the Validation button.
void HandleComboBox(Int_t widgetId, Int_t id)
void SetMode(std::string mode)
std::vector< int > GetDefaultValues() const
Get the default values, return an empty vector if none are provided.
Definition: Indicator.cpp:88
static Int_t statbar_parts[]
for Status Bar, place in %, no in a namespace, need to be static
Define an abstract base class for all objects to be painted in a THStock.
TGHorizontalFrame * fHframe_c_stock
frame for all THStockFrame ( 1 canvas stock inside each )
void SetStatusBar(std::vector< std::string > &vec_str_text)
print data from EventInfo in the status bar
static const char * tips[]
For ToolBar, define text.