/*
*
* 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)
{
CChartDateTimeAxis* pAxis = new CChartDateTimeAxis();
没有合适的资源?快使用搜索试试~ 我知道了~
chartctrl-demo
共337个文件
html:161个
svn-base:62个
h:41个
需积分: 5 1 下载量 89 浏览量
2023-09-07
09:30:37
上传
评论
收藏 790KB ZIP 举报
温馨提示
chartctrl_demo
资源推荐
资源详情
资源评论
收起资源包目录
chartctrl-demo (337个子文件)
all-wcprops 4KB
ChartCtrl.cpp 30KB
ColourPopup.cpp 30KB
ChartDemoDlg.cpp 21KB
ChartAxis.cpp 19KB
ChartDateTimeAxis.cpp 10KB
ColourPicker.cpp 10KB
ChartLineSerie.cpp 10KB
ChartBarSerie.cpp 10KB
ChartLegend.cpp 9KB
ChartPointsSerie.cpp 9KB
ChartSurfaceSerie.cpp 7KB
ChartCandlestickSerie.cpp 7KB
SeriesPropDlg.cpp 6KB
ChartGanttSerie.cpp 6KB
ChartXYSerie.cpp 5KB
ChartLogarithmicAxis.cpp 5KB
ChartScrollBar.cpp 5KB
ChartStandardAxis.cpp 5KB
ChartTitle.cpp 5KB
ChartSerie.cpp 4KB
ChartGradient.cpp 4KB
ChartAxisLabel.cpp 4KB
ChartFont.cpp 3KB
ChartGrid.cpp 3KB
ChartDragLineCursor.cpp 2KB
ChartDemo.cpp 2KB
ChartCrossHairCursor.cpp 2KB
PointsPropDialog.cpp 2KB
ChartCursor.cpp 1KB
SurfacePropDialog.cpp 1KB
LinePropDialog.cpp 1KB
StdAfx.cpp 211B
doxygen.css 6KB
tabs.css 2KB
ChartDemo.dsp 10KB
ChartDemo.dsw 543B
entries 8KB
entries 677B
format 2B
format 2B
tab_r.gif 3KB
tab_l.gif 706B
tab_b.gif 35B
ChartCtrl.h 21KB
ChartAxis.h 17KB
ChartSerie.h 9KB
ChartSerieBase.h 7KB
ChartBarSerie.h 7KB
ChartPointsArray.h 6KB
ChartDateTimeAxis.h 5KB
ChartXYSerie.h 5KB
ChartGanttSerie.h 5KB
ChartLegend.h 5KB
ColourPopup.h 5KB
ChartCandlestickSerie.h 4KB
ChartSurfaceSerie.h 4KB
ChartTitle.h 4KB
ColourPicker.h 4KB
ChartCursor.h 4KB
ChartLabel.h 4KB
ChartLineSerie.h 3KB
ChartPointsSerie.h 3KB
resource.h 3KB
ChartAxisLabel.h 3KB
ChartBalloonLabel.h 3KB
ChartFont.h 3KB
ChartMouseListener.h 3KB
ChartDemoDlg.h 2KB
ChartStandardAxis.h 2KB
ChartScrollBar.h 2KB
ChartDragLineCursor.h 2KB
ChartGrid.h 2KB
SeriesPropDlg.h 2KB
ChartSeriesMouseListener.h 2KB
ChartCrossHairCursor.h 2KB
ChartGradient.h 2KB
ChartLogarithmicAxis.h 2KB
PointsPropDialog.h 1KB
ChartDemo.h 1KB
SurfacePropDialog.h 1KB
LinePropDialog.h 1KB
StdAfx.h 1KB
ChartString.h 932B
PointsOrdering.h 917B
class_c_chart_ctrl.html 75KB
class_c_chart_axis.html 61KB
class_c_chart_serie.html 50KB
_chart_ctrl_8h-source.html 39KB
class_c_chart_serie_base.html 38KB
_chart_axis_8h-source.html 36KB
class_c_chart_bar_serie-members.html 24KB
class_c_chart_surface_serie-members.html 23KB
_chart_serie_8h-source.html 22KB
class_c_chart_points_serie-members.html 22KB
class_c_chart_points_array.html 21KB
_chart_axis_old_8h-source.html 21KB
class_c_chart_line_serie-members.html 21KB
class_c_chart_x_y_serie.html 20KB
class_c_chart_x_y_serie-members.html 20KB
共 337 条
- 1
- 2
- 3
- 4
资源评论
shuda356421
- 粉丝: 0
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- SOIL库,包括include和lib文件夹
- 别墅图纸编号D068-两层-13.50&14.10米- 施工图-施工说明.dwg
- 别墅图纸编号D068-两层-13.50&14.10米- 施工图-第一张.dwg
- 别墅图纸编号D068-两层-13.50&14.10米- 施工图-第5张.dwg
- zabbix-agent-6.0.25-windows-amd64-openssl.msi
- 别墅图纸编号D068-两层-13.50&14.10米- 施工图-第四张.dwg
- AUTOSAR-SWS-PWMDriver.pdf
- AUTOSAR-SWS-PortDriver.pdf
- 别墅图纸编号D068-两层-13.50&14.10米- 施工图-第三张.dwg
- AUTOSAR-SWS-OCUDriver.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功