-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathGraphSeries.cpp
104 lines (88 loc) · 2.1 KB
/
GraphSeries.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
#pragma once
#include "stdafx.h"
#include "GraphSeries.h"
#include "GraphDataSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGraphSeries
CGraphSeries::CGraphSeries()
{
dataValues = new CObList();
}
CGraphSeries::~CGraphSeries()
{
POSITION pos;
CGraphDataSet *dataSet;
pos = dataValues->GetHeadPosition();
while(pos != NULL)
{
dataSet = (CGraphDataSet*)dataValues->GetAt(pos);
dataValues->RemoveAt(pos);
delete dataSet;
}
delete dataValues;
}
BEGIN_MESSAGE_MAP(CGraphSeries, CStatic)
//{{AFX_MSG_MAP(CGraphSeries)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGraphSeries message handlers
void CGraphSeries::SetLabel(CString label)
{
seriesLabel = label;
}
void CGraphSeries::SetData(double xValue, double yValue)
{
CGraphDataSet *dataSet = new CGraphDataSet();
dataSet->SetXPosition(xValue);
dataSet->SetYValue(yValue);
dataValues->AddTail(dataSet);
}
CString CGraphSeries::GetLabel()
{
return seriesLabel;
}
double CGraphSeries::GetData(double xValue)
{
POSITION pos;
pos = dataValues->GetHeadPosition();
double retVal = 0;
while(pos != NULL)
{
CGraphDataSet *dataSet;
dataSet = (CGraphDataSet*)dataValues->GetAt(pos);
if(dataSet->GetXData() == xValue)
{
retVal = dataSet->GetYData();
return retVal;
}
dataValues->GetNext(pos);
}
return 0;
}
int CGraphSeries::GetDataCount()
{
return dataValues->GetCount();
}
double CGraphSeries::GetXDataValue()
{
POSITION pos;
pos = dataValues->GetHeadPosition();
CGraphDataSet *retVal;
retVal = (CGraphDataSet*)dataValues->GetAt(pos);
return retVal->GetXData();
}
double CGraphSeries::GetYDataValue()
{
POSITION pos;
pos = dataValues->GetHeadPosition();
CGraphDataSet *retVal;
retVal = (CGraphDataSet*)dataValues->GetAt(pos);
return retVal->GetYData();
}