Not sure what a “library” has to do with it? Qt treats libraries in 2 ways - static, where the code is complied and linked IN the app binary OR dynamic, where the code is compiled and a dll is created, which is linked at run time. You can do it either way with same code, and in end makes no operational difference. Dll’s are usually used where the author does not wish to release the source code.
That being said… the bulk of the Seamly apps are libraries. Specific to the formulas, RT ported the MuParser math parser to Qt… thus QMuParser. For whatever reason, it’s built as a dll?
Now for a rough flow outline:
Load pattern from XML to a QDomDocument in memory.
Parse Increments.
Parse Draw Elements (AKA draft blocks).
Within each Draw element parse each child tool element in sequential order followed by the detail ( pattern piece) elements.
As each tool is parsed, each formula is 1st translated. Then the formula is evaluated. 1st to see if any variables (increments, measurements, other tool variables) or math tokens exist, if not it’s just a number - no calculation required - return number. If there are tokens then the formula is Eval()'d, where the variables are replaced with their value. Then the formula is math parsed via QMuParser, and the final calc returned.
Since each tool is built sequentially, only the tool variables (line length / angle, etc) that were created BEFORE are available to be Eval()'d. THAT’S why future tool variables are NOT yet available to use in tools created before hand - they’re not in the data container yet.
I should note that as each tool is created, for each other parent tool it references, it calls that tool’s IncrementReferens(parentId), which increments it’s use counter by 1, and if that tool is deleted it calls the DecrementReferens(patentId) of each parent. So if you go to delete a tool where it’s use count > 0, you can’t delete it, until all child tools are deleted.
Editing a tool’s formula in a dialog or the Properties Editor that changes geometry will probably trigger a reparse of the pattern via the same evaluation of the formulas.
That’s it in a nutshell.
The language used was not a big issue for me since I’ve learned dozens of languages over 45+ years (including Java), it was easy to pick up the bulk of the syntax of C++ in a couple weeks. It’s the learning the Qt api that takes a long time… not to mention reading through piles of poorly styled code.