Mon, 25 Mar 2013 22:52:53 +0200
Draw main color in the selection dialog based on preferences, take subfiles into account when calculating bbox
bbox.cpp | file | annotate | diff | comparison | revisions | |
bbox.h | file | annotate | diff | comparison | revisions | |
colors.cpp | file | annotate | diff | comparison | revisions | |
file.cpp | file | annotate | diff | comparison | revisions | |
zz_colorSelectDialog.cpp | file | annotate | diff | comparison | revisions |
--- a/bbox.cpp Mon Mar 25 17:04:18 2013 +0200 +++ b/bbox.cpp Mon Mar 25 22:52:53 2013 +0200 @@ -34,43 +34,60 @@ if (!g_CurrentFile) return; - for (LDObject* obj : g_CurrentFile->objects) { - switch (obj->getType ()) { - case OBJ_Line: - { - LDLine* line = static_cast<LDLine*> (obj); - for (short i = 0; i < 2; ++i) - checkVertex (line->vaCoords[i]); - } - break; - - case OBJ_Triangle: - { - LDTriangle* tri = static_cast<LDTriangle*> (obj); - for (short i = 0; i < 3; ++i) - checkVertex (tri->vaCoords[i]); + for (LDObject* obj : g_CurrentFile->objects) + checkObject (obj); +} + +// ============================================================================= +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +// ============================================================================= +void bbox::checkObject (LDObject* obj) { + switch (obj->getType ()) { + case OBJ_Line: + { + LDLine* line = static_cast<LDLine*> (obj); + for (short i = 0; i < 2; ++i) + checkVertex (line->vaCoords[i]); + } + break; + + case OBJ_Triangle: + { + LDTriangle* tri = static_cast<LDTriangle*> (obj); + for (short i = 0; i < 3; ++i) + checkVertex (tri->vaCoords[i]); + } + break; + + case OBJ_Quad: + { + LDQuad* quad = static_cast<LDQuad*> (obj); + for (short i = 0; i < 4; ++i) + checkVertex (quad->vaCoords[i]); + } + break; + + case OBJ_CondLine: + { + LDCondLine* line = static_cast<LDCondLine*> (obj); + for (short i = 0; i < 4; ++i) + checkVertex (line->vaCoords[i]); + } + break; + + case OBJ_Subfile: + { + LDSubfile* ref = static_cast<LDSubfile*> (obj); + vector<LDObject*> objs = ref->inlineContents (true, true); + + for (LDObject* obj : objs) { + checkObject (obj); + delete obj; } - break; - - case OBJ_Quad: - { - LDQuad* quad = static_cast<LDQuad*> (obj); - for (short i = 0; i < 4; ++i) - checkVertex (quad->vaCoords[i]); - } - break; - - case OBJ_CondLine: - { - LDCondLine* line = static_cast<LDCondLine*> (obj); - for (short i = 0; i < 4; ++i) - checkVertex (line->vaCoords[i]); - } - break; - - default: - break; } + + default: + break; } }
--- a/bbox.h Mon Mar 25 17:04:18 2013 +0200 +++ b/bbox.h Mon Mar 25 22:52:53 2013 +0200 @@ -39,6 +39,7 @@ double calcSize (); private: + void checkObject (LDObject* obj); void checkVertex (vertex v); };
--- a/colors.cpp Mon Mar 25 17:04:18 2013 +0200 +++ b/colors.cpp Mon Mar 25 22:52:53 2013 +0200 @@ -48,7 +48,7 @@ {26, "Magenta", "#FFA0FF", 1.0}, {27, "Lime", "#00FF00", 1.0}, {28, "Sand", "#989070", 1.0}, - {32, "Smoke", "#101010", 0.5}, + {32, "Lens Black", "#101010", 0.8}, {33, "Trans Blue", "#0000FF", 0.5}, {34, "Trans Green", "#008000", 0.5}, {35, "Trans Teal", "#008080", 0.5}, @@ -56,7 +56,7 @@ {37, "Trans Dk Pink", "#C00060", 0.5}, {38, "Trans Brown", "#604000", 0.5}, {39, "Trans Gray", "#989890", 0.5}, - {40, "Trans Dk Gray", "#6E6D62", 0.5}, + {40, "Smoke", "#6E6D62", 0.5}, {41, "Trans Lt Blue", "#60A0C0", 0.5}, {42, "Trans Bt Green", "#40C040", 0.5}, {43, "Trans Cyan", "#00FFFF", 0.5},
--- a/file.cpp Mon Mar 25 17:04:18 2013 +0200 +++ b/file.cpp Mon Mar 25 22:52:53 2013 +0200 @@ -128,6 +128,10 @@ for (LDObject* obj : objects) delete obj; + // Clear the cache as well + for (LDObject* obj : objCache) + delete obj; + delete this; }
--- a/zz_colorSelectDialog.cpp Mon Mar 25 17:04:18 2013 +0200 +++ b/zz_colorSelectDialog.cpp Mon Mar 25 22:52:53 2013 +0200 @@ -27,6 +27,7 @@ #include <qscrollbar.h> #include "zz_colorSelectDialog.h" #include "colors.h" +#include "config.h" static const short g_dNumColumns = 8; static const short g_dNumRows = 10; @@ -35,6 +36,9 @@ static const long g_lHeight = (g_dNumRows * g_dSquareSize); static const long g_lMaxHeight = ((MAX_COLORS / g_dNumColumns) * g_dSquareSize); +extern_cfg (str, gl_maincolor); +extern_cfg (float, gl_maincolor_alpha); + // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= @@ -105,11 +109,19 @@ const double y = (i / g_dNumColumns) * g_dSquareSize; const double w = (g_dSquareSize) - (fPenWidth / 2); - QColor qColor (meta->zColor.chars ()); - qColor.setAlpha (meta->fAlpha * 255.0); + QColor qColor; + + if (i == dMainColor) { + // Use the user preferences for main color here + qColor = gl_maincolor.value.chars (); + qColor.setAlpha (gl_maincolor_alpha * 255.0f); + } else { + qColor = meta->zColor.chars (); + qColor.setAlpha (meta->fAlpha * 255.0f); + } uchar ucLuma = (0.2126f * qColor.red()) + - (0.7152f * qColor.green()) + (0.0722 * qColor.blue()); + (0.7152f * qColor.green()) + (0.0722f * qColor.blue()); bool bDark = (ucLuma < 80); qScene->addRect (x, y, w, w, qPen, qColor);