MoCapLogger.h
Go to the documentation of this file.00001 #ifndef INCLUDED_MoCapLogger_h_
00002 #define INCLUDED_MoCapLogger_h_
00003
00004 #include "Behaviors/Controls/ControlBase.h"
00005 #include "Behaviors/Controls/NullControl.h"
00006 #include "Behaviors/Controls/ToggleControl.h"
00007 #include "Behaviors/Controls/StringInputControl.h"
00008 #include "Events/MoCapEvent.h"
00009 #include "Events/TextMsgEvent.h"
00010 #include "Events/EventCallback.h"
00011 #include "Shared/TimeET.h"
00012 #include <fstream>
00013 #include <memory>
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 class MoCapLogger : public ControlBase {
00025 protected:
00026 TimeET lastRefresh;
00027 NullControl* x;
00028 NullControl* y;
00029 NullControl* z;
00030 NullControl* r0;
00031 NullControl* r1;
00032 NullControl* r2;
00033 ToggleControl * consoleLog;
00034 StringInputControl * fileLog;
00035 ToggleControl * rotAxis;
00036
00037 std::ofstream file;
00038
00039
00040 static void rename(ControlBase* c, std::ostream& sstream);
00041
00042
00043
00044
00045
00046 std::unique_ptr<EventCallbackAs<MoCapEvent> > mocapGUI;
00047 void gotMoCapGUI(const MoCapEvent& mce);
00048
00049 std::unique_ptr<EventCallbackAs<MoCapEvent> > mocapConsole;
00050 void gotMoCapConsole(const MoCapEvent& mce);
00051
00052 std::unique_ptr<EventCallbackAs<MoCapEvent> > mocapFile;
00053 void gotMoCapFile(const MoCapEvent& mce);
00054
00055
00056
00057
00058 EventCallbackAs<TextMsgEvent> txtmsgSingle;
00059 void gotTxtMsgSingle(const TextMsgEvent& txt);
00060
00061 EventCallback mocapSingle;
00062 void gotMoCapSingle(const EventBase& event);
00063
00064 public:
00065
00066 MoCapLogger() : ControlBase("MoCap Logger","Displays and log motion capture event data (e.g. from Mirage)"),
00067 lastRefresh(), x(), y(), z(), r0(), r1(), r2(), consoleLog(), fileLog(), rotAxis(), file(), mocapGUI(), mocapConsole(), mocapFile(),
00068 txtmsgSingle(&MoCapLogger::gotTxtMsgSingle,*this),
00069 mocapSingle(&MoCapLogger::gotMoCapSingle,*this)
00070 {
00071 pushSlot(x = new NullControl("X: waiting"));
00072 pushSlot(y = new NullControl("Y: waiting"));
00073 pushSlot(z = new NullControl("Z: waiting"));
00074 pushSlot(r0 = new NullControl("Heading: waiting"));
00075 pushSlot(r1 = new NullControl("Pitch: waiting"));
00076 pushSlot(r2 = new NullControl("Roll: waiting"));
00077 pushSlot(consoleLog = new ToggleControl("Log To Console","Will write MoCapEvent data to the console"));
00078 pushSlot(fileLog = new StringInputControl("Log To File","Enter filename to dump mocap data into"));
00079 pushSlot(rotAxis = new ToggleControl("Rotation Axis","If selected, will display/log the quaternion axis, otherwise heading/pitch/roll"));
00080 }
00081
00082
00083 void dump(std::ostream& os, const MoCapEvent& mce);
00084
00085
00086 virtual void refresh();
00087
00088
00089 virtual void deactivate();
00090
00091
00092
00093 virtual ControlBase * doSelect();
00094
00095
00096
00097 virtual void registered() {
00098 erouter->addListener(&txtmsgSingle,EventBase::textmsgEGID);
00099 }
00100
00101 private:
00102 MoCapLogger(const MoCapLogger& o);
00103 MoCapLogger& operator=(const MoCapLogger& o);
00104 };
00105
00106
00107
00108
00109
00110
00111 #endif