Wed, 21 May 2014 13:18:19 +0300
- selecting an invertnext'd object now also selects the invertnext
changelog.txt | file | annotate | diff | comparison | revisions | |
src/ldObject.cc | file | annotate | diff | comparison | revisions | |
src/ldObject.h | file | annotate | diff | comparison | revisions | |
src/mainWindow.cc | file | annotate | diff | comparison | revisions |
--- a/changelog.txt Sat May 17 20:33:27 2014 +0300 +++ b/changelog.txt Wed May 21 13:18:19 2014 +0300 @@ -65,6 +65,8 @@ - Fixed: LDForge would sometimes crash during startup over uninitialized data in the GL renderer. - Fixed: The message log was still written with black text with dark backgrounds. +- Selecting an invertnext'd object now also selects the invertnext. + ================================================= == Changes in version 0.2.1 =================================================
--- a/src/ldObject.cc Sat May 17 20:33:27 2014 +0300 +++ b/src/ldObject.cc Wed May 21 13:18:19 2014 +0300 @@ -560,6 +560,21 @@ // ============================================================================= // +bool LDObject::previousIsInvertnext (LDBFCPtr& ptr) +{ + LDObjectPtr prev (previous()); + + if (prev != null && prev->type() == EBFC && prev.staticCast<LDBFC>()->statement() == LDBFC::InvertNext) + { + ptr = prev.staticCast<LDBFC>(); + return true; + } + + return false; +} + +// ============================================================================= +// void LDObject::move (Vertex vect) { if (hasMatrix()) @@ -851,6 +866,12 @@ { assert (document() != null); document()->addToSelection (self()); + + // If this object is inverted with INVERTNEXT, pick the INVERTNEXT as well. + LDBFCPtr invertnext; + + if (previousIsInvertnext (invertnext)) + invertnext->select(); } // ============================================================================= @@ -859,6 +880,12 @@ { assert (document() != null); document()->removeFromSelection (self()); + + // If this object is inverted with INVERTNEXT, deselect the INVERTNEXT as well. + LDBFCPtr invertnext; + + if (previousIsInvertnext (invertnext)) + invertnext->deselect(); } // =============================================================================
--- a/src/ldObject.h Sat May 17 20:33:27 2014 +0300 +++ b/src/ldObject.h Wed May 21 13:18:19 2014 +0300 @@ -56,6 +56,9 @@ class LDDocument; class LDSharedVertex; +class LDBFC; +using LDBFCPtr = QSharedPointer<LDBFC>; + // ============================================================================= // LDObject // @@ -138,6 +141,9 @@ // Object prior to this in the current file LDObjectPtr previous() const; + // Is the previous object INVERTNEXT? + bool previousIsInvertnext (LDBFCPtr& ptr); + // Replace this LDObject with another LDObject. Object is deleted in the process. void replace (LDObjectPtr other);
--- a/src/mainWindow.cc Sat May 17 20:33:27 2014 +0300 +++ b/src/mainWindow.cc Wed May 21 13:18:19 2014 +0300 @@ -473,6 +473,10 @@ } } + // The select() method calls may have selected additional items (i.e. invertnexts) + // Update it all now. + updateSelection(); + // Update the GL renderer LDObjectList compound = priorSelection + selection(); removeDuplicates (compound);