Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworked visualizer navigation #516

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,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 @@ -300,7 +301,8 @@ bool frmMain::isGCodeFile(QString fileName)
|| fileName.endsWith(".nc", Qt::CaseInsensitive)
|| fileName.endsWith(".ncc", Qt::CaseInsensitive)
|| fileName.endsWith(".ngc", Qt::CaseInsensitive)
|| fileName.endsWith(".tap", Qt::CaseInsensitive);
|| fileName.endsWith(".tap", Qt::CaseInsensitive)
|| fileName.endsWith(".gcode", Qt::CaseInsensitive);
}

bool frmMain::isHeightmapFile(QString fileName)
Expand Down Expand Up @@ -344,6 +346,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 @@ -495,6 +500,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 @@ -1431,6 +1439,7 @@ void frmMain::placeVisualizerButtons()
ui->cmdFront->move(ui->cmdLeft->geometry().left() - ui->cmdFront->width() - 8, ui->cmdIsometric->geometry().bottom() + 8);
// ui->cmdFit->move(ui->cmdTop->geometry().left() - ui->cmdFit->width() - 10, 10);
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::showEvent(QShowEvent *se)
Expand Down Expand Up @@ -1609,7 +1618,7 @@ void frmMain::on_cmdFileOpen_clicked()
if (!saveChanges(false)) return;

QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), m_lastFolder,
tr("G-Code files (*.nc *.ncc *.ngc *.tap *.txt);;All files (*.*)"));
tr("G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt);;All files (*.*)"));

if (!fileName.isEmpty()) m_lastFolder = fileName.left(fileName.lastIndexOf(QRegExp("[/\\\\]+")));

Expand Down Expand Up @@ -2201,6 +2210,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 @@ -2255,13 +2267,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 Expand Up @@ -2618,7 +2632,7 @@ bool frmMain::saveProgramToFile(QString fileName, GCodeTableModel *model)

void frmMain::on_actFileSaveTransformedAs_triggered()
{
QString fileName = (QFileDialog::getSaveFileName(this, tr("Save file as"), m_lastFolder, tr("G-Code files (*.nc *.ncc *.ngc *.tap *.txt)")));
QString fileName = (QFileDialog::getSaveFileName(this, tr("Save file as"), m_lastFolder, tr("G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt)")));

if (!fileName.isEmpty()) {
saveProgramToFile(fileName, &m_programHeightmapModel);
Expand All @@ -2628,7 +2642,7 @@ void frmMain::on_actFileSaveTransformedAs_triggered()
void frmMain::on_actFileSaveAs_triggered()
{
if (!m_heightMapMode) {
QString fileName = (QFileDialog::getSaveFileName(this, tr("Save file as"), m_lastFolder, tr("G-Code files (*.nc *.ncc *.ngc *.tap *.txt)")));
QString fileName = (QFileDialog::getSaveFileName(this, tr("Save file as"), m_lastFolder, tr("G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt)")));

if (!fileName.isEmpty()) if (saveProgramToFile(fileName, &m_programModel)) {
m_programFileName = fileName;
Expand Down Expand Up @@ -2689,6 +2703,10 @@ void frmMain::on_cmdIsometric_clicked()
ui->glwVisualizer->setIsometricView();
}

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

void frmMain::on_actAbout_triggered()
{
m_frmAbout.exec();
Expand Down
1 change: 1 addition & 0 deletions src/frmmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ private slots:
void on_cmdFront_clicked();
void on_cmdLeft_clicked();
void on_cmdIsometric_clicked();
void on_cmdToggleProjection_clicked();
void on_actAbout_triggered();
void on_grpOverriding_toggled(bool checked);
void on_grpSpindle_toggled(bool checked);
Expand Down
27 changes: 27 additions & 0 deletions src/frmmain.ui
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,32 @@ QSlider::handle:horizontal:hover {
</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="QSplitter" name="splitter">
<property name="orientation">
Expand Down Expand Up @@ -2762,6 +2788,7 @@ padding-right: 8;</string>
<tabstop>cmdIsometric</tabstop>
<tabstop>cmdFront</tabstop>
<tabstop>cmdLeft</tabstop>
<tabstop>cmdToggleProjection</tabstop>
<tabstop>cmdFit</tabstop>
<tabstop>tblProgram</tabstop>
<tabstop>tblHeightMap</tabstop>
Expand Down
27 changes: 27 additions & 0 deletions src/frmsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,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 @@ -656,6 +680,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/frmsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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
90 changes: 90 additions & 0 deletions src/frmsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,96 @@ QGroupBox {
</property>
</widget>
</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>
</item>
</layout>
Expand Down
1 change: 1 addition & 0 deletions src/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
<file>images/num4.png</file>
<file>images/handle2s1.png</file>
<file>images/brake.png</file>
<file>images/toggle.png</file>
</qresource>
</RCC>
Binary file added src/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.
16 changes: 8 additions & 8 deletions src/translations/candle_es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,8 @@
<message>
<location filename="../frmmain.cpp" line="2613"/>
<location filename="../frmmain.cpp" line="2623"/>
<source>G-Code files (*.nc *.ncc *.ngc *.tap *.txt)</source>
<translation>Archivos de G-Code (*.nc *.ncc *.ngc *.tap *.txt)</translation>
<source>G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt)</source>
<translation>Archivos de G-Code (*.nc *.ncc *.ngc *.gcode *.tap *.txt)</translation>
</message>
<message>
<source>Connected</source>
Expand Down Expand Up @@ -905,16 +905,16 @@ Tiempo transcurrido: %1</translation>
<translation>Envio de archivo en progreso. Detener y salir?</translation>
</message>
<message>
<source>G-Code files (*.nc *.ncc *.tap *.txt);;All files (*.*)</source>
<translation type="vanished">Archivos de G-Code (*.nc *.ncc *.tap *.txt);;Todos los archivos (*.*)</translation>
<source>G-Code files (*.nc *.ncc *.gcode *.tap *.txt);;All files (*.*)</source>
<translation type="vanished">Archivos de G-Code (*.nc *.ncc *.gcode *.tap *.txt);;Todos los archivos (*.*)</translation>
</message>
<message>
<source>Sent</source>
<translation type="vanished">Enviado</translation>
</message>
<message>
<source>G-Code files (*.nc *.ncc *.tap *.txt)</source>
<translation type="vanished">Archivos de G-Code (*.nc *.ncc *.tap *.txt)</translation>
<source>G-Code files (*.nc *.ncc *.gcode *.tap *.txt)</source>
<translation type="vanished">Archivos de G-Code (*.nc *.ncc *.gcode *.tap *.txt)</translation>
</message>
<message>
<location filename="../frmmain.cpp" line="1628"/>
Expand All @@ -938,8 +938,8 @@ Tiempo transcurrido: %1</translation>
</message>
<message>
<location filename="../frmmain.cpp" line="1615"/>
<source>G-Code files (*.nc *.ncc *.ngc *.tap *.txt);;All files (*.*)</source>
<translation>Archivos de G-Code (*.nc *.ncc *.ngc *.tap *.txt);;Todos los archivos (*.*)</translation>
<source>G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt);;All files (*.*)</source>
<translation>Archivos de G-Code (*.nc *.ncc *.ngc *.gcode *.tap *.txt);;Todos los archivos (*.*)</translation>
</message>
<message>
<location filename="../frmmain.cpp" line="1777"/>
Expand Down
8 changes: 4 additions & 4 deletions src/translations/candle_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,8 @@ Temps écoulé: %1</translation>
</message>
<message>
<location filename="../frmmain.cpp" line="1615"/>
<source>G-Code files (*.nc *.ncc *.ngc *.tap *.txt);;All files (*.*)</source>
<translation>G-Code fichiers (*.nc *.ncc *.ngc *.tap *.txt);;Tous les fichiers (*.*)</translation>
<source>G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt);;All files (*.*)</source>
<translation>G-Code fichiers (*.nc *.ncc *.ngc *.gcode *.tap *.txt);;Tous les fichiers (*.*)</translation>
</message>
<message>
<location filename="../frmmain.cpp" line="1704"/>
Expand Down Expand Up @@ -970,8 +970,8 @@ Temps écoulé: %1</translation>
<message>
<location filename="../frmmain.cpp" line="2613"/>
<location filename="../frmmain.cpp" line="2623"/>
<source>G-Code files (*.nc *.ncc *.ngc *.tap *.txt)</source>
<translation>G-Code fichiers (*.nc *.ncc *.ngc *.tap *.txt)</translation>
<source>G-Code files (*.nc *.ncc *.ngc *.gcode *.tap *.txt)</source>
<translation>G-Code fichiers (*.nc *.ncc *.ngc *.gcode *.tap *.txt)</translation>
</message>
<message>
<location filename="../frmmain.cpp" line="3119"/>
Expand Down
Loading