# HG changeset patch # User Santeri Piippo # Date 1367878531 -10800 # Node ID 2247a32e63a859d34d8299af5b70ebf288edb9ef # Parent f562323760a2c86fb37601079e18d32ff6c8e9dc Added visibility toggling diff -r f562323760a2 -r 2247a32e63a8 gldraw.cpp --- a/gldraw.cpp Tue May 07 00:22:01 2013 +0300 +++ b/gldraw.cpp Tue May 07 01:15:31 2013 +0300 @@ -387,8 +387,12 @@ glRotatef (m_rotZ, 0.0f, 0.0f, 1.0f); } - for (LDObject* obj : g_curfile->m_objs) + for (LDObject* obj : g_curfile->m_objs) { + if (obj->hidden ()) + continue; // Don't draw hidden objects + glCallList (m_picking == false ? obj->uGLList : obj->uGLPickList); + } if (gl_axes && !m_picking) glCallList (m_axeslist); diff -r f562323760a2 -r 2247a32e63a8 gui.cpp --- a/gui.cpp Tue May 07 00:22:01 2013 +0300 +++ b/gui.cpp Tue May 07 01:15:31 2013 +0300 @@ -202,14 +202,18 @@ addMenuAction ("paste"); // Paste addMenuAction ("del"); // Delete menu->addSeparator (); // ----- + + for (uchar i = 0; i < LDObject::NumGroups; ++i) + addMenuAction (fmt ("group%c", 'A' + i)); // Group * + + addMenuAction ("ungroup"); // Ungroup + menu->addSeparator (); // ----- addMenuAction ("selectAll"); // Select All addMenuAction ("selectByColor"); // Select by Color addMenuAction ("selectByType"); // Select by Type - menu->addSeparator (); // ----- for (uchar i = 0; i < LDObject::NumGroups; ++i) - addMenuAction (fmt ("group%c", 'A' + i)); // Group * - addMenuAction ("groupNone"); // No Group + addMenuAction (fmt ("selGroup%c", 'A' + i)); // Select Group * initMenu ("&Tools"); addMenuAction ("setColor"); // Set Color @@ -222,6 +226,7 @@ addMenuAction ("makeCornerVerts"); // Make Corner Vertices addMenuAction ("roundCoords"); // Round Coordinates addMenuAction ("uncolorize"); // Uncolorize + addMenuAction ("visibility"); // Toggle Visibility // Move menu initMenu ("&Move"); @@ -394,6 +399,7 @@ addToolBarAction ("roundCoords"); addToolBarAction ("screencap"); addToolBarAction ("uncolorize"); + addToolBarAction ("visibility"); initSingleToolBar ("External Programs"); addToolBarAction ("ytruder"); @@ -412,7 +418,7 @@ g_CurrentToolBar->addWidget (btn); } - addToolBarAction ("groupNone"); + addToolBarAction ("ungroup"); updateToolBars (); } @@ -570,14 +576,14 @@ m_objList->clear (); for (LDObject* obj : g_curfile->m_objs) { - str zText; + str descr; switch (obj->getType ()) { case LDObject::Comment: - zText = static_cast (obj)->text.chars(); + descr = static_cast (obj)->text.chars(); // Remove leading whitespace - while (~zText && zText[0] == ' ') - zText -= -1; + while (~descr && descr[0] == ' ') + descr -= -1; break; case LDObject::Empty: @@ -586,7 +592,7 @@ case LDObject::Line: { LDLine* line = static_cast (obj); - zText.format ("%s, %s", + descr.format ("%s, %s", line->vaCoords[0].stringRep (true).chars(), line->vaCoords[1].stringRep (true).chars()); } @@ -595,7 +601,7 @@ case LDObject::Triangle: { LDTriangle* triangle = static_cast (obj); - zText.format ("%s, %s, %s", + descr.format ("%s, %s, %s", triangle->vaCoords[0].stringRep (true).chars(), triangle->vaCoords[1].stringRep (true).chars(), triangle->vaCoords[2].stringRep (true).chars()); @@ -605,7 +611,7 @@ case LDObject::Quad: { LDQuad* quad = static_cast (obj); - zText.format ("%s, %s, %s, %s", + descr.format ("%s, %s, %s, %s", quad->vaCoords[0].stringRep (true).chars(), quad->vaCoords[1].stringRep (true).chars(), quad->vaCoords[2].stringRep (true).chars(), @@ -616,7 +622,7 @@ case LDObject::CondLine: { LDCondLine* line = static_cast (obj); - zText.format ("%s, %s, %s, %s", + descr.format ("%s, %s, %s, %s", line->vaCoords[0].stringRep (true).chars(), line->vaCoords[1].stringRep (true).chars(), line->vaCoords[2].stringRep (true).chars(), @@ -625,55 +631,61 @@ break; case LDObject::Gibberish: - zText.format ("ERROR: %s", + descr.format ("ERROR: %s", static_cast (obj)->zContents.chars()); break; case LDObject::Vertex: - zText.format ("%s", static_cast (obj)->vPosition.stringRep (true).chars()); + descr.format ("%s", static_cast (obj)->vPosition.stringRep (true).chars()); break; case LDObject::Subfile: { LDSubfile* ref = static_cast (obj); - zText.format ("%s %s, (", + descr.format ("%s %s, (", ref->zFileName.chars(), ref->vPosition.stringRep (true).chars()); for (short i = 0; i < 9; ++i) - zText.appendformat ("%s%s", + descr.appendformat ("%s%s", ftoa (ref->mMatrix[i]).chars(), (i != 8) ? " " : ""); - zText += ')'; + descr += ')'; } break; case LDObject::BFC: { LDBFC* bfc = static_cast (obj); - zText = LDBFC::statements[bfc->type]; + descr = LDBFC::statements[bfc->type]; } break; case LDObject::Radial: { LDRadial* pRad = static_cast (obj); - zText.format ("%d / %d %s", pRad->dSegments, pRad->dDivisions, pRad->radialTypeName()); + descr.format ("%d / %d %s", pRad->dSegments, pRad->dDivisions, pRad->radialTypeName()); if (pRad->eRadialType == LDRadial::Ring || pRad->eRadialType == LDRadial::Cone) - zText.appendformat (" %d", pRad->dRingNum); + descr.appendformat (" %d", pRad->dRingNum); - zText.appendformat (" %s", pRad->vPosition.stringRep (true).chars ()); + descr.appendformat (" %s", pRad->vPosition.stringRep (true).chars ()); } break; default: - zText = g_saObjTypeNames[obj->getType ()]; + descr = g_saObjTypeNames[obj->getType ()]; break; } - QListWidgetItem* item = new QListWidgetItem (zText.chars()); + // Put it into brackets if it's hidden + if (obj->hidden ()) { + str copy = descr.chars (); + descr.format ("[[ %s ]]", copy.chars ()); + } + + QListWidgetItem* item = new QListWidgetItem (descr.chars()); item->setIcon (getIcon (g_saObjTypeIcons[obj->getType ()])); // Color gibberish orange on red so it stands out. diff -r f562323760a2 -r 2247a32e63a8 gui_actions.cpp --- a/gui_actions.cpp Tue May 07 00:22:01 2013 +0300 +++ b/gui_actions.cpp Tue May 07 01:15:31 2013 +0300 @@ -170,13 +170,13 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= MAKE_ACTION (about, "About " APPNAME, "ldforge", - "Shows information about " APPNAME ".", CTRL (F1)) + "Shows information about " APPNAME ".", (0)) { AboutDialog dlg; dlg.exec (); } -MAKE_ACTION (aboutQt, "About Qt", "qt", "Shows information about Qt.", CTRL_SHIFT (F1)) { +MAKE_ACTION (aboutQt, "About Qt", "qt", "Shows information about Qt.", (0)) { QMessageBox::aboutQt (g_win); } @@ -405,6 +405,67 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= +void setGroup (const LDObject::Group group) { + for (LDObject* obj : g_win->sel ()) + obj->setGroup (group); + + g_win->refresh (); +} + +// ============================================================================= +void selGroup (const LDObject::Group group) { + for (LDObject* obj : g_curfile->m_objs) { + if (obj->group () != group) + continue; // wrong group + + bool selected = false; + for (LDObject* selobj : g_win->sel ()) { + if (selobj == obj) { + selected = true; + break; + } + } + + if (selected) + continue; // already selected + + g_win->sel ().push_back (obj); + } + + g_win->refresh (); +} + +#define GROUP_ACTION(N, KEY) \ + MAKE_ACTION (group##N, "Group " #N, "group", "Set group of selected objects to " #N, CTRL_SHIFT (KEY)) { \ + setGroup (LDObject::N); \ + } \ + \ + MAKE_ACTION (selGroup##N, "Select Group " #N, "group", "Select the contents of group " #N, SHIFT (F##KEY)) { \ + selGroup (LDObject::N); \ + } + +GROUP_ACTION (A, 1) +GROUP_ACTION (B, 2) +GROUP_ACTION (C, 3) +GROUP_ACTION (D, 4) + +MAKE_ACTION (ungroup, "Ungroup", "ungroup", "Unset the group of selected objects", CTRL_SHIFT (0)) { + setGroup (LDObject::NoGroup); +} + +// ============================================================================= +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +// ============================================================================= +MAKE_ACTION (visibility, "Toggle Visibility", "visibility", "Toggles visibility/hiding on objects.", (0)) { + for (LDObject* obj : g_win->sel ()) + obj->setHidden (!obj->hidden ()); + + g_win->refresh (); +} + +// ============================================================================= +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +// ============================================================================= // Debug things #ifndef RELEASE MAKE_ACTION (addTestQuad, "Add Test Quad", "add-quad", "Adds a test quad.", (0)) { diff -r f562323760a2 -r 2247a32e63a8 gui_editactions.cpp --- a/gui_editactions.cpp Tue May 07 00:22:01 2013 +0300 +++ b/gui_editactions.cpp Tue May 07 01:15:31 2013 +0300 @@ -684,28 +684,4 @@ History::addEntry (new EditHistory (indices, oldCopies, newCopies)); g_win->refresh (); } -} - -// ============================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ============================================================================= -void setGroup (const LDObject::Group group) { - for (LDObject* obj : g_win->sel ()) - obj->setGroup (group); - - g_win->refresh (); -} - -#define GROUP_ACTION(N, KEY) \ - MAKE_ACTION (group##N, "Group " #N, "group", "Set group of selected objects to " #N, CTRL_SHIFT (KEY)) { \ - setGroup (LDObject::N); \ - } - -GROUP_ACTION (A, 1) -GROUP_ACTION (B, 2) -GROUP_ACTION (C, 3) -GROUP_ACTION (D, 4) - -MAKE_ACTION (groupNone, "No Group", "group-no", "Unset objects' group", CTRL_SHIFT (0)) { - setGroup (LDObject::NoGroup); } \ No newline at end of file diff -r f562323760a2 -r 2247a32e63a8 ldforge.qrc --- a/ldforge.qrc Tue May 07 00:22:01 2013 +0300 +++ b/ldforge.qrc Tue May 07 01:15:31 2013 +0300 @@ -84,6 +84,7 @@ ./icons/undo.png ./icons/ungroup.png ./icons/vertex.png + ./icons/visibility.png ./icons/ytruder.png ./docs/test2.html ./docs/test.html diff -r f562323760a2 -r 2247a32e63a8 ldtypes.cpp --- a/ldtypes.cpp Tue May 07 00:22:01 2013 +0300 +++ b/ldtypes.cpp Tue May 07 01:15:31 2013 +0300 @@ -61,6 +61,7 @@ qObjListEntry = null; parent = null; m_group = NoGroup; + m_hidden = false; } LDGibberish::LDGibberish (str _zContent, str _zReason) {