Fri, 15 Mar 2013 22:27:38 +0200
remove leading whitespace from comments when drawing them in the list
0 | 1 | #include <QApplication> |
2 | #include "gui.h" | |
3 | #include "io.h" | |
4 | #include "bbox.h" | |
5 | ||
6 | vector<OpenFile*> g_LoadedFiles; | |
7 | OpenFile* g_CurrentFile = NULL; | |
8 | LDForgeWindow* g_qWindow = NULL; | |
9 | bbox g_BBox; | |
10 | ||
11 | int main (int argc, char** argv) { | |
3
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
12 | if (g_CurrentFile) { |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
13 | printf ("bbox: (%.3f, %.3f, %.3f), (%.3f, %.3f, %.3f)\n", |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
14 | FVERTEX (g_BBox.v0), FVERTEX (g_BBox.v1)); |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
15 | printf ("%u objects\n", g_CurrentFile->objects.size()); |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
16 | } |
0 | 17 | |
18 | QApplication app (argc, argv); | |
19 | LDForgeWindow* win = new LDForgeWindow; | |
20 | g_qWindow = win; | |
21 | win->show (); | |
22 | return app.exec (); | |
23 | } | |
24 | ||
25 | vertex vertex::midpoint (vertex& other) { | |
26 | vertex mid; | |
27 | mid.x = (x + other.x); | |
28 | mid.y = (y + other.y); | |
29 | mid.z = (z + other.z); | |
30 | return mid; | |
31 | } | |
32 | ||
33 | static str getCoordinateRep (double fCoord) { | |
34 | str zRep = str::mkfmt ("%.3f", fCoord); | |
35 | ||
36 | // Remove trailing zeroes | |
37 | while (zRep[~zRep - 1] == '0') | |
38 | zRep -= 1; | |
39 | ||
40 | // If there was only zeroes in the decimal place, remove | |
41 | // the decimal point now. | |
42 | if (zRep[~zRep - 1] == '.') | |
43 | zRep -= 1; | |
44 | ||
45 | return zRep; | |
46 | } | |
47 | ||
48 | str vertex::getStringRep () { | |
49 | return str::mkfmt ("(%s, %s, %s)", | |
50 | getCoordinateRep (x).chars(), | |
51 | getCoordinateRep (y).chars(), | |
52 | getCoordinateRep (z).chars()); | |
53 | } |