src/miscallenous.h

changeset 1013
fa025ba493d8
parent 1012
413ecd6b9801
child 1014
f0a8ecb6a357
equal deleted inserted replaced
1012:413ecd6b9801 1013:fa025ba493d8
24 24
25 class LDDocument; 25 class LDDocument;
26 class QColor; 26 class QColor;
27 class QAction; 27 class QAction;
28 28
29 // Simplifies the given fraction.
30 void Simplify (int& numer, int& denom);
31
32 using ApplyToMatrixFunction = std::function<void (int, double&)>; 29 using ApplyToMatrixFunction = std::function<void (int, double&)>;
33 using ApplyToMatrixConstFunction = std::function<void (int, double)>; 30 using ApplyToMatrixConstFunction = std::function<void (int, double)>;
34 31
35 void RoundToDecimals (double& a, int decimals);
36 void ApplyToMatrix (Matrix& a, ApplyToMatrixFunction func);
37 void ApplyToMatrix (const Matrix& a, ApplyToMatrixConstFunction func);
38
39 double GetCoordinateOf (const Vertex& a, Axis ax);
40 QString MakePrettyFileSize (qint64 size);
41
42 QString Join (QList<StringFormatArg> vals, QString delim = " ");
43
44 // Grid stuff
45 float gridCoordinateSnap();
46 float gridAngleSnap();
47 float gridBezierCurveSegments();
48
49 // =============================================================================
50 enum class RotationPoint 32 enum class RotationPoint
51 { 33 {
52 ObjectOrigin, 34 ObjectOrigin,
53 WorldOrigin, 35 WorldOrigin,
54 CustomPoint, 36 CustomPoint,
55 NumValues 37 NumValues
56 }; 38 };
57 39
58 Vertex GetRotationPoint (const LDObjectList& objs);
59 void ConfigureRotationPoint();
60
61 // =============================================================================
62 namespace Grid 40 namespace Grid
63 { 41 {
64 enum Type 42 enum Type
65 { 43 {
66 Coarse, 44 Coarse,
71 enum Config 49 enum Config
72 { 50 {
73 Coordinate, 51 Coordinate,
74 Angle 52 Angle
75 }; 53 };
54 }
76 55
77 double Snap (double value, const Grid::Config type); 56 void applyToMatrix (Matrix& a, ApplyToMatrixFunction func);
78 } 57 void applyToMatrix (const Matrix& a, ApplyToMatrixConstFunction func);
58 void configureRotationPoint();
59 QString formatFileSize (qint64 size);
60 int gcd (int a, int b);
61 Vertex getRotationPoint (const LDObjectList& objs);
62 float gridAngleSnap();
63 float gridBezierCurveSegments();
64 float gridCoordinateSnap();
65 QString joinStrings (QList<StringFormatArg> vals, QString delim = " ");
66 void roundToDecimals (double& a, int decimals);
67 void simplify (int& numer, int& denom);
68 double snapToGrid (double value, const Grid::Config type);

mercurial