Click here to Skip to main content
15,893,486 members
Articles / Desktop Programming / MFC

Plot Graphic Library

Rate me:
Please Sign up or sign in to vote.
4.95/5 (70 votes)
7 May 2003LGPL36 min read 1.4M   51.3K   383  
A library to plot data (lines, maps...) in MFC projects
In this article, you will see a library called PGL that encapsulates plot capabilities in a MFC project for VC6 and VC7. It can easily plot data generated in a project without the need of any external software.
// CPGLView.cpp: implementation of the CPGLView class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "PGL/PGLView.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CPGLView, CObject, 1);

void CPGLView::Serialize(CArchive &archive)
{
    // call base class function first
    // base class is CObject in this case
    CObject::Serialize( archive );

    // now do the stuff for our specific class
    if( archive.IsStoring() )
	{
		archive<<m_iTx<<m_iTy<<m_iWidth<<m_iHeight;
	}
    else
	{
		archive>>m_iTx>>m_iTy>>m_iWidth>>m_iHeight;
	}
}

#ifdef _DEBUG
void CPGLView::Dump( CDumpContext& dc ) const
{
    // call base class function first
    CObject::Dump( dc );

    // now do the stuff for our specific class
	// now dumping
	dc <<_T("--- CPGLView ---") << endl;
}

void CPGLView::AssertValid() const
{
    // call inherited AssertValid first
    CObject::AssertValid();

    // check CPGLView members...
	ASSERT(m_iTx>=0);
	ASSERT(m_iTy>=0);
	ASSERT(m_iWidth>=0);
	ASSERT(m_iHeight>=0);
} 

#endif

CPGLView::CPGLView(int _iTx,int _iTy,int _iWidth,int _iHeight)
{	
	m_iTx=_iTx; 
	m_iTy=_iTy; 
	m_iWidth=_iWidth; 
	m_iHeight=_iHeight; 
};
	
CPGLView::CPGLView(const CPGLView& v)
{
	m_iTx=v.m_iTx; 
	m_iTy=v.m_iTy; 
	m_iWidth=v.m_iWidth; 
	m_iHeight=v.m_iHeight; 
}
	
CPGLView& CPGLView::operator= (const CPGLView& v)
{
	if (this!=&v)
	{
		m_iTx=v.m_iTx; 
		m_iTy=v.m_iTy; 
		m_iWidth=v.m_iWidth; 
		m_iHeight=v.m_iHeight; 
	}
	return *this;
}

void CPGLView::PlotGfx(gfxinterface::CGfxInterface& gfx)
{
	gfx.SetBoundingBox(m_iTx, m_iTy,m_iTx+m_iWidth,m_iTy+m_iHeight);
}

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 GNU Lesser General Public License (LGPLv3)


Written By
Engineer
United States United States
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).

Comments and Discussions