mxstime.h

Go to the documentation of this file.
00001 /*      MSTime.h - the time family of classes for MAXScript
00002  *
00003  *      Copyright (c) John Wainwright, 1996
00004  *      
00005  *
00006  */
00007 
00008 #pragma once
00009 
00010 #include "..\kernel\value.h"
00011 #include "..\..\units.h"
00012 
00013 /* ------------------------ Time ------------------------------ */
00014 
00015 visible_class_debug_ok (MSTime)
00016 
00017 class MSTime : public Value
00018 {
00019 public:
00020     TimeValue   time;
00021 
00022     ENABLE_STACK_ALLOCATE(MSTime);
00023 
00024                 MSTime (TimeValue t);
00025     static ScripterExport Value* intern(TimeValue t);
00026 
00027 #   define      is_time(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MSTime))
00028                 classof_methods (MSTime, Value);
00029     void        collect() { delete this; }
00030     ScripterExport void sprin1(CharStream* s);
00031 
00032 #include "..\macros\define_implementations.h"
00033 #   include "..\protocols\time.inl"
00034     def_generic  ( coerce,  "coerce");
00035 
00036     def_property ( ticks );
00037     def_property ( frame );
00038     def_property ( normalized );
00039 
00040     TimeValue   to_timevalue() { return time; }
00041     float       to_float() { return (float)time / GetTicksPerFrame(); }
00042     double      to_double() { return static_cast<double>(time) / GetTicksPerFrame(); }
00043     int         to_int() { return (int)time / GetTicksPerFrame(); }
00044     INT64       to_int64() { return static_cast<INT64>(time / GetTicksPerFrame()); }
00045     INT_PTR     to_intptr() { return static_cast<INT_PTR>(time / GetTicksPerFrame()); }
00046     void        to_fpvalue(FPValue& v) { v.i = time; v.type = TYPE_TIMEVALUE; }
00047 
00048     Value*  widen_to(Value* arg, Value** arg_list);
00049     BOOL    comparable(Value* arg);
00050 
00051     // scene I/O 
00052     IOResult Save(ISave* isave);
00053     static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
00054 };
00055 
00056 /* ------------------------ Interval ------------------------------ */
00057 
00058 applyable_class_debug_ok (MSInterval)
00059 
00060 class MSInterval : public Value
00061 {
00062 public:
00063     Interval    interval;
00064 
00065     ENABLE_STACK_ALLOCATE(MSInterval);
00066 
00067 
00068                 MSInterval () {};
00069  ScripterExport MSInterval (Interval i);
00070  ScripterExport MSInterval (TimeValue s, TimeValue e);
00071 
00072 #   define      is_interval(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MSInterval))
00073                 classof_methods (MSInterval, Value);
00074     void        collect() { delete this; }
00075     ScripterExport void sprin1(CharStream* s);
00076 
00077 #include "..\macros\define_implementations.h"
00078     def_property ( start );
00079     def_property ( end );
00080 
00081     Interval    to_interval() { return interval; }
00082     ScripterExport void to_fpvalue(FPValue& v);
00083 
00084     // scene I/O 
00085     IOResult Save(ISave* isave);
00086     static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
00087 };
00088