Panda3D
 All Classes Functions Variables Enumerations
pointerEventList.h
1 // Filename: pointerEventList.h
2 // Created by: drose (12Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef POINTEREVENTLIST_H
16 #define POINTEREVENTLIST_H
17 
18 #include "pandabase.h"
19 
20 #include "pointerEvent.h"
21 #include "typedReferenceCount.h"
22 #include "eventParameter.h"
23 #include "vector_double.h"
24 
25 class ModifierPointers;
26 class Datagram;
27 class DatagramIterator;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : PointerEventList
31 // Description : Records a set of pointer events that happened
32 // recently. This class is usually used only in the
33 // data graph, to transmit the recent pointer presses,
34 // but it may be used anywhere a list of PointerEvents
35 // is desired.
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_PANDA_EVENT PointerEventList : public ParamValueBase {
38 PUBLISHED:
39  INLINE PointerEventList();
40 
41  INLINE int get_num_events() const;
42  INLINE bool get_in_window(int n) const;
43  INLINE int get_xpos(int n) const;
44  INLINE int get_ypos(int n) const;
45  INLINE int get_dx(int n) const;
46  INLINE int get_dy(int n) const;
47  INLINE int get_sequence(int n) const;
48  INLINE double get_length(int n) const;
49  INLINE double get_direction(int n) const;
50  INLINE double get_rotation(int n) const;
51  INLINE double get_time(int n) const;
52 
53  INLINE void clear();
54  INLINE void pop_front();
55  void add_event(bool in_win, int xpos, int ypos, int seq, double time);
56 
57  bool encircles(int x, int y) const;
58  double total_turns(double sec) const;
59  double match_pattern(const string &pattern, double rot, double seglen);
60 
61 public:
62  INLINE PointerEventList(const PointerEventList &copy);
63  INLINE void operator = (const PointerEventList &copy);
64 
65  virtual void output(ostream &out) const;
66  void write(ostream &out, int indent_level = 0) const;
67 
68 private:
69  void parse_pattern(const string &ascpat, vector_double &pattern);
71  Events _events;
72 
73 public:
74  static TypeHandle get_class_type() {
75  return _type_handle;
76  }
77  static void init_type() {
78  ParamValueBase::init_type();
79  register_type(_type_handle, "PointerEventList",
80  ParamValueBase::get_class_type());
81  }
82  virtual TypeHandle get_type() const {
83  return get_class_type();
84  }
85  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
86 
87 private:
88  static TypeHandle _type_handle;
89 };
90 
91 INLINE ostream &operator << (ostream &out, const PointerEventList &pointerlist) {
92  pointerlist.output(out);
93  return out;
94 }
95 
96 #include "pointerEventList.I"
97 
98 #endif
99 
Records a set of pointer events that happened recently.
A non-template base class of ParamValue (below), which serves mainly to define the placeholder for th...
Definition: paramValue.h:34
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43