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) {
141 size_t MouseWatcherBase::
142 get_num_regions()
const {
148 return _regions.
size();
162 if (n < _regions.
size()) {
171 void MouseWatcherBase::
172 output(std::ostream &out)
const {
173 out <<
"MouseWatcherGroup (" << _regions.
size() <<
" regions)";
179 void MouseWatcherBase::
180 write(std::ostream &out,
int indent_level)
const {
184 region->write(out, indent_level);
197 do_show_regions(render2d, bin_name, draw_order);
242 void MouseWatcherBase::
245 _regions.sort_unique();
254 bool MouseWatcherBase::
258 Regions::iterator ri;
262 ri = lower_bound(_regions.begin(), _regions.end(), ptr);
265 ri = find(_regions.begin(), _regions.end(), ptr);
268 if (ri != _regions.end() && (*ri) == ptr) {
273 nassertr(_vizzes.size() == _regions.size(),
false);
274 size_t index = ri - _regions.begin();
275 Vizzes::iterator vi = _vizzes.begin() + index;
294 void MouseWatcherBase::
295 do_show_regions(
const NodePath &render2d,
const std::string &bin_name,
298 _show_regions =
true;
300 _show_regions_root.
set_bin(bin_name, draw_order);
310 void MouseWatcherBase::
313 _show_regions =
false;
323 void MouseWatcherBase::
324 do_update_regions() {
333 _vizzes.reserve(_regions.size());
336 _vizzes.push_back(make_viz_region(region));
354 ls.set_color(_color);
356 const LVecBase4 &f = region->get_frame();
358 ls.move_to(LVector3::rfu(f[0], 0.0f, f[2]));
359 ls.draw_to(LVector3::rfu(f[1], 0.0f, f[2]));
360 ls.draw_to(LVector3::rfu(f[1], 0.0f, f[3]));
361 ls.draw_to(LVector3::rfu(f[0], 0.0f, f[3]));
362 ls.draw_to(LVector3::rfu(f[0], 0.0f, f[2]));
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.
bool debug_is_locked() const
Returns true if the current thread has locked the LightMutex, false otherwise.
size_type_0 size() const
Returns the number of elements in the ordered vector.
void clear()
Removes all elements from the ordered vector.
bool remove_region(MouseWatcherRegion *region)
Removes the indicated region from the group.
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.
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_region(PT(MouseWatcherRegion) region)
Adds the indicated region to the set of regions in the group.
get_region
Returns the nth region of the group; returns NULL if there is no nth region.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
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.
bool has_region(MouseWatcherRegion *region) const
Returns true if the indicated region has already been added to the MouseWatcherBase,...
void clear_regions()
Removes all the regions from the group.
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,...
void update_regions()
Refreshes the visualization created by show_regions().
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 remove_all_children(Thread *current_thread=Thread::get_current_thread())
Removes all the children from the node at once, including stashed children.
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().
This represents a collection of MouseWatcherRegions that may be managed as a group.
void push_back(const value_type_0 &key)
Adds the new element to the end of the vector without regard for proper sorting.
PandaNode * node() const
Returns the referenced node of the path.
void remove_node(Thread *current_thread=Thread::get_current_thread())
Disconnects the referenced node from the scene graph.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
MouseWatcherRegion * find_region(const std::string &name) const
Returns a pointer to the first region found with the indicated name.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.