Panda3D
nodePathCollection.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file nodePathCollection.h
10  * @author drose
11  * @date 2002-03-06
12  */
13 
14 #ifndef NODEPATHCOLLECTION_H
15 #define NODEPATHCOLLECTION_H
16 
17 #include "pandabase.h"
18 #include "nodePath.h"
19 #include "pointerToArray.h"
20 
21 /**
22  * This is a set of zero or more NodePaths. It's handy for returning from
23  * functions that need to return multiple NodePaths (for instance,
24  * NodePaths::get_children).
25  */
26 class EXPCL_PANDA_PGRAPH NodePathCollection {
27 PUBLISHED:
28  NodePathCollection() = default;
29 
30 #ifdef HAVE_PYTHON
31  EXTENSION(NodePathCollection(PyObject *self, PyObject *sequence));
32  EXTENSION(PyObject *__reduce__(PyObject *self) const);
33 #endif
34 
35  void add_path(const NodePath &node_path);
36  bool remove_path(const NodePath &node_path);
37  void add_paths_from(const NodePathCollection &other);
38  void remove_paths_from(const NodePathCollection &other);
39  void remove_duplicate_paths();
40  bool has_path(const NodePath &path) const;
41  void clear();
42  void reserve(size_t num);
43 
44  bool is_empty() const;
45  int get_num_paths() const;
46  NodePath get_path(int index) const;
47  MAKE_SEQ(get_paths, get_num_paths, get_path);
48  NodePath operator [] (size_t index) const;
49  size_t size() const;
50  INLINE void operator += (const NodePathCollection &other);
51  INLINE NodePathCollection operator + (const NodePathCollection &other) const;
52 
53  // Method names to satisfy Python's conventions.
54  INLINE void append(const NodePath &node_path);
55  INLINE void extend(const NodePathCollection &other);
56 
57  // Handy operations on many NodePaths at once.
58  INLINE void ls() const;
59  void ls(std::ostream &out, int indent_level = 0) const;
60 
61  NodePathCollection find_all_matches(const std::string &path) const;
62  void reparent_to(const NodePath &other);
63  void wrt_reparent_to(const NodePath &other);
64 
65  void show();
66  void hide();
67  void stash();
68  void unstash();
69  void detach();
70 
71  CollideMask get_collide_mask() const;
72  void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change = CollideMask::all_on(),
73  TypeHandle node_type = TypeHandle::none());
74 
75  bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const;
76 
77  EXTENSION(PyObject *get_tight_bounds() const);
78 
79  void set_texture(Texture *tex, int priority = 0);
80  void set_texture(TextureStage *stage, Texture *tex, int priority = 0);
81  void set_texture_off(int priority = 0);
82  void set_texture_off(TextureStage *stage, int priority = 0);
83 
84  INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0,
85  int priority = 0);
86  void set_color(const LColor &color, int priority = 0);
87 
88  INLINE void set_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0,
89  int priority = 0);
90  void set_color_scale(const LVecBase4 &scale, int priority = 0);
91 
92  INLINE void compose_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0,
93  int priority = 0);
94  void compose_color_scale(const LVecBase4 &scale, int priority = 0);
95 
96  void set_attrib(const RenderAttrib *attrib, int priority = 0);
97 
98  void output(std::ostream &out) const;
99  void write(std::ostream &out, int indent_level = 0) const;
100 
101 private:
102  typedef PTA(NodePath) NodePaths;
103  NodePaths _node_paths;
104 
105  // This typedef is used in set_attrib() and similar methods.
106  typedef pmap<CPT(RenderState), CPT(RenderState) > StateMap;
107 };
108 
109 INLINE std::ostream &operator << (std::ostream &out, const NodePathCollection &col) {
110  col.output(out);
111  return out;
112 }
113 
114 #include "nodePathCollection.I"
115 
116 #endif
This is our own Panda specialization on the default STL map.
Definition: pmap.h:49
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:51
static BitMask< WType, nbits > all_on()
Returns a BitMask whose bits are all on.
Definition: bitMask.I:32
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void output(std::ostream &out) const
Writes a brief one-line description of the NodePathCollection to the indicated output stream.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:35
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a set of zero or more NodePaths.