src/basics.h

changeset 1217
314e12e23c3a
parent 1010
969b48eddd6b
child 1218
e0b59d183f96
--- a/src/basics.h	Thu Jan 04 19:40:52 2018 +0200
+++ b/src/basics.h	Thu Jan 04 19:44:26 2018 +0200
@@ -57,33 +57,33 @@
 class Vertex : public QVector3D
 {
 public:
-	using ApplyFunction = std::function<void (Axis, double&)>;
-	using ApplyConstFunction = std::function<void (Axis, double)>;
+	using ApplyFunction = std::function<void(Axis, double&)>;
+	using ApplyConstFunction = std::function<void(Axis, double)>;
 
 	Vertex();
-	Vertex (const QVector3D& a);
-	Vertex (qreal xpos, qreal ypos, qreal zpos);
+	Vertex(const QVector3D& a);
+	Vertex(qreal xpos, qreal ypos, qreal zpos);
 
-	void	apply (ApplyFunction func);
-	void	apply (ApplyConstFunction func) const;
-	QString	toString (bool mangled = false) const;
-	void	transform (const Matrix& matr, const Vertex& pos);
-	void	setCoordinate (Axis ax, qreal value);
+	void	apply(ApplyFunction func);
+	void	apply(ApplyConstFunction func) const;
+	QString	toString(bool mangled = false) const;
+	void	transform(const Matrix& matr, const Vertex& pos);
+	void	setCoordinate(Axis ax, qreal value);
 
 	Vertex&	operator+= (const Vertex& other);
-	Vertex	operator+ (const Vertex& other) const;
+	Vertex	operator+(const Vertex& other) const;
 	Vertex&	operator*= (qreal scalar);
-	Vertex	operator* (qreal scalar) const;
-	bool	operator< (const Vertex& other) const;
-	double	operator[] (Axis ax) const;
+	Vertex	operator*(qreal scalar) const;
+	bool	operator<(const Vertex& other) const;
+	double	operator[](Axis ax) const;
 };
 
-inline Vertex operator* (qreal scalar, const Vertex& vertex)
+inline Vertex operator*(qreal scalar, const Vertex& vertex)
 {
 	return vertex * scalar;
 }
 
-Q_DECLARE_METATYPE (Vertex)
+Q_DECLARE_METATYPE(Vertex)
 
 //
 // A mathematical 3 x 3 matrix
@@ -92,21 +92,21 @@
 {
 public:
 	Matrix() {}
-	Matrix (const std::initializer_list<double>& vals);
+	Matrix(const std::initializer_list<double>& vals);
 
 	// Constructs a matrix all 9 elements initialized to the same value.
-	Matrix (double fillval);
+	Matrix(double fillval);
 
 	// Constructs a matrix with a C-array.
 	// note: @vals is expected to have exactly 9 elements.
-	Matrix (double vals[]);
+	Matrix(double vals[]);
 
 	// Calculates the matrix's determinant.
 	double			getDeterminant() const;
 
 	// Multiplies this matrix with @other
 	// note: a.mult(b) is not equivalent to b.mult(a)!
-	Matrix			mult (const Matrix& other) const;
+	Matrix			mult(const Matrix& other) const;
 
 	// Prints the matrix to stdout.
 	void			dump() const;
@@ -121,33 +121,33 @@
 	Matrix&			operator= (const Matrix& other);
 
 	// Returns a mutable reference to a value by @idx
-	inline double& value (int idx)
+	inline double& value(int idx)
 	{
 		return m_vals[idx];
 	}
 
 	// An overload of value() for const matrices.
-	inline const double& value (int idx) const
+	inline const double& value(int idx) const
 	{
 		return m_vals[idx];
 	}
 
 	// An operator overload for mult().
-	inline Matrix operator* (const Matrix& other) const
+	inline Matrix operator*(const Matrix& other) const
 	{
-		return mult (other);
+		return mult(other);
 	}
 
 	// An operator overload for value().
-	inline double& operator[] (int idx)
+	inline double& operator[](int idx)
 	{
-		return value (idx);
+		return value(idx);
 	}
 
 	// An operator overload for value() const.
-	inline const double& operator[] (int idx) const
+	inline const double& operator[](int idx) const
 	{
-		return value (idx);
+		return value(idx);
 	}
 
 	// Checks whether the two matrices have the same values.
@@ -166,8 +166,8 @@
 public:
 	LDBoundingBox();
 
-	void calcObject (LDObject* obj);
-	void calcVertex (const Vertex& vertex);
+	void calcObject(LDObject* obj);
+	void calcVertex(const Vertex& vertex);
 	Vertex center() const;
 	bool isEmpty() const;
 	double longestMeasurement() const;
@@ -175,8 +175,8 @@
 	const Vertex& vertex0() const;
 	const Vertex& vertex1() const;
 
-	LDBoundingBox& operator<< (LDObject* obj);
-	LDBoundingBox& operator<< (const Vertex& v);
+	LDBoundingBox& operator<<(LDObject* obj);
+	LDBoundingBox& operator<<(const Vertex& v);
 
 private:
 	bool m_isEmpty;
@@ -193,44 +193,44 @@
 // =============================================================================
 // Plural expression
 template<typename T>
-static inline const char* plural (T n)
+static inline const char* plural(T n)
 {
 	return (n != 1) ? "s" : "";
 }
 
 template<typename T>
-bool isZero (T a)
+bool isZero(T a)
 {
-	return qFuzzyCompare (a + 1.0, 1.0);
+	return qFuzzyCompare(a + 1.0, 1.0);
 }
 
 template<typename T>
-bool isInteger (T a)
+bool isInteger(T a)
 {
-	return (qAbs (a - floor(a)) < 0.00001) or (qAbs (a - ceil(a)) < 0.00001);
+	return (qAbs(a - floor(a)) < 0.00001) or(qAbs(a - ceil(a)) < 0.00001);
 }
 
 template<typename T>
-void removeDuplicates (T& a)
+void removeDuplicates(T& a)
 {
-	std::sort (a.begin(), a.end());
-	a.erase (std::unique (a.begin(), a.end()), a.end());
+	std::sort(a.begin(), a.end());
+	a.erase(std::unique(a.begin(), a.end()), a.end());
 }
 
 //
 // Returns true if first arg is equal to any of the other args
 //
 template<typename T, typename Arg, typename... Args>
-bool isOneOf (T const& a, Arg const& arg, Args const&... args)
+bool isOneOf(T const& a, Arg const& arg, Args const&... args)
 {
 	if (a == arg)
 		return true;
 
-	return isOneOf (a, args...);
+	return isOneOf(a, args...);
 }
 
 template<typename T>
-bool isOneOf (T const&)
+bool isOneOf(T const&)
 {
 	return false;
 }

mercurial