98 } |
98 } |
99 |
99 |
100 // ============================================================================= |
100 // ============================================================================= |
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
102 // ============================================================================= |
102 // ============================================================================= |
103 MAKE_ACTION (save, "&Save", "file-save", "Save the part model.", CTRL (S)) |
103 DEFINE_ACTION (Save, CTRL (S)) { |
104 { |
|
105 g_win->save (currentFile(), false); |
104 g_win->save (currentFile(), false); |
106 } |
105 } |
107 |
106 |
108 // ============================================================================= |
107 // ============================================================================= |
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
110 // ============================================================================= |
109 // ============================================================================= |
111 MAKE_ACTION (saveAs, "Save &As", "file-save-as", "Save the part model to a specific file.", CTRL_SHIFT (S)) |
110 DEFINE_ACTION (SaveAs, CTRL_SHIFT (S)) { |
112 { |
|
113 g_win->save (currentFile(), true); |
111 g_win->save (currentFile(), true); |
114 } |
112 } |
115 |
113 |
116 // ============================================================================= |
114 // ============================================================================= |
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
118 // ============================================================================= |
116 // ============================================================================= |
119 MAKE_ACTION (settings, "Settin&gs", "settings", "Edit the settings of " APPNAME ".", (0)) { |
117 DEFINE_ACTION (Settings, 0) { |
120 ConfigDialog::staticDialog(); |
118 ConfigDialog::staticDialog(); |
121 } |
119 } |
122 |
120 |
123 MAKE_ACTION (setLDrawPath, "Set LDraw Path", "settings", "Change the LDraw directory path.", (0)) { |
121 DEFINE_ACTION (SetLDrawPath, 0) { |
124 LDrawPathDialog dlg (true); |
122 LDrawPathDialog dlg (true); |
125 dlg.exec(); |
123 dlg.exec(); |
126 } |
124 } |
127 |
125 |
128 // ============================================================================= |
126 // ============================================================================= |
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
130 // ============================================================================= |
128 // ============================================================================= |
131 MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME ".", CTRL (Q)) { |
129 DEFINE_ACTION (Exit, CTRL (Q)) { |
132 exit (0); |
130 exit (0); |
133 } |
131 } |
134 |
132 |
135 // ============================================================================= |
133 // ============================================================================= |
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
137 // ============================================================================= |
135 // ============================================================================= |
138 MAKE_ACTION (newSubfile, "New Subfile", "add-subfile", "Creates a new subfile reference.", 0) { |
136 DEFINE_ACTION (NewSubfile, 0) { |
139 AddObjectDialog::staticDialog (LDObject::Subfile, null); |
137 AddObjectDialog::staticDialog (LDObject::Subfile, null); |
140 } |
138 } |
141 |
139 |
142 MAKE_ACTION (newLine, "New Line", "add-line", "Creates a new line.", 0) { |
140 DEFINE_ACTION (NewLine, 0) { |
143 AddObjectDialog::staticDialog (LDObject::Line, null); |
141 AddObjectDialog::staticDialog (LDObject::Line, null); |
144 } |
142 } |
145 |
143 |
146 MAKE_ACTION (newTriangle, "New Triangle", "add-triangle", "Creates a new triangle.", 0) { |
144 DEFINE_ACTION (NewTriangle, 0) { |
147 AddObjectDialog::staticDialog (LDObject::Triangle, null); |
145 AddObjectDialog::staticDialog (LDObject::Triangle, null); |
148 } |
146 } |
149 |
147 |
150 MAKE_ACTION (newQuad, "New Quadrilateral", "add-quad", "Creates a new quadrilateral.", 0) { |
148 DEFINE_ACTION (NewQuad, 0) { |
151 AddObjectDialog::staticDialog (LDObject::Quad, null); |
149 AddObjectDialog::staticDialog (LDObject::Quad, null); |
152 } |
150 } |
153 |
151 |
154 MAKE_ACTION (newCondLine, "New Conditional Line", "add-condline", "Creates a new conditional line.", 0) { |
152 DEFINE_ACTION (NewCLine, 0) { |
155 AddObjectDialog::staticDialog (LDObject::CondLine, null); |
153 AddObjectDialog::staticDialog (LDObject::CondLine, null); |
156 } |
154 } |
157 |
155 |
158 MAKE_ACTION (newComment, "New Comment", "add-comment", "Creates a new comment.", 0) { |
156 DEFINE_ACTION (NewComment, 0) { |
159 AddObjectDialog::staticDialog (LDObject::Comment, null); |
157 AddObjectDialog::staticDialog (LDObject::Comment, null); |
160 } |
158 } |
161 |
159 |
162 MAKE_ACTION (newBFC, "New BFC Statement", "add-bfc", "Creates a new BFC statement.", 0) { |
160 DEFINE_ACTION (NewBFC, 0) { |
163 AddObjectDialog::staticDialog (LDObject::BFC, null); |
161 AddObjectDialog::staticDialog (LDObject::BFC, null); |
164 } |
162 } |
165 |
163 |
166 MAKE_ACTION (newVertex, "New Vertex", "add-vertex", "Creates a new vertex.", 0) { |
164 DEFINE_ACTION (NewVertex, 0) { |
167 AddObjectDialog::staticDialog (LDObject::Vertex, null); |
165 AddObjectDialog::staticDialog (LDObject::Vertex, null); |
168 } |
166 } |
169 |
167 |
170 MAKE_ACTION (makePrimitive, "Make a Primitive", "radial", "Generate a new circular primitive.", 0) |
168 DEFINE_ACTION (MakePrimitive, 0) { |
171 { |
|
172 generatePrimitive(); |
169 generatePrimitive(); |
173 } |
170 } |
174 |
171 |
175 MAKE_ACTION (editObject, "Edit Object", "edit-object", "Edits this object.", 0) { |
172 DEFINE_ACTION (Edit, 0) { |
176 if (g_win->sel().size() != 1) |
173 if (g_win->sel().size() != 1) |
177 return; |
174 return; |
178 |
175 |
179 LDObject* obj = g_win->sel()[0]; |
176 LDObject* obj = g_win->sel()[0]; |
180 AddObjectDialog::staticDialog (obj->getType(), obj); |
177 AddObjectDialog::staticDialog (obj->getType(), obj); |
181 } |
178 } |
182 |
179 |
183 MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME " help manual.", KEY (F1)) { |
180 DEFINE_ACTION (Help, KEY (F1)) { |
184 |
181 |
185 } |
182 } |
186 |
183 |
187 // ============================================================================= |
184 // ============================================================================= |
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
189 // ============================================================================= |
186 // ============================================================================= |
190 MAKE_ACTION (about, "About " APPNAME, "ldforge", |
187 DEFINE_ACTION (About, 0) { |
191 "Shows information about " APPNAME ".", (0)) |
188 AboutDialog().exec(); |
192 { |
189 } |
193 AboutDialog dlg; |
190 |
194 dlg.exec(); |
191 DEFINE_ACTION (AboutQt, 0) { |
195 } |
|
196 |
|
197 MAKE_ACTION (aboutQt, "About Qt", "qt", "Shows information about Qt.", (0)) { |
|
198 QMessageBox::aboutQt (g_win); |
192 QMessageBox::aboutQt (g_win); |
199 } |
193 } |
200 |
194 |
201 // ============================================================================= |
195 // ============================================================================= |
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
203 // ============================================================================= |
197 // ============================================================================= |
204 MAKE_ACTION (selectAll, "Select All", "select-all", "Selects all objects.", CTRL (A)) { |
198 DEFINE_ACTION (SelectAll, CTRL (A)) { |
205 g_win->sel().clear(); |
199 g_win->sel().clear(); |
206 |
200 |
207 for (LDObject* obj : currentFile()->objs()) |
201 for (LDObject* obj : currentFile()->objs()) |
208 g_win->sel() << obj; |
202 g_win->sel() << obj; |
209 |
203 |
210 g_win->updateSelection(); |
204 g_win->updateSelection(); |
211 } |
205 } |
212 |
206 |
213 // ============================================================================= |
207 // ============================================================================= |
214 MAKE_ACTION (selectByColor, "Select by Color", "select-color", |
208 DEFINE_ACTION (SelectByColor, CTRL_SHIFT (A)) { |
215 "Select all objects by the given color.", CTRL_SHIFT (A)) |
|
216 { |
|
217 short colnum = g_win->getSelectedColor(); |
209 short colnum = g_win->getSelectedColor(); |
218 |
210 |
219 if (colnum == -1) |
211 if (colnum == -1) |
220 return; // no consensus on color |
212 return; // no consensus on color |
221 |
213 |
266 } |
256 } |
267 |
257 |
268 // ============================================================================= |
258 // ============================================================================= |
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
270 // ============================================================================= |
260 // ============================================================================= |
271 MAKE_ACTION (gridCoarse, "Coarse Grid", "grid-coarse", "Set the grid to Coarse", (0)) { |
261 DEFINE_ACTION (GridCoarse, 0) { |
272 grid = Grid::Coarse; |
262 grid = Grid::Coarse; |
273 g_win->updateGridToolBar(); |
263 g_win->updateGridToolBar(); |
274 } |
264 } |
275 |
265 |
276 MAKE_ACTION (gridMedium, "Medium Grid", "grid-medium", "Set the grid to Medium", (0)) { |
266 DEFINE_ACTION (GridMedium, 0) { |
277 grid = Grid::Medium; |
267 grid = Grid::Medium; |
278 g_win->updateGridToolBar(); |
268 g_win->updateGridToolBar(); |
279 } |
269 } |
280 |
270 |
281 MAKE_ACTION (gridFine, "Fine Grid", "grid-fine", "Set the grid to Fine", (0)) { |
271 DEFINE_ACTION (GridFine, 0) { |
282 grid = Grid::Fine; |
272 grid = Grid::Fine; |
283 g_win->updateGridToolBar(); |
273 g_win->updateGridToolBar(); |
284 } |
274 } |
285 |
275 |
286 // ============================================================================= |
276 // ============================================================================= |
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
288 // ============================================================================= |
278 // ============================================================================= |
289 MAKE_ACTION (resetView, "Reset View", "reset-view", "Reset view angles, pan and zoom", CTRL (0)) { |
279 DEFINE_ACTION (ResetView, CTRL (0)) { |
290 g_win->R()->resetAngles(); |
280 g_win->R()->resetAngles(); |
291 g_win->R()->update(); |
281 g_win->R()->update(); |
292 } |
282 } |
293 |
283 |
294 // ============================================================================= |
284 // ============================================================================= |
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
296 // ============================================================================= |
286 // ============================================================================= |
297 MAKE_ACTION (insertFrom, "Insert from File", "file-import", "Insert LDraw data from a file.", (0)) { |
287 DEFINE_ACTION (InsertFrom, 0) { |
298 str fname = QFileDialog::getOpenFileName(); |
288 str fname = QFileDialog::getOpenFileName(); |
299 ulong idx = g_win->getInsertionPoint(); |
289 ulong idx = g_win->getInsertionPoint(); |
300 |
290 |
301 if (!fname.length()) |
291 if (!fname.length()) |
302 return; |
292 return; |
402 critical (fmt ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); |
391 critical (fmt ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); |
403 |
392 |
404 delete[] imgdata; |
393 delete[] imgdata; |
405 } |
394 } |
406 |
395 |
407 // ========================================================================================================================================= |
396 // ============================================================================= |
408 extern_cfg (bool, gl_axes); |
397 extern_cfg (bool, gl_axes); |
409 MAKE_ACTION (axes, "Draw Axes", "axes", "Toggles drawing of axes", (0)) { |
398 DEFINE_ACTION (Axes, 0) { |
410 gl_axes = !gl_axes; |
399 gl_axes = !gl_axes; |
411 ACTION (axes)->setChecked (gl_axes); |
400 ACTION (Axes)->setChecked (gl_axes); |
412 g_win->R()->update(); |
401 g_win->R()->update(); |
413 } |
402 } |
414 |
403 |
415 // ========================================================================================================================================= |
404 // ============================================================================= |
416 MAKE_ACTION (visibility, "Toggle Visibility", "visibility", "Toggles visibility/hiding on objects.", (0)) { |
405 DEFINE_ACTION (Visibility, 0) { |
417 for (LDObject* obj : g_win->sel()) |
406 for (LDObject* obj : g_win->sel()) |
418 obj->setHidden (!obj->hidden()); |
407 obj->setHidden (!obj->hidden()); |
419 |
408 |
420 g_win->fullRefresh(); |
409 g_win->fullRefresh(); |
421 } |
410 } |
422 |
411 |
423 MAKE_ACTION (wireframe, "Wireframe", "wireframe", "Toggle wireframe view", (0)) { |
412 DEFINE_ACTION (Wireframe, 0) { |
424 gl_wireframe = !gl_wireframe; |
413 gl_wireframe = !gl_wireframe; |
425 g_win->R()->refresh(); |
414 g_win->R()->refresh(); |
426 } |
415 } |
427 |
416 |
428 MAKE_ACTION (setOverlay, "Set Overlay Image", "overlay", "Set an overlay image", 0) |
417 DEFINE_ACTION (SetOverlay, 0) |
429 { |
418 { |
430 OverlayDialog dlg; |
419 OverlayDialog dlg; |
431 |
420 |
432 if (!dlg.exec()) |
421 if (!dlg.exec()) |
433 return; |
422 return; |
434 |
423 |
435 g_win->R()->setupOverlay ((GL::Camera) dlg.camera(), dlg.fpath(), dlg.ofsx(), |
424 g_win->R()->setupOverlay ((GL::Camera) dlg.camera(), dlg.fpath(), dlg.ofsx(), |
436 dlg.ofsy(), dlg.lwidth(), dlg.lheight() ); |
425 dlg.ofsy(), dlg.lwidth(), dlg.lheight() ); |
437 } |
426 } |
438 |
427 |
439 MAKE_ACTION (clearOverlay, "Clear Overlay Image", "overlay-clear", "Clear the overlay image.", (0)) { |
428 DEFINE_ACTION (ClearOverlay, 0) { |
440 g_win->R()->clearOverlay(); |
429 g_win->R()->clearOverlay(); |
441 } |
430 } |
442 |
431 |
443 MAKE_ACTION (modeSelect, "Select Mode", "mode-select", "Select objects from the camera view.", CTRL (1)) { |
432 DEFINE_ACTION (ModeSelect, CTRL (1)) { |
444 g_win->R()->setEditMode (Select); |
433 g_win->R()->setEditMode (Select); |
445 } |
434 } |
446 |
435 |
447 MAKE_ACTION (modeDraw, "Draw Mode", "mode-draw", "Draw objects into the camera view.", CTRL (2)) { |
436 DEFINE_ACTION (ModeDraw, CTRL (2)) { |
448 g_win->R()->setEditMode (Draw); |
437 g_win->R()->setEditMode (Draw); |
449 } |
438 } |
450 |
439 |
451 MAKE_ACTION (setDrawDepth, "Set Depth Value", "depth-value", "Set the depth coordinate of the current camera.", (0)) { |
440 DEFINE_ACTION (SetDrawDepth, 0) { |
452 if (g_win->R()->camera() == GL::Free) |
441 if (g_win->R()->camera() == GL::Free) |
453 return; |
442 return; |
454 |
443 |
455 bool ok; |
444 bool ok; |
456 double depth = QInputDialog::getDouble (g_win, "Set Draw Depth", |
445 double depth = QInputDialog::getDouble (g_win, "Set Draw Depth", |