-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathClassView.cpp
110 lines (87 loc) · 2.37 KB
/
ClassView.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
// ClassView.cpp : implementation file
//
#include "stdafx.h"
#include "WinDE.h"
#include "ClassView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// ClassView dialog
ClassView::ClassView(CWnd* pParent /*=NULL*/)
: CTabPageSSL(ClassView::IDD, pParent)
{
//{{AFX_DATA_INIT(ClassView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void ClassView::DoDataExchange(CDataExchange* pDX)
{
CTabPageSSL::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ClassView)
DDX_Control(pDX, IDC_MSCHART1, m_ChartControl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(ClassView, CTabPageSSL)
//{{AFX_MSG_MAP(ClassView)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ClassView message handlers
BOOL ClassView::OnInitDialog()
{
CTabPageSSL::OnInitDialog();
COleSafeArray saRet;
SAFEARRAYBOUND sab[2];
CString csTemp;
long index[2] = {0,0}; //a 2D graph needs a 2D array as index array
BSTR bstr;
index[0]=1;
int x=1, max_x =0, i;
for( i = CLASS_NONE; i < MAX_CLASS; i++)
{
if(GetClassCount(i) > 0)
max_x++;
}
m_ChartControl.SetRowCount(1);
m_ChartControl.SetShowLegend(TRUE);
//m_ChartControl.SetAllowSelections(false);
sab[0].cElements =1;
sab[1].cElements = max_x+1;//number of columns + 1 (because the first column is where we put
sab[0].lLbound = sab[1].lLbound = 1;
saRet.Create(VT_BSTR, 2, sab);
m_ChartControl.SetColumnCount(max_x);
m_ChartControl.SetColumnLabelCount(max_x);
index[1]=1;
csTemp = "Class Statistics";
bstr = csTemp.AllocSysString(); // Row label
saRet.PutElement(index, bstr);
for(i = CLASS_NONE; i < MAX_CLASS; i++)
{
if(GetClassCount(i) > 0)
{
x++;
index[1]=x;
csTemp.Format("%f", GetClassPercent(i));
bstr = csTemp.AllocSysString();
saRet.PutElement(index, bstr);
::SysFreeString(bstr);
}
}
m_ChartControl.SetChartData(saRet.Detach());
x = 1;
for(i = CLASS_NONE; i< MAX_CLASS; i++)
{
if(GetClassCount(i) > 0)
{
m_ChartControl.SetColumn(x);
m_ChartControl.SetColumnLabel(GetClassName(i));
x++;
}
}
//m_ChartControl.SetTitleText("Class Percentages");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}