nodePathCollection.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. NodePath operator [] (int index) const;
  43. // Handy operations on many NodePaths at once.
  44. INLINE void ls() const;
  45. void ls(ostream &out, int indent_level = 0) const;
  46. NodePathCollection find_all_matches(const string &path) const;
  47. void reparent_to(const NodePath &other);
  48. void wrt_reparent_to(const NodePath &other);
  49. void show();
  50. void hide();
  51. void stash();
  52. void unstash();
  53. void detach();
  54. CollideMask get_collide_mask() const;
  55. void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change = CollideMask::all_on(),
  56. TypeHandle node_type = TypeHandle::none());
  57. void set_texture(Texture *tex, int priority = 0);
  58. void set_texture(TextureStage *stage, Texture *tex, int priority = 0);
  59. void set_texture_off(int priority = 0);
  60. void set_texture_off(TextureStage *stage, int priority = 0);
  61. INLINE void set_color(float r, float g, float b, float a = 1.0,
  62. int priority = 0);
  63. void set_color(const Colorf &color, int priority = 0);
  64. INLINE void set_color_scale(float r, float g, float b, float a = 1.0,
  65. int priority = 0);
  66. void set_color_scale(const LVecBase4f &scale, int priority = 0);
  67. INLINE void compose_color_scale(float r, float g, float b, float a = 1.0,
  68. int priority = 0);
  69. void compose_color_scale(const LVecBase4f &scale, int priority = 0);
  70. void set_attrib(const RenderAttrib *attrib, int priority = 0);
  71. void output(ostream &out) const;
  72. void write(ostream &out, int indent_level = 0) const;
  73. private:
  74. typedef PTA(NodePath) NodePaths;
  75. NodePaths _node_paths;
  76. // This typedef is used in set_attrib() and similar methods.
  77. typedef pmap<CPT(RenderState), CPT(RenderState) > StateMap;
  78. };
  79. INLINE ostream &operator << (ostream &out, const NodePathCollection &col) {
  80. col.output(out);
  81. return out;
  82. }
  83. #include "nodePathCollection.I"
  84. #endif