mousetool.h

Go to the documentation of this file.
00001 /*  
00002  *      MouseTool.h - scriptable mouse CommandModes for MAX
00003  *
00004  *          Copyright (c) Autodesk, Inc, 1998.  John Wainwright.
00005  *
00006  */
00007 
00008 #pragma once
00009 
00010 #include "..\kernel\value.h"
00011 #include "..\..\mouseman.h"
00012 #include "..\..\point3.h"
00013 #include "..\..\cmdmode.h"
00014 #include "..\..\maxapi.h"
00015 
00016 // forward declarations
00017 class MouseTool;
00018 class MSPlugin;
00019 class ViewExp;
00020 class Matrix3;
00021 class HashTable;
00022 
00023 // tool context local indexes - MUST match order in Parser::tool_def()
00024 enum { cl_viewPoint, cl_worldPoint, cl_worldDist, cl_worldAngle, cl_gridPoint, cl_gridDist, cl_gridAngle, cl_nodeTM, cl_shift, cl_ctrl, cl_alt, cl_lbutton, cl_mbutton, cl_rbutton, };
00025 
00026 /* --------- MouseTool command mode & callback classes ------------- */
00027 
00028 class MouseToolCallBack : public MouseCallBack
00029 {
00030     public:
00031         MouseTool*  tool;
00032         IPoint2     last_mp;
00033         Point3      last_wp;
00034         Point3      last_cpp;
00035 
00036         MouseToolCallBack() {}
00037         int proc(HWND hwnd, int msg, int point, int flags, IPoint2 m);
00038         int mouse_proc(ViewExp *vpt, int msg, int point, int flags, IPoint2 m, Matrix3& mat, BOOL createMouseCallback = FALSE);
00039         void set_context_locals(ViewExp* vpx, int snap, int point, int flag, IPoint2 mp, Point3 cpp, Matrix3& mat);
00040         void reset_context_locals();
00041 };
00042 
00043 #define MOUSE_TOOL_COMMAND  7364
00044 #define CID_MOUSE_TOOL      CID_USER + 45237
00045 
00046 class MouseToolCommandMode : public CommandMode, public CommandModeChangedCallback 
00047 {
00048 public:
00049     MouseToolCallBack   proc;
00050     BOOL                active;
00051     MCHAR*              prompt;
00052     int                 num_points;
00053     int                 cmd_class;
00054 
00055     int Class() { return cmd_class; }
00056     int ID() { return CID_MOUSE_TOOL; }
00057     MouseCallBack *MouseProc(int *points) { *points = num_points; return &proc; }
00058     ChangeForegroundCallback *ChangeFGProc() { return NULL; }
00059     BOOL ChangeFG(CommandMode* oldMode) { UNUSED_PARAM(oldMode); return FALSE; }
00060     void EnterMode(); 
00061     void ExitMode();
00062     void ModeChanged(CommandMode *oldM, CommandMode *newM);
00063 };
00064 
00065 /* ------------- MouseTool MAXScript value class -------------- */
00066 
00067 visible_class (MouseTool)
00068 
00069 class MouseTool : public Value
00070 {
00071 public:
00072     Value*      name;                       // tool name
00073     HashTable*  local_scope;                // local name space 
00074     Value**     locals;                     // local var array  
00075     Value**     local_inits;                //   "    "    "  init vals 
00076     int         local_count;                //   "    "  count  
00077     HashTable*  handlers;                   // handler tables   
00078     short       flags;                      // tool flags
00079     int         cmd_class;                  // command mode class
00080     int         num_points;                 // number of points
00081     Value*      prompt;                     // staus line prompt if non-null
00082     BOOL        init_values;                // whether to init ctrl/local values on (re)open 
00083     BOOL        end_tool_mode;              // signals end of tool cmd mode
00084     MouseToolCommandMode cmdmode;           // my command mode
00085     // command mode locals...
00086     Value*      result;                     // tool result
00087     Value*      snap_mode;                  // #2D or #3D or #none
00088     MSPlugin*   plugin;                     // current plugin under manip if non-NULL
00089 
00090                 MouseTool(short iflags);
00091     void        init(Value* name, int local_count, Value** inits, HashTable* local_scope, HashTable* handlers);
00092                ~MouseTool();
00093 
00094 #   define      is_mousetool(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MouseTool))
00095                 classof_methods (MouseTool, Value);
00096     void        collect() { delete this; }
00097     void        gc_trace();
00098     ScripterExport void sprin1(CharStream* s);
00099 
00100     BOOL        call_event_handler(Value* handler, Value** arg_list, int count, BOOL enable_redraw = TRUE);
00101     void        init_locals();
00102 
00103     virtual Value*  get_property(Value** arg_list, int count);
00104     virtual Value*  set_property(Value** arg_list, int count);
00105 
00106     // added 3/21/05. Used by debugger to dump locals and externals to standard out
00107     void        dump_local_vars_and_externals(int indentLevel);
00108 };
00109