nodePathCollection.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // Filename: nodePathCollection.h
  2. // Created by: drose (06Mar02)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef NODEPATHCOLLECTION_H
  15. #define NODEPATHCOLLECTION_H
  16. #include "pandabase.h"
  17. #include "nodePath.h"
  18. #include "pointerToArray.h"
  19. ////////////////////////////////////////////////////////////////////
  20. // Class : NodePathCollection
  21. // Description : This is a set of zero or more NodePaths. It's handy
  22. // for returning from functions that need to return
  23. // multiple NodePaths (for instance,
  24. // NodePaths::get_children).
  25. ////////////////////////////////////////////////////////////////////
  26. class EXPCL_PANDA_PGRAPH NodePathCollection {
  27. PUBLISHED:
  28. NodePathCollection();
  29. NodePathCollection(const NodePathCollection &copy);
  30. void operator = (const NodePathCollection &copy);
  31. INLINE ~NodePathCollection();
  32. void add_path(const NodePath &node_path);
  33. bool remove_path(const NodePath &node_path);
  34. void add_paths_from(const NodePathCollection &other);
  35. void remove_paths_from(const NodePathCollection &other);
  36. void remove_duplicate_paths();
  37. bool has_path(const NodePath &path) const;
  38. void clear();
  39. bool is_empty() const;
  40. int get_num_paths() const;
  41. NodePath get_path(int index) const;
  42. MAKE_SEQ(get_paths, get_num_paths, get_path);
  43. NodePath operator [] (int index) const;
  44. int size() const;
  45. INLINE void operator += (const NodePathCollection &other);
  46. INLINE NodePathCollection operator + (const NodePathCollection &other) const;
  47. // Handy operations on many NodePaths at once.
  48. INLINE void ls() const;
  49. void ls(ostream &out, int indent_level = 0) const;
  50. NodePathCollection find_all_matches(const string &path) const;
  51. void reparent_to(const NodePath &other);
  52. void wrt_reparent_to(const NodePath &other);
  53. void show();
  54. void hide();
  55. void stash();
  56. void unstash();
  57. void detach();
  58. CollideMask get_collide_mask() const;
  59. void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change = CollideMask::all_on(),
  60. TypeHandle node_type = TypeHandle::none());
  61. void set_texture(Texture *tex, int priority = 0);
  62. void set_texture(TextureStage *stage, Texture *tex, int priority = 0);
  63. void set_texture_off(int priority = 0);
  64. void set_texture_off(TextureStage *stage, int priority = 0);
  65. INLINE void set_color(float r, float g, float b, float a = 1.0,
  66. int priority = 0);
  67. void set_color(const Colorf &color, int priority = 0);
  68. INLINE void set_color_scale(float r, float g, float b, float a = 1.0,
  69. int priority = 0);
  70. void set_color_scale(const LVecBase4f &scale, int priority = 0);
  71. INLINE void compose_color_scale(float r, float g, float b, float a = 1.0,
  72. int priority = 0);
  73. void compose_color_scale(const LVecBase4f &scale, int priority = 0);
  74. void set_attrib(const RenderAttrib *attrib, int priority = 0);
  75. void output(ostream &out) const;
  76. void write(ostream &out, int indent_level = 0) const;
  77. private:
  78. typedef PTA(NodePath) NodePaths;
  79. NodePaths _node_paths;
  80. // This typedef is used in set_attrib() and similar methods.
  81. typedef pmap<CPT(RenderState), CPT(RenderState) > StateMap;
  82. };
  83. INLINE ostream &operator << (ostream &out, const NodePathCollection &col) {
  84. col.output(out);
  85. return out;
  86. }
  87. #include "nodePathCollection.I"
  88. #endif