-
Notifications
You must be signed in to change notification settings - Fork 156
/
ChartMaster.h
118 lines (81 loc) · 3.38 KB
/
ChartMaster.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/************************************************************************
* Copyright(c) 2011, One Unified. All rights reserved. *
* *
* This file is provided as is WITHOUT ANY WARRANTY *
* without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* This software may not be used nor distributed without proper license *
* agreement. *
* *
* See the file LICENSE.txt for redistribution information. *
************************************************************************/
#pragma once
#include <vector>
#include <string>
#include <functional>
#include <boost/format.hpp>
// Note, that there is a wxChartDir wrapper!
// https://github.com/utelle/wxchartdir
// https://www.wxwidgets.org/blog/2018/08/wxchartdir-using-chartdirector-in-wxwidgets-applications/
#include <boost/date_time/posix_time/posix_time.hpp>
class MultiChart;
class XYChart;
class MemBlock;
class DrawArea;
namespace ou { // One Unified
class ChartDataView;
class ChartMaster {
public:
ChartMaster();
ChartMaster( unsigned int width, unsigned int height );
virtual ~ChartMaster();
void SetChartDataView( ChartDataView* pcdv );
ChartDataView* GetChartDataView() const { return m_pCdv; };
void SetBarWidth( boost::posix_time::time_duration tdBarWidth );
void SetChartDimensions( unsigned int width, unsigned int height);
void DrawChart();
using fOnDrawChart_t = std::function<void( bool bCursor, const MemBlock& )>;
void SetOnDrawChart( fOnDrawChart_t&& function ) {
m_fOnDrawChart = std::move( function );
}
void SetCrossHairPosition( int x, int y );
void SetCrossHairTime( const std::string& );
void CrossHairDraw( bool );
void GetWorldCoordX( int& nChart, double& dblX ) const { nChart = m_nChart; dblX = m_dblX; }
void GetWorldCoordY( int& nChart, double& dblY ) const { nChart = m_nChart; dblY = m_dblY; }
void GetX( int& left, int& x, int& right ) const {
left = m_xLeft; x = m_xX; right = m_xRight;
}
protected:
unsigned int m_nChartWidth;
unsigned int m_nChartHeight;
boost::posix_time::time_duration m_tdBarWidth;
fOnDrawChart_t m_fOnDrawChart;
private:
ChartDataView* m_pCdv;
std::unique_ptr<MultiChart> m_pChart;
using pXYChart_t = std::unique_ptr<XYChart>;
using vSubChart_t = std::vector<pXYChart_t>;
vSubChart_t m_vSubCharts;
boost::format m_formatter;
XYChart* m_pXY0;
DrawArea* m_pDA;
bool m_bHasData;
int m_intCrossHairX, m_intCrossHairY;
bool m_bCrossHair;
int m_nChart;
double m_dblX; // date time
double m_dblY; // chart specific value
int m_xLeft; // coord of left side of chart
int m_xX; // coord of mouse on chart
int m_xRight; // coord of right side of chart
char m_szCursorTime[ 100 ]; // place time at cursor
void Initialize();
void ChartStructure();
void ChartData( XYChart* );
bool DrawDynamicLayer(); // true if cross hairs
void RenderChart();
bool ResetDynamicLayer();
};
} // namespace ou