NorMIT-nav  22.09
An IGT application
cxUtilHelpers.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 #ifndef CXUTILHELPERS_H_
13 #define CXUTILHELPERS_H_
14 
15 #include "cxResourceExport.h"
16 
17 #include <sstream>
18 #include <iomanip>
19 #include <QString>
20 
21 namespace cx
22 {
23 
32 template<class ITER> std::ostream& stream_range(std::ostream& s, ITER begin, ITER end, char separator=' ')
33 {
34  if (begin==end)
35  return s;
36 
37  std::ostringstream ss; // avoid changing state of input stream
38  ss << std::setprecision(3) << std::fixed;
39 
40  ss << std::setw(10) << *begin;
41  ++begin;
42  for (; begin!=end; ++begin)
43  ss << separator << std::setw(10) << *begin;
44 
45  s << ss.str();
46 
47  return s;
48 }
49 // --------------------------------------------------------
50 
51 cxResource_EXPORT double constrainValue(double val, double min, double max);
52 cxResource_EXPORT int constrainValue(int val, int min, int max);
53 cxResource_EXPORT int sign(double x);
54 cxResource_EXPORT QString changeExtension(QString name, QString ext);
55 cxResource_EXPORT void sleep_ms(int ms);
56 
61 } // namespace cx
62 
63 #endif /*CXUTILHELPERS_H_*/
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
begin
Scalar * begin()
Definition: cxPlainObjectEigenAddons.h:22
cx::stream_range
std::ostream & stream_range(std::ostream &s, ITER begin, ITER end, char separator=' ')
Definition: cxUtilHelpers.h:32
cx::changeExtension
QString changeExtension(QString name, QString ext)
Definition: cxUtilHelpers.cpp:53
end
Scalar * end()
Definition: cxPlainObjectEigenAddons.h:32
cx::sleep_ms
void sleep_ms(int ms)
Definition: cxUtilHelpers.cpp:70
cx::constrainValue
double constrainValue(double val, double min, double max)
Definition: cxUtilHelpers.cpp:28
cx::sign
int sign(double x)
Definition: cxUtilHelpers.cpp:46