00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef MOUSERECORDER_H
00016 #define MOUSERECORDER_H
00017
00018 #include "recorderBase.h"
00019 #include "dataNode.h"
00020 #include "dataNodeTransmit.h"
00021 #include "linmath_events.h"
00022 #include "buttonEventList.h"
00023
00024 class FactoryParams;
00025 class BamReader;
00026 class BamWriter;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class EXPCL_PANDA_RECORDER MouseRecorder : public DataNode, public RecorderBase {
00039 PUBLISHED:
00040 MouseRecorder(const string &name);
00041 virtual ~MouseRecorder();
00042
00043 public:
00044 virtual void record_frame(BamWriter *manager, Datagram &dg);
00045 virtual void play_frame(DatagramIterator &scan, BamReader *manager);
00046
00047 public:
00048 virtual void output(ostream &out) const;
00049 virtual void write(ostream &out, int indent_level = 0) const;
00050
00051 protected:
00052
00053 virtual void do_transmit_data(DataGraphTraverser *trav,
00054 const DataNodeTransmit &input,
00055 DataNodeTransmit &output);
00056
00057 private:
00058
00059 int _pixel_xy_input;
00060 int _xy_input;
00061 int _button_events_input;
00062
00063
00064 int _pixel_xy_output;
00065 int _xy_output;
00066 int _button_events_output;
00067
00068 bool _has_mouse;
00069 LPoint2 _mouse_xy;
00070 LPoint2 _mouse_pixel_xy;
00071 PT(ButtonEventList) _live_button_events;
00072 PT(ButtonEventList) _save_button_events;
00073
00074 PT(EventStoreVec2) _pixel_xy;
00075 PT(EventStoreVec2) _xy;
00076
00077 public:
00078 static void register_with_read_factory();
00079 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00080 virtual void write_recorder(BamWriter *manager, Datagram &dg);
00081
00082 protected:
00083 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00084 static RecorderBase *make_recorder(const FactoryParams ¶ms);
00085 void fillin(DatagramIterator &scan, BamReader *manager);
00086 void fillin_recorder(DatagramIterator &scan, BamReader *manager);
00087
00088 public:
00089 static TypeHandle get_class_type() {
00090 return _type_handle;
00091 }
00092 static void init_type() {
00093 DataNode::init_type();
00094 RecorderBase::init_type();
00095 register_type(_type_handle, "MouseRecorder",
00096 DataNode::get_class_type(),
00097 RecorderBase::get_class_type());
00098 }
00099 virtual TypeHandle get_type() const {
00100 return get_class_type();
00101 }
00102 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00103
00104 private:
00105 static TypeHandle _type_handle;
00106 };
00107
00108 #endif
00109