Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

2D Graph ActiveX Control

, 5 Aug 2003
An ActiveX control for 2D data visualisation
ntgraph_activex_demo.zip
NTGraph_demo
NTGraph
Debug
Demo
Debug
res
Test.ico
Test.aps
Test.clw
Test.dsp
Test.plg
NTGraph.aps
NTGraph.clw
NTGraph.def
NTGraph.dsp
NTGraph.dsw
NTGraph.ico
NTGraph.ncb
NTGraph.odl
NTGraph.opt
NTGraph.plg
NTGraphCtl.bmp
Test.exe
ntgraph_activex_src.zip
ntgraph_bin.zip
ntgraph_bin1.zip
ntgraph_bin2.zip
ntgraph_bin3.zip
ntgraph_ctrl.zip
NTGraph_Ctrl
NTGraph.aps
NTGraph.clw
NTGraph.def
NTGraph.dsp
NTGraph.dsw
NTGraph.ico
NTGraph.ncb
NTGraph.odl
NTGraph.opt
NTGraph.plg
NTGraphCtl.bmp
Release
ntgraph_ctrl1.zip
NTGraph.aps
NTGraph.clw
NTGraph.def
NTGraph.dsp
NTGraph.dsw
NTGraph.ico
NTGraph.ncb
NTGraph.odl
NTGraph.opt
NTGraph.plg
NTGraphCtl.bmp
ntgraph_ctrl2.zip
NTGraph_Ctrl2
Debug
MAGNIFY.CUR
NTGraph.aps
NTGraph.clw
NTGraph.def
NTGraph.dsp
NTGraph.dsw
NTGraph.ico
NTGraph.ncb
NTGraph.odl
NTGraph.opt
NTGraph.plg
NTGraphCtl.bmp
Release
Test.dsm
ntgraph_ctrl3.zip
NTGraph_Ctrl3
Debug
hmove.cur
MAGNIFY.CUR
NTGraph.aps
NTGraph.clw
NTGraph.def
NTGraph.dsp
NTGraph.dsw
NTGraph.ico
NTGraph.odl
NTGraph.opt
NTGraph.plg
NTGraphCtl.bmp
Release
Test.dsm
ntgraph_demo.zip
Demo.ppt
Demo.xls
DlgDemo
Demo.aps
Demo.clw
Demo.dsp
Demo.dsw
Demo.exe
Demo.ncb
Demo.opt
Demo.plg
res
Demo.ico
MDIDemo
MDIDemo.aps
MDIDemo.clw
MDIDemo.dsp
MDIDemo.dsw
MDIDemo.exe
MDIDemo.ncb
MDIDemo.opt
MDIDemo.plg
res
MDIDemo.ico
MDIDemoDoc.ico
Toolbar.bmp
ntgraph_demo1.zip
Debug
Demo.aps
Demo.clw
Demo.dsp
Demo.dsw
Demo.ncb
Demo.opt
Demo.plg
res
Demo.ico
ntgraph_demo2.zip
NTGraph_demo2
Debug
Demo.aps
Demo.clw
Demo.dsp
Demo.dsw
Demo.ncb
Demo.opt
Demo.plg
res
Demo.ico
ntgraph_demo3.zip
NTGraph_demo3
Debug
Demo.dsp
Demo.dsw
res
Demo.ico
test.pdf
ntgraph_ppt.zip
ntgraph_ppt1.zip
ntgraph_src.zip
NTGraph_src
Frame.bmp
Hlp
Bullet.bmp
NTGraph.hm
NTGraph.RTF
Margritte.bmp
Margritte.jpg
NTGraph.aps
NTGraph.clw
NTGraph.def
NTGraph.dsp
NTGraph.dsw
NTGRAPH.GID
NTGRAPH.HLP
NTGraph.hpj
NTGraph.ico
NTGraph.log
NTGraph.ncb
NTGraph.odl
NTGraph.opt
NTGraph.ph
NTGraph.plg
NTGraph.suo
NTGraphCtl.bmp
Release
Test.dsm
#if !defined(AFX_NTGRAPHCTL_H__4E772943_A5F2_4917_B53F_DE7BE01A6E36__INCLUDED_)
#define AFX_NTGRAPHCTL_H__4E772943_A5F2_4917_B53F_DE7BE01A6E36__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef MAX
#define MAX 1
#endif

#ifndef MIN
#define MIN 0
#endif

#define MAX_ELEMENTS 100

class CGraphElement {

public :
	CGraphElement() ;
	BOOL bIsPlotAvailable ;
	double *dValueX ;
	double *dValueY ;
	COLORREF m_plotColor ;
	BOOL AllocElement(UINT nPoint);
	BOOL FreeElement();

protected:
	BOOL bBufferAllocated;
} ;

// NTGraphCtl.h : Declaration of the CNTGraphCtrl ActiveX Control class.

/////////////////////////////////////////////////////////////////////////////
// CNTGraphCtrl : See NTGraphCtl.cpp for implementation.

class CNTGraphCtrl : public COleControl
{
	DECLARE_DYNCREATE(CNTGraphCtrl)

// Constructor
public:
	CNTGraphCtrl();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CNTGraphCtrl)
	public:
	virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual void DoPropExchange(CPropExchange* pPX);
	virtual void OnResetState();
	virtual DWORD GetControlFlags();
	//}}AFX_VIRTUAL

// Implementation
protected:
	~CNTGraphCtrl();

	DECLARE_OLECREATE_EX(CNTGraphCtrl)    // Class factory and guid
	DECLARE_OLETYPELIB(CNTGraphCtrl)      // GetTypeInfo
	DECLARE_PROPPAGEIDS(CNTGraphCtrl)     // Property page IDs
	DECLARE_OLECTLTYPE(CNTGraphCtrl)	  // Type name and misc status

	// Subclassed control support
	BOOL IsSubclassedControl();
	LRESULT OnOcmCommand(WPARAM wParam, LPARAM lParam);

// Message maps
	//{{AFX_MSG(CNTGraphCtrl)
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

// Dispatch maps
	//{{AFX_DISPATCH(CNTGraphCtrl)
	BOOL m_showGrid;
	afx_msg void OnShowGridChanged();
	BOOL m_changeMappingMode;
	afx_msg void OnChangeMappingModeChanged();
	CString m_strLabelX;
	afx_msg void OnXLabelChanged();
	CString m_strLabelY;
	afx_msg void OnYLabelChanged();
	OLE_COLOR m_gridColor;
	afx_msg void OnGridColorChanged();
	OLE_COLOR m_labelColor;
	afx_msg void OnLabelColorChanged();
	OLE_COLOR m_axisColor;
	afx_msg void OnAxisColorChanged();
	short m_nGridX;
	afx_msg void OnNGridXChanged();
	short m_nGridY;
	afx_msg void OnNGridYChanged();
	double m_minX;
	afx_msg void OnMinXChanged();
	double m_maxX;
	afx_msg void OnMaxXChanged();
	double m_minY;
	afx_msg void OnMinYChanged();
	double m_maxY;
	afx_msg void OnMaxYChanged();
	BOOL m_showCursor;
	afx_msg void OnShowCursorChanged();
	CString m_strGraphTitle;
	afx_msg void OnGraphTitleChanged();
	OLE_COLOR m_cursorColor;
	afx_msg void OnCursorColorChanged();
	afx_msg OLE_COLOR GetPlotColor();
	afx_msg void SetPlotColor(OLE_COLOR nNewValue);
	afx_msg short GetElement();
	afx_msg void SetElement(short nNewValue);
	afx_msg short GetElementCount();
	afx_msg void SetElementCount(short nNewValue);
	afx_msg void ClearGraph();
	afx_msg BOOL CreateElement(long nElement);
	afx_msg BOOL SetRange(double MinX, double MaxX,double MinY,double MaxY);
	afx_msg BOOL SetXYValue(double x, double y, long index, short iElementId);
	//}}AFX_DISPATCH
	DECLARE_DISPATCH_MAP()

	afx_msg void AboutBox();

// Event maps
	//{{AFX_EVENT(CNTGraphCtrl)
	//}}AFX_EVENT
	DECLARE_EVENT_MAP()


// Dispatch and event IDs
public:
	enum {
	//{{AFX_DISP_ID(CNTGraphCtrl)
	dispidShowGrid = 1L,
	dispidChangeMappingMode = 2L,
	dispidXLabel = 3L,
	dispidYLabel = 4L,
	dispidGridColor = 5L,
	dispidLabelColor = 6L,
	dispidAxisColor = 7L,
	dispidNGridX = 8L,
	dispidNGridY = 9L,
	dispidMinX = 10L,
	dispidMaxX = 11L,
	dispidMinY = 12L,
	dispidMaxY = 13L,
	dispidPlotColor = 17L,
	dispidElement = 18L,
	dispidElementCount = 19L,
	dispidShowCursor = 14L,
	dispidGraphTitle = 15L,
	dispidCursorColor = 16L,
	dispidClearGraph = 20L,
	dispidCreateElement = 21L,
	dispidSetRange = 22L,
	dispidSetXYValue = 23L,
	//}}AFX_DISP_ID
	};

	CPoint Corrdinate(double x, double y);
	CGraphElement mpElement[MAX_ELEMENTS] ;
	int nElementCount ;
	COLORREF m_BGColor ;
	BOOL bFontIsCreate ;


protected:
	BOOL m_bIsCursorInRange;
	void DrawCursor();
	double m_dXCur;
	double m_dYCur;
	short m_ElementId;
	void ResCalc();
	void CalcRect();
	void CreateFont();
	void DrawGraphTitle();
	void DrawGrid();
	void DrawAxis();
	void DrawTicks();
	void DrawAxisLabel();
	void PlotElement();



	int nPointCount ;
	int nPlotIndex ;
	double dResY, dResX ;
	double dRangeY[2], dRangeX[2];


	BOOL bIsElementAllocated ;

private:
 CRect m_ctlRect,m_clientRect, m_axisRect;
 CDC* m_pDC;

 	CFont *pTickFont ;
	CFont *pTitleFont;
	CFont *pXLabelFont;
	CFont *pYLabelFont;

 //Function to Intialize DC and mapping mode
 void PrepareForDrawing(CRect rect); 


};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_NTGRAPHCTL_H__4E772943_A5F2_4917_B53F_DE7BE01A6E36__INCLUDED)

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Nikolai Teofilov
Researcher
Germany Germany
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 6 Aug 2003
Article Copyright 2002 by Nikolai Teofilov
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid