15 #include "mouseWatcherBase.h"
18 #include "lightMutexHolder.h"
29 _lock(
"MouseWatcherBase")
33 _show_regions =
false;
34 _color.set(0.4, 0.6f, 1.0f, 1.0f);
65 Regions::const_iterator ri =
66 find(_regions.begin(), _regions.end(), pt);
67 nassertv(ri == _regions.end());
73 nassertv(_vizzes.size() == _regions.size());
74 _vizzes.push_back(make_viz_region(pt));
78 _regions.push_back(pt);
96 Regions::const_iterator ri = lower_bound(_regions.begin(), _regions.end(), ptr);
97 return (ri != _regions.end() && (*ri) == ptr);
101 Regions::const_iterator ri = find(_regions.begin(), _regions.end(), ptr);
102 return (ri != _regions.end());
115 return do_remove_region(region);
129 Regions::const_iterator ri;
130 for (ri = _regions.begin(); ri != _regions.end(); ++ri) {
132 if (region->get_name() == name) {
194 return _regions.size();
208 if (n >= 0 && n < (
int)_regions.size()) {
219 void MouseWatcherBase::
220 output(ostream &out)
const {
221 out <<
"MouseWatcherGroup (" << _regions.size() <<
" regions)";
229 void MouseWatcherBase::
230 write(ostream &out,
int indent_level)
const {
233 Regions::const_iterator ri;
234 for (ri = _regions.begin(); ri != _regions.end(); ++ri) {
236 region->write(out, indent_level);
252 do_show_regions(render2d, bin_name, draw_order);
308 void MouseWatcherBase::
311 sort(_regions.begin(), _regions.end());
322 bool MouseWatcherBase::
326 Regions::iterator ri;
330 ri = lower_bound(_regions.begin(), _regions.end(), ptr);
333 ri = find(_regions.begin(), _regions.end(), ptr);
336 if (ri != _regions.end() && (*ri) == ptr) {
341 nassertr(_vizzes.size() == _regions.size(),
false);
342 size_t index = ri - _regions.begin();
343 Vizzes::iterator vi = _vizzes.begin() + index;
364 void MouseWatcherBase::
365 do_show_regions(
const NodePath &render2d,
const string &bin_name,
368 _show_regions =
true;
370 _show_regions_root.
set_bin(bin_name, draw_order);
382 void MouseWatcherBase::
385 _show_regions =
false;
397 void MouseWatcherBase::
398 do_update_regions() {
404 _vizzes.reserve(_regions.size());
406 Regions::const_iterator ri;
407 for (ri = _regions.begin(); ri != _regions.end(); ++ri) {
408 _vizzes.push_back(make_viz_region(*ri));
428 ls.set_color(_color);
430 const LVecBase4 &f = region->get_frame();
439 _show_regions_root.attach_new_node(node);
A basic node of the scene graph or data graph.
void remove_child(int child_index, Thread *current_thread=Thread::get_current_thread())
Removes the nth child from the node.
void sort_regions()
Sorts all the regions in this group into pointer order.
bool remove_region(MouseWatcherRegion *region)
Removes the indicated region from the group.
MouseWatcherRegion * find_region(const string &name) const
Returns a pointer to the first region found with the indicated name.
PandaNode * node() const
Returns the referenced node of the path.
bool is_sorted() const
Returns true if the group has already been sorted, false otherwise.
void add_region(MouseWatcherRegion *region)
Adds the indicated region to the set of regions in the group.
MouseWatcherRegion * get_region(int n) const
Returns the nth region of the group; returns NULL if there is no nth region.
static LVector3f rfu(float right, float fwd, float up, CoordinateSystem cs=CS_default)
Returns a vector that is described by its right, forward, and up components, in whatever way the coor...
bool debug_is_locked() const
Returns true if the current thread has locked the LightMutex, false otherwise.
void clear_regions()
Removes all the regions from the group.
void show_regions(const NodePath &render2d, const string &bin_name, int draw_order)
Enables the visualization of all of the regions handled by this MouseWatcherBase. ...
void hide_regions()
Stops the visualization created by a previous call to show_regions().
Encapsulates creation of a series of connected or disconnected line segments or points, for drawing paths or rays.
void update_regions()
Refreshes the visualization created by show_regions().
void set_bin(const string &bin_name, int draw_order, int priority=0)
Assigns the geometry at this level and below to the named rendering bin.
void remove_all_children(Thread *current_thread=Thread::get_current_thread())
Removes all the children from the node at once, including stashed children.
bool has_region(MouseWatcherRegion *region) const
Returns true if the indicated region has already been added to the MouseWatcherBase, false otherwise.
Similar to MutexHolder, but for a light mutex.
This is the class that defines a rectangular region on the screen for the MouseWatcher.
void set_color(const LColor &color)
Specifies the color used to draw the region rectangles for the regions visualized by show_regions()...
int get_num_regions() const
Returns the number of regions in the group.
This is the base class for all three-component vectors and points.
void remove_node(Thread *current_thread=Thread::get_current_thread())
Disconnects the referenced node from the scene graph.
TypeHandle is the identifier used to differentiate C++ class types.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
NodePath attach_new_node(PandaNode *node, int sort=0, Thread *current_thread=Thread::get_current_thread()) const
Attaches a new node, with or without existing parents, to the scene graph below the referenced node o...