CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxDoubleRange.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
13 /*
14  * sscDoubleRange.h
15  *
16  * Created on: Jun 23, 2010
17  * Author: christiana
18  */
19 #ifndef CXDOUBLERANGE_H_
20 #define CXDOUBLERANGE_H_
21 
22 #include "cxResourceExport.h"
23 
24 namespace cx
25 {
26 
32 struct cxResource_EXPORT DoubleRange
33 {
35  mMin(0), mMax(1), mStep(0.1)
36  {
37  }
38  DoubleRange(double min, double max, double step) :
39  mMin(min), mMax(max), mStep(step)
40  {
41  }
42  double mMin;
43  double mMax;
44  double mStep;
45  double min() const
46  {
47  return mMin;
48  }
49  double max() const
50  {
51  return mMax;
52  }
53  double step() const
54  {
55  return mStep;
56  }
57  double resolution() const
58  {
59  return (mMax - mMin) / mStep;
60  }
61  double range() const
62  {
63  return mMax - mMin;
64  }
65 
68  double constrainValue(double val)
69  {
70  if (val <= mMin)
71  return mMin;
72  if (val >= mMax)
73  return mMax;
74  return val;
75  }
76 };
77 
78 }
79 #endif /* CXDOUBLERANGE_H_ */
double max() const
maximum value
Definition: cxDoubleRange.h:49
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
double resolution() const
number of steps in range (1 step means 1 resolution).
Definition: cxDoubleRange.h:57
double min() const
minimum value
Definition: cxDoubleRange.h:45
double constrainValue(double val)
Definition: cxDoubleRange.h:68
double step() const
smallest reasonable increment
Definition: cxDoubleRange.h:53
DoubleRange(double min, double max, double step)
Definition: cxDoubleRange.h:38
double range() const
max - min
Definition: cxDoubleRange.h:61
Namespace for all CustusX production code.