HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PRM_Range.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: PRM_Range.h (Parameter Library)
7  *
8  * COMMENTS:
9  * This parameter is used to set upper and lower limits on
10  * parameters. For simplicity only floating point numbers are
11  * used. These limits are not actually enforced by the parmeter
12  * library. But maybe they should. Discuss.
13  */
14 
15 
16 #ifndef __PRM_RANGE__
17 #define __PRM_RANGE__
18 
19 #include "PRM_API.h"
20 #include <SYS/SYS_Math.h>
21 #include <SYS/SYS_Types.h>
22 
24 {
25  PRM_RANGE_FREE = 0x0, // ie range is ignored.
26  PRM_RANGE_UI = 0x1, // For some UI (sliders, etc) only
27  PRM_RANGE_PRM = 0x2, // Strictly enforced by PRM, too
29 };
30 
32 {
33 public:
34  PRM_Range(PRM_RangeFlag theminflag = PRM_RANGE_UI, fpreal themin = 0,
35  PRM_RangeFlag themaxflag = PRM_RANGE_UI, fpreal themax = 1)
36  {
37  myMinFlag = theminflag;
38  myMin = themin;
39  myMaxFlag = themaxflag;
40  myMax = themax;
41  }
42 
43  bool hasParmMin() const
44  {
45  return ((myMinFlag & PRM_RANGE_PRM) != 0);
46  }
47  bool hasParmMax() const
48  {
49  return ((myMaxFlag & PRM_RANGE_PRM) != 0);
50  }
51 
53  {
54  if (myMinFlag != PRM_RANGE_FREE)
55  return myMin;
56  return -SYS_FPREAL_MAX;
57  }
59  {
60  if (myMaxFlag != PRM_RANGE_FREE)
61  return myMax;
62  return SYS_FPREAL_MAX;
63  }
64 
65  bool hasUIMin() const
66  {
67  return ((myMinFlag & PRM_RANGE_UI) != 0);
68  }
69  bool hasUIMax() const
70  {
71  return ((myMaxFlag & PRM_RANGE_UI) != 0);
72  }
73 
74  fpreal getUIMin() const { return getParmMin(); }
75  fpreal getUIMax() const { return getParmMax(); }
76 
77 private:
78  PRM_RangeFlag myMinFlag;
79  PRM_RangeFlag myMaxFlag;
80  fpreal myMin;
81  fpreal myMax;
82 };
83 
84 #endif
PRM_Range(PRM_RangeFlag theminflag=PRM_RANGE_UI, fpreal themin=0, PRM_RangeFlag themaxflag=PRM_RANGE_UI, fpreal themax=1)
Definition: PRM_Range.h:34
bool hasUIMax() const
Definition: PRM_Range.h:69
fpreal getParmMin() const
Definition: PRM_Range.h:52
fpreal getParmMax() const
Definition: PRM_Range.h:58
bool hasParmMax() const
Definition: PRM_Range.h:47
PRM_RangeFlag
Definition: PRM_Range.h:23
fpreal getUIMin() const
Definition: PRM_Range.h:74
fpreal getUIMax() const
Definition: PRM_Range.h:75
#define SYS_FPREAL_MAX
Definition: SYS_Types.h:272
double fpreal
Definition: SYS_Types.h:263
#define PRM_API
Definition: PRM_API.h:10
bool hasParmMin() const
Definition: PRM_Range.h:43
bool hasUIMin() const
Definition: PRM_Range.h:65