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

📄 chartctrl.cpp

📁 The application wizard has created this SoccerDoctor application for you. This application not onl
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/************************************************************************************************
// $Header: /home/cvsroot/SoccerDoctor/Chart/ChartCtrl.cpp,v 1.5 2002/09/10 06:44:35 peter Exp $
//***********************************************************************************************
/************************************************************************************************/
/*                                                                                              */
/* File    : ChartCtrl.cpp                                                                      */
/*                                                                                              */
/* Purpose : interface for the CChartCtrl                                                       */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 10JUN02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          10JUN02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
// ChartCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "ChartCtrl.h"
#include "math.h"

/////////////////////////////////////////////////////////////////////////////
// CChartCtrl

extern double AutoScale(double dValue, BOOL bDirection);

CChartCtrl::CChartCtrl() : 
    m_bHeaderVisible(TRUE),
    m_bFooterVisible(TRUE),
    m_bLegendVisible(TRUE) {

    SetLegendPosition(eBOTTOM);
    
    return;
    }

CChartCtrl::~CChartCtrl() {}

BEGIN_MESSAGE_MAP(CChartCtrl, CWnd)
	//{{AFX_MSG_MAP(CChartCtrl)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_ERASEBKGND()
	ON_WM_LBUTTONDBLCLK()
	ON_WM_RBUTTONDOWN()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
    ON_MESSAGE(CHART_UPDATE_WINDOW, UpdateWindow)
    ON_MESSAGE(WM_GET_POPUP_TEXT, OnGetPopupText)
    ON_MESSAGE(WM_LBUTTONDBLCLK_DATA_POINT, OnDoubleClickDataPoint)
END_MESSAGE_MAP()

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::SetChartType()                                                         */
/*                                                                                              */
/* Purpose : sets the type of chart to be displayed. some chart types have forced attributes    */
/*                                                                                              */
/* Inputs  : enum CHART_TYPE eChartType -> type of chart to set                                 */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 15MAY02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          15MAY02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::SetChartType(enum CHART_TYPE eChartType) {

    m_eChartType = TYPE_NONE;

    //we don't allow either of the strip chart base types
    if (TYPE_STRIP_CHART==eChartType)
        eChartType = TYPE_STRIP_CHART_15;
    else if (TYPE_STRIP_CHART_FILLED==eChartType)
        eChartType = TYPE_STRIP_CHART_15_FILLED;
    
    //if a rotatable chart then set the defaults
    if (TYPE_BAR            ==eChartType||
        TYPE_ROTATED_PIE    ==eChartType) {
        SetDepth(50);
        SetHorzRotation(50);
        SetVertRotation(50);

        m_wndChartWnd.SetAxisStyles(X_AXIS, AUTO_SCALE|AXIS_BOTTOM|TICK_MINOR|TICK_MAJOR|GRAT_MINOR|GRAT_MAJOR);
        }
    else {
        SetDepth(0);
        SetHorzRotation(0);
        SetVertRotation(0);
        }

    //if a pie then don't draw the axis
    if (TYPE_PIE            ==eChartType||
        TYPE_ROTATED_PIE    ==eChartType)
        m_wndChartWnd.SetGenericAxisStyle(NO_DRAW);
    else
        m_wndChartWnd.SetGenericAxisStyle(DRAW);

    //set the generic axis style if a strip chart
    switch (eChartType) {
        case TYPE_STRIP_CHART_15:
        case TYPE_STRIP_CHART_30:
        case TYPE_STRIP_CHART_60:
        case TYPE_STRIP_CHART_120:
        case TYPE_STRIP_CHART_300:
        case TYPE_STRIP_CHART_600:
            m_wndChartWnd.SetGenericAxisStyle(TYPE_STRIP_CHART|m_wndChartWnd.GetGenericAxisStyle());
            m_eChartType = TYPE_STRIP_CHART;
            m_wndChartWnd.SetChartType(eChartType);
            break;
        case TYPE_STRIP_CHART_15_FILLED:
        case TYPE_STRIP_CHART_30_FILLED:
        case TYPE_STRIP_CHART_60_FILLED:
        case TYPE_STRIP_CHART_120_FILLED:
        case TYPE_STRIP_CHART_300_FILLED:
        case TYPE_STRIP_CHART_600_FILLED:
            m_wndChartWnd.SetGenericAxisStyle(TYPE_STRIP_CHART_FILLED|m_wndChartWnd.GetGenericAxisStyle());
            m_eChartType = TYPE_STRIP_CHART_FILLED;
            m_wndChartWnd.SetChartType(eChartType);
            break;
        default:
            m_wndChartWnd.SetChartType(m_eChartType = eChartType);
        }

    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::SetDepth()                                                             */
/*                                                                                              */
/* Purpose : sets the depth of the chart for a 3D look                                          */
/*                                                                                              */
/* Inputs  : BYTE yDepth -> amount of depth desired                                             */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::SetDepth(BYTE yDepth) {
    
    if (TYPE_STRIP_CHART        ==m_eChartType||
        TYPE_STRIP_CHART_FILLED ==m_eChartType||
        TYPE_LINE               ==m_eChartType||
        TYPE_AREA               ==m_eChartType||
        TYPE_XY                 ==m_eChartType||
        TYPE_PIE                ==m_eChartType)
        return;
    
    m_wndChartWnd.SetDepth(yDepth); 
    
    if (::IsWindow(m_hWnd)) 
        m_wndChartWnd.Invalidate();
    
    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::SetHorzRotation()                                                      */
/*                                                                                              */
/* Purpose : sets the amount of horo rotation of the chart for a 3D look                        */
/*                                                                                              */
/* Inputs  : BYTE yDepth -> amount of depth desired                                             */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::SetHorzRotation(double dHorzRotation) {
    
    if (TYPE_STRIP_CHART        ==m_eChartType||
        TYPE_STRIP_CHART_FILLED ==m_eChartType||
        TYPE_LINE               ==m_eChartType||
        TYPE_AREA               ==m_eChartType||
        TYPE_XY                 ==m_eChartType||
        TYPE_PIE                ==m_eChartType)
        return;
    
    m_wndChartWnd.SetHorzRotation(dHorzRotation); 
    
    if (::IsWindow(m_hWnd)) 
        m_wndChartWnd.Invalidate();
    
    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::SetVertRotation()                                                      */
/*                                                                                              */
/* Purpose : sets the amount of vert rotation of the chart for a 3D look                        */
/*                                                                                              */
/* Inputs  : BYTE yDepth -> amount of depth desired                                             */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::SetVertRotation(double dVertRotation) {
    
    if (TYPE_STRIP_CHART        ==m_eChartType||
        TYPE_STRIP_CHART_FILLED ==m_eChartType||
        TYPE_LINE               ==m_eChartType||
        TYPE_AREA               ==m_eChartType||
        TYPE_XY                 ==m_eChartType||
        TYPE_PIE                ==m_eChartType)
        return;
    
    m_wndChartWnd.SetVertRotation(dVertRotation); 
    
    if (::IsWindow(m_hWnd)) 
        m_wndChartWnd.Invalidate();
    
    return;
    }
    
/////////////////////////////////////////////////////////////////////////////
// CChartCtrl message handlers

⌨️ 快捷键说明

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