gui_editactions.cpp

changeset 109
f40b35142586
parent 104
6e29bb0e83c5
child 110
a62ab18d1b80
equal deleted inserted replaced
108:351aef26f444 109:f40b35142586
28 28
29 // ============================================================================= 29 // =============================================================================
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
31 // ============================================================================= 31 // =============================================================================
32 static bool copyToClipboard () { 32 static bool copyToClipboard () {
33 vector<LDObject*> objs = g_ForgeWindow->getSelectedObjects (); 33 vector<LDObject*> objs = g_ForgeWindow->selection ();
34 34
35 if (objs.size() == 0) 35 if (objs.size() == 0)
36 return false; 36 return false;
37 37
38 // Clear the clipboard first. 38 // Clear the clipboard first.
105 105
106 // ============================================================================= 106 // =============================================================================
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
108 // ============================================================================= 108 // =============================================================================
109 static void doInline (bool bDeep) { 109 static void doInline (bool bDeep) {
110 vector<LDObject*> sel = g_ForgeWindow->getSelectedObjects (); 110 vector<LDObject*> sel = g_ForgeWindow->selection ();
111 111
112 // History stuff 112 // History stuff
113 vector<LDSubfile*> paRefs; 113 vector<LDSubfile*> paRefs;
114 vector<ulong> ulaRefIndices, ulaBitIndices; 114 vector<ulong> ulaRefIndices, ulaBitIndices;
115 115
168 168
169 // ============================================================================= 169 // =============================================================================
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
171 // ============================================================================= 171 // =============================================================================
172 ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.", (0)) { 172 ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.", (0)) {
173 vector<LDObject*> objs = g_ForgeWindow->getSelectedObjects (); 173 vector<LDObject*> objs = g_ForgeWindow->selection ();
174 174
175 vector<ulong> ulaIndices; 175 vector<ulong> ulaIndices;
176 vector<LDQuad*> paCopies; 176 vector<LDQuad*> paCopies;
177 177
178 // Store stuff first for history archival 178 // Store stuff first for history archival
214 // ============================================================================= 214 // =============================================================================
215 ACTION (setContents, "Set Contents", "set-contents", "Set the raw code of this object.", KEY (F9)) { 215 ACTION (setContents, "Set Contents", "set-contents", "Set the raw code of this object.", KEY (F9)) {
216 if (g_ForgeWindow->qObjList->selectedItems().size() != 1) 216 if (g_ForgeWindow->qObjList->selectedItems().size() != 1)
217 return; 217 return;
218 218
219 LDObject* obj = g_ForgeWindow->getSelectedObjects ()[0]; 219 LDObject* obj = g_ForgeWindow->selection ()[0];
220 SetContentsDialog::staticDialog (obj); 220 SetContentsDialog::staticDialog (obj);
221 } 221 }
222 222
223 // ============================================================================= 223 // =============================================================================
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
228 return; 228 return;
229 229
230 short dColor; 230 short dColor;
231 short dDefault = -1; 231 short dDefault = -1;
232 232
233 std::vector<LDObject*> objs = g_ForgeWindow->getSelectedObjects (); 233 std::vector<LDObject*> objs = g_ForgeWindow->selection ();
234 234
235 // If all selected objects have the same color, said color is our default 235 // If all selected objects have the same color, said color is our default
236 // value to the color selection dialog. 236 // value to the color selection dialog.
237 for (LDObject* obj : objs) { 237 dDefault = g_ForgeWindow->getSelectedColor ();
238 if (obj->dColor == -1)
239 continue; // doesn't use color
240
241 if (dDefault != -1 && obj->dColor != dDefault) {
242 // No consensus in object color, therefore we don't have a
243 // proper default value to use.
244 dDefault = -1;
245 break;
246 }
247
248 if (dDefault == -1)
249 dDefault = obj->dColor;
250 }
251 238
252 // Show the dialog to the user now and ask for a color. 239 // Show the dialog to the user now and ask for a color.
253 if (ColorSelectDialog::staticDialog (dColor, dDefault, g_ForgeWindow)) { 240 if (ColorSelectDialog::staticDialog (dColor, dDefault, g_ForgeWindow)) {
254 std::vector<ulong> ulaIndices; 241 std::vector<ulong> ulaIndices;
255 std::vector<short> daColors; 242 std::vector<short> daColors;
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
273 // ============================================================================= 260 // =============================================================================
274 ACTION (makeBorders, "Make Borders", "make-borders", "Add borders around given polygons.", 261 ACTION (makeBorders, "Make Borders", "make-borders", "Add borders around given polygons.",
275 CTRL_SHIFT (B)) 262 CTRL_SHIFT (B))
276 { 263 {
277 vector<LDObject*> objs = g_ForgeWindow->getSelectedObjects (); 264 vector<LDObject*> objs = g_ForgeWindow->selection ();
278 265
279 vector<ulong> ulaIndices; 266 vector<ulong> ulaIndices;
280 vector<LDObject*> paObjs; 267 vector<LDObject*> paObjs;
281 268
282 for (LDObject* obj : objs) { 269 for (LDObject* obj : objs) {
325 "Adds vertex objects to the corners of the given polygons", (0)) 312 "Adds vertex objects to the corners of the given polygons", (0))
326 { 313 {
327 vector<ulong> ulaIndices; 314 vector<ulong> ulaIndices;
328 vector<LDObject*> paObjs; 315 vector<LDObject*> paObjs;
329 316
330 for (LDObject* obj : g_ForgeWindow->getSelectedObjects ()) { 317 for (LDObject* obj : g_ForgeWindow->selection ()) {
331 vertex* vaCoords = null; 318 vertex* vaCoords = null;
332 ushort uNumCoords = 0; 319 ushort uNumCoords = 0;
333 320
334 switch (obj->getType ()) { 321 switch (obj->getType ()) {
335 case OBJ_Quad: 322 case OBJ_Quad:
371 358
372 // ============================================================================= 359 // =============================================================================
373 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
374 // ============================================================================= 361 // =============================================================================
375 static void doMoveSelection (const bool bUp) { 362 static void doMoveSelection (const bool bUp) {
376 vector<LDObject*> objs = g_ForgeWindow->getSelectedObjects (); 363 vector<LDObject*> objs = g_ForgeWindow->selection ();
377 364
378 // Get the indices of the objects for history archival 365 // Get the indices of the objects for history archival
379 vector<ulong> ulaIndices; 366 vector<ulong> ulaIndices;
380 for (LDObject* obj : objs) 367 for (LDObject* obj : objs)
381 ulaIndices.push_back (obj->getIndex (g_CurrentFile)); 368 ulaIndices.push_back (obj->getIndex (g_CurrentFile));
413 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 400 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
414 // ============================================================================= 401 // =============================================================================
415 void doMoveObjects (const vertex vVector) { 402 void doMoveObjects (const vertex vVector) {
416 vector<ulong> ulaIndices; 403 vector<ulong> ulaIndices;
417 404
418 for (LDObject* obj : g_ForgeWindow->getSelectedObjects ()) { 405 for (LDObject* obj : g_ForgeWindow->selection ()) {
419 ulaIndices.push_back (obj->getIndex (g_CurrentFile)); 406 ulaIndices.push_back (obj->getIndex (g_CurrentFile));
420 obj->move (vVector); 407 obj->move (vVector);
421 } 408 }
422 409
423 History::addEntry (new MoveHistory (ulaIndices, vVector)); 410 History::addEntry (new MoveHistory (ulaIndices, vVector));

mercurial