Added a slider to set line width.

This commit is contained in:
Leonardo Zide 2020-06-06 11:16:01 -07:00
parent aefe36dbca
commit 8932469470
3 changed files with 55 additions and 24 deletions

View file

@ -28,7 +28,6 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
delete ui->povrayLayout; delete ui->povrayLayout;
#endif #endif
ui->lineWidth->setValidator(new QDoubleValidator(ui->lineWidth));
connect(ui->FadeStepsColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); connect(ui->FadeStepsColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
connect(ui->HighlightNewPartsColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); connect(ui->HighlightNewPartsColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
connect(ui->gridStudColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); connect(ui->gridStudColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
@ -69,7 +68,21 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
else else
ui->antiAliasingSamples->setCurrentIndex(0); ui->antiAliasingSamples->setCurrentIndex(0);
ui->edgeLines->setChecked(mOptions->Preferences.mDrawEdgeLines); ui->edgeLines->setChecked(mOptions->Preferences.mDrawEdgeLines);
ui->lineWidth->setText(lcFormatValueLocalized(mOptions->Preferences.mLineWidth));
if (QGLFormat::defaultFormat().sampleBuffers() && QGLFormat::defaultFormat().samples() > 1)
{
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, mLineWidthRange);
glGetFloatv(GL_SMOOTH_LINE_WIDTH_GRANULARITY, &mLineWidthGranularity);
}
else
{
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, mLineWidthRange);
mLineWidthGranularity = 1.0f;
}
ui->LineWidthSlider->setRange(0, (mLineWidthRange[1] - mLineWidthRange[0]) / mLineWidthGranularity);
ui->LineWidthSlider->setValue((mOptions->Preferences.mLineWidth - mLineWidthRange[0]) / mLineWidthGranularity);
ui->MeshLOD->setChecked(mOptions->Preferences.mAllowLOD); ui->MeshLOD->setChecked(mOptions->Preferences.mAllowLOD);
ui->FadeSteps->setChecked(mOptions->Preferences.mFadeSteps); ui->FadeSteps->setChecked(mOptions->Preferences.mFadeSteps);
ui->HighlightNewParts->setChecked(mOptions->Preferences.mHighlightNewParts); ui->HighlightNewParts->setChecked(mOptions->Preferences.mHighlightNewParts);
@ -137,6 +150,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
on_studLogo_toggled(); on_studLogo_toggled();
on_antiAliasing_toggled(); on_antiAliasing_toggled();
on_edgeLines_toggled(); on_edgeLines_toggled();
on_LineWidthSlider_valueChanged();
on_FadeSteps_toggled(); on_FadeSteps_toggled();
on_HighlightNewParts_toggled(); on_HighlightNewParts_toggled();
on_gridStuds_toggled(); on_gridStuds_toggled();
@ -205,7 +219,7 @@ void lcQPreferencesDialog::accept()
mOptions->AASamples = 2; mOptions->AASamples = 2;
mOptions->Preferences.mDrawEdgeLines = ui->edgeLines->isChecked(); mOptions->Preferences.mDrawEdgeLines = ui->edgeLines->isChecked();
mOptions->Preferences.mLineWidth = lcParseValueLocalized(ui->lineWidth->text()); mOptions->Preferences.mLineWidth = mLineWidthRange[0] + static_cast<float>(ui->LineWidthSlider->value()) * mLineWidthGranularity;
mOptions->Preferences.mAllowLOD = ui->MeshLOD->isChecked(); mOptions->Preferences.mAllowLOD = ui->MeshLOD->isChecked();
mOptions->Preferences.mFadeSteps = ui->FadeSteps->isChecked(); mOptions->Preferences.mFadeSteps = ui->FadeSteps->isChecked();
mOptions->Preferences.mHighlightNewParts = ui->HighlightNewParts->isChecked(); mOptions->Preferences.mHighlightNewParts = ui->HighlightNewParts->isChecked();
@ -375,7 +389,14 @@ void lcQPreferencesDialog::on_antiAliasing_toggled()
void lcQPreferencesDialog::on_edgeLines_toggled() void lcQPreferencesDialog::on_edgeLines_toggled()
{ {
ui->lineWidth->setEnabled(ui->edgeLines->isChecked()); ui->LineWidthSlider->setEnabled(ui->edgeLines->isChecked());
ui->LineWidthLabel->setEnabled(ui->edgeLines->isChecked());
}
void lcQPreferencesDialog::on_LineWidthSlider_valueChanged()
{
float Value = mLineWidthRange[0] + static_cast<float>(ui->LineWidthSlider->value()) * mLineWidthGranularity;
ui->LineWidthLabel->setText(QString::number(Value));
} }
void lcQPreferencesDialog::on_FadeSteps_toggled() void lcQPreferencesDialog::on_FadeSteps_toggled()

View file

@ -35,6 +35,7 @@ public slots:
void ColorButtonClicked(); void ColorButtonClicked();
void on_antiAliasing_toggled(); void on_antiAliasing_toggled();
void on_edgeLines_toggled(); void on_edgeLines_toggled();
void on_LineWidthSlider_valueChanged();
void on_FadeSteps_toggled(); void on_FadeSteps_toggled();
void on_HighlightNewParts_toggled(); void on_HighlightNewParts_toggled();
void on_gridStuds_toggled(); void on_gridStuds_toggled();
@ -68,5 +69,7 @@ private:
void UpdateMouseTree(); void UpdateMouseTree();
void UpdateMouseTreeItem(int ItemIndex); void UpdateMouseTreeItem(int ItemIndex);
void setShortcutModified(QTreeWidgetItem *treeItem, bool modified); void setShortcutModified(QTreeWidgetItem *treeItem, bool modified);
};
float mLineWidthRange[2];
float mLineWidthGranularity;
};

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>598</width> <width>598</width>
<height>492</height> <height>494</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -391,16 +391,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineWidth">
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="antiAliasing"> <widget class="QCheckBox" name="antiAliasing">
<property name="text"> <property name="text">
@ -441,13 +431,6 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="2" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>width</string>
</property>
</widget>
</item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="axisIcon"> <widget class="QCheckBox" name="axisIcon">
<property name="text"> <property name="text">
@ -476,6 +459,29 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QSlider" name="LineWidthSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="LineWidthLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -1220,7 +1226,8 @@
<tabstop>studLogo</tabstop> <tabstop>studLogo</tabstop>
<tabstop>studLogoCombo</tabstop> <tabstop>studLogoCombo</tabstop>
<tabstop>edgeLines</tabstop> <tabstop>edgeLines</tabstop>
<tabstop>lineWidth</tabstop> <tabstop>LineWidthSlider</tabstop>
<tabstop>LineWidthLabel</tabstop>
<tabstop>MeshLOD</tabstop> <tabstop>MeshLOD</tabstop>
<tabstop>axisIcon</tabstop> <tabstop>axisIcon</tabstop>
<tabstop>FadeSteps</tabstop> <tabstop>FadeSteps</tabstop>