src/miscallenous.h

Thu, 04 Jan 2018 19:44:26 +0200

author
Santeri Piippo
date
Thu, 04 Jan 2018 19:44:26 +0200
changeset 1217
314e12e23c3a
parent 1012
413ecd6b9801
child 1221
7f6715f08faf
permissions
-rw-r--r--

fix paren style

655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
968
4b93b7963456 Happy new year 2015
Teemu Piippo <crimsondusk64@gmail.com>
parents: 879
diff changeset
3 * Copyright (C) 2013 - 2015 Teemu Piippo
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #pragma once
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <QVector>
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
21 #include <functional>
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "main.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "basics.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 class LDDocument;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 class QColor;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 class QAction;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 // Simplifies the given fraction.
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
30 void Simplify(int& numer, int& denom);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
32 using ApplyToMatrixFunction = std::function<void(int, double&)>;
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
33 using ApplyToMatrixConstFunction = std::function<void(int, double)>;
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
34
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
35 void RoundToDecimals(double& a, int decimals);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
36 void ApplyToMatrix(Matrix& a, ApplyToMatrixFunction func);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
37 void ApplyToMatrix(const Matrix& a, ApplyToMatrixConstFunction func);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
39 double GetCoordinateOf(const Vertex& a, Axis ax);
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
40 QString MakePrettyFileSize(qint64 size);
859
ebc7a186699c - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
41
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
42 QString Join(QList<StringFormatArg> vals, QString delim = " ");
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 // Grid stuff
971
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
45 float gridCoordinateSnap();
c00f9665a9f8 Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
46 float gridAngleSnap();
1005
a88cf5a32246 Subject Bézier curve fineness to the grid. By default, the coarse grid uses 8 segments, medium 16 and fine 32. Moved rasterization from demoting to inlining, it feels more sensible for it to be there.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 971
diff changeset
47 float gridBezierCurveSegments();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 // =============================================================================
859
ebc7a186699c - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
50 enum class RotationPoint
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 {
859
ebc7a186699c - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
52 ObjectOrigin,
ebc7a186699c - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
53 WorldOrigin,
ebc7a186699c - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
54 CustomPoint,
ebc7a186699c - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
55 NumValues
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
58 Vertex GetRotationPoint(const LDObjectList& objs);
859
ebc7a186699c - refactor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 852
diff changeset
59 void ConfigureRotationPoint();
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 namespace Grid
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 enum Type
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 Coarse,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 Medium,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 Fine
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 enum Config
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 {
754
c37564d59ce1 - grids now have a single coordinate snap value instead of individual X, Y and Z values
Santeri Piippo <crimsondusk64@gmail.com>
parents: 733
diff changeset
73 Coordinate,
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 Angle
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 };
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 1012
diff changeset
77 double Snap(double value, const Grid::Config type);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 }

mercurial