objectsets.h

Go to the documentation of this file.
00001 /*  
00002  *      ObjectSets.h - ObjectSet classes for MAXScript
00003  *
00004  *          Copyright (c) John Wainwright 1996
00005  *
00006  */
00007 
00008 #pragma once
00009 
00010 #include "..\kernel\value.h"
00011 #include "..\foundation\collection.h"
00012 #include "..\foundation\streams.h"
00013 
00014 visible_class (Set)
00015 
00016 class Set : public Value, public Collection
00017 {
00018 public:
00019             classof_methods (Set, Value);
00020     BOOL    _is_collection() { return 1; }
00021 
00022 #include "..\macros\define_implementations.h"
00023     def_generic  (coerce,   "coerce"); 
00024 };
00025 
00026 visible_class_s (ObjectSet, Set)
00027 
00028 class ObjectSet : public Set
00029 {
00030 protected:
00031                 ObjectSet() { }
00032 public:
00033     MCHAR*      set_name;
00034     BOOL        (*selector)(INode* node, int level, void* arg); // set selector function
00035     void*       selector_arg;                                   // selector fn argument
00036 
00037                 ObjectSet(MCHAR* name, SClass_ID class_id);
00038                 ObjectSet(MCHAR* init_name, BOOL (*sel_fn)(INode*, int, void*), void* init_arg = NULL);
00039     void        init(MCHAR* name);
00040 
00041                 classof_methods (ObjectSet, Set);
00042     static void setup();
00043     MCHAR*      name() { return set_name; }
00044     void        collect() { delete this; }
00045     void        sprin1(CharStream* s) { s->printf(_M("$%s"), set_name); }
00046     void        export_to_scripter();
00047 #   define      is_objectset(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(ObjectSet))
00048 
00049     ScripterExport Value* map(node_map& m);
00050     ScripterExport Value* map_path(PathName* path, node_map& m);
00051     ScripterExport Value* find_first(BOOL (*test_fn)(INode* node, int level, void* arg), void* test_arg);
00052     ScripterExport Value* get_path(PathName* path);
00053 
00054 #include "..\macros\define_implementations.h"
00055     def_generic  (get,      "get");   // indexed get (no put or append)
00056     def_property ( count );
00057     def_property ( center );
00058     def_property ( min );
00059     def_property ( max );
00060 };
00061 
00062 class CurSelObjectSet : public ObjectSet
00063 {
00064 public:
00065                 CurSelObjectSet(MCHAR* name);
00066 
00067     void        collect() { delete this; }
00068 
00069     ScripterExport Value* map(node_map& m);
00070 
00071 #include "..\macros\define_implementations.h"
00072     def_generic  (get,      "get");   // indexed get (no put or append)
00073     def_generic  (coerce,   "coerce"); 
00074 
00075     def_property ( count );
00076 };
00077 
00078 extern ObjectSet all_objects;
00079 extern ObjectSet all_geometry;
00080 extern ObjectSet all_lights;
00081 extern ObjectSet all_cameras;
00082 extern ObjectSet all_helpers;
00083 extern ObjectSet all_shapes;
00084 extern ObjectSet all_systems;
00085 extern ObjectSet all_spacewarps;
00086 extern CurSelObjectSet current_selection;
00087