00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * ramin 00008 * Side Effects Software Inc. 00009 * 20 Maud St. 00010 * Toronto, Ontario, M5V 2M5 00011 * Canada 00012 * 416-366-4607 00013 * 00014 * NAME: PRM_Range.h (Parameter Library) 00015 * 00016 * COMMENTS: 00017 * This parameter is used to set upper and lower limits on 00018 * parameters. For simplicity only floating point numbers are 00019 * used. These limits are not actually enforced by the parmeter 00020 * library. But maybe they should. Discuss. 00021 */ 00022 00023 00024 #ifndef __PRM_RANGE__ 00025 #define __PRM_RANGE__ 00026 00027 #include "PRM_API.h" 00028 #include <SYS/SYS_Math.h> 00029 #include <SYS/SYS_Types.h> 00030 00031 enum PRM_RangeFlag 00032 { 00033 PRM_RANGE_FREE = 0x0, // ie range is ignored. 00034 PRM_RANGE_UI = 0x1, // For some UI (sliders, etc) only 00035 PRM_RANGE_PRM = 0x2, // Strictly enforced by PRM, too 00036 PRM_RANGE_RESTRICTED= (PRM_RANGE_UI | PRM_RANGE_PRM) // both UI and PRM 00037 }; 00038 00039 class PRM_API PRM_Range 00040 { 00041 public: 00042 PRM_Range(PRM_RangeFlag theminflag = PRM_RANGE_UI, fpreal themin = 0, 00043 PRM_RangeFlag themaxflag = PRM_RANGE_UI, fpreal themax = 1) 00044 { 00045 myMinFlag = theminflag; 00046 myMin = themin; 00047 myMaxFlag = themaxflag; 00048 myMax = themax; 00049 } 00050 00051 bool hasParmMin() const 00052 { 00053 return ((myMinFlag & PRM_RANGE_PRM) != 0); 00054 } 00055 bool hasParmMax() const 00056 { 00057 return ((myMaxFlag & PRM_RANGE_PRM) != 0); 00058 } 00059 00060 fpreal getParmMin() const 00061 { 00062 if (myMinFlag != PRM_RANGE_FREE) 00063 return myMin; 00064 return -SYS_FPREAL_MAX; 00065 } 00066 fpreal getParmMax() const 00067 { 00068 if (myMaxFlag != PRM_RANGE_FREE) 00069 return myMax; 00070 return SYS_FPREAL_MAX; 00071 } 00072 00073 bool hasUIMin() const 00074 { 00075 return ((myMinFlag & PRM_RANGE_UI) != 0); 00076 } 00077 bool hasUIMax() const 00078 { 00079 return ((myMaxFlag & PRM_RANGE_UI) != 0); 00080 } 00081 00082 fpreal getUIMin() const { return getParmMin(); } 00083 fpreal getUIMax() const { return getParmMax(); } 00084 00085 private: 00086 PRM_RangeFlag myMinFlag; 00087 PRM_RangeFlag myMaxFlag; 00088 fpreal myMin; 00089 fpreal myMax; 00090 }; 00091 00092 #endif
1.5.9