• 大小: 46KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: C/C++
  • 标签: GDI  

资源简介

MFC画二维动态图表

资源截图

代码片段和文件信息

// 2DBarGraph.cpp: implementation of the C2DBarGraph class.
//
//////////////////////////////////////////////////////////////////////

#include “stdafx.h“
#include “2DBarGraph.h“

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

C2DBarGraph::C2DBarGraph(CPoint g_position CSize g_size)
{
// Set graph position and size
m_Position = g_position;
m_Size = g_size;

// Set graph segments and series number
m_SegmentsNumber = 0;
m_Segments = NULL;
m_SeriesNumber = 0;
m_Series = NULL;

// Set graph legend font
m_LegendFont = new CFont();
m_LegendFont->CreateFont( int(m_Size.cy*0.075) 0 0 0 FW_NORMAL FALSE FALSE FALSE
DEFAULT_CHARSET OUT_CHARACTER_PRECIS CLIP_CHARACTER_PRECIS PROOF_QUALITY DEFAULT_PITCH | FF_DONTCARE “Arial“ );

// Set graph series font
m_SegmentFont = NULL;

// Set graph value font
m_ValueFont = new CFont();
m_ValueFont->CreateFont( int(m_Size.cy*0.1) 0 0 0 FW_NORMAL FALSE FALSE FALSE
DEFAULT_CHARSET OUT_CHARACTER_PRECIS CLIP_CHARACTER_PRECIS PROOF_QUALITY DEFAULT_PITCH | FF_DONTCARE “Arial“ );

// Set default graph background color
m_GraphBkColor = RGB(2552552555);

// Set default graph labels color
m_LabelsColor = RGB(000);

// Set default graph legend background color
m_LegendBackgroundColor = RGB(255255255);
m_LegendTextColor = RGB(000);
}

C2DBarGraph::~C2DBarGraph()
{
// Delete graph segments and series
ClearGraph();

// Delete graph legend font
m_LegendFont->Deleteobject();
delete m_LegendFont;
m_LegendFont = NULL;

// Delete graph segment font
m_SegmentFont = NULL;

// Delete graph value font
m_ValueFont->Deleteobject();
delete m_ValueFont;
m_ValueFont = NULL;
}

void C2DBarGraph::ClearGraph()
{
_2DBarGraphSeries *curr_ser *prev_ser;
_2DBarGraphSegments *curr_seg *prev_seg;
_2DBarGraphValues *curr_val *prev_val;

// Delete all graph series
curr_ser = m_Series;
while ( curr_ser != NULL )
{
// Delete all graph values
curr_val = curr_ser->values;
while ( curr_val != NULL )
{
prev_val = curr_val;
curr_val = curr_val->next;
delete prev_val;
}

prev_ser = curr_ser;
curr_ser = curr_ser->next;
delete prev_ser;
}

// Delete all graph segments
curr_seg = m_Segments;
while ( curr_seg != NULL )
{
prev_seg = curr_seg;
curr_seg = curr_seg->next;
delete prev_seg;
}

// Set graph segment and series parameters
m_Segments = NULL;
m_SegmentsNumber = 0;
m_Series = NULL;
m_SeriesNumber = 0;
}

void C2DBarGraph::BuildGraph(HDC hDC)
{
int seg_width seg_height;
CPoint ser_start seg_font_pos;
int ser_width;
int max_value;

// Set graph step parameters
int seg_area = int(m_Size.cx*0.6);
int se

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        4311  2005-01-18 19:14  CGraphExample.cpp
     文件        5336  2005-01-18 19:14  CGraphExample.dsp
     文件         551  2005-01-18 19:14  CGraphExample.dsw
     文件        1433  2005-01-18 19:14  CGraphExample.h
     文件       11242  2005-01-18 19:14  CGraphExample.rc
     文件        1882  2005-01-18 19:14  CGraphExampleDoc.cpp
     文件        1552  2005-01-18 19:14  CGraphExampleDoc.h
     文件       20913  2005-01-21 07:11  CGraphExampleView.cpp
     文件        2322  2005-01-18 19:14  CGraphExampleView.h
     文件       31831  2005-01-21 07:16  Graphobject.cpp
     文件        4371  2005-01-21 07:12  Graphobject.h
     文件        2514  2005-01-18 19:14  MainFrm.cpp
     文件        1581  2005-01-18 19:14  MainFrm.h
     文件          67  2005-01-18 19:14  MathParams.h
     文件        4479  2005-01-18 19:14  ReadMe.txt
     文件         922  2005-01-18 19:14  Resource.h
     文件         215  2005-01-18 19:14  StdAfx.cpp
     文件        1026  2005-01-18 19:14  StdAfx.h
     文件        1078  2005-01-18 19:14  res\CGraphExample.ico
     文件         405  2005-01-18 19:14  res\CGraphExample.rc2
     文件        1078  2005-01-18 19:14  res\CGraphExampleDoc.ico
     文件        1078  2005-01-18 19:14  res\Toolbar.bmp
     目录           0  2005-01-19 07:12  res\
     文件       57938  2005-01-21 07:25  2DBarGraph.cpp
     文件        2645  2005-01-19 07:29  2DBarGraph.h
     文件       43580  2005-01-21 07:29  2DLineGraph.cpp
     文件        2618  2005-01-19 07:28  2DLineGraph.h
     文件       22607  2005-01-21 07:19  2DPieGraph.cpp
     文件        2051  2005-01-19 07:28  2DPieGraph.h
     文件        2605  2005-01-21 07:12  CGraphExample.clw

评论

共有 条评论