Panda3D
 All Classes Functions Variables Enumerations
nodePathCollection.h
00001 // Filename: nodePathCollection.h
00002 // Created by:  drose (06Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef NODEPATHCOLLECTION_H
00016 #define NODEPATHCOLLECTION_H
00017 
00018 #include "pandabase.h"
00019 #include "nodePath.h"
00020 #include "pointerToArray.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : NodePathCollection
00024 // Description : This is a set of zero or more NodePaths.  It's handy
00025 //               for returning from functions that need to return
00026 //               multiple NodePaths (for instance,
00027 //               NodePaths::get_children).
00028 ////////////////////////////////////////////////////////////////////
00029 class EXPCL_PANDA_PGRAPH NodePathCollection {
00030 PUBLISHED:
00031   NodePathCollection();
00032   NodePathCollection(const NodePathCollection &copy);
00033   void operator = (const NodePathCollection &copy);
00034   INLINE ~NodePathCollection();
00035 
00036 #ifdef HAVE_PYTHON
00037   NodePathCollection(PyObject *self, PyObject *sequence);
00038   PyObject *__reduce__(PyObject *self) const;
00039 #endif
00040 
00041   void add_path(const NodePath &node_path);
00042   bool remove_path(const NodePath &node_path);
00043   void add_paths_from(const NodePathCollection &other);
00044   void remove_paths_from(const NodePathCollection &other);
00045   void remove_duplicate_paths();
00046   bool has_path(const NodePath &path) const;
00047   void clear();
00048 
00049   bool is_empty() const;
00050   int get_num_paths() const;
00051   NodePath get_path(int index) const;
00052   MAKE_SEQ(get_paths, get_num_paths, get_path);
00053   NodePath operator [] (int index) const;
00054   int size() const;
00055   INLINE void operator += (const NodePathCollection &other);
00056   INLINE NodePathCollection operator + (const NodePathCollection &other) const;
00057 
00058   // Method names to satisfy Python's conventions.
00059   INLINE void append(const NodePath &node_path);
00060   INLINE void extend(const NodePathCollection &other);
00061 
00062   // Handy operations on many NodePaths at once.
00063   INLINE void ls() const;
00064   void ls(ostream &out, int indent_level = 0) const;
00065 
00066   NodePathCollection find_all_matches(const string &path) const;
00067   void reparent_to(const NodePath &other);
00068   void wrt_reparent_to(const NodePath &other);
00069 
00070   void show();
00071   void hide();
00072   void stash();
00073   void unstash();
00074   void detach();
00075 
00076   CollideMask get_collide_mask() const;
00077   void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change = CollideMask::all_on(),
00078                         TypeHandle node_type = TypeHandle::none());
00079 
00080   void set_texture(Texture *tex, int priority = 0);
00081   void set_texture(TextureStage *stage, Texture *tex, int priority = 0);
00082   void set_texture_off(int priority = 0);
00083   void set_texture_off(TextureStage *stage, int priority = 0);
00084 
00085   INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0,
00086                         int priority = 0);
00087   void set_color(const LColor &color, int priority = 0);
00088 
00089   INLINE void set_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0,
00090                               int priority = 0);
00091   void set_color_scale(const LVecBase4 &scale, int priority = 0);
00092 
00093   INLINE void compose_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0,
00094                                   int priority = 0);
00095   void compose_color_scale(const LVecBase4 &scale, int priority = 0);
00096 
00097   void set_attrib(const RenderAttrib *attrib, int priority = 0);
00098 
00099   void output(ostream &out) const;
00100   void write(ostream &out, int indent_level = 0) const;
00101 
00102 private:
00103   typedef PTA(NodePath) NodePaths;
00104   NodePaths _node_paths;
00105 
00106   // This typedef is used in set_attrib() and similar methods.
00107   typedef pmap<CPT(RenderState), CPT(RenderState) > StateMap;
00108 };
00109 
00110 INLINE ostream &operator << (ostream &out, const NodePathCollection &col) {
00111   col.output(out);
00112   return out;
00113 }
00114 
00115 #include "nodePathCollection.I"
00116 
00117 #endif
00118 
00119 
 All Classes Functions Variables Enumerations