34 #include <boost/bind.hpp> 35 #include <boost/make_shared.hpp> 49 EntryHandle handle =
doInsert( title, visualization_msgs::MenuEntry::FEEDBACK,
"", feedback_cb );
55 const uint8_t command_type,
56 const std::string &command )
67 boost::unordered_map<EntryHandle, EntryContext>::iterator parent_context =
72 EntryHandle handle =
doInsert( title, visualization_msgs::MenuEntry::FEEDBACK,
"", feedback_cb );
73 parent_context->second.sub_entries.push_back( handle );
79 const uint8_t command_type,
80 const std::string &command )
82 boost::unordered_map<EntryHandle, EntryContext>::iterator parent_context =
88 parent_context->second.sub_entries.push_back( handle );
95 boost::unordered_map<EntryHandle, EntryContext>::iterator context =
103 context->second.visible = visible;
110 boost::unordered_map<EntryHandle, EntryContext>::iterator context =
118 context->second.check_state = check_state;
125 boost::unordered_map<EntryHandle, EntryContext>::const_iterator context =
134 check_state = context->second.check_state;
141 visualization_msgs::InteractiveMarker int_marker;
143 if ( !server.
get( marker_name, int_marker ) )
150 int_marker.menu_entries.clear();
154 server.
insert( int_marker );
161 std::vector<visualization_msgs::MenuEntry>& entries_out,
164 for (
unsigned t = 0; t < handles_in.size(); t++ )
167 boost::unordered_map<EntryHandle, EntryContext>::iterator context_it =
172 ROS_ERROR(
"Internal error: context handle not found! This is a bug in MenuHandler." );
183 entries_out.push_back(
makeEntry( context, handle, parent_handle ));
200 std::set<std::string>::iterator next_it = it;
202 success =
apply( server, *it ) && success;
209 const uint8_t command_type,
210 const std::string &command,
217 context.
title = title;
230 visualization_msgs::MenuEntry menu_entry;
235 menu_entry.title = context.
title;
238 menu_entry.title =
"[x] "+context.
title;
241 menu_entry.title =
"[ ] "+context.
title;
245 menu_entry.command = context.
command;
247 menu_entry.id = handle;
248 menu_entry.parent_id = parent_handle;
256 boost::unordered_map<EntryHandle, EntryContext>::iterator context =
261 context->second.feedback_cb( feedback );
267 boost::unordered_map<EntryHandle, EntryContext>::const_iterator context =
275 title = context->second.title;
EntryHandle doInsert(const std::string &title, const uint8_t command_type, const std::string &command, const FeedbackCallback &feedback_cb)
bool pushMenuEntries(std::vector< EntryHandle > &handles_in, std::vector< visualization_msgs::MenuEntry > &entries_out, EntryHandle parent_handle)
visualization_msgs::MenuEntry makeEntry(EntryContext &context, EntryHandle handle, EntryHandle parent_handle)
bool getCheckState(EntryHandle handle, CheckState &check_state) const
void processFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
boost::shared_ptr< interactive_markers::InteractiveMarkerServer > server
std::vector< EntryHandle > sub_entries
bool apply(InteractiveMarkerServer &server, const std::string &marker_name)
FeedbackCallback feedback_cb
bool setVisible(EntryHandle handle, bool visible)
Specify if an entry should be visible or hidden.
bool setCheckState(EntryHandle handle, CheckState check_state)
Specify if an entry is checked or can't be checked at all.
#define ROS_ASSERT_MSG(cond,...)
bool getTitle(EntryHandle handle, std::string &title) const
EntryHandle insert(const std::string &title, const FeedbackCallback &feedback_cb)
Insert top-level entry with feedback function.
INTERACTIVE_MARKERS_PUBLIC void insert(const visualization_msgs::InteractiveMarker &int_marker)
INTERACTIVE_MARKERS_PUBLIC bool setCallback(const std::string &name, FeedbackCallback feedback_cb, uint8_t feedback_type=DEFAULT_FEEDBACK_CB)
boost::function< void(const FeedbackConstPtr &) > FeedbackCallback
std::set< std::string > managed_markers_
bool reApply(InteractiveMarkerServer &server)
Re-apply to all markers that this was applied to previously.
std::vector< EntryHandle > top_level_handles_
EntryHandle current_handle_
boost::unordered_map< EntryHandle, EntryContext > entry_contexts_
INTERACTIVE_MARKERS_PUBLIC bool get(std::string name, visualization_msgs::InteractiveMarker &int_marker) const