⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statisticdialog.cpp

📁 The application wizard has created this SoccerDoctor application for you. This application not onl
💻 CPP
字号:
/************************************************************************************************
// $Header: /home/cvsroot/SoccerDoctor/StatisticDialog.cpp,v 1.11 2002/09/10 06:44:35 peter Exp $
//***********************************************************************************************/

#include "stdafx.h"
#include "SoccerDoctor.h"
#include "StatisticDialog.h"
#include "analyzer.h" // CAnalyzer
#include "MainFrm.h"
// CStatisticDialog 对话框

IMPLEMENT_DYNAMIC(CStatisticDialog, CDialog)
CStatisticDialog::CStatisticDialog(const CAnalyzer* pAnalyzer,CWnd* pParent /*=NULL*/)
	: _pAnalyzer(pAnalyzer),CDialog(CStatisticDialog::IDD, pParent)
{
}

CStatisticDialog::~CStatisticDialog()
{
}

void CStatisticDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_STATTAB, _StatTabCtrl);
	DDX_Control(pDX, IDC_STATLIST, _StatList);
}


BEGIN_MESSAGE_MAP(CStatisticDialog, CDialog)
	ON_NOTIFY(TCN_SELCHANGE, IDC_STATTAB, OnStatChangeType)
END_MESSAGE_MAP()


// CStatisticDialog 消息处理程序

BOOL CStatisticDialog::OnInitDialog()
{
	CDialog::OnInitDialog();
	InitTabCtrl();		
	InitStatChart();
	//缺省的状态
	_StatList.init();
	HideAll();
	ShowSummory();
	return TRUE;  // return TRUE unless you set the focus to a control
}
void CStatisticDialog::InitTabCtrl()
{
	TC_ITEM TabCtrlItem;
	TabCtrlItem.mask = TCIF_TEXT;
	TabCtrlItem.pszText = "Summary";
	_StatTabCtrl.InsertItem( 0, &TabCtrlItem );
	TabCtrlItem.pszText = "Left";
	_StatTabCtrl.InsertItem( 1, &TabCtrlItem );
	TabCtrlItem.pszText = "Shoots(L)";
	_StatTabCtrl.InsertItem( 2, &TabCtrlItem );
	TabCtrlItem.pszText = "Passes(L)";
	_StatTabCtrl.InsertItem( 3, &TabCtrlItem );
	TabCtrlItem.pszText = "Dribbles(L)";
	_StatTabCtrl.InsertItem( 4, &TabCtrlItem );
	TabCtrlItem.pszText = "Interceptions(L)";
	_StatTabCtrl.InsertItem( 5, &TabCtrlItem );
	TabCtrlItem.pszText = "Right";
	_StatTabCtrl.InsertItem( 6, &TabCtrlItem );
	TabCtrlItem.pszText = "Shoots(R)";
	_StatTabCtrl.InsertItem( 7, &TabCtrlItem );
	TabCtrlItem.pszText = "Passes(R)";
	_StatTabCtrl.InsertItem( 8, &TabCtrlItem );
	TabCtrlItem.pszText = "Dribbles(R)";
	_StatTabCtrl.InsertItem( 9, &TabCtrlItem );
	TabCtrlItem.pszText = "Interceptions(R)";
	_StatTabCtrl.InsertItem( 10, &TabCtrlItem );
}
void CStatisticDialog::InitStatChart()
{
	CRect clientRect;
	GetClientRect(&clientRect);
	clientRect.top += 50; // skip teh tab control
	_StatChart.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,clientRect,this,1);
	_StatChart.SetChartType(TYPE_BAR);
	_StatChart.SetAxisScale(X_AXIS, 1, 11);
	_StatChart.SetAxisScale(Y_AXIS, 0, 10);
    _StatChart.SetScaleStep(X_AXIS, 1, 1);
	_StatChart.SetAxisStyleX(AUTO_SCALE| TICK_TEXT | _StatChart.GetAxisStyleX());
	_StatChart.SetAxisStyleY(AUTO_SCALE|_StatChart.GetAxisStyleY());
	_StatChart.SetAxisFormatString(X_AXIS, CString("%.0f"));
	_StatChart.SetAxisFormatString(Y_AXIS, CString("%.0f"));
	
}
void CStatisticDialog::ShowStatistic()
{
	switch(_StatTabCtrl.GetCurSel()) {
	case 0:
		ShowSummory();
		break;
	case 1:
		ShowOverview(LEFT);
		break;
	case 2:
		ShowShots(LEFT);
		break;
	case 3:
		ShowPasses(LEFT);
		break;
	case 4:
		ShowDribbles(LEFT);
		break;
	case 5:
		ShowIntercepts(LEFT);
		break;
	case 6:
		ShowOverview(RIGHT);
		break;
	case 7:
		ShowShots(RIGHT);
		break;
	case 8:
		ShowPasses(RIGHT);
		break;
	case 9:
		ShowDribbles(RIGHT);
		break;
	case 10:
		ShowIntercepts(RIGHT);
		break;
	default:
		break;
	}
}
void CStatisticDialog::OnStatChangeType(NMHDR *pNMHDR, LRESULT *pResult)
{
	// TODO: 在此添加控件通知处理程序代码
	HideAll();
	ShowStatistic();
	*pResult = 0;
}
void CStatisticDialog::ShowSummory()
{
	for(int nID=IDC_LEFTTEAMNAME; nID<=IDC_RIGHTCONTROL; nID++){
		GetDlgItem(nID)->ShowWindow(SW_SHOW);
	}
	CString strText;
	// Left Side
	strText.Format("%d",_pAnalyzer->getTeamShootCount(LEFT));
	GetDlgItem(IDC_LEFTSHOOTS)->SetWindowText(strText);
	strText.Format("%d",_pAnalyzer->getTeamSuccessShootCount(LEFT));
	GetDlgItem(IDC_LEFTONTARGETS)->SetWindowText(strText);
	strText.Format("%d",_pAnalyzer->getTeamCornerKickCount(LEFT));
	GetDlgItem(IDC_LEFTCORNERS)->SetWindowText(strText);
	strText.Format("%d",_pAnalyzer->getTeamFreeKickCount(LEFT));
	GetDlgItem(IDC_LEFTFREEKICKS)->SetWindowText(strText);
	strText.Format("%d",_pAnalyzer->getTeamKickInCount(LEFT));
	GetDlgItem(IDC_LEFTTHROWINS)->SetWindowText(strText);
	if( _pAnalyzer->getTeamPassCount(LEFT) != 0 ){
		strText.Format("%d%%",_pAnalyzer->getTeamSuccessPassCount(LEFT)*100/_pAnalyzer->getTeamPassCount(LEFT));
	}else{
		strText = "0";
	}
	GetDlgItem(IDC_LEFTPASSES)->SetWindowText(strText);
	
	if( _pAnalyzer->getTeamInterceptCount(LEFT) != 0 ){
		strText.Format("%d%%",_pAnalyzer->getTeamSuccessInterceptCount(LEFT)*100/_pAnalyzer->getTeamInterceptCount(LEFT));
	}else{
		strText = "0";
	}
	GetDlgItem(IDC_LEFTINTERCEPTS)->SetWindowText(strText);
	
	if( _pAnalyzer->getTeamDribbleCount(LEFT) != 0 ){
		strText.Format("%d%%",_pAnalyzer->getTeamSuccessDribbleCount(LEFT)*100/_pAnalyzer->getTeamDribbleCount(LEFT));
	}else{
		strText = "0";
	}
	GetDlgItem(IDC_LEFTDRIBBLES)->SetWindowText(strText);
	
	// Right Side
	strText.Format("%d",_pAnalyzer->getTeamShootCount(RIGHT));
	GetDlgItem(IDC_RIGHTSHOOTS)->SetWindowText(strText);
	strText.Format("%d",_pAnalyzer->getTeamSuccessShootCount(RIGHT));
	GetDlgItem(IDC_RIGHTONTARGETS)->SetWindowText(strText);
	strText.Format("%d",_pAnalyzer->getTeamCornerKickCount(RIGHT));
	GetDlgItem(IDC_RIGHTCORNERS)->SetWindowText(strText);
	strText.Format("%d",_pAnalyzer->getTeamFreeKickCount(RIGHT));
	GetDlgItem(IDC_RIGHTFREEKICKS)->SetWindowText(strText);
	strText.Format("%d",_pAnalyzer->getTeamKickInCount(RIGHT));
	GetDlgItem(IDC_RIGHTTHROWINS)->SetWindowText(strText);
	if( _pAnalyzer->getTeamPassCount(RIGHT) != 0 ){
		strText.Format("%d%%",_pAnalyzer->getTeamSuccessPassCount(RIGHT)*100/_pAnalyzer->getTeamPassCount(RIGHT));
	}else{
		strText = "0";
	}
	GetDlgItem(IDC_RIGHTPASSES)->SetWindowText(strText);
	
	if( _pAnalyzer->getTeamInterceptCount(RIGHT) != 0 ){
		strText.Format("%d%%",_pAnalyzer->getTeamSuccessInterceptCount(RIGHT)*100/_pAnalyzer->getTeamInterceptCount(RIGHT));
	}else{
		strText = "0";
	}
	GetDlgItem(IDC_RIGHTINTERCEPTS)->SetWindowText(strText);
	
	if( _pAnalyzer->getTeamDribbleCount(RIGHT) != 0 ){
		strText.Format("%d%%",_pAnalyzer->getTeamSuccessDribbleCount(RIGHT)*100/_pAnalyzer->getTeamDribbleCount(RIGHT));
	}else{
		strText = "0";
	}
	GetDlgItem(IDC_RIGHTDRIBBLES)->SetWindowText(strText);
	
	strText.Format("%.0f%%",_pAnalyzer->getTeamWithBallCycleRate(LEFT)*100);
	GetDlgItem(IDC_LEFTCONTROL)->SetWindowText(strText);
	strText.Format("%.0f%%",_pAnalyzer->getTeamWithBallCycleRate(RIGHT)*100);
	GetDlgItem(IDC_RIGHTCONTROL)->SetWindowText(strText);

	strText.Format("%.0f%%",_pAnalyzer->getLeftControlRate()*100);
	GetDlgItem(IDC_LEFTFIELD)->SetWindowText(strText);
	strText.Format("%.0f%%",_pAnalyzer->getMiddleControlRate()*100);
	GetDlgItem(IDC_MIDFIELD)->SetWindowText(strText);
	strText.Format("%.0f%%",_pAnalyzer->getRightControlRate()*100);
	GetDlgItem(IDC_RIGHTFIELD)->SetWindowText(strText);


}
void CStatisticDialog::ClearStatChart()
{
	_StatChart.Purge();
	_StatChart.AddDataSeries("ALL", RGB(255, 0, 0));
	_StatChart.AddDataSeries("SUCCEED", RGB(0, 255, 0));
	
}
void CStatisticDialog::ShowStatChart()
{
	_StatChart.ShowSeriesLegend();
	_StatChart.UpdateWindow();
	_StatChart.ShowWindow(SW_SHOW);
	
}
void CStatisticDialog::ShowShots(int side)
{
	ClearStatChart();	
	CDataPoint dataPoint;
	for(int i=1; i<=MAX_PLAYER; i++){
		dataPoint.m_dX = i;
		dataPoint.m_dY = _pAnalyzer->getPlayerShootCount(side,i);
		_StatChart.AddDataPoint(&dataPoint);
		dataPoint.m_dY = _pAnalyzer->getPlayerSuccessShootCount(side,i);
		_StatChart.AddDataPoint(&dataPoint,1);
	}
	ShowStatChart();
}
void CStatisticDialog::ShowPasses(int side)
{
	ClearStatChart();	
	CDataPoint dataPoint;
	for(int i=1; i<=MAX_PLAYER; i++){
		dataPoint.m_dX = i;
		dataPoint.m_dY = _pAnalyzer->getPlayerPassCount(side,i);
		_StatChart.AddDataPoint(&dataPoint);
		dataPoint.m_dY = _pAnalyzer->getPlayerSuccessPassCount(side,i);
		_StatChart.AddDataPoint(&dataPoint,1);
	}
	ShowStatChart();
}
void CStatisticDialog::ShowDribbles(int side)
{
	ClearStatChart();	
	CDataPoint dataPoint;
	for(int i=1; i<=MAX_PLAYER; i++){
		dataPoint.m_dX = i;
		dataPoint.m_dY = _pAnalyzer->getPlayerDribbleCount(side,i);
		_StatChart.AddDataPoint(&dataPoint);
		dataPoint.m_dY = _pAnalyzer->getPlayerSuccessDribbleCount(side,i);
		_StatChart.AddDataPoint(&dataPoint,1);
	}
	ShowStatChart();
}
void CStatisticDialog::ShowIntercepts(int side)
{
	ClearStatChart();	
	CDataPoint dataPoint;
	for(int i=1; i<=MAX_PLAYER; i++){
		dataPoint.m_dX = i;
		dataPoint.m_dY = _pAnalyzer->getPlayerInterceptCount(side,i);
		_StatChart.AddDataPoint(&dataPoint);
		dataPoint.m_dY = _pAnalyzer->getPlayerSuccessInterceptCount(side,i);
		_StatChart.AddDataPoint(&dataPoint,1);
	}
	ShowStatChart();
}
void CStatisticDialog::HideAll()
{
	for(int nID=IDC_LEFTTEAMNAME; nID<=IDC_RIGHTCONTROL; nID++){
		GetDlgItem(nID)->ShowWindow(SW_HIDE);
	}
	_StatChart.ShowWindow(SW_HIDE);
	_StatList.ShowWindow(SW_HIDE);
}
void CStatisticDialog::ShowOverview(int side)
{
	_StatList.DeleteAllItems();
	for(UINT i=1; i<=MAX_PLAYER; i++){
		_StatList.addLine(i,_pAnalyzer->getPlayerPassCount(side,i),_pAnalyzer->getPlayerSuccessPassCount(side,i),
			_pAnalyzer->getPlayerShootCount(side,i),_pAnalyzer->getPlayerSuccessShootCount(side,i),
			_pAnalyzer->getPlayerDribbleCount(side,i),_pAnalyzer->getPlayerSuccessDribbleCount(side,i),
			_pAnalyzer->getPlayerInterceptCount(side,i),_pAnalyzer->getPlayerSuccessInterceptCount(side,i));
	}
	_StatList.ShowWindow(SW_SHOW);
}
void CStatisticDialog::OnCancel()
{
	ShowWindow(SW_HIDE);
	// CDialog::OnCancel();
}

BOOL CStatisticDialog::PreTranslateMessage(MSG* pMsg)
{
	if( pMsg->message == WM_KEYDOWN || pMsg->message == WM_CHAR || pMsg->message == WM_DROPFILES ){
		CMainFrame* pFrame = dynamic_cast<CMainFrame*>(AfxGetMainWnd());
		if( pFrame ){
			pFrame->PostMessage(pMsg->message,pMsg->wParam,pMsg->lParam);
			return TRUE;
		}
	}
	return CDialog::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -