Click here to Skip to main content
15,886,110 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.
// PGLLine2DLODPropPage.cpp : implementation file
//

#include "stdafx.h"
#include "PGL/pgl.h"
#include "PGL/PGLLine2DLODPropPage.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPGLLine2DLODPropPage property page

IMPLEMENT_DYNCREATE(CPGLLine2DLODPropPage, CPropertyPage)

CPGLLine2DLODPropPage::CPGLLine2DLODPropPage(CPGLLine2DLOD* _pLine2DLOD) : CPropertyPage(CPGLLine2DLODPropPage::IDD)
{
	//{{AFX_DATA_INIT(CPGLLine2DLODPropPage)
	m_iNbPApprox = 0;
	m_iNbPOrig = 0;
	m_dTol = 0.0;
	m_dPreview = FALSE;
	//}}AFX_DATA_INIT

	m_pLine2DLOD=_pLine2DLOD;
}

CPGLLine2DLODPropPage::~CPGLLine2DLODPropPage()
{
}

void CPGLLine2DLODPropPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPGLLine2DLODPropPage)
	DDX_Text(pDX, IDC_PGL_EDIT_NBPAPPROX, m_iNbPApprox);
	DDX_Text(pDX, IDC_PGL_EDIT_NBPORIG, m_iNbPOrig);
	DDX_Text(pDX, IDC_PGL_EDIT_TOL, m_dTol);
	DDX_Check(pDX, IDC_PGL_CHECK_PREVIEW, m_dPreview);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPGLLine2DLODPropPage, CPropertyPage)
	//{{AFX_MSG_MAP(CPGLLine2DLODPropPage)
	ON_EN_CHANGE(IDC_PGL_EDIT_TOL, OnChangePglEditTol)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPGLLine2DLODPropPage message handlers

BOOL CPGLLine2DLODPropPage::OnKillActive() 
{
	UpdateData(TRUE);

	CDPHull* pHull=m_pLine2DLOD->GetHull();
	ASSERT(pHull);

	// Setting tolerance
	pHull->SetTol(m_dTol);

	// Simplify
	pHull->Simplify();	
	
	return CPropertyPage::OnKillActive();
}

void CPGLLine2DLODPropPage::OnChangePglEditTol() 
{
	UpdateData(TRUE);
	if (m_dPreview)
	{

		CDPHull* pHull=m_pLine2DLOD->GetHull();
		ASSERT(pHull);

		// Setting tolerance
		pHull->SetTol(m_dTol);
	
		pHull->Simplify();
		Refresh();
	}

	UpdateData(FALSE);
}

void CPGLLine2DLODPropPage::Refresh()
{
	CDPHull* pHull=m_pLine2DLOD->GetHull();
	ASSERT(pHull);

	m_iNbPOrig=pHull->GetNPoints();
	m_iNbPApprox=pHull->GetDPNPoints();
	m_dTol=pHull->GetTol();
}

BOOL CPGLLine2DLODPropPage::OnSetActive() 
{
	ASSERT(m_pLine2DLOD);
	m_dPreview=TRUE;

	Refresh();
	UpdateData(FALSE);
	
	return CPropertyPage::OnSetActive();
}

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