Sat, 04 May 2013 01:57:42 +0300
Added axes rendering
colors.cpp | file | annotate | diff | comparison | revisions | |
gldraw.cpp | file | annotate | diff | comparison | revisions | |
gldraw.h | file | annotate | diff | comparison | revisions | |
gui.cpp | file | annotate | diff | comparison | revisions | |
gui_actions.cpp | file | annotate | diff | comparison | revisions | |
gui_editactions.cpp | file | annotate | diff | comparison | revisions | |
icons/axes.png | file | annotate | diff | comparison | revisions | |
zz_configDialog.cpp | file | annotate | diff | comparison | revisions | |
zz_configDialog.h | file | annotate | diff | comparison | revisions |
--- a/colors.cpp Fri May 03 23:46:46 2013 +0300 +++ b/colors.cpp Sat May 04 01:57:42 2013 +0300 @@ -37,12 +37,12 @@ col = new color; col->zColorString = "#AAAAAA"; col->qColor = col->zColorString.chars (); - col->qEdge = "#000000"; + col->qEdge = Qt::black; g_LDColors[maincolor] = col; col = new color; col->zColorString = "#000000"; - col->qEdge = col->qColor = col->zColorString.chars (); + col->qEdge = col->qColor = Qt::black; g_LDColors[edgecolor] = col; parseLDConfig ();
--- a/gldraw.cpp Fri May 03 23:46:46 2013 +0300 +++ b/gldraw.cpp Sat May 04 01:57:42 2013 +0300 @@ -55,6 +55,8 @@ cfg (bool, gl_colorbfc, true); cfg (bool, gl_selflash, false); cfg (int, gl_camera, GLRenderer::Free); +cfg (bool, gl_blackedges, true); +cfg (bool, gl_axes, false); // CameraIcon::img is a heap-allocated QPixmap because otherwise it gets // initialized before program gets to main() and constructs a QApplication @@ -248,23 +250,31 @@ qCol = getMainColor (); else { color* col = getColor (obj->dColor); + qCol = col->qColor; + } + + if (obj->dColor == edgecolor) { + qCol = Qt::black; + color* col; - if (col != null) - qCol = col->qColor; - else { - // The color was unknown. Use main color to make the object at least - // not appear pitch-black. + if (!gl_blackedges && obj->parent != null && (col = getColor (obj->parent->dColor)) != null) + qCol = col->qEdge; + } + + if (qCol.isValid () == false) { + // The color was unknown. Use main color to make the object at least + // not appear pitch-black. + if (obj->dColor != edgecolor) qCol = getMainColor (); - - // Warn about the unknown colors, but only once. - for (short i : g_daWarnedColors) - if (obj->dColor == i) - return; - - printf ("%s: Unknown color %d!\n", __func__, obj->dColor); - g_daWarnedColors.push_back (obj->dColor); - return; - } + + // Warn about the unknown colors, but only once. + for (short i : g_daWarnedColors) + if (obj->dColor == i) + return; + + printf ("%s: Unknown color %d!\n", __func__, obj->dColor); + g_daWarnedColors.push_back (obj->dColor); + return; } long r = qCol.red (), @@ -331,6 +341,15 @@ glMatrixMode (GL_MODELVIEW); } +const struct GLAxis { + const QColor col; + const vertex vert; +} g_GLAxes[3] = { + { QColor (255, 0, 0), vertex (10000, 0, 0) }, + { QColor (128, 192, 0), vertex (0, 10000, 0) }, + { QColor (0, 160, 192), vertex (0, 0, 10000) }, +}; + void GLRenderer::drawGLScene () { if (g_CurrentFile == null) return; @@ -369,6 +388,9 @@ for (LDObject* obj : g_CurrentFile->objects) glCallList (picking == false ? obj->uGLList : obj->uGLPickList); + if (gl_axes && !picking) + glCallList (axeslist); + glPopMatrix (); glMatrixMode (GL_MODELVIEW); } @@ -378,14 +400,14 @@ // ============================================================================= void GLRenderer::paintEvent (QPaintEvent* ev) { Q_UNUSED (ev) + vw = zoom; + vh = (height * vw) / width; drawGLScene (); QPainter paint (this); QFontMetrics metrics = QFontMetrics (QFont ()); paint.setRenderHint (QPainter::Antialiasing); - vw = zoom; - vh = (height * vw) / width; m_hoverpos = g_Origin; if (m_camera != Free) { @@ -531,6 +553,18 @@ objLists.push_back (obj->uGLList); } + + // Compile axes + axeslist = glGenLists (1); + glNewList (axeslist, GL_COMPILE); + glBegin (GL_LINES); + for (const GLAxis& ax : g_GLAxes) { + qglColor (ax.col); + compileVertex (ax.vert); + compileVertex (-ax.vert); + } + glEnd (); + glEndList (); } // ============================================================================= @@ -642,11 +676,11 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -void GLRenderer::compileVertex (vertex& vert) { +void GLRenderer::compileVertex (const vertex& vrt) { glVertex3d ( - (vert[X] + g_objOffset[0]) / g_storedBBoxSize, - -(vert[Y] + g_objOffset[1]) / g_storedBBoxSize, - -(vert[Z] + g_objOffset[2]) / g_storedBBoxSize); + (vrt[X] + g_objOffset[0]) / g_storedBBoxSize, + -(vrt[Y] + g_objOffset[1]) / g_storedBBoxSize, + -(vrt[Z] + g_objOffset[2]) / g_storedBBoxSize); } // =============================================================================
--- a/gldraw.h Fri May 03 23:46:46 2013 +0300 +++ b/gldraw.h Sat May 04 01:57:42 2013 +0300 @@ -95,11 +95,12 @@ QPoint pos, rangeStart; QPen thinBorderPen, thickBorderPen; Camera toolTipCamera; + uint axeslist; void compileOneObject (LDObject* obj); template<class T> void compileSubObject (LDObject* obj, const GLenum eGLType, const short dVerts); - void compileVertex (vertex& vrt); + void compileVertex (const vertex& vrt); void clampAngle (double& fAngle); void setObjectColor (LDObject* obj); void drawGLScene ();
--- a/gui.cpp Fri May 03 23:46:46 2013 +0300 +++ b/gui.cpp Sat May 04 01:57:42 2013 +0300 @@ -94,6 +94,7 @@ EXTERN_ACTION (screencap) EXTERN_ACTION (editObject) EXTERN_ACTION (uncolorize) +EXTERN_ACTION (axes) #ifndef RELEASE EXTERN_ACTION (addTestQuad) @@ -108,6 +109,7 @@ cfg (int, gui_toolbar_iconsize, 24); cfg (str, gui_colortoolbar, "16:24:|:0:1:2:3:4:5:6:7"); extern_cfg (str, io_recentfiles); +extern_cfg (bool, gl_axes); // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -172,11 +174,14 @@ connect (qAct, SIGNAL (triggered ()), this, SLOT (slot_action ())); } - // Grid actions are checkable + // Grid actions and axes are checkable ACTION (gridCoarse)->setCheckable (true); ACTION (gridMedium)->setCheckable (true); ACTION (gridFine)->setCheckable (true); + ACTION (axes)->setCheckable (true); + ACTION (axes)->setChecked (gl_axes); + // things not implemented yet QAction* const qaDisabledActions[] = { ACTION (help), @@ -211,6 +216,7 @@ // View menu qViewMenu = menuBar ()->addMenu (tr ("&View")); qViewMenu->addAction (ACTION (resetView)); // Reset View + qViewMenu->addAction (ACTION (axes)); // Draw Axes qViewMenu->addSeparator (); // ----- qViewMenu->addAction (ACTION (screencap)); // Screencap Part qViewMenu->addAction (ACTION (showHistory)); // Edit History @@ -395,6 +401,10 @@ addToolBarBreak (Qt::TopToolBarArea); // ========================================== + initSingleToolBar ("View"); + g_CurrentToolBar->addAction (ACTION (axes)); + + // ========================================== // Color toolbar qColorToolBar = new QToolBar ("Quick Colors"); addToolBar (Qt::RightToolBarArea, qColorToolBar); @@ -415,6 +425,7 @@ g_CurrentToolBar->addAction (ACTION (screencap)); g_CurrentToolBar->addAction (ACTION (uncolorize)); + updateToolBars (); }
--- a/gui_actions.cpp Fri May 03 23:46:46 2013 +0300 +++ b/gui_actions.cpp Sat May 04 01:57:42 2013 +0300 @@ -382,6 +382,16 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= +extern_cfg (bool, gl_axes); +MAKE_ACTION (axes, "Draw Axes", "axes", "Toggles drawing of axes", (0)) { + gl_axes = !gl_axes; + ACTION (axes)->setChecked (gl_axes); + g_ForgeWindow->R->update (); +} + +// ============================================================================= +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +// ============================================================================= // Debug things #ifndef RELEASE MAKE_ACTION (addTestQuad, "Add Test Quad", "add-quad", "Adds a test quad.", (0)) {
--- a/gui_editactions.cpp Fri May 03 23:46:46 2013 +0300 +++ b/gui_editactions.cpp Sat May 04 01:57:42 2013 +0300 @@ -28,7 +28,7 @@ vector<LDObject*> g_Clipboard; -cfg (bool, edit_insertSchemanticsOnly, false); +cfg (bool, edit_schemanticinline, false); // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
--- a/zz_configDialog.cpp Fri May 03 23:46:46 2013 +0300 +++ b/zz_configDialog.cpp Sat May 04 01:57:42 2013 +0300 @@ -39,7 +39,8 @@ extern_cfg (int, gui_toolbar_iconsize); extern_cfg (str, gui_colortoolbar); extern_cfg (bool, gl_selflash); -extern_cfg (bool, edit_insertSchemanticsOnly); +extern_cfg (bool, edit_schemanticinline); +extern_cfg (bool, gl_blackedges); ConfigDialog* g_ConfigDialog = null; @@ -132,8 +133,13 @@ cb_selFlash = new QCheckBox ("Selection flash"); INIT_CHECKBOX (cb_selFlash, gl_selflash) - cb_insertSchemanticsOnly = new QCheckBox ("Only insert schemantic objects from a file"); - INIT_CHECKBOX (cb_insertSchemanticsOnly, edit_insertSchemanticsOnly) + cb_blackEdges = new QCheckBox ("Black edges"); + cb_blackEdges->setWhatsThis ("If this is set, all edgelines appear black. If this is " + "not set, edge lines take their color as defined in LDConfig.ldr"); + INIT_CHECKBOX (cb_blackEdges, gl_blackedges) + + cb_schemanticInline = new QCheckBox ("Only insert schemantic objects from a file"); + INIT_CHECKBOX (cb_schemanticInline, edit_schemanticinline) QGridLayout* layout = new QGridLayout; layout->addWidget (lb_LDrawPath, 0, 0); @@ -155,7 +161,8 @@ layout->addWidget (cb_colorize, 4, 0, 1, 4); layout->addWidget (cb_colorBFC, 5, 0, 1, 4); layout->addWidget (cb_selFlash, 6, 0, 1, 4); - layout->addWidget (cb_insertSchemanticsOnly, 7, 0, 1, 4); + layout->addWidget (cb_blackEdges, 7, 0, 1, 4); + layout->addWidget (cb_schemanticInline, 8, 0, 1, 4); mainTab->setLayout (layout); // Add the tab to the manager @@ -172,6 +179,12 @@ lw_shortcutList = new QListWidget; qLayout = new QGridLayout; + shortcutsTab->setWhatsThis ("Here you can alter keyboard shortcuts for " + "almost all LDForge actions. Only exceptions are the controls for the " + "viewport. Use the set button to set a key shortcut, clear to remove it " + "and reset to restore the shortcut to its default value.\n" + "\tShortcut changes apply immediately after closing this dialog." ); + // Init table items ulong i = 0; for (actionmeta meta : g_ActionMeta) { @@ -608,7 +621,8 @@ APPLY_CHECKBOX (dlg.cb_colorize, lv_colorize) APPLY_CHECKBOX (dlg.cb_colorBFC, gl_colorbfc) APPLY_CHECKBOX (dlg.cb_selFlash, gl_selflash) - APPLY_CHECKBOX (dlg.cb_insertSchemanticsOnly, edit_insertSchemanticsOnly) + APPLY_CHECKBOX (dlg.cb_schemanticInline, edit_schemanticinline) + APPLY_CHECKBOX (dlg.cb_blackEdges, gl_blackedges) gl_maincolor_alpha = ((double)dlg.sl_viewFgAlpha->value ()) / 10.0f; gl_linethickness = dlg.sl_lineThickness->value ();
--- a/zz_configDialog.h Fri May 03 23:46:46 2013 +0300 +++ b/zz_configDialog.h Sat May 04 01:57:42 2013 +0300 @@ -44,7 +44,8 @@ QLineEdit* le_LDrawPath; QPushButton* pb_findLDrawPath; QPushButton* pb_viewBg, *pb_viewFg; - QCheckBox* cb_colorize, *cb_colorBFC, *cb_selFlash, *cb_insertSchemanticsOnly; + QCheckBox* cb_colorize, *cb_colorBFC, *cb_selFlash, *cb_schemanticInline, + *cb_blackEdges; QSlider* sl_viewFgAlpha, *sl_lineThickness, *sl_iconSize; // =========================================================================