Skip to content

Commit

Permalink
Base translation added.
Browse files Browse the repository at this point in the history
G53 added to "Return" command.
Rapid speed setting added to calculate estimated job time.
  • Loading branch information
Denvi committed Aug 9, 2015
1 parent 4f16242 commit 915502b
Show file tree
Hide file tree
Showing 9 changed files with 796 additions and 122 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

29 changes: 17 additions & 12 deletions frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ frmMain::frmMain(QWidget *parent) :
ui->setupUi(this);

ui->txtJogStep->setLocale(QLocale::C);
m_frmSettings.layout()->setSizeConstraint(QLayout::SetFixedSize);
// m_frmSettings.layout()->setSizeConstraint(QLayout::SetFixedSize);

m_frmSettings.setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);

m_settingsFileName = qApp->applicationDirPath() + "/settings.ini";
loadSettings();
Expand Down Expand Up @@ -122,6 +124,7 @@ void frmMain::loadSettings()
m_frmSettings.setArcPrecision(set.value("arcPrecision", 0).toDouble());
m_frmSettings.setShowAllCommands(set.value("showAllCommands", 0).toBool());
m_frmSettings.setSafeZ(set.value("safeZ", 0).toDouble());
m_frmSettings.setRapidSpeed(set.value("rapidSpeed", 0).toDouble());
ui->chkAutoScroll->setChecked(set.value("autoScroll", false).toBool());
ui->tblProgram->horizontalHeader()->restoreState(set.value("header", QByteArray()).toByteArray());

Expand Down Expand Up @@ -149,6 +152,7 @@ void frmMain::saveSettings()
set.setValue("arcPrecision", m_frmSettings.arcPrecision());
set.setValue("showAllCommands", m_frmSettings.showAllCommands());
set.setValue("safeZ", m_frmSettings.safeZ());
set.setValue("rapidSpeed", m_frmSettings.rapidSpeed());
set.setValue("autoScroll", ui->chkAutoScroll->isChecked());
set.setValue("header", ui->tblProgram->horizontalHeader()->saveState());
set.setValue("splitter", ui->splitter->saveState());
Expand Down Expand Up @@ -540,6 +544,7 @@ void frmMain::processFile(QString fileName)
ui->tblProgram->setModel(NULL);

GcodeParser gp;
gp.setTraverseSpeed(m_rapidSpeed);

while (!textStream.atEnd())
{
Expand All @@ -557,7 +562,7 @@ void frmMain::processFile(QString fileName)
ui->tblProgram->setModel(&m_tableModel);
ui->tblProgram->horizontalHeader()->restoreState(headerState);

m_viewParser.reset();
m_viewParser.reset();
updateProgramEstimatedTime(m_viewParser.getLinesFromParser(&gp, m_frmSettings.arcPrecision()));

ui->glwVisualizator->fitDrawables();
Expand Down Expand Up @@ -642,6 +647,7 @@ void frmMain::on_tblProgram_cellChanged(QModelIndex i1, QModelIndex i2)
// QList<QString> commands;

GcodeParser gp;
gp.setTraverseSpeed(m_rapidSpeed);

for (int i = 0; i < m_tableModel.rowCount() - 1; i++) {
gp.addCommand(m_tableModel.data(m_tableModel.index(i, 1)).toString());
Expand Down Expand Up @@ -684,6 +690,7 @@ void frmMain::applySettings() {
ui->glwVisualizator->setLineWidth(m_frmSettings.lineWidth());
m_showAllCommands = m_frmSettings.showAllCommands();
m_safeZ = m_frmSettings.safeZ();
m_rapidSpeed = m_frmSettings.rapidSpeed();
ui->glwVisualizator->setAntialiasing(m_frmSettings.antialiasing());
ui->glwVisualizator->update();
}
Expand Down Expand Up @@ -731,8 +738,7 @@ void frmMain::on_cmdZeroZ_clicked()
void frmMain::on_cmdReturnXY_clicked()
{
sendCommand(QString("G21"));
sendCommand(QString("G92.1"));
sendCommand(QString("G90G0X%1Y%2").arg(m_storedX).arg(m_storedY));
sendCommand(QString("G53G90G0X%1Y%2").arg(m_storedX).arg(m_storedY));
sendCommand(QString("G92X0Y0Z%1").arg(ui->txtMPosZ->text().toDouble() - m_storedZ));
}

Expand All @@ -750,8 +756,7 @@ void frmMain::on_cmdTopZ_clicked()
{

sendCommand(QString("G21"));
sendCommand(QString("G90 G0Z%1").arg(m_safeZ - ui->txtMPosZ->text().toDouble()
+ ui->txtWPosZ->text().toDouble()));
sendCommand(QString("G53G90G0Z%1").arg(m_safeZ));
}

void frmMain::on_cmdSpindle_clicked(bool checked)
Expand All @@ -778,37 +783,37 @@ void frmMain::on_sliSpindleSpeed_valueChanged(int value)
void frmMain::on_cmdYPlus_clicked()
{
sendCommand("$G");
sendCommand("G91 G0 Y" + ui->txtJogStep->text());
sendCommand("G91G0Y" + ui->txtJogStep->text());
}

void frmMain::on_cmdYMinus_clicked()
{
sendCommand("$G");
sendCommand("G91 G0 Y-" + ui->txtJogStep->text());
sendCommand("G91G0Y-" + ui->txtJogStep->text());
}

void frmMain::on_cmdXPlus_clicked()
{
sendCommand("$G");
sendCommand("G91 G0 X" + ui->txtJogStep->text());
sendCommand("G91G0X" + ui->txtJogStep->text());
}

void frmMain::on_cmdXMinus_clicked()
{
sendCommand("$G");
sendCommand("G91 G0 X-" + ui->txtJogStep->text());
sendCommand("G91G0X-" + ui->txtJogStep->text());
}

void frmMain::on_cmdZPlus_clicked()
{
sendCommand("$G");
sendCommand("G91 G0 Z" + ui->txtJogStep->text());
sendCommand("G91G0Z" + ui->txtJogStep->text());
}

void frmMain::on_cmdZMinus_clicked()
{
sendCommand("$G");
sendCommand("G91 G0 Z-" + ui->txtJogStep->text());
sendCommand("G91G0Z-" + ui->txtJogStep->text());
}

void frmMain::on_chkTestMode_clicked()
Expand Down
1 change: 1 addition & 0 deletions frmmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ private slots:
double m_storedY = 0;
double m_storedZ = 0;
double m_safeZ = 0;
double m_rapidSpeed = 0;

bool m_settingZeroXY = false;
bool m_settingZeroZ = false;
Expand Down
13 changes: 13 additions & 0 deletions frmsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ frmSettings::frmSettings(QWidget *parent) :
validator->setTop(65535);
ui->txtSafeZ->setValidator(validator);

validator->setBottom(0);
ui->txtRapidSpeed->setValidator(validator);

searchPorts();
}

Expand Down Expand Up @@ -124,6 +127,16 @@ void frmSettings::setSafeZ(double safeZ)
ui->txtSafeZ->setText(QString::number(safeZ));
}

double frmSettings::rapidSpeed()
{
return ui->txtRapidSpeed->text().toDouble();
}

void frmSettings::setRapidSpeed(double rapidSpeed)
{
ui->txtRapidSpeed->setText(QString::number(rapidSpeed));
}

void frmSettings::searchPorts()
{
ui->cboPort->clear();
Expand Down
2 changes: 2 additions & 0 deletions frmsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class frmSettings : public QDialog
void setShowAllCommands(bool showAllCommands);
double safeZ();
void setSafeZ(double safeZ);
double rapidSpeed();
void setRapidSpeed(double rapidSpeed);


private slots:
Expand Down
76 changes: 16 additions & 60 deletions frmsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@
<rect>
<x>0</x>
<y>0</y>
<width>389</width>
<width>350</width>
<height>554</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
Expand Down Expand Up @@ -145,12 +139,6 @@
</item>
<item>
<widget class="QLineEdit" name="txtLineWidth">
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
Expand All @@ -168,12 +156,6 @@
</item>
<item>
<widget class="QLineEdit" name="txtArcPrecision">
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
Expand Down Expand Up @@ -205,12 +187,6 @@
</property>
<item row="1" column="1">
<widget class="QLineEdit" name="txtToolDiameter">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
Expand Down Expand Up @@ -238,12 +214,6 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Flat</string>
Expand All @@ -268,12 +238,6 @@
</item>
<item row="1" column="5">
<widget class="QLineEdit" name="txtToolLength">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
Expand All @@ -294,12 +258,6 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
Expand All @@ -314,7 +272,7 @@
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>GRBL Control</string>
<string>GRBL</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
Expand All @@ -331,12 +289,6 @@
</item>
<item>
<widget class="QLineEdit" name="txtSafeZ">
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
Expand All @@ -346,17 +298,21 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Rapid speed:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtRapidSpeed">
<property name="text">
<string>0</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</spacer>
</widget>
</item>
</layout>
</item>
Expand Down Expand Up @@ -397,7 +353,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Show G-code program commands in console</string>
<string>Show G-code program commands</string>
</property>
</widget>
</item>
Expand Down
9 changes: 9 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ int main(int argc, char *argv[])
if (translator->load(translationFileName)) a.installTranslator(translator); else delete translator;
}

QString baseTranslationFileName = translationsFolder + "qtbase_" + loc + ".qm";

if(QFile::exists(translationFileName)) {

QTranslator* baseTranslator = new QTranslator();

if (baseTranslator->load(baseTranslationFileName)) a.installTranslator(baseTranslator); else delete baseTranslator;
}

frmMain w;
w.show();

Expand Down
Binary file modified translations/grblControl_ru.qm
Binary file not shown.
Loading

0 comments on commit 915502b

Please sign in to comment.