src/gui_editactions.cpp

changeset 542
46a33bdc0b36
parent 541
0e38beeb050a
child 551
0efe5dbcef07
equal deleted inserted replaced
541:0e38beeb050a 542:46a33bdc0b36
373 } 373 }
374 374
375 // ============================================================================= 375 // =============================================================================
376 // ----------------------------------------------------------------------------- 376 // -----------------------------------------------------------------------------
377 DEFINE_ACTION (MoveXNeg, KEY (Left)) 377 DEFINE_ACTION (MoveXNeg, KEY (Left))
378 { doMoveObjects ( { -1, 0, 0}); 378 { doMoveObjects ({ -1, 0, 0});
379 } 379 }
380 380
381 DEFINE_ACTION (MoveYNeg, KEY (Home)) 381 DEFINE_ACTION (MoveYNeg, KEY (Home))
382 { doMoveObjects ( {0, -1, 0}); 382 { doMoveObjects ({0, -1, 0});
383 } 383 }
384 384
385 DEFINE_ACTION (MoveZNeg, KEY (Down)) 385 DEFINE_ACTION (MoveZNeg, KEY (Down))
386 { doMoveObjects ( {0, 0, -1}); 386 { doMoveObjects ({0, 0, -1});
387 } 387 }
388 388
389 DEFINE_ACTION (MoveXPos, KEY (Right)) 389 DEFINE_ACTION (MoveXPos, KEY (Right))
390 { doMoveObjects ( {1, 0, 0}); 390 { doMoveObjects ({1, 0, 0});
391 } 391 }
392 392
393 DEFINE_ACTION (MoveYPos, KEY (End)) 393 DEFINE_ACTION (MoveYPos, KEY (End))
394 { doMoveObjects ( {0, 1, 0}); 394 { doMoveObjects ({0, 1, 0});
395 } 395 }
396 396
397 DEFINE_ACTION (MoveZPos, KEY (Up)) 397 DEFINE_ACTION (MoveZPos, KEY (Up))
398 { doMoveObjects ( {0, 0, 1}); 398 { doMoveObjects ({0, 0, 1});
399 } 399 }
400 400
401 // ============================================================================= 401 // =============================================================================
402 // ----------------------------------------------------------------------------- 402 // -----------------------------------------------------------------------------
403 DEFINE_ACTION (Invert, CTRL_SHIFT (W)) 403 DEFINE_ACTION (Invert, CTRL_SHIFT (W))
451 { vertex v = obj->getVertex (i); 451 { vertex v = obj->getVertex (i);
452 rotateVertex (v, rotpoint, transform); 452 rotateVertex (v, rotpoint, transform);
453 obj->setVertex (i, v); 453 obj->setVertex (i, v);
454 } 454 }
455 } elif (obj->hasMatrix()) 455 } elif (obj->hasMatrix())
456
457 { LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj); 456 { LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj);
458 457
459 // Transform the position 458 // Transform the position
460 vertex v = mo->getPosition(); 459 vertex v = mo->getPosition();
461 rotateVertex (v, rotpoint, transform); 460 rotateVertex (v, rotpoint, transform);
506 DEFINE_ACTION (RoundCoordinates, 0) 505 DEFINE_ACTION (RoundCoordinates, 0)
507 { setlocale (LC_ALL, "C"); 506 { setlocale (LC_ALL, "C");
508 int num = 0; 507 int num = 0;
509 508
510 for (LDObject* obj : selection()) 509 for (LDObject* obj : selection())
511 { for (int i = 0; i < obj->vertices(); ++i) 510 { LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj);
512 { vertex v = obj->getVertex (i); 511
512 if (mo != null)
513 { vertex v = mo->getPosition();
514 matrix t = mo->getTransform();
513 515
514 for (const Axis ax : g_Axes) 516 for (const Axis ax : g_Axes)
515 { // HACK: .. should find a better way to do this 517 roundToDecimals (v[ax], 3);
516 str valstr; 518
517 valstr.sprintf ("%.3f", v[ax]); 519 // Let matrix values be rounded to 4 decimals,
518 v[ax] = valstr.toDouble(); 520 // they need that extra precision
521 for (int i = 0; i < 9; ++i)
522 roundToDecimals (t[i], 4);
523
524 mo->setPosition (v);
525 mo->setTransform (t);
526 num += 10;
527 }
528 else
529 { for (int i = 0; i < obj->vertices(); ++i)
530 { vertex v = obj->getVertex (i);
531
532 for (const Axis ax : g_Axes)
533 roundToDecimals (v[ax], 3);
534
535 obj->setVertex (i, v);
536 g_win->R()->compileObject (obj);
537 num += 3;
519 } 538 }
520 539 }
521 obj->setVertex (i, v); 540 }
522 g_win->R()->compileObject (obj); 541
523 num += 3; 542 log (ForgeWindow::tr ("Rounded %1 values"), num);
524 } 543 g_win->refreshObjectList();
525 }
526
527 log (ForgeWindow::tr ("Rounded %1 coordinates"), num);
528 g_win->refresh(); 544 g_win->refresh();
529 } 545 }
530 546
531 // ============================================================================= 547 // =============================================================================
532 // ----------------------------------------------------------------------------- 548 // -----------------------------------------------------------------------------

mercurial