This is not logic specific to MODULE. Breaking it out to
kicad_string.h acheives:
* Slimming of the MODULE interface
* Enables reuse of the function
* Enables testing of the function
Also add a test under qa_common for this function.
The CONFIG_SAVE_RESTORE_WINDOW class does not need to be tied
to the array dialog, put it in common/widgets.
Also do a refactor and tidy-up of the the class, use a union for (slightly)
better type-safety and syntax (a variant would be better but that's C++17).
Also enable integral field save/restore from text boxes.
The geometry and numbering logic is separate to the dialog, and
can be separated for clearer logic and better testability.
Moreover, refactor it to avoid any dependency on pcbnew
classes, so it can be move to common for potential re-use in
eeschema and friends in future.
Also convert all wxPoint logic in these classes to VECTOR2I and
fix some function visibilities.
Add some unit tests of the ARRAY_OPTIONS geometry and numbering.
ClipperLib::Path is std::vector<IntPoint>. Iterating this with
"for( auto point : path)" could result in 'n' IntPoint copy-constructions.
It does seem GCC 8, at least, manages to optimise these constructions
out.
Replace with the "standard" for( const auto& point : path) idiom.
When prompting for a new footprint library, we need to treat the input
as a file for creation rather than a directory for selection.
Otherwise, users cannot specify the name of their new footprint library
independently of the existing directory names.
Fixes: lp:1812135
* https://bugs.launchpad.net/kicad/+bug/1812135
The intention here is to make it possible to wrap up many of the
KiCad utility tools into a single executable. This reduces link times
as well as the duplication of CMake files needed to build very
similar tools.
This particular tool should be suitable for any code in common,
code in pcbnew and other end-executables probalby will need an
analagous version linked to the relevant kiface.
The first tool is the coroutine_example.cpp test case, which
can be useful when learning, debugging or porting the coroutine
infrastructure.
CHANGED: By default dialog closes on Esc key immediately and if dialog
has a grid control there is no way to close a cell editor with canceling
changes. New behavior is next: if dialog has a grid and the grid has an
active cell editor Esc key closes cell editor, otherwise Esc key closes
the dialog.
When removing steiner points, there is the possibility that the test
point is also removed. In this case, it is no longer a member of the
linked list and will break the output.
The test for re-fracturing a broken polygon can also result in multiple
polygons, rather than only 0 or 1. Skipping the extra polygons will
result in a limited tesselation.
Fixes: lp:1812393
* https://bugs.launchpad.net/kicad/+bug/1812393
This issue created memory leak and not working wxComboboxes (for instance after modifying the language selection).
Now, these wxComboboxes are created only once, never recreated.
Also: minor cosmetic enhancement in footprint editor main toolbar
(the save footprint icon is modified if the footprint is saved to the board or to the library)
The config was saving a canvas type EDA_DRAW_FRAME member not always accurately initialized.
And the last canvas opened frame setup was saved, not necessary a frame having a canvas type that can be set by user.
This is a broken feature especially because the footprint viewer has a fixed canvas setting.
The canvas type might change without the frame being notified. If this
happens, the user is presented with repeated notifications of OpenGL
issues. Howver, switching canvas is not an error and should be
presented to the user as an info message to clarify that the system is
still working but it has changed how it renders the screen.
Fixes: lp:1795240
* https://bugs.launchpad.net/kicad/+bug/1795240
Use the AddFileExtListToFilter() to also generate the
wildcard for "all files". This is because:
* Users can use AddFileExtListToFilter for the all files WC
with the same interface as for any other extensions.
* Users do not need to worry about wxGetTranslation, as the
_() is applied in the same way as the other *Wildcard() helpers,
and it is a function just like the others, so it is consistent
* There is a testable interface to document the expected result.
The test is added.
Varargs make it very hard to pass strings in flexibly
when they (and the number of them) are not known
at compile time.
For example, this allows up to now amalgamate the "single
ext" and "multiple ext" unit tests.
The application warps the cursor when initiating some actions (dragging,
selecting modules or Find and Move). This warping should not also
trigger the autopan action.
Fixes: lp:1810787
* https://bugs.launchpad.net/kicad/+bug/1810787
The standard DIM() macro was not typesafe as it happily deferred errors
to runtime that can be caught at compile time. Replacing it with a
generic C++11 constexpr allows for typecasting, comparison and compile
time error checking.
The intention here is to make it possible to wrap up many of the
KiCad utility tools into a single executable. This reduces link times
as well as the duplication of CMake files needed to build very
similar tools.
This particular tool should be suitable for any code in common,
code in pcbnew and other end-executables probalby will need an
analagous version linked to the relevant kiface.
The first tool is the coroutine_example.cpp test case, which
can be useful when learning, debugging or porting the coroutine
infrastructure.
Cairo supports antialiasing when rendering but can be slow when set to
sub-pixel mode. This bumps the minimum version of Cairo to 1.12
(available in 14.04 LTS as well as mingw) to support three antialias
settings (fast, good, best) that offer speed/appearance tradeoffs.
This can provide a higher-quality eeschema render as it works on a
per-element basis as opposed to the OpenGL per-screen antialias.
wxChoice centers the selection on GTK. So when switching from a
mid-list item to an item at the top, the list is always cut off for
choice lists located on the top toolbar. Using a combobox provides a
drop-down that allows easier access to all elements in the box.
Fixes: lp:1808569
* https://bugs.launchpad.net/kicad/+bug/1808569
It avoid including these extensions in a translatable string, thus avoid breaking filter
if the translation is incorrect (It happens sometimes).
See wildcards_and_files_ext.cpp for use.
This make the use of legacy canvas on GTK3 a default-off
advanced config. Legacy is substantially broken on GTK3
and is of basically no use at all to general users on this
platform.
If the program starts with legacy canvas in the config,
it is forced into a GAL mode, as otherwise it could happen
that the user is stuck and unable to get into pcbnew to change
the setting.
Fixes: lp:1803156
* https://bugs.launchpad.net/kicad/+bug/1803156
This can be used for "advanced" options which are for developers
to use for feature-flags and other configuration. Run time config
has some advantages over preprocessor defines:
* Can be changed without recompilation
* Sensitive to XDG_CONFIG_DIR, so flipping configs is easy
* Better compiler coverage (less conditionally compiled code means
less chance to break a different configuration). Also better
analysis coverage.
* Type safe config params
* Centralised documentation: it's in doxygen, in one place
No advanced config should be required by a general users. If a general
user does use one of these configs, it's probably because:
* There is a bug and one of these configs is a workaround
* A config in here is generally useful and should be moved into the
relevant application config and given UI.
For now, the config is read-only, and is read from the
"kicad_advanced" config file in the normal config dir.
Rather than depend on proper unlocking for each exit, we move the
connectivity lock mutex into an RAII-type configuration that
automatically unlocks on exit.
The fracture() call may result in zero polygons remaining, which will
cause failure in our tesselation routine, so we need to check whether
this is a valid POLYGON before re-tesselating.
Tesselation can fail for a number of reasons. When this happens, we set
the triangulationValid flag to false to prevent using the broken
triangulation. This will fall back to the slow OpenGL triangulation
when DrawPolygon is called.
Use TesselatePolygon() to draw polygons in Gerbview instead of GLU tesselation, much slower.
Add helper methods in GAL to know if the current GAL engine is Cairo, OpenGL or something else,
useful to optimize drawing code.
Append the appropriate file extension to the file name if the file name
does not have a file extension. This is a know issue with the GTK+ file
dialog.
Make the last 3D viewer screenshot last file used code more coherent.
Add the 3D viewer main frame trace string to the trace environment
variables doxygen group.
Doxygen comment and other minor code cleaning.
Fixes lp:1804980
https://bugs.launchpad.net/bugs/1804980
GTK3 smooth scrolling is enabled by wxWidgets but not to the exclusion
of normal scroll up/down events. wxWidgets maps these both to the same
scroll handler and will fire them both if they are not handled before
being queued. Testing timestamps allows us to mark and ignore the
dupes.
This is set to GTK3 only for now as it isn't listed as a problem for
other platforms. But it shouldn't cause issues if it is enabled
elsewhere in the future.
This adds a check for contiguous board outlines to the DRC. It also
uses the calculated outline to ensure that traces are not crossing the
outlines.
Fixes: lp:1648055
* https://bugs.launchpad.net/kicad/+bug/1648055
The reduces a little bit of WX dependency, and makes
the timing code a bit more type-safe.
Also adds a more testable interface for the accelerated
zoom controller.
This is done to avoid a big chunk of conditionally-compiled code
in the middle of the event function.
Also separates the zoom logic from the WX_VIEW_CONTROLS object
and isolates it in a separate class behind a clearer interface.
Add some simple tests for sane steps on GTK+3-sized scroll
steps.
This syncs the "All" checkbox with the state of the report options such
that selecting "All" automatically selects the other boxes and
deselecting a box results in the "All" box also being unselected. This
allows a single click filtering of report messages.
Fixes: lp:1796992
* https://bugs.launchpad.net/kicad/+bug/1796992
This makes using Scrollbars more easy to use, especially for "small" page sizes like A or B.
Note also the working/drawing area size is bigger than the page size (3 times)
Factor out save current canvas view to image file code from symbol editor
code so it can be used anywhere.
Add ability to save to any image format supported by wxBitmapType. See
https://docs.wxwidgets.org/3.0/gdicmn_8h.html#a90a1eb6d85b5044a99b706fd979f27f5.
Currently only PNG output is implemented.
Please note that there is a minor bug that appears to be due to the
scroll bars which causes unfilled areas on the right and bottom edges
of the image. This always existed in the save symbol editor view
image but it was not as noticeable because by default the background
color is white. It is very noticeable in the footprint editor with
a black background.
The usual smattering of coding policy and comment fixes.
Fixes lp:1802127
https://bugs.launchpad.net/kicad/+bug/1802127
Due to the implicit floor of the cast from double to unsigned char,
there was a small rounding error in COLOUR4D's WX conversion function.
This fixes the failing tests.
Also make the cast to unsigned char explicit.
Add some unit tests on TITLE_BLOCK
This commit also requires some mocks so the libcommon stuff
can work:
* Needs a Kiface() function to be linkable
* Needs some stuff from common to be build specially
* Needs to define itself as one of the unit-having programs
to appease the units defines.
Display GALs had an incorrect world unit value set. Now the world unit
value says how many internal units are in an inch, in accord with the comments
in the GAL header. Bitmap drawing code relied on the information about DPI,
so scaling worked differently for display and print GALs.
CAIRO_PRINT_CTX provides a Cairo context created from wxPrintDC.
It allows one to prepare printouts using the Cairo library and
let wxWidgets handle the rest.
Fixes a crash when typing fast in the place footprint filter box.
Also adds a bunch more checking to GAL locking, including making
sure the same person unlocks as locked, and preventing piece-meal
calls (the RAII objects must be used).
When processing the selection filter, items were deselected before being
reselected after passing through the filter. This adjusts the logic to
only deselect those items that are filtered out.
Many operations on the selection involved getting an item by index or
dereference. The std::set needed to iterate from the beginning of the
set to find the item in its red-black tree. Using a deque that we keep
sorted, we get index access in O(1) and item search in O(lg N).
Replace all instances of wxLogDebug with wxLogTrace in the common and
kicad folders to prevent unwanted debugging output.
Add new trace flags for locale and screen object tracing.
The usual smattering of code policy fixes.
This prevents deadlocks when exceptions are thrown and the context
ends up not getting unlocked.
It also removes an earlier hack to try and minimize this which
didn't work anyway.
Getting the position of a non-position TOOL_EVENT will
now result in a wxCHECK, and a null-position (0,0) will
be returned. The new interface HasPosition() can be used
to determine if a call to a position function is safe to
make from the caller.
Fixes the underlying danger behind lp:1796045, which has
already been neutralised by a4966adb6, which avoids calling
the Position() functions when the TOOL_EVENT is not known
to be a position.
Fixes: lp:1796045
* https://bugs.launchpad.net/kicad/+bug/1796045
Block rotate and mirror now work like they do in Pcbnew (that is
they're treated as part of the block move/duplicate/whatever
rather than finishing it).
Fixes: lp:1780794
* https://bugs.launchpad.net/kicad/+bug/1780794
1) when duplicating don’t keep original hidden until end of drag
2) reset selectionArea when showing it so it doesn’t flash in its previous location
3) center a pasted block on the cursor
4) don’t draw the source selectionArea when pasting a block
5) implement selection-style highlighting for contents of blocks
6) add pasted items to view so they don’t disappear when the block is placed
Fixes: lp:1747197
* https://bugs.launchpad.net/kicad/+bug/1747197
Split antialiasing options out from display options. Move
antialiasing to common. Duplicate the rest of display options
for Eeschema.
Implement OnSelectGrid and hookup GAL canvas refresh to
SetPresetGrid.
Add Grid Settings... to View menu and move Show Grid from
preferences to View Menu to match Pcbnew.
5.0 doesn't set the GAL's line width. It gets away with this since
it's using the same GAL to measure as to set up the drawing, so
the width happens to be set correctly for other reasons. 5.1 uses
a separate GAL and so isn't so lucky.
Note: it's only the renderer that is changed from wxDC to GAL. Tools stay the same, consider this a temporary hack.
This commit splits the EDA_DRAW_FRAME, EDA_DRAW_PANEL and BLOCK_SELECTOR classes into two variants, each independently compiled into a static library.
- "legacy_wx" for PCBnew/Gerbview - wxDC-based legacy canvas. We have full GAL support there anyway so it makes no sense to introduce GAL rendering API to the legacy tools.
- "legacy_gal" for EEschema and the rest - GAL-based legacy canvas, using legacy tools but with a GAL renderer.
Such split ensures only a small part of the common library and eeschema is affected, without messing around with already GALified tools.
The commit also removes some header dependencies on class_drawpanel.h
It would appear that some platforms process the KILL_FOCUS event
after running TransferDataFromWindow(). This change makes sure
that the evaluation is done no matter the order.
Fixes: lp:1793911
* https://bugs.launchpad.net/kicad/+bug/1793911
The '/' and ':' are reserved and cannot be used in symbol or footprint
names. They will cause the LIB_ID parser and formatter to fail. While
it seems like they should be legal in symbol alias names, they will
trigger a symbol rescue the next time the schematic is loaded.
Use ID_SCH as in the Eagle schematic plugin rather than ID_ALIAS to
ensure symbol names do not need rescued the next time the schematic is
opened.
Remove ID_ALIAS since the rules for alias names are the same as the
rules for symbol names. Otherwise, allowing '/' and ':' in alias names
will force a symbol rescue on the next schematic load.
Fixes lp:1795600
https://bugs.launchpad.net/kicad/+bug/1795600