Go to the documentation of this file.
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);
bool is_playing() const
Returns true if this recorder is presently playing back data from session file, false otherwise.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...
A class to retrieve the individual data elements previously stored in a Datagram.
void write_recorder(BamWriter *manager, Datagram &dg)
This method is provided for the benefit of classes (like MouseRecorder) that inherit from PandaMode a...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static RecorderFactory * get_factory()
Returns the global RecorderFactory for generating TypedWritable objects.
virtual void write_recorder(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for encoding in the session file.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
virtual void write_recorder(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for encoding in the session file.
static WritableFactory * get_factory()
Returns the global WritableFactory 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 ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
static void register_with_read_factory()
Tells the BamReader how to create objects of type Lens.
TypeHandle is the identifier used to differentiate C++ class types.
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
bool get_bool()
Extracts a boolean value.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The fundamental type of node for the data graph.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
void set_data(int index, const EventParameter &data)
Sets the data for the indicated parameter.
An optional parameter associated with an event.
Encapsulates the data generated from (or sent into) any particular DataNode.
bool is_recording() const
Returns true if this recorder is presently recording data for saving to a session file,...
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
This object records any data generated by a particular MouseAndKeyboard node on the datagraph for a s...
void add_bool(bool value)
Adds a boolean value to the datagram.
get_value
Retrieves the value stored in the parameter.
virtual void play_frame(DatagramIterator &scan, BamReader *manager)
Reloads the most recent data collected from the indicated datagram.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...