src/gui_editactions.cpp

changeset 262
56f8987f4c7c
parent 254
434c9844e45d
child 265
955c0aabfebf
equal deleted inserted replaced
261:c4ad4e3c6839 262:56f8987f4c7c
679 679
680 MAKE_ACTION (isecalc, "Isecalc", "isecalc", "Compute intersection between objects", (0)) { 680 MAKE_ACTION (isecalc, "Isecalc", "isecalc", "Compute intersection between objects", (0)) {
681 runIsecalc (); 681 runIsecalc ();
682 } 682 }
683 683
684 // ========================================================================================================================================= 684 // =============================================================================
685 MAKE_ACTION (replaceCoords, "Replace Coordinates", "replace-coords", "Find and replace coordinate values", CTRL (R)) { 685 MAKE_ACTION (replaceCoords, "Replace Coordinates", "replace-coords", "Find and replace coordinate values", CTRL (R)) {
686 ReplaceCoordsDialog dlg; 686 ReplaceCoordsDialog dlg;
687 687
688 if (!dlg.exec ()) 688 if (!dlg.exec ())
689 return; 689 return;
690 690
691 const double search = dlg.searchValue (), 691 const double search = dlg.searchValue (),
692 replacement = dlg.replacementValue (); 692 replacement = dlg.replacementValue ();
693 const bool any = dlg.any (),
694 rel = dlg.rel ();
695
693 vector<int> sel = dlg.axes (); 696 vector<int> sel = dlg.axes ();
694
695 EditHistory* history = new EditHistory; 697 EditHistory* history = new EditHistory;
696 698
697 for (LDObject* obj : g_win->sel ()) { 699 for (LDObject* obj : g_win->sel ()) {
698 LDObject* copy = obj->clone (); 700 LDObject* copy = obj->clone ();
699 701
700 for (short i = 0; i < obj->vertices (); ++i) 702 for (short i = 0; i < obj->vertices (); ++i)
701 for (int ax : sel) { 703 for (int ax : sel) {
702 double& coord = obj->coords[i][(Axis) ax]; 704 double& coord = obj->coords[i][(Axis) ax];
703 705
704 if (coord == search) 706 if (any || coord == search) {
705 coord = replacement; 707 if (!rel)
708 coord = 0;
709
710 coord += replacement;
711 }
706 } 712 }
707 713
708 history->addEntry (copy, obj, obj->getIndex (g_curfile)); 714 history->addEntry (copy, obj, obj->getIndex (g_curfile));
709 715
710 delete copy; 716 delete copy;

mercurial