-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartSerie.cpp
150 lines (128 loc) · 3.93 KB
/
ChartSerie.cpp
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
*
* ChartSerie.cpp
*
* Written by Cédric Moonen ([email protected])
*
*
*
* This code may be used for any non-commercial and commercial purposes in a compiled form.
* The code may be redistributed as long as it remains unmodified and providing that the
* author name and this disclaimer remain intact. The sources can be modified WITH the author
* consent only.
*
* This code is provided without any garanties. I cannot be held responsible for the damage or
* the loss of time it causes. Use it at your own risks
*
* An e-mail to notify me that you are using this code is appreciated also.
*
* History:
* - 11/08/2006: Management of the auto axis now done in the axis. Series Register
* Unregister themselves to their respective axes .
* - 29/02/2008: Taking into account that RefreshAutoAxis doesn't refresh the control.
* - 01/03/2008: RemovePointsFromBegin and RemovePointsFromEnd functions added.
* - 08/03/2008: AddPoints function added (thanks to Bruno Lavier).
* - 11/03/2008: Min and max values are now cached.
* - 14/03/2008: Series can be ordered. Speed improvement done in that case.
* - 13/08/2008: Bug fix: calling AddPoint was not drawing the new points.
* - 27/11/2008: Points are now stored into the CChartPointsArray class instead of
* std::vector for efficiency.
*
*/
#include "stdafx.h"
#include "ChartCtrl.h"
#include "ChartSerie.h"
#include "ChartAxis.h"
#include "Math.h"
#include <algorithm>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
unsigned CChartSerie::m_uNextFreeId = 0;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CChartSerie::CChartSerie(CChartCtrl* pParent)
{
m_pParentCtrl = pParent;
// m_uLastDrawnPoint = 0;
m_strSerieName = _T("");
m_pHorizontalAxis = m_pVerticalAxis = NULL;
m_uSerieId = m_uNextFreeId;
m_uNextFreeId++;
m_bIsVisible = true;
m_bShadow = false;
m_SerieColor = RGB(0, 0, 0);
m_ShadowColor = RGB(150,150,150);
m_iShadowDepth = 2;
m_bMouseClickNotifications = true;
m_bMouseMoveNotifications = false;
}
CChartSerie::~CChartSerie()
{
m_pHorizontalAxis->UnregisterSeries(this);
m_pVerticalAxis->UnregisterSeries(this);
}
//void CChartSerie::SetSeriesOrdering(CChartPointsArray::PointsOrdering newOrdering)
//{
// m_vPoints.SetOrdering(newOrdering);
//}
void CChartSerie::SetName(const TChartString& NewName)
{
m_strSerieName = NewName;
m_pParentCtrl->RefreshCtrl();
}
double CChartSerie::XScreenToValue(long XScreenCoord) const
{
return m_pHorizontalAxis->ScreenToValue(XScreenCoord);
}
double CChartSerie::YScreenToValue(long YScreenCoord) const
{
return m_pVerticalAxis->ScreenToValue(YScreenCoord);
}
void CChartSerie::ValueToScreen(double XValue, double YValue, CPoint &ScreenPoint) const
{
ScreenPoint.x = m_pHorizontalAxis->ValueToScreen(XValue);
ScreenPoint.y = m_pVerticalAxis->ValueToScreen(YValue);
}
void CChartSerie::SetVisible(bool bVisible)
{
m_bIsVisible = bVisible;
m_pParentCtrl->RefreshCtrl();
}
void CChartSerie::SetColor(COLORREF NewColor)
{
m_SerieColor = NewColor;
m_pParentCtrl->RefreshCtrl();
}
void CChartSerie::SetShadowColor(COLORREF NewColor)
{
m_ShadowColor = NewColor;
m_pParentCtrl->RefreshCtrl();
}
void CChartSerie::EnableShadow(bool bEnable)
{
m_bShadow = bEnable;
m_pParentCtrl->RefreshCtrl();
}
void CChartSerie::SetShadowDepth(int Depth)
{
m_iShadowDepth = Depth;
m_pParentCtrl->RefreshCtrl();
}
void CChartSerie::EnableMouseNotifications(bool bClickEnabled, bool bMoveEnabled)
{
m_bMouseClickNotifications = bClickEnabled;
m_bMouseMoveNotifications = bMoveEnabled;
}
void CChartSerie::RefreshAutoAxes(bool bForceRefresh)
{
m_pParentCtrl->EnableRefresh(false);
m_pHorizontalAxis->RefreshAutoAxis();
m_pVerticalAxis->RefreshAutoAxis();
if (bForceRefresh)
m_pParentCtrl->RefreshCtrl();
m_pParentCtrl->EnableRefresh(true);
}