Wed, 05 Nov 2014 23:41:58 +0200
- merged two default heads
--- a/changelog.txt Sat Sep 20 14:47:13 2014 +0300 +++ b/changelog.txt Wed Nov 05 23:41:58 2014 +0200 @@ -1,6 +1,14 @@ + Changes in version 0.4 + + + ++ - Pressing Ctrl while drawing now causes the new line to become locked to cardinal directions, ala Gimp. +- - Selecting an invertnext'd object no longer selects the invertnext (reverted feature from 0.3, caused too many problems). + + Changes in version 0.3
--- a/src/editmodes/drawMode.cc Sat Sep 20 14:47:13 2014 +0300 +++ b/src/editmodes/drawMode.cc Wed Nov 05 23:41:58 2014 +0200 @@ -21,6 +21,7 @@ #include "drawMode.h" #include "../ldObject.h" #include "../glRenderer.h" +#include "../miscallenous.h" DrawMode::DrawMode (GLRenderer* renderer) : Super (renderer) {} @@ -40,7 +41,7 @@ // Draw the cursor vertex as the last one in the list. if (poly.size() < 4) - poly << renderer()->position3D(); + poly << getCursorVertex(); renderPolygon (painter, poly, true, true); } @@ -74,7 +75,7 @@ return true; } - addDrawnVertex (renderer()->position3D()); + addDrawnVertex (getCursorVertex()); return true; } @@ -127,3 +128,36 @@ finishDraw (objs); } + +template<typename _Type> +_Type IntervalClamp (_Type a, _Type interval) +{ + _Type remainder = a % interval; + + if (remainder >= float (interval / 2)) + a += interval; + + a -= remainder; + return a; +} + +Vertex DrawMode::getCursorVertex() const +{ + Vertex result = renderer()->position3D(); + + if (renderer()->keyboardModifiers() & Qt::ControlModifier + and not m_drawedVerts.isEmpty()) + { + Vertex const& v0 = m_drawedVerts.last(); + Vertex const& v1 = result; + Axis relX, relY; + + renderer()->getRelativeAxes (relX, relY); + QLineF ln (v0[relX], v0[relY], v1[relX], v1[relY]); + ln.setAngle (IntervalClamp<int> (ln.angle(), 45)); + result.setCoordinate (relX, Grid::Snap (ln.x2(), Grid::Coordinate)); + result.setCoordinate (relY, Grid::Snap (ln.y2(), Grid::Coordinate)); + } + + return result; +}
--- a/src/editmodes/drawMode.h Sat Sep 20 14:47:13 2014 +0300 +++ b/src/editmodes/drawMode.h Wed Nov 05 23:41:58 2014 +0200 @@ -32,4 +32,5 @@ bool mouseReleased (MouseEventData const& data) override; void endDraw(); bool preAddVertex (Vertex const&); + Vertex getCursorVertex() const; };
--- a/src/glRenderer.cc Sat Sep 20 14:47:13 2014 +0300 +++ b/src/glRenderer.cc Wed Nov 05 23:41:58 2014 +0200 @@ -1296,10 +1296,7 @@ // void GLRenderer::zoomNotch (bool inward) { - if (zoom() > 15) - zoom() *= inward ? 0.833f : 1.2f; - else - zoom() += inward ? -1.2f : 1.2f; + zoom() *= inward ? 0.833f : 1.2f; } // ============================================================================= @@ -1313,14 +1310,10 @@ bool lastfilled = false; bool firstrun = true; - const uint32 white = 0xFFFFFFFF; + enum { black = 0xFF000000 }; bool inward = true; - const int w = m_width, h = m_height; int runaway = 50; - glClearColor (1.0, 1.0, 1.0, 1.0); - glDisable (GL_DITHER); - // Use the pick list while drawing the scene, this way we can tell whether borders // are background or not. setPicking (true); @@ -1329,24 +1322,22 @@ { if (zoom() > 10000.0 or zoom() < 0.0) { - // Obviously, there's nothing to draw if we get here. - // Default to 30.0f and break out. + // Nothing to draw if we get here. zoom() = 30.0; break; } zoomNotch (inward); - - uchar* cap = new uchar[4 * w * h]; + QVector<unsigned char> capture (4 * m_width * m_height); drawGLScene(); - glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap); - uint32* imgdata = reinterpret_cast<uint32*> (cap); + glReadPixels (0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, capture.data()); + QImage image (capture.constData(), m_width, m_height, QImage::Format_ARGB32); bool filled = false; // Check the top and bottom rows - for (int i = 0; i < w; ++i) + for (int i = 0; i < image.width(); ++i) { - if (imgdata[i] != white or imgdata[((h - 1) * w) + i] != white) + if (image.pixel (i, 0) != black or image.pixel (i, m_height - 1) != black) { filled = true; break; @@ -1356,9 +1347,9 @@ // Left and right edges if (filled == false) { - for (int i = 0; i < h; ++i) + for (int i = 0; i < image.height(); ++i) { - if (imgdata[i * w] != white or imgdata[(i * w) + w - 1] != white) + if (image.pixel (0, i) != black or image.pixel (m_width - 1, i) != black) { filled = true; break; @@ -1366,8 +1357,6 @@ } } - delete[] cap; - if (firstrun) { // If this is the first run, we don't know enough to determine @@ -1397,7 +1386,6 @@ lastfilled = filled; } - setBackground(); setPicking (false); } @@ -1405,15 +1393,7 @@ // void GLRenderer::zoomAllToFit() { - ECamera oldcam = camera(); - - for (ECamera cam = EFirstCamera; cam < ENumCameras; ++cam) - { - setCamera (cam); - zoomToFit(); - } - - setCamera (oldcam); + zoomToFit(); } // ============================================================================= @@ -1650,6 +1630,11 @@ return g_FixedCameras[camera()].negatedDepth ? -1 : 1; } +Qt::KeyboardModifiers GLRenderer::keyboardModifiers() const +{ + return m_keymods; +} + LDFixedCamera const& GetFixedCamera (ECamera cam) { assert (cam != EFreeCamera);
--- a/src/glRenderer.h Sat Sep 20 14:47:13 2014 +0300 +++ b/src/glRenderer.h Wed Nov 05 23:41:58 2014 +0200 @@ -169,6 +169,7 @@ Axis getRelativeZ() const; LDGLOverlay& getOverlay (int newcam); uchar* getScreencap (int& w, int& h); + Qt::KeyboardModifiers keyboardModifiers() const; void hardRefresh(); void highlightCursorObject(); void initGLData();
--- a/src/ldDocument.cc Sat Sep 20 14:47:13 2014 +0300 +++ b/src/ldDocument.cc Wed Nov 05 23:41:58 2014 +0200 @@ -168,13 +168,11 @@ // ============================================================================= // -extern QMap<long, LDObjectWeakPtr> g_allObjects; void LDDocument::setImplicit (bool const& a) { if (m_isImplicit != a) { m_isImplicit = a; - print ("Setting implicity of %1 to %2\n", this, a ? "true" : "false"); if (a == false) { @@ -188,9 +186,7 @@ } else { - print ("Removing %1 from explicit documents...\n", this); g_explicitDocuments.removeOne (self().toStrongRef()); - print ("Removed %1", this); print ("Closed %1", name()); }
--- a/src/mainWindow.cc Sat Sep 20 14:47:13 2014 +0300 +++ b/src/mainWindow.cc Wed Nov 05 23:41:58 2014 +0200 @@ -58,6 +58,7 @@ CFGENTRY (Bool, ColorizeObjectsList, true) CFGENTRY (String, QuickColorToolbar, "4:25:14:27:2:3:11:1:22:|:0:72:71:15") CFGENTRY (Bool, ListImplicitFiles, false) +CFGENTRY (List, HiddenToolbars, {}) EXTERN_CFGENTRY (List, RecentFiles) EXTERN_CFGENTRY (Bool, DrawAxes) EXTERN_CFGENTRY (String, MainColor) @@ -125,6 +126,14 @@ connect (ui->ringToolSegments, SIGNAL (valueChanged (int)), this, SLOT (circleToolSegmentsChanged())); circleToolSegmentsChanged(); // invoke it manually for initial label text + + for (QVariant const& toolbarname : cfg::HiddenToolbars) + { + QToolBar* toolbar = findChild<QToolBar*> (toolbarname.toString()); + + if (toolbar != null) + toolbar->hide(); + } } MainWindow::~MainWindow() @@ -632,10 +641,17 @@ return; } - // Save the configuration before leaving so that, for instance, grid choice - // is preserved across instances. + // Save the toolbar set + cfg::HiddenToolbars.clear(); + + for (QToolBar* toolbar : findChildren<QToolBar*>()) + { + if (toolbar->isHidden()) + cfg::HiddenToolbars << toolbar->objectName(); + } + + // Save the configuration before leaving. Config::Save(); - ev->accept(); }