Panda3D
Loading...
Searching...
No Matches
pointerEventList.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 pointerEventList.h
10 * @author drose
11 * @date 2002-03-12
12 */
13
14#ifndef POINTEREVENTLIST_H
15#define POINTEREVENTLIST_H
16
17#include "pandabase.h"
18
19#include "pointerEvent.h"
20#include "typedReferenceCount.h"
21#include "eventParameter.h"
22#include "vector_double.h"
23
24class ModifierPointers;
25class Datagram;
27
28/**
29 * Records a set of pointer events that happened recently. This class is
30 * usually used only in the data graph, to transmit the recent pointer
31 * presses, but it may be used anywhere a list of PointerEvents is desired.
32 */
33class EXPCL_PANDA_EVENT PointerEventList : public ParamValueBase {
34PUBLISHED:
35 INLINE PointerEventList();
36
37 INLINE size_t get_num_events() const;
38 INLINE bool get_in_window(size_t n) const;
39 INLINE int get_xpos(size_t n) const;
40 INLINE int get_ypos(size_t n) const;
41 INLINE double get_dx(size_t n) const;
42 INLINE double get_dy(size_t n) const;
43 INLINE int get_sequence(size_t n) const;
44 INLINE double get_length(size_t n) const;
45 INLINE double get_direction(size_t n) const;
46 INLINE double get_rotation(size_t n) const;
47 INLINE double get_time(size_t n) const;
48
49 INLINE void clear();
50 INLINE void pop_front();
51 void add_event(const PointerData &data, int seq, double time);
52 void add_event(bool in_win, int xpos, int ypos, int seq, double time);
53 void add_event(bool in_win, int xpos, int ypos, double xdelta, double ydelta,
54 int seq, double time);
55
56 bool encircles(int x, int y) const;
57 double total_turns(double sec) const;
58 double match_pattern(const std::string &pattern, double rot, double seglen);
59
60public:
61 INLINE PointerEventList(const PointerEventList &copy);
62 INLINE void operator = (const PointerEventList &copy);
63
64 INLINE bool empty() const;
65 INLINE const PointerEvent &get_event(size_t n) const;
66
67 virtual void output(std::ostream &out) const;
68 void write(std::ostream &out, int indent_level = 0) const;
69
70private:
71 void parse_pattern(const std::string &ascpat, vector_double &pattern);
73 Events _events;
74
75public:
76 static TypeHandle get_class_type() {
77 return _type_handle;
78 }
79 static void init_type() {
80 ParamValueBase::init_type();
81 register_type(_type_handle, "PointerEventList",
82 ParamValueBase::get_class_type());
83 }
84 virtual TypeHandle get_type() const {
85 return get_class_type();
86 }
87 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
88
89private:
90 static TypeHandle _type_handle;
91};
92
93INLINE std::ostream &operator << (std::ostream &out, const PointerEventList &pointerlist) {
94 pointerlist.output(out);
95 return out;
96}
97
98#include "pointerEventList.I"
99
100#endif
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
A non-template base class of ParamValue (below), which serves mainly to define the placeholder for th...
Definition paramValue.h:31
Holds the data that might be generated by a 2-d pointer input device, such as the mouse in the Graphi...
Definition pointerData.h:38
Records a set of pointer events that happened recently.
Records a pointer movement event.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
This is our own Panda specialization on the default STL deque.
Definition pdeque.h:36
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(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.