⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapview.cpp

📁 基于vc 的环境下机器人自主避障的算法 图形处理 具有载物功能
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////
// MuRoS - Multi Robot Simulator
//
// Luiz Chaimowicz
// GRASP Lab. University of Pennsylvania
// VERLab - DCC - UFMG - Brasil
//
// MapView.cpp : implementation file
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "simulator.h"
#include "MapView.h"
#include "const.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMapView dialog


CMapView::CMapView(CWnd* pParent /*=NULL*/)
	: CDialog(CMapView::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMapView)
	//}}AFX_DATA_INIT
}



void CMapView::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMapView)
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMapView, CDialog)
	//{{AFX_MSG_MAP(CMapView)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMapView message handlers


// Draw the map and path. The member m_mapPath points to the coorect
// CMapPath structure
void CMapView::OnPaint() 
{
	int i, j, k, aux;
	COLORREF color;

	CPaintDC dc(this); // device context for painting

	int max = (int) ( (m_mapPath->m_maxValue / 256.0) + 1);

	for (i=0;i<m_mapPath->m_sizeX;i++)
		for (j=0;j<m_mapPath->m_sizeY;j++){
			// set the color of the pixel (gray level for map or blue for obstacle)
			if (m_mapPath->m_map[i][j] < 0)
				color = (m_mapPath->m_map[i][j] == -1) ? RGB(0,0,255) : RGB(0,255,0);
			else{
				aux = 255 - round(m_mapPath->m_map[i][j] / max);
				color = RGB(aux,aux,aux);
			}
			// Paint pixel
			dc.SetPixel(i,j,color);
		}

	// Draw path
	for(k=0; k<m_mapPath->m_path.GetSize(); k++)
		dc.SetPixel(m_mapPath->m_path[k].x/m_mapPath->m_resX, m_mapPath->m_path[k].y/m_mapPath->m_resY, RGB(255,0,0) );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -