Panda3D
|
00001 // Filename: mouseWatcherGroup.h 00002 // Created by: drose (02Jul01) 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 MOUSEWATCHERGROUP_H 00016 #define MOUSEWATCHERGROUP_H 00017 00018 #include "pandabase.h" 00019 #include "mouseWatcherRegion.h" 00020 00021 #include "pointerTo.h" 00022 #include "referenceCount.h" 00023 #include "pvector.h" 00024 #include "nodePath.h" 00025 #include "lightMutex.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : MouseWatcherGroup 00029 // Description : This represents a collection of MouseWatcherRegions 00030 // that may be managed as a group. 00031 //////////////////////////////////////////////////////////////////// 00032 class EXPCL_PANDA_TFORM MouseWatcherGroup : virtual public ReferenceCount { 00033 public: 00034 MouseWatcherGroup(); 00035 virtual ~MouseWatcherGroup(); 00036 00037 PUBLISHED: 00038 void add_region(MouseWatcherRegion *region); 00039 bool has_region(MouseWatcherRegion *region) const; 00040 bool remove_region(MouseWatcherRegion *region); 00041 MouseWatcherRegion *find_region(const string &name) const; 00042 void clear_regions(); 00043 00044 void sort_regions(); 00045 bool is_sorted() const; 00046 00047 int get_num_regions() const; 00048 MouseWatcherRegion *get_region(int n) const; 00049 MAKE_SEQ(get_regions, get_num_regions, get_region); 00050 00051 void output(ostream &out) const; 00052 void write(ostream &out, int indent_level = 0) const; 00053 00054 #ifndef NDEBUG 00055 void show_regions(const NodePath &render2d, 00056 const string &bin_name, int draw_order); 00057 void set_color(const LColor &color); 00058 void hide_regions(); 00059 00060 void update_regions(); 00061 #endif // NDEBUG 00062 00063 protected: 00064 void do_sort_regions(); 00065 bool do_remove_region(MouseWatcherRegion *region); 00066 00067 #ifndef NDEBUG 00068 virtual void do_show_regions(const NodePath &render2d, 00069 const string &bin_name, int draw_order); 00070 virtual void do_hide_regions(); 00071 void do_update_regions(); 00072 #endif // NDEBUG 00073 00074 protected: 00075 typedef pvector< PT(MouseWatcherRegion) > Regions; 00076 Regions _regions; 00077 bool _sorted; 00078 00079 // This mutex protects the above list of regions, as well as the 00080 // below list of vizzes. It is also referenced directly by 00081 // MouseWatcher, a derived class. 00082 LightMutex _lock; 00083 00084 private: 00085 #ifndef NDEBUG 00086 PandaNode *make_viz_region(MouseWatcherRegion *region); 00087 00088 typedef pvector< PT(PandaNode) > Vizzes; 00089 Vizzes _vizzes; 00090 00091 bool _show_regions; 00092 NodePath _show_regions_root; 00093 LColor _color; 00094 #endif // NDEBUG 00095 00096 public: 00097 static TypeHandle get_class_type() { 00098 ReferenceCount::init_type(); 00099 return _type_handle; 00100 } 00101 static void init_type() { 00102 register_type(_type_handle, "MouseWatcherGroup", 00103 ReferenceCount::get_class_type()); 00104 } 00105 00106 private: 00107 static TypeHandle _type_handle; 00108 00109 friend class MouseWatcher; 00110 friend class BlobWatcher; 00111 }; 00112 00113 #endif