Wed, 08 May 2013 01:12:23 +0300
Removed groups.. that was stupid. Intersector input now based on colors.
extprogs.cpp | file | annotate | diff | comparison | revisions | |
gui.cpp | file | annotate | diff | comparison | revisions | |
gui.h | file | annotate | diff | comparison | revisions | |
gui_actions.cpp | file | annotate | diff | comparison | revisions | |
icons/group.png | file | annotate | diff | comparison | revisions | |
icons/ungroup.png | file | annotate | diff | comparison | revisions | |
ldforge.pro | file | annotate | diff | comparison | revisions | |
ldforge.qrc | file | annotate | diff | comparison | revisions | |
ldtypes.cpp | file | annotate | diff | comparison | revisions | |
ldtypes.h | file | annotate | diff | comparison | revisions |
--- a/extprogs.cpp Tue May 07 23:37:46 2013 +0300 +++ b/extprogs.cpp Wed May 08 01:12:23 2013 +0300 @@ -119,6 +119,12 @@ fwrite (line.chars(), 1, ~line, fp); } +#ifndef RELEASE + ushort idx = rand (); + printf ("%s -> debug_%u\n", fname.chars (), idx); + QFile::copy (fname.chars (), fmt ("debug_%u", idx)); +#endif // RELEASE + fclose (fp); } @@ -128,10 +134,10 @@ } // ============================================================================= -void writeGroup (const LDObject::Group group, str fname) { +void writeColorGroup (const short colnum, str fname) { std::vector<LDObject*> objects; for (LDObject*& obj : g_curfile->m_objs) { - if (obj->group() != group) + if (obj->isColored () == false || obj->dColor != colnum) continue; objects.push_back (obj); @@ -171,7 +177,7 @@ #ifndef RELASE printf ("%s", qchars (QString (proc.readAllStandardOutput ()))); -#endif +#endif // RELEASE if (proc.exitStatus () == QProcess::CrashExit) { processError (prog, proc); @@ -180,10 +186,10 @@ } // ======================================================================================================================================== -static void insertOutput (str fname, bool replace, vector<LDObject::Group> groupsToReplace) { +static void insertOutput (str fname, bool replace, vector<short> colorsToReplace) { #ifndef RELEASE - QFile::copy (fname, "./output.dat"); -#endif + QFile::copy (fname, "./debug_lastOutput"); +#endif // RELEASE // Read the output file FILE* fp = fopen (fname, "r"); @@ -201,8 +207,8 @@ if (replace) *cmb << g_win->deleteSelection (); - for (const LDObject::Group group : groupsToReplace) - *cmb << g_win->deleteGroup (group); + for (const short colnum : colorsToReplace) + *cmb << g_win->deleteByColor (colnum); // Insert the new objects g_win->sel ().clear (); @@ -365,8 +371,8 @@ QDialog dlg; - LabeledWidget<QComboBox>* cmb_ingroup = new LabeledWidget<QComboBox> ("Input group", new QComboBox), - *cmb_cutgroup = new LabeledWidget<QComboBox> ("Cutter group", new QComboBox); + LabeledWidget<QComboBox>* cmb_incol = new LabeledWidget<QComboBox> ("Input", new QComboBox), + *cmb_cutcol = new LabeledWidget<QComboBox> ("Cutter", new QComboBox); QCheckBox* cb_colorize = new QCheckBox ("Colorize output"), *cb_nocondense = new QCheckBox ("No condensing"), *cb_repeatInverse = new QCheckBox ("Repeat inverse"), @@ -377,16 +383,16 @@ " cutter group with the input group. Both groups are cut by the intersection."); cb_edges->setWhatsThis ("Makes " APPNAME " try run Isecalc to create edgelines for the intersection."); - makeGroupSelector (cmb_ingroup->w ()); - makeGroupSelector (cmb_cutgroup->w ()); + makeColorSelector (cmb_incol->w ()); + makeColorSelector (cmb_cutcol->w ()); dsb_prescale->w ()->setMinimum (0.0f); dsb_prescale->w ()->setMaximum (10000.0f); dsb_prescale->w ()->setSingleStep (0.01f); dsb_prescale->w ()->setValue (1.0f); QVBoxLayout* layout = new QVBoxLayout (&dlg); - layout->addWidget (cmb_ingroup); - layout->addWidget (cmb_cutgroup); + layout->addWidget (cmb_incol); + layout->addWidget (cmb_cutcol); QHBoxLayout* cblayout = new QHBoxLayout; cblayout->addWidget (cb_colorize); @@ -405,12 +411,12 @@ if (!dlg.exec ()) return; - const LDObject::Group inGroup = (LDObject::Group) cmb_ingroup->w ()->currentIndex (), - cutGroup = (LDObject::Group) cmb_cutgroup->w ()->currentIndex (); + const short inCol = cmb_incol->w ()->itemData (cmb_incol->w ()->currentIndex ()).toInt (), + cutCol = cmb_cutcol->w ()->itemData (cmb_cutcol->w ()->currentIndex ()).toInt (); const bool repeatInverse = cb_repeatInverse->isChecked (); - if (inGroup == cutGroup) { - critical ("Cannot use the same group for both input and cutter!"); + if (inCol == cutCol) { + critical ("Cannot use the same color group for both input and cutter!"); goto exec; } @@ -438,14 +444,14 @@ str argv_normal = fmt ("%s %s %s %s", parms.chars (), inDATName.chars (), cutDATName.chars (), outDATName.chars ()); str argv_inverse = fmt ("%s %s %s %s", parms.chars (), cutDATName.chars (), inDATName.chars (), outDAT2Name.chars ()); - writeGroup (inGroup, inDATName); - writeGroup (cutGroup, cutDATName); + writeColorGroup (inCol, inDATName); + writeColorGroup (cutCol, cutDATName); runUtilityProcess (Intersector, prog_intersector, argv_normal); - insertOutput (outDATName, false, {inGroup}); + insertOutput (outDATName, false, {inCol}); if (repeatInverse) { runUtilityProcess (Intersector, prog_intersector, argv_inverse); - insertOutput (outDAT2Name, false, {cutGroup}); + insertOutput (outDAT2Name, false, {cutCol}); } if (cb_edges->isChecked ()) {
--- a/gui.cpp Tue May 07 23:37:46 2013 +0300 +++ b/gui.cpp Wed May 08 01:12:23 2013 +0300 @@ -46,19 +46,6 @@ extern_cfg (str, io_recentfiles); extern_cfg (bool, gl_axes); -const QColor g_GroupBackgrounds[] = { - QColor (0, 192, 255), // blue - QColor (144, 255, 0), // green - QColor (255, 128, 0), // orange - QColor (255, 255, 0), // yellow - QColor (160, 64, 255), // purple - QColor (0, 255, 160), // emerald -}; - -QIcon g_groupSelectorIcons[6]; - -const ushort g_numGroups = 2; - // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= @@ -90,16 +77,6 @@ setMinimumSize (320, 200); resize (800, 600); - // Init group bg icons - for (uchar i = 0; i < LDObject::NumGroups; ++i) { - QImage img (16, 16, QImage::Format_ARGB32); - QPainter paint (&img); - paint.fillRect (0, 0, 16, 16, Qt::black); - paint.fillRect (1, 1, 14, 14, g_GroupBackgrounds[i]); - - g_groupSelectorIcons[i] = QIcon (QPixmap::fromImage (img)); - } - connect (QCoreApplication::instance (), SIGNAL (aboutToQuit ()), this, SLOT (slot_lastSecondCleanup ())); } @@ -213,16 +190,6 @@ addMenuAction ("selectByColor"); // Select by Color addMenuAction ("selectByType"); // Select by Type - initMenu ("&Groups"); - for (uchar i = 0; i < LDObject::NumGroups; ++i) - addMenuAction (fmt ("group%c", 'A' + i)); // Group * - - menu->addSeparator (); // ----- - addMenuAction ("ungroup"); // Ungroup - menu->addSeparator (); // ----- - for (uchar i = 0; i < LDObject::NumGroups; ++i) - addMenuAction (fmt ("selGroup%c", 'A' + i)); // Select Group * - initMenu ("&Tools"); addMenuAction ("setColor"); // Set Color addMenuAction ("invert"); // Invert @@ -408,22 +375,6 @@ addToolBarAction ("ytruder"); addToolBarAction ("rectifier"); addToolBarAction ("intersector"); - - initSingleToolBar ("Groups"); - - // We need to create the group toolbar buttons manually so that we can - // set a custom background for them. - for (uchar i = 0; i < LDObject::NumGroups; ++i) { - QToolButton* btn = new QToolButton (this); - QColor col = g_GroupBackgrounds[i]; - - btn->setDefaultAction (findAction (fmt ("group%c", 'A' + i))); - btn->setStyleSheet (fmt ("QToolButton { background-color: \"#%.2X%.2X%.2X\"; }", - col.red (), col.green (), col.blue ())); - g_CurrentToolBar->addWidget (btn); - } - - addToolBarAction ("ungroup"); updateToolBars (); } @@ -705,8 +656,6 @@ color* col = getColor (obj->dColor); if (col) item->setForeground (col->qColor); - } else if (obj->group () != LDObject::NoGroup) { - item->setBackground (g_GroupBackgrounds[obj->group ()]); } obj->qObjListEntry = item; @@ -971,10 +920,10 @@ } // ======================================================================================================================================== -DelHistory* ForgeWindow::deleteGroup (const LDObject::Group group) { +DelHistory* ForgeWindow::deleteByColor (const short colnum) { vector<LDObject*> objs; for (LDObject* obj : g_curfile->m_objs) { - if (obj->group () != group) + if (!obj->isColored () || obj->dColor != colnum) continue; objs.push_back (obj); @@ -1036,22 +985,39 @@ } // ============================================================================= -void makeGroupSelector (QComboBox* box) { - ulong counts[6]; - uchar selGroup = 0; - memset (&counts[0], 0, sizeof counts); +void makeColorSelector (QComboBox* box) { + std::map<short, ulong> counts; - for (LDObject* obj : g_curfile->m_objs) - if (obj->group () != LDObject::NoGroup) - counts[obj->group ()]++; + for (LDObject* obj : g_curfile->m_objs) { + if (!obj->isColored ()) + continue; + + if (counts.find (obj->dColor) == counts.end ()) + counts[obj->dColor] = 1; + else + counts[obj->dColor]++; + } box->clear (); - for (uchar i = 0; i < LDObject::NumGroups; ++i) { - box->addItem (g_groupSelectorIcons[i], fmt ("%c (%lu objects)", QChar ('A' + i), counts[i])); + ulong row = 0; + for (const auto& pair : counts) { + const ushort size = 16; + color* col = getColor (pair.first); + assert (col != null); - if (counts[i] > 0 && selGroup == 0) - selGroup = i; + // Paint an icon for this color + QIcon ico; + QImage img (size, size, QImage::Format_ARGB32); + QPainter paint (&img); + paint.fillRect (QRect (0, 0, size, size), Qt::black); + paint.drawPixmap (QRect (1, 1, size - 2, size - 2), getIcon ("checkerboard"), QRect (0, 0, 8, 8)); + paint.fillRect (QRect (1, 1, size - 2, size - 2), QColor (col->qColor)); + ico = QIcon (QPixmap::fromImage (img)); + + box->addItem (ico, fmt ("[%d] %s (%lu object%s)", + pair.first, col->zName.chars (), pair.second, PLURAL (pair.second))); + box->setItemData (row, pair.first); + + ++row; } - - box->setCurrentIndex (selGroup); } \ No newline at end of file
--- a/gui.h Tue May 07 23:37:46 2013 +0300 +++ b/gui.h Wed May 08 01:12:23 2013 +0300 @@ -140,7 +140,7 @@ void spawnContextMenu (const QPoint pos); DelHistory* deleteObjVector (const std::vector<LDObject*> objs); DelHistory* deleteSelection (); - DelHistory* deleteGroup (const LDObject::Group group); + DelHistory* deleteByColor (const short colnum); GLRenderer* R () { return m_renderer; } std::vector<LDObject*>& sel () { return m_sel; } void setQuickColorMeta (std::vector<quickColorMetaEntry>& quickColorMeta) { @@ -244,7 +244,7 @@ bool confirm (str msg); void critical (str msg); QAction* findAction (str name); -void makeGroupSelector (QComboBox* box); +void makeColorSelector (QComboBox* box); // ----------------------------------------------------------------------------- // Pointer to the instance of ForgeWindow.
--- a/gui_actions.cpp Tue May 07 23:37:46 2013 +0300 +++ b/gui_actions.cpp Wed May 08 01:12:23 2013 +0300 @@ -405,50 +405,6 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -void setGroup (const LDObject::Group group) { - for (LDObject* obj : g_win->sel ()) - obj->setGroup (group); - - g_win->refresh (); -} - -// ============================================================================= -void selGroup (const LDObject::Group group) { - g_win->sel ().clear (); - - for (LDObject* obj : g_curfile->m_objs) { - if (obj->group () != group) - continue; // wrong group - - 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) -GROUP_ACTION (E, 5) -GROUP_ACTION (F, 6) - -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 ());
--- a/ldforge.pro Tue May 07 23:37:46 2013 +0300 +++ b/ldforge.pro Wed May 08 01:12:23 2013 +0300 @@ -6,9 +6,11 @@ TARGET = DEPENDPATH += . INCLUDEPATH += . -OBJECTS_DIR = build/ +OBJECTS_DIR = ./build/ RC_FILE = ldforge.rc RESOURCES = ldforge.qrc +MOC_DIR = ./autogen/ +RCC_DIR = ./autogen/ # Input HEADERS += bbox.h \
--- a/ldforge.qrc Tue May 07 23:37:46 2013 +0300 +++ b/ldforge.qrc Wed May 08 01:12:23 2013 +0300 @@ -47,7 +47,6 @@ <file>./icons/grid-coarse.png</file> <file>./icons/grid-fine.png</file> <file>./icons/grid-medium.png</file> - <file>./icons/group.png</file> <file>./icons/help.png</file> <file>./icons/history.png</file> <file>./icons/inline-deep.png</file> @@ -83,7 +82,6 @@ <file>./icons/triangle.png</file> <file>./icons/uncolorize.png</file> <file>./icons/undo.png</file> - <file>./icons/ungroup.png</file> <file>./icons/vertex.png</file> <file>./icons/visibility.png</file> <file>./icons/ytruder.png</file>
--- a/ldtypes.cpp Tue May 07 23:37:46 2013 +0300 +++ b/ldtypes.cpp Wed May 08 01:12:23 2013 +0300 @@ -60,7 +60,6 @@ LDObject::LDObject () { qObjListEntry = null; parent = null; - m_group = NoGroup; m_hidden = false; }
--- a/ldtypes.h Tue May 07 23:37:46 2013 +0300 +++ b/ldtypes.h Wed May 08 01:12:23 2013 +0300 @@ -73,12 +73,6 @@ NumTypes // Amount of object types }; - enum Group { - NoGroup = -1, - A = 0, B, C, D, E, F, - NumGroups - }; - LDObject (); virtual ~LDObject (); @@ -144,13 +138,10 @@ // Object list entry for this object QListWidgetItem* qObjListEntry; - Group group () const { return m_group; } - void setGroup (const Group group) { m_group = group; } bool hidden () const { return m_hidden; } void setHidden (const bool hidden) { m_hidden = hidden; } private: - Group m_group; bool m_hidden; };