From 0cead36c7fb2969e60fa3775afbe90afc65f2509 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sat, 11 Jul 2020 10:47:52 -0700 Subject: [PATCH] Added option to select the overlay and axis colors. Fixes #464. --- common/lc_application.cpp | 4 + common/lc_application.h | 2 + common/lc_profile.cpp | 2 + common/lc_profile.h | 2 + common/view.cpp | 4 +- qt/lc_qpreferencesdialog.cpp | 26 +++++- qt/lc_qpreferencesdialog.ui | 168 ++++++++++++++++++++++++----------- 7 files changed, 151 insertions(+), 57 deletions(-) diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 7ff7a92d..1ac978ea 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -18,6 +18,8 @@ void lcPreferences::LoadDefaults() mMouseSensitivity = lcGetProfileInt(LC_PROFILE_MOUSE_SENSITIVITY); mShadingMode = static_cast(lcGetProfileInt(LC_PROFILE_SHADING_MODE)); mDrawAxes = lcGetProfileInt(LC_PROFILE_DRAW_AXES); + mAxesColor = lcGetProfileInt(LC_PROFILE_AXES_COLOR); + mOverlayColor = lcGetProfileInt(LC_PROFILE_OVERLAY_COLOR); mDrawEdgeLines = lcGetProfileInt(LC_PROFILE_DRAW_EDGE_LINES); mLineWidth = lcGetProfileFloat(LC_PROFILE_LINE_WIDTH); mAllowLOD = lcGetProfileInt(LC_PROFILE_ALLOW_LOD); @@ -46,6 +48,8 @@ void lcPreferences::SaveDefaults() lcSetProfileInt(LC_PROFILE_MOUSE_SENSITIVITY, mMouseSensitivity); lcSetProfileInt(LC_PROFILE_SHADING_MODE, static_cast(mShadingMode)); lcSetProfileInt(LC_PROFILE_DRAW_AXES, mDrawAxes); + lcSetProfileInt(LC_PROFILE_AXES_COLOR, mAxesColor); + lcSetProfileInt(LC_PROFILE_OVERLAY_COLOR, mOverlayColor); lcSetProfileInt(LC_PROFILE_DRAW_EDGE_LINES, mDrawEdgeLines); lcSetProfileFloat(LC_PROFILE_LINE_WIDTH, mLineWidth); lcSetProfileInt(LC_PROFILE_ALLOW_LOD, mAllowLOD); diff --git a/common/lc_application.h b/common/lc_application.h index b6138c5c..f064c2ad 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -30,6 +30,8 @@ public: int mMouseSensitivity; lcShadingMode mShadingMode; bool mDrawAxes; + quint32 mAxesColor; + quint32 mOverlayColor; bool mDrawEdgeLines; float mLineWidth; bool mAllowLOD; diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index e99f8016..de098aa2 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -64,6 +64,8 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = lcProfileEntry("Settings", "HighlightNewPartsColor", LC_RGBA(255, 242, 0, 192)), // LC_PROFILE_HIGHLIGHT_NEW_PARTS_COLOR lcProfileEntry("Settings", "ShadingMode", static_cast(lcShadingMode::DefaultLights)), // LC_PROFILE_SHADING_MODE lcProfileEntry("Settings", "DrawAxes", 0), // LC_PROFILE_DRAW_AXES + lcProfileEntry("Settings", "AxesColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_AXES_COLOR + lcProfileEntry("Settings", "OverlayColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_OVERLAY_COLOR lcProfileEntry("Settings", "DrawEdgeLines", 1), // LC_PROFILE_DRAW_EDGE_LINES lcProfileEntry("Settings", "GridStuds", 1), // LC_PROFILE_GRID_STUDS lcProfileEntry("Settings", "GridStudColor", LC_RGBA(64, 64, 64, 192)), // LC_PROFILE_GRID_STUD_COLOR diff --git a/common/lc_profile.h b/common/lc_profile.h index ed84fbec..53ee4b86 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -12,6 +12,8 @@ enum LC_PROFILE_KEY LC_PROFILE_HIGHLIGHT_NEW_PARTS_COLOR, LC_PROFILE_SHADING_MODE, LC_PROFILE_DRAW_AXES, + LC_PROFILE_AXES_COLOR, + LC_PROFILE_OVERLAY_COLOR, LC_PROFILE_DRAW_EDGE_LINES, LC_PROFILE_GRID_STUDS, LC_PROFILE_GRID_STUD_COLOR, diff --git a/common/view.cpp b/common/view.cpp index f2c815d4..2ef0c150 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -1532,7 +1532,7 @@ void View::DrawRotateViewOverlay() mContext->SetProjectionMatrix(lcMatrix44Ortho(0, w, 0, h, -1, 1)); glDisable(GL_DEPTH_TEST); - mContext->SetColor(0.0f, 0.0f, 0.0f, 1.0f); + mContext->SetColor(lcVector4FromColor(lcGetPreferences().mOverlayColor)); float Verts[32 * 16 * 2]; float* CurVert = Verts; @@ -1824,7 +1824,7 @@ void View::DrawAxes() mContext->SetVertexBufferPointer(TextBuffer); mContext->SetVertexFormat(0, 3, 0, 2, 0, false); - mContext->SetColor(0.0f, 0.0f, 0.0f, 1.0f); + mContext->SetColor(lcVector4FromColor(lcGetPreferences().mAxesColor)); mContext->DrawPrimitives(GL_TRIANGLES, 0, 6 * 3); glDisable(GL_BLEND); diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index 2916deed..80b9ca37 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -28,6 +28,8 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO delete ui->povrayLayout; #endif + connect(ui->AxesColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); + connect(ui->OverlayColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); connect(ui->FadeStepsColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); connect(ui->HighlightNewPartsColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); connect(ui->gridStudColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); @@ -89,7 +91,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO ui->gridStuds->setChecked(mOptions->Preferences.mDrawGridStuds); ui->gridLines->setChecked(mOptions->Preferences.mDrawGridLines); ui->gridLineSpacing->setText(QString::number(mOptions->Preferences.mGridLineSpacing)); - ui->axisIcon->setChecked(mOptions->Preferences.mDrawAxes); + ui->AxisIconCheckBox->setChecked(mOptions->Preferences.mDrawAxes); ui->ViewSphereLocationCombo->setCurrentIndex((int)mOptions->Preferences.mViewSphereLocation); @@ -126,6 +128,12 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO QPixmap pix(12, 12); + pix.fill(QColor(LC_RGBA_RED(mOptions->Preferences.mAxesColor), LC_RGBA_GREEN(mOptions->Preferences.mAxesColor), LC_RGBA_BLUE(mOptions->Preferences.mAxesColor))); + ui->AxesColorButton->setIcon(pix); + + pix.fill(QColor(LC_RGBA_RED(mOptions->Preferences.mOverlayColor), LC_RGBA_GREEN(mOptions->Preferences.mOverlayColor), LC_RGBA_BLUE(mOptions->Preferences.mOverlayColor))); + ui->OverlayColorButton->setIcon(pix); + pix.fill(QColor(LC_RGBA_RED(mOptions->Preferences.mFadeStepsColor), LC_RGBA_GREEN(mOptions->Preferences.mFadeStepsColor), LC_RGBA_BLUE(mOptions->Preferences.mFadeStepsColor))); ui->FadeStepsColor->setIcon(pix); @@ -228,7 +236,7 @@ void lcQPreferencesDialog::accept() mOptions->Preferences.mDrawGridLines = ui->gridLines->isChecked(); mOptions->Preferences.mGridLineSpacing = gridLineSpacing; - mOptions->Preferences.mDrawAxes = ui->axisIcon->isChecked(); + mOptions->Preferences.mDrawAxes = ui->AxisIconCheckBox->isChecked(); mOptions->Preferences.mViewSphereLocation = (lcViewSphereLocation)ui->ViewSphereLocationCombo->currentIndex(); switch (ui->ViewSphereSizeCombo->currentIndex()) @@ -318,7 +326,19 @@ void lcQPreferencesDialog::ColorButtonClicked() quint32* Color = nullptr; QColorDialog::ColorDialogOptions DialogOptions; - if (Button == ui->FadeStepsColor) + if (Button == ui->AxesColorButton) + { + Color = &mOptions->Preferences.mAxesColor; + Title = tr("Select Axes Color"); + DialogOptions = 0; + } + else if (Button == ui->OverlayColorButton) + { + Color = &mOptions->Preferences.mOverlayColor; + Title = tr("Select Overlay Color"); + DialogOptions = 0; + } + else if (Button == ui->FadeStepsColor) { Color = &mOptions->Preferences.mFadeStepsColor; Title = tr("Select Fade Color"); diff --git a/qt/lc_qpreferencesdialog.ui b/qt/lc_qpreferencesdialog.ui index 4bbb64f1..55ca6437 100644 --- a/qt/lc_qpreferencesdialog.ui +++ b/qt/lc_qpreferencesdialog.ui @@ -309,7 +309,20 @@ - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + Highlight new parts @@ -335,23 +348,17 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + - Stud Logo + Mesh LOD + + + + + + + Edge lines @@ -384,10 +391,10 @@ - - + + - Edge lines + Stud Logo @@ -398,21 +405,21 @@ - - + + - Mesh LOD + Fade previous steps - + Shading Mode: - + @@ -431,28 +438,14 @@ - - - - Axis icon - - - - - - - Fade previous steps - - - - + - + @@ -485,6 +478,76 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Interface + + + + + + Overlays + + + + + + + + + + + + + Axis icon + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Overlay Color: + + + + + + + + + + + + + @@ -553,13 +616,13 @@ - + View Sphere - + - + Qt::Horizontal @@ -596,14 +659,14 @@ - + Highlight Color: - + Size: @@ -617,7 +680,7 @@ - + Color: @@ -631,14 +694,14 @@ - + Text Color: - + Location: @@ -679,7 +742,7 @@ - + Qt::Vertical @@ -1227,14 +1290,15 @@ studLogoCombo edgeLines LineWidthSlider - LineWidthLabel MeshLOD - axisIcon FadeSteps FadeStepsColor HighlightNewParts HighlightNewPartsColor ShadingMode + AxisIconCheckBox + AxesColorButton + OverlayColorButton gridStuds gridStudColor gridLines