Panda3D
Loading...
Searching...
No Matches
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
23class FactoryParams;
24class BamReader;
25class 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 */
34class EXPCL_PANDA_RECORDER MouseRecorder : public DataNode, public RecorderBase {
35PUBLISHED:
36 explicit MouseRecorder(const std::string &name);
37 virtual ~MouseRecorder();
38
39public:
40 virtual void record_frame(BamWriter *manager, Datagram &dg);
41 virtual void play_frame(DatagramIterator &scan, BamReader *manager);
42
43public:
44 virtual void output(std::ostream &out) const;
45 virtual void write(std::ostream &out, int indent_level = 0) const;
46
47protected:
48 // Inherited from DataNode
49 virtual void do_transmit_data(DataGraphTraverser *trav,
50 const DataNodeTransmit &input,
51 DataNodeTransmit &output);
52
53private:
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
75public:
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
84protected:
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
90public:
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
106private:
107 static TypeHandle _type_handle;
108};
109
110#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
Records a set of button events that happened recently.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...
Encapsulates the data generated from (or sent into) any particular DataNode.
The fundamental type of node for the data graph.
Definition dataNode.h:52
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
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This object records any data generated by a particular MouseAndKeyboard node on the datagraph for a s...
virtual bool unref() const final
Explicitly decrements the reference count.
void write_recorder(BamWriter *manager, Datagram &dg)
This method is provided for the benefit of classes (like MouseRecorder) that inherit from PandaMode a...
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
Definition paramValue.h:103
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
virtual void play_frame(DatagramIterator &scan, BamReader *manager)
Reloads the most recent data collected from the indicated datagram.
virtual void record_frame(BamWriter *manager, Datagram &dg)
Records the most recent data collected into the indicated datagram.
void ref() const
Explicitly increments the reference count.
get_ref_count
Returns the current reference count.
virtual bool unref() const
Explicitly decrements the reference count.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...