Added option to color grid origin lines. Fixes #372.

This commit is contained in:
Leonardo Zide 2021-01-11 18:49:57 -08:00
parent e873ba2a35
commit c92c423e3f
7 changed files with 51 additions and 12 deletions

View file

@ -44,6 +44,7 @@ void lcPreferences::LoadDefaults()
mDrawGridLines = lcGetProfileInt(LC_PROFILE_GRID_LINES);
mGridLineSpacing = lcGetProfileInt(LC_PROFILE_GRID_LINE_SPACING);
mGridLineColor = lcGetProfileInt(LC_PROFILE_GRID_LINE_COLOR);
mDrawGridOrigin = lcGetProfileInt(LC_PROFILE_GRID_ORIGIN);
mViewSphereEnabled = lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_ENABLED);
mViewSphereLocation = static_cast<lcViewSphereLocation>(lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_LOCATION));
mViewSphereSize = lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_SIZE);
@ -89,6 +90,7 @@ void lcPreferences::SaveDefaults()
lcSetProfileInt(LC_PROFILE_GRID_LINES, mDrawGridLines);
lcSetProfileInt(LC_PROFILE_GRID_LINE_SPACING, mGridLineSpacing);
lcSetProfileInt(LC_PROFILE_GRID_LINE_COLOR, mGridLineColor);
lcSetProfileInt(LC_PROFILE_GRID_LINE_COLOR, mDrawGridOrigin);
lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_ENABLED, mViewSphereSize ? 1 : 0);
lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_LOCATION, static_cast<int>(mViewSphereLocation));
lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_SIZE, mViewSphereSize);

View file

@ -56,6 +56,7 @@ public:
bool mDrawGridLines;
int mGridLineSpacing;
quint32 mGridLineColor;
bool mDrawGridOrigin;
bool mFixedAxes;
bool mViewSphereEnabled;
lcViewSphereLocation mViewSphereLocation;

View file

@ -83,6 +83,7 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] =
lcProfileEntry("Settings", "GridLines", 1), // LC_PROFILE_GRID_LINES
lcProfileEntry("Settings", "GridLineSpacing", 5), // LC_PROFILE_GRID_LINE_SPACING
lcProfileEntry("Settings", "GridLineColor", LC_RGBA(24, 24, 24, 255)), // LC_PROFILE_GRID_LINE_COLOR
lcProfileEntry("Settings", "GridOrigin", 0), // LC_PROFILE_GRID_ORIGIN
lcProfileEntry("Settings", "AASamples", 1), // LC_PROFILE_ANTIALIASING_SAMPLES
lcProfileEntry("Settings", "ViewSphereEnabled", 1), // LC_PROFILE_VIEW_SPHERE_ENABLED
lcProfileEntry("Settings", "ViewSphereLocation", (int)lcViewSphereLocation::TopRight), // LC_PROFILE_VIEW_SPHERE_LOCATION

View file

@ -30,6 +30,7 @@ enum LC_PROFILE_KEY
LC_PROFILE_GRID_LINES,
LC_PROFILE_GRID_LINE_SPACING,
LC_PROFILE_GRID_LINE_COLOR,
LC_PROFILE_GRID_ORIGIN,
LC_PROFILE_ANTIALIASING_SAMPLES,
LC_PROFILE_VIEW_SPHERE_ENABLED,
LC_PROFILE_VIEW_SPHERE_LOCATION,

View file

@ -1820,7 +1820,7 @@ void lcView::DrawGrid()
{
const lcPreferences& Preferences = lcGetPreferences();
if (!Preferences.mDrawGridStuds && !Preferences.mDrawGridLines)
if (!Preferences.mDrawGridStuds && !Preferences.mDrawGridLines && !Preferences.mDrawGridOrigin)
return;
if (!Preferences.mGridEnabled)
@ -1997,6 +1997,30 @@ void lcView::DrawGrid()
mContext->SetVertexFormat(BufferOffset, 3, 0, 0, 0, false);
mContext->DrawPrimitives(GL_LINES, 0, NumVerts);
}
if (Preferences.mDrawGridOrigin)
{
struct lcGridVertex
{
float x, y;
quint32 Color;
};
const quint32 Red = LC_RGBA(204, 0, 0, 255);
const quint32 Green = LC_RGBA(0, 204, 0, 255);
const float Scale = 20.0f * Spacing;
const lcGridVertex Verts[4] =
{
{ 0.0f, MinY * Scale, Green }, { 0.0f, MaxY * Scale, Green }, { MinX * Scale, 0.0f, Red }, { MaxX * Scale, 0.0f, Red }
};
mContext->SetMaterial(lcMaterialType::UnlitVertexColor);
mContext->SetVertexBufferPointer(Verts);
mContext->SetVertexFormat(0, 2, 0, 0, 4, false);
mContext->DrawPrimitives(GL_LINES, 0, 4);
}
}
lcTrackTool lcView::GetOverrideTrackTool(Qt::MouseButton Button) const

View file

@ -103,6 +103,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->GridOriginCheckBox->setChecked(mOptions->Preferences.mDrawGridOrigin);
ui->AxisIconCheckBox->setChecked(mOptions->Preferences.mDrawAxes);
if (!mOptions->Preferences.mBackgroundGradient)
@ -278,6 +279,7 @@ void lcQPreferencesDialog::accept()
mOptions->Preferences.mDrawGridStuds = ui->gridStuds->isChecked();
mOptions->Preferences.mDrawGridLines = ui->gridLines->isChecked();
mOptions->Preferences.mGridLineSpacing = gridLineSpacing;
mOptions->Preferences.mDrawGridOrigin = ui->GridOriginCheckBox->isChecked();
mOptions->Preferences.mBackgroundGradient = ui->BackgroundGradientRadio->isChecked();
mOptions->Preferences.mDrawAxes = ui->AxisIconCheckBox->isChecked();

View file

@ -554,7 +554,7 @@
<item row="1" column="0">
<widget class="QCheckBox" name="AxisIconCheckBox">
<property name="text">
<string>Axis icon</string>
<string>Axis Icon</string>
</property>
</widget>
</item>
@ -642,13 +642,6 @@
<string>Base Grid</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="gridStuds">
<property name="text">
<string>Draw studs</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label">
<property name="text">
@ -669,6 +662,13 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="gridLines">
<property name="text">
<string>Draw lines every</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="gridLineSpacing">
<property name="maximumSize">
@ -679,10 +679,17 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="gridLines">
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="GridOriginCheckBox">
<property name="text">
<string>Draw lines every</string>
<string>Draw origin lines</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="gridStuds">
<property name="text">
<string>Draw studs</string>
</property>
</widget>
</item>
@ -1703,6 +1710,7 @@
<tabstop>gridStuds</tabstop>
<tabstop>gridLines</tabstop>
<tabstop>gridLineSpacing</tabstop>
<tabstop>GridOriginCheckBox</tabstop>
<tabstop>PreviewViewSphereSizeCombo</tabstop>
<tabstop>PreviewViewSphereLocationCombo</tabstop>
<tabstop>PreviewAxisIconCheckBox</tabstop>