Wed, 30 Apr 2014 23:44:50 +0300
- made the mouse-hover object highlight togglable from configuration
- somewhat optimized vbo merging
src/configDialog.cc | file | annotate | diff | comparison | revisions | |
src/glRenderer.cc | file | annotate | diff | comparison | revisions | |
src/glRenderer.h | file | annotate | diff | comparison | revisions | |
ui/config.ui | file | annotate | diff | comparison | revisions |
--- a/src/configDialog.cc Wed Apr 30 04:25:32 2014 +0300 +++ b/src/configDialog.cc Wed Apr 30 23:44:50 2014 +0300 @@ -76,6 +76,7 @@ EXTERN_CFGENTRY (Float, gridMediumAngleSnap); EXTERN_CFGENTRY (Float, gridFineCoordinateSnap); EXTERN_CFGENTRY (Float, gridFineAngleSnap); +EXTERN_CFGENTRY (Bool, highlightObjectBelowCursor) const char* g_extProgPathFilter = #ifdef _WIN32 @@ -158,6 +159,7 @@ ui->gridMediumAngleSnap->setValue (cfg::gridMediumAngleSnap); ui->gridFineCoordinateSnap->setValue (cfg::gridFineCoordinateSnap); ui->gridFineAngleSnap->setValue (cfg::gridFineAngleSnap); + ui->highlightObjectBelowCursor->setChecked (cfg::highlightObjectBelowCursor); initExtProgs(); selectPage (deftab); @@ -297,6 +299,7 @@ cfg::defaultName = ui->m_profileName->text(); cfg::defaultLicense = ui->m_profileLicense->currentIndex(); cfg::antiAliasedLines = ui->m_aa->isChecked(); + cfg::highlightObjectBelowCursor = ui->highlightObjectBelowCursor->isChecked(); // Rebuild the quick color toolbar g_win->setQuickColors (quickColors);
--- a/src/glRenderer.cc Wed Apr 30 04:25:32 2014 +0300 +++ b/src/glRenderer.cc Wed Apr 30 23:44:50 2014 +0300 @@ -63,20 +63,21 @@ { 0, 1, 0, 2, 0, 0, 0, 0, 2 }, }; -CFGENTRY (String, backgroundColor, "#FFFFFF") -CFGENTRY (String, mainColor, "#A0A0A0") -CFGENTRY (Float, mainColorAlpha, 1.0) -CFGENTRY (Int, lineThickness, 2) -CFGENTRY (Bool, bfcRedGreenView, false) -CFGENTRY (Int, camera, GLRenderer::EFreeCamera) -CFGENTRY (Bool, blackEdges, false) -CFGENTRY (Bool, drawAxes, false) -CFGENTRY (Bool, drawWireframe, false) -CFGENTRY (Bool, useLogoStuds, false) -CFGENTRY (Bool, antiAliasedLines, true) -CFGENTRY (Bool, drawLineLengths, true) -CFGENTRY (Bool, drawAngles, false) -CFGENTRY (Bool, randomColors, false) +CFGENTRY (String, backgroundColor, "#FFFFFF") +CFGENTRY (String, mainColor, "#A0A0A0") +CFGENTRY (Float, mainColorAlpha, 1.0) +CFGENTRY (Int, lineThickness, 2) +CFGENTRY (Bool, bfcRedGreenView, false) +CFGENTRY (Int, camera, GLRenderer::EFreeCamera) +CFGENTRY (Bool, blackEdges, false) +CFGENTRY (Bool, drawAxes, false) +CFGENTRY (Bool, drawWireframe, false) +CFGENTRY (Bool, useLogoStuds, false) +CFGENTRY (Bool, antiAliasedLines, true) +CFGENTRY (Bool, drawLineLengths, true) +CFGENTRY (Bool, drawAngles, false) +CFGENTRY (Bool, randomColors, false) +CFGENTRY (Bool, highlightObjectBelowCursor, true) // argh const char* g_CameraNames[7] = @@ -136,7 +137,8 @@ m_hoverpos = g_origin; m_toolTipTimer = new QTimer (this); m_toolTipTimer->setSingleShot (true); - m_objectAtCursor = 0; + m_objectAtCursor = null; + m_isCameraMoving = false; connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (slot_toolTipTimer())); m_thickBorderPen = QPen (QColor (0, 0, 0, 208), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); @@ -1127,6 +1129,7 @@ int dx = ev->x() - m_pos.x(); int dy = ev->y() - m_pos.y(); m_totalmove += abs (dx) + abs (dy); + setCameraMoving (false); const bool left = ev->buttons() & Qt::LeftButton, mid = ev->buttons() & Qt::MidButton, @@ -1137,6 +1140,7 @@ pan (X) += 0.03f * dx * (zoom() / 7.5f); pan (Y) -= 0.03f * dy * (zoom() / 7.5f); m_panning = true; + setCameraMoving (true); } elif (left && not m_rangepick && camera() == EFreeCamera) { @@ -1145,6 +1149,7 @@ clampAngle (rot (X)); clampAngle (rot (Y)); + setCameraMoving (true); } // Start the tool tip timer @@ -1160,10 +1165,7 @@ // Update rect vertices since m_hoverpos may have changed updateRectVerts(); - - // highlightCursorObject(); - update(); } @@ -1189,7 +1191,7 @@ zoomNotch (ev->delta() > 0); zoom() = clamp (zoom(), 0.01, 10000.0); - + setCameraMoving (true); update(); ev->accept(); } @@ -2146,26 +2148,38 @@ // void GLRenderer::highlightCursorObject() { - setPicking (true); - drawGLScene(); - setPicking (false); + if (not cfg::highlightObjectBelowCursor && objectAtCursor() == null) + return; - unsigned char pixel[4]; - glReadPixels (m_pos.x(), m_height - m_pos.y(), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel[0]); LDObject* newObject = null; LDObject* oldObject = objectAtCursor(); - qint32 newIndex = pixel[0] * 0x10000 | pixel[1] * 0x100 | pixel[2]; + qint32 newIndex; + + if (isCameraMoving() || not cfg::highlightObjectBelowCursor) + { + newIndex = 0; + } + else + { + setPicking (true); + drawGLScene(); + setPicking (false); + + unsigned char pixel[4]; + glReadPixels (m_pos.x(), m_height - m_pos.y(), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel[0]); + newIndex = pixel[0] * 0x10000 | pixel[1] * 0x100 | pixel[2]; + } if (newIndex != (oldObject != null ? oldObject->id() : 0)) { if (newIndex != 0) newObject = LDObject::fromID (newIndex); + setObjectAtCursor (newObject); + if (oldObject != null) compileObject (oldObject); - setObjectAtCursor (newObject); - if (newObject != null) compileObject (newObject); }
--- a/src/glRenderer.h Wed Apr 30 04:25:32 2014 +0300 +++ b/src/glRenderer.h Wed Apr 30 23:44:50 2014 +0300 @@ -150,6 +150,7 @@ PROPERTY (public, EditMode, editMode, setEditMode, CUSTOM_WRITE) PROPERTY (private, GLCompiler*, compiler, setCompiler, STOCK_WRITE) PROPERTY (private, LDObject*, objectAtCursor, setObjectAtCursor, STOCK_WRITE) + PROPERTY (private, bool, isCameraMoving, setCameraMoving, STOCK_WRITE) public: GLRenderer (QWidget* parent = null);
--- a/ui/config.ui Wed Apr 30 04:25:32 2014 +0300 +++ b/ui/config.ui Wed Apr 30 23:44:50 2014 +0300 @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>717</width> - <height>399</height> + <height>407</height> </rect> </property> <property name="windowTitle"> @@ -302,17 +302,11 @@ </widget> </item> <item> - <spacer name="verticalSpacer_6"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <widget class="QCheckBox" name="highlightObjectBelowCursor"> + <property name="text"> + <string>Highlight object below cursor</string> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> + </widget> </item> </layout> </item>