CustusX  2023.01.05-dev+develop.0da12
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_*/
Scalar * end()
Scalar * begin()
std::ostream & stream_range(std::ostream &s, ITER begin, ITER end, char separator=' ')
Definition: cxUtilHelpers.h:32
double constrainValue(double val, double min, double max)
int sign(double x)
QString changeExtension(QString name, QString ext)
void sleep_ms(int ms)
Namespace for all CustusX production code.