00001 #ifndef VELODYNEUTILS_PIPELINE_HPP
00002 #define VELODYNEUTILS_PIPELINE_HPP
00003
00004 #include <string>
00005 #include <vector>
00006
00007 #include <pcl/visualization/pcl_visualizer.h>
00008
00009 #include "executives.hpp"
00010
00011 namespace jafar {
00012 namespace velodyneutils {
00013
00018 enum PlaybackState {
00019 STOPPED,
00020 PAUSED,
00021 PLAYING
00022 };
00023
00027 class KeyboardPortBase {
00028 public:
00029 virtual const bool* getControlAddress() const = 0;
00030 virtual void setControl(bool set) = 0;
00031 virtual void toggleControl() = 0;
00032 virtual const void* getNumAddress(int index) const = 0;
00033 virtual void setNumValue(int index, void* value) = 0;
00034 virtual void setNumValue(int index) = 0;
00035 virtual void appendToNumString(const std::string& numString) = 0;
00036 virtual void increaseNumValue(int index) = 0;
00037 virtual void decreaseNumValue(int index) = 0;
00038 virtual bool isId(const std::string& id) const = 0;
00039 };
00040
00041 template<typename NumType>
00042 class KeyboardPort : KeyboardPortBase {
00043 public:
00044 KeyboardPort(int numSize, const std::string& idIn);
00045 ~KeyboardPort();
00046
00047 virtual const bool* getControlAddress() const;
00048 virtual void setControl(bool set);
00049 virtual void toggleControl();
00050 virtual const void* getNumAddress(int index) const;
00051 virtual void setNumValue(int index, void* value);
00052 virtual void setNumValue(int index);
00053 virtual void appendToNumString(const std::string& numString);
00054 virtual void increaseNumValue(int index);
00055 virtual void decreaseNumValue(int index);
00056 virtual bool isId(const std::string& id) const;
00057
00058 private:
00059 bool control;
00060 std::vector<NumType> numValues;
00061 std::string numString;
00062 NumType valueIncrement;
00063 std::string id;
00064 };
00065
00069 class Visualizer {
00070 public:
00071 Visualizer(pcl::visualization::PCLVisualizer* visualizerIn);
00072 ~Visualizer();
00073
00074 void init();
00075
00076
00077 void addExecutive(Executive* executive);
00078 void updateExecutives();
00079
00080
00081 void addKeyboardPort(KeyboardPortBase* port);
00082 void selectPort(const std::string& id);
00083 void toggleKeyboardPortControl();
00084 void setKeyboardPortNumValue(int index, void* value);
00085 void setKeyboardPortNumValue(int index);
00086 void appendToKeyboardPortNumString(const std::string& numString);
00087 void increaseKeyboardPortNumValue(int index);
00088 void decreaseKeyboardPortNumValue(int index);
00089
00090 void render();
00091
00092
00093 void stop();
00094
00095
00096
00097
00098
00099 private:
00100 pcl::visualization::PCLVisualizer* visualizer;
00101 PlaybackState playbackState;
00102 int sleepMicroseconds;
00103
00104 std::vector<Executive*> executives;
00105 std::vector<KeyboardPortBase*> keyboardPorts;
00106
00107 int selectedPort;
00108 };
00109
00114 void keyboardEventCallback(const pcl::visualization::KeyboardEvent& event,
00115 void* visualizer);
00116
00117 }
00118 }
00119
00120 #endif // VELODYNEUTILS_PIPELINE_HPP