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. [转]初探Metasploit的自动攻击

    1. 科普Metasploit   以前只是个Back Track操作系统(简称:BT) 下的攻击框架,自成继承了后攻击渗透模块,隐隐有成为攻击平台的趋势. 我们都戏称它为美少妇,很简单,msf. 它 ...

  2. C++之路进阶——codevs2306(晨跑)

    2306 晨跑 2009年省队选拔赛山东  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 大师 Master       题目描述 Description Elaxia最近迷恋 ...

  3. JSSDK用法//////////////////zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

    参照微信官方文档,调试成功之后总结如下: 步骤一:绑定域名 先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”. 备注:登录后可在“开发者中心”查看对应的接口权限. 步骤二: ...

  4. springmvc中的controller是单例的

    今天发现spring3中的controller默认是单例的,若是某个controller中有一个私有的变量a,所有请求到同一个controller时,使用的a变量是共用的,即若是某个请求中修改了这个变 ...

  5. Android监听返回键、Home键+再按一次返回键退出应用

    Android监听返回键需重写onKeyDown()方法 Home键keyCode==KeyEvent.KEYCODE_HOME @Override public boolean onKeyDown( ...

  6. Android 开发基础及环境配置

    2011年买了第一部安卓操作系统的手机,当时势头正盛的HTC不可思议(incredible),当时的想法就是想学习下智能手机开发,但是由于各种原因,客观上是公司的项目太忙了,忙于项目管理.团队建设.客 ...

  7. jsonp 使用总结

    首先:jsonp是json用来跨域的一个东西. 原理是通过script标签的跨域特性来绕过同源策略. 发送端: $.ajax({ type : "post", url : &quo ...

  8. hibernate配置文件详细解析

    在javaweb开发中,hibernate框架的是常用的,能帮我们节省大量的时间,以下是hibernate的配置文件解析. hibernate配置文件的默认名为:hibernate.cfg.xml 默 ...

  9. Asp.net MVC+Bootstrap3的悬浮式登录框效果

    1.引用Bootstarp3 @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/bootstrap&q ...

  10. IIS Express 配置外部访问

    IIS Express是Visual Stuido自带的微型Web服务器,简单易用. IIS Express默认只允许本机访问,通过Visual Studio调试Web程序时,我们有时需要通过外部访问 ...