scriptable_monitor_rqt.h
Go to the documentation of this file.
00001 /*
00002  * scriptable_monitor_rqt.h
00003  *
00004  *  Created on: Oct 31, 2013
00005  *      Author: blackpc
00006  */
00007 
00008 #ifndef scriptable_monitor_RQT_H_
00009 #define scriptable_monitor_RQT_H_
00010 
00011 #include <iostream>
00012 
00013 #include <ros/ros.h>
00014 #include <boost/foreach.hpp>
00015 
00016 #include <QWidget>
00017 #include <QStandardItemModel>
00018 #include <QMessageBox>
00019 
00020 #include <rqt_gui_cpp/plugin.h>
00021 #include <pluginlib/class_list_macros.h>
00022 
00023 #include <scriptable_monitor_rqt/ScriptsList.h>
00024 #include <scriptable_monitor_rqt/AddScript.h>
00025 
00026 #include <scriptable_monitor/Script.h>
00027 #include <scriptable_monitor/GetScripts.h>
00028 #include <scriptable_monitor/AddScript.h>
00029 
00030 using namespace std;
00031 
00032 namespace scriptable_monitor
00033 {
00034 
00035 class ScriptableMonitorRqt : public rqt_gui_cpp::Plugin
00036 {
00037 
00038 Q_OBJECT
00039 
00040 public:
00041         ScriptableMonitorRqt();
00042         ~ScriptableMonitorRqt();
00043 
00044         virtual void initPlugin(qt_gui_cpp::PluginContext& context);
00045         virtual void shutdownPlugin();
00046         virtual void saveSettings(qt_gui_cpp::Settings& plugin_settings,
00047                         qt_gui_cpp::Settings& instance_settings) const;
00048         virtual void restoreSettings(const qt_gui_cpp::Settings& plugin_settings,
00049                         const qt_gui_cpp::Settings& instance_settings);
00050 
00051 public slots:
00052         void refreshClicked() {
00053                 refreshScripts();
00054         }
00055 
00056         void newScriptWindowClicked() {
00057                 _newScriptDialog->show();
00058 
00059         }
00060 
00061         void addScriptClicked() {
00062                 scriptable_monitor::AddScript addScriptService;
00063 
00064                 addScriptService.request.script.data = _newScriptUi.scriptText->toPlainText().toStdString();
00065                 _addScriptClient.call(addScriptService);
00066 
00067                 if ((int)addScriptService.response.success == 1) {
00068                         _newScriptDialog->hide();
00069                         refreshScripts();
00070                         return;
00071                 }
00072 
00073                 QMessageBox Msgbox;
00074                 Msgbox.setText(QString::fromStdString("Couldn't add script: " + addScriptService.response.message.data));
00075                 Msgbox.exec();
00076         }
00077 
00078 private:
00079         QWidget* widget_;
00080         Ui_ScriptsForm _scriptsUi;
00081         Ui_NewScriptForm _newScriptUi;
00082         QDialog* _newScriptDialog;
00083 
00084         ros::NodeHandle* _nodeHandle;
00085         ros::ServiceClient _getScriptsClient;
00086         ros::ServiceClient _addScriptClient;
00087 
00088         void refreshScripts();
00089         void connectEvents();
00090 
00091 };
00092 } // namespace
00093 
00094 #endif /* scriptable_monitor_RQT_H_ */


scriptable_monitor_rqt
Author(s):
autogenerated on Wed Aug 26 2015 16:21:35