Commit Graph

918 Commits (953c472897b081d0c438302f650559a429bae52b)

Author SHA1 Message Date
Ryan Pavlik a0e992374d Clean up virtual, override, default, and void params. NFC.
Found by clang-tidy.
2019-09-11 10:31:07 +00:00
Ryan Pavlik ae417fc14c Use emplace_back. NFC.
Found by clang-tidy.
2019-09-11 10:31:07 +00:00
Ryan Pavlik 34dccbf935 Don't call static methods through an instance. NFC.
Found by clang-tidy.
2019-09-11 10:31:07 +00:00
Ryan Pavlik b1e280e75f Fix undefined behavior in IdList::end(). 2019-09-11 09:44:30 +00:00
Ryan Pavlik bedea1ef3c Avoid undefined behavior from out-of-range access. NFC. 2019-09-10 06:44:34 +00:00
Ryan Pavlik b8ee0e941b Remove extraneous semicolon. NFC. 2019-09-10 06:44:34 +00:00
Ryan Pavlik 78819ffca3 Fix "virtual function without virtual destructor" warning. NFC. 2019-09-10 06:44:34 +00:00
Ryan Pavlik c959af1149 Fix a comment. NFC.
Found by clang-tidy.
2019-09-10 06:44:34 +00:00
Ryan Pavlik 3e566d7e67 Remove std::move from trivially-copyable types. NFC.
Found by clang-tidy
2019-09-10 06:44:34 +00:00
Ryan Pavlik c0904e2ba8 Use IsEmpty() or .empty() to check if a container is empty. NFC.
Most found by clang-tidy.
2019-09-10 04:22:21 +00:00
Ryan Pavlik 61c0167ad7 Fix TTF iteration in case of an empty list. 2019-09-10 04:22:07 +00:00
Ryan Pavlik 15838dc5a1 For loop cleanup. NFC. 2019-09-10 04:21:57 +00:00
Ryan Pavlik 231dff6cd9 Add and use List::Last(). NFC. 2019-09-10 04:20:38 +00:00
whitequark c5f3cd151a Use the same @todo hot comment style everywhere. 2019-09-10 04:07:42 +00:00
Ryan Pavlik d514a26f92 Fix use-after-free in revolve and helix.
Pointers get invalidated if a list has to be re-allocated.
CopyEntity can do that.
2019-09-10 04:07:42 +00:00
Ryan A. Pavlik a4c0022815 Fix a warning about a virtual destructor. 2019-09-10 03:33:05 +00:00
Ryan A. Pavlik 43b2261e9c CLI/testsuite: do not crash if a dialog is displayed. 2019-09-10 03:23:31 +00:00
phkahler 22e4011cb6 use std::vector in helix operations instead of fixed length array. Remove limit on number of sections. Delete definition of Revolved struct. 2019-08-25 14:30:37 +00:00
phkahler e22c522c81 use std::vector in lathe operations instead of fixed length array 2019-08-25 14:30:37 +00:00
phkahler 2dd50d0f3a Only allow lathe, revolve and helix for 2d sketches. 2019-08-25 14:30:37 +00:00
Ryan Pavlik 13820bf27d Revert "IdList::RemoveTagged switch to std::remove_if from iteration. NFC."
This reverts commit 0bb6a348e3.
2019-08-20 23:28:43 +00:00
Ryan Pavlik b284e80785 Improve NextAfter. NFC. 2019-08-20 15:57:11 +00:00
Ryan Pavlik 533ca618eb Fix a manual manipulation of List::n. NFC.
This broke encapsulation and thus caused problems for any deeper changes
to List.
2019-08-20 15:57:11 +00:00
Ryan Pavlik dd738dd1fc Add Last(). NFC.
Counterpart of First().  standard library calls this "back()".
2019-08-20 15:57:11 +00:00
Ryan Pavlik 610e35f6dd Improve Clear(). NFC.
Was getting segfaults near here with another patch since removed from the branch.
Moving these assignments after the memfree means they still have
useful data when debugging a crash in memfree.
2019-08-20 15:57:11 +00:00
Ryan Pavlik b9d035c805 Improve MoveSelfInto. NFC.
std::swap is an idiomatic way to do a move.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 9fd09ddd8a Add IdList::AllocForOneMore() based on List. NFC.
Also modifies a sizeof call.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 0bfbbe2bf3 Improve implementation hiding in IdList/List. NFC.
Allows distancing users from the internal "elem" member.

Add Get() and operator[].
Replace direct references to elem.
Make elem and elemsAllocated private in IdList/List.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 482f0e8de9 Replace qsort with std::sort and lambda. NFC.
Removes static variable usage, permits hiding of the underlying pointer
(std::sort uses iterators intead), type safety, etc.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 1b97a006e9 Add and use List<T>::IsEmpty, range-for, etc. NFC.
Changes resemble those already made to IdList.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 0bb6a348e3 IdList::RemoveTagged switch to std::remove_if from iteration. NFC. 2019-08-20 15:57:11 +00:00
Ryan Pavlik 3ea077b70f Reduce scopes and placate clang-tidy. NFC.
Pointing out one potential issue with an assert.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 60fdac141d Simplify IdList::Add(). NFC.
Offloads most of the work onto standard algorithms to make it
more self-evidently correct.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 3340392bf0 Add and use LowerBound methods in IdList. NFC.
Clearer and less error-prone to use standard-supplied algorithms.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 0c941aedb1 Revise IdList::Tag to reduce code duplication. NFC. 2019-08-20 15:57:11 +00:00
Ryan Pavlik 5ada4dbd9c Add and use IdList::IsEmpty. NFC.
Removes consuming code from the implementation details, easing swap of
the underlying container, etc.
2019-08-20 15:57:11 +00:00
Ryan Pavlik b5f36a4f01 Provide cbegin(), cend() in containers. NFC.
Allows forcing const iteration.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 86f20cc7e5 Convert many loops to range-for or std algorithms. NFC.
Also add comments about indexing and when we don't use range-for.
2019-08-20 15:57:11 +00:00
whitequark 97c8cb7d71 Make sure changing color of a group does not reset alpha. 2019-08-12 08:52:51 +00:00
nabijaczleweli d9081b0b08 VRML: add support for transparency. 2019-08-09 23:32:24 +00:00
nabijaczleweli 837628ea3e Add VRML (WRL) triangle mesh export.
Transparency is not supported.
2019-08-09 21:30:33 +00:00
phkahler 986da7d224 Implement helical extrusion groups. 2019-07-31 04:16:56 +00:00
whitequark b3f739f2c4 Improve layout for reference axes with very vertically small windows. 2019-07-12 11:23:28 +00:00
Ryan Pavlik b2af9cee6c Use the fact that handles are now less-than comparable. NFC. 2019-07-10 15:40:21 +00:00
Ryan Pavlik 5efb09e6d4 Use the new equality/inequality operators of handles to reduce references to .v. NFC. 2019-07-10 15:40:21 +00:00
Ryan Pavlik 7bd4b149f7 Traits work for handles to permit sharing functionality and operators. NFC. 2019-07-10 15:40:21 +00:00
phkahler 346f004e51 Brighter blue and yellow in text window for higher contrast/readability. 2019-07-09 00:48:06 +00:00
whitequark 02d7f0c0aa Auto-recover files corrupted by the bug in commit bd84bc1a. 2019-06-25 00:48:57 +00:00
whitequark 49a7f863b8 Fix off-by-1 in Group::Remap.
This was introduced in bd84bc1a and caused crashes with:
  Assertion failed: hm.v != t->h.v.
2019-06-24 22:59:34 +00:00
phkahler 5df53fc59e Implement revolve groups. 2019-06-03 17:32:38 +00:00
whitequark 3d80062b66 GTK: delete all gtkmm objects before destrying Gtk::Main.
Otherwise this results in harmless but annoying spam on applciation
shutdown.

See https://gitlab.gnome.org/GNOME/gtkmm/issues/22.
2019-05-31 23:07:04 +00:00
whitequark 359697990a Update q3d submodule. 2019-05-31 23:07:04 +00:00
ruevs 9ac55f392a Win32: fix build with -DOPENGL=1. 2019-05-29 15:06:25 +00:00
whitequark 6352405206 Deselect entities with Ctrl-LMB.
In other words, Ctrl inverts the normal action of LMB. It is already
possible to deselect entities through the context menu, but that
can be very awkward on laptop touchpads with a crowded sketch; with
Ctrl, a misclick is easily corrected without moving cursor at all.
2019-05-24 19:11:56 +00:00
whitequark bd84bc1ae9 Replace entity map implementation with std::unordered_map.
On a single load benchmark this provides about 25% speedup.
2019-05-24 18:19:10 +00:00
whitequark 406c55e8b9 Instead of creating an exact copy of existing constraint, select it. 2019-05-24 16:21:55 +00:00
whitequark 09ca442715 Commit missing parts of cf2f0e5d. 2019-05-24 16:02:01 +00:00
whitequark eb7e12b829 Make sure file from a recent menu exists before using it.
Otherwise it can result in a very confusing error that does not
suggest at all that the file is missing.
2019-05-24 15:57:43 +00:00
whitequark beea4444ab Move logic for handling allowRedundant out of System. NFC. 2019-05-24 15:43:20 +00:00
whitequark cf2f0e5d44 In TryConstrain(), reject redundant constraints in overconstrained groups.
This keeps groups with allowed redundant constraints cleaner when
they are used together with automatic constraints.
2019-05-24 15:40:18 +00:00
whitequark 549565958f Skip creating an automatic H/V constraint if it would be redundant.
This means that automatically added H/V constraints now will never
cause the sketch to become overconstrained, which currently makes
that feature almost unusable.
2019-05-24 15:06:53 +00:00
whitequark 394c1f62d8 Remove forceDofCheck parameter from SolveRank(). NFC.
It makes no sense to solve by substitution (therefore weakening rank
check) in SolveRank(), since that's the whole point of SolveRank().

In addition, because SolveRank() is currently always called right
after AddConstraint(), forceDofCheck would always be true anyway.

In addition, it makes no sense to have TestRankForGroup() dependent
on the result of the previous solve. (For SolveGroup(), solving by
substitution after we know that rank test succeeds makes dragging
points much faster.)
2019-05-24 14:07:48 +00:00
whitequark 88879d352e Show Degrees of Freedom → Show Underconstrained Points
Clarify the name of the command, as the old name is not strictly
correct. E.g. consider a vertical line with a midpoint constraint to
origin has 1 DOF, but 2 highlights are shown. Conversely, a single
datum point has 2 DOF, but 1 highlight is shown.
2019-05-24 12:34:42 +00:00
EvilSpirit 9d1c295495 Add a setting to format constraint labels using SI prefixes.
Supported metric units: km, m, cm, mm, µm, nm.
Supported USCS units: in, mil, µin.

Also, use the newly introduced unit formatting machinery in tools for
measuring perimeter, area and volume, so that e.g. volume is not
displayed in millions of cubic millimeters.
2019-05-24 12:31:41 +00:00
whitequark 9faa7cb0ca Fix commit cc107887. 2019-05-24 03:39:34 +00:00
whitequark 6c167db602 Add an explicit mirror checkbox for Paste Transformed.
This has always been possible by using negative scale, so this just
adds a checkbox controlling the sign.
2019-05-24 02:16:01 +00:00
whitequark df6777aaf3 Warn on broken extrusions, like on broken polygons.
It's not very obvious if the extrusion failed because in a later
group, the solid (by default) uses a very dark gray color that blends
into the black background.

This needs to be done separately because, while we already warn on
broken polygons in workplanes, many more groups can be extruded, e.g.
the canonical way (for now) to mirror a group is to use a rotation,
and that doesn't get checked for closed contour, since most rotations
won't get extruded.
2019-05-23 23:42:57 +00:00
whitequark 43a59e212f Work around MSVC bug 746973.
MSVC has a long history of value initialization bugs, and this one is
no exception. In this case, when some MSVC versions (at least up to
2013) are instructed to value-initialize a non-POD class with
a compiler generated non-trivial constructor, it does not zero out
the POD members.
2019-05-23 20:50:04 +00:00
whitequark 9f2077b1f3 Explain how forceDofCheck in System::Solve works. NFC. 2019-05-23 19:40:32 +00:00
whitequark cc107887e7 Remove the last use of memmove. NFC.
Much clearer!
2019-05-23 19:30:33 +00:00
whitequark fabffbab79 Get rid of FreeTemporary. NFC.
Its only use was in a context where it was completely equivalent to
MemFree, so just use that instead, and keep the temporary heap as
purely an arena allocator, that could use something like bump
pointer.
2019-05-23 19:30:31 +00:00
whitequark ac7b82d7c1 Allow configuring the amount of digits displayed after decimal point.
This is useful in niche cases, like making angular measurement tools.

Also, use simpler and more principled code for numeric precision
while editing constraints: don't special-case angles, but use up to
10 digits after the decimal point for everything.
2019-05-23 17:53:53 +00:00
whitequark d01f715ebf CLI: accept --chord-tol as an option to regenerate.
This is currently necessary to get repeatable results when exporting
assemblies as a part of a batch process, since the mesh geometry in
imported files is not regenerated for export.
2019-05-23 16:31:08 +00:00
whitequark 50c004b679 Add a button to hide construction entities.
Also, mark not just curves, but also points and normals derived from
construction requests as construction.

Also, don't always mark arc center point as construction just to
exclude it from chord tolerance bounding box calculation; instead,
special-case it there.
2019-05-23 16:29:00 +00:00
Dynamo Dan e67f967933 Implement turntable (SketchUp-like) mouse navigation. 2019-05-23 15:45:15 +00:00
Werner Almesberger c2c26e95ad Make minor errors visible at a glance in the group list.
If a sketch has a "minor" problem, such as being self-intersecting,
this can cause considerably confusion in subsequent groups, yet is
not indicated in the group list.

This commit makes the "err" yellow in such cases. Note that the
indication may not change immediately when a change leading to
trouble is made, since the dependent groups are not recalculated
on all changes.
2019-05-23 15:23:18 +00:00
Ruevski 260769c03b Win32: Restore Windows XP Compatibility
By setting WINVER=0x0501 (Windows XP) in CMakeLists.txt and adding a few
missing defines in guiwin.cpp and configuring OPENGL=1 in CMake
Solvespace (3.0~25b6eba1) compiles and works perfectly on Windows XP.
Tested with MinGW GCC-6.3.0-1
2019-05-23 14:42:55 +00:00
Ryan Pavlik 31f58738f2 Add a few asserts. NFC. 2019-05-23 14:31:44 +00:00
EvilSpirit c9397eaa07 Make help text for image and TTF request creation reflect reality.
Before this commit it would prompt for top left and bottom left
corner, neither of which was what in fact was being used. Those two
specific points cannot be used because of the way equations are
written, so instead change that to top left and bottom right, which
is more convenient anyway.
2019-05-23 14:05:09 +00:00
whitequark 3296474c15 Rework tooltip implementation to track tip area.
This fixes an elusive GTK issue where tooltips would be spuriously
displayed, and makes tooltips behave nicer on Windows.

Unfortunately the macOS code is unchanged as the macOS tooltip
implementation seems seriously broken in ways I do not understand.
2019-05-23 13:54:24 +00:00
whitequark f6484c78e7 macOS: fix a crash at startup introduced in 75a09c8b. 2019-05-23 12:40:40 +00:00
whitequark e9b9dca2ca Win32: use native OpenGL drivers, if available.
After this commit, if the target system does have modern OpenGL
drivers installed, ANGLE is configured to use them, bypassing most
translation (shaders still have to be translated from ESSL to GLSL).

If there are no OpenGL drivers, such as if the graphics drivers were
installed via Windows Update, DirectX translation is still used. This
results in a very noticeable startup delay and minor performance
degradation.

In addition it is no longer necessary to build with -DOPENGL=1 to be
able to run the binary in wine; everything works out of the box.
Before, wine's incomplete HLSL translator would crash.

This change required renaming the variable `texture` in shaders,
since it shadows the Core GLSL function with the same name, and ANGLE
translates texture2D() calls to texture() calls.
2019-05-23 10:58:31 +00:00
whitequark 09212963ed Update copyright statement in about box.
Also, make sure it's localized properly.
2019-05-23 07:43:29 +00:00
whitequark 25b6eba148 Adjust angle label margin similarly to eda294ef. 2019-05-21 23:05:05 +00:00
whitequark 9500487a3f Fix an edge case with fps measured as infinite.
If the timer is not sufficiently high resolution but the graphics
card is fast, we can get renderTime.count() == 0.
2019-05-21 22:51:28 +00:00
Ryan Pavlik 39c348090b Add CountIf method to IdList to simplify some call sites. NFC.
This also changes GetNumConstraints to return size_t.
2019-05-21 01:19:11 +00:00
Ryan Pavlik 43c9cba7dd Reduce Vector::Element calls in SKdNode::SnapToVertex. NFC. 2019-05-21 01:19:09 +00:00
Ryan Pavlik f885daf752 Simplify. NFC. 2019-05-21 01:14:42 +00:00
whitequark 75a09c8b67 Minor cleanups. NFC.
A few code style changes extracted from the Emscripten port.
2019-05-21 00:48:20 +00:00
whitequark 7f75148671 Win32: ignore WM_MOUSEWHEEL events that are forwarded to other window.
Before this commit, scrolling the property browser positioned on top
of a face in the main window would highlight the face.
2019-05-20 22:58:07 +00:00
whitequark 5dbe090098 Win32: do not insert windows with parents after HWND_TOPMOST.
It is not clear why this code was added (I don't remember) and
the normal parent-child relationship should be sufficient for
the task of keeping property browser on top of the main window.

With SetWindowPos(hwnd, HWND_TOPMOST) though, the property browser
window stays on top of *anything*, even if the user switches to
an entirely different application.
2019-05-20 22:43:29 +00:00
whitequark be0dc7e2cb Win32: silence a GetProcAddress-related warning. 2019-05-20 22:12:45 +00:00
whitequark e11e23483d Win32: remove dead code in keyboard event handling.
The forwarding is now performed explicitly in the text window setup
code, so this branch never has a chance to run.
2019-05-20 21:52:06 +00:00
whitequark bda3b80609 GTK: fix last remains of legacy event handling code. 2019-05-20 21:42:37 +00:00
whitequark f43954cc29 Adjust GL1 and GL3 ReadFrame to take pixel ratio into account.
Currently, on HiDPI screens the Export Image command would return
a cropped screenshot.
2019-05-20 19:09:40 +00:00
whitequark 11c5cdc7b0 Adjust GL3 ReadFrame() for GL ES 2.1 compatibility.
Currently on Win32 this errors out and renders a black rectangle.
2019-05-20 19:09:40 +00:00
Ryan Pavlik 62aba398f7 Move two members of Vector to be inline.
Performance change: moved since they show up disproportionately
in profiling.
2019-05-15 19:53:38 +00:00
Ryan A. Pavlik 52a481cd1e Small performance optimization in Vector::Equals.
This function showed up surprisingly high on a CPU time profile
when the GUI was unresponsive "doing things". Removed a duplicated
difference in the not-equal case, and switched to abs and a single compare
instead of two compares with a negation. It seems to have moved the
function further down in the profile.
2019-05-13 15:21:18 +00:00
whitequark 838126f81f GTK: rework f07e975d to fix build on both pre and post 3.24 GTK. 2019-05-13 15:21:11 +00:00
Bauke Conijn 7d181f0d0f Include custom styled entities in the same plane when exporting section. 2019-05-13 14:34:22 +00:00
whitequark c44a471649 Win32: fix destruction order issue leading to crash on close. 2019-05-13 09:13:55 +00:00
Zhuowei Zhang f07e975db1 GTK: fix build on Ubuntu 18.04 by removing debug define
Ubuntu 18.04 uses GTKMM 3.22.2-2, which doesn't support native file chooser.

Commit bc3e09edbf checks if native file chooser
is available, but the result is overridden with a hardcoded define,
probably for debugging.

Removing the debugging code fixes build on Ubuntu 18.04.
2019-05-13 07:03:22 +00:00
whitequark bc3e09edbf GTK: use native file chooser dialog, if available.
This requires GTK 3.24+ and (at least for GTK 3.24) the environment
variable GTK_USE_PORTAL to be set to 1.
2019-05-08 22:59:20 +00:00
whitequark fa66229030 Fix choice of normal for revolution in some corner cases.
Before this commit, if the sketch contain no entities with starting
points off of the axis of revolution, the revolution may fail, which
manifests as the face normals being inverted. The code at the top of
MakeFromRevolutionOf() takes the furthest point from the axis,
projects it on that axis to get a vector. In this case that vector
is essentially zero length except for rounding errors.

After this commit, instead of only considering start points of
beziers, all control points are considered.

Fix by @phkahler.
2019-04-22 11:50:47 +00:00
whitequark b69ef71e63 Fix misuse of Path in dc6c7bd0. 2019-04-21 06:54:46 +00:00
probonopd dc6c7bd0ce Add a lookup for resources in ../share/solvespace.
This is useful for relocatable bundles, e.g. AppImage or NixOS.
2019-04-21 06:16:35 +00:00
whitequark ce0b130d6c Disable mnemonics when pathnames are used as menu item labels.
Based on a patch by Matthew White.
2019-04-13 11:02:43 +00:00
whitequark a7b2f28999 Silence some gcc 7 warnings.
* Mark switch fallthrough
    (-Wfallthrough);
  * Initialize variables to avoid false positives
    (-Wmaybe-uninitialized);
  * Fudge indentation to avoid false positives
    (-Wmisleading-indentation).
2019-03-28 09:46:16 +00:00
Sergiusz Bazanski 3a3a2755bf Implement Q3DO export.
We plan to use flatbuffers in the future for the next generation of
the .slvs file format, so flatbuffers are built unconditionally; and
the Q3DO exporter itself is tiny.
2019-03-28 08:53:37 +00:00
Bauke Conijn 9d1601eea9 Fix uninitialized memory access in toolbar. 2019-02-19 11:35:56 +00:00
Bauke Conijn 8d07a6b4f4 Import missing styles from linked files. 2019-02-19 10:42:14 +00:00
Sergiusz Bazanski 9e512882d1 Add checkbox to control automatic line constraints
Signed-off-by: Sergiusz Bazanski <q3k@q3k.org>
2019-02-11 13:17:38 +00:00
whitequark 94b26ddfac Add a built-in Bitstream Vera Sans Roman font.
Before this commit, the default font chosen for TTF text is Arial
(chosen by the basename of arial.ttf), which isn't present on most
Linux systems, and cannot be redistributed. After this commit, it is
replaced with Bitstream Vera Sans, which can be. Existing files
are not affected.

The font name in the TTF file was artificially modified to add
the (built-in) suffix, which will need to be done if more built-in
fonts are added.
2019-02-11 11:03:47 +00:00
Bauke Conijn e69478e61a Let tangent arc modify the original entities.
Modifying the original entities instead of deleting them, retains the
original associated constraints. This makes creating rounded rectangles
a lot easier.
2019-02-11 10:45:11 +00:00
whitequark e383b7fba8 Remove superfluous glPolygonOffset() call in GL3 renderer.
This caused red fringes on mesh boundary with back faces turned on.
2019-02-04 20:41:50 +00:00
whitequark 28fa348859 Use correct polygon winding order in GL3 renderer. 2019-02-04 20:25:45 +00:00
whitequark 8e4c4b0d46 Check return values of fread, etc in ReadFile/WriteFile. 2019-01-10 07:12:12 +00:00
whitequark 52c41782d8 cli: fix typo. 2018-11-08 04:10:14 +00:00
luz.paz 258545a334 Misc. typos
Found via `codespell -q 3 --skip="./res/locales,./extlib"`
2018-09-19 18:52:11 +00:00
whitequark 4d1e1341d9 GTK: fix an use-after-free in message dialog ShowModal(). 2018-08-03 13:39:00 +00:00
whitequark 42bc7efa44 Fix Z-index of UI elements drawn by the color picker.
Also fix asymmetric crosshairs, while we're at it.
2018-07-31 21:26:47 +00:00
whitequark 21d1a625e3 Fix a few warnings emitted by Clang. 2018-07-31 21:03:52 +00:00
whitequark 80c111bf75 Finish OpenGL 2 to OpenGL 3 renaming started in ecb6550b. 2018-07-31 21:01:28 +00:00
whitequark 4d1bd55cc2 GTK: fix dismissing the editor with Escape.
Before this commit, the editor was simply hidden, and as a result
pressing Escape in the color chooser would leave the latter open.
2018-07-31 20:49:56 +00:00
whitequark eda294efb5 Adjust the horizontal constraint label margin to equal vertical.
Right now, horizontally placed labels appear more cramped than
those that are placed vertically.
2018-07-31 17:21:15 +00:00
Alexander Meißner bc6a923c4c macOS: fix crash on startup.
Added missing @synthesize acceptsFirstResponder;
Replaced generic ApplicationDelegate in MainMenu.xib
2018-07-31 15:55:11 +00:00
whitequark c3875cba9e Add missing override qualifier. 2018-07-31 15:54:31 +00:00
whitequark a4644cc58d GTK: fix message dialogs not being responsive to buttons. 2018-07-22 09:00:13 +00:00
whitequark 8426992f27 Eliminate blocking in Error() and Message() calls.
This serves two purposes.

First, we want to (some day) convert these messages into a less
obtrustive form, something like toaster notifications, such that they
don't interrupt workflow as harshly. That would, of course, be
nonblocking.

Second, some platforms, like Emscripten, do not support nested event
loops, and it's not possible to display a modal dialog on them
synchronously.

When making this commit, I've reviewed all Error() and Message()
calls to ensure that only some of the following is true for all
of them:
  * The call is followed a break or return statement that exits
    an UI entry point (e.g. an MenuX function);
  * The call is followed by cleanup (in fact, in this case the new
    behavior is better, since even with a synchronous modal dialog
    we have to be reentrant);
  * The message is an informational message only and nothing
    unexpected will happen if the operation proceeds in background.

In general, all Error() calls already satisfied the above conditions,
although in some cases I changed control flow aroudn them to more
clearly show that. The Message() calls that didn't satisfy these
conditions were reworked into an asynchronous form.

There are three explicit RunModal() calls left that need to be
reworked into an async form.
2018-07-20 04:40:19 +00:00
whitequark 396cac556d Add missing virtual destructors. 2018-07-19 22:42:24 +00:00
whitequark c37cddfc7f I18n: internationalise some messages that were missing gettext calls. 2018-07-19 21:51:27 +00:00
whitequark fb138f496a Add final qualifiers where applicable.
We have a lot of classes with virtual functions but no virtual
destructor, mostly under render/. While this is not a problem
due to how our hierarchy is structured, some versions of clang
warn about this on the delete statement inside shared_ptr.

We could add a virtual destructor, but adding final qualifiers
expresses intent better, is generally more efficient (since it allows
devirtualizing most virtual calls in render/), and solves
the potential problem clang is warning us about.
2018-07-19 00:11:04 +00:00
whitequark 4f52167a78 Use std::shared_ptr instead of std::unique_ptr for Platform::TimerRef.
We currently support MSVC 2013, and MSVC 2013 has weird bugs around
std::unique_ptr; the one we hit is Connect ID 858243. You can't
actually open the bug report anymore because Microsoft has shut down
Microsoft Connect. We probably shouldn't support a compiler so old
its bugtracker doesn't exist anymore, but there isn't any very good
reason to use unique_ptr for TimerRef either, so let's change that
for the time being.
2018-07-18 23:49:51 +00:00
whitequark a738e3f82e Eliminate imperative redraws.
This commit removes Platform::Window::Redraw function, and rewrites
its uses to run on timer events. Most UI toolkits have obscure issues
with recursive event handling loops, and Emscripten is purely event-
driven and cannot handle imperative redraws at all.

As a part of this change, the Platform::Timer::WindUp function
is split into three to make the interpretation of its argument
less magical. The new functions are RunAfter (a regular timeout,
setTimeout in browser terms), RunAfterNextFrame (an animation
request, requestAnimationFrame in browser terms), and
RunAfterProcessingEvents (a request to run something after all
events for the current frame are processed, used for coalescing
expensive operations in face of input event queues).

This commit changes two uses of Redraw(): the AnimateOnto() and
ScreenStepDimGo() functions. The latter was actually broken in that
on small sketches, it would run very quickly and not animate
the dimension change at all; this has been fixed.

While we're at it, get rid of unused Platform::Window::NativePtr
function as well.
2018-07-18 23:18:02 +00:00
whitequark 738ac02cbf Fix some strict GL ES 2 conformance issues.
This commit fixes two issues that cause issues in WebGL:
  * Non-power-of-two textures must wrap as GL_CLAMP_TO_EDGE.
    This breaks non-power-of-two textures.
  * Render calls with zero primitives should not be issued.
    This just causes warning spam.
2018-07-18 19:40:14 +00:00
whitequark 02ec64ee66 Fix unaligned access in LoadStringFromGzip.
The code in LoadStringFromGzip was attempting to perform an unaligned
access using memcpy, but it cast the source to a pointer with
alignment requirements larger than 1, which, under optimizations,
reintroduced the original issue.
2018-07-18 15:36:59 +00:00
whitequark efc3da4579 CMake: add an ENABLE_CLI flag. 2018-07-18 11:49:06 +00:00
whitequark 22a9705a21 Win32: fix crash on application exit. 2018-07-18 03:07:48 +00:00
whitequark 5853fa0421 Finish refactoring of platform code.
This commit finally unifies all main() functions and moves the few
remaining application-wide functions where they belong.
2018-07-18 03:04:16 +00:00
whitequark 350d2ad211 CLI: fix crash running the "thumbnail" command. 2018-07-18 02:31:37 +00:00
whitequark 0fb9a4cc23 GUI: fix formatting of messages with only one sentence. 2018-07-18 02:31:35 +00:00
whitequark 7630e0e4e2 Make some dubious type conversions explicit.
This is to address MSVC warnings.

This commit changes a few configuration fields to use double instead
of float. There doesn't seem to be any reason these use float except
for the legacy Windows code using float for saved configuration.
Changing their type to double improves consistency.
2018-07-18 01:14:59 +00:00
whitequark c1f1c7c409 Add a platform abstraction for 6-DOF input devices.
This commit mostly just moves code around.
2018-07-18 01:05:19 +00:00
whitequark 6b5db58971 Add a platform abstraction for file dialogs.
This commit merges all ad-hoc file dialog code, such as the feature
where dialogs remember last location and format, and exposes it
through a common interface.

This commit also significantly improves Gtk dialog handling code.
2018-07-17 22:33:45 +00:00
whitequark d7968978ad Add a platform abstraction for message dialogs.
This commit changes the awfully specific code for dialogs with
messages duplicated three times to go through a generic interface.
It also fixes some issues with the way translated messages
were parameterized.

This commit removes the custom message dialog box used on Windows,
for several reasons. First, it was the last element not respecting
HiDPI displays. Second, other OSes do not easily provide this much
control over rendering default message boxes, and both Gnome and
macOS frown upon non-standard renderings such as those; so the custom
rendering was already not used on the other OSes.
2018-07-17 22:33:45 +00:00
whitequark 84bf37abed GTK: save boolean settings as JSON booleans. 2018-07-17 16:05:46 +00:00
whitequark 26f3751ce8 macOS: rename application bundle to SolveSpace.
This changes the capitalization shown in GUI.
2018-07-17 15:01:58 +00:00
whitequark a93283df9d macOS: put assertion message into crash reporter dialog.
This commit makes FatalError a GUI-dependent function.
2018-07-17 15:01:58 +00:00
whitequark eb5501ecd6 Implement a platform abstraction for settings.
This commit mostly just changes the settings code to be in line with
the rest of the platform abstractions, although it also fixes some
settings names to be consistent with others, and uses native bool
types where applicable.

This commit also makes settings-related operations much less
wasteful, not that it should matter.
2018-07-17 15:01:58 +00:00
whitequark f324477dd0 Implement a platform abstraction for windows.
This commit removes a large amount of code partially duplicated
between the text and the graphics windows, and opens the path to
having more than one model window on screen at any given time,
as well as simplifies platform work.

This commit also adds complete support for High-DPI device pixel
ratio. It adds support for font scale factor (a fractional factor
on top of integral device pixel ratio) on the platform side, but not
on the application side.

This commit also adds error checking to all Windows API calls
(within the abstracted code) and fixes a significant number of
misuses and non-future-proof uses of Windows API.

This commit also makes uses of Windows API idiomatic, e.g. using
the built-in vertical scroll bar, native tooltips, control
subclassing instead of hooks in the global dispatch loop, and so on.

It reinstates tooltip support and removes menu-related hacks.
2018-07-17 13:31:17 +00:00
whitequark 55baaf310f Implement a platform abstraction for menus.
This commit removes a large amount of redundant code that needed
to be kept in sync between platforms and also makes it much easier
to add new menu-related functionality since little to no platform
code needs to be altered anymore.

This commit also greatly improves code locality in context menu
handling by allowing context menu click handlers to be closures.

This commit temporarily introduces a SetMainMenu API, which is rather
hacky but only necessary until an abstraction for windows is added.
2018-07-16 11:21:30 +00:00
whitequark 7ab87caa88 Implement a platform abstraction for timers.
This commit temporarily disables tooltip functionality; it will
be handled natively in a platform abstraction for windows using
much simpler code.
2018-07-16 11:21:30 +00:00
whitequark 28f94dcd0a Start using C++ in-place member initialization.
We should make good use of in-place member initialization. Many
new classes have constructors that effectively do nothing but
default-initialize POD members, and when adding new members,
it is very easy to miss initializing them. With in-place
initialization, the code is more compact, the diffs are nicer,
and it's harder to miss them.

This commit only converts render/ and platform/ to use in-place
member initialization, since there was a bug in CairoRenderer,
but we should convert the entire codebase.
2018-07-16 11:21:30 +00:00
whitequark 975b49f520 Win32: offer to restart application on fatal errors.
This changes the assertion failure behavior to be the same in debug
and release builds: to show the complete failure message, and
to offer to restart the application or defer to Windows Error
Reporting to generate a backtrace. Contrary to popular belief,
WER is not useless, and since SolveSpace publishes pdb files,
WER-generated reports can be symbolized.

This commit also addresses the long-standing problem where showing
a dialog on fatal error would re-enter the application code, thus
causing another error or a crash that is more fatal than the current
one.
2018-07-14 16:05:08 +00:00
Bauke Conijn 8192c965ea Show degrees of freedom in property browser. 2018-07-13 04:29:36 +00:00
whitequark 595ae86b29 I18n: update translations. 2018-07-12 23:06:07 +00:00
whitequark f54dabbb5f Clean up includes and include guards.
According to the C standard all preprocessor definitions starting
with an underscore are reserved for standard and implementation use,
so don't use those. Also, sort and unique include directives.
2018-07-12 18:48:51 +00:00
Guido d471e65e7d Implement splitting at point with "Split Curves at Intersection". 2018-07-12 18:39:19 +00:00
whitequark f2ecd7abe6 macOS: use correct format for connexionName field.
3DConnexion configuration tool appears to use Pascal strings there.
2018-07-12 12:17:22 +00:00
EvilSpirit a16c204304 Allow using m (in addition to mm and inch) as base unit. 2018-07-12 12:01:46 +00:00
EvilSpirit 6ad5c684d8 Avoid degenerate triangles when snapping to mesh.
This can cause memory exhaustion when exporting to mesh with small
(but not excessively small) chord tolerance.
2018-07-12 11:50:24 +00:00
EvilSpirit 025bb960c0 Improve performance of mesh-forced assemblies. 2018-07-12 11:47:58 +00:00
whitequark c8fc033047 macOS: fix #include to work on case-sensitive filesystem. 2018-07-12 11:45:15 +00:00
whitequark 9c99f69da5 Clean up unused shader variables. 2018-07-12 11:43:25 +00:00
whitequark 20a4a2b23f Avoid using `tan` as identifier in shaders.
This conflicts with the tan() function, currently only on macOS.
2018-07-12 11:40:51 +00:00
whitequark f37881a2e3 macOS: bundle and statically link external dependencies.
This fixes numerous linking issues where updated system libraries
on macOS cause errors on startup in newer OS versions.
2018-07-12 11:15:31 +00:00
Mat M 03e479eb25 Ensure va_end() is always called in TextWindow::Printf(). 2018-07-12 05:06:35 +00:00
luzpaz 771b415a12 Fix various comment and UI string typos. 2018-07-12 05:05:43 +00:00
whitequark 49ff36fd51 Use a more rigorous check for library containing backtrace(). 2018-07-11 02:36:17 +00:00
whitequark 8cedefc278 Allow using non-ASCII format strings in Printf. 2018-07-10 23:44:02 +00:00
whitequark 2b9ffd1542 Fix handling of relative paths with no directory in solvespace-cli.
Before this commit, e.g. `solvespace-cli regenerate foo.slvs`
would save a file called just `.slvs`.
2018-05-10 15:31:55 +00:00
whitequark 3d7e9f5e7b Provide correct arguments to inflateInit2.
windowBits of 16 means "decode gzip header" and "use window size
from zlib header". For some reason, this results in a window size
that is too small on OpenBSD. Instead, use maximum window size
explicitly, since there is no downside for doing so.
2017-12-17 18:44:38 +00:00
Evil-Spirit a10db16a9c Fix dash-dash-dot line style. 2017-08-08 12:23:48 +00:00
whitequark 49c64f7f15 CMake, macOS: create bundle directory explicitly.
Before this commit, this worked fine with the Unix Makefiles
generator, but not with the Xcode generator.
2017-07-23 03:52:40 +00:00
whitequark 33b6e51737 Locale LCID is a hex number, not a decimal. 2017-05-07 21:45:53 +00:00
whitequark 280d5b902f TTF: avoid crashes on fonts without U+0041 LATIN CAPITAL LETTER A.
Since font sizes in SolveSpace are specified in terms of cap height,
we need U+0041 to determine cap height. Some fonts lack it; in
that case, we assume that cap height is the same as the size we've
requested. This avoids a crash, at the cost of completely wrong
(although consistent) metrics; I do not really know of a better way.
2017-04-26 23:07:54 +00:00
whitequark 5408f73b96 Fix a crash creating a group from a non-reference workplane. 2017-04-21 23:08:08 +00:00
whitequark 85b4b25278 Fix a crash changing g->meshCombine when g->type!=EXTRUDE. 2017-04-16 02:12:31 +00:00
whitequark 1480f890bd Add a check omitted in e5259d7a. 2017-04-16 00:35:44 +00:00
whitequark e5259d7a3e Swap arc endpoints when pasting transformed with negative scale. 2017-04-12 04:51:23 +00:00
whitequark 5d67b42842 CMake: don't have multiple rules generating same targets.
There was a copy rule that copied the locale from the source
to the binary directory, and also a regeneration rule that used
the locale in the binary directory as a temporary file.
Rename the target for the latter.
2017-04-08 18:37:02 +00:00
whitequark 287bd98a3f Fix copying and pasting image requests. 2017-04-08 17:17:38 +00:00
EvilSpirit 99f6ea34f1 Add an option to display areas of closed contours.
This is useful e.g. for architectural work.
2017-04-08 16:43:06 +00:00
whitequark c0b6eaa935 Fix automatic marking of constraints as reference.
To reproduce:
  * New sketch;
  * Create two redundant constraints, with second being automatically
    marked as reference;
  * Switch one of these to non-reference;
  * Allow redundant constraints;
  * All new constraints with labels created as reference, even
    if that specific degree of freedom is not constrained yet.
2017-04-08 14:42:35 +00:00
whitequark 43dc16262a Rewrite equation for pt-on-circle to avoid negative diameter. 2017-04-08 14:38:07 +00:00
EvilSpirit 8fd11f4886 Fix forcing NURBS to mesh in a step group when the flag is inherited.
Before this commit, if the source group of a step rotate/translate
group is forced to triangle mesh, the UI would show that the step
rotate/translate group is also forced to triangle mesh, but the group
would in fact contain NURBS surfaces.
2017-04-06 07:40:47 +00:00
whitequark ecb6550b5c Change mentions of OpenGL 2 to OpenGL 3.
We ended up in a confusing state where OpenGL 2 (like in "gl2")
actually refers to OpenGL ES 2, which roughly corresponds to
OpenGL 3. Rectify that.
2017-04-06 07:20:50 +00:00
whitequark 7eb6574f90 Rename TextWindow::CHAR_WIDTH to CHAR_WIDTH_.
glibc defines a CHAR_WIDTH macro in limits.h since about 6.3.*.
This is apparently added as a part of ISO TS 18661-1:2014, which
I cannot read because it is not publicly available, and which covers
some sort of floating-point extensions. This is one of those changes
that should never have been done yet here we are.
2017-04-06 06:54:07 +00:00
whitequark b0ea9d8eb4 Allow suppressing solid model of extrude and lathe groups. 2017-04-05 18:49:18 +00:00
whitequark 6337bbbcd6 Fix a missing semicolon. 2017-03-22 19:13:00 +00:00
EvilSpirit aaa9c6df7a Fix a texture memory leak. 2017-03-22 19:12:25 +00:00
whitequark 827f54f2c4 GTK: ensure the editor always uses contrasting colors.
On some configurations, it seems that the default GTK theme
has a transparent background, which makes black text on black
(GL) background illegible.
2017-03-19 18:43:27 +00:00
whitequark acc25ecd57 Fix toolbar height after 5744d1d5. 2017-03-13 01:14:59 +00:00
whitequark ca2aad7fea Remove the "style → background image" feature. 2017-03-13 01:12:58 +00:00
EvilSpirit 5744d1d599 Implement an image request. 2017-03-12 00:13:56 +00:00
whitequark e2e74762f4 Rework path and file operations to be more robust.
This commit updates a *lot* of rather questionable path handling
logic to be robust. Specifically:
  * All path operations go through Platform::Path.
  * All ad-hoc path handling functions are removed, together with
    PATH_SEP. This removes code that was in platform-independent
    parts, but had platform-dependent behavior.
  * Group::linkFileRel is removed; only an absolute path is stored
    in Group::linkFile. However, only Group::linkFileRel is saved,
    with the relative path calculated on the fly, from the filename
    passed into SaveToFile. This eliminates dependence on global
    state, and makes it unnecessary to have separare code paths
    for saved and not yet saved files.
  * In a departure from previous practice, functions with
    platform-independent code but platform-dependent behavior
    are all grouped under platform/. This makes it easy to grep
    for functions with platform-dependent behavior.
  * Similarly, new (GUI-independent) code for all platforms is added
    in the same platform.cpp file, guarded with #ifs. It turns out
    that implementations for different platforms had a lot of shared
    code that tended to go out of sync.
2017-03-11 18:58:53 +00:00
whitequark 335c217114 Collect together and rigorously test all our ad-hoc path functions. 2017-03-11 16:24:12 +00:00
whitequark 60f85f5a39 Win32: fix invalid accelerator labels. 2017-03-11 16:24:12 +00:00
whitequark 7e2b1b1d8d Add a test for the link group. 2017-03-10 21:19:02 +00:00
whitequark 15f349049c Make CLI usage text more readable. 2017-03-10 21:05:52 +00:00