-
-
Notifications
You must be signed in to change notification settings - Fork 557
/
Copy pathmain.cpp
158 lines (125 loc) · 5.84 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich
#include "frmmain.h"
#include "gcodepreprocessorutils.h"
#include "gcodeparser.h"
#include "gcodeviewparse.h"
#include <QApplication>
#include <QDebug>
#include <QGLWidget>
#include <QLocale>
#include <QTranslator>
#include <QFile>
#include <QStyleFactory>
#include <QFontDatabase>
#include <QMessageBox>
int main(int argc, char *argv[])
{
#ifdef UNIX
bool styleOverrided = false;
for (int i = 0; i < argc; i++) if (QString(argv[i]).toUpper() == "-STYLE") {
styleOverrided = true;
break;
}
#endif
QApplication a(argc, argv);
// QFontDatabase::addApplicationFont(":/fonts/segoeui.ttf");
// QFontDatabase::addApplicationFont(":/fonts/tahoma.ttf");
#ifdef GLES
QFontDatabase::addApplicationFont(":/fonts/Ubuntu-R.ttf");
#endif
QGLFormat glf = QGLFormat::defaultFormat();
glf.setSampleBuffers(true);
glf.setSamples(8);
QGLFormat::setDefaultFormat(glf);
// QLocale::setDefault(QLocale("fr"));
QString loc = QLocale().name().left(2);
QString translationsFolder = qApp->applicationDirPath() + "/translations/";
QString translationFileName = translationsFolder + "grblControl_" + loc + ".qm";
qDebug() << "locale:" << loc;
if(QFile::exists(translationFileName)) {
QTranslator* translator = new QTranslator();
if (translator->load(translationFileName)) a.installTranslator(translator); else delete translator;
}
QString baseTranslationFileName = translationsFolder + "qt_" + loc + ".qm";
if(QFile::exists(translationFileName)) {
QTranslator* baseTranslator = new QTranslator();
if (baseTranslator->load(baseTranslationFileName)) a.installTranslator(baseTranslator); else delete baseTranslator;
}
a.setApplicationVersion(APP_VERSION);
#ifdef UNIX
if (!styleOverrided) foreach (QString str, QStyleFactory::keys()) {
if (str.contains("GTK+")) {
a.setStyle(QStyleFactory::create(str));
break;
}
}
#endif
#ifdef GLES
a.setStyle(QStyleFactory::create("Fusion"));
QPalette palette;
palette.setColor(QPalette::Highlight, QColor(204, 204, 254));
palette.setColor(QPalette::HighlightedText, QColor(0, 0, 0));
a.setPalette(palette);
a.setStyleSheet("QWidget {font-family: \"Ubuntu\";}\
QMenuBar {background-color: #303030; padding-top: 2px; padding-bottom: 2px;}\
QMenuBar::item {spacing: 3px; padding: 2px 8px; background: transparent; color: white;}\
QMenuBar::item:pressed {border: 1px solid #505050; border-bottom: 1px; border-top-left-radius: 3px; border-top-right-radius: 3px; background: #404040; color: white;}\
QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white;}\
QDialog {border: 1px solid palette(mid);}");
#endif
a.setStyleSheet(a.styleSheet() + "QWidget {font-size: 8pt}");
frmMain w;
w.show();
// qDebug() << GcodePreprocessorUtils::overrideSpeed("G0 X0 Y10 Z200 F123", 50);
// qDebug() << GcodePreprocessorUtils::removeComment("G1 X10 ((test comment 1))");
// qDebug() << GcodePreprocessorUtils::removeComment("G1 X10 ;;test comment 2");
// qDebug() << GcodePreprocessorUtils::parseComment("G1 X10 ((test comment 1))");
// qDebug() << GcodePreprocessorUtils::parseComment("G1 X10 ;;test comment 2");
// qDebug() << GcodePreprocessorUtils::truncateDecimals(1, "G0 X123.4456 Y3.12345 Z0.5");
// qDebug() << GcodePreprocessorUtils::removeAllWhitespace(" test spaces ");
// qDebug() << GcodePreprocessorUtils::parseCodes(QString("G0 X123.4456 Y3.12345 Z0.5").split(' '), 'X');
// qDebug() << GcodePreprocessorUtils::parseGCodes("G0 G02 G12 G3 G021 M03");
// qDebug() << GcodePreprocessorUtils::parseMCodes("G0 G02 G12 G3 G021 M03");
// qDebug() << GcodePreprocessorUtils::splitCommand("G0 X123.4456 Y3.12345 Z0.5");
// qDebug() << GcodePreprocessorUtils::updatePointWithCommand("G0 X10 Y20 Z30", QVector3D(10, 10, 10), false);
// qDebug() << GcodePreprocessorUtils::updateCenterWithCommand(GcodePreprocessorUtils::splitCommand("G0 X10 Y20 I0 J20 K6"), QVector3D(10, 10, 10), QVector3D(20, 20, 20), false, true);
// qDebug() << GcodePreprocessorUtils::generateG1FromPoints(QVector3D(10, 10, 10), QVector3D(20, 20, 20), true, 3);
// qDebug() << GcodePreprocessorUtils::getAngle(QVector3D(0, 0, 0), QVector3D(-10, 0, 10));
// qDebug() << GcodePreprocessorUtils::calculateSweep(M_PI / 2, 0, false);
// qDebug() << GcodePreprocessorUtils::generatePointsAlongArcBDring(QVector3D(10, 0, 0), QVector3D(0, 10, 0), QVector3D(0, 0, 0), false, 10, 0.1, 5);
// GcodeParser gp;
// gp.addCommand("G1 X0 Y10");
// gp.addCommand("G1 X10 Y0");
// gp.addCommand("G1 X10 Y10 Z0");
// gp.addCommand("G2 X20 Y0 R10");
// qDebug() << "PointSegment list";
// for (int i = 0; i < 10000; i++) {
// GcodeParser gp1;
// gp1.addCommand("G1 X0 Y10");
// gp1.addCommand("G1 X10 Y0");
// gp1.addCommand("G1 X10 Y10 Z0");
// gp1.addCommand("G2 X20 Y0 R10");
// }
// foreach (PointSegment *ps, gp.getPointSegmentList()) {
// qDebug() << *ps->point() << ps->isArc() << ps->isClockwise();
// }
// GcodeViewParse gvp;
// QList<QString> commands;
// commands.append("G1 X0 Y10");
// commands.append("G1 X10 Y0");
// commands.append("G1 X10 Y10 Z0");
// commands.append("G2 X20 Y0 Z0 R10");
// qDebug() << "LineSegment list";
// for (int i = 0; i < 10000; i++)
// {
// GcodeViewParse gvp1;
// foreach (LineSegment* ls, gvp1.toObjRedux(commands, 5)) {
// }
// }
// foreach (LineSegment* ls, gvp.toObjRedux(commands, 5)) {
// qDebug() << ls->getStart() << ls->getEnd() << ls->getLineNumber() << ls->isArc();
// }
// return 0;
return a.exec();
}