26 MouseRecorder(
const std::string &name) :
29 _pixel_xy_input = define_input(
"pixel_xy", EventStoreVec2::get_class_type());
30 _pixel_size_input = define_input(
"pixel_size", EventStoreVec2::get_class_type());
31 _xy_input = define_input(
"xy", EventStoreVec2::get_class_type());
32 _button_events_input = define_input(
"button_events", ButtonEventList::get_class_type());
34 _pixel_xy_output = define_output(
"pixel_xy", EventStoreVec2::get_class_type());
35 _pixel_size_output = define_output(
"pixel_size", EventStoreVec2::get_class_type());
36 _xy_output = define_output(
"xy", EventStoreVec2::get_class_type());
37 _button_events_output = define_output(
"button_events", ButtonEventList::get_class_type());
63 _mouse_xy.write_datagram(dg);
64 _mouse_pixel_xy.write_datagram(dg);
66 _save_button_events->write_datagram(manager, dg);
67 _save_button_events->clear();
79 _mouse_xy.read_datagram(scan);
80 _mouse_pixel_xy.read_datagram(scan);
83 button_events.
fillin(scan, manager);
84 _save_button_events->add_events(button_events);
91 output(std::ostream &out)
const {
92 DataNode::output(out);
99 write(std::ostream &out,
int indent_level)
const {
100 DataNode::write(out, indent_level);
114 bool has_mouse =
false;
116 LPoint2 mouse_pixel_xy;
118 _live_button_events->clear();
123 has_mouse = _has_mouse;
124 mouse_xy = _mouse_xy;
125 mouse_pixel_xy = _mouse_pixel_xy;
126 _live_button_events->add_events(*_save_button_events);
127 _save_button_events->clear();
143 if (input.
has_data(_button_events_input)) {
145 DCAST_INTO_V(button_events, input.
get_data(_button_events_input).
get_ptr());
146 _live_button_events->add_events(*button_events);
154 _pixel_xy->set_value(_mouse_pixel_xy);
155 _xy->set_value(_mouse_xy);
160 if (_live_button_events->get_num_events() != 0) {
166 _has_mouse = has_mouse;
167 _mouse_xy = mouse_xy;
168 _mouse_pixel_xy = mouse_pixel_xy;
169 _save_button_events->add_events(*_live_button_events);
219 node->fillin(scan, manager);
235 node->fillin_recorder(scan, manager);
246 DataNode::fillin(scan, manager);
255 RecorderBase::fillin_recorder(scan, manager);
256 DataNode::fillin_recorder(scan, manager);
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
The fundamental type of node for the data graph.
static void register_with_read_factory()
Tells the BamReader how to create objects of type Lens.
bool get_bool()
Extracts a boolean value.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An optional parameter associated with an event.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void write_recorder(BamWriter *manager, Datagram &dg)
This method is provided for the benefit of classes (like MouseRecorder) that inherit from PandaMode a...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static RecorderFactory * get_factory()
Returns the global RecorderFactory for generating TypedWritable objects.
virtual void record_frame(BamWriter *manager, Datagram &dg)
Records the most recent data collected into the indicated datagram, and returns true if there is any ...
get_value
Retrieves the value stored in the parameter.
Base class for objects that can be written to and read from Bam files.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
void add_bool(bool value)
Adds a boolean value to the datagram.
void set_data(int index, const EventParameter &data)
Sets the data for the indicated parameter.
virtual void write_recorder(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for encoding in the session file.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
virtual void write_recorder(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for encoding in the session file.
const EventParameter & get_data(int index) const
Extracts the data for the indicated index, if it has been stored, or the empty parameter if it has no...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This object records any data generated by a particular MouseAndKeyboard node on the datagraph for a s...
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
bool is_playing() const
Returns true if this recorder is presently playing back data from session file, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_recording() const
Returns true if this recorder is presently recording data for saving to a session file,...
Encapsulates the data generated from (or sent into) any particular DataNode.
virtual void play_frame(DatagramIterator &scan, BamReader *manager)
Reloads the most recent data collected from the indicated datagram.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...