Skip to content

Commit e394023

Browse files
committed
Updates for cbang changes
1 parent 3f11243 commit e394023

File tree

11 files changed

+53
-58
lines changed

11 files changed

+53
-58
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ by C!, can be installed with the following command line:
5656

5757
sudo apt-get update
5858
sudo apt-get -y install scons build-essential libqt5websockets5-dev \
59-
libqt5opengl5-dev libnode-dev libglu1-mesa-dev pkgconf git
59+
libqt5opengl5-dev qttools5-dev-tools libnode-dev libglu1-mesa-dev \
60+
pkgconf git
6061

6162
## Building C! (cbang)
6263
Clone the C! git repository, build the software using scons and set the
6364
environment variable CBANG_HOME so the CAMotics build system can find it
64-
later. **You must install V8 or ChakraCore before this step.**
65+
later. **You must install V8 before this step.**
6566

6667
git clone https://github.com/CauldronDevelopmentLLC/cbang.git
6768
scons -C cbang

SConstruct

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ env.CBAddVariables(
2121
('python_version', 'Set python version', '3'),
2222
BoolVariable('with_tpl', 'Enable TPL', True),
2323
BoolVariable('with_gui', 'Enable graphical user interface', True),
24-
BoolVariable('wrap_glibc', 'Enable GlibC function wrapping',
25-
env['PLATFORM'] == 'posix'),
24+
BoolVariable('wrap_glibc', 'Enable GlibC function wrapping', False)
2625
)
2726
conf = env.CBConfigure()
2827

@@ -70,14 +69,12 @@ if not env.GetOption('clean'):
7069

7170
conf.CBConfig('cbang')
7271
env.CBDefine('USING_CBANG') # Using CBANG macro namespace
73-
for lib in 'mariadbclient snappy leveldb yaml re2 sqlite3'.split():
72+
for lib in 'mariadbclient snappy leveldb yaml sqlite3'.split():
7473
if lib in env['LIBS']: env['LIBS'].remove(lib)
7574

7675
# Include path
7776
env.AppendUnique(CPPPATH = ['#/src'])
7877

79-
if env['PLATFORM'] != 'win32': env.AppendUnique(CCFLAGS = ['-fPIC'])
80-
8178
# Python
8279
have_python = conf.CBConfig('python', False)
8380

@@ -176,8 +173,8 @@ if env['with_tpl']:
176173

177174
# DXFlib
178175
if not have_dxflib:
179-
libDXFlib = SConscript('src/dxflib/SConscript',
180-
variant_dir = 'build/dxflib')
176+
libDXFlib = SConscript(
177+
'src/dxflib/SConscript', variant_dir = 'build/dxflib')
181178
env.Append(LIBS = libDXFlib)
182179

183180

src/cairo/SConscript

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
Import('*')
22
env = env.Clone()
33

4-
if env['compiler_mode'] == 'gnu':
5-
env.AppendUnique(CCFLAGS = ['-Wno-enum-conversion'])
4+
if not env.GetOption('clean'):
5+
if env['compiler_mode'] == 'gnu':
6+
env.AppendUnique(CCFLAGS = ['-Wno-enum-conversion'])
67

78

8-
# Ignore warnings
9-
import re
10-
flags = env.subst('${CCFLAGS}')
11-
flags = re.sub(r'-W((all)|(error))(=[^\s$]+)?(\s|$)', '', flags)
12-
env.Replace(CCFLAGS = flags)
9+
# Ignore warnings
10+
import re
11+
flags = env.subst('${CCFLAGS}')
12+
flags = re.sub(r'-W((all)|(error))(=[^\s$]+)?(\s|$)', '', flags)
13+
env.Replace(CCFLAGS = flags)
1314

1415

15-
# Configure
16-
env.AppendUnique(CPPDEFINES = [
17-
'CAIRO_NO_MUTEX', 'HAVE_INTTYPES_H', 'CAIRO_HAS_IMAGE_SURFACE'])
18-
env.Append(CPPPATH = ['#/src/cairo'])
16+
# Configure
17+
env.AppendUnique(CPPDEFINES = [
18+
'CAIRO_NO_MUTEX', 'HAVE_INTTYPES_H', 'CAIRO_HAS_IMAGE_SURFACE'])
19+
env.Append(CPPPATH = ['#/src/cairo'])
1920

2021

2122
# Bulid library

src/camotics/contour/TriangleSurface.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,9 @@ void TriangleSurface::read(const JSON::Value &value) {
188188
if (value.hasList("vertices")) {
189189
vertices.clear();
190190
bounds = Rectangle3D();
191-
auto &l = value.get("vertices");
192191

193-
for (unsigned i = 0; i < l->size(); i++) {
194-
vertices.push_back(l->getNumber(i));
192+
for (auto &vert: *value.get("vertices")) {
193+
vertices.push_back(vert->getNumber());
195194

196195
unsigned n = vertices.size();
197196
if (n % 3 == 0)

src/camotics/machine/MachineModel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ void MachineModel::read(const JSON::Value &value) {
4040
workpiece.read(value.getList("workpiece"));
4141

4242
auto &parts = value.getDict("parts");
43-
for (unsigned i = 0; i < parts.size(); i++)
44-
add(new MachinePart(parts.keyAt(i), parts.get(i)));
43+
for (auto e: parts.entries())
44+
add(new MachinePart(e.key(), e.value()));
4545
}
4646

4747

src/camotics/machine/MachinePart.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ MachinePart::MachinePart(const string &name, const JSON::ValuePtr &config) :
3030

3131

3232
void MachinePart::read(const JSON::Value &value) {
33-
color.read(value.getList("color"));
34-
init.read(value.getList("init"));
35-
home.read(value.getList("home"));
36-
min.read(value.getList("min"));
37-
max.read(value.getList("max"));
33+
color .read(value.getList("color"));
34+
init .read(value.getList("init"));
35+
home .read(value.getList("home"));
36+
min .read(value.getList("min"));
37+
max .read(value.getList("max"));
3838
movement.read(value.getList("movement"));
3939

4040
if (value.hasList("lines")) {
4141
auto &lines = value.getList("lines");
42-
for (unsigned i = 0; i < lines.size(); i++)
43-
this->lines.push_back(lines.getNumber(i));
42+
for (auto &line: lines)
43+
this->lines.push_back(line->getNumber());
4444
}
4545

4646
auto &vertices = value.getList("mesh");

src/camotics/project/Files.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ string Files::getRelativePath(unsigned i) const {
4343
SmartPointer<File> Files::find(const string &_path) const {
4444
string path = SystemUtilities::absolute(directory, _path);
4545

46-
for (unsigned i = 0; i < size(); i++)
47-
if (path == files[i]->getPath()) return files[i];
46+
for (auto &file: files)
47+
if (path == file->getPath()) return file;
4848

4949
return 0;
5050
}
@@ -56,16 +56,16 @@ void Files::add(const string &path) {
5656

5757

5858
void Files::read(const JSON::Value &value) {
59-
for (unsigned i = 0; i < value.size(); i++)
60-
add(SystemUtilities::absolute(directory, value.getString(i)));
59+
for (auto v: value)
60+
add(SystemUtilities::absolute(directory, v->getString()));
6161
}
6262

6363

6464
void Files::write(JSON::Sink &sink) const {
6565
sink.beginList();
6666

67-
for (unsigned i = 0; i < files.size(); i++)
68-
sink.append(get(i)->getRelativePath(directory));
67+
for (auto &file: files)
68+
sink.append(file->getRelativePath(directory));
6969

7070
sink.endList();
7171
}

src/camotics/qt/BBCtrlAPI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ void BBCtrlAPI::onTextMessageReceived(const QString &message) {
165165

166166
bool updatePosition = false;
167167

168-
for (unsigned i = 0; i < json->size(); i++) {
169-
string key = json->keyAt(i);
170-
vars.insert(key, json->get(key));
168+
for (auto e: json->entries()) {
169+
auto &key = e.key();
170+
vars.insert(key, e.value());
171171

172172
if (key == "xp" || key == "yp" || key == "zp" ||
173173
key == "offset_x" || key == "offset_y" || key == "offset_z")

src/gcode/ToolPath.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ int ToolPath::find(double time) const {return find(time, 0, size());}
5959
void ToolPath::read(const JSON::Value &value) {
6060
GCode::Axes start;
6161
GCode::MoveType type = GCode::MoveType::MOVE_RAPID;
62-
int line = 0;
6362
SmartPointer<string> filename;
64-
int tool = 1;
65-
double feed = 0;
63+
int line = 0;
64+
int tool = 1;
65+
double feed = 0;
6666
double speed = 0;
67-
double time = 0;
67+
double time = 0;
6868

69-
for (unsigned i = 0; i < value.size(); i++) {
70-
auto &dict = value.getDict(i);
69+
for (auto v: value) {
70+
auto &dict = v->getDict();
7171

7272
GCode::Axes end;
7373
for (int j = 0; j < 9; j++)
@@ -82,9 +82,9 @@ void ToolPath::read(const JSON::Value &value) {
8282
filename = new string(_filename);
8383
}
8484

85-
line = dict.getNumber("line", line);
86-
tool = dict.getNumber("tool", tool);
87-
feed = dict.getNumber("feed", feed);
85+
line = dict.getNumber("line", line);
86+
tool = dict.getNumber("tool", tool);
87+
feed = dict.getNumber("feed", feed);
8888
speed = dict.getNumber("speed", speed);
8989
double delta = dict.getNumber("time", 0);
9090

src/gcode/ToolTable.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,9 @@ void ToolTable::add(const Tool &tool) {
7878
void ToolTable::read(const JSON::Value &value) {
7979
clear();
8080

81-
for (unsigned i = 0; i < value.size(); i++) {
82-
string key = value.keyAt(i);
83-
unsigned number = String::parseU32(key);
84-
Tool tool(number);
85-
86-
tool.read(value.getDict(i));
81+
for (auto e: value.entries()) {
82+
Tool tool(String::parseU32(e.key()));
83+
tool.read(e.value()->getDict());
8784
set(tool);
8885
}
8986
}

0 commit comments

Comments
 (0)