mrpt-gui模块中提供了三个类以实现显示GUI窗口,每个都有特定的用途:

  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图形界面的更多相关文章

  1. Ubuntu设置root用户登录图形界面

    Ubuntu默认的是root用户不能登录图形界面的,只能以其他用户登录图形界面.这样就很麻烦,因为权限的问题,不能随意复制删除文件,用gedit编辑文件时经常不能保存,只能用vim去编辑. 解决的办法 ...

  2. VMware安装CentOS时,无法以图形界面安装解决办法

    有的同学问: 用虚拟机软件(vmware.VirtualBox)安装CentOS系统时, 安装过程中没有中文,也没有出现图形界面,都是以命令行方式去安装, 有时候又会出现图形界面,不知道哪里配置的问题 ...

  3. Linux安装xwindow图形界面(转载)

    http://jingyan.baidu.com/article/7f766daf42ce984100e1d045.html 1.检查Linux系统是否能够联网. 2.执行命令 yum -y grou ...

  4. 修改/etc/profile和/etc/environment导致图形界面无法登陆的问题

    在使用ubuntu开发时,往往要修改PATH变量,有时会通过修改/etc/profile和/etc/environment来修改默认的PATH变量,但是一旦出错,很容易造成无法登陆进入图形界面的问题. ...

  5. Linux启动界面切换:图形界面-字符界面(转)

    Linux字符界面切换到图形界面 由字符界面切换到图形界面可用两种简单方法实现: 1.在字符界面输入startx或init 5 . 2.通过编辑/etc/inittab文件实现默认进入图形界面. 把其 ...

  6. 设置CentOS不启用图形界面

    由于linux服务器放在机房长时间运行,或者只是在后台运行,一般通过secureCRT连接服务器: 所以在虚拟机上都不需要图形界面,而且图形界面占用内存. 所以,我们可以通过简单的设置,让linux只 ...

  7. [.net 面向对象程序设计进阶] (25) 团队开发利器(四)分布式版本控制系统Git——使用GitStack+TortoiseGit 图形界面搭建Git环境

    [.net 面向对象程序设计进阶] (25) 团队开发利器(四)分布式版本控制系统Git——使用GitStack+TortoiseGit 图形界面搭建Git环境 本篇导读: 前面介绍了两款代码管理工具 ...

  8. 为CentOS7(文字界面操作)系统安装gnome图形界面程序

    1.安装gnome sudo yum groupinstall "GNOME Desktop" "Graphical Administration Tools" ...

  9. no screens found! ubuntu进不了图形界面了

    no screens found! ubuntu进不了图形界面了 结果是没装显卡 startx error. reinstall xorg, x server doesn't work. driver ...

随机推荐

  1. 如何删除NSDictionary或NSArray中的NSNull

    前段时间与某公司的技术交流,被问到一个问题,如何删除NSDictionary中的NSNull.当时在纸上写,以前太依赖Xcode编译器了,以至于方法名都写不全,最终也没写出来,我想我肯定被鄙视的体无完 ...

  2. C++ 中的std::vector介绍(转)

    vector是C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库.vector之所以被认为是一个容器,是因为它能够像容器一样存放各种类型的对象,简单地说,vec ...

  3. Java学习笔记,第三章

    Java基础语法 3.1类型.变量与运算符 3.1.1类型 Java可分为基本类型和类类型或参考类型.基本类型主要有 整数:可分为short整数(2字节,-32768 -- 32767),int整数( ...

  4. struts---JSP界面验证码生成与验证

    之前想做一个随机验证码的功能,自己也搜索了一下别人写的代码,然后自己重新用struts2实现了一下,现在将我自己实现代码贴出来!大家有什么意见都可以指出来! 首先是生成随机验证码图片的action: ...

  5. C#字符串的方法

    static void Main(string[] args) { StrMethod(); } public static void StrMethod() { string myString = ...

  6. C++之路进阶——HDU1880(魔咒词典)

    ---恢复内容开始--- New~ 欢迎参加2016多校联合训练的同学们~ 魔咒词典 Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 3 ...

  7. hdu5722 Jewelry

    题意就是说问有多少个区间,其中有至少一种种类的宝珠出现的次数恰好为x次.            先预处理出每一个位置的宝珠下一个出现与其同种类的宝珠位置next和上一个出现与其同种类的位置pre   ...

  8. FRM-40400:事务完成:已应用和保存X条记录"消息框不显示处理方法

    oldmesl := :system.message_level; :system.message_level :;--不显示长度超过25的信息 do_key('COMMIT_FORM'); :sys ...

  9. SecureCRT:保存输出日志的方法

    处理地址: http://blog.sina.com.cn/s/blog_64c1dd210101gzgz.html 或者: http://renchen.blog.51cto.com/4531967 ...

  10. [Phalcon] DI默认的服务

    代码,说明一切 namespace Phalcon\Di\FactoryDefault; use Phalcon\Di\Service; use Phalcon\Di\FactoryDefault; ...