src/gui_editactions.cpp

changeset 251
c4b96bc41298
parent 250
6e80f038e8df
child 252
3f9067022d74
equal deleted inserted replaced
250:6e80f038e8df 251:c4b96bc41298
259 long lIndex = obj->getIndex (g_curfile); 259 long lIndex = obj->getIndex (g_curfile);
260 260
261 if (lIndex == -1) 261 if (lIndex == -1)
262 return; 262 return;
263 263
264 std::vector<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles (); 264 vector<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles ();
265 265
266 // Replace the quad with the first triangle and add the second triangle 266 // Replace the quad with the first triangle and add the second triangle
267 // after the first one. 267 // after the first one.
268 g_curfile->setObject (lIndex, triangles[0]); 268 g_curfile->setObject (lIndex, triangles[0]);
269 g_curfile->insertObj (lIndex + 1, triangles[1]); 269 g_curfile->insertObj (lIndex + 1, triangles[1]);
315 return; 315 return;
316 316
317 short colnum; 317 short colnum;
318 short defcol = -1; 318 short defcol = -1;
319 319
320 std::vector<LDObject*> objs = g_win->sel (); 320 vector<LDObject*> objs = g_win->sel ();
321 321
322 // If all selected objects have the same color, said color is our default 322 // If all selected objects have the same color, said color is our default
323 // value to the color selection dialog. 323 // value to the color selection dialog.
324 defcol = g_win->getSelectedColor (); 324 defcol = g_win->getSelectedColor ();
325 325
326 // Show the dialog to the user now and ask for a color. 326 // Show the dialog to the user now and ask for a color.
327 if (ColorSelectDialog::staticDialog (colnum, defcol, g_win)) { 327 if (ColorSelectDialog::staticDialog (colnum, defcol, g_win)) {
328 std::vector<ulong> indices; 328 vector<ulong> indices;
329 std::vector<short> colornums; 329 vector<short> colornums;
330 330
331 for (LDObject* obj : objs) { 331 for (LDObject* obj : objs) {
332 if (obj->isColored () == false) 332 if (obj->isColored () == false)
333 continue; 333 continue;
334 334
520 // them and wrap them into a ComboHistory, which allows storage of multiple 520 // them and wrap them into a ComboHistory, which allows storage of multiple
521 // simultaneous edits with different type. This is what we ultimately store into 521 // simultaneous edits with different type. This is what we ultimately store into
522 // History. 522 // History.
523 // ============================================================================= 523 // =============================================================================
524 MAKE_ACTION (invert, "Invert", "invert", "Reverse the winding of given objects.", CTRL_SHIFT (W)) { 524 MAKE_ACTION (invert, "Invert", "invert", "Reverse the winding of given objects.", CTRL_SHIFT (W)) {
525 std::vector<LDObject*> sel = g_win->sel (); 525 vector<LDObject*> sel = g_win->sel ();
526 ComboHistory* history = new ComboHistory; 526 ComboHistory* history = new ComboHistory;
527 527
528 for (LDObject* obj : sel) { 528 for (LDObject* obj : sel) {
529 *history << obj->invert (); 529 *history << obj->invert ();
530 g_win->R ()->compileObject (obj); 530 g_win->R ()->compileObject (obj);
539 539
540 // ============================================================================= 540 // =============================================================================
541 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 541 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
542 // ============================================================================= 542 // =============================================================================
543 static void doRotate (const short l, const short m, const short n) { 543 static void doRotate (const short l, const short m, const short n) {
544 std::vector<LDObject*> sel = g_win->sel (); 544 vector<LDObject*> sel = g_win->sel ();
545 vertex origin; 545 vertex origin;
546 std::vector<vertex*> queue; 546 vector<vertex*> queue;
547 const double angle = (pi * currentGrid ().confs[Grid::Angle]->value) / 180; 547 const double angle = (pi * currentGrid ().confs[Grid::Angle]->value) / 180;
548 548
549 // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2 549 // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2
550 const double cosangle = cos (angle), 550 const double cosangle = cos (angle),
551 sinangle = sin (angle); 551 sinangle = sin (angle);

mercurial