# HG changeset patch # User Teemu Piippo # Date 1414071892 -10800 # Node ID 5209474e9f38911b77631b90df1e7d78f636c5ec # Parent f0d14f16ae8794a4de9c76a9cffe0b780c6b0e24# Parent 3a69c2e0532cf43e24ac1796a5c1ace0b22f05b4 - merged with default diff -r f0d14f16ae87 -r 5209474e9f38 changelog.txt --- a/changelog.txt Tue Sep 09 02:44:02 2014 +0300 +++ b/changelog.txt Thu Oct 23 16:44:52 2014 +0300 @@ -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 diff -r f0d14f16ae87 -r 5209474e9f38 src/editmodes/drawMode.cc --- a/src/editmodes/drawMode.cc Tue Sep 09 02:44:02 2014 +0300 +++ b/src/editmodes/drawMode.cc Thu Oct 23 16:44:52 2014 +0300 @@ -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 +_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 (ln.angle(), 45)); + result.setCoordinate (relX, Grid::Snap (ln.x2(), Grid::Coordinate)); + result.setCoordinate (relY, Grid::Snap (ln.y2(), Grid::Coordinate)); + } + + return result; +} diff -r f0d14f16ae87 -r 5209474e9f38 src/editmodes/drawMode.h --- a/src/editmodes/drawMode.h Tue Sep 09 02:44:02 2014 +0300 +++ b/src/editmodes/drawMode.h Thu Oct 23 16:44:52 2014 +0300 @@ -32,4 +32,5 @@ bool mouseReleased (MouseEventData const& data) override; void endDraw(); bool preAddVertex (Vertex const&); + Vertex getCursorVertex() const; }; diff -r f0d14f16ae87 -r 5209474e9f38 src/glRenderer.cc --- a/src/glRenderer.cc Tue Sep 09 02:44:02 2014 +0300 +++ b/src/glRenderer.cc Thu Oct 23 16:44:52 2014 +0300 @@ -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 capture (4 * m_width * m_height); drawGLScene(); - glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap); - uint32* imgdata = reinterpret_cast (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); diff -r f0d14f16ae87 -r 5209474e9f38 src/glRenderer.h --- a/src/glRenderer.h Tue Sep 09 02:44:02 2014 +0300 +++ b/src/glRenderer.h Thu Oct 23 16:44:52 2014 +0300 @@ -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(); diff -r f0d14f16ae87 -r 5209474e9f38 src/ldDocument.cc --- a/src/ldDocument.cc Tue Sep 09 02:44:02 2014 +0300 +++ b/src/ldDocument.cc Thu Oct 23 16:44:52 2014 +0300 @@ -167,13 +167,11 @@ // ============================================================================= // -extern QMap 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) { @@ -187,9 +185,7 @@ } else { - print ("Removing %1 from explicit documents...\n", this); g_explicitDocuments.removeOne (self().toStrongRef()); - print ("Removed %1", this); print ("Closed %1", name()); } diff -r f0d14f16ae87 -r 5209474e9f38 src/mainWindow.cc --- a/src/mainWindow.cc Tue Sep 09 02:44:02 2014 +0300 +++ b/src/mainWindow.cc Thu Oct 23 16:44:52 2014 +0300 @@ -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 (toolbarname.toString()); + + if (toolbar != null) + toolbar->hide(); + } } MainWindow::~MainWindow() @@ -630,10 +639,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()) + { + if (toolbar->isHidden()) + cfg::HiddenToolbars << toolbar->objectName(); + } + + // Save the configuration before leaving. Config::Save(); - ev->accept(); } diff -r f0d14f16ae87 -r 5209474e9f38 src/version.h --- a/src/version.h Tue Sep 09 02:44:02 2014 +0300 +++ b/src/version.h Thu Oct 23 16:44:52 2014 +0300 @@ -28,7 +28,7 @@ // Version number // #define VERSION_MAJOR 0 -#define VERSION_MINOR 3 +#define VERSION_MINOR 4 #define VERSION_PATCH 0 //