Click here to Skip to main content
15,886,199 members
Articles / Desktop Programming / ATL

A 2D Graph Component With Zoom Capability

Rate me:
Please Sign up or sign in to vote.
4.92/5 (37 votes)
21 Dec 2004CPOL2 min read 288.2K   21.5K   166  
A 2D graph component with zoom capability.
// SmartGraphDemoView.h : interface of the CSmartGraphDemoView class
//


#pragma once
#include "SmartGraph.h"

enum CursorState { CURSOR_NORMAL, CURSOR_ZOOM_IN, CURSOR_ZOOM_OUT, CURSOR_HAND };

class CSmartGraphDemoView : public CFormView
{
protected: // create from serialization only
	CSmartGraphDemoView();
	DECLARE_DYNCREATE(CSmartGraphDemoView)

public:
	enum{ IDD = IDD_SMARTGRAPHDEMO_FORM };

// Attributes
public:
	CSmartGraphDemoDoc* GetDocument() const;

// Operations
public:

// Overrides
	public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual void OnInitialUpdate(); // called first time after construct

// Implementation
public:
	virtual ~CSmartGraphDemoView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	CRect m_rcSelRect;
	bool m_bFirstCall;
	int m_nSkipMove;
	bool m_bSkip;
	CBrush m_brSelection;
	void ZoomIn();
	void ZoomOut();
	HCURSOR m_hNormal, m_hZoomIn,m_hZoomOut,m_hHand;  
	CursorState 	m_nCursor;

// Generated message map functions
protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnZoomIn();
	afx_msg void OnZoomOut();
	afx_msg void OnZoomReset();
	CSmartGraph m_Graph;
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnUpdateZoomIn(CCmdUI *pCmdUI);
	afx_msg void OnUpdateZoomOut(CCmdUI *pCmdUI);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	DECLARE_EVENTSINK_MAP()
	void LButtonDownSmartgraph1(long xPos, long yPos, LONGLONG wParam);
	void LButtonUpSmartgraph1(long xPos, long yPos, LONGLONG wParam);
	void MouseMoveSmartgraph1(long xPos, long yPos, LONGLONG wParam);
	afx_msg void OnFileOpen();
	afx_msg void OnGraphtypeDot();
	afx_msg void OnGraphtypeLine();
	afx_msg void OnGraphtypeBar();
	afx_msg void OnNcPaint();
};

#ifndef _DEBUG  // debug version in SmartGraphDemoView.cpp
inline CSmartGraphDemoDoc* CSmartGraphDemoView::GetDocument() const
   { return reinterpret_cast<CSmartGraphDemoDoc*>(m_pDocument); }
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) https://shahaab-co.com
Iran (Islamic Republic of) Iran (Islamic Republic of)
Currently I'm working at Dept. of Electrical Engineering in University of Shahrood.
Pattern Recognition (specially OCR), Neural Networks, Image Processing and Machine Vision are my interests. However I'm a PROGRAMMER as well.
BSc: Sharif University of technology @ 2002
MSc. and PhD: Tarbiat Modarres University @ 2006 & 2010 respectively

Personal Blog: Andisheh Online

Religious Blogs: Shia Muslims , Islamic Quotes

Company Site: Shahaab-co
My old Site: Farsi OCR

Comments and Discussions