From ee6ef69ede42cea932698af251eab764db9b1cc4 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 20 Jan 2019 11:59:18 -0800 Subject: [PATCH] Confgurable view sphere colors. --- common/lc_application.cpp | 6 ++ common/lc_application.h | 4 +- common/lc_profile.cpp | 5 +- common/lc_profile.h | 5 +- common/lc_viewsphere.cpp | 20 +++--- qt/lc_qpreferencesdialog.cpp | 84 ++++++++++++++++++++++-- qt/lc_qpreferencesdialog.h | 3 +- qt/lc_qpreferencesdialog.ui | 120 ++++++++++++++++++++++++++++------- 8 files changed, 203 insertions(+), 44 deletions(-) diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 9c324432..114b508f 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -27,6 +27,9 @@ void lcPreferences::LoadDefaults() mGridLineColor = lcGetProfileInt(LC_PROFILE_GRID_LINE_COLOR); mViewSphereLocation = (lcViewSphereLocation)lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_LOCATION); mViewSphereSize = lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_SIZE); + mViewSphereColor = lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_COLOR); + mViewSphereTextColor = lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_TEXT_COLOR); + mViewSphereHighlightColor = lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR); } void lcPreferences::SaveDefaults() @@ -44,6 +47,9 @@ void lcPreferences::SaveDefaults() lcSetProfileInt(LC_PROFILE_GRID_LINE_COLOR, mGridLineColor); lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_LOCATION, (int)mViewSphereLocation); lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_SIZE, mViewSphereSize); + lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_COLOR, mViewSphereColor); + lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_TEXT_COLOR, mViewSphereTextColor); + lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR, mViewSphereHighlightColor); } lcApplication::lcApplication(int& Argc, char** Argv) diff --git a/common/lc_application.h b/common/lc_application.h index ccb3c1d8..b14cc6f1 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -16,7 +16,6 @@ enum lcShadingMode enum class lcViewSphereLocation { - DISABLED, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, @@ -42,6 +41,9 @@ public: bool mFixedAxes; lcViewSphereLocation mViewSphereLocation; int mViewSphereSize; + quint32 mViewSphereColor; + quint32 mViewSphereTextColor; + quint32 mViewSphereHighlightColor; }; class lcApplication : public QApplication diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index 89950848..78d6d2ba 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -53,7 +53,7 @@ lcProfileEntry::lcProfileEntry(const char* Section, const char* Key) mDefault.IntValue = 0; } -lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = +static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = { lcProfileEntry("Settings", "FixedAxes", false), // LC_PROFILE_FIXED_AXES lcProfileEntry("Settings", "LineWidth", 1.0f), // LC_PROFILE_LINE_WIDTH @@ -68,6 +68,9 @@ lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = lcProfileEntry("Settings", "AASamples", 1), // LC_PROFILE_ANTIALIASING_SAMPLES lcProfileEntry("Settings", "ViewSphereLocation", (int)lcViewSphereLocation::TOP_RIGHT), // LC_PROFILE_VIEW_SPHERE_LOCATION lcProfileEntry("Settings", "ViewSphereSize", 100), // LC_PROFILE_VIEW_SPHERE_SIZE + lcProfileEntry("Settings", "ViewSphereColor", LC_RGBA(255, 255, 255, 255)), // LC_PROFILE_VIEW_SPHERE_COLOR + lcProfileEntry("Settings", "ViewSphereTextColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_VIEW_SPHERE_TEXT_COLOR + lcProfileEntry("Settings", "ViewSphereHighlightColor", LC_RGBA(255, 0, 0, 255)), // LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR lcProfileEntry("Settings", "CheckUpdates", 1), // LC_PROFILE_CHECK_UPDATES lcProfileEntry("Settings", "ProjectsPath", ""), // LC_PROFILE_PROJECTS_PATH diff --git a/common/lc_profile.h b/common/lc_profile.h index 06cedce8..7a835f5f 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -16,6 +16,9 @@ enum LC_PROFILE_KEY LC_PROFILE_ANTIALIASING_SAMPLES, LC_PROFILE_VIEW_SPHERE_LOCATION, LC_PROFILE_VIEW_SPHERE_SIZE, + LC_PROFILE_VIEW_SPHERE_COLOR, + LC_PROFILE_VIEW_SPHERE_TEXT_COLOR, + LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR, LC_PROFILE_CHECK_UPDATES, LC_PROFILE_PROJECTS_PATH, @@ -100,8 +103,6 @@ public: } mDefault; }; -extern lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS]; - void lcRemoveProfileKey(LC_PROFILE_KEY Key); int lcGetDefaultProfileInt(LC_PROFILE_KEY Key); diff --git a/common/lc_viewsphere.cpp b/common/lc_viewsphere.cpp index 00fcdea4..e65c81de 100644 --- a/common/lc_viewsphere.cpp +++ b/common/lc_viewsphere.cpp @@ -152,15 +152,15 @@ void lcViewSphere::DestroyResources(lcContext* Context) void lcViewSphere::Draw() { const lcPreferences& Preferences = lcGetPreferences(); - lcViewSphereLocation Location = Preferences.mViewSphereLocation; + int ViewportSize = Preferences.mViewSphereSize; - if (Location == lcViewSphereLocation::DISABLED) + if (ViewportSize == 0) return; lcContext* Context = mView->mContext; int Width = mView->mWidth; int Height = mView->mHeight; - int ViewportSize = Preferences.mViewSphereSize; + lcViewSphereLocation Location = Preferences.mViewSphereLocation; int Left = (Location == lcViewSphereLocation::BOTTOM_LEFT || Location == lcViewSphereLocation::TOP_LEFT) ? 0 : Width - ViewportSize; int Bottom = (Location == lcViewSphereLocation::BOTTOM_LEFT || Location == lcViewSphereLocation::BOTTOM_RIGHT) ? 0 : Height - ViewportSize; @@ -195,9 +195,9 @@ void lcViewSphere::Draw() HighlightPosition = lcVector4(lcNormalize(lcVector3(HighlightPosition)), mHighlightRadius); } - const lcVector4 TextColor(0.0, 0.0, 0.0, 1.0); - const lcVector4 BackgroundColor(1.0, 1.0, 1.0, 1.0); - const lcVector4 HighlightColor(1.0, 0.0, 0.0, 1.0); + const lcVector4 TextColor = lcVector4FromColor(Preferences.mViewSphereTextColor); + const lcVector4 BackgroundColor = lcVector4FromColor(Preferences.mViewSphereColor); + const lcVector4 HighlightColor = lcVector4FromColor(Preferences.mViewSphereHighlightColor); Context->SetHighlightParams(HighlightPosition, TextColor, BackgroundColor, HighlightColor); Context->DrawIndexedPrimitives(GL_TRIANGLES, mSubdivisions * mSubdivisions * 6 * 6, GL_UNSIGNED_SHORT, 0); @@ -211,7 +211,7 @@ void lcViewSphere::Draw() bool lcViewSphere::OnLeftButtonDown() { const lcPreferences& Preferences = lcGetPreferences(); - if (Preferences.mViewSphereLocation == lcViewSphereLocation::DISABLED) + if (Preferences.mViewSphereSize == 0) return false; mIntersectionFlags = GetIntersectionFlags(mIntersection); @@ -229,7 +229,7 @@ bool lcViewSphere::OnLeftButtonDown() bool lcViewSphere::OnLeftButtonUp() { const lcPreferences& Preferences = lcGetPreferences(); - if (Preferences.mViewSphereLocation == lcViewSphereLocation::DISABLED) + if (Preferences.mViewSphereSize == 0) return false; if (!mMouseDown) @@ -258,9 +258,7 @@ bool lcViewSphere::OnLeftButtonUp() bool lcViewSphere::OnMouseMove() { const lcPreferences& Preferences = lcGetPreferences(); - lcViewSphereLocation Location = Preferences.mViewSphereLocation; - - if (Location == lcViewSphereLocation::DISABLED) + if (Preferences.mViewSphereSize == 0) return false; if (IsDragging()) diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index 08b98d3f..1e2173f6 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -25,8 +25,11 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget *parent, void *data) : #endif ui->lineWidth->setValidator(new QDoubleValidator(ui->lineWidth)); - connect(ui->gridStudColor, SIGNAL(clicked()), this, SLOT(colorClicked())); - connect(ui->gridLineColor, SIGNAL(clicked()), this, SLOT(colorClicked())); + connect(ui->gridStudColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); + connect(ui->gridLineColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); + connect(ui->ViewSphereColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); + connect(ui->ViewSphereTextColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); + connect(ui->ViewSphereHighlightColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); connect(ui->categoriesTree, SIGNAL(itemSelectionChanged()), this, SLOT(updateParts())); ui->shortcutEdit->installEventFilter(this); connect(ui->commandList, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(commandChanged(QTreeWidgetItem*))); @@ -55,8 +58,24 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget *parent, void *data) : ui->gridLines->setChecked(options->Preferences.mDrawGridLines); ui->gridLineSpacing->setText(QString::number(options->Preferences.mGridLineSpacing)); ui->axisIcon->setChecked(options->Preferences.mDrawAxes); + ui->ViewSphereLocationCombo->setCurrentIndex((int)options->Preferences.mViewSphereLocation); - ui->ViewSphereSizeEdit->setText(QString::number(options->Preferences.mViewSphereSize)); + + switch (options->Preferences.mViewSphereSize) + { + case 200: + ui->ViewSphereSizeCombo->setCurrentIndex(3); + break; + case 100: + ui->ViewSphereSizeCombo->setCurrentIndex(2); + break; + case 50: + ui->ViewSphereSizeCombo->setCurrentIndex(1); + break; + default: + ui->ViewSphereSizeCombo->setCurrentIndex(0); + break; + } if (!gSupportsShaderObjects) ui->ShadingMode->removeItem(LC_SHADING_DEFAULT_LIGHTS); @@ -70,10 +89,20 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget *parent, void *data) : pix.fill(QColor(LC_RGBA_RED(options->Preferences.mGridLineColor), LC_RGBA_GREEN(options->Preferences.mGridLineColor), LC_RGBA_BLUE(options->Preferences.mGridLineColor))); ui->gridLineColor->setIcon(pix); + pix.fill(QColor(LC_RGBA_RED(options->Preferences.mViewSphereColor), LC_RGBA_GREEN(options->Preferences.mViewSphereColor), LC_RGBA_BLUE(options->Preferences.mViewSphereColor))); + ui->ViewSphereColorButton->setIcon(pix); + + pix.fill(QColor(LC_RGBA_RED(options->Preferences.mViewSphereTextColor), LC_RGBA_GREEN(options->Preferences.mViewSphereTextColor), LC_RGBA_BLUE(options->Preferences.mViewSphereTextColor))); + ui->ViewSphereTextColorButton->setIcon(pix); + + pix.fill(QColor(LC_RGBA_RED(options->Preferences.mViewSphereHighlightColor), LC_RGBA_GREEN(options->Preferences.mViewSphereHighlightColor), LC_RGBA_BLUE(options->Preferences.mViewSphereHighlightColor))); + ui->ViewSphereHighlightColorButton->setIcon(pix); + on_antiAliasing_toggled(); on_edgeLines_toggled(); on_gridStuds_toggled(); on_gridLines_toggled(); + on_ViewSphereSizeCombo_currentIndexChanged((int)options->Preferences.mViewSphereLocation); updateCategories(); ui->categoriesTree->setCurrentItem(ui->categoriesTree->topLevelItem(0)); @@ -135,7 +164,23 @@ void lcQPreferencesDialog::accept() options->Preferences.mDrawAxes = ui->axisIcon->isChecked(); options->Preferences.mViewSphereLocation = (lcViewSphereLocation)ui->ViewSphereLocationCombo->currentIndex(); - options->Preferences.mViewSphereSize = ui->ViewSphereSizeEdit->text().toInt(); + + switch (ui->ViewSphereSizeCombo->currentIndex()) + { + case 3: + options->Preferences.mViewSphereSize = 200; + break; + case 2: + options->Preferences.mViewSphereSize = 100; + break; + case 1: + options->Preferences.mViewSphereSize = 50; + break; + default: + options->Preferences.mViewSphereSize = 0; + break; + } + options->Preferences.mShadingMode = (lcShadingMode)ui->ShadingMode->currentIndex(); QDialog::accept(); @@ -171,7 +216,7 @@ void lcQPreferencesDialog::on_lgeoPathBrowse_clicked() ui->lgeoPath->setText(QDir::toNativeSeparators(result)); } -void lcQPreferencesDialog::colorClicked() +void lcQPreferencesDialog::ColorButtonClicked() { QObject *button = sender(); QString title; @@ -190,6 +235,24 @@ void lcQPreferencesDialog::colorClicked() title = tr("Select Grid Line Color"); dialogOptions = 0; } + else if (button == ui->ViewSphereColorButton) + { + color = &options->Preferences.mViewSphereColor; + title = tr("Select View Sphere Color"); + dialogOptions = 0; + } + else if (button == ui->ViewSphereTextColorButton) + { + color = &options->Preferences.mViewSphereTextColor; + title = tr("Select View Sphere Text Color"); + dialogOptions = 0; + } + else if (button == ui->ViewSphereHighlightColorButton) + { + color = &options->Preferences.mViewSphereHighlightColor; + title = tr("Select View Sphere Highlight Color"); + dialogOptions = 0; + } else return; @@ -225,6 +288,17 @@ void lcQPreferencesDialog::on_gridStuds_toggled() void lcQPreferencesDialog::on_gridLines_toggled() { ui->gridLineColor->setEnabled(ui->gridLines->isChecked()); + ui->gridLineSpacing->setEnabled(ui->gridLines->isChecked()); +} + +void lcQPreferencesDialog::on_ViewSphereSizeCombo_currentIndexChanged(int Index) +{ + bool Enabled = Index != 0; + + ui->ViewSphereLocationCombo->setEnabled(Enabled); + ui->ViewSphereColorButton->setEnabled(Enabled); + ui->ViewSphereTextColorButton->setEnabled(Enabled); + ui->ViewSphereHighlightColorButton->setEnabled(Enabled); } void lcQPreferencesDialog::updateCategories() diff --git a/qt/lc_qpreferencesdialog.h b/qt/lc_qpreferencesdialog.h index dbdf64f3..0073950d 100644 --- a/qt/lc_qpreferencesdialog.h +++ b/qt/lc_qpreferencesdialog.h @@ -29,11 +29,12 @@ public slots: void on_partsLibraryBrowse_clicked(); void on_povrayExecutableBrowse_clicked(); void on_lgeoPathBrowse_clicked(); - void colorClicked(); + void ColorButtonClicked(); void on_antiAliasing_toggled(); void on_edgeLines_toggled(); void on_gridStuds_toggled(); void on_gridLines_toggled(); + void on_ViewSphereSizeCombo_currentIndexChanged(int Index); void updateParts(); void on_newCategory_clicked(); void on_editCategory_clicked(); diff --git a/qt/lc_qpreferencesdialog.ui b/qt/lc_qpreferencesdialog.ui index a9e3978e..fa9588a9 100644 --- a/qt/lc_qpreferencesdialog.ui +++ b/qt/lc_qpreferencesdialog.ui @@ -14,6 +14,16 @@ Preferences + + + + QFrame::HLine + + + QFrame::Raised + + + @@ -330,20 +340,94 @@ View Sphere - - - - Location + + + + Qt::Horizontal - + + + 40 + 20 + + + - + Disabled + + + Small + + + + + Medium + + + + + Large + + + + + + + + Highlight Color: + + + + + + + Size: + + + + + + + + + + + + + + Color: + + + + + + + + + + + + + + Text Color: + + + + + + + Location: + + + + + Top Left @@ -366,16 +450,13 @@ - - + + - Size + - - - @@ -884,16 +965,6 @@ - - - - QFrame::HLine - - - QFrame::Raised - - - @@ -928,8 +999,11 @@ gridLines gridLineSpacing gridLineColor + ViewSphereSizeCombo ViewSphereLocationCombo - ViewSphereSizeEdit + ViewSphereColorButton + ViewSphereTextColorButton + ViewSphereHighlightColorButton categoriesTree partsTree importCategories