Unification of canvases and improvements to the module editor (pcbnew)
Maciej Sumiński/CERN <maciej.suminski@cern.ch>
May 2014
Rationale
While we migrate all the existing tools to the new GAL-based view, users will be able to select a view using the View menu. Choices include legacy (the default one, used by KiCad till now), OpenGL & Cairo. In order to guarantee a coherent user experience, once a view is selected, it will be used for all tools, including the module editor and browser described in this blueprint. Among others, the required changes are related to the Module Editor - that is an opportunity to add a few improvements in order to increase the convenience of footprint creation and modification process.
The module editor is a separate window that is launched upon clicking
"Open module editor" toolbar button. Its purpose is to let user edit an
existing footprint or create a new one.
Besides converting it to a GAL canvas, there are a few features that
could be introduced, so the editing process is easier and faster:
- Change the editing tools to the ones available in the GAL canvas of
the board editor. That includes:
- Selection Tool which allows selection of items within chosen area as well as individual picking.
- Drawing Tools is a set of tools with increased capabilites in
comparison to the default ones:
- Lines can be drawn at any angle, yet there is a 45 degree mode.
- When drawing arcs, user is allowed to change both radius and angle without using the properties dialog.
- Point Editor gives a possibility of easy alteration of graphical elements. This is achieved by adding points, that can be dragged with the mouse cursor, so the end effect is instantly visible to the user. Another upgrade is to let the user modify shapes without entering new coordinates/angles with dialogs, but using the drag & drop method.
- Layer selection widget, the one that is available in the board editor. In the default editor it is possible to have graphics on different layers, but it requires modification of every single element that is expected to be on a layer different than F.Silkscreen. To improve it, there could be a widget where a layer is selected first and then new items are put on the chosen layer. That includes the Edge.Cuts layer, which was inaccesible previously.
- Items alignment - for a block of selected items, give an option to
align one edge of every selected item bounding box to the edge of
another item (e.g. the leftmost edge or the top edge), so in the end
they appear in a single row or column.
Another related functionality is "items spread" that puts parts evenly distanced from each other alongside a chosen axis. - Copy & paste for pads. This will allow to select a group of pads and copy them to another place, preserving the distance between them. For example: when drawing a QFN32 footprint, you may draw a column of 8 pads, then copy & paste the column 4 times and rearrange them. Currently, you have to place 32 pads and put them in right places (or in that particular case - use a footprint wizard, but I wanted to show you an example).
- Enable DXF import, so users may have a possibility to use outlines/helper graphics drawn with a different tool. For the time being the only possible way is to import a DXF file using the layout editor and then manipulate project files using a text editor to achieve the expected outcome.
Technical specification
Pad properties dialog
All operations are handled by the DIALOG_PAD_PROPERTIES class. The visualization is presented on a wxPanel object (m_panelShowPad). To replace it with a GAL view, I see two possible solutions (both are a bit hacky, but this is what happens when there are 2 views working in parallel):
- Change m_panelShowPad type from wxPanel* to wxWindow* and if GAL is to be used - recreate it in the DIALOG_PAD_PROPERTIES constructor and fix the code in the painting routine.
- Add a DRAW_PANEL_GAL (or a simpler object that only displays BOARD_ITEMs, see Other remarks) to the DIALOG_PAD_PROPERTIES_BASE and hide either m_panelShowPad or the GAL canvas in the DIALOG_PAD_PROPERTIES constructor.
Module viewer/browser
Changing the legacy view to the GAL one in the module viewer should be a relatively easy task, considering the FOOTPRINT_VIEWER_FRAME class inherits from the EDA_DRAW_FRAME. That means, it already contains the right canvas - it just has to be explicitly shown and then a few handlers have to be extended by routines to deal with drawing and controlling the GAL view.
Module editor
To convert the module editor canvas to a GAL canvas, the module editor
requires an introduction of the same changes as the viewer, but applied
to the FOOTPRINT_EDIT_FRAME class.
To have the improvements mentioned in the rationale:
* To use the tools that were created for the Tool Framework, create an instance of the TOOL_MANAGER class, that will handle a necessary set of tools (SELECTION_TOOL, DRAWING_TOOL, POINT_EDITOR).
* To enable drawing on any layer (including Edge.Cuts layer) without a necessity to edit properties of every single graphics item:
-
Add a layer widget, the one that is used in the board editor. Currently it is possible to have drawings on the mentioned layers, but it requires editing every item individually.
Required changes for having graphics on Edge.Cuts layer: -
The zone filling algorithm requires a single change:
diff --git a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp index b41d859..f2bc923 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp @@ -299,7 +299,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() ) {
-
if( !item->IsOnLayer( GetLayer() ) )
-
if( !item->IsOnLayer( GetLayer() ) && !item->IsOnLayer( EDGE_N ) ) continue; if( item->Type() != PCB_MODULE_EDGE_T )
-
-
Please correct me if I am wrong, but the current DRC allows to have items crossing board edges (they are not pointed out as errors). If so, then there is no modification required to the DRC algorithm.
-
Board edges stored in modules are plotted & printed correctly, so that part requires no changes as well.
- Regarding the DXF import functionality - the layout editor already has such option, so it is just a matter of reusing a few pieces of code in the module editor.
Other remarks
To reduce the amount of replicated code, there could be created a new, simple widget which has only one purpose - draw a BOARD_ITEM and allow simple view control (zoom in/out, panning).