Skip to content

Commit

Permalink
Merged Denvi#516 (Reworked visualizer navigation)
Browse files Browse the repository at this point in the history
  • Loading branch information
etet100 committed Mar 17, 2024
1 parent 92a5330 commit b515257
Show file tree
Hide file tree
Showing 10 changed files with 298 additions and 61 deletions.
18 changes: 18 additions & 0 deletions src/candle/frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ frmMain::frmMain(QWidget *parent) :
ui->cmdYMinus->setBackColor(ui->cmdXMinus->backColor());
ui->cmdYPlus->setBackColor(ui->cmdXMinus->backColor());

ui->cmdToggleProjection->setParent(ui->glwVisualizer);
ui->cmdFit->setParent(ui->glwVisualizer);
ui->cmdIsometric->setParent(ui->glwVisualizer);
ui->cmdTop->setParent(ui->glwVisualizer);
Expand Down Expand Up @@ -968,6 +969,11 @@ void frmMain::on_cmdIsometric_clicked()
ui->glwVisualizer->setIsometricView();
}

void frmMain::on_cmdToggleProjection_clicked()
{
ui->glwVisualizer->toggleProjectionType();
}

void frmMain::on_cmdFit_clicked()
{
ui->glwVisualizer->fitDrawable(m_currentDrawer);
Expand Down Expand Up @@ -2021,6 +2027,7 @@ void frmMain::placeVisualizerButtons()
ui->cmdLeft->move(ui->glwVisualizer->width() - ui->cmdLeft->width() - 8, ui->cmdIsometric->geometry().bottom() + 8);
ui->cmdFront->move(ui->cmdLeft->geometry().left() - ui->cmdFront->width() - 8, ui->cmdIsometric->geometry().bottom() + 8);
ui->cmdFit->move(ui->glwVisualizer->width() - ui->cmdFit->width() - 8, ui->cmdLeft->geometry().bottom() + 8);
ui->cmdToggleProjection->move(ui->cmdFit->geometry().left() - ui->cmdToggleProjection->width() - 8, ui->cmdLeft->geometry().bottom() + 8);
}

void frmMain::preloadSettings()
Expand Down Expand Up @@ -2057,6 +2064,9 @@ void frmMain::loadSettings()
m_settings->setMsaa(set.value("msaa", true).toBool());
m_settings->setVsync(set.value("vsync", false).toBool());
m_settings->setZBuffer(set.value("zBuffer", false).toBool());
m_settings->setFov(set.value("fov", 60).toDouble());
m_settings->setNearPlane(set.value("nearPlane", 0.5).toDouble());
m_settings->setFarPlane(set.value("farPlane", 10000.0).toDouble());
m_settings->setSimplify(set.value("simplify", false).toBool());
m_settings->setSimplifyPrecision(set.value("simplifyPrecision", 0).toDouble());
m_settings->setGrayscaleSegments(set.value("grayscaleSegments", false).toBool());
Expand Down Expand Up @@ -2283,6 +2293,9 @@ void frmMain::saveSettings()
set.setValue("msaa", m_settings->msaa());
set.setValue("vsync", m_settings->vsync());
set.setValue("zBuffer", m_settings->zBuffer());
set.setValue("fov", m_settings->fov());
set.setValue("nearPlane", m_settings->nearPlane());
set.setValue("farPlane", m_settings->farPlane());
set.setValue("simplify", m_settings->simplify());
set.setValue("simplifyPrecision", m_settings->simplifyPrecision());
set.setValue("grayscaleSegments", m_settings->grayscaleSegments());
Expand Down Expand Up @@ -2472,6 +2485,9 @@ void frmMain::applySettings() {
ui->glwVisualizer->setAntialiasing(m_settings->antialiasing());
ui->glwVisualizer->setMsaa(m_settings->msaa());
ui->glwVisualizer->setZBuffer(m_settings->zBuffer());
ui->glwVisualizer->setFov(m_settings->fov());
ui->glwVisualizer->setNearPlane(m_settings->nearPlane());
ui->glwVisualizer->setFarPlane(m_settings->farPlane());
ui->glwVisualizer->setVsync(m_settings->vsync());
ui->glwVisualizer->setFps(m_settings->fps());
ui->glwVisualizer->setColorBackground(m_settings->colors("VisualizerBackground"));
Expand Down Expand Up @@ -2518,13 +2534,15 @@ void frmMain::applySettings() {
.arg(normal.name()).arg(highlight.name())
.arg(base.name()));

ui->cmdToggleProjection->setIcon(QIcon(":/images/toggle.png"));
ui->cmdFit->setIcon(QIcon(":/images/fit_1.png"));
ui->cmdIsometric->setIcon(QIcon(":/images/cube.png"));
ui->cmdFront->setIcon(QIcon(":/images/cubeFront.png"));
ui->cmdLeft->setIcon(QIcon(":/images/cubeLeft.png"));
ui->cmdTop->setIcon(QIcon(":/images/cubeTop.png"));

if (!light) {
Util::invertButtonIconColors(ui->cmdToggleProjection);
Util::invertButtonIconColors(ui->cmdFit);
Util::invertButtonIconColors(ui->cmdIsometric);
Util::invertButtonIconColors(ui->cmdFront);
Expand Down
1 change: 1 addition & 0 deletions src/candle/frmmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ private slots:
void on_cmdFront_clicked();
void on_cmdLeft_clicked();
void on_cmdIsometric_clicked();
void on_cmdToggleProjection_clicked();
void on_cmdFit_clicked();
void on_grpOverriding_toggled(bool checked);
void on_grpSpindle_toggled(bool checked);
Expand Down
26 changes: 26 additions & 0 deletions src/candle/frmmain.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,32 @@ QLabel[overrided="false"] {
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="cmdToggleProjection">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>Toggle perspective/orthographic projection</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/toggle.png</normaloff>:/images/toggle.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="cmdTop">
<property name="minimumSize">
Expand Down
27 changes: 27 additions & 0 deletions src/candle/frmsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,30 @@ void frmSettings::setZBuffer(bool zBuffer)
ui->chkZBuffer->setChecked(zBuffer);
}

double frmSettings::fov() {
return ui->txtFov->value();
}

void frmSettings::setFov(double fov) {
ui->txtFov->setValue(fov);
}

double frmSettings::nearPlane() {
return ui->txtNear->value();
}

void frmSettings::setNearPlane(double near) {
ui->txtNear->setValue(near);
}

double frmSettings::farPlane() {
return ui->txtFar->value();
}

void frmSettings::setFarPlane(double far) {
ui->txtFar->setValue(far);
}

double frmSettings::lineWidth()
{
return ui->txtLineWidth->value();
Expand Down Expand Up @@ -815,6 +839,9 @@ void frmSettings::on_cmdDefaults_clicked()
setSimplifyPrecision(0.0);
setFps(60);
setZBuffer(false);
setFov(60.0);
setNearPlane(0.5);
setFarPlane(10000.0);
setGrayscaleSegments(false);
setGrayscaleSCode(true);
setDrawModeVectors(true);
Expand Down
6 changes: 6 additions & 0 deletions src/candle/frmsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ class frmSettings : public QDialog
void setAntialiasing(bool antialiasing);
bool zBuffer();
void setZBuffer(bool zBuffer);
double fov();
void setFov(double fov);
double nearPlane();
void setNearPlane(double nearPlane);
double farPlane();
void setFarPlane(double farPlane);
double lineWidth();
void setLineWidth(double lineWidth);
double arcLength();
Expand Down
94 changes: 94 additions & 0 deletions src/candle/frmsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,100 @@ QSplitter::handle:horizontal {
</item>
</layout>
</item>

<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_1">
<item>
<widget class="QLabel" name="label_1">
<property name="text">
<string>FOV:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="txtFov">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>20</double>
</property>
<property name="maximum">
<double>179</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Near plane:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="txtNear">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>0.01</double>
</property>
<property name="maximum">
<double>100000.00</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="4">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Far plane:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="txtFar">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>0.01</double>
</property>
<property name="maximum">
<double>100000.00</double>
</property>
</widget>
</item>
</layout>
</item>



</layout>
</widget>
</item>
Expand Down
1 change: 1 addition & 0 deletions src/candle/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
<file>images/gpilot_256.png</file>
<file>images/gpilot_icon.png</file>
<file>images/gpilot.ico</file>
<file>images/toggle.png</file>
</qresource>
</RCC>
Binary file added src/candle/images/toggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b515257

Please sign in to comment.