26 _lock(
"MouseWatcherBase")
30 _show_regions =
false;
31 _color.set(0.4, 0.6f, 1.0f, 1.0f);
52 if (UNLIKELY(_show_regions)) {
55 Regions::const_iterator ri =
56 std::find(_regions.
begin(), _regions.
end(), region);
58 if (ri == _regions.
end()) {
59 nassertv(_vizzes.size() == _regions.
size());
60 _vizzes.push_back(make_viz_region(region));
83 Regions::const_iterator ri = lower_bound(_regions.
begin(), _regions.
end(), ptr);
84 return (ri != _regions.
end() && (*ri) == ptr);
88 Regions::const_iterator ri = find(_regions.
begin(), _regions.
end(), ptr);
89 return (ri != _regions.
end());
99 return do_remove_region(region);
112 if (region->get_name() == name) {
148 return _regions.
size();
162 if (n < _regions.
size()) {
171void MouseWatcherBase::
172output(std::ostream &out)
const {
173 out <<
"MouseWatcherGroup (" << _regions.
size() <<
" regions)";
179void MouseWatcherBase::
180write(std::ostream &out,
int indent_level)
const {
184 region->write(out, indent_level);
188#if !defined(NDEBUG) || !defined(CPPPARSER)
198 do_show_regions(render2d, bin_name, draw_order);
203#if !defined(NDEBUG) || !defined(CPPPARSER)
219#if !defined(NDEBUG) || !defined(CPPPARSER)
232#if !defined(NDEBUG) || !defined(CPPPARSER)
250void MouseWatcherBase::
262bool MouseWatcherBase::
266 Regions::iterator ri;
270 ri = lower_bound(_regions.
begin(), _regions.
end(), ptr);
273 ri = find(_regions.
begin(), _regions.
end(), ptr);
276 if (ri != _regions.
end() && (*ri) == ptr) {
281 nassertr(_vizzes.size() == _regions.
size(),
false);
282 size_t index = ri - _regions.
begin();
283 Vizzes::iterator vi = _vizzes.begin() + index;
302void MouseWatcherBase::
303do_show_regions(
const NodePath &render2d,
const std::string &bin_name,
306 _show_regions =
true;
308 _show_regions_root.
set_bin(bin_name, draw_order);
318void MouseWatcherBase::
321 _show_regions =
false;
331void MouseWatcherBase::
341 _vizzes.reserve(_regions.
size());
344 _vizzes.push_back(make_viz_region(region));
362 ls.set_color(_color);
364 const LVecBase4 &f = region->get_frame();
366 ls.move_to(LVector3::rfu(f[0], 0.0f, f[2]));
367 ls.draw_to(LVector3::rfu(f[1], 0.0f, f[2]));
368 ls.draw_to(LVector3::rfu(f[1], 0.0f, f[3]));
369 ls.draw_to(LVector3::rfu(f[0], 0.0f, f[3]));
370 ls.draw_to(LVector3::rfu(f[0], 0.0f, f[2]));
bool debug_is_locked() const
Returns true if the current thread has locked the LightMutex, false otherwise.
Similar to MutexHolder, but for a light mutex.
Encapsulates creation of a series of connected or disconnected line segments or points,...
This represents a collection of MouseWatcherRegions that may be managed as a group.
bool remove_region(MouseWatcherRegion *region)
Removes the indicated region from the group.
get_num_regions
Returns the number of regions in the group.
void clear_regions()
Removes all the regions from the group.
void add_region(PT(MouseWatcherRegion) region)
Adds the indicated region to the set of regions in the group.
void show_regions(const NodePath &render2d, const std::string &bin_name, int draw_order)
Enables the visualization of all of the regions handled by this MouseWatcherBase.
MouseWatcherRegion * find_region(const std::string &name) const
Returns a pointer to the first region found with the indicated name.
get_region
Returns the nth region of the group; returns NULL if there is no nth region.
void set_color(const LColor &color)
Specifies the color used to draw the region rectangles for the regions visualized by show_regions().
void update_regions()
Refreshes the visualization created by show_regions().
void hide_regions()
Stops the visualization created by a previous call to show_regions().
bool has_region(MouseWatcherRegion *region) const
Returns true if the indicated region has already been added to the MouseWatcherBase,...
This is the class that defines a rectangular region on the screen for the MouseWatcher.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
void remove_node(Thread *current_thread=Thread::get_current_thread())
Disconnects the referenced node from the scene graph.
PandaNode * node() const
Returns the referenced node of the path.
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...
void set_bin(const std::string &bin_name, int draw_order, int priority=0)
Assigns the geometry at this level and below to the named rendering bin.
A basic node of the scene graph or data graph.
void remove_all_children(Thread *current_thread=Thread::get_current_thread())
Removes all the children from the node at once, including stashed children.
void remove_child(int child_index, Thread *current_thread=Thread::get_current_thread())
Removes the nth child from the node.
TypeHandle is the identifier used to differentiate C++ class types.
void sort_unique()
Ensures that the vector is properly sorted after a potentially damaging operation.
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
void push_back(const value_type_0 &key)
Adds the new element to the end of the vector without regard for proper sorting.
size_type_0 size() const
Returns the number of elements in the ordered vector.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
void clear()
Removes all elements from the ordered vector.
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.