15 #include "mouseRecorder.h"
16 #include "recorderController.h"
17 #include "dataNodeTransmit.h"
18 #include "bamReader.h"
19 #include "bamWriter.h"
29 MouseRecorder(
const string &name) :
32 _pixel_xy_input = define_input(
"pixel_xy", EventStoreVec2::get_class_type());
33 _pixel_size_input = define_input(
"pixel_size", EventStoreVec2::get_class_type());
34 _xy_input = define_input(
"xy", EventStoreVec2::get_class_type());
35 _button_events_input = define_input(
"button_events", ButtonEventList::get_class_type());
37 _pixel_xy_output = define_output(
"pixel_xy", EventStoreVec2::get_class_type());
38 _pixel_size_output = define_output(
"pixel_size", EventStoreVec2::get_class_type());
39 _xy_output = define_output(
"xy", EventStoreVec2::get_class_type());
40 _button_events_output = define_output(
"button_events", ButtonEventList::get_class_type());
74 _save_button_events->write_datagram(manager, dg);
75 _save_button_events->clear();
94 button_events.
fillin(scan, manager);
95 _save_button_events->add_events(button_events);
104 output(ostream &out)
const {
105 DataNode::output(out);
114 write(ostream &out,
int indent_level)
const {
115 DataNode::write(out, indent_level);
134 bool has_mouse =
false;
138 _live_button_events->clear();
143 has_mouse = _has_mouse;
144 mouse_xy = _mouse_xy;
145 mouse_pixel_xy = _mouse_pixel_xy;
146 _live_button_events->add_events(*_save_button_events);
147 _save_button_events->clear();
164 if (input.
has_data(_button_events_input)) {
166 DCAST_INTO_V(button_events, input.
get_data(_button_events_input).
get_ptr());
167 _live_button_events->add_events(*button_events);
175 _pixel_xy->set_value(_mouse_pixel_xy);
176 _xy->set_value(_mouse_xy);
181 if (_live_button_events->get_num_events() != 0) {
187 _has_mouse = has_mouse;
188 _mouse_xy = mouse_xy;
189 _mouse_pixel_xy = mouse_pixel_xy;
190 _save_button_events->add_events(*_live_button_events);
250 parse_params(params, scan, manager);
251 node->fillin(scan, manager);
269 parse_params(params, scan, manager);
270 node->fillin_recorder(scan, manager);
284 DataNode::fillin(scan, manager);
296 RecorderBase::fillin_recorder(scan, manager);
297 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.
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 ...
Base class for objects that can be written to and read from Bam files.
bool is_recording() const
Returns true if this recorder is presently recording data for saving to a session file...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
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.
void read_datagram(DatagramIterator &source)
Reads the vector from the Datagram using get_stdfloat().
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...
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
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...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
virtual void write_recorder(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for encoding in the session file.
const Type & get_value() const
Retrieves the value stored in the parameter.
void write_datagram(Datagram &destination) const
Writes the vector to the Datagram using add_stdfloat().
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
bool is_playing() const
Returns true if this recorder is presently playing back data from session file, false otherwise...
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. ...
This is a two-component point in space.
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
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...