Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef INTERACTIVE_MARKER_MENU_HANDLER
00033 #define INTERACTIVE_MARKER_MENU_HANDLER
00034
00035 #include <visualization_msgs/MenuEntry.h>
00036 #include <interactive_markers/interactive_marker_server.h>
00037
00038 #include <boost/function.hpp>
00039 #include <boost/unordered_map.hpp>
00040
00041 namespace interactive_markers
00042 {
00043
00044
00045
00046 class MenuHandler
00047 {
00048 public:
00049
00050 typedef uint32_t EntryHandle;
00051
00052 typedef visualization_msgs::InteractiveMarkerFeedbackConstPtr FeedbackConstPtr;
00053 typedef boost::function< void ( const FeedbackConstPtr& ) > FeedbackCallback;
00054
00055 enum CheckState {
00056 NO_CHECKBOX,
00057 CHECKED,
00058 UNCHECKED
00059 };
00060
00061 MenuHandler( );
00062
00064 EntryHandle insert( const std::string &title, const FeedbackCallback &feedback_cb );
00065
00067 EntryHandle insert( const std::string &title,
00068 const uint8_t command_type = visualization_msgs::MenuEntry::FEEDBACK,
00069 const std::string &command="" );
00070
00072 EntryHandle insert( EntryHandle parent, const std::string &title,
00073 const FeedbackCallback &feedback_cb );
00074
00076 EntryHandle insert( EntryHandle parent, const std::string &title,
00077 const uint8_t command_type = visualization_msgs::MenuEntry::FEEDBACK,
00078 const std::string &command="" );
00079
00081 bool setVisible( EntryHandle handle, bool visible );
00082
00084 bool setCheckState( EntryHandle handle, CheckState check_state );
00085
00088 bool getCheckState( EntryHandle handle, CheckState &check_state ) const;
00089
00092 bool apply( InteractiveMarkerServer &server, const std::string &marker_name );
00093
00095 bool reApply( InteractiveMarkerServer &server );
00096
00099 bool getTitle( EntryHandle handle, std::string &title ) const;
00100
00101 private:
00102
00103 struct EntryContext
00104 {
00105 std::string title;
00106 std::string command;
00107 uint8_t command_type;
00108 std::vector<EntryHandle> sub_entries;
00109 bool visible;
00110 CheckState check_state;
00111 FeedbackCallback feedback_cb;
00112 };
00113
00114
00115 void processFeedback( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
00116
00117
00118
00119
00120 bool pushMenuEntries( std::vector<EntryHandle>& handles_in,
00121 std::vector<visualization_msgs::MenuEntry>& entries_out,
00122 EntryHandle parent_handle );
00123
00124 visualization_msgs::MenuEntry makeEntry( EntryContext& context, EntryHandle handle, EntryHandle parent_handle );
00125
00126
00127 EntryHandle doInsert( const std::string &title,
00128 const uint8_t command_type,
00129 const std::string &command,
00130 const FeedbackCallback &feedback_cb );
00131
00132 std::vector<EntryHandle> top_level_handles_;
00133
00134 boost::unordered_map<EntryHandle, EntryContext> entry_contexts_;
00135
00136 EntryHandle current_handle_;
00137
00138 std::set<std::string> managed_markers_;
00139 };
00140
00141 }
00142
00143 #endif