src/types.h

changeset 622
622c49e60348
parent 617
f5059d144438
child 667
31540c1f22ea
equal deleted inserted replaced
621:928365840d0d 622:622c49e60348
20 #define LDFORGE_TYPES_H 20 #define LDFORGE_TYPES_H
21 21
22 #include <QString> 22 #include <QString>
23 #include <QObject> 23 #include <QObject>
24 #include <QStringList> 24 #include <QStringList>
25 #include <deque> 25 #include <QMetaType>
26 #include "main.h" 26 #include "property.h"
27 27
28 class LDObject; 28 class LDObject;
29 class QFile; 29 class QFile;
30 class QTextStream; 30 class QTextStream;
31 31
72 Matrix (double vals[]); 72 Matrix (double vals[]);
73 73
74 double getDeterminant() const; 74 double getDeterminant() const;
75 Matrix mult (const Matrix& other) const; 75 Matrix mult (const Matrix& other) const;
76 void puts() const; 76 void puts() const;
77 QString stringRep() const; 77 QString toString() const;
78 void zero(); 78 void zero();
79 Matrix& operator= (const Matrix& other); 79 Matrix& operator= (const Matrix& other);
80 80
81 inline double& val (int idx) 81 inline double& val (int idx)
82 { 82 {
124 Vertex (double x, double y, double z); 124 Vertex (double x, double y, double z);
125 125
126 double distanceTo (const Vertex& other) const; 126 double distanceTo (const Vertex& other) const;
127 Vertex midpoint (const Vertex& other); 127 Vertex midpoint (const Vertex& other);
128 void move (const Vertex& other); 128 void move (const Vertex& other);
129 QString stringRep (bool mangled) const; 129 QString toString (bool mangled) const;
130 void transform (Matrix matr, Vertex pos); 130 void transform (const Matrix& matr, const Vertex& pos);
131 131
132 Vertex& operator+= (const Vertex& other); 132 Vertex& operator+= (const Vertex& other);
133 Vertex operator+ (const Vertex& other) const; 133 Vertex operator+ (const Vertex& other) const;
134 Vertex operator/ (const double d) const; 134 Vertex operator/ (const double d) const;
135 Vertex& operator/= (const double d); 135 Vertex& operator/= (const double d);
136 bool operator== (const Vertex& other) const; 136 bool operator== (const Vertex& other) const;
137 bool operator!= (const Vertex& other) const; 137 bool operator!= (const Vertex& other) const;
138 Vertex operator-() const; 138 Vertex operator-() const;
139 int operator< (const Vertex& other) const; 139 int operator< (const Vertex& other) const;
140 double& operator[] (const Axis ax); 140
141 const double& operator[] (const Axis ax) const; 141 inline double& operator[] (const Axis ax)
142 double& operator[] (const int ax); 142 {
143 const double& operator[] (const int ax) const; 143 return getCoordinate ((int) ax);
144 144 }
145 inline double& coord (int n) 145
146 inline const double& operator[] (const Axis ax) const
147 {
148 return getCoordinate ((int) ax);
149 }
150
151 inline double& operator[] (const int ax)
152 {
153 return getCoordinate (ax);
154 }
155
156 inline const double& operator[] (const int ax) const
157 {
158 return getCoordinate (ax);
159 }
160
161 inline double& getCoordinate (int n)
146 { 162 {
147 return m_coords[n]; 163 return m_coords[n];
148 } 164 }
149 165
150 inline const double& coord (int n) const 166 inline const double& getCoordinate (int n) const
151 { 167 {
152 return m_coords[n]; 168 return m_coords[n];
153 } 169 }
154 170
155 inline double& x() 171 inline double& x()
183 } 199 }
184 200
185 private: 201 private:
186 double m_coords[3]; 202 double m_coords[3];
187 }; 203 };
204
205 Q_DECLARE_METATYPE (Vertex)
188 206
189 // ============================================================================= 207 // =============================================================================
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
191 // ============================================================================= 209 // =============================================================================
192 // StringFormatArg 210 // StringFormatArg
202 StringFormatArg (const uchar& a) : m_val (a) {} 220 StringFormatArg (const uchar& a) : m_val (a) {}
203 StringFormatArg (const QChar& a) : m_val (a) {} 221 StringFormatArg (const QChar& a) : m_val (a) {}
204 StringFormatArg (int a) : m_val (QString::number (a)) {} 222 StringFormatArg (int a) : m_val (QString::number (a)) {}
205 StringFormatArg (const float& a) : m_val (QString::number (a)) {} 223 StringFormatArg (const float& a) : m_val (QString::number (a)) {}
206 StringFormatArg (const double& a) : m_val (QString::number (a)) {} 224 StringFormatArg (const double& a) : m_val (QString::number (a)) {}
207 StringFormatArg (const Vertex& a) : m_val (a.stringRep (false)) {} 225 StringFormatArg (const Vertex& a) : m_val (a.toString (false)) {}
208 StringFormatArg (const Matrix& a) : m_val (a.stringRep()) {} 226 StringFormatArg (const Matrix& a) : m_val (a.toString()) {}
209 StringFormatArg (const char* a) : m_val (a) {} 227 StringFormatArg (const char* a) : m_val (a) {}
210 228
211 StringFormatArg (const void* a) 229 StringFormatArg (const void* a)
212 { 230 {
213 m_val.sprintf ("%p", a); 231 m_val.sprintf ("%p", a);

mercurial