//Download by http://www.NewXing.com
/*
*
* ChartCtrl.cpp
*
* Written by C�dric Moonen (cedric_moonen@hotmail.com)
*
*
*
* This code may be used for any non-commercial and commercial purposes in a compiled form.
* The code may be redistributed as long as it remains unmodified and providing that the
* author name and this disclaimer remain intact. The sources can be modified WITH the author
* consent only.
*
* This code is provided without any garanties. I cannot be held responsible for the damage or
* the loss of time it causes. Use it at your own risks
*
* An e-mail to notify me that you are using this code is appreciated also.
*
*
* History:
* - 18/05/2006: Added support for panning
* - 28/05/2006: Bug corrected in RemoveAllSeries
* - 28/05/2006: Added support for resizing
* - 12/06/2006: Added support for manual zoom
* - 10/08/2006: Added SetZoomMinMax and UndoZoom
* - 24/03/2007: GDI leak corrected
* - 24/03/2007: Invisible series are not taken in account for auto axis
* and legend (thanks to jerminator-jp).
* - 24/03/2007: possibility to specify a margin for the axis. Needs to be improved
* - 05/04/2007: ability to change the text color of the axis.
* - 05/04/2007: ability to change the color of the border of the drawing area.
* - 05/04/2007: Surface series added.
* - 26/08/2007: The clipping area of the series is a bit larger (they will be
* drawn over the bottom and right axes).
* - 12/01/2007: Ability to change the color of the zoom rectangle.
* - 08/02/2008: Added convenience functions to convert from date to value and
* opposite.
* - 21/02/2008: The zoom doesn't do anything if the user only clicks on the control
* (thanks to Eugene Pustovoyt).
* - 29/02/2008: The auto axis are now refreshed when a series is removed (thanks to
* Bruno Lavier).
* - 08/03/2008: EnableRefresh function added (thanks to Bruno Lavier).
* - 21/03/2008: Added support for scrolling.
* - 25/03/2008: UndoZoom function added.
* - 25/03/2008: A series can now be removed using its pointer.
* - 12/08/2008: Performance patch (thanks to Nick Holgate).
* - 18/08/2008: Added support for printing.
* - 31/10/2008: Fixed a bug for unicode.
*
*/
#include "stdafx.h"
#include "ChartCtrl.h"
#include "ChartSerie.h"
#include "ChartGradient.h"
#include "ChartStandardAxis.h"
#include "ChartDateTimeAxis.h"
#include "ChartLogarithmicAxis.h"
#include "ChartCrossHairCursor.h"
#include "ChartDragLineCursor.h"
#include "ChartPointsSerie.h"
#include "ChartLineSerie.h"
#include "ChartSurfaceSerie.h"
#include "ChartBarSerie.h"
#include "ChartCandlestickSerie.h"
#include "ChartGanttSerie.h"
#if _MFC_VER > 0x0600
#include "atlImage.h"
#endif
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define CHARTCTRL_CLASSNAME _T("ChartCtrl") // Window class name
COLORREF pSeriesColorTable[] = { RGB(255,0,0), RGB(0,150,0), RGB(0,0,255), RGB(255,255,0), RGB(0,255,255),
RGB(255,128,0), RGB(128,0,128), RGB(128,128,0), RGB(255,0,255), RGB(64,128,128)};
/////////////////////////////////////////////////////////////////////////////
// CChartCtrl
CChartCtrl::CChartCtrl()
{
RegisterWindowClass();
m_iEnableRefresh = 1;
m_bPendingRefresh = false;
m_BorderColor = RGB(0,0,0);
m_BackColor = GetSysColor(COLOR_BTNFACE);
EdgeType = EDGE_RAISED;
m_BackGradientType = gtVertical;
m_bBackGradient = false;
m_BackGradientCol1 = m_BackGradientCol2 = m_BackColor;
for (int i=0;i<4;i++)
m_pAxes[i] = NULL;
m_pLegend = new CChartLegend(this);
m_pTitles = new CChartTitle(this);
m_bMemDCCreated = false;
m_bPanEnabled = true;
m_bRMouseDown = false;
m_bZoomEnabled = true;
m_bLMouseDown = false;
m_ZoomRectColor = RGB(255,255,255);
m_bToolBarCreated = false;
m_pMouseListener = NULL;
m_bMouseVisible = true;
}
CChartCtrl::~CChartCtrl()
{
TSeriesMap::iterator seriesIter = m_mapSeries.begin();
for (seriesIter; seriesIter!=m_mapSeries.end(); seriesIter++)
{
delete (seriesIter->second);
}
TCursorMap::iterator cursorIter = m_mapCursors.begin();
for (cursorIter; cursorIter!=m_mapCursors.end(); cursorIter++)
{
delete (cursorIter->second);
}
for (int i=0; i<4 ;i++)
{
if (m_pAxes[i])
delete m_pAxes[i];
}
if (m_pLegend)
{
delete m_pLegend;
m_pLegend = NULL;
}
if (m_pTitles)
{
delete m_pTitles;
m_pTitles = NULL;
}
}
BEGIN_MESSAGE_MAP(CChartCtrl, CWnd)
//{{AFX_MSG_MAP(CChartCtrl)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDBLCLK()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
ON_WM_RBUTTONDBLCLK()
ON_WM_SIZE()
ON_WM_HSCROLL()
ON_WM_VSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChartCtrl message handlers
void CChartCtrl::OnPaint()
{
CPaintDC dc(this); // device context for painting
if (!m_bMemDCCreated)
{
RefreshCtrl();
m_bMemDCCreated = true;
}
// Get Size of Display area
CRect rect;
GetClientRect(&rect);
dc.BitBlt(0, 0, rect.Width(), rect.Height(),
&m_BackgroundDC, 0, 0, SRCCOPY) ;
// Draw the zoom rectangle
if (m_bZoomEnabled && m_bLMouseDown)
{
CPen NewPen(PS_SOLID,1,m_ZoomRectColor);
CPen* pOldPen = dc.SelectObject(&NewPen);
dc.MoveTo(m_rectZoomArea.TopLeft());
dc.LineTo(m_rectZoomArea.right,m_rectZoomArea.top);
dc.LineTo(m_rectZoomArea.BottomRight());
dc.LineTo(m_rectZoomArea.left,m_rectZoomArea.bottom);
dc.LineTo(m_rectZoomArea.TopLeft());
dc.SelectObject(pOldPen);
DeleteObject(NewPen);
}
// Draw the cursors.
TCursorMap::iterator iter = m_mapCursors.begin();
for (iter; iter!=m_mapCursors.end(); iter++)
iter->second->Draw(&dc);
}
BOOL CChartCtrl::OnEraseBkgnd(CDC* )
{
// To avoid flickering
// return CWnd::OnEraseBkgnd(pDC);
return FALSE;
}
CChartCrossHairCursor* CChartCtrl::CreateCrossHairCursor(bool bSecondaryHorizAxis,
bool bSecondaryVertAxis)
{
CChartAxis* pHorizAxis = NULL;
CChartAxis* pVertAxis = NULL;
if (bSecondaryHorizAxis)
pHorizAxis = m_pAxes[TopAxis];
else
pHorizAxis = m_pAxes[BottomAxis];
if (bSecondaryVertAxis)
pVertAxis = m_pAxes[RightAxis];
else
pVertAxis = m_pAxes[LeftAxis];
ASSERT(pHorizAxis != NULL);
ASSERT(pVertAxis != NULL);
CChartCrossHairCursor* pNewCursor = new CChartCrossHairCursor(this, pHorizAxis, pVertAxis);
m_mapCursors[pNewCursor->GetCursorId()] = pNewCursor;
return pNewCursor;
}
CChartDragLineCursor* CChartCtrl::CreateDragLineCursor(EAxisPos relatedAxis)
{
ASSERT(m_pAxes[relatedAxis] != NULL);
CChartDragLineCursor* pNewCursor = new CChartDragLineCursor(this, m_pAxes[relatedAxis]);
m_mapCursors[pNewCursor->GetCursorId()] = pNewCursor;
return pNewCursor;
}
void CChartCtrl::AttachCustomCursor(CChartCursor* pCursor)
{
m_mapCursors[pCursor->GetCursorId()] = pCursor;
}
void CChartCtrl::RemoveCursor(unsigned cursorId)
{
TCursorMap::iterator iter = m_mapCursors.find(cursorId);
if (iter != m_mapCursors.end())
{
delete iter->second;
m_mapCursors.erase(iter);
}
}
void CChartCtrl::ShowMouseCursor(bool bShow)
{
m_bMouseVisible = bShow;
if (!bShow)
SetCursor(NULL);
}
CChartStandardAxis* CChartCtrl::CreateStandardAxis(EAxisPos axisPos)
{
CChartStandardAxis* pAxis = new CChartStandardAxis();
AttachCustomAxis(pAxis, axisPos);
return pAxis;
}
CChartLogarithmicAxis* CChartCtrl::CreateLogarithmicAxis(EAxisPos axisPos)
{
CChartLogarithmicAxis* pAxis = new CChartLogarithmicAxis();
AttachCustomAxis(pAxis, axisPos);
return pAxis;
}
CChartDateTimeAxis* CChartCtrl::CreateDateTimeAxis(EAxisPos axisPos)
{
CChartDateTimeA
没有合适的资源?快使用搜索试试~ 我知道了~
cchart.zip
共491个文件
html:161个
h:72个
svn-base:62个
需积分: 10 9 下载量 171 浏览量
2020-01-10
09:55:37
上传
评论
收藏 26.64MB ZIP 举报
温馨提示
c/c++曲线库函数,功能强大由于经常需要在程序中绘制一些曲线,一直在找一个好用的函数库, CChart主要特点: 1、可以绘制任意多条曲线,每条曲线任意选择颜色、线宽、线性等参数,可对封闭曲线进行填充。 2、对于多条曲线,可以以多种方式自动选择颜色,线型。 3、自动选择坐标轴的范围,也可指定坐标轴范围,坐标轴可以指定标题,颜色,字型及字体大小等。 4、上、下、左、右四个坐标轴可选。 ...
资源推荐
资源详情
资源评论
收起资源包目录
cchart.zip (491个子文件)
all-wcprops 4KB
ChartDemo.aps 31KB
ChartDemo.bsc 14.27MB
ChartCtrl.cpp 30KB
ChartCtrl.cpp 30KB
ColourPopup.cpp 30KB
ChartDemoDlg.cpp 21KB
ChartAxis.cpp 19KB
ChartAxis.cpp 19KB
ChartDateTimeAxis.cpp 10KB
ChartDateTimeAxis.cpp 10KB
ColourPicker.cpp 10KB
ChartLineSerie.cpp 10KB
ChartLineSerie.cpp 10KB
ChartBarSerie.cpp 10KB
ChartBarSerie.cpp 10KB
ChartLegend.cpp 9KB
ChartLegend.cpp 9KB
ChartPointsSerie.cpp 9KB
ChartPointsSerie.cpp 9KB
ChartSurfaceSerie.cpp 7KB
ChartSurfaceSerie.cpp 7KB
ChartCandlestickSerie.cpp 7KB
ChartCandlestickSerie.cpp 7KB
SeriesPropDlg.cpp 6KB
ChartGanttSerie.cpp 6KB
ChartGanttSerie.cpp 6KB
ChartXYSerie.cpp 5KB
ChartXYSerie.cpp 5KB
ChartLogarithmicAxis.cpp 5KB
ChartLogarithmicAxis.cpp 5KB
ChartScrollBar.cpp 5KB
ChartScrollBar.cpp 5KB
ChartStandardAxis.cpp 5KB
ChartStandardAxis.cpp 5KB
ChartTitle.cpp 5KB
ChartTitle.cpp 5KB
ChartSerie.cpp 4KB
ChartSerie.cpp 4KB
ChartGradient.cpp 4KB
ChartGradient.cpp 4KB
ChartAxisLabel.cpp 4KB
ChartAxisLabel.cpp 4KB
ChartFont.cpp 3KB
ChartFont.cpp 3KB
ChartGrid.cpp 3KB
ChartGrid.cpp 3KB
ChartDragLineCursor.cpp 2KB
ChartDragLineCursor.cpp 2KB
ChartDemo.cpp 2KB
ChartCrossHairCursor.cpp 2KB
ChartCrossHairCursor.cpp 2KB
PointsPropDialog.cpp 2KB
ChartCursor.cpp 1KB
ChartCursor.cpp 1KB
SurfacePropDialog.cpp 1KB
LinePropDialog.cpp 1KB
StdAfx.cpp 249B
doxygen.css 6KB
tabs.css 2KB
ChartDemo.dsp 10KB
ChartDemo.dsw 543B
entries 8KB
entries 677B
ChartDemo.exe 739KB
ChartDemo.vcxproj.filters 9KB
format 2B
format 2B
tab_r.gif 3KB
tab_l.gif 706B
tab_b.gif 35B
ChartCtrl.h 21KB
ChartCtrl.h 21KB
ChartAxis.h 17KB
ChartAxis.h 17KB
ChartSerie.h 9KB
ChartSerie.h 9KB
ChartSerieBase.h 7KB
ChartSerieBase.h 7KB
ChartBarSerie.h 7KB
ChartBarSerie.h 7KB
ChartPointsArray.h 6KB
ChartPointsArray.h 6KB
ChartDateTimeAxis.h 5KB
ChartDateTimeAxis.h 5KB
ChartXYSerie.h 5KB
ChartXYSerie.h 5KB
ChartGanttSerie.h 5KB
ChartGanttSerie.h 5KB
ChartLegend.h 5KB
ChartLegend.h 5KB
ColourPopup.h 5KB
ChartCandlestickSerie.h 4KB
ChartCandlestickSerie.h 4KB
ChartSurfaceSerie.h 4KB
ChartSurfaceSerie.h 4KB
ChartTitle.h 4KB
ChartTitle.h 4KB
ColourPicker.h 4KB
ChartCursor.h 4KB
共 491 条
- 1
- 2
- 3
- 4
- 5
资源评论
生命之树jungle
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 数据库课程设计.zip
- 这是利用tf2实现不同YOLO模型的集成库,支持训练自己数据集.zip
- 基于FPGA的二进制密码锁.zip
- GoogleAndroid开发入门与实战随书视频wmv最新版本
- PHP基于ThinkPHP5.1的wms进销存系统源码带文字安装教程数据库 MySQL源码类型 WebForm
- AndoridAPI手机系统编程完整版chm最新版本
- DevSidecar 和 GithubSpeed安装包
- JAVAspringboot进销存管理系统源码带文字搭建教程数据库 MySQL源码类型 WebForm
- PHP的ThinkPHP6.0小说CMS管理系统源码带搭建教程数据库 MySQL源码类型 WebForm
- java实现的贪吃蛇小游戏.zip学习资料
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功