-
Notifications
You must be signed in to change notification settings - Fork 11
/
GraphLegend.cpp
106 lines (91 loc) · 2.35 KB
/
GraphLegend.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
#pragma once
#include "stdafx.h"
#include "GraphLegend.h"
#include "GraphLegendSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGraphLegend
CGraphLegend::CGraphLegend()
{
legendLabels = new CObList();
legendLength = 0;
}
CGraphLegend::~CGraphLegend()
{
POSITION pos;
CGraphLegendSet *legendSet;
pos = legendLabels->GetHeadPosition();
while(pos != NULL)
{
legendSet = (CGraphLegendSet*)legendLabels->GetAt(pos);
legendLabels->RemoveAt(pos);
delete legendSet;
}
delete legendLabels;
}
BEGIN_MESSAGE_MAP(CGraphLegend, CStatic)
//{{AFX_MSG_MAP(CGraphLegend)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGraphLegend message handlers
void CGraphLegend::SetLegendText(int datagroup, CString label)
{
CGraphLegendSet *legendData = new CGraphLegendSet();
legendData->SetLegendLabel(datagroup, label);
legendLabels->AddTail(legendData);
if(label.GetLength() > legendLength)
legendLength = label.GetLength();
}
CString CGraphLegend::GetLegendText(int datagroup)
{
POSITION pos;
CGraphLegendSet *legendData;
if((legendLabels->GetCount() < datagroup) || (legendLabels->GetCount() == 0))
{
return "";
}
pos = legendLabels->GetHeadPosition();
#pragma omp parallel for
for (int i = 0; i < datagroup; i++)
{
legendLabels->GetNext(pos);
}
legendData = (CGraphLegendSet*)legendLabels->GetAt(pos);
return legendData->GetLegendLabel();
}
int CGraphLegend::GetLegendLength()
{
return legendLength;
}
void CGraphLegend::Remove(int dataGroup)
{
POSITION pos;
CGraphLegendSet *legendSet;
pos = legendLabels->GetHeadPosition();
#pragma omp parallel for
for (int i = 0; i < dataGroup; i++)
{
legendSet = (CGraphLegendSet*)legendLabels->GetAt(pos);
legendLabels->GetNext(pos);
}
legendLabels->RemoveAt(pos);
delete legendSet;
}
void CGraphLegend::RemoveAll()
{
POSITION pos;
CGraphLegendSet *legendSet;
pos = legendLabels->GetHeadPosition();
while(pos != NULL)
{
legendSet = (CGraphLegendSet*)legendLabels->GetAt(pos);
legendLabels->RemoveAt(pos);
delete legendSet;
}
}