From b2880731dbd4d00c8f80915af2dd787c8dfc46ba Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 7 Mar 2021 09:53:35 -0800 Subject: [PATCH] Added conditional lines option. --- common/lc_application.cpp | 2 + common/lc_application.h | 1 + common/lc_profile.cpp | 1 + common/lc_profile.h | 1 + common/lc_scene.cpp | 4 +- qt/lc_qpreferencesdialog.cpp | 16 +- qt/lc_qpreferencesdialog.h | 1 + qt/lc_qpreferencesdialog.ui | 345 +++++++++++++++++++---------------- 8 files changed, 213 insertions(+), 158 deletions(-) diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 99febb66..ae352148 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -32,6 +32,7 @@ void lcPreferences::LoadDefaults() mActiveViewColor = lcGetProfileInt(LC_PROFILE_ACTIVE_VIEW_COLOR); mInactiveViewColor = lcGetProfileInt(LC_PROFILE_INACTIVE_VIEW_COLOR); mDrawEdgeLines = lcGetProfileInt(LC_PROFILE_DRAW_EDGE_LINES); + mDrawConditionalLines = lcGetProfileInt(LC_PROFILE_DRAW_CONDITIONAL_LINES); mLineWidth = lcGetProfileFloat(LC_PROFILE_LINE_WIDTH); mAllowLOD = lcGetProfileInt(LC_PROFILE_ALLOW_LOD); mMeshLODDistance = lcGetProfileFloat(LC_PROFILE_LOD_DISTANCE); @@ -85,6 +86,7 @@ void lcPreferences::SaveDefaults() lcSetProfileInt(LC_PROFILE_ACTIVE_VIEW_COLOR, mActiveViewColor); lcSetProfileInt(LC_PROFILE_INACTIVE_VIEW_COLOR, mInactiveViewColor); lcSetProfileInt(LC_PROFILE_DRAW_EDGE_LINES, mDrawEdgeLines); + lcSetProfileInt(LC_PROFILE_DRAW_CONDITIONAL_LINES, mDrawConditionalLines); lcSetProfileFloat(LC_PROFILE_LINE_WIDTH, mLineWidth); lcSetProfileInt(LC_PROFILE_ALLOW_LOD, mAllowLOD); lcSetProfileFloat(LC_PROFILE_LOD_DISTANCE, mMeshLODDistance); diff --git a/common/lc_application.h b/common/lc_application.h index d179f8fe..fa495116 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -43,6 +43,7 @@ public: quint32 mActiveViewColor; quint32 mInactiveViewColor; bool mDrawEdgeLines; + bool mDrawConditionalLines; float mLineWidth; bool mAllowLOD; float mMeshLODDistance; diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index d6faf331..c7511a8a 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -78,6 +78,7 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = lcProfileEntry("Settings", "ActiveViewColor", LC_RGBA(41, 128, 185, 255)), // LC_PROFILE_ACTIVE_VIEW_COLOR lcProfileEntry("Settings", "InactiveViewColor", LC_RGBA(69, 69, 69, 255)), // LC_PROFILE_INACTIVE_VIEW_COLOR lcProfileEntry("Settings", "DrawEdgeLines", 1), // LC_PROFILE_DRAW_EDGE_LINES + lcProfileEntry("Settings", "DrawConditionalLines", 1), // LC_PROFILE_DRAW_CONDITIONAL_LINES lcProfileEntry("Settings", "GridStuds", 1), // LC_PROFILE_GRID_STUDS lcProfileEntry("Settings", "GridStudColor", LC_RGBA(24, 24, 24, 192)), // LC_PROFILE_GRID_STUD_COLOR lcProfileEntry("Settings", "GridLines", 1), // LC_PROFILE_GRID_LINES diff --git a/common/lc_profile.h b/common/lc_profile.h index 00fbfced..a6992869 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -25,6 +25,7 @@ enum LC_PROFILE_KEY LC_PROFILE_ACTIVE_VIEW_COLOR, LC_PROFILE_INACTIVE_VIEW_COLOR, LC_PROFILE_DRAW_EDGE_LINES, + LC_PROFILE_DRAW_CONDITIONAL_LINES, LC_PROFILE_GRID_STUDS, LC_PROFILE_GRID_STUD_COLOR, LC_PROFILE_GRID_LINES, diff --git a/common/lc_scene.cpp b/common/lc_scene.cpp index 49341c1b..e0b02ec7 100644 --- a/common/lc_scene.cpp +++ b/common/lc_scene.cpp @@ -404,8 +404,8 @@ void lcScene::Draw(lcContext* Context) const Context->SetViewMatrix(mViewMatrix); const lcPreferences& Preferences = lcGetPreferences(); - const bool DrawLines = Preferences.mDrawEdgeLines && Preferences.mLineWidth != 0.0f; - const bool DrawConditional = false; + const bool DrawLines = Preferences.mDrawEdgeLines && Preferences.mLineWidth > 0.0f; + const bool DrawConditional = Preferences.mDrawConditionalLines && Preferences.mLineWidth > 0.0f; // lcShadingMode ShadingMode = Preferences.mShadingMode; // if (ShadingMode == lcShadingMode::Wireframe && !mAllowWireframe) diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index b0c83f72..461e7644 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -84,6 +84,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO else ui->antiAliasingSamples->setCurrentIndex(0); ui->edgeLines->setChecked(mOptions->Preferences.mDrawEdgeLines); + ui->ConditionalLinesCheckBox->setChecked(mOptions->Preferences.mDrawConditionalLines); #ifndef LC_OPENGLES if (QSurfaceFormat::defaultFormat().samples() > 1) @@ -273,6 +274,7 @@ void lcQPreferencesDialog::accept() mOptions->AASamples = 2; mOptions->Preferences.mDrawEdgeLines = ui->edgeLines->isChecked(); + mOptions->Preferences.mDrawConditionalLines = ui->ConditionalLinesCheckBox->isChecked(); mOptions->Preferences.mLineWidth = mLineWidthRange[0] + static_cast(ui->LineWidthSlider->value()) * mLineWidthGranularity; mOptions->Preferences.mAllowLOD = ui->MeshLOD->isChecked(); mOptions->Preferences.mMeshLODDistance = ui->MeshLODSlider->value() * mMeshLODMultiplier; @@ -509,8 +511,18 @@ void lcQPreferencesDialog::on_antiAliasing_toggled() void lcQPreferencesDialog::on_edgeLines_toggled() { - ui->LineWidthSlider->setEnabled(ui->edgeLines->isChecked()); - ui->LineWidthLabel->setEnabled(ui->edgeLines->isChecked()); + const bool Enable = ui->edgeLines->isChecked() || ui->ConditionalLinesCheckBox->isChecked(); + + ui->LineWidthSlider->setEnabled(Enable); + ui->LineWidthLabel->setEnabled(Enable); +} + +void lcQPreferencesDialog::on_ConditionalLinesCheckBox_toggled() +{ + const bool Enable = ui->edgeLines->isChecked() || ui->ConditionalLinesCheckBox->isChecked(); + + ui->LineWidthSlider->setEnabled(Enable); + ui->LineWidthLabel->setEnabled(Enable); } void lcQPreferencesDialog::on_LineWidthSlider_valueChanged() diff --git a/qt/lc_qpreferencesdialog.h b/qt/lc_qpreferencesdialog.h index ccd12427..c0cf6dfd 100644 --- a/qt/lc_qpreferencesdialog.h +++ b/qt/lc_qpreferencesdialog.h @@ -70,6 +70,7 @@ public slots: void on_studStyleCombo_currentIndexChanged(int index); void on_antiAliasing_toggled(); void on_edgeLines_toggled(); + void on_ConditionalLinesCheckBox_toggled(); void on_LineWidthSlider_valueChanged(); void on_MeshLODSlider_valueChanged(); void on_FadeSteps_toggled(); diff --git a/qt/lc_qpreferencesdialog.ui b/qt/lc_qpreferencesdialog.ui index 6646cf1d..fd0345b3 100644 --- a/qt/lc_qpreferencesdialog.ui +++ b/qt/lc_qpreferencesdialog.ui @@ -7,7 +7,7 @@ 0 0 621 - 658 + 503 @@ -333,132 +333,33 @@ - - + + - Shading Mode: + Contrast Settings... - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Edge lines - - - - - - - - - - - - - - Stud Style - - - - - - - - - - - - - - Anti-aliasing - - - - - - - Fade previous steps - - - - - - - Mesh LOD - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - - - - - - - Highlight new parts - - - - - + + - 2x + Wireframe - 4x + Flat Shading - 8x + Default Lights - - - - - - - - + @@ -502,7 +403,161 @@ - + + + + Shading Mode: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Stud Style + + + + + + + Anti-aliasing + + + + + + + + 2x + + + + + 4x + + + + + 8x + + + + + + + + + + + + + + + Highlight New Parts + + + + + + + Mesh LOD + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + + + + + + + Fade Previous Steps + + + + + + + + + + + + + + + + + Lines + + + + + + + + + + + + + Conditional Lines + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Line Width: + + + + @@ -518,46 +573,27 @@ - + + + + Edge Lines + + + + + + + Automate Edge Color + + + + Settings... - - - - Automate edge color - - - - - - - Contrast Settings... - - - - - - - - Wireframe - - - - - Flat Shading - - - - - Default Lights - - - - @@ -1708,7 +1744,6 @@ - tabWidget partsLibrary partsLibraryBrowse partsArchiveBrowse @@ -1729,19 +1764,20 @@ RestoreTabLayout antiAliasing antiAliasingSamples - edgeLines - LineWidthSlider - MeshLOD - MeshLODSlider - AutomateEdgeColor - AutomateEdgeColorButton FadeSteps FadeStepsColor HighlightNewParts HighlightNewPartsColor + MeshLOD + MeshLODSlider studStyleCombo HighContrastButton ShadingMode + edgeLines + ConditionalLinesCheckBox + AutomateEdgeColor + AutomateEdgeColorButton + LineWidthSlider ViewSphereSizeCombo ViewSphereLocationCombo AxisIconCheckBox @@ -1758,12 +1794,12 @@ BackgroundGradient1ColorButton BackgroundGradient2ColorButton ActiveViewColorButton - TextColorButton - MarqueeBorderColorButton - OverlayColorButton InactiveViewColorButton + TextColorButton AxesColorButton + MarqueeBorderColorButton MarqueeFillColorButton + OverlayColorButton gridLineColor gridStudColor ViewSphereColorButton @@ -1796,6 +1832,7 @@ mouseAssign mouseRemove mouseSensitivity + tabWidget