Panda3D

mouseRecorder.h
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file mouseRecorder.h
10 * @author drose
11 * @date 2004-01-25
12 */
13
14 #ifndef MOUSERECORDER_H
15 #define MOUSERECORDER_H
16
17 #include "recorderBase.h"
18 #include "dataNode.h"
19 #include "dataNodeTransmit.h"
20 #include "linmath_events.h"
21 #include "buttonEventList.h"
22
23 class FactoryParams;
24 class BamReader;
25 class BamWriter;
26
27 /**
28 * This object records any data generated by a particular MouseAndKeyboard
29 * node on the datagraph for a session for eventual playback via a
30 * DataGraphPlayback (and a PlaybackController). To use it, make it a child
31 * of the node you wish to record. It also serves as a pass-through, so that
32 * additional child nodes may be parented directly to it.
33 */
34 class EXPCL_PANDA_RECORDER MouseRecorder : public DataNode, public RecorderBase {
35 PUBLISHED:
36 explicit MouseRecorder(const std::string &name);
37 virtual ~MouseRecorder();
38
39 public:
40 virtual void record_frame(BamWriter *manager, Datagram &dg);
41 virtual void play_frame(DatagramIterator &scan, BamReader *manager);
42
43 public:
44 virtual void output(std::ostream &out) const;
45 virtual void write(std::ostream &out, int indent_level = 0) const;
46
47 protected:
48 // Inherited from DataNode
49 virtual void do_transmit_data(DataGraphTraverser *trav,
50 const DataNodeTransmit &input,
51 DataNodeTransmit &output);
52
53 private:
54 // inputs
55 int _pixel_xy_input;
56 int _pixel_size_input;
57 int _xy_input;
58 int _button_events_input;
59
60 // outputs
61 int _pixel_xy_output;
62 int _pixel_size_output;
63 int _xy_output;
64 int _button_events_output;
65
66 bool _has_mouse;
67 LPoint2 _mouse_xy;
68 LPoint2 _mouse_pixel_xy;
69 PT(ButtonEventList) _live_button_events;
70 PT(ButtonEventList) _save_button_events;
71
72 PT(EventStoreVec2) _pixel_xy;
73 PT(EventStoreVec2) _xy;
74
75 public:
76 static void register_with_read_factory();
77 virtual void write_datagram(BamWriter *manager, Datagram &dg);
78 virtual void write_recorder(BamWriter *manager, Datagram &dg);
79
80 INLINE virtual int get_ref_count() const final { return ReferenceCount::get_ref_count(); };
81 INLINE virtual void ref() const final { ReferenceCount::ref(); };
82 INLINE virtual bool unref() const final { return ReferenceCount::unref(); };
83
84 protected:
85 static TypedWritable *make_from_bam(const FactoryParams &params);
86 static RecorderBase *make_recorder(const FactoryParams &params);
87 void fillin(DatagramIterator &scan, BamReader *manager);
88 void fillin_recorder(DatagramIterator &scan, BamReader *manager);
89
90 public:
91 static TypeHandle get_class_type() {
92 return _type_handle;
93 }
94 static void init_type() {
95 DataNode::init_type();
96 RecorderBase::init_type();
97 register_type(_type_handle, "MouseRecorder",
98 DataNode::get_class_type(),
99 RecorderBase::get_class_type());
100 }
101 virtual TypeHandle get_type() const {
102 return get_class_type();
103 }
104 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
105
106 private:
107 static TypeHandle _type_handle;
108 };
109
110 #endif
buttonEventList.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
ButtonEventList
Records a set of button events that happened recently.
Definition: buttonEventList.h:33
DataGraphTraverser
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...
Definition: dataGraphTraverser.h:32
DataNodeTransmit
Encapsulates the data generated from (or sent into) any particular DataNode.
Definition: dataNodeTransmit.h:32
DataNode
The fundamental type of node for the data graph.
Definition: dataNode.h:52
DataNode::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: dataNode.cxx:309
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
MouseRecorder
This object records any data generated by a particular MouseAndKeyboard node on the datagraph for a s...
Definition: mouseRecorder.h:34
PandaNode::write_recorder
void write_recorder(BamWriter *manager, Datagram &dg)
This method is provided for the benefit of classes (like MouseRecorder) that inherit from PandaMode a...
Definition: pandaNode.cxx:3612
PandaNode::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:3574
ParamValue
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
Definition: paramValue.h:103
RecorderBase
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
Definition: recorderBase.h:46
RecorderBase::play_frame
virtual void play_frame(DatagramIterator &scan, BamReader *manager)
Reloads the most recent data collected from the indicated datagram.
Definition: recorderBase.cxx:45
RecorderBase::record_frame
virtual void record_frame(BamWriter *manager, Datagram &dg)
Records the most recent data collected into the indicated datagram.
Definition: recorderBase.cxx:38
ReferenceCount::ref
void ref() const
Explicitly increments the reference count.
Definition: referenceCount.I:151
ReferenceCount::get_ref_count
get_ref_count
Returns the current reference count.
Definition: referenceCount.h:53
ReferenceCount::unref
virtual bool unref() const
Explicitly decrements the reference count.
Definition: referenceCount.I:179
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
dataNodeTransmit.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dataNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
linmath_events.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
recorderBase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22