程序:main_window.hpp:
/**
* @file /include/gui/main_window.hpp
*
* @brief Qt based gui for gui.
*
* @date November 2010
**/
#ifndef gui_MAIN_WINDOW_H
#define gui_MAIN_WINDOW_H
/*****************************************************************************
** Includes
*****************************************************************************/
#include <QtGui/QMainWindow>
#include "ui_main_window.h"
#include "qnode.hpp"
/*****************************************************************************
** Namespace
*****************************************************************************/
namespace gui {
//float angular_value = 0.0 ;
//float turtle_angular = 0.0;
/*****************************************************************************
** Interface [MainWindow]
*****************************************************************************/
/**
* @brief Qt central, all operations relating to the view part here.
*/
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(int argc, char** argv, QWidget *parent = 0);
~MainWindow();
void ReadSettings(); // Load up qt program settings at startup
void WriteSettings(); // Save qt program settings when closing
void closeEvent(QCloseEvent *event); // Overloaded function
void showNoMasterMessage();
float right_angular_value = 0 ;
float right_linear_value = 0 ;
float left_angular_value = 0 ;
float left_linear_value = 0 ;
float backward_angular_value = 0 ;
float backward_linear_value = 0 ;
float forward_angular_value = 0 ;
float forward_linear_value = 0 ;
public Q_SLOTS:
/******************************************
** Auto-connections (connectSlotsByName())
*******************************************/
void on_actionAbout_triggered();
void on_button_connect_clicked(bool check );
void on_checkbox_use_environment_stateChanged(int state);
/******************************************
** Manual connections
*******************************************/
void updateLoggingView(); // no idea why this can't connect automatically
private Q_SLOTS:
void on_forward_clicked();
void on_backward_clicked();
void on_right_clicked();
void on_left_clicked();
void on_AngularSlider_valueChanged(int value);
void on_AngularSlider_left_valueChanged(int value);
void on_LinearSlider_backward_valueChanged(int value);
void on_LinearSlider_forward_valueChanged(int value);
private:
Ui::MainWindowDesign ui;
QNode qnode;
};
} // namespace gui
#endif // gui_MAIN_WINDOW_H
qnode.hpp:
/**
* @file /include/gui/qnode.hpp
*
* @brief Communications central!
*
* @date February 2011
**/
/*****************************************************************************
** Ifdefs
*****************************************************************************/
#ifndef gui_QNODE_HPP_
#define gui_QNODE_HPP_
/*****************************************************************************
** Includes
*****************************************************************************/
// To workaround boost/qt4 problems that won't be bugfixed. Refer to
// https://bugreports.qt.io/browse/QTBUG-22829
#ifndef Q_MOC_RUN
#include <ros/ros.h>
#endif
#include <string>
#include <QThread>
#include <QStringListModel>
/*****************************************************************************
** Namespaces
*****************************************************************************/
namespace gui {
//float angular_value = 0 ;
//float turtle_angular = 0;
/*****************************************************************************
** Class
*****************************************************************************/
//float turtle_linear = 0.0;
class QNode : public QThread {
Q_OBJECT
public:
QNode(int argc, char** argv );
virtual ~QNode();
bool init();
bool init(const std::string