Panda3D
|
00001 // Filename: pointerEventList.h 00002 // Created by: drose (12Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef POINTEREVENTLIST_H 00016 #define POINTEREVENTLIST_H 00017 00018 #include "pandabase.h" 00019 00020 #include "pointerEvent.h" 00021 #include "typedReferenceCount.h" 00022 #include "eventParameter.h" 00023 #include "vector_double.h" 00024 00025 class ModifierPointers; 00026 class Datagram; 00027 class DatagramIterator; 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : PointerEventList 00031 // Description : Records a set of pointer events that happened 00032 // recently. This class is usually used only in the 00033 // data graph, to transmit the recent pointer presses, 00034 // but it may be used anywhere a list of PointerEvents 00035 // is desired. 00036 //////////////////////////////////////////////////////////////////// 00037 class EXPCL_PANDA_EVENT PointerEventList : public EventStoreValueBase { 00038 PUBLISHED: 00039 INLINE PointerEventList(); 00040 00041 INLINE int get_num_events() const; 00042 INLINE bool get_in_window(int n) const; 00043 INLINE int get_xpos(int n) const; 00044 INLINE int get_ypos(int n) const; 00045 INLINE int get_dx(int n) const; 00046 INLINE int get_dy(int n) const; 00047 INLINE int get_sequence(int n) const; 00048 INLINE double get_length(int n) const; 00049 INLINE double get_direction(int n) const; 00050 INLINE double get_rotation(int n) const; 00051 INLINE double get_time(int n) const; 00052 00053 INLINE void clear(); 00054 INLINE void pop_front(); 00055 void add_event(bool in_win, int xpos, int ypos, int seq, double time); 00056 00057 bool encircles(int x, int y) const; 00058 double total_turns(double sec) const; 00059 double match_pattern(const string &pattern, double rot, double seglen); 00060 00061 public: 00062 INLINE PointerEventList(const PointerEventList ©); 00063 INLINE void operator = (const PointerEventList ©); 00064 00065 00066 virtual void output(ostream &out) const; 00067 void write(ostream &out, int indent_level = 0) const; 00068 00069 private: 00070 void parse_pattern(const string &ascpat, vector_double &pattern); 00071 typedef pdeque<PointerEvent> Events; 00072 Events _events; 00073 00074 public: 00075 static TypeHandle get_class_type() { 00076 return _type_handle; 00077 } 00078 static void init_type() { 00079 EventStoreValueBase::init_type(); 00080 register_type(_type_handle, "PointerEventList", 00081 EventStoreValueBase::get_class_type()); 00082 } 00083 virtual TypeHandle get_type() const { 00084 return get_class_type(); 00085 } 00086 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00087 00088 private: 00089 static TypeHandle _type_handle; 00090 }; 00091 00092 INLINE ostream &operator << (ostream &out, const PointerEventList &pointerlist) { 00093 pointerlist.output(out); 00094 return out; 00095 } 00096 00097 #include "pointerEventList.I" 00098 00099 #endif 00100