LibreCAD 3 Development Logs

Development logs of GSoC 2017

No comments

The GSoC 2017 has ended and my project plan was completed.
It was modified during the coding period, the drawing order and optimizations were replaced by the creation of an OpenGL backend.

You can see the list of my commits on GitHub from the June 1st to the August 20st.
The OpenGL backend commits are not present.
Modifications were made to libdxfrw as well, this wasn't planned but it was required to load and save application data (group code 102).

List of commits by features
Blocks support
db707e3 06/06 - Add blocks support
e556fb7 06/13 - Fix a bug when removing Insert
a5b3499 06/13 - Block support (missing changes)
3d348d4 06/16 - Add ByBlock linewidth support
1625261 06/22 - Render of ByBlock line width and color
3cdaa75 06/24 - Render of ByBlock line pattern
9868d99 06/24 - Render of selected insert
fd8a553 06/24 - Insert bounding box

Custom entities
dad86e6 06/14 - Add plugin manager
cbe7278 06/15 - Prevent layer "0" from being removed
ee9fc84 06/19 - Read/write files in Lua
abba6eb 06/21 - UI dialog to choose a file
2269ec9 06/24 - Remove test plugin
5edfa90 06/26 - Add custom entity storage
ba6b675 06/26 - Add block operations (AddBlock, RemoveBlock, ReplaceBlock)
fcb4b8d 06/30 - Add Insert Lua bindings
da1827e 06/30 - Save custom entity in libdxfrw
2899797 07/01 - Make CustomEntityStorage immutable
9d09b9d 07/06 - Create nearestPointOnPath and SnapPoints functions in Lua
d9a68be 07/07 - Keep references to Lua functions after doing an operation on the custom entity
bf661b3 07/07 - Drag points support for custom entities
9cb2673 07/12 - Create a custom entities "waiting list" (used for DXF load)
b2ad53c 07/15 - Allow plugins to manage custom entities if the plugin is loaded after the file
35e4944 07/22 - Rectangle plugin
086b38d 07/23 - Fractal plugin
c5958d5 07/23 - Gear plugin
0234b84 07/23 - Star plugin
1d2f8ab 07/23 - Spiral plugin

Builders
0a88c44 06/20 - Layers
f226485 06/20 - DxfLinePattern
1bc66b9 06/29 - Add Lua bindings
4dafdfe 07/17 - Builders refactor

Rendering improvements and unit tests
0ec5de8 07/30 - Add rendering unit tests
0d2a4a4 07/31 - Rendering unit tests configurations
921429a 08/02 - Support of multiple rendering unit tests
da256b7 08/04 - Ellipse rendering fix
3f691b7 08/05 - Arc/LWPolyline rendering fix
69855f7 08/05 - Enable rendering unit tests
55723b5 08/06 - Fix ellipse bounding box

OpenGL painter
The OpenGL painter won't be merged to master, even if it works and offer better performance than Cairo painter.
It'll be used as a reference for OpenGL integration, and the nanovg library will be used. It offers support for gradients and paths, and uses VBO which gives better performance.

e545397 08/18 - OpenGL painter

No comments

I tested nanovg library and I could use it to draw in the LibreCAD window.

The compilation is easier, but I needed to add -fPIC compilation flag.

We need some modifications to integrate it in LibreCAD 3.

  • We need to call a function to begin a frame and to end a frame. A begin and end function (empty by default) could be added to LCPainter.
  • There is no clear function, that might be called by the begin frame function.
  • OpenGL initialization code might be modified.

No comments

I made some tests integrating Skia in LibreCAD 3.
The code is too hard to compile to include it in LibreCAD; I couldn't get to compile the shared library so I had to modify some files and compile as Debug to get a .a file.

I'm currently looking at nanovg, which has almost the same API as Cairo but using an OpenGL backend and manages the VBO. The only problem is the lack of support of dashed lines.

No comments

After fixing a bug with zoom, I added today OpenGL support for splines and ellipses.

The next step will be to add text/dash support which is better with geometry shaders, but that requires a refactoring of painters

No comments

Today I removed the cached painters of DocumentCanvas to keep only one. Now the grid and entities form document are visible.
I also enabled anti-aliasing (x4) for the entities of document. It's disabled for the others.
I'll add support for GradientBackground now.

No comments

I added the user_to_device and device_to_user methods to the OpenGL painter
I lost a lot of time with a bug making the coordinates rendering not at the correct place. The QOpenGLWidget is incompatible with QMdiChild, and this was resolved by using QOpenGLWindow and QWidget::createWindowContainer()

No comments

I began the work on the new OpenGL painter and finished those functions:

  • move_to
  • line_to
  • clear
  • gradient background functions

I'll be working on device_to_user and user_to_device functions now

No comments

I begin the drawing optimizations this week.
After a profiling with callgrind (I had to remove a std::lock_guard which makes LC crash with callgrind), I began with LibreCAD internal functions.
Outside drawing, the function which takes most time is copy constructor of Coordinate, called by Area minP and maxP, Vector start and end functions. As Coordinate is immutable I changed these functions to return reference, it makes ~70% less calls and make a difference when it's slow.

Now the drawing, the paintEvent of LCADViewer (the function which copy from cairo to Qt) is taking 40% of execution time

No comments

I'm currently fixing ellipse, I fixed the size (it was too big). This was caused during DXF importing (division by factor instead of multiplication)
Now I'm fixing the angle, and I think this one is in the render code

No comments

Today I added a rendering test, containing all the current entities to be faster.
That make me solve a problem with the test code (with two tests it could skip one or all tests).

I saw a problem in rendering of ellipse and lwpolyline that I'll try to solve this week