NorMIT-nav  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_ */
cx::DoubleRange::DoubleRange
DoubleRange(double min, double max, double step)
Definition: cxDoubleRange.h:38
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::DoubleRange::mMin
double mMin
Definition: cxDoubleRange.h:42
cx::DoubleRange::mMax
double mMax
Definition: cxDoubleRange.h:43
cx::DoubleRange::mStep
double mStep
Definition: cxDoubleRange.h:44
cx::DoubleRange::constrainValue
double constrainValue(double val)
Definition: cxDoubleRange.h:68
cx::DoubleRange
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
cx::DoubleRange::DoubleRange
DoubleRange()
Definition: cxDoubleRange.h:34