Future automatic releases in LibreCAD3 – Final Report: GSoC 2022

Hello everyone! This week is the last one for GSoC22 and I’m here to announce to you all the progress done in my project.

You now can download LibreCAD 3 in windows and Linux! Thanks to GitHub Actions and several changes to the codebase, when entering in any “Librecad3 builders” run in the actions tab of my clone of the repository, for example, this last one ( https://github.com/CRiSTiK24/AddCI-CDLibreCAD_3/actions/runs/3003305310 ) you will find as artifacts installers or packages for Windows and Linux.

What is new?

I’ve moved this part to https://github.com/LibreCAD/LibreCAD_3/wiki/Installation. As a summary on the current status, the artifacts are available as artifacts in my own repo at the Github Actions tab, and once it gets merged, in the main repo tab. Also, since LibreCAD3 is unstable, I’ve considered that i’d be better to not put it in the snap store.

Next, I’ll provide a list of the different technologies I’ve learned during my project, and some links to my work ( dev log, wiki, etc ).

Tools used:

CMake/CPack: We were taught to use GCC at university, yet Cmake is another kind of beast. At first, I was hesitant about how overcomplicated the CMake files and command line arguments looked, yet little by little I began to appreciate how many tools it was integrated with (the snap, appimage, and cpack were able to automatically deploy into the install folder without much complication). Also, once I started messing with the interactions and different directories in C++, I saw how easy was to add a library without having to put in the C++ file the exact location of it.

C++ & Qt: C++ is the main programming language taught at my university, but still there was a lot of new keywords and code structure that was totally new to me. Either if it was “External”, or the “newclass : inherited class”, I had to try many times different combinations of code until one of them worked and let me understand the logic of that file. Meanwhile, Qt was well documented, and other than the huge collection of types and functions (There is really a necessity for that many strings) it was quite fast to figure it out since I didn’t have to modify code related to the GUI.

System call tracers and debuggers: At university, we aren’t taught how to use them, so my usual method used to be lots of prints() everywhere. However in a project this huge, It would have been impossible to detect missing files of the package without the call tracers (strace in Linux). Also, the debugger allowed me to have a way to set the absolute path to the exe from the Graphical subdirectory using Qt Methods to the other subdirectories. Without using the Visual Studio Debugger it’d have been totally impossible to find the way.

GitHub Actions and Snapcraft YAML: Though its indentation made me have to rewrite the code more times than I’d have liked, It wasn’t much different from a regular bash/batch file with some special way to pass the arguments. What I found harder was the way to use GitHub Actions variables. Foreign actions like Checkout set some helpful variables like the path towards the cloned repo, still, in the documentation, there were many ways to access it, but only the way it’s right now worked for me.

Bash and Batch: We were taught the basics in the university, so it didn’t feel very strange. It was mostly planning on the more effective way to get a tool (like visual studio compiler) that would last. Thanks to GitHub actions I was able to get tools like Qt from a foreign action, instead of having to use a strange URL that could disappear in little.

Conclusions:

I’ve certainly learned a lot this summer. One of the things that I will remember is how many posts with similar issues to the ones I faced were on the internet and how many of them remained unanswered or used a workaround that didn’t work for me. It made me think of how much of the big software that we regularly use and consider rock solid is probably much more fragile than we really think.

The other one is how entering through an opportunity presents many more. At the GSoC summit at the beginning of the summer, we were presented with Google Developer Student Clubs. There weren’t any in my city so I took the opportunity and this year I’ve been selected to begin a chapter at my university. At the same time, I began taking my LinkedIn seriously, and it made me receive a message to participate in a week-long Huawei formation called “Seeds for the Future”.

There are some ideas that I wrote in the original proposal that I’ve not implemented because I thought they wouldn’t be a good idea. The main example is uploading every snap to the snap store automatically. Since LibreCAD3 is still experimental software, I thought that if someone was using a functional snap they wouldn’t want an automatic update to break their version just because one of the devs tried out a new change. Also, the proposal had some extra steps for testing, though after being involved with the building of the snap and appimage I’ve seen that they are so hard to get built that just getting there is a pretty good test. If it needs more tests I’ve checked back the proposal and using “appimage-testsuite” on the AppImage seems the best option.

So as the last paragraph, I’d like to thank the mentors and everyone else in Zulip that helped me out. I’ll try to stay active so if anything related to my work has an issue I can lend a pair of eyes.




A brief look at the future automatic releases in LibreCAD3: GSoC 2022

Hi everyone! I’m Cristian and I’ll tell you about my project, which intends that anyone who wants to try out the current state of LibreCAD3 can do it as any other application. You should be able to download it as a ‘.exe’, or if you are a Linux user, get it as a ‘.appImage’ or as a ‘snap’ in the Snap store.
The key parts of this proposal are building, packaging, testing and deploying:

  1. Building: When I started getting involved with LibreCAD two months ago, I first started with the Windows installation. The wiki installation was outdated and sometimes confusing for a non-experienced dev. 
    Fortunately, Florian was able to patch all the errors surrounding the installation, and so I finally installed it successfully. After this “week-long installation”, I committed to writing a batch script to install it automatically, which can be consulted in the installation wiki. 
    Also, I updated the Windows guide so anyone with a bit of experience following guides can get it built. The next step will be installing it for Ubuntu. Right now the wiki only covers a long line of packages to be installed with apt. I’ll try it out and update the wiki with additional steps if needed.
  2. Packaging: After LibreCAD3 is built, in Windows it needs to be packaged with QT and Conan dependencies. After having everything together, an extraction script will be needed so that when the ‘.exe’ is executed, its contents are moved and some requirements like PATH variables are appended.
    For Linux, It’ll have to follow AppImage’s & Snapscraft Documentation to get them packaged.
  3. Testing: It’ll have to test the packages before deploying. For AppImage and Snap, some programs can do exactly that. For Windows, It can try to install it from the ‘.exe’ and see if it doesn’t fail.
  4. Deploying: Finally, with all the packages tested, The ‘.appImage’ and ‘.exe’ will be uploaded to Github as a release, while the ‘snap’ will be uploaded to the Snap store.


Hope you like the proposal! If you have any new ideas or improvements on how to tackle this goal feel free to reach me out in Zulip-Chat(@CRiSTiK24) or leave a comment down below!

You can check the complete proposal (12 pages in pdf) and more here:
Link to Librecad’s Gsoc page in wiki

LibreCAD 3 GUI Revamp – GSoC 2020 Final Report

This is my final report for GSoC 2020. I’ve finished all my tasks laid out in my proposal and also managed to get a few more tasks done. I’d like to thank my mentors Florian and Armin for their tremendous help and swift reply to my doubts. I’d also like to thank members of the community like Rupak Bajgain, Guruprasad Rane and flywire for their help and advice.

Major PRs :-

Other PRs :-

Important Links :-


Brief description of work done

GUI shift from Lua to C++

  • The GUI has been entirely shifted from lua to C++.
  • Created MainWindow class, updated layer,toolbar,clicommand classes.
  • All qt related code removed from qtbridge, now renamed to lua bridge.
  • All lua ui files removed.

Lua GUI API

  • Added Lua GUI API to allow lua plugin scripts to interact with the gui elements like the mainwindow, toolbar buttons, menu buttons, layer, clicommand etc.
  • Added many dialog widget GUI classes, which allow the user to form his own gui widget for the user using a plugin.
  • Lua GUI API Documentation added to the wiki.

Unit Tests

  • Updated unit tests for the widgets like layers, clicommand, toolbar and mainwindow unit tests.
  • Added Lua GUI API unit tests

Operation Loading

Loading of operation and generation and connection of the correct buttons, menu items, cli commands, context operations etc happen automatically by using the properties specified in the beginning of each lua operation file, making it easier to add new lua files without needing to change code elsewhere

Customize Toolbar Widget

  • Ability to customize and order the toolbar buttons in the user’s desired order
  • Order can be saved and loaded by the user (saved in json format)
  • Added ui settings json file which stores ui settings and is validated by a schema on loading.

Property Editor

  • Property editor added which allows the user to change the properties of the created entities, the change in properties updates the entity with new properties instantaneously.
  • Uses the input gui widgets developed earlier in the lua gui api.
  • Also contains meta info and layer properties.

Context Menu

  • Context menu can be opened by right clicking, it has three states, active,inactive and selected.
  • Can easily access create and modify tools using the context menu
  • Contains undo, last command, copy, paste etc.
  • Allows transition between different methods while creating an entity.

Other

  • Copying and pasting of entities among different librecadv3 windows.
  • Few missing arc operations implemented.
  • Added text operations lua file and a text dialog which allows adding more customized text with different style and font.

What I’ve learned

GSoC at librecad has been a great learning experience for me and I had a lot of fun working on the project. Some of the things I’ve learned

  • Gained confidence in writing C++ object oriented code, as well learned the importance of writing comments and readable code.
  • Learnt lua while preparing and working on my gsoc project.
  • Learnt how to work with tools like CMake, which I was initially intimidated by but am now fairly comfortable with.
  • Learnt the importance of approaching problems properly, like how florian pointed out that using the visitor design pattern in a certain problem was better than the approach I was going for.
  • Gained confidence in using git and github, learning how to work with branches, squash commits, merge etc.
  • Learnt how to use the Qt framework and about qt’s signal and slots system, model/view programming etc.
  • Importance of discussing the task and problem, instead of diving head first into implementing it, and to also take into account the user’s perspective.
  • Learned how to properly debug and track down problems.

I was lucky to have great mentors to help guide me through the summer, Florian has been extremely helpful and responsive from the very start when I started contributing at the end of December. Armin too has been very helpful and made the setting up of the required accounts for wiki and the blog a breeze.

Thanks for taking the time to read my final report, I’d again like to thank everyone involved for their help and advice. GSoC was a great experience and has helped me gain confidence to continue contributing to LibreCAD and other open source organizations in the future.

Akhil Nair

LibreCAD 3 GUI Revamp – GSoC 2020 Phase 3

Hello!

With the last coding period of GSoC coming to an end, here’s what has been worked on in the last coding period.

Context Menu

A context menu has been added which allows the user to easily access some operations as well as switch between different input methods while creating an entity. The context menu can be accessed by right clicking.

The context menu has three modes, active, inactive and selected.

Inactive
Selected
Active

The user can undo,redo or start any tool through the inactive menu (when no entity is selected and no operation is in progress), while during selected mode the user can modify and copy the entity. In active mode (when an operation is in progress) the user can switch to a different method of input if required and can PAN or cancel the operation.

Context menu transitions can be easily specified in the lua operations by mentioning it in the operation properties

context_transitions = {
        setSecondPoint = {"LineWithPointAngleLength", "HorizontalLine", "VerticalLine"},
        LineWithPointAngleLength = {"setSecondPoint", "HorizontalLine", "VerticalLine"},
        HorizontalLine = {"setSecondPoint", "LineWithPointAngleLength", "VerticalLine"},
        VerticalLine = {"setSecondPoint", "LineWithPointAngleLength", "HorizontalLine"},
        LineParallelToLine = {"LineOrthogonalToLine"},
        LineOrthogonalToLine = {"LineParallelToLine"},
        ...
    }

Dock Positioning

Added dock position data in the ui_settings so that the dock configuration (along with width percentage) can be saved and loaded as desired.

The widget title bar has been updated to properly switch between horizontal and vertical titlebar depending on the dock position of the widget.

UI settings class has also been updated to make it easier to add more configurations in the future.

Copying Entities

Copying and pasting of entities and dimensions has been added between the same window or multiple windows. Entities can be copied/pasted by using the copy/paste option from the context menu or by using the keyboard shortcuts Ctrl-C and Ctrl-V

The entity properties data is transferred by serializing it into json format and then passing it to the required window, where it is deserialized and reconstructed from the properties.

Arc Operations

Some of the remaining missing arc operations has been added (StartCenterEnd, StartCenterAngle, StartCenterLength, StartEndAngle, StartEndRadius, StartEndCenter, CenterStartEnd, CenterStartAngle, CenterStartLength). Context menu options to switch between the input modes has also been added for these arc operations.

Text Operations

Text operations lua file and text dialog has been added to allow the user to create text entities. User can use either the lua operation (through toolbar or menu) to enter the text with the insertion point, height and angle. If the user requires more control over the font and other properties, text dialog can be used to add the text entity.

I had a lot of fun this summer and would again like to extend my thanks to my mentors and the community for helping me with my project, helping me learn and guiding and helping me with every doubt or issue that I had.

Akhil Nair

Dev Log

LibreCAD 3 GUI Revamp – GSoC 2020 Phase 2

Hi!

With the end of another fun coding period, I’m here to bring you the updates on what work has been done in this period.

Again my mentors have been extremely helpful and the community too has been very responsive and helpful, giving me vital and useful feedback as I work on the project.

Documentation for GUI API

Documentation for GUI API has been added to the new librecad wiki. A page for every GUI class describing the function, syntax and an example for each function has been added, for both the normal GUI classes and InputGUI classes. An example on how to add and use the dialog widget and input guis has been added too.

https://dokuwiki.librecad.org/doku.php/dev:v3:gui_api

Settings format changed from XML to JSON

The Settings/toolbar format has been changed from xml to json, to leverage the ability of validating the settings using a json schema and simplicity of json. Rapidjson library has been used for parsing and validating the json file.

Property Editor

Property editor has been added which allows us to change the properties of any of the created entities. The property editor shows up with the properties of all currently selected entities.

Changed the entity property instantaneously changes the entity to the new entity with the changed property. Properties changed work in accordance with the undo manager and hence can be undo.

Property editor makes use of the already existing input guis with the addition of a few more classes like the ListGUI, LineSelectGUI etc.

Other minor changes

Minor changes like addition of ok/cancel and removal of the row/column count constraint in the customizable toolbar, addition of build_constants file so that settings file location is determined by the cmake on installation and hence can be changed for different operating systems.

Thanks again to my mentors for their help, and to the community for helping and pointing out various bugs/changes in the features I’m working on.

Dev Log

Akhil Nair

LibreCAD 3 GUI Revamp – GSoC 2020 Phase 1

Hi everyone!

Phase 1 of the GSoC is now over and I’m happy to say that a lot of work has been managed to be done by now. Given the uncertainity surrounding my exams due to the pandemic we are facing, I began my work early in the month of may. All the milestones for the first period( and more so) has been completed.

My mentors Florian and Armin have been of great help and have helped me overcome every issue I’ve faced, as well as provided interesting and useful information as GSoC is at it’s core a great learning experience for us students. The community has also been helpful and interactive and helped me implement the features in the desired way and provided insight on what the users of LibreCAD would require.

Shifting of GUI from Lua to C++

MainWindow class has been added which has responsibilty of managing and initialization of the GUI. Toolbar, CliCommand and Layers classes have been updated to reflect the new changes.

All the lua scripts from lcUILua/ui which were responsible for the GUI initialization have been removed and all their functionality has been shifted to the C++ classes.

Operation Loading

Thanks to Florian’s idea of operation loading, the lua tools are now loaded automatically by the C++ code. The lua scripts define properties according to which the appropriate menu item, toolbar button and command is created for that particular tool.

This has made it easy to add lua tools without requiring to change the code in any of the other files.

Lua GUI API

The Lua GUI API has been added. Menu, MenuItem, ToolbarTab, ToolbarGroup, ToolbarButton have been added, and the MainWindow, CliCommand and Layers classes have been updated to add all the required lua gui api functions.

Mutiple callbacks, positioning of menu items, easy addition of commands to the commandline and other functionality have been added thanks to the addition of this api.

Removal of QtBridge

With the addition of the lua gui api, the qt bridge is no longer necessary and has been replaced with the lua bridge. Knowledge of qt is no longer required for using gui related functions and operations in the lua plugins.

Dialog Widget Lua GUI API

Lua GUI API has been extended to include many dialog widget classes that make it easy to create and use GUI widgets in lua plugins. The following classes have been added :-

DialogWidget , AngleGUI, ColorGUI, EntityGUI, ButtonGUI, ComboBox GUI, InputGUI, HorizontalGroupGUI, SliderGUI, TextGUI, NumberGUI, RadioButtonGUI, RadioGroupGUI, CoordinateGUI, CheckBoxGUI.

Unit Tests :-

Unit tests have been added for all the work done above.

Customizable Toolbar :-

Customizable toolbar has been added which allows the user to easily customize the toolbar buttons and groups into their desired order. The order is saved so the next time the user opens LibreCAD, the toolbar buttons are in the same order.

The order of buttons can be stored and imported in xml format, as well as a default order is available.

Benefits to the user :-

So what do you the user, benefit from the work done so far?

  • Lua plugins are easier to write, GUI related code can be written without requiring any knowledge of the Qt Framework, GUI can be easily manipulated.
  • Tool operations can be easily added without needing to change the code in any other part of the project.
  • Parts of the user documentation like the lua tools can be automatically generated thanks to the addition of the properties.
  • Dialog Widget API provides lots of easy to use GUI elements that can be used in the lua plugins to provide more interaction through the plugins without writing a lot of code.
  • Toolbar buttons can be ordered in the user’s desired way so that users can access the most frequently used tools easily.
  • The toolbar ordering is exported and imported in xml so can be easily transferred between different computers.

It’s been a lot of fun so far and I look forward to working on more things on the next two coding periods.

Thanks for reading!

Dev Log

Akhil Nair

LibreCAD 3 GUI Revamp – GSoC 2020

Hello

I’m Akhil and I’ll be participating in GSoC this year under LibreCAD for the GUI revamp of LibreCAD 3.

I will be mentored by Florian (Feragon) and Armin (LodOfBikes) this summer as I attempt to achieve all the goals laid out in my proposal.

My proposal aims to solve the following problems :-

1) Shifting LibreCAD 3 GUI Window management from Lua to C++. Having the main window and widget initialization in Lua doesn’t provide much advantage and instead serves as a disadvantage as Lua lacks the compiler checks, unit tests and debugging tools that are available with C++.

A MainWindow C++ class will be created which will take over the responsibility of window initialization and management from the lua scripts.

2) Users wishing to extend the functionality of LibreCAD with their own plugins using Lua need to know Qt should they wish to make changes and add GUI widgets.

A Lua GUI API will be added to make it much easier for users to create GUI widgets and interact with the LibreCAD 3 GUI without the hassle of needing to learn Qt. This will also help us maintain control over the style of the GUI, even those added by plugins. This API will be made to be as intuitive and easy to use as possible along with providing enough flexibility to meet the needs of most users.

3) Qt bindings will be removed and the toolbar will be overhauled to make it customizable by the user, so the user can now have easy access to whichever operation that they wish to use.

Documentation and at least one tutorial for the new Lua GUI API will be added. Efforts will be made to make the documentation as clear and informative as possible. Unit tests will also be added throughout the development process to ensure everything performs as expected.

I shall start off with the shifting of GUI from Lua to C++ and hope to have it done by the first coding period. After that I will add the LuaGUI API bit by bit, working on the customizable toolbar on the side. Finally the documentation and tutorials and all remaining tasks will be completed.

I am absolutely thrilled to be a part of this and look forward to a productive summer, learning and contributing to open source.

Thank you and stay safe everyone!

Project proposal

Link to the wiki

Google Summer of Code 2020 (GSoC)

These are hard times all over the world and firstly we wish health and energy to all to overcome the COVID-19 pandemic.
Nevertheless live must go on and therefor a new round of Google Summer of Code is going on.

We are happy to announce, that LibreCAD is part of GSoC in 2020!

GSoC has already started a couple of month ago and after organization selection, slot allocation and finally student selection we are yet in the phase of community bonding with the selected student.
We are proud to introduce our student Akhil Nair, who has applied with his proposal GUI Revamp, which is about rewriting the LibreCAD 3 GUI entirely in C++. The current implementation in LUA has come to some drawbacks which should be solved with a pure C++ interface. This may also open doors for implementing other often asked for scripting languages like Python or LISP, which is used by AutoCAD.

Akhil has joined us already a few month ago and is actively contributing to LibreCAD 3 development.
We wish him all the best for the coding period, which will start on June 1 and ends on August 31.

Many thanks also to our friends from BRL-CAD, who again took us under their umbrella and managing the organization part for us and other CAD/CAM/CAE projects.

The LibreCAD Team

LibreCAD 3 “OpenGL Rendering” – GSoC 2019 Final Report

The GSoC 2019 has ended and my project is finished.
The OpenGL Rendering Module is working
FINAL PR : click here —> OpenGL Rendering Implemented

(Important links:)
LAST GSOC COMMIT —> 4b43e5f (Working state)
DETAILED LOG —> Project_Log
WORKING REPOSITORY —> Working Repo
MY GITHUB —> MyGitHub
BLOGS —> Blog , Phase1 , Phase2 , Phase3

WHAT WORK IS DONE?
“Quick Recap”
There are a lot of commits made , these are the ones with major milestones reached
Making a Viewport System: a589542
User-Device Coordinate System: f0b2787
Saving/Restoring Context-Management: 8af6bcc
Matrix transformations: da330e5
Paper-Background: 5c28e68
Caching-Mechanism for accelerated rendering: 4a402df
Basic GL_Entity: dec9c97
Gradient Entity for gradient background: fd9c35f
Gradient_Shader: b75f17f
Shader’s book to save all different shaders: 6b44b40
Shader based Thicklines with miter joints: c680b7e
Shader based dash-Gap Line-Patterns: 7a8d468
Transparency with alpha channel: 16d4d31
Font_Book to store different font styles: 665a3a3
Text Entity for text rendering: 35d318d
Text-Rendering: b13289d
Beziér Curves (linear, quadratic, cubic): 15af822
Arcs: 470c15c
Ellipse: 4b43e5f

WHAT WORK IS LEFT?
Me and my mentors Florian and Armin are working to make code more cleaned , Testing , abstracting some parts , following some standards, removing code duplication , code refactoring.

LibreCAD 3 OpenGL Rendering – GSoC “Phase 3”

Finally our Tank Fires

“Major Challenges finished”
During Phase 2 the most hard challenges were accomplished. Which required a lot of research and finding multiple ways to implement them. Mentors kept patience and belief in me and gave me opportunity to work on my pace.
The major challenges finished till now were-
–> Thicklines
–> Shader based thick polyline with miter joints
–> Shader based Dash-Gap line patterns

“We need to write some Text”
This was the major work to be done as phase 3 starts.
Getting a simple string to render on screen is quite difficult with a low-level library like OpenGL. In LibreCAD there is no limit for characters and extended characters are used often for like mathematical expressions.
Once you think about all these complicated matters of text, it wouldn’t surprise you that this probably doesn’t belong in a low-level API like OpenGL.

“Going with Textures”
So the basic idea behind text rendering is to store the textures corresponding to each character and also its information of coordinates and dimension.(Collectively known as glyphs ) . Not only this glyph data , my idea extended to even cache them as vertex buffer in GPU along with texture. This will not require to generate them at each frame and i just used matrix translations to render them at the perfect position.
And to generate the texture i used the Freetype library. FreeType is a software development library that is able to load fonts, render them to bitmaps and provide support for several font-related operations.
Finally we got nice font rendering with extended characters too.

“Rendering curves”
Now it was time to finish some missing functionalities of the opengl painter which includes curves, bezier , quadratic , cubic , ellipse etc.
As the core part was already done adding these functionalities on the topmost layer was not that hard , it required some mathematics though.

Bezier , quadratic , cubic ,ellipse curves

“Testing before Integration”
So now the painter was ready and it was time for cleaning code, following standards, code refactoring, unit testing etc.
Initially there were some issues on building against the Travis CI , but Florian helped me a lot in this. The code was building successfully.
The OpenGL Rendering works fine.
Overall during the last phase my learning curve got higher. I came across different things, from very simple to hard, how code is made standard, using tools like Travis ,CodeFactor
My Mentors really helped me in learning these things and use them.

“What happening after this”the work left
Me and Florian are working to make code more cleaned , abstracting some parts ,following some standards, removing code duplication , code refactoring.
These are small but important things .
After that there is more work like user defined textures ,MSDF font rendering(if needed) etc.