MRPT图形界面
mrpt-gui模块中提供了三个类以实现显示GUI窗口,每个都有特定的用途:
- mrpt::gui::CDisplayWindow : Displays 2D bitmap images, and optionally sets of points over them, etc.
- mrpt::gui::CDisplayWindow3D : A powerful 3D rendering window capable of displaying a mrpt::opengl::COpenGLScene. It features mouse navigation, Alt+Enter fullscreen switching, multiple viewports, etc. See this tutorial.
- mrpt::gui::CDisplayWindowPlots : Displays one or more 2D vectorial graphs, in a manner very similar to MATLAB "plot" commands.
All these window classes inherits from mrpt::gui::CBaseGUIWindow, which provides a set of methods and variables common to all the classes. It allow moving/resizing the windows, polling for key strokes, etc. All the classes in this library are in the namespace mrpt::gui
在Ubuntu中使用如下命令安装mrpt的APP和lib:
sudo apt-get install mrpt-apps libmrpt-dev
下面的代码绘制一幅正态分布概率密度函数图,自变量范围为0~5。
#include <mrpt/gui/CDisplayWindowPlots.h>
#include <mrpt/math/CVectorTemplate.h>
#include <mrpt/math/distributions.h>
#include <mrpt/system/os.h>
#include <mrpt/system/threads.h> using namespace std;
using namespace mrpt;
using namespace mrpt::math;
using namespace mrpt::gui; // ------------------------------------------------------
// TestDisplayPlots
// ------------------------------------------------------
int main()
{
CDisplayWindowPlots win("Example of function plot",,); //width:500, height:400 // Generate data for a 2D plot:
CVectorDouble X,Y;
for (double x=;x<;x+=0.01f)
{
//Evaluates the multivariate normal (Gaussian) distribution at a given point "x".
double y = normalPDF(x, ,0.3); X.push_back(x);
Y.push_back(y);
} //Adds a new layer with a 2D plot based on two vectors of X and Y points, using a MATLAB-like syntax.
/*********************************************************************
The lineFormat string is a combination of the following characters: Line styles:
'.': One point for each data point
'-': A continuous line
':': A dashed line Colors:
k: black
r: red
g: green
b: blue
m: magenta
c: cyan Line width:
'1' to '9': The line width (default=1) Examples:
'r.' -> red points.
'k3' or 'k-3' -> A black line with a line width of 3 pixels.
********************************************************************/
win.plot(X,Y,"b-2"); //Enable/disable the feature of pan/zoom with the mouse (default=enabled)
win.enableMousePanZoom(true);
//Enable/disable the fixed X/Y aspect ratio fix feature
win.axis_equal(false);
//Fix automatically the view area according to existing graphs
win.axis_fit();
//Changes the position of the window on the screen.
win.setPos(,); cout << "Press any key to exit..." << endl;
win.waitForKey(); //while (!mrpt::system::os::kbhit() &&win.isOpen())
//mrpt::system::sleep(50); return ;
}
使用CMake来生成makefile:
SET(sampleName displayPlots)
SET(PRJ_NAME "EXAMPLE_${sampleName}") # ---------------------------------------
# Declare a new CMake Project:
# ---------------------------------------
PROJECT(${PRJ_NAME}) # These commands are needed by modern versions of CMake:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) FIND_PACKAGE(MRPT REQUIRED base;gui) # ---------------------------------------------
# TARGET:
# ---------------------------------------------
# Define the executable target:
ADD_EXECUTABLE(${sampleName} test.cpp ) # Add the required libraries for linking:
TARGET_LINK_LIBRARIES(${sampleName}
${MRPT_LIBS} # This is filled by FIND_PACKAGE(MRPT ...)
"" # Optional extra libs...
)

其中,enableMousePanZoom函数参数为true时可以进行如下操作:滚动鼠标中键,可以上下平移函数图象;按住鼠标右键可以对图像进行拖动;鼠标左键可以进行框选将函数图象放大。当设为false时这些操作被禁用。axis_equal函数参数为true时,X、Y坐标轴的单位长度将相等,即以相同的比例显示函数图象。axis_fit()函数可以用来自动调整函数图象以适应窗口。
参考:
http://www.mrpt.org/MRPT_in_GNU/Linux_repositories
https://github.com/MRPT/mrpt/tree/master/samples/displayPlots
MRPT图形界面的更多相关文章
- Ubuntu设置root用户登录图形界面
Ubuntu默认的是root用户不能登录图形界面的,只能以其他用户登录图形界面.这样就很麻烦,因为权限的问题,不能随意复制删除文件,用gedit编辑文件时经常不能保存,只能用vim去编辑. 解决的办法 ...
- VMware安装CentOS时,无法以图形界面安装解决办法
有的同学问: 用虚拟机软件(vmware.VirtualBox)安装CentOS系统时, 安装过程中没有中文,也没有出现图形界面,都是以命令行方式去安装, 有时候又会出现图形界面,不知道哪里配置的问题 ...
- Linux安装xwindow图形界面(转载)
http://jingyan.baidu.com/article/7f766daf42ce984100e1d045.html 1.检查Linux系统是否能够联网. 2.执行命令 yum -y grou ...
- 修改/etc/profile和/etc/environment导致图形界面无法登陆的问题
在使用ubuntu开发时,往往要修改PATH变量,有时会通过修改/etc/profile和/etc/environment来修改默认的PATH变量,但是一旦出错,很容易造成无法登陆进入图形界面的问题. ...
- Linux启动界面切换:图形界面-字符界面(转)
Linux字符界面切换到图形界面 由字符界面切换到图形界面可用两种简单方法实现: 1.在字符界面输入startx或init 5 . 2.通过编辑/etc/inittab文件实现默认进入图形界面. 把其 ...
- 设置CentOS不启用图形界面
由于linux服务器放在机房长时间运行,或者只是在后台运行,一般通过secureCRT连接服务器: 所以在虚拟机上都不需要图形界面,而且图形界面占用内存. 所以,我们可以通过简单的设置,让linux只 ...
- [.net 面向对象程序设计进阶] (25) 团队开发利器(四)分布式版本控制系统Git——使用GitStack+TortoiseGit 图形界面搭建Git环境
[.net 面向对象程序设计进阶] (25) 团队开发利器(四)分布式版本控制系统Git——使用GitStack+TortoiseGit 图形界面搭建Git环境 本篇导读: 前面介绍了两款代码管理工具 ...
- 为CentOS7(文字界面操作)系统安装gnome图形界面程序
1.安装gnome sudo yum groupinstall "GNOME Desktop" "Graphical Administration Tools" ...
- no screens found! ubuntu进不了图形界面了
no screens found! ubuntu进不了图形界面了 结果是没装显卡 startx error. reinstall xorg, x server doesn't work. driver ...
随机推荐
- EF 保证线程内唯一 上下文的创建
1.ef添加完这个对象,就会自动返回这个对象数据库的内容,比如下面这个表是自增ID 最后打印出来的ID 就是自增的结果 2.lambda 中怎么select * var userInfoList = ...
- mysql入门
mysql:关系型数据库的一种,用来存储数据: 一个仓库------一个数据库: 一个箱子------ 表: 进入mysql命令行:mysql -uroot -p(密码):查看数据库中所有表:show ...
- 802.1X基础
这是一个认证规范.使用EAPOL协议在客户端与认证端交互. EAPOL协议:Extensible Authentication Protocol over LAN. 假设三个实体: 客户端:PC 认证 ...
- Python函数信息
Python函数func的信息可以通过func.func_*和func.func_code来获取 一.先看看它们的应用吧: 1.获取原函数名称: 1 >>> def yes():pa ...
- 我的archlinux中安装的关于xfce4的软件
包括一些panel的插件: xfce4-appfinder - xfce4-battery-plugin - xfce4-eyes-plugin - xfce4-mixer - xfce4-netlo ...
- Silverlight5 Tools安装失败及解决方案
Silverlight5 Tools在安装的时候往往会提示以下错误 解决办法:解压Silverlight5 Tools.exe,打开ParameterInfo.xml文件,将其中的1033全部替换为2 ...
- javascript 创建 div
纯JAVASCRIPPT创建 (1):document.getElementById("要创建DIV位置的ID").innerHTML='<div>div里面的 ...
- 无法打开物理文件xxx.mdf操作系统错误 5:“5(拒绝访问。)” (Microsoft SQL Server,错误: 5120)的解决方法
无法打开物理文件xxx.mdf操作系统错误 5:“5(拒绝访问.)” (Microsoft SQL Server,错误: 5120)的解决方法 问题描述: 在附加数据库到sql server时,附 ...
- LINUX+Vmware+SVN的配置和安装
LINUX+Vmware+SVN的配置和安装 验证SVN安装了没有 svnserve --version 查看CentOS自带JDK是否已安装. ◆输入:yum list installed |gre ...
- Ubuntu 反复进入登录框问题
记录一下,今天碰到一个问题,到ubuntu登陆界面时,输入用户名和密码之后,马上又回到登陆界面 查看了 .xsession-errors. 网上查找了相关资料,想到自己之前装过nvidia的驱动. 卸 ...