src/miscallenous.cpp

changeset 1217
314e12e23c3a
parent 1215
77a0270352a3
child 1218
e0b59d183f96
--- a/src/miscallenous.cpp	Thu Jan 04 19:40:52 2018 +0200
+++ b/src/miscallenous.cpp	Thu Jan 04 19:44:26 2018 +0200
@@ -85,22 +85,22 @@
 //
 // Grid stuff
 //
-ConfigOption (int Grid = 1)
-ConfigOption (float GridCoarseCoordinateSnap = 5.0f)
-ConfigOption (float GridCoarseAngleSnap = 45.0f)
-ConfigOption (float GridCoarseBezierCurveSegments = 8)
-ConfigOption (float GridMediumCoordinateSnap = 1.0f)
-ConfigOption (float GridMediumAngleSnap = 22.5f)
-ConfigOption (float GridMediumBezierCurveSegments = 16)
-ConfigOption (float GridFineCoordinateSnap = 0.1f)
-ConfigOption (float GridFineAngleSnap = 7.5f)
-ConfigOption (float GridFineBezierCurveSegments = 32)
-ConfigOption (int RotationPointType = 0)
-ConfigOption (Vertex CustomRotationPoint = Origin)
+ConfigOption(int Grid = 1)
+ConfigOption(float GridCoarseCoordinateSnap = 5.0f)
+ConfigOption(float GridCoarseAngleSnap = 45.0f)
+ConfigOption(float GridCoarseBezierCurveSegments = 8)
+ConfigOption(float GridMediumCoordinateSnap = 1.0f)
+ConfigOption(float GridMediumAngleSnap = 22.5f)
+ConfigOption(float GridMediumBezierCurveSegments = 16)
+ConfigOption(float GridFineCoordinateSnap = 0.1f)
+ConfigOption(float GridFineAngleSnap = 7.5f)
+ConfigOption(float GridFineBezierCurveSegments = 32)
+ConfigOption(int RotationPointType = 0)
+ConfigOption(Vertex CustomRotationPoint = Origin)
 
 float gridCoordinateSnap()
 {
-	switch (config.grid())
+	switch(config.grid())
 	{
 	case Grid::Coarse: return config.gridCoarseCoordinateSnap();
 	case Grid::Medium: return config.gridMediumCoordinateSnap();
@@ -112,7 +112,7 @@
 
 float gridAngleSnap()
 {
-	switch (config.grid())
+	switch(config.grid())
 	{
 	case Grid::Coarse: return config.gridCoarseAngleSnap();
 	case Grid::Medium: return config.gridMediumAngleSnap();
@@ -124,7 +124,7 @@
 
 float gridBezierCurveSegments()
 {
-	switch (config.grid())
+	switch(config.grid())
 	{
 	default:
 	case Grid::Coarse: return config.gridCoarseBezierCurveSegments();
@@ -137,13 +137,13 @@
 //
 // Snap the given coordinate value on the current grid's given axis.
 //
-double Grid::Snap (double value, const Grid::Config type)
+double Grid::Snap(double value, const Grid::Config type)
 {
 	double snapvalue = (type == Coordinate) ? gridCoordinateSnap() : gridAngleSnap();
-	double mult = floor (qAbs<double> (value / snapvalue));
+	double mult = floor(qAbs<double>(value / snapvalue));
 	double out = mult * snapvalue;
 
-	if (qAbs (value) - (mult * snapvalue) > snapvalue / 2)
+	if (qAbs(value) -(mult * snapvalue) > snapvalue / 2)
 		out += snapvalue;
 
 	if (value < 0)
@@ -154,7 +154,7 @@
 
 // =============================================================================
 //
-void Simplify (int& numer, int& denom)
+void Simplify(int& numer, int& denom)
 {
 	bool repeat;
 
@@ -162,14 +162,14 @@
 	{
 		repeat = false;
 
-		for (int x = 0; x < countof (PrimeNumbers); x++)
+		for (int x = 0; x < countof(PrimeNumbers); x++)
 		{
 			int const prime = PrimeNumbers[x];
 
 			if (numer < prime and denom < prime)
 				break;
 
-			if ((numer % prime == 0) and (denom % prime == 0))
+			if ((numer % prime == 0) and(denom % prime == 0))
 			{
 				numer /= prime;
 				denom /= prime;
@@ -182,9 +182,9 @@
 
 // =============================================================================
 //
-Vertex GetRotationPoint (const LDObjectList& objs)
+Vertex GetRotationPoint(const LDObjectList& objs)
 {
-	switch (RotationPoint (config.rotationPointType()))
+	switch(RotationPoint(config.rotationPointType()))
 	{
 	case RotationPoint::ObjectOrigin:
 		{
@@ -194,7 +194,7 @@
 			for (LDObject* obj : objs)
 			{
 				if (obj->hasMatrix())
-					box << static_cast<LDMatrixObject*> (obj)->position();
+					box << static_cast<LDMatrixObject*>(obj)->position();
 				else
 					box << obj;
 			}
@@ -221,20 +221,20 @@
 {
 	QDialog* dlg = new QDialog;
 	Ui::RotPointUI ui;
-	ui.setupUi (dlg);
+	ui.setupUi(dlg);
 
-	switch (RotationPoint (config.rotationPointType()))
+	switch(RotationPoint(config.rotationPointType()))
 	{
 	case RotationPoint::ObjectOrigin:
-		ui.objectPoint->setChecked (true);
+		ui.objectPoint->setChecked(true);
 		break;
 
 	case RotationPoint::WorldOrigin:
-		ui.worldPoint->setChecked (true);
+		ui.worldPoint->setChecked(true);
 		break;
 
 	case RotationPoint::CustomPoint:
-		ui.customPoint->setChecked (true);
+		ui.customPoint->setChecked(true);
 		break;
 
 	case RotationPoint::NumValues:
@@ -242,39 +242,39 @@
 	}
 
 	Vertex custompoint = config.customRotationPoint();
-	ui.customX->setValue (custompoint.x());
-	ui.customY->setValue (custompoint.y());
-	ui.customZ->setValue (custompoint.z());
+	ui.customX->setValue(custompoint.x());
+	ui.customY->setValue(custompoint.y());
+	ui.customZ->setValue(custompoint.z());
 
 	if (not dlg->exec())
 		return;
 
-	config.setRotationPointType (int (
+	config.setRotationPointType(int(
 		(ui.objectPoint->isChecked()) ? RotationPoint::ObjectOrigin :
 		(ui.worldPoint->isChecked())  ? RotationPoint::WorldOrigin :
 		RotationPoint::CustomPoint));
 
-	custompoint.setX (ui.customX->value());
-	custompoint.setY (ui.customY->value());
-	custompoint.setZ (ui.customZ->value());
-	config.setCustomRotationPoint (custompoint);
+	custompoint.setX(ui.customX->value());
+	custompoint.setY(ui.customY->value());
+	custompoint.setZ(ui.customZ->value());
+	config.setCustomRotationPoint(custompoint);
 }
 
 // =============================================================================
 //
-QString Join (QList<StringFormatArg> vals, QString delim)
+QString Join(QList<StringFormatArg> vals, QString delim)
 {
 	QStringList list;
 
 	for (const StringFormatArg& arg : vals)
 		list << arg.text();
 
-	return list.join (delim);
+	return list.join(delim);
 }
 
 // =============================================================================
 //
-void RoundToDecimals (double& a, int decimals)
+void RoundToDecimals(double& a, int decimals)
 {
 	static const long e10[] =
 	{
@@ -290,31 +290,31 @@
 		1000000000l,
 	};
 
-	if (decimals >= 0 and decimals < countof (e10))
-		a = round (a * e10[decimals]) / e10[decimals];
+	if (decimals >= 0 and decimals < countof(e10))
+		a = round(a * e10[decimals]) / e10[decimals];
 }
 
 // =============================================================================
 //
-void ApplyToMatrix (Matrix& a, ApplyToMatrixFunction func)
+void ApplyToMatrix(Matrix& a, ApplyToMatrixFunction func)
 {
 	for (int i = 0; i < 9; ++i)
-		func (i, a[i]);
+		func(i, a[i]);
 }
 
 // =============================================================================
 //
-void ApplyToMatrix (const Matrix& a, ApplyToMatrixConstFunction func)
+void ApplyToMatrix(const Matrix& a, ApplyToMatrixConstFunction func)
 {
 	for (int i = 0; i < 9; ++i)
-		func (i, a[i]);
+		func(i, a[i]);
 }
 
 // =============================================================================
 //
-double GetCoordinateOf (const Vertex& a, Axis ax)
+double GetCoordinateOf(const Vertex& a, Axis ax)
 {
-	switch (ax)
+	switch(ax)
 	{
 		case X: return a.x();
 		case Y: return a.y();
@@ -327,14 +327,14 @@
 
 // =============================================================================
 //
-QString MakePrettyFileSize (qint64 size)
+QString MakePrettyFileSize(qint64 size)
 {
 	if (size < 1024LL)
-		return QString::number (size) + " bytes";
-	else if (size < (1024LL * 1024LL))
-		return QString::number (double (size) / 1024LL, 'f', 1) + " Kb";
-	else if (size < (1024LL * 1024LL * 1024LL))
-		return QString::number (double (size) / (1024LL * 1024LL), 'f', 1) + " Mb";
+		return QString::number(size) + " bytes";
+	else if (size <(1024LL * 1024LL))
+		return QString::number(double(size) / 1024LL, 'f', 1) + " Kb";
+	else if (size <(1024LL * 1024LL * 1024LL))
+		return QString::number(double(size) /(1024LL * 1024LL), 'f', 1) + " Mb";
 	else
-		return QString::number (double (size) / (1024LL * 1024LL * 1024LL), 'f', 1) + " Gb";
+		return QString::number(double(size) /(1024LL * 1024LL * 1024LL), 'f', 1) + " Gb";
 }

mercurial