13 #include "../View/MainIndicatorTHStockFrame.h"
16 #include "../View/THStockFrame.h"
17 #include "../View/IndicatorFrame.h"
19 #include "../../src_cpp/StockManager.h"
20 #include "../../src_cpp/Stock.h"
24 #include "../GUIMainController.h"
26 #include "../GUIException.h"
28 #include "../TransientFrame.h"
31 TGCompositeFrame * associated_frame,
bool b_mainframe ) :
34 #ifdef DEBUG_CONT_FRAME
35 std::cout <<
"Constructor MainControllerIndicatorTHStock name " <<
GetName() << std::endl;
36 std::cout <<
"associated/moteher_frame " << associated_frame << std::endl;
37 std::cout <<
"b_mainfrane " << b_mainframe << std::endl;
64 #ifdef DEBUG_CONT_FRAME
65 std::cout <<
"Create an independent MainIndicatorTHStockFrame " << std::endl;
72 #ifdef DEBUG_CONT_FRAME
73 std::cout <<
"Create an MainIndicatorTHStockFrame inside assoc_frame" << associated_frame << std::endl;
77 associated_frame->AddFrame(
findic_thstock,
new TGLayoutHints( kLHintsLeft | kLHintsExpandX | kLHintsExpandY ,2,2,2,2) );
80 #ifdef DEBUG_CONT_FRAME
81 std::cout <<
"After creation of MainIndicatorTHStockFrame this (MainController) " <<
this << std::endl;
85 std::cout <<
"created MainIndicatorTHStockFrame findic_thstock " <<
findic_thstock << std::endl;
86 std::cout <<
"set kMainFrame " <<
kMainFrame << std::endl;
87 std::cout <<
"End constructor MainControllerIndicatorTHStockFrame " << std::endl;
92 #ifdef DEBUG_CONT_FRAME
93 std::cout <<
"Destructor MainControllerIndicatorTHStock delete sub-controllers " << std::endl;
115 #ifdef DEBUG_CONT_FRAME
116 std::cout <<
"\n\tEntry MainControllerIndicatorTHStock::AddCouple_Indicator_THStock frame_name " << frame_name << std::endl;
159 #ifdef DEBUG_CONT_FRAME
160 std::cout <<
"child_controller->GetIndicatorFrame() " << child_controller->
GetIndicatorFrame() << std::endl;
161 std::cout <<
"child_controller->GetTHStockFrame() " << child_controller->
GetTHStockFrame() << std::endl;
198 #ifdef DEBUG_CONT_FRAME
199 std::cout <<
"MainControllerIndicatorTHStock::Validation( fullname ) " << fullname << std::endl;
203 std::string frame_name;
229 #ifdef DEBUG_CONT_FRAME
230 std::cout <<
"extracted namestock " << namestock << std::endl;
231 std::cout <<
"new created frame_name " << frame_name << std::endl;
263 Stock *tmp_stock = fstockmanager->
Find( namestock );
266 if ( tmp_stock == 0 ) {
267 #ifdef DEBUG_CONT_FRAME
268 std::cout <<
"namestock " << namestock <<
"is not loaded " << std::endl;
274 std::cout <<
"MainControllerIndicatorTHStock::Validation Should check than the indicator is not loaded as well " << std::endl;
284 #ifdef DEBUG_CONT_FRAME
285 std::cout <<
"Caught StockException from Read_HeaderCSV" << std::endl;
286 std::cout <<
"Message e.what: " << e.
what() << std::endl;
295 #ifdef DEBUG_CONT_FRAME
296 std::cout <<
"\n\tbefore TransDataBox transdata " << transdata_date.
first <<
" " << transdata_date.
last << std::endl;
304 tmscl, indic, transdata_date, &to_insert );
307 std::cout <<
"Caught a GUIException from TransDateBox " << std::endl;
309 }
catch (
const std::exception & e ) {
310 std::cout <<
"From Controller get a base std::exception " << std::endl;
314 #ifdef DEBUG_CONT_FRAME
315 std::cout <<
"after TransDataBox " << transdata_date.
first <<
" " << transdata_date.
last << std::endl ;
316 std::cout <<
"to_insert " << to_insert << std::endl;
317 std::cout <<
"\n\tafter TransDataBox " << transdata_date.
first <<
" " << transdata_date.
last << std::endl ;
333 #ifdef DEBUG_CONT_FRAME
334 std::cout <<
"insert_new_stock true, call StockManager->Load()" << std::endl;
343 fstockmanager->
AddStock( tmp_stock );
362 #ifdef DEBUG_CONT_FRAME
363 std::cout <<
"Load directly without transient frame" << std::endl;
368 fstockmanager->
Load( namestock, tmscl, indic, vec_param, transdata_date );
373 std::cout <<
"\nMainController Catch a StockException " << std::endl;
374 std::cout <<
"e.what() " << e.
what() << std::endl;
381 #ifdef DEBUG_CONT_FRAME
386 #ifdef DEBUG_CONT_FRAME
397 #ifdef DEBUG_CONT_FRAME
398 std::cout <<
"ToMakeMain " << std::endl;
416 new_control->
GetFrame()->MapSubwindows();
418 new_control->
GetFrame()->MapWindow();
428 #ifdef DEBUG_CONT_FRAME
429 std::cout <<
"ToAddCanvas() CreateCouple Indicator " << std::endl;
436 #ifdef DEBUG_CONT_FRAME
450 #ifdef DEBUG_CONT_FRAME
451 std::cout <<
"Before UpdateGUIFromController UpdateGUIFromController" << std::endl;
467 #ifdef DEBUG_CONT_FRAME
468 std::cout <<
"Entry MainControllerIndicatorTHStock::Updated " << std::endl;
474 if ( message[0] ==
"update_dcsv" ) {
479 (*it)->Updated( message );
483 std::cout <<
"Message MainControllerIndicatorTHStock::Updated not known message " << message[0] << std::endl;
490 #ifdef DEBUG_CONT_FRAME
491 std::cout <<
"\n\tEntry MainControllerIndicatorTHStock::GetSelected child_control " << child_controller << std::endl;
492 std::cout <<
"child_controller->GetName() " << child_controller->
GetName() << std::endl;
512 #ifdef DEBUG_CONT_FRAME
513 std::cout <<
"Entry MainControllerIndicatorTHStock::UpdateIndicator mode " << mode << std::endl;
516 if ( ( mode ==
"DELETE_ALL" ) || ( mode ==
"HIDE_ALL" ) ) {
519 #ifdef DEBUG_CONT_FRAME
520 std::cout <<
"In Update mode DELETE_ALL or HIDE_ALL " << std::endl;
527 if (mode ==
"DELETE_ALL" ) {
528 #ifdef DEBUG_CONT_FRAME
529 std::cout <<
" DELETE_ALL " << std::endl;
544 delete child_controller;
554 #ifdef DEBUG_CONT_FRAME
555 std::cout <<
" After DELETE_ALL " << std::endl;
559 }
else if ( mode ==
"SHOW_ALL" ) {
560 #ifdef DEBUG_CONT_FRAME
561 std::cout <<
" Update mode SHOW_ALL " << std::endl;
565 std::cout <<
"\n\tError mode not known in MainControllerIndicatorTHStock::UpdateIndicator mode !!\n" << mode << std::endl;
573 #ifdef DEBUG_CONT_FRAME
574 std::cout <<
"Entry MainControllerIndicatorTHStock::Update" << std::endl;
Singleton class, stores all loaded stocks.
MainControllerIndicatorTHStock(GUIMainController *parent_control, std::string name, TGCompositeFrame *associated_frame, bool b_mainframe)
Constructor.
void SetTextResearch(std::string new_text)
need for controller to set up
std::string MakeFrameName(const std::string &namestock, const ETime &tmscl)
Create a frame name string from its components.
std::list< ControllerIndicatorTHStock * > list_controller
list more convenient, remove if not shown ?, or insert
Controller for a dual frame containing Indicator+THStock(s).
"Clever" enumeration of the ListDataStock type : StockCSV, Volume, EMA, BOLL,...
void ResetEntries()
reset all widget entries, may add options
void SetTimeScale(int tmscl)
bool kMainFrame
link to StockManager, singleton, initialized in constructor
void UpdateGUIFromController()
only gui_mainframe->Resize(), but seems necessary when a new frame created
Main controller of the application, linked to the view GUIMainFrame.
void AddController(ControllerIndicatorTHStock *control)
Common Function for dealing with the list, need a name, may call other controllers...
virtual const char * what() const noexcept
virtual void DeleteList(bool call_delete=true)
Iterative call for deleting child controller.
virtual unsigned int GetSizeListController() const
virtual ~MainControllerIndicatorTHStock()
MainIndicatorTHStockFrame * findic_thstock
void DeleteIndicatorTHstock()
Delete all couples of frames and thstocks Call by MainControllerIndicatorStock::CloseWindow() ...
Final controller class, does not derive from ListController.
ControllerIndicatorTHStock * fcurrent_controller
Stock * Load(const std::string namestock, const ETime &tmscl, const Indicator &indic, std::vector< int > param=std::vector< int >(), Utils::firstlast_dates dates=Utils::get_fldate_default())
Load a specific ListDataStock.
std::list< ControllerIndicatorTHStock * >::iterator it_list
useful typedef for the class ( and derivatives !)
bool ToAddCanvas()
check state of button
Base Exception for Stock and StockManager, all src_cpp code.
std::string GetNameStock(const std::string &fname)
Extract the name of the stock.
Main class to deal with one stock.
void DeleteControllerIndicatorTHStock(MainControllerIndicatorTHStock *control)
MainIndicatorTHStockFrame * GetFrame() const
Sub-controller : assure drawing and coupling of 1 IndicatorFrame and 1 THStock.
virtual void Updated(std::vector< std::string > &message)
Call by parent controller, when a new message is available.
StockManager * GetStockManager() const
TGHorizontalFrame * GetTHStockFrame() const
void SetTHStockFrame(THStockFrame *fthstock)
MainControllerIndicatorTHStock * CreateMainControllerIndicatorTHStock(bool kmain=false)
Creates child controllers, contains Indicator+THStock(s).
Indicator GetIndicator(const std::string &fname)
Extract the Indicator from a fullname.
ControllerIndicatorTHStock * GetFirstController()
get the first controller in list, useful after a delete
void SetIndicatorFrame(IndicatorFrame *findic)
ETime
Enumeration for the different time representation, from instantaneous (INST) to year(YEAR) ...
std::string GetName() const
static Indicator const StockInst
void GetSelected(ControllerIndicatorTHStock *child_controller)
receive indirectly the IndicatorFrame Selected, can set the current_frame ( can get pad also ) ...
void AddData(std::string fullname)
Used when a new ListData is added, need SM access here, or in parent...
Frame contains Indicator and THStock.
TGVerticalFrame * GetIndicatorFrame() const
get the important child frames for drawing
void Update()
coming from StockManager, through observer pattern no should come from gui_maincontroller now ...
std::string GetPathData()
void UpdateIndicator(ControllerIndicatorTHStock *child_controller, std::string mode)
called by controller child for some tasks child cannot do.
Stock * Find(const std::string &namestock) const
Retrieve an instance of a stock.
void AddCouple_Indicator_THStock(std::string frame_name)
Create a new sub-controller and update views for adding a new frame Does not add any data...
void Validation(std::string fullname)
Load stock or indicator after pressing the Validation button.
static Indicator const StockCSV
GUIMainController * GetGUIMainController() const
ControllerIndicatorTHStock * GetCurrentController() const
Base class, for all gui errors Need a real base class here, or just use directly StockException.
void PrintMapChrono(const unsigned int verbose=0) const
Print map content to the console.
static SUPPRESS_NOT_USED_WARN firstlast_dates get_fldate_default()
need to be static for using default argument in a function
void UpdateFrames()
keep only for updating THStockFrame for the moment, how done by Indicator ?
void RemoveController(ControllerIndicatorTHStock *control)
int Read_HeaderCSV(ETime tmscl, Utils::firstlast_dates &dates) const
Read the dates from the header file.
see remark below, much easier if composition than derivation in the case of ListController, same for parent_controller as member <U> easily extends to View as well ( ListView possible ), but strong coupling again
THStockFrame * GetTHStockFrame() const
general structure for dates in csv files
StockManager * GetStockManager() const
needed here
int AddStock(Stock *)
Add a stock to the stockmanager.
void PrintMap()
Print an user-friendly view of the StockManger content.
std::vector< int > GetParams(const std::string &fname)
Extract params from a fullname.
IndicatorFrame * GetIndicatorFrame() const
ETime GetTimeScale(const std::string &fname)
Extract the TimeScale from a fullname.
GUIMainController * myparent_controller