Confgurable view sphere colors.

This commit is contained in:
Leonardo Zide 2019-01-20 11:59:18 -08:00
parent 6077400b3c
commit ee6ef69ede
8 changed files with 203 additions and 44 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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())

View file

@ -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()

View file

@ -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();

View file

@ -14,6 +14,16 @@
<string>Preferences</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
@ -330,20 +340,94 @@
<string>View Sphere</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Location</string>
<item row="0" column="7">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="ViewSphereLocationCombo">
<widget class="QComboBox" name="ViewSphereSizeCombo">
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>Small</string>
</property>
</item>
<item>
<property name="text">
<string>Medium</string>
</property>
</item>
<item>
<property name="text">
<string>Large</string>
</property>
</item>
</widget>
</item>
<item row="2" column="5">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Highlight Color:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="ViewSphereColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QToolButton" name="ViewSphereTextColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Text Color:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="ViewSphereLocationCombo">
<item>
<property name="text">
<string>Top Left</string>
@ -366,16 +450,13 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<item row="2" column="6">
<widget class="QToolButton" name="ViewSphereHighlightColorButton">
<property name="text">
<string>Size</string>
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="ViewSphereSizeEdit"/>
</item>
</layout>
</widget>
</item>
@ -884,16 +965,6 @@
</widget>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
@ -928,8 +999,11 @@
<tabstop>gridLines</tabstop>
<tabstop>gridLineSpacing</tabstop>
<tabstop>gridLineColor</tabstop>
<tabstop>ViewSphereSizeCombo</tabstop>
<tabstop>ViewSphereLocationCombo</tabstop>
<tabstop>ViewSphereSizeEdit</tabstop>
<tabstop>ViewSphereColorButton</tabstop>
<tabstop>ViewSphereTextColorButton</tabstop>
<tabstop>ViewSphereHighlightColorButton</tabstop>
<tabstop>categoriesTree</tabstop>
<tabstop>partsTree</tabstop>
<tabstop>importCategories</tabstop>