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

📄 dataseries.cpp

📁 The application wizard has created this SoccerDoctor application for you. This application not onl
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/*                                                                                              */
/* Scott Pelger          12MAR02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CDataSeriesArray::DrawData(CDC* pDC, C2DScale* pScale) {

    m_pDC = pDC;
    m_pScale = pScale;

    int nY = (int)(m_pScale->m_yDepth*sin(D2R(m_pScale->m_dVertRotation)));
    int nX = (int)(m_pScale->m_yDepth*sin(D2R(m_pScale->m_dHorzRotation)));

    switch (m_eChartType) {
        case TYPE_LINE :
        case TYPE_STRIP_CHART :
            _DrawLineChart(nX, nY);
            break;
        case TYPE_AREA :
        case TYPE_STRIP_CHART_FILLED :
            _DrawAreaChart(nX, nY);
            break;
        case TYPE_XY :
            _DrawXYChart(nX, nY);
            break;
        case TYPE_BAR :
            _DrawBarChart(nX, nY);
            break;
        case TYPE_PIE :
            _DrawPieChart(nX, nY);
            break;
        case TYPE_ROTATED_PIE :
            _DrawRotatedPieChart(nX, nY);
            break;
        }

    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: DrawIcons()                                                                        */
/*                                                                                              */
/* Purpose : draws any icons                                                                    */
/*                                                                                              */
/* Inputs  : CDC* pDC -> the device context to draw with                                        */
/*           C2DScale* pScale -> pointer to the scale class for access to the private methods   */
/*           and members of which this class has been granted friendship                        */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 12MAR02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          12MAR02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CDataSeriesArray::DrawIcons(CDC* pDC, C2DScale* pScale) {

    m_pDC = pDC;
    m_pScale = pScale;

    CDataPoint* pDataPoint = NULL;
    CDataSeries* pDataSeries = NULL;
    CPoint* pPointArray = NULL;
    
    for (int i(0);i<m_DataSeriesArray.GetSize();i++) {
        pDataSeries = (CDataSeries*)m_DataSeriesArray.GetAt(i);
        if (!pDataSeries->GetCount())
            continue;

        int j((m_pbScrolling&&*m_pbScrolling)?pDataSeries->GetCount()-2:0);
        j = TYPE_STRIP_CHART_FILLED==m_eChartType?j:0;
        for (;j<pDataSeries->GetCount();j++) {
            pDataPoint = pDataSeries->GetAt(j);
			if (pDataPoint->m_hIcon){
                m_pDC->DrawIcon(m_pScale->_XValueToPixel(TYPE_STRIP_CHART_FILLED==m_eChartType||TYPE_STRIP_CHART==m_eChartType?pDataPoint->m_dX:j)-32, 
                                m_pScale->_YValueToPixel(pDataPoint->m_dY), pDataPoint->m_hIcon);
			}
		}
	}
}

/************************************************************************************************/
/*                                                                                              */
/* Function: ChartCompare()                                                                     */
/*                                                                                              */
/* Purpose : this function compares the m_dY member of a CDataPoint array                       */
/*                                                                                              */
/* Inputs  : const void* v1 -> pointer to an item to compare                                    */
/*           const void* v2 -> pointer to an item to compare                                    */
/*                                                                                              */
/* Outputs : int <- -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2                                  */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 10MAR02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          10MAR02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
BYTE ySortAxis;
int	ChartCompare(const void *v1, const void *v2) {
	
    CDataPoint* n1;
	CDataPoint* n2;
	
    int equal = 0;

	n1 = ((CDataPoint *)v1);
	n2 = ((CDataPoint *)v2);

    if(n1 == NULL || n2 == NULL) {
		ASSERT(FALSE);
        return 0;
        }

	if ((BYTE)(X_AXIS>>24)==ySortAxis)
        return n1->m_dX>n2->m_dX?1:n2->m_dX>n1->m_dX?-1:0;
    else if ((BYTE)(Y_AXIS>>24)==ySortAxis)
        return n1->m_dY>n2->m_dY?1:n2->m_dY>n1->m_dY?-1:0;

    return 0;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: _DrawLineChart()                                                                   */
/*                                                                                              */
/* Purpose : draws a line chart                                                                 */
/*                                                                                              */
/* Inputs  : int nX -> x offset for depth due to rotation                                       */
/*           int nY -> y offset for depth due to rotation                                       */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 12MAR02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          12MAR02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CDataSeriesArray::_DrawLineChart(int nX, int nY) {

    CDataPoint* pDataPoint = NULL;
    CDataSeries* pDataSeries = NULL;
    CPoint* pPointArray = NULL;
    
    CPen Pen;

    for (int i(0);i<m_DataSeriesArray.GetSize();i++) {
        pDataSeries = (CDataSeries*)m_DataSeriesArray.GetAt(i);
        if (!pDataSeries->GetCount())
            continue;

        pPointArray = new CPoint[pDataSeries->GetCount()];

        //set the series' color
        Pen.CreatePen(PS_SOLID, 1, pDataSeries->m_crColor);
        CPen* pOldPen = m_pDC->SelectObject(&Pen);

        pDataPoint = pDataSeries->GetAt(0);
        
        for (int j(0);j<pDataSeries->GetCount();j++) {
            pDataPoint = pDataSeries->GetAt(j);
            pPointArray[j].x = m_pScale->_XValueToPixel(TYPE_STRIP_CHART==m_eChartType?pDataPoint->m_dX:j);
            pPointArray[j].y = m_pScale->_YValueToPixel(pDataPoint->m_dY);

            if (m_eChartType==TYPE_LINE) {
                pDataPoint->m_DetectRegion.DeleteObject();
                pDataPoint->m_PopupRegion.DeleteObject();
                pDataPoint->m_DetectRegion.CreateRectRgn(pPointArray[j].x-5, pPointArray[j].y-5,
                                                         pPointArray[j].x+5, pPointArray[j].y+5);
                pDataPoint->m_PopupRegion.CreateRectRgn(pPointArray[j].x-5, pPointArray[j].y-5,
                                                        pPointArray[j].x+5, pPointArray[j].y+5);
                }
            }
        m_pDC->Polyline(pPointArray, pDataSeries->GetCount());
        m_pDC->SelectObject(pOldPen);
		Pen.DeleteObject();
        
        delete [] pPointArray;
        }
    
    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: _DrawRotatedLineChart()                                                            */
/*                                                                                              */
/* Purpose : draws a rotated line char

⌨️ 快捷键说明

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