Previously, the count of segments used a magic number optimized for Pcbnew.
This is not good, and does not work well on Gerbview.
The count uses now a max error acceptable is approximation (5 microns in Gerbview and Pcbnew).
Fixes#9101https://gitlab.com/kicad/code/kicad/issues/9101
curl.h has constraints on Windows (because it includes winsocks2.h) and must be
included before any wxxxx.h.
Because only very few files need curl.h, kicad_curl.h is included only in these files
Fix the valgrind warning from the use of an uninitialized
member variable by setting the DEFAULT value for
m_currentNativeCursor in the constructors member initializer list.
This fixes the following warning caused by the SetNativeCursorStyle
method call later on the constructor.
==66660== Warning: client switching stacks? SP change: 0x1ffeffee40 --> 0xdf7efe8
==66660== to suppress, use: --max-stackframe=137187819096 or greater
==66660== Conditional jump or move depends on uninitialised value(s)
==66660== at 0x13F0764E: UnknownInlinedFun (graphics_abstraction_layer.cpp:276)
==66660== by 0x13F0764E: KIGFX::GAL::GAL(KIGFX::GAL_DISPLAY_OPTIONS&) (graphics_abstraction_layer.cpp:78)
Error can be reproduced and checked from the log.txt
by launching kicad with valgrind command
"valgrind --leak-check=full kicad > log.txt 2>&1"
and then launching the footprint editor from the kicad main dialog.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8784
Signed-off-by: Mika Laitio <lamikr@gmail.com>
The max-char-width impl was buggy and never applied to PCBNew anyway.
Plus the stroke font has a max-char-width of 2.8 time the space width,
so it made for really wide tab spacing.
Also fixes a bug where the Scintilla editors weren't getting a
monospace font on Mac. (This bug may also exist on the other
platforms, but each would need its own fix.)
Also moves more of the Scintalla customizations to SCINTILLA_TRICKS
where they can be shared.
Fixes https://gitlab.com/kicad/code/kicad/issues/8666
Reduce each (Accel & Fallback) to 3 options: Off, Fast, Good. Fast AA
in accelerated canvas uses SMAA with tweaks suggested by David Beinder.
Good AA is super-sampled x2.
Cairo is similarly reduced to Off, Fast, Good, which map to the Cairo
options themselves. Best is removed as it mostly affects text rendering
and not line drawing (as our text is)
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8522
Conservative makes SMAA usable in Eeschema through weaker AA.
Aggressive reduces some artifacts compared to the High preset.
Restores the unused Ultra preset in the shader source to its original state.
Avoid fractional pixel offsets by forcing integer division of m_screenSize.
Shift rounded lookAtPoint onto OpenGL pixel center to ensure consistent rounding to int.
The pixel 0..1 @ 1x needs to fill the area 0..2 @ 2x so its center moves by 0.5 * (pixel size @ 1x).
This was leaking windows headers and partial wx headers to 1084 compilation units......
This also means math/util.h is leaking to 1084 compilation units which seems a bit high too.
Initialized COLOR4D takes an EDA_COLOR_T enum but then referenced it as
an index to the color table. This uses the enum as comparison against
the table-stored enum.
Adds standard orange to picker swatches
VIEW::GetBoundary() returns the entire view area, not the visible area.
Surprisingly, we had no API for this, so I added one.
Also, changed the dragger behavior to toggle between optimizing just the
modified area and optimizing the visible area, i.e. we will now never
optimize off-screen portions of the dragged track.
The native cursor must be set on the GAL canvas wx object,
not its frame (otherwise on GTK the cursor is only set
when we get a request for it from the WM and not immediately).
Fixes https://gitlab.com/kicad/code/kicad/issues/6421
Vertex memory allocation uses malloc and realloc without checking the
result. Throw exceptions that can be caught in the DoRepaint() method
in EDA_DRAW_PANEL_GAL when malloc and realloc return a null pointer.
We had been using each 4th column of spaces. But we needed an absolute
spacing rather than relative to the existing text to match spacing
between the input text box and our stroke font
wxWidgets 3.1.5+ on Linux will compile with the Wayland EGL
canvas as the backend instead of the X11 backend. This requires a
version of GLEW compiled with the proper EGL defines and a different
header/code for certain parts that are X11 GLEW specific.
This introduces an in-tree version of GLEW that will be built with the
GLEW_EGL flag then statically linked into the KiCad executables when
EGL support is needed.
Correcting the error is more trouble than it is worth, and anyway
might not be corrected exactly the same way plotting/filling/DRC
is corrected anyway.
Use a segment count multiple of 2, because we have a control point on the
middle of the arc, and the look is better if it is on a segment junction
because there is no arc to segment approx error
The radius correction does not fix correctly approximation errors,
and creates serious issues for thin arcs:
- control point outside the arc
- HitTest active area outside the arc shown on screen
- Cairo and opengl gives different arc positions.
- the formula used in radius correction is probably incorrect.
The OpenGL missing segments (when small) are due to rounding in larger
coordinates. The GAL shader uses floats to represent int32 values for
position and distance. Thus, at larger coordinates, the smaller integer
values cannot be represented accurately. This tests for the rounding
error and, if it exists, draws a plain circle instead
Fixes https://gitlab.com/kicad/code/kicad/issues/5751
You can now enable and disable snap to grid when drawing/editing across
all apps. You can also tie snap to grid to the visibility of the grid
to allow rapid enable/disable via grid display.
Cairo Polyline and Polygon draw functions share a common routine. While
Polygons must have 3 points to allow triangulation, a polyline (like our
text) need only have 2
This resolves a crash when passing an empty polygon and alerts debug
users to possible generation cases when bad polygons are created.
Thanks for Frans Zellman
(https://gitlab.com/kicad/code/kicad/-/merge_requests/365) for
identifying the issue.
The use of printf, wxLogDebug, and std::err/std::out causes excessive
debugging output which makes finding specific debugging messages more
difficult than it needs to be.
There is still some debugging output in test code that really needs to
be moved into a unit test.
Add debugging output section to the coding policy regarding debugging
output.
The base GAL has the linewidth property already, and its
accessor will only return the base version. This was causing
problems with the Cairo printing GAL, since that setter wasn't
using the base class version. Also, this removes the print-specific
setter, since the actual setting of line width shouldn't be done
there and is instead done where the drawing happens.
Fixes https://gitlab.com/kicad/code/kicad/issues/5089
On platforms with limited framebuffer attachments, like GC7000L
driven by the open source etnaviv driver, we can still use
GPU acceleration by drawing directly to the main buffer.
EDA_DRAW_PANEL_GAL::onPaint checks if an overlay target is
available in the GAL, and if not, redraws the whole view if the
overlay target should be dirty.
Clearing of the overlay target is a no-op if there is no overlay
buffer.
Signed-off-by: Lukas F. Hartmann <lukas@mntre.com>
When drawing segments that are smaller than the segment width, OpenGL
did not use realistic values, leading to hidden, small tracks. Instead,
we set the track to only draw a segment when the length is at least 1
radius long (so that we can see the full semi-circle at the track end)
Fixes https://gitlab.com/kicad/code/kicad/issues/5009
- New public static function OPENGL_GAL::CheckFeatures() gets called in EDA_DRAW_PANEL_GAL::SwitchBackend() before switching to OPENGL_GAL
- Moved all OpenGL feature checks from OPENGL_GAL constructor to OPENGL_GAL::init()
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4714
Swap syncs can limit the redraw rate as the screen waits for previously
issued syncs. Setting this to -1 allows for adaptive swapping
(resorting to unsynced if it falls behind) if it is supported by the
card but will fall back to unsynced (0) if the adaptive is not
supported.
Fixes https://gitlab.com/kicad/code/kicad/issues/4226
The scaling factor stored inside the canvas is created by a DPI_SCALING
helper, which will call the platform-specific functions if no user scaling
is specified. This change only affects OSX and Retina displays, so this
now also allows custom scaling to be used on OSX if desired (although it
shouldn't be needed, since wx has detection for it in 3.0.4).
CHANGED: Settings are now stored in versioned sub-directories
ADDED: First-run dialog for migrating settings from a previous version
CHANGED: Settings are now stored as JSON files instead of wxConfig-style INI files
CHANGED: Color settings are now all stored in a separate settings file
CHANGED: The symbol editor and footprint editor now have their own settings files
CHANGED: Color settings are no longer exposed through BOARD object
CHANGED: Page layout editor now uses Eeschema's color scheme
Settings are now managed through a central SETTINGS_MANAGER held by PGM_BASE.
Existing settings will be migrated from the wxConfig format on first run of each application.
Per-application settings are now stored in one class for each application.
* Split up the thirdparty code into the thirdparty folder (#3637)
* Create a new kimath static library containing all the math functions
This is part of cleaning the build system for #1906.
Ratsnest did not need a reserve and then iterative emplace. Instead, we
use resize(). Stroke font gets private vars initialized and kiway
variables that are only used in debug builds are properly scoped for
releases as well
Calling resize(size()) will only zero out elements that exist above the
vector size(). The memory is not freed in this case. shrink_to_fit()
will accomplish this action (at the discretion of the library)
This update replaces the existing uses of unique pointer creation with
the C++14 std::make_unique call that provides proper memory release in
event of an exception.
Don't accidentally flip the x-axis glyph size when resetting after
a sub- or superscript.
Special-case three tildes in a row. (We could also do this for
sub- and superscript, but does anyone really need a superscript
^ or a subscript?
Fixes: lp:1851657
* https://bugs.launchpad.net/kicad/+bug/1851657
Fixes: lp:1851880
* https://bugs.launchpad.net/kicad/+bug/1851880
Note that since the markup might exist for other reasons, it has
to be turned on with a preference setting. (It goes through a set
of bitflags so the same architecture can be used for other markup
structures that we might want to support in the future.)
Note also that this is more about engineering nomenclature than
visual formatting. In that respect it's more similar to overbar
than italic or bold.
deque structures have higher overhead than vectors. Not usually
problematic, but with hundreds of thousands of characters each with only
a few strokes, the overhead becomes dominant.
Previously, a 600 DPI was used to set device scale (can create minor visible rounding issues).
Using now 4800 DPI to reduce these rounding artifacts.
Fixes: lp:1845229
https://bugs.launchpad.net/kicad/+bug/1845229
It was due to a angle normalization between -360 and 360 degrees.
So, in arcs, if the start angle and end angle diff is n*360 deg,
this normalization gives start angle = end angle.
The fix forces end angle = start angle+360deg in this case.
Fixes: lp:1832096
https://bugs.launchpad.net/kicad/+bug/1832096
This allows a const BITMAP_BASE to expose const image
data. This is currently done with const_casts, which is
"OK", only as long as the source image is not declared
const, in which case it's undefined behaviour.
Also immediately dereference the pointer to a reference
if it's not checked to make the non-null requirements
explicit at the point of access.
Move repeated GAL config reading routines into GAL_DISPLAY_OPTIONS.
THe app-level config is in here already, do the same for the
common config.
This means that the configs are loaded consistently, which fixes
the symbol-chooser preview window, which previously didn't use the
same config routine as other GAL canvases.
Future work could move these functions to free functions that
act on the public interface of GAL_DISPLAY_OPTIONS to avoid
GAL_DISPLAY_OPTIONS having to know about wxConfig and wxWindow.
Fixes: lp:1824524
* https://bugs.launchpad.net/kicad/+bug/1824524
Both Cairo and OpenGL had issues (different, though) with circles that are
thicker in line width than they have radius. This corrects the OpenGL
implementation (radius is calculated to the outer edge) as well as Cairo
(line width needs to be clamped to twice the radius)
Fixes: lp:1822765
* https://bugs.launchpad.net/kicad/+bug/1822765
First, add automatic detection of toolkit DPI scaling options. For now, this
is, in order,
* Check the GDK_SCALE option under GTK+ (users can set this to force the scaling)
* Check the value from WX's GetContentScalingFactor(). This will start to work
correctly from WX 3.1 and GTK+ 3.10.
Then, add a user-settable override in the main prefs panel, next to the icon
scaling. This is independent of the icon scaling options.
DPI handling is performed in a standalone class, so they can be shared between
the prefs UI and the OpenGL backend easily. Also means Cairo could use the same
interface in future.
Also adjust the OpenGL grid drawing code to use the computed scale factor,
which avoids over-thick grids in scaled environments (the user can manually
thicken the grid if wanted).
Fixes: lp:1797308
* https://bugs.launchpad.net/kicad/+bug/1797308
In Symbol editor, axis are always shown. However after switching the backend, axis were no longer drawn.
In Cairo engine, fix a bug preventing axis to be shown.
Each dot is an integer number of pixels wide, so supporting 0.5 width
steps no longer makes sense. We round up the existing settings to the
nearest integer and only allow integers in the dialog.
Fixes: lp:1816748
* https://bugs.launchpad.net/kicad/+bug/1816748
We shouldn't adjust the pixel size of the grid based on alignment in
GAL. This creates artifacts on the screen at different zoom levels.
The pixel width is fixed by grid size preference
Also clean a left-over debug statement
Fixes: lp:1817377
* https://bugs.launchpad.net/kicad/+bug/1817377
Arc pixel adjustment needs to be limited to +/-1 pixel. But making this
adjustment to nearby points and then using the projection to correct the
center point accumulates errors that are large for angles near 0 and
near 360. This is a compromise that aligns _most_ arcs and provides
stable generation for all angles.
Fixes: lp:1817226
* https://bugs.launchpad.net/kicad/+bug/1817226
And filled but we don't use those yet. No pixel-alignment needed for
stroked semi-circles (I think) as we set the pixel width to be 1
regardless of the zoom level.
Fixes: lp:1816263
* https://bugs.launchpad.net/kicad/+bug/1816263
Pixel alignment is not required for track outline mode. It creates
differences between segment and radius calculations.
Also add specific width of the outlines
gal: pixel alignment for Cairo.
gal: pixel alignment for OpenGL
Cleanup of pixel alignment patches
gal/opengl: more pixel alignment patches:
- works on Retina displays now
- pixel alignment for circles
- correct 1-pixel strokes
- fixed unfinished 1-pixel line ends
GAL: Restore antialiasing options in Cairo
GAL: Fix arc drawing
Removes DrawArcSegment, which drew arcs whose edge was optionally
stroked (a feature that we did not use). Fixes Cairo arc drawing issue
where arcs were not visible in pcbnew.
gal: further cleanup
gal: removed unused shader parameter
When adding colors to length tuner, we depend on the window background
color, which can be set by the user, resulting in an unreadable text.
This uses the HSL conversion to detect which shade it should use for the
coloring.
Also adds test cases for round-trip HSL and HSV conversion
Fixes: lp:1814530
* https://bugs.launchpad.net/kicad/+bug/1814530
Bitmaps loaded via wx can contain alpha channels. We utilize underlying
routines to correctly map the alpha. This also standardizes the Cairo
alpha calls to ensure correct display in Fallback for partially
transparent highlights
Fixes: lp:1809845
* https://bugs.launchpad.net/kicad/+bug/1809845
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.
If a page layout contains bitmaps and is used in all sheets of a hierarchy, and in the board editor,
the cross-probing from pcbnew to eeschema invalidate textures associated to these shared bitmaps,
when switching active sheets.
Usually a crash happens after switching or when closing editors.
As a workaround, I disabled bitmaps (therefore associated textures) cache.
Not optimal, but at least it avoid crashes.
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.
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.