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

📄 chartctrl.cpp

📁 The application wizard has created this SoccerDoctor application for you. This application not onl
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                m_ChartRect.right = m_LegendRect.left;
                break;
            case eTOP :
                m_ChartRect.top = m_LegendRect.bottom;
                break;
            case eBOTTOM :
                m_ChartRect.bottom = m_LegendRect.top;
                break;
            }
        }

    if (m_bHeaderVisible)
        m_ChartRect.top = m_HeaderRect.bottom;
    if (m_bFooterVisible)
        m_ChartRect.bottom = m_FooterRect.top;
    
    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::_RecalculateAllWindows()                                               */
/*                                                                                              */
/* Purpose : recalculates all window components for the chart control                           */
/*                                                                                              */
/* Inputs  : NONE                                                                               */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::_RecalculateAllWindows() {
    
    if (!IsWindow(m_hWnd))
        return;

    CClientDC DC(this);

    CRect WindowRect;
    GetClientRect(&WindowRect);
    if (GetStyle()&RAISED_BORDER)
        WindowRect.DeflateRect(2, 2, 2, 2);

    m_ChartRect = m_LegendRect = m_FooterRect = m_HeaderRect = WindowRect;

    /****The Legend Window****/
    m_wndLegendWnd.SetInitialWindowSize(&m_LegendRect);
    _RecalculateLegend(WindowRect);
    
    if (m_wndLegendWnd.m_hWnd)
        m_wndLegendWnd.SetWindowPos(NULL, m_LegendRect.left, m_LegendRect.top, m_LegendRect.Width(), m_LegendRect.Height(), SWP_SHOWWINDOW);
    /****The Legend Window****/
    
    /****The Header Window****/
    _RecalculateHeader(WindowRect);

    if (m_wndHeaderWnd.m_hWnd)
        m_wndHeaderWnd.SetWindowPos(NULL, m_HeaderRect.left, m_HeaderRect.top, m_HeaderRect.Width(), m_HeaderRect.Height(), SWP_SHOWWINDOW);
    /****The Header Window****/
    
    /****The Footer Window****/
    _RecalculateFooter(WindowRect);

    if (m_wndFooterWnd.m_hWnd)
        m_wndFooterWnd.SetWindowPos(NULL, m_FooterRect.left, m_FooterRect.top, m_FooterRect.Width(), m_FooterRect.Height(), SWP_SHOWWINDOW);
    /****The Footer Window****/
    
    /****The Chart Window****/
    _RecalculateChart(WindowRect);

    if (m_wndChartWnd.m_hWnd)
        m_wndChartWnd.SetWindowPos(NULL, m_ChartRect.left, m_ChartRect.top, m_ChartRect.Width(), m_ChartRect.Height(), SWP_SHOWWINDOW);
    /****The Chart Window****/
    
}

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::SetAxisScale()                                                         */
/*                                                                                              */
/* Purpose : sets the scale for the specified axis, use of this function will turn off          */
/*           AUTO_SCALE if it is currently set for the specified axis                           */
/*                                                                                              */
/* Inputs  : DWORD dwAxis -> the axis to set                                                    */
/*           double dMin -> minimum setting                                                     */
/*           double dMax -> maximum setting                                                     */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::SetAxisScale(enum AXIS eAxis, double dMin, double dMax) {

    DWORD dwStyle = m_wndChartWnd.GetAxisStyles(eAxis) & ~AUTO_SCALE;
    m_wndChartWnd.SetAxisStyles(eAxis, dwStyle);

    m_wndChartWnd.SetAxisScale(eAxis, dMin, dMax);
    m_wndChartWnd.Invalidate();
    
    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::_SetAxisStyle()                                                        */
/*                                                                                              */
/* Purpose : called by SetAxisStyleX() and SetAxisStyleY(). sets the axis style for the         */
/*           specified axis (embedded in dweStyle).                                             */
/*                                                                                              */
/* Inputs  : DWORD dwStyle -> the style to set                                                  */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::_SetAxisStyle(DWORD dwStyle) {

    enum AXIS eAxis = (AXIS)(dwStyle&X_AXIS);
	if (!eAxis){
        eAxis = Y_AXIS;
	}
	if (!eAxis){
        eAxis = Z_AXIS;
	}

    m_wndChartWnd.SetAxisStyles(eAxis, dwStyle);
    
	if (AUTO_SCALE&dwStyle){
        _AutoScale(dwStyle);
	}
}

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::_AutoScale()                                                           */
/*                                                                                              */
/* Purpose : called to rescale the chart based on the axis                                      */
/*                                                                                              */
/* Inputs  : DWORD dwStyle -> style contains the axis                                           */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::_AutoScale(DWORD dwStyle) {

    double dMin(1);
    double dMax(5);

    if (X_AXIS&dwStyle) {
        GetXAxisRange(dMin, dMax);
        if (FORCE_ZERO&dwStyle)
            dMin = 0;
        
        //for now we will always set the bottom to ZERO
        dMin = 0;

        //for now we will always set the bottom to ZERO, so shave 1 off the max
        if (dMax>1)
            dMax = AutoScale(dMax-1, MAX);
        else
            dMax = AutoScale(dMax, MAX);
        
        if (TYPE_LINE               ==m_eChartType||
            TYPE_AREA               ==m_eChartType) {
            dMax = 0;
            for (int i(0);i<m_wndChartWnd.m_DataSeriesArray.GetCount();i++) {
                dMin = m_wndChartWnd.m_DataSeriesArray.GetNumOfDataPoints(i);
                dMax = dMax>dMin?dMax:dMin;
                }
            dMax -= 1;
            dMin = 0;
            
            dMax = AutoScale(dMax, MAX);

            /****see if we have any data points****/
            if (dMin>dMax+DBL_EPSILON) {
                dMin = 0;
                dMax = 0.0000000001;
                }
            /****see if we have any data points****/
                
            m_wndChartWnd.SetAxisScale(X_AXIS, dMin, dMax);
            m_wndChartWnd.SetScaleStep(X_AXIS, dMax/10, dMax/5);
            }
        else if (TYPE_STRIP_CHART        ==m_eChartType||
                 TYPE_STRIP_CHART_FILLED ==m_eChartType) {
            GetXAxisRange(dMin, dMax);
            
            /****see if we have any data points****/
            if (dMin>dMax+DBL_EPSILON) {
                CTime TTime = CTime::GetCurrentTime();
                dMin = (double)TTime.GetTime();
                dMax = dMin;
                }
            /****see if we have any data points****/
                
            m_wndChartWnd.SetAxisScale(X_AXIS, dMin, dMax);
            m_wndChartWnd.SetScaleStep(X_AXIS, 1, 10);
            }
        }

    if (Y_AXIS&dwStyle) {
        GetYAxisRange(dMin, dMax);
        if (FORCE_ZERO&dwStyle)
            dMin = 0;
        
        //for now we will always set the bottom to ZERO
        dMin = 0;
        
        /****see if we have any data points****/
        if (dMin>dMax+DBL_EPSILON) {
            dMin = 0;
            dMax = 0.0000000001;
            }
        /****see if we have any data points****/
        
        //dMin = AutoScale(m_wndChartWnd.m_DataSeriesArray.GetMinValue(), MIN);
        dMax = AutoScale(dMax, MAX);
        m_wndChartWnd.SetAxisScale(Y_AXIS, dMin, dMax);

        m_wndChartWnd.SetScaleStep(Y_AXIS, dMax/10, dMax/5);

⌨️ 快捷键说明

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