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

📄 chartutils.cpp

📁 The application wizard has created this SoccerDoctor application for you. This application not onl
💻 CPP
字号:
/************************************************************************************************
// $Header: /home/cvsroot/SoccerDoctor/Chart/ChartUtils.cpp,v 1.1 2002/09/07 06:03:54 peter Exp $
//***********************************************************************************************
/************************************************************************************************/
/*                                                                                              */
/* File    : ChartUtils.cpp                                                                     */
/*                                                                                              */
/* Purpose : utility functions that support the CChartCtrl                                      */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 10JUN02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          10JUN02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
#include "stdafx.h"
#include "float.h"

/************************************************************************************************/
/*                                                                                              */
/* Function: SubdueColor()                                                                      */
/*                                                                                              */
/* Purpose : based on the color arg this function will return a subdued shade.                  */
/*                                                                                              */
/* Inputs  : COLORREF Color -> the color to subdue                                              */
/*                                                                                              */
/* Outputs : COLORREF <- the subdued color                                                      */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 15MAY02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          15MAY02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
COLORREF SubdueColor(COLORREF Color) {

    BYTE Red(GetRValue(Color));
    BYTE Green(GetGValue(Color));
    BYTE Blue(GetBValue(Color));

    BYTE yLevel(30);

    if (Red>=yLevel)
        Red -= yLevel;
    else
        Red = 0;

    if (Green>=yLevel)
        Green -= yLevel;
    else
        Green = 0;

    if (Blue>=yLevel)
        Blue -= yLevel;
    else
        Blue = 0;

    return (RGB(Red, Green, Blue));
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: CreateBorderColor()                                                                */
/*                                                                                              */
/* Purpose : based on the color arg this function will return a darker shade for chart borders  */
/*           as in the pie and bar charts. similar to SubdueColor()                             */
/*                                                                                              */
/* Inputs  : COLORREF Color -> the color to create a border color for                           */
/*                                                                                              */
/* Outputs : COLORREF <- the border color                                                       */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 15MAY02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          15MAY02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
COLORREF CreateBorderColor(COLORREF Color) {

    return (Color&0xFF0000)/2&0xFF0000|
           (Color&0x00FF00)/2&0x00FF00|
           (Color&0x0000FF)/2&0x0000FF;
    }

#define MIN TRUE
#define MAX FALSE
/************************************************************************************************/
/*                                                                                              */
/* Function: AutoScale()                                                                        */
/*                                                                                              */
/* Purpose : based on the value and direction passed in this function will return an easy to use*/
/*           value to be used in setting the chart scales automatically                         */
/*                                                                                              */
/* Inputs  : double dValue -> the value to scale                                                */
/*           BOOL bDirection -> the direction to scale toward.                                  */
/*                                                                                              */
/* Outputs : double <- the auto scaled value                                                    */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 15MAY02     */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          15MAY02     initial version                                            */
/*                                                                                              */
/************************************************************************************************/
double AutoScale(double dValue, BOOL bDirection) {

    BOOL bNegative(dValue<0);
    
    if (bNegative) {
        dValue *= -1;
        bDirection = !bDirection;
        }

    if (dValue+DBL_EPSILON==0)
        return 0;

    double dLimits[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    double dReturn(0);

    while (9) {
        if (dValue<*dLimits) {
            *(dLimits+0) = *(dLimits+0)/10;
            *(dLimits+1) = *(dLimits+1)/10;
            *(dLimits+2) = *(dLimits+2)/10;
            *(dLimits+3) = *(dLimits+3)/10;
            *(dLimits+4) = *(dLimits+4)/10;
            *(dLimits+5) = *(dLimits+5)/10;
            *(dLimits+6) = *(dLimits+6)/10;
            *(dLimits+7) = *(dLimits+7)/10;
            *(dLimits+8) = *(dLimits+8)/10;
            *(dLimits+9) = *(dLimits+9)/10;
            }
        else if (dValue>*(dLimits+sizeof(dLimits)/sizeof(double)-1)) {
            *(dLimits+0) = *(dLimits+0)*10;
            *(dLimits+1) = *(dLimits+1)*10;
            *(dLimits+2) = *(dLimits+2)*10;
            *(dLimits+3) = *(dLimits+3)*10;
            *(dLimits+4) = *(dLimits+4)*10;
            *(dLimits+5) = *(dLimits+5)*10;
            *(dLimits+6) = *(dLimits+6)*10;
            *(dLimits+7) = *(dLimits+7)*10;
            *(dLimits+8) = *(dLimits+8)*10;
            *(dLimits+9) = *(dLimits+9)*10;
            }
        else
            break;
        }

    for (int i(0);MIN==bDirection&&i<sizeof(dLimits)/sizeof(double)-1;i++) {
        if (dValue>=*(dLimits+i)&&dValue<=*(dLimits+i+1)) {
            dReturn = *(dLimits+i);
            break;
            }
        }

    for (i=0;MAX==bDirection&&i<sizeof(dLimits)/sizeof(double)-1;i++) {
        if (dValue>=*(dLimits+i)&&dValue<=*(dLimits+i+1)) {
            dReturn = *(dLimits+i+1);
            break;
            }
        }

    if (bNegative)
        dReturn *= -1;

    return dReturn;
    }


//***********************************************************************************************
// END OF FILE
// $Log: ChartUtils.cpp,v $
// Revision 1.1  2002/09/07 06:03:54  peter
// 新的chart类,从别的地方拷来的
//
//***********************************************************************************************

⌨️ 快捷键说明

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