Tools to generate CNC toolpaths and G-Code. More...

Modules

 Parameters helper macros
 Collections of macros for managing groups of parameters.
 

Detailed Description

Tools to generate CNC toolpaths and G-Code.

Parameter helper macros

Motivation

For an application like FreeCAD, there are often cases where the same set of parameters are referred in dozons of different places. The macros here is designed to help managing those parameters, so that you can define groups of parameters once, and refer them everywhere in groups with simple macro calls for all kinds of purposes. Any changing, adding and removing of parameters in the group become much easier. And by everywhere, I mean class definition, implementation, document object properties, python c++ classes, and even doc string, pretty much everything except the python code, which although not implemented yet, is in fact also possible to be done using C preprocessor (No one says C preprocessor must produce C code :). It is also possible (not implemented yet) to use macros to generate python wrapper class instead of using FreeCAD's current xml python export.

Debugging

Extensive use of macros has one noticeable disadvantage, though. If some thing goes wrong, the compiler error message is kind of cryptic. If so, first double check your macro definition of the parameter is correctly, not missing or having extra parathesis or comma. Then, you can use the CMake intermediate file target to get the preprocessor output for checking. For example, for a file located at src/Mod/Path/App/Area.cpp,

cd <your_build_dir>/src/Mod/Path/App
make Area.cpp.i

The preprocessed intermediate output will be at,

<your_build_dir>/src/Mod/Path/App.CMakeFiles/Path.dir/Area.cpp.i

Introduction

The macros here make heavy use of the awesome Boost.Preprocessor (short for Boost.PP). Here are is a brief introduction on Boost.PP concept in order to explain why this marco library is designed the way it is.

In Boost.PP, a sequence is defined as,

(a)(b)(c)...

A sequence cannot be empty. Thus, () is not a sequence. And also those a, b, c here cannot directly contain ,. These restriction is due to the fact that ( ) , are among those very few special characters recognized by the preprocssor. a can itself be a sequence or other Boost.PP types, so by right, our parameter can be defined as something like

((type)(name)(default)...)

A bit awkward to write. So another Boost.PP type is chosen, tuple, to define each individual parameter. A tuple is defined as

(a,b,c ...)

This is why the parameter definition requires a double parathesis, as shown in the following section.

Overview

In this macro library, a parameter is defined using a tuple inside a sequence,

((<type>, <arg>, <name>, <default>, <doc>, <seq>, <info>))
  • type is the type of the parameter. Currently only five types of parameters are defined, short, long, double, bool, enum, enum2.