ui.h
Go to the documentation of this file.
1 // console user interface
2 // Author: Max Schwarz <max.schwarz@uni-bonn.de>
3 
4 #ifndef UI_H
5 #define UI_H
6 
7 #include "monitor/monitor.h"
8 #include "fd_watcher.h"
9 #include "terminal.h"
10 
11 #include <ros/wall_timer.h>
12 
13 #include <map>
14 #include <unordered_set>
15 
16 namespace rosmon
17 {
18 
19 class UI
20 {
21 public:
22  explicit UI(monitor::Monitor* monitor, const FDWatcher::Ptr& fdWatcher);
23  ~UI();
24 
25  void update();
26  void log(const std::string& channel, const std::string& str);
27 private:
28  struct ChannelInfo
29  {
31  {}
32 
33  ChannelInfo(uint32_t color)
34  : labelColor(color)
35  {}
36 
37  uint32_t labelColor;
39  };
40 
41  void drawStatusLine();
42  void checkWindowSize();
43  void setupColors();
44  void handleInput();
45 
46  inline bool anyMuted()
47  { return !m_mutedSet.empty(); }
48 
49  inline bool isMuted(const std::string &s)
50  { return m_mutedSet.find(s) != m_mutedSet.end(); }
51 
52  inline void mute(const std::string &s)
53  { m_mutedSet.insert(s); }
54 
55  inline void unmute(const std::string &s)
56  { m_mutedSet.erase(s); }
57 
58  inline void muteAll()
59  { for(auto& node : m_monitor->nodes()) m_mutedSet.insert(node->name()); }
60 
61  inline void unmuteAll()
62  { m_mutedSet.clear(); }
63 
66 
68 
69  int m_columns;
71 
72  std::unordered_set<std::string> m_mutedSet;
73 
74  std::map<std::string, ChannelInfo> m_nodeColorMap;
75 
77 
78  std::string m_strSetColor;
79 };
80 
81 }
82 
83 #endif
84 
Definition: ui.h:19
const std::vector< NodeMonitor::Ptr > & nodes() const
Definition: monitor.h:40
bool anyMuted()
Definition: ui.h:46
~UI()
Definition: ui.cpp:68
std::map< std::string, ChannelInfo > m_nodeColorMap
Definition: ui.h:74
int m_selectedNode
Definition: ui.h:76
void setupColors()
Definition: ui.cpp:73
std::string m_strSetColor
Definition: ui.h:78
FDWatcher::Ptr m_fdWatcher
Definition: ui.h:65
UI(monitor::Monitor *monitor, const FDWatcher::Ptr &fdWatcher)
Definition: ui.cpp:36
void handleInput()
Definition: ui.cpp:287
monitor::Monitor * m_monitor
Definition: ui.h:64
void mute(const std::string &s)
Definition: ui.h:52
ros::WallTimer m_sizeTimer
Definition: ui.h:70
void update()
Definition: ui.cpp:263
void log(const std::string &channel, const std::string &str)
Definition: ui.cpp:218
Terminal::Parser parser
Definition: ui.h:38
void drawStatusLine()
Definition: ui.cpp:100
Terminal m_term
Definition: ui.h:67
ChannelInfo(uint32_t color)
Definition: ui.h:33
void checkWindowSize()
Definition: ui.cpp:280
bool isMuted(const std::string &s)
Definition: ui.h:49
void unmute(const std::string &s)
Definition: ui.h:55
std::unordered_set< std::string > m_mutedSet
Definition: ui.h:72
void unmuteAll()
Definition: ui.h:61
uint32_t labelColor
Definition: ui.h:37
Encapsulates terminal control.
Definition: terminal.h:20
Terminal escape sequence parser.
Definition: terminal.h:58
void muteAll()
Definition: ui.h:58
int m_columns
Definition: ui.h:69


rosmon_core
Author(s): Max Schwarz
autogenerated on Wed Jul 10 2019 03:10:12