src/gui_editactions.cpp

changeset 344
55fcf67230fd
parent 330
76505a9c7b56
child 346
ba2db5e22f8b
equal deleted inserted replaced
343:75487752f3e6 344:55fcf67230fd
39 cfg (bool, edit_schemanticinline, false); 39 cfg (bool, edit_schemanticinline, false);
40 40
41 // ============================================================================= 41 // =============================================================================
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
43 // ============================================================================= 43 // =============================================================================
44 static void copyToClipboard () { 44 static int copyToClipboard () {
45 vector<LDObject*> objs = g_win->sel (); 45 vector<LDObject*> objs = g_win->sel ();
46 int num = 0;
46 47
47 // Clear the clipboard first. 48 // Clear the clipboard first.
48 g_Clipboard.clear (); 49 g_Clipboard.clear ();
49 50
50 // Now, copy the contents into the clipboard. 51 // Now, copy the contents into the clipboard.
51 for (LDObject* obj : objs) 52 for (LDObject* obj : objs)
53 {
52 g_Clipboard << obj->raw (); 54 g_Clipboard << obj->raw ();
55 ++num;
56 }
57
58 return num;
53 } 59 }
54 60
55 // ============================================================================= 61 // =============================================================================
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
57 // ============================================================================= 63 // =============================================================================
58 MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.", CTRL (X)) { 64 MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.", CTRL (X)) {
59 copyToClipboard (); 65 int num = copyToClipboard ();
60 g_win->deleteSelection (); 66 g_win->deleteSelection ();
67
68 log( ForgeWindow::tr( "%1 objects cut" ), num );
61 } 69 }
62 70
63 // ============================================================================= 71 // =============================================================================
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
65 // ============================================================================= 73 // =============================================================================
66 MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.", CTRL (C)) { 74 MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.", CTRL (C)) {
67 copyToClipboard (); 75 int num = copyToClipboard ();
76 log( ForgeWindow::tr( "%1 objects copied" ), num );
68 } 77 }
69 78
70 // ============================================================================= 79 // =============================================================================
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
72 // ============================================================================= 81 // =============================================================================
73 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) { 82 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) {
74 ulong idx = g_win->getInsertionPoint (); 83 ulong idx = g_win->getInsertionPoint ();
75 g_win->sel ().clear (); 84 g_win->sel ().clear ();
85 int num = 0;
76 86
77 for (str line : g_Clipboard) { 87 for (str line : g_Clipboard) {
78 LDObject* pasted = parseLine (line); 88 LDObject* pasted = parseLine (line);
79 g_curfile->insertObj (idx++, pasted); 89 g_curfile->insertObj (idx++, pasted);
80 g_win->sel () << pasted; 90 g_win->sel () << pasted;
81 g_win->R ()->compileObject (pasted); 91 g_win->R ()->compileObject (pasted);
82 } 92 ++num;
83 93 }
94
95 log( ForgeWindow::tr( "%1 objects pasted" ), num );
84 g_win->refresh (); 96 g_win->refresh ();
85 g_win->scrollToSelection (); 97 g_win->scrollToSelection ();
86 } 98 }
87 99
88 // ============================================================================= 100 // =============================================================================
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
90 // ============================================================================= 102 // =============================================================================
91 MAKE_ACTION (del, "Delete", "delete", "Delete the selection", KEY (Delete)) { 103 MAKE_ACTION (del, "Delete", "delete", "Delete the selection", KEY (Delete)) {
92 g_win->deleteSelection (); 104 int num = g_win->deleteSelection ();
105 log( ForgeWindow::tr( "%1 objects deleted" ), num );
93 } 106 }
94 107
95 // ============================================================================= 108 // =============================================================================
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
97 // ============================================================================= 110 // =============================================================================
140 // =============================================================================================== 153 // ===============================================================================================
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
142 // =============================================================================================== 155 // ===============================================================================================
143 MAKE_ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.", (0)) { 156 MAKE_ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.", (0)) {
144 vector<LDObject*> objs = g_win->sel (); 157 vector<LDObject*> objs = g_win->sel ();
158 int num = 0;
145 159
146 for (LDObject* obj : objs) { 160 for (LDObject* obj : objs) {
147 if (obj->getType() != LDObject::Quad) 161 if (obj->getType() != LDObject::Quad)
148 continue; 162 continue;
149 163
160 g_curfile->setObject (index, triangles[0]); 174 g_curfile->setObject (index, triangles[0]);
161 g_curfile->insertObj (index + 1, triangles[1]); 175 g_curfile->insertObj (index + 1, triangles[1]);
162 176
163 // Delete this quad now, it has been split. 177 // Delete this quad now, it has been split.
164 delete obj; 178 delete obj;
165 } 179
180 num++;
181 }
182
183 log( "%1 quadrilaterals split", num );
166 184
167 g_win->fullRefresh (); 185 g_win->fullRefresh ();
168 } 186 }
169 187
170 // ============================================================================= 188 // =============================================================================
474 492
475 MAKE_ACTION (rotateZNeg, "Rotate -Z", "rotate-z-neg", "Rotate objects around Z axis", CTRL (Down)) { 493 MAKE_ACTION (rotateZNeg, "Rotate -Z", "rotate-z-neg", "Rotate objects around Z axis", CTRL (Down)) {
476 doRotate (0, 0, -1); 494 doRotate (0, 0, -1);
477 } 495 }
478 496
479 // =========================================================================================================================================
480 MAKE_ACTION (rotpoint, "Set Rotation Point", "rotpoint", "Configure the rotation point.", (0)) { 497 MAKE_ACTION (rotpoint, "Set Rotation Point", "rotpoint", "Configure the rotation point.", (0)) {
481 configRotationPoint (); 498 configRotationPoint ();
482 } 499 }
483 500
484 // ============================================================================= 501 // =============================================================================
491 for (LDObject* obj : g_win->sel ()) 508 for (LDObject* obj : g_win->sel ())
492 for (short i = 0; i < obj->vertices (); ++i) { 509 for (short i = 0; i < obj->vertices (); ++i) {
493 vertex v = obj->getVertex (i); 510 vertex v = obj->getVertex (i);
494 511
495 for (const Axis ax : g_Axes) { 512 for (const Axis ax : g_Axes) {
496 // HACK: :p 513 // HACK: .. should find a better way to do this
497 char valstr[64]; 514 char valstr[64];
498 sprintf (valstr, "%.3f", v[ax]); 515 sprintf (valstr, "%.3f", v[ax]);
499 v[ax] = atof (valstr); 516 v[ax] = atof (valstr);
500 } 517 }
501 518
509 526
510 // ============================================================================= 527 // =============================================================================
511 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 528 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
512 // ============================================================================= 529 // =============================================================================
513 MAKE_ACTION (uncolorize, "Uncolorize", "uncolorize", "Reduce colors of everything selected to main and edge colors", (0)) { 530 MAKE_ACTION (uncolorize, "Uncolorize", "uncolorize", "Reduce colors of everything selected to main and edge colors", (0)) {
531 int num = 0;
532
514 for (LDObject* obj : g_win->sel ()) { 533 for (LDObject* obj : g_win->sel ()) {
515 if (obj->isColored () == false) 534 if (obj->isColored () == false)
516 continue; 535 continue;
517 536
518 obj->setColor ((obj->getType () == LDObject::Line || obj->getType () == LDObject::CondLine) ? edgecolor : maincolor); 537 int col = maincolor;
519 } 538 if( obj->getType() == LDObject::Line || obj->getType() == LDObject::CondLine )
520 539 col = edgecolor;
540
541 obj->setColor( col );
542 num++;
543 }
544
545 log( ForgeWindow::tr( "%1 objects uncolored" ), num );
521 g_win->fullRefresh (); 546 g_win->fullRefresh ();
522 } 547 }
523 548
524 // ============================================================================= 549 // =============================================================================
525 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 550 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

mercurial