Mon, 18 Mar 2013 12:15:23 +0200
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
0 | 1 | #include <QtGui> |
2 | ||
3 | #include "common.h" | |
4 | #include "draw.h" | |
5 | #include "gui.h" | |
6 | #include "io.h" | |
7 | ||
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
8 | #include "zz_setContentsDialog.h" |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
9 | |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
10 | ForgeWindow::ForgeWindow () { |
0 | 11 | R = new renderer; |
12 | ||
13 | qObjList = new QTreeWidget; | |
14 | qObjList->setHeaderHidden (true); | |
15 | qObjList->setMaximumWidth (256); | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
16 | qObjList->setSelectionMode (QTreeWidget::MultiSelection); |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
17 | connect (qObjList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ())); |
0 | 18 | |
19 | qMessageLog = new QTextEdit; | |
20 | qMessageLog->setReadOnly (true); | |
21 | qMessageLog->setMaximumHeight (96); | |
22 | ||
23 | QWidget* w = new QWidget; | |
24 | QGridLayout* layout = new QGridLayout; | |
25 | layout->setColumnMinimumWidth (0, 192); | |
26 | layout->setColumnStretch (0, 1); | |
27 | layout->addWidget (R, 0, 0); | |
28 | layout->addWidget (qObjList, 0, 1); | |
29 | layout->addWidget (qMessageLog, 1, 0, 1, 2); | |
30 | w->setLayout (layout); | |
31 | setCentralWidget (w); | |
32 | ||
33 | createMenuActions (); | |
34 | createMenus (); | |
35 | createToolbars (); | |
36 | ||
22
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
37 | slot_selectionChanged (); |
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
38 | |
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
39 | setTitle (); |
0 | 40 | setMinimumSize (320, 200); |
41 | resize (800, 600); | |
42 | } | |
43 | ||
44 | #define MAKE_ACTION(OBJECT, DISPLAYNAME, IMAGENAME, DESCR) \ | |
45 | qAct_##OBJECT = new QAction (QIcon ("./icons/" IMAGENAME ".png"), tr (DISPLAYNAME), this); \ | |
46 | qAct_##OBJECT->setStatusTip (tr (DESCR)); \ | |
47 | connect (qAct_##OBJECT, SIGNAL (triggered ()), this, SLOT (slot_##OBJECT ())); | |
48 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
49 | void ForgeWindow::createMenuActions () { |
0 | 50 | // Long menu names go here so my cool action definition table doesn't get out of proportions |
51 | const char* sNewCdLineText = "New Conditional Line", | |
52 | *sNewQuadText = "New Quadrilateral", | |
53 | *sAboutText = "About " APPNAME_DISPLAY; | |
54 | ||
55 | MAKE_ACTION (new, "&New", "file-new", "Create a new part model.") | |
5
727e02d6b87a
rename file-specific icons to file-*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
56 | MAKE_ACTION (open, "&Open", "file-open", "Load a part model from a file.") |
727e02d6b87a
rename file-specific icons to file-*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
57 | MAKE_ACTION (save, "&Save", "file-save", "Save the part model.") |
727e02d6b87a
rename file-specific icons to file-*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
58 | MAKE_ACTION (saveAs, "Save &As", "file-save-as", "Save the part to a specific file.") |
0 | 59 | MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".") |
60 | ||
61 | MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.") | |
62 | MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.") | |
63 | MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.") | |
64 | MAKE_ACTION (about, sAboutText, "about", "Shows information about " APPNAME_DISPLAY ".") | |
65 | MAKE_ACTION (aboutQt, "About Qt", "aboutQt", "Shows information about Qt.") | |
66 | ||
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
67 | MAKE_ACTION (inline, "Inline", "inline", "Inline selected subfiles.") |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
68 | MAKE_ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.") |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
69 | MAKE_ACTION (setContents, "Set Contents", "set-contents", "Set the raw code of this object.") |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
70 | |
0 | 71 | MAKE_ACTION (newSubfile, "New Subfile", "add-subfile", "Creates a new subfile reference.") |
72 | MAKE_ACTION (newLine, "New Line", "add-line", "Creates a new line.") | |
73 | MAKE_ACTION (newTriangle, "New Triangle", "add-triangle", "Creates a new triangle.") | |
74 | MAKE_ACTION (newQuad, sNewQuadText, "add-quad", "Creates a new quadrilateral.") | |
75 | MAKE_ACTION (newCondLine, sNewCdLineText, "add-condline", "Creates a new conditional line."); | |
76 | MAKE_ACTION (newComment, "New Comment", "add-comment", "Creates a new comment."); | |
77 | MAKE_ACTION (newVector, "New Vector", "add-vector", "Creates a new vector.") | |
78 | MAKE_ACTION (newVertex, "New Vertex", "add-vertex", "Creates a new vertex.") | |
79 | ||
80 | // Keyboard shortcuts | |
81 | qAct_new->setShortcut (Qt::CTRL | Qt::Key_N); | |
82 | qAct_open->setShortcut (Qt::CTRL | Qt::Key_O); | |
83 | qAct_save->setShortcut (Qt::CTRL | Qt::Key_S); | |
84 | qAct_saveAs->setShortcut (Qt::CTRL | Qt::SHIFT | Qt::Key_S); | |
85 | ||
86 | qAct_cut->setShortcut (Qt::CTRL | Qt::Key_X); | |
87 | qAct_copy->setShortcut (Qt::CTRL | Qt::Key_C); | |
88 | qAct_paste->setShortcut (Qt::CTRL | Qt::Key_V); | |
89 | ||
90 | // things not implemented yet | |
91 | QAction* qaDisabledActions[] = { | |
92 | qAct_saveAs, | |
93 | qAct_newSubfile, | |
94 | qAct_newTriangle, | |
95 | qAct_newQuad, | |
96 | qAct_newCondLine, | |
97 | qAct_newComment, | |
98 | qAct_newVector, | |
99 | qAct_newVertex, | |
100 | qAct_cut, | |
101 | qAct_copy, | |
102 | qAct_paste, | |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
103 | qAct_about, |
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
104 | qAct_inline, |
0 | 105 | }; |
106 | ||
107 | for (ushort i = 0; i < sizeof qaDisabledActions / sizeof *qaDisabledActions; ++i) | |
108 | qaDisabledActions[i]->setEnabled (false); | |
109 | } | |
110 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
111 | void ForgeWindow::createMenus () { |
0 | 112 | // File menu |
113 | qFileMenu = menuBar ()->addMenu (tr ("&File")); | |
114 | qFileMenu->addAction (qAct_new); // New | |
115 | qFileMenu->addAction (qAct_open); // Open | |
116 | qFileMenu->addAction (qAct_save); // Save | |
117 | qFileMenu->addAction (qAct_saveAs); // Save As | |
118 | qFileMenu->addSeparator (); // ------- | |
119 | qFileMenu->addAction (qAct_exit); // Exit | |
120 | ||
121 | // Edit menu | |
122 | qInsertMenu = menuBar ()->addMenu (tr ("&Insert")); | |
123 | qInsertMenu->addAction (qAct_newSubfile); // New Subfile | |
124 | qInsertMenu->addAction (qAct_newLine); // New Line | |
125 | qInsertMenu->addAction (qAct_newTriangle); // New Triangle | |
126 | qInsertMenu->addAction (qAct_newQuad); // New Quad | |
127 | qInsertMenu->addAction (qAct_newCondLine); // New Conditional Line | |
128 | qInsertMenu->addAction (qAct_newComment); // New Comment | |
129 | qInsertMenu->addAction (qAct_newVector); // New Vector | |
130 | qInsertMenu->addAction (qAct_newVertex); // New Vertex | |
131 | ||
132 | qEditMenu = menuBar ()->addMenu (tr ("&Edit")); | |
133 | qEditMenu->addAction (qAct_cut); // Cut | |
134 | qEditMenu->addAction (qAct_copy); // Copy | |
135 | qEditMenu->addAction (qAct_paste); // Paste | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
136 | qEditMenu->addSeparator (); // ----- |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
137 | qEditMenu->addAction (qAct_inline); // Inline |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
138 | qEditMenu->addAction (qAct_splitQuads); // Split Quads |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
139 | qEditMenu->addAction (qAct_setContents); // Set Contents |
0 | 140 | |
141 | // Help menu | |
142 | qHelpMenu = menuBar ()->addMenu (tr ("&Help")); | |
143 | qHelpMenu->addAction (qAct_about); // About | |
144 | qHelpMenu->addAction (qAct_aboutQt); // About Qt | |
145 | } | |
146 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
147 | void ForgeWindow::createToolbars () { |
0 | 148 | qFileToolBar = new QToolBar ("File"); |
149 | qFileToolBar->addAction (qAct_new); | |
150 | qFileToolBar->addAction (qAct_open); | |
151 | qFileToolBar->addAction (qAct_save); | |
152 | qFileToolBar->addAction (qAct_saveAs); | |
153 | addToolBar (qFileToolBar); | |
154 | ||
155 | qInsertToolBar = new QToolBar ("Insert"); | |
156 | qInsertToolBar->addAction (qAct_newSubfile); | |
157 | qInsertToolBar->addAction (qAct_newLine); | |
158 | qInsertToolBar->addAction (qAct_newTriangle); | |
159 | qInsertToolBar->addAction (qAct_newQuad); | |
160 | qInsertToolBar->addAction (qAct_newCondLine); | |
161 | qInsertToolBar->addAction (qAct_newComment); | |
162 | qInsertToolBar->addAction (qAct_newVector); | |
163 | qInsertToolBar->addAction (qAct_newVertex); | |
164 | addToolBar (qInsertToolBar); | |
165 | ||
166 | qEditToolBar = new QToolBar ("Edit"); | |
167 | qEditToolBar->addAction (qAct_cut); | |
168 | qEditToolBar->addAction (qAct_copy); | |
169 | qEditToolBar->addAction (qAct_paste); | |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
170 | qEditToolBar->addAction (qAct_inline); |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
171 | qEditToolBar->addAction (qAct_splitQuads); |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
172 | qEditToolBar->addAction (qAct_setContents); |
0 | 173 | addToolBar (qEditToolBar); |
174 | } | |
175 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
176 | void ForgeWindow::setTitle () { |
7
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
177 | str zTitle = APPNAME_DISPLAY " v" VERSION_STRING; |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
178 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
179 | // Append our current file if we have one |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
180 | if (g_CurrentFile) { |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
181 | zTitle.appendformat (": %s", basename (g_CurrentFile->zFileName.chars())); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
182 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
183 | if (g_CurrentFile->objects.size() > 0 && |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
184 | g_CurrentFile->objects[0]->getType() == OBJ_Comment) |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
185 | { |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
186 | // Append title |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
187 | LDComment* comm = static_cast<LDComment*> (g_CurrentFile->objects[0]); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
188 | zTitle.appendformat (":%s", comm->zText.chars()); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
189 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
190 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
191 | |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
192 | setWindowTitle (zTitle.chars()); |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
193 | } |
098e3c4949c6
Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
194 | |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
195 | void ForgeWindow::slot_new () { |
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
196 | newFile (); |
0 | 197 | } |
198 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
199 | void ForgeWindow::slot_open () { |
4
758302636564
improve opening, don't auto-load 55966.dat (:P)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
200 | str name = QFileDialog::getOpenFileName (this, "Open File", |
0 | 201 | "", "LDraw files (*.dat *.ldr)").toStdString().c_str(); |
202 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
203 | openMainFile (name); |
0 | 204 | } |
205 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
206 | void ForgeWindow::slot_save () { |
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
207 | g_CurrentFile->save (); |
0 | 208 | } |
209 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
210 | void ForgeWindow::slot_saveAs () { |
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
211 | |
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
212 | } |
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
213 | |
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
214 | void ForgeWindow::slot_exit () { |
0 | 215 | exit (0); |
216 | } | |
217 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
218 | void ForgeWindow::slot_newSubfile () { |
0 | 219 | |
220 | } | |
221 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
222 | void ForgeWindow::slot_newLine () { |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
223 | LDLine* line = new LDLine; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
224 | const ulong ulSpot = getInsertionPoint (); |
0 | 225 | |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
226 | memset (line->vaCoords, 0, sizeof line->vaCoords); |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
227 | line->dColor = 24; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
228 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
229 | g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + ulSpot, line); |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
230 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
231 | buildObjList (); |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
232 | R->hardRefresh (); |
0 | 233 | } |
234 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
235 | void ForgeWindow::slot_newTriangle () { |
0 | 236 | |
237 | } | |
238 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
239 | void ForgeWindow::slot_newQuad () { |
0 | 240 | |
241 | } | |
242 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
243 | void ForgeWindow::slot_newCondLine () { |
0 | 244 | |
245 | } | |
246 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
247 | void ForgeWindow::slot_newComment () { |
0 | 248 | |
249 | } | |
250 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
251 | void ForgeWindow::slot_about () { |
0 | 252 | |
253 | } | |
254 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
255 | void ForgeWindow::slot_aboutQt () { |
0 | 256 | QMessageBox::aboutQt (this); |
257 | } | |
258 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
259 | void ForgeWindow::slot_cut () { |
0 | 260 | |
261 | } | |
262 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
263 | void ForgeWindow::slot_copy () { |
0 | 264 | |
265 | } | |
266 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
267 | void ForgeWindow::slot_paste () { |
0 | 268 | |
269 | } | |
270 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
271 | void ForgeWindow::slot_newVector () { |
0 | 272 | |
273 | } | |
274 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
275 | void ForgeWindow::slot_newVertex () { |
0 | 276 | |
277 | } | |
278 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
279 | void ForgeWindow::slot_inline () { |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
280 | |
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
281 | } |
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
23
diff
changeset
|
282 | |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
283 | void ForgeWindow::slot_splitQuads () { |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
284 | if (qObjList->selectedItems().size() == 0) |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
285 | return; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
286 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
287 | const QList<QTreeWidgetItem*> qaItems = qObjList->selectedItems(); |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
288 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
289 | for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) { |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
290 | LDObject* obj = g_CurrentFile->objects[i]; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
291 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
292 | // Don't even consider non-quads |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
293 | if (obj->getType() != OBJ_Quad) |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
294 | continue; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
295 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
296 | bool bIsSelected = false; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
297 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
298 | for (long j = 0; j < qaItems.size(); ++j) { |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
299 | if (qaItems[j] == obj->qObjListEntry) { |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
300 | bIsSelected = true; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
301 | break; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
302 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
303 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
304 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
305 | if (!bIsSelected) |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
306 | continue; // Was not selected |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
307 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
308 | static_cast<LDQuad*> (obj)->splitToTriangles (); |
22
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
309 | i++;// Skip past the second triangle |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
310 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
311 | |
22
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
312 | printf ("build obj list\n"); |
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
313 | buildObjList (); |
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
314 | |
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
315 | printf ("refresh teh renderer\n"); |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
316 | R->hardRefresh (); |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
317 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
318 | |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
319 | void ForgeWindow::slot_setContents () { |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
320 | if (qObjList->selectedItems().size() != 1) |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
321 | return; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
322 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
323 | ulong ulIndex; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
324 | LDObject* obj = nullptr; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
325 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
326 | QTreeWidgetItem* item = qObjList->selectedItems()[0]; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
327 | for (ulIndex = 0; ulIndex < g_CurrentFile->objects.size(); ++ulIndex) { |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
328 | obj = g_CurrentFile->objects[ulIndex]; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
329 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
330 | if (obj->qObjListEntry == item) |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
331 | break; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
332 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
333 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
334 | if (ulIndex >= g_CurrentFile->objects.size()) |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
335 | return; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
336 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
337 | Dialog_SetContents::staticDialog (obj, this); |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
338 | } |
0 | 339 | |
340 | static QIcon IconForObjectType (LDObject* obj) { | |
341 | switch (obj->getType ()) { | |
342 | case OBJ_Empty: | |
343 | return QIcon ("icons/empty.png"); | |
344 | ||
345 | case OBJ_Line: | |
346 | return QIcon ("icons/line.png"); | |
347 | ||
348 | case OBJ_Quad: | |
349 | return QIcon ("icons/quad.png"); | |
350 | ||
351 | case OBJ_Subfile: | |
352 | return QIcon ("icons/subfile.png"); | |
353 | ||
354 | case OBJ_Triangle: | |
355 | return QIcon ("icons/triangle.png"); | |
356 | ||
357 | case OBJ_CondLine: | |
358 | return QIcon ("icons/condline.png"); | |
359 | ||
360 | case OBJ_Comment: | |
361 | return QIcon ("icons/comment.png"); | |
362 | ||
363 | case OBJ_Vector: | |
364 | return QIcon ("icons/vector.png"); | |
365 | ||
366 | case OBJ_Vertex: | |
367 | return QIcon ("icons/vertex.png"); | |
368 | ||
369 | case OBJ_Gibberish: | |
370 | case OBJ_Unidentified: | |
371 | return QIcon ("icons/error.png"); | |
372 | } | |
373 | ||
374 | return QIcon (); | |
375 | } | |
376 | ||
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
377 | void ForgeWindow::buildObjList () { |
3
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
378 | if (!g_CurrentFile) |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
379 | return; |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
380 | |
0 | 381 | QList<QTreeWidgetItem*> qaItems; |
3
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
382 | |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
383 | qObjList->clear (); |
2b78cf8634c3
don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
384 | |
22
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
385 | for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) { |
0 | 386 | LDObject* obj = g_CurrentFile->objects[i]; |
387 | ||
388 | str zText; | |
389 | switch (obj->getType ()) { | |
390 | case OBJ_Comment: | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
391 | zText = static_cast<LDComment*> (obj)->zText.chars(); |
10
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
392 | |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
393 | // Remove leading whitespace |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
394 | while (~zText && zText[0] == ' ') |
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
395 | zText -= -1; |
0 | 396 | break; |
397 | ||
398 | case OBJ_Empty: | |
399 | break; // leave it empty | |
400 | ||
401 | case OBJ_Line: | |
402 | case OBJ_CondLine: | |
403 | { | |
404 | LDLine* line = static_cast<LDLine*> (obj); | |
405 | zText.format ("%s, %s", | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
406 | line->vaCoords[0].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
407 | line->vaCoords[1].getStringRep (true).chars()); |
0 | 408 | } |
409 | break; | |
410 | ||
411 | case OBJ_Triangle: | |
412 | { | |
413 | LDTriangle* triangle = static_cast<LDTriangle*> (obj); | |
414 | zText.format ("%s, %s, %s", | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
415 | triangle->vaCoords[0].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
416 | triangle->vaCoords[1].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
417 | triangle->vaCoords[2].getStringRep (true).chars()); |
0 | 418 | } |
419 | break; | |
420 | ||
421 | case OBJ_Quad: | |
422 | { | |
423 | LDQuad* quad = static_cast<LDQuad*> (obj); | |
10
5b0579997e9b
remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
424 | zText.format ("%s, %s, %s, %s", |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
425 | quad->vaCoords[0].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
426 | quad->vaCoords[1].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
427 | quad->vaCoords[2].getStringRep (true).chars(), |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
428 | quad->vaCoords[3].getStringRep (true).chars()); |
0 | 429 | } |
430 | break; | |
431 | ||
432 | case OBJ_Gibberish: | |
433 | zText.format ("ERROR: %s", | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
434 | static_cast<LDGibberish*> (obj)->zContents.chars()); |
0 | 435 | break; |
436 | ||
437 | case OBJ_Vector: | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
438 | zText.format ("%s", static_cast<LDVector*> (obj)->vPos.getStringRep(true).chars()); |
0 | 439 | break; |
440 | ||
441 | case OBJ_Vertex: | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
442 | zText.format ("%s", static_cast<LDVertex*> (obj)->vPosition.getStringRep(true).chars()); |
0 | 443 | break; |
444 | ||
445 | default: | |
446 | zText = g_saObjTypeNames[obj->getType ()]; | |
447 | break; | |
448 | } | |
449 | ||
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
450 | QTreeWidgetItem* item = new QTreeWidgetItem ((QTreeWidget*) (nullptr), |
0 | 451 | QStringList (zText.chars()), 0); |
452 | item->setIcon (0, IconForObjectType (obj)); | |
453 | ||
11
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
454 | // Color gibberish red |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
455 | if (obj->getType() == OBJ_Gibberish) { |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
456 | item->setBackgroundColor (0, "#AA0000"); |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
457 | item->setForeground (0, QColor ("#FFAA00")); |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
458 | } |
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
459 | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
460 | obj->qObjListEntry = item; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
461 | |
0 | 462 | qaItems.append (item); |
463 | } | |
464 | ||
465 | qObjList->insertTopLevelItems (0, qaItems); | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
466 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
467 | |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
468 | void ForgeWindow::slot_selectionChanged () { |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
469 | // If the selection isn't 1 exact, disable setting contents |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
470 | qAct_setContents->setEnabled (qObjList->selectedItems().size() == 1); |
22
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
471 | |
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
472 | // If we have no selection, disable splitting quads |
335e430a6b4f
So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
473 | qAct_splitQuads->setEnabled (qObjList->selectedItems().size() > 0); |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
474 | } |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
475 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
476 | // ============================================================================= |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
477 | // ulong getInsertionPoint () |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
478 | // |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
479 | // Returns the index of where a new item should be placed at. |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
480 | // ============================================================================= |
25
c74bb88f537d
Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
481 | ulong ForgeWindow::getInsertionPoint () { |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
482 | ulong ulIndex; |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
483 | |
17
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
484 | if (qObjList->selectedItems().size() == 1) { |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
485 | // If we have a selection, put the item after it. |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
486 | for (ulIndex = 0; ulIndex < g_CurrentFile->objects.size(); ++ulIndex) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
487 | if (g_CurrentFile->objects[ulIndex]->qObjListEntry == qObjList->selectedItems()[0]) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
488 | break; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
489 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
490 | if (ulIndex >= g_CurrentFile->objects.size()) |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
491 | return ulIndex + 1; |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
492 | } |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
493 | |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
494 | // Otherwise place the object at the end. |
5606eebd0b90
Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
495 | return g_CurrentFile->objects.size(); |
0 | 496 | } |