Click here to Skip to main content
12,635,662 members (24,593 online)
Click here to Skip to main content

Stats

224.8K views
19.4K downloads
164 bookmarked
Posted

A 2D Graph Component With Zoom Capability

, 21 Dec 2004 CPOL
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)

Share

About the Author

Hossein Khosravi
Software Developer (Senior) FarsiOCR.ir
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 , Ashura , Islamic Quotes

Commercial Site: Farsi OCR

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161208.2 | Last Updated 22 Dec 2004
Article Copyright 2004 by Hossein Khosravi
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid