About the Project
The project is focussed on enhancing OpenSCAD GUI by adding some new features and widgets, suggested by the OpenSCAD Community.
The following enhancements were proposed for working on during the GSoC 2020 period.
- Implementing User-Defined Shortcut Feature through GUI
- Number Scroll via Mouse Wheel in the Text Editor
- Enhanced Error Reporting & a new Error-Log Widget
The following PRs have been made during GSoC-
- Shortcuts GUI: https://github.com/openscad/openscad/pull/3338
- Number scroll by mouse: https://github.com/openscad/openscad/pull/3369
- Better Error Reporting & a separate Error Log: https://github.com/openscad/openscad/pull/3392
- Improving the File-Based Approach for Shortcuts, on which I started working before the commencement of the Coding Period of GSoC.
- A simple JSON file can now be used to override the default shortcuts for various actions in OpenSCAD.
// remove all shortcuts
"action1" : "",
// overwrite default shortcut
"action2" : "CTRL-X", // overwrite default shortcut with multikey shortcut
"action3" : "CTRL-X, CTRL-Y", // add shortcut leaving the default one active as default
"action4" : ["DEFAULT", "CTRL-X"],
// set multiple shortcuts
"action6" : ["CTRL-X", "CTRL-Y"],
Note: JSON File must be placed in UserConfig Path, with name — shortcuts.json
- Making a GUI for Shortcut Configuration.
- Added a GUI for allowing users to set custom-shortcuts.
- Users can set new shortcuts by selecting the action and pressing the key-sequence.
- Added a search bar at the top of the widget, to search actions by name.
- All the shortcuts can be reset to defaults using the ‘Reset’ button.
Look and Feel:
- A validator for Pressed Key-Sequences.
- Import a file from GUI to the user-config path.
This feature will allow the user to scroll the numbers in the text-editor by scrolling the mouse wheel.
What has been done:
- Numerical Values can be changed by mouse wheel scroll with a modifier.
- The modifier can be selected from Editor Preferences.
- The step size can be configured from Editor Preferences.
- The feature can be disabled from Editor Preferences.
Look and Feel:
- Disabling Mouse Movements while changing numbers (causing abrupt jump when the Most-Significant-Digit, changes its size)
- Delay Preview Until Done
The work in this phase can be divided into two steps:
a. Introducing a new unified method to accept the messages for Errors, Warnings, Trace, etc from different parts of the application:
Added a new method LOG() to accept log-messages from different parts and sending them to the console and a new ErrorLog Widget simultaneously.
LOG(message_group, Location, Document Path, Message, Args.....)
LOG(message_group::Warning,inst->location(),ctx->documentPath(),"color() expects numbers between 0.0 and 1.0. Value of %1$.1f is out of range");
** All the old PRINT(), PRINTB(), PRINT_DEPRECATION() statements have been replaced with the new LOG() ones, throughout the source-code.
** On the suggestion of mentors, changes in the expected output of tests are kept minimum.
Some outputs contained a ‘,’ (comma), before location info and some don’t. For working with the new approach, a uniformity was needed. So, after some discussion, the tests containing the outputs with ‘,’ before location info, were overridden to remove it.
b. Making a new GUI Widget for logging all the Errors/Warnings kind of messages:
- A new Dockable Error Log Widget where all the errors/warnings and other messages will be listed in the tabular form.
- The row containing messages are selectable and jump the cursor/caret to the error/warning location inside the text-editor if the location exists.
- An option to Hide/Unhide Error-Log in View menu.
- A filter in the new widget to view messages belonging to a particular group.
Look and Feel:
c. Hyperlink the messages in the console, with their locations:
The messages in the console having an appropriate concerning location in the .scad files are now hyperlinked with their locations. Clicking them will take the caret to the location of concern, inside the text editor.
Look and Feel:
- Old PRINTB() like statements in the PRs which are not yet merged, have to be replaced with a new LOG() method.
- Testing for GUI Features is done manually, by abusing the GUI Systems and trying different interactions.
Feedback from the mentors helped me a lot in bringing new bugs into the notice.
- Testing of the new LOG() method introduced, is done through the already existing test-bed of OpenSCAD, which is ctests.
- The biggest challenge for me was to jump from working on one feature to another, because they were quite different in implementation, and it took time for me to understand my tasks, before making significant progress at the start of all the three features.
- While introducing the new LOG() method for messages, most of the tests start failing due to certain differences in the expected output. So, handling those tests made me explore the entire source-code, and it was quite challenging.