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

📄 2dscale.cpp

📁 The application wizard has created this SoccerDoctor application for you. This application not onl
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    CRect Rect;
    if (m_sYAxisText.GetLength()) {
        m_pDC->SelectObject(m_pYAxisFont);
        Rect.SetRectEmpty();
        m_pDC->DrawText(m_sYAxisText, &Rect, DT_CALCRECT);
        
        Rect.bottom ^= Rect.right;
        Rect.right ^= Rect.bottom;
        Rect.bottom ^= Rect.right;
        //compensate for rotated text
        Rect.top -= Rect.Width();

        int nMin(_YValueToPixel(m_dYMin));
        int nMax(_YValueToPixel(m_dYMax));

        Rect.OffsetRect(0, nMax);
        Rect.OffsetRect(0, (m_pRect->Height()-Rect.Height())/2);
        
        nYAxisOffset = 2*Rect.Width();

        if (m_dwYStyle&AXIS_LEFT) {
            Rect.OffsetRect(7, 0);
            m_pRect->left += Rect.Width()*2 - 7;
            }
        else {
            m_pRect->right -= Rect.Width()*2;
            Rect.OffsetRect(m_FullRect.Width()-Rect.Width()-5, 0);
            }

        m_pDC->DrawText(m_sYAxisText, &Rect, DT_BOTTOM|DT_SINGLELINE);
        m_pDC->SelectObject(m_pFont);
        }
    
    //the x axis text
    if (m_sXAxisText.GetLength()) {
        Rect.SetRectEmpty();
        m_pDC->DrawText(m_sXAxisText, &Rect, DT_CALCRECT);

        int nMin(_XValueToPixel(m_dXMin));
        int nMax(_XValueToPixel(m_dXMax));

        Rect.OffsetRect(nMin, 0);
        Rect.OffsetRect((m_pRect->Width()-Rect.Width())/2, 0);
        
        nXAxisOffset = 2*Rect.Height();

        if (m_dwXStyle&AXIS_BOTTOM) {
            Rect.OffsetRect(0, m_pRect->Height()-Rect.Height());
            m_pRect->bottom -= Rect.Height()*2;
            }
        else {
            Rect.OffsetRect(0, 10);
            m_pRect->top += Rect.Height()*2;
            }
        
        m_pDC->DrawText(m_sXAxisText, &Rect, DT_RIGHT|DT_VCENTER);
        }
    
    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: C2DScale::_DrawAxis()                                                              */
/*                                                                                              */
/* Purpose : draws the axes                                                                     */
/*                                                                                              */
/* Inputs  : NONE                                                                               */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 29JAN02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          29JAN02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/    
void C2DScale::_DrawAxis() {
    
    int dY = (int)(m_yDepth*sin(D2R(m_dVertRotation)));
    int dX = (int)(m_yDepth*sin(D2R(m_dHorzRotation)));
    
    if (dY>DBL_EPSILON||m_dwXStyle&AXIS_BOTTOM) {
        m_pDC->MoveTo(m_pRect->left, m_pRect->bottom);
        m_pDC->LineTo(m_pRect->right-dX, m_pRect->bottom);
        m_pDC->LineTo(m_pRect->right, m_pRect->bottom-dY);
        m_pDC->LineTo(m_pRect->left+dX, m_pRect->bottom-dY);
        }
    else {
        m_pDC->MoveTo(m_pRect->left, m_pRect->top);
        m_pDC->LineTo(m_pRect->right, m_pRect->top);
        }

    if (dX>DBL_EPSILON||m_dwYStyle&AXIS_LEFT) {
        m_pDC->MoveTo(m_pRect->left, m_pRect->bottom);
        m_pDC->LineTo(m_pRect->left, m_pRect->top+dY);
        m_pDC->LineTo(m_pRect->left+dX, m_pRect->top);
        m_pDC->LineTo(m_pRect->left+dX, m_pRect->bottom-dY);
        //one extra pixel to maintain a straight diaganol line
        m_pDC->LineTo(m_pRect->left, m_pRect->bottom);
        }
    else {
        m_pDC->MoveTo(m_pRect->right, m_pRect->bottom);
        m_pDC->LineTo(m_pRect->right, m_pRect->top);
        }

}

/************************************************************************************************/
/*                                                                                              */
/* Function: C2DScale::_DrawGraticules()                                                        */
/*                                                                                              */
/* Purpose : draws the graticules                                                               */
/*                                                                                              */
/* Inputs  : NONE                                                                               */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 29JAN02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          29JAN02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/    
void C2DScale::_DrawGraticules() {
    
    int dY = (int)(m_yDepth*sin(D2R(m_dVertRotation)));
    int dX = (int)(m_yDepth*sin(D2R(m_dHorzRotation)));
    
    double dStepX(m_dXMin);
    double dStepY(m_dYMin);

    double dInc(0);

    if ((m_dwXStyle&GRAT_MAJOR)||(m_dwXStyle&GRAT_MINOR)) {
        if (m_dwXStyle&GRAT_MINOR)
            dInc = m_dMinorStepX;
        else if (m_dwXStyle&GRAT_MAJOR)
            dInc = m_dMajorStepXDraw;

        int nStep(1);
        while (m_dMajorStepXDraw>nStep) {
            nStep += 1;
            }

        if (TYPE_STRIP_CHART&m_dwGenericStyle||
            TYPE_STRIP_CHART_FILLED&m_dwGenericStyle) {
            if (m_bRemoved) {
                //find out where we are supposed to start...
                while (m_dwXStyle&TICK_TEXT&&dStepX<=m_dXMax) {
                    if (!((long)dStepX%nStep))
                        break;
                    dStepX += 1;
                    }
                }
            
            //now start drawing the grats...
            while (m_dwXStyle&TICK_TEXT&&dStepX<=m_dXMax) {
                if ((long)dStepX%nStep) {
                    dStepX += 1;
                    continue;
                    }
                
                m_pDC->MoveTo(_XValueToPixel(dStepX)+dX, m_pRect->top);
                m_pDC->LineTo(_XValueToPixel(dStepX)+dX, m_pRect->bottom-dY);
                m_pDC->LineTo(_XValueToPixel(dStepX), m_pRect->bottom);
                dStepX += nStep;
                }
            }
        else {
            while (dStepX<=m_dXMax) {
                m_pDC->MoveTo(_XValueToPixel(dStepX)+dX, m_pRect->top);
                m_pDC->LineTo(_XValueToPixel(dStepX)+dX, m_pRect->bottom-dY);
                m_pDC->LineTo(_XValueToPixel(dStepX), m_pRect->bottom);
                dStepX += dInc;
                }
            }

        if (1||dStepX-dInc!=m_dXMax) {
            m_pDC->MoveTo(_XValueToPixel(m_dXMax)+dX, m_pRect->top);
            m_pDC->LineTo(_XValueToPixel(m_dXMax)+dX, m_pRect->bottom-dY);
            }
        }
    
    if ((m_dwYStyle&GRAT_MAJOR)||(m_dwYStyle&GRAT_MINOR)) {
        if (m_dwYStyle&GRAT_MINOR)
            dInc = m_dMinorStepY;
        else if (m_dwYStyle&GRAT_MAJOR)
            dInc = m_dMajorStepYDraw;

        while (dStepY<=m_dYMax) {
            m_pDC->MoveTo(m_pRect->right, _YValueToPixel(dStepY)-dY);
            m_pDC->LineTo(m_pRect->left+dX, _YValueToPixel(dStepY)-dY);
            m_pDC->LineTo(m_pRect->left, _YValueToPixel(dStepY));
            dStepY += dInc;
            }

        if (dStepY-dInc!=m_dYMax) {
            m_pDC->MoveTo(m_pRect->right, _YValueToPixel(m_dYMax)-dY);
            m_pDC->LineTo(m_pRect->left+dX, _YValueToPixel(m_dYMax)-dY);
            }
        }
    
    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: C2DScale::_DrawTickMarks()                                                         */
/*                                                                                              */
/* Purpose : draws tick marks                                                                   */
/*                                                                                              */
/* Inputs  : NONE                                                                               */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */

⌨️ 快捷键说明

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