Commit Graph

996 Commits (37de36425770880032bd281efe069a1c0b8daea9)

Author SHA1 Message Date
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
whitequark 27b59f601e Fix type conversion warnings. 2017-03-10 21:05:52 +00:00
whitequark dbf66639aa Replace ad-hoc implementations of Basename with calls to it. 2017-03-08 19:25:45 +00:00
whitequark f2f37aeed8 Remove dead code. 2017-03-08 18:08:20 +00:00
whitequark 61fe8badf2 GTK: take scale factor into account when positioning entry. 2017-03-04 00:09:05 +00:00
whitequark 8e27a5e34b GTK: take margin and border size into account when positioning entry. 2017-03-04 00:09:05 +00:00
EvilSpirit 91574254fe Improve handling of corner cases related to assembled loop normals.
Extrustion top and bottom faces require a normal to be present.

Before this commit, the normal is always taken from the assembled
loop; if the loop could not be assembled (i.e. the loop is broken
or not coplanar) the normal will be (0,0,0), which breaks the sketch.
Also, loops are not generated when generating the sketch
to determine its bounding box.

This may result in spuriously broken sketches when e.g. undoing
a change that has broken a loop.

After this commit, loops are generated when generating for bounding
box, and if the loop could not be assembled, then the workplane
normal is used. This still results in failures when there is
no workplane, but those cases should be quite pathological.
2017-02-17 05:01:19 +00:00
whitequark dea573e156 Highlight normals and circle radii that have a degree of freedom. 2017-02-17 04:14:36 +00:00
EvilSpirit 3bcc376224 Same orientation constraint doesn't exist in a workplane.
Before this commit, a same orientation constraint created with
a workplane selected would only remove 2 of 3 DOFs. After
this commit, it properly removes all 3 DOFs.
2017-02-17 03:05:43 +00:00
EvilSpirit 6bc2ed9771 Remove nonexistent degrees of freedom from lathe groups.
Before this commit, lathe groups had three DOFs, which of course
could not actually move. After this commit, lathe groups have
zero DOFs, as expected.

This bug was introduced in commit 6dced80.
2017-02-17 03:01:45 +00:00
EvilSpirit 3c36d8f887 Pin comments with custom styles to front layer, like regular ones.
This is the 2.x behavior that was accidentally broken in the canvas
rewrite.
2017-02-17 02:53:20 +00:00
EvilSpirit 312184505c Fix undefined behavior in solvespace-cli. 2017-02-17 02:52:19 +00:00
whitequark 41794dbadb Fix a crash in expression parser.
Found by lineprinter0@gmail.com through fuzzing.
2017-02-17 02:50:00 +00:00
whitequark f29d9d7a34 GTK: run DoLater after the next main loop iteration.
Before this commit, DoLater would be run as an idle callback,
which (depending on system performance) could either result in
a half-regenerated sketch being displayed, with only the dragged
entity updated, or no regeneration whatsoever during the drag.

After this commit, the GTK behavior matches macOS and Win32 ones.
2017-02-08 14:27:02 +00:00
whitequark 1871efa02b Commit missing parts of d77f617. 2017-02-06 16:01:10 +00:00
whitequark 2e15f60ef6 Win32: implement support for full-screen graphics window. 2017-02-06 15:12:26 +00:00
whitequark d77f617dc4 Remove the "show menu bar" option.
Hiding the menu bar was only supported on macOS, and it is inherently
troublesome to port because keyboard accelerators on Win32 and GTK
are inherently dependent on the menu bar being visible.

On top of that, it's not clear how to bring it back if it's hidden
by accident.
2017-02-06 15:11:58 +00:00
EvilSpirit 97e71856b3 Snap point to entity when constraining to a hovered entity.
Before this commit, when a point is constrained to an entity (point,
circle, arc of circle or line segment) by clicking on it,
the resulting constraint is not necessarily satisfied, and the next
regeneration may place the newly constrained point somewhere other
than the intended position. After this commit, the parameters
are modified to satisfy the constraint.
2017-02-06 14:20:19 +00:00
EvilSpirit ced42440e7 Explicitly represent the parameter used in constraints.
Commit f5485cb and its ancestors add a parameter to some constraints.
This parameter must be materialized and assigned a non-zero value via
ModifyToSatisfy for the solver library to not make unnecessary
changes to the sketch during the initial generation. For this, we
represent it explicitly instead of using hc.param(0), such that
the materialized constraint does not conflict with any user-defined
ones.
2017-02-06 13:02:49 +00:00
whitequark 4260be2445 DXF: mark POLYLINE as 3d if any of the points have non-zero Z.
This commit follows 41365c5, which enabled export of Z coordinate
by using POLYLINE instead of LWPOLYLINE. After this commit, only
the AcDb2dPolyline/AcDb2dVertex are used when exporting flat views,
which may improve compatibility with 2d design packages.
2017-02-05 09:39:22 +00:00
EvilSpirit baf9dc0aae Remove degenerate triangles when generating triangle mesh. 2017-02-05 09:25:07 +00:00
whitequark 4465bc0270 CMake: do not remove translations on `make clean`. 2017-02-02 18:09:50 +00:00
whitequark 279424290b Remove a redundant ReloadAllImported() call. 2017-01-31 02:20:10 +00:00
whitequark 6e88eaef69 Fix a path construction issue introduced in 3fc85b7. 2017-01-31 02:15:37 +00:00
EvilSpirit d4b052d34d Fix logic introduced in 55ae10b.
Before this commit, the effect of the AddPending() call was
immediately reversed by ClearSuper.
2017-01-24 20:30:48 +00:00
whitequark 3fc85b7934 CLI: add the "regenerate" command, for use in Makefiles etc. 2017-01-24 19:55:53 +00:00
whitequark 27a5f6f9bd CLI: include directory name in %-replacement. 2017-01-24 19:54:47 +00:00
whitequark 67a916d19c CLI: show usage when --help/-h passed. 2017-01-24 19:40:30 +00:00
whitequark ff0af6fdba Fix a typo in 495a7ac. 2017-01-23 11:15:37 +00:00
whitequark 495a7ac166 Refactor the "File → Export Image" command.
The existing code is horrible and needlessly platform-dependent.
Even worse, it causes a freeze on GTK. Instead of propping that up
with a few more crutches, just fix the root cause.
2017-01-23 00:24:18 +00:00
whitequark bb2cc4aa56 GTK: do not compose rendered geometry with an alpha buffer.
The somewhat confusingly named set_has_alpha() function does not
affect whether alpha can be used during rendering to the area.
Rather, it affects whether alpha will be used when composing
the contents of the area with the window underneath it.
2017-01-21 06:34:44 +00:00
EvilSpirit 669e6f0dcb Select the appropriate entity when dragging a circle or a normal.
This commit adds logic that was missed in 25631d4.
2017-01-20 11:54:56 +00:00
EvilSpirit 119b17ac75 Fix an occasional crash when starting to drag an entity. 2017-01-20 11:48:47 +00:00
EvilSpirit 86f229c5e6 Render points corresponding to a DOF in the front layer.
Before this commit, if any rendering mode except "show all occluded"
is enabled, points can be highlighted for corresponding to a DOF
after "Analyze → Degrees of Freedom" but then promptly occluded,
which is confusing.
2017-01-20 11:46:31 +00:00
EvilSpirit db75e06ecc Add a command to show center of mass, assuming uniform density. 2017-01-19 08:54:11 +00:00
whitequark 068191bf28 GTK: unbreak the color chooser.
We want to suppress accelerators but still get input to (at least)
the window where the editor is opened. It's no harm to permit input
to other windows, but it is bad to route all of it to the editor,
since color chooser depends on being able to receive input.

So, what we do is add modal grab to the *overlay*, which has
the editor and the underlay widget, route all events as usual
to children, and just force the key events to go to the editor,
since otherwise they would still propagate up for some reason.
2017-01-17 13:11:09 +00:00
whitequark 8749a175a6 Draw constraints/entities when hovered or selected even if invisible.
This goes really well with the related constraint/request lists,
and in general seems very natural.
2017-01-17 11:53:51 +00:00
whitequark e388d9fd16 List applied constraints when selecting an entity. 2017-01-17 11:43:45 +00:00
whitequark 5d9356a90a List constrained requests when selecting a constraint. 2017-01-17 11:32:50 +00:00
EvilSpirit 3e668079b5 Fix a crash after creating a constraint.
To reproduce, e.g.:
  * draw a rect;
  * translate the rect;
  * add a pt-on-line constraint between two instances.
2017-01-17 11:26:04 +00:00
whitequark 572fbc7463 Reapply "Simplify Group::IsVisible(), GroupsInOrder()."
This reverts commit 1d1bdddef21baf1e312fcc65bb67e76c87b2b0fc,
with a bugfix for pruning orphans when deleting a group in the middle
of the sketch.
2017-01-17 11:26:04 +00:00
whitequark 67146f6ab2 Revert "Simplify Group::IsVisible(), GroupsInOrder()."
This reverts commit 022d012a44.

The commit above has caused crashes during pruning.
2017-01-17 11:26:04 +00:00
whitequark 8370382a33 Fix reference to a shader that no longer exists. 2017-01-17 11:26:04 +00:00
whitequark 5b2ad9b5f1 Fix 2d stippling of hovered and selected faces.
This was broken in ec07516.
2017-01-17 11:26:04 +00:00
whitequark 6931979b8e Fix an OpenGL initialization glitch.
Before this commit, the first time NewFrame() is called,
the background color would not be filled, leading to interference
with whatever the GUI toolkit decided to put there.
2017-01-14 06:06:55 +00:00
EvilSpirit 5c34b3f6ef Allow copying and pasting of datum points. 2017-01-14 03:17:09 +00:00
EvilSpirit 12a1a35784 Reserve space upfront when possible, to avoid re-allocations. 2017-01-14 03:07:33 +00:00
whitequark fba88859e1 Normalize CRLF newlines to LF when loading string resources. 2017-01-14 02:41:23 +00:00
whitequark ec07516580 GTK: work around a gtkmm<3.22 bug. 2017-01-14 02:41:23 +00:00
whitequark 29e43e67ea Fall back to en_US if the system locale is not available.
Without this, msgids would be used instead of the more proper
message strings. Also, since RefreshLocale() is never called,
the menu goes missing.
2017-01-14 00:32:47 +00:00
whitequark cde86a0626 Fix an uninitialized variable. 2017-01-13 23:43:02 +00:00
whitequark 6b67cfe63f Except when using OpenGL ES 2, use OpenGL 3.2+ Core profile.
This is primarily done to lower the GTK version dependency below
GTK 3.22, since GTK 3.22 is unlikely to be widely availale any
time soon.
2017-01-13 23:43:02 +00:00
whitequark 6de5133609 GTK: default to the en_US locale if LANGUAGE is set and empty. 2017-01-13 21:13:40 +00:00
EvilSpirit 022d012a44 Simplify Group::IsVisible(), GroupsInOrder(). 2017-01-12 01:40:34 +00:00
EvilSpirit 43db2201fd Turn newly created redundant constraints with a label into references.
This is a fairly standard CAD feature; it conveys the same
information and has the same recovery path, without erroring out,
so seems like an obvious win.
2017-01-12 01:34:41 +00:00
EvilSpirit c00ab25740 Don't move points when automatically constraining coincident.
This can change the sketch dramatically, e.g. extrude a rectangle
and draw a line diagonally from the top to the bottom face.
2017-01-11 04:34:11 +00:00
whitequark 855de072be Automatically constrain arc or rectangle points. 2017-01-11 04:17:14 +00:00
EvilSpirit 55ae10b5b8 Do not hover or select entities from any pending request. 2017-01-11 04:16:59 +00:00
whitequark 96476ca2e5 GTK: respect the scale factor when computing coordinates.
This doesn't bring true HiDPI support yet, since there are no HiDPI
assets anyway, but it makes the interface usable.
2017-01-11 03:41:06 +00:00
EvilSpirit fb667fb8bb Use a dedicated BitmapFont instance per Canvas.
Before this commit, updates to the bitmap font in the graphics window
cause missing characters in the text window and vice versa. This is
because BitmapFont contains a texture that's mutated, and sharing it
would also require sharing display lists between GL contexts, which
is not done (and overly complicated for this case anyway).
2017-01-11 03:33:10 +00:00
whitequark 33c9ffb5ca Gettext: automatically update all translations. 2017-01-11 03:08:58 +00:00
whitequark c12672be66 Internationalize platform-specific code. 2017-01-11 03:02:04 +00:00
whitequark aeebc3c395 Gettext: fill in empty msgstrs from msgid. 2017-01-11 01:23:59 +00:00
whitequark 984f74d271 Internationalize all messages without substitutions. 2017-01-07 06:47:40 +00:00
whitequark da7c74af2e GTK: only attempt to use libspnav on X11.
This makes SolveSpace run on Wayland.
2017-01-06 22:28:44 +00:00
whitequark 00dda08917 Internationalize the context menu. 2017-01-05 12:35:50 +00:00
whitequark 27ac3c7b5f Internationalize the toolbar. 2017-01-05 12:27:28 +00:00
whitequark 529e1bfd63 Internationalize the main menu. 2017-01-05 12:17:09 +00:00
Elvira Khabirova 4f04406121 Implement a gettext .po file parser. 2017-01-05 12:14:40 +00:00
whitequark 387c5c5144 Fix a tearing issue while dragging a new rect.
Before this commit, dragging a new rect would result in one
of the lines lagging behind, because it is drawn in the middle
of regeneration. After this commit, the rectangle stays rectangular.

For a reason I do not understand, this only fixes Win32; GTK
continues to exhibit the bug, whereas Cocoa has never exhibited it
but the render latency seems to have lowered slightly.
2017-01-03 01:47:29 +00:00
whitequark c385740087 Fix a dereference of an iterator one past the end. 2017-01-03 01:21:38 +00:00
whitequark 9f697af138 Win32: don't display dialogs for CRT assertions, like for aborts.
Among other annoyances this causes our CI builds to hang infinitely
without any indication in the console.
2017-01-03 01:11:16 +00:00
whitequark d8932772ef Don't crash when trying to load a non-existent vector/bitmap character. 2017-01-02 23:48:13 +00:00
whitequark 02ab358bd9 Allow the digit group separator, "_", in expressions. 2017-01-02 23:34:36 +00:00
whitequark daf3c7b070 GTK, Win32: always map keypad decimal separator to dot.
We only accept dot as a decimal separator, but the OS locale
may use a comma there.
2017-01-02 23:34:18 +00:00
whitequark e127b28a2d CMake: allow building the CLI without the GUI. 2017-01-02 22:13:20 +00:00
whitequark 6bb73a162c GTK: remove GlWidget, use standard Gtk::GLArea.
This removes a large number of hacks from the codebase, speeds up
the rendering, and removes tearing when dragging entities.
2017-01-02 16:21:05 +00:00
whitequark 7dbbd75969 Drop support for GTK 2.
It's a deprecated platform that has weird OpenGL-related bugs and
is incompatible with using EGL anyway. It was clear we're going
to drop it, the only question was when. Answer: now.
2017-01-02 16:20:12 +00:00
EvilSpirit 25631d4fb2 Choose entities to select in a way appropriate for the operation.
Before this commit, when an entity is clicked at or dragged, and it
shares a place with other entities, which of them is selected is
decided more or less at random. This is particularly annoying when
dragging.

After this commit, when clicking, an entity from the current group
is given preference, and when dragging, an entity from a request
is given preference. This allows e.g. dragging points of a sketch
even when an extrusion of that sketch is active.
2017-01-02 12:21:01 +00:00
Evil-Spirit d99a133982 Do ScheduleGenerateAll in MarkGroupDirty.
This generally simplifies code, and also fixes a bug where adding
a datum point would not regenerate the sketch.
2016-12-26 07:58:00 +00:00
EvilSpirit 9148d0cb91 Force DOF check every time a constraint is added.
Before this commit, it was possible to add some redundant constraints
(e.g. vertical, horizontal or midpoint) without failing the sketch,
because SolveBySubstitution() removed the redundant equations.
However, this could result in the solve failing later because
the system didn't converge, without any pointers as to the true
cause of the failure.
2016-12-21 19:40:33 +00:00
EvilSpirit 10251c6484 In OpenGl2Renderer, do not issue a draw call per DrawVectorText call.
This significantly improves performance with ANGLE.
2016-12-21 18:58:20 +00:00
EvilSpirit 727c0a97dc Draw projected lines for pt-line-distance constraints in 3d. 2016-12-21 18:43:42 +00:00
EvilSpirit 5763972ed8 Don't apply scale twice for text if both height and stroke are in mm. 2016-12-21 18:34:15 +00:00
whitequark d6e2ac8328 test: add tests for ExprParser, and fix two crashes. 2016-12-13 11:27:59 +00:00
whitequark 15571ef58e Fix swapped operands in boolean operators in expression parser. 2016-12-13 09:46:31 +00:00
whitequark 435682729e Unix: add FreeBSD compatibility for FindLocalResourceDir(). 2016-12-07 16:02:54 +00:00
whitequark 374d1b5e7f Win32: simplify.
Sanitization done by the removed code is already performed
by CommandLineToArgvW.
2016-12-06 17:32:07 +00:00
whitequark 6fcf1bbe79 Somewhat improve rendering of transparent meshes.
After this commit, any transparent triangles are drawn last, which
causes them to not clobber the depth buffer, and so if they overlap
some opaque triangles, then these opaque triangles will be visible.

There are still issues with overlapping transparent triangles,
and with transparent triangles overlapping outlines and entities.
2016-12-05 03:11:34 +00:00
whitequark 4a0b4fd8d3 Win32: unbreak solvespace-cli.
It was broken because of three bugs:
  * Uninitialized variables in RunCommand;
  * Trying to use (OEM-encoded) main() argc/argv arguments instead
    of GetCommandLineW();
  * Trying to pass relative paths directly into ssfopen.
2016-12-05 01:24:17 +00:00
whitequark 679a1f0ded Win32/MSVC: garbage-collect symbols even in debug builds.
This shrinks debug build binaries by ~1/3.
2016-12-04 20:42:53 +00:00
Evil-Spirit 3858cbe249 Fix a possible use-after-free in OpenGl2Batch.
IdList could reallocate its storage after we grab an interior
pointer, so just make a copy instead.
2016-12-03 08:22:12 +00:00
whitequark b975380493 Fix refactoring issue in gl2shader.h.
Oops, I accidentally changed the order of fields where I shouldn't
have; add a comment to avoid this in the future.
2016-12-02 11:13:31 +00:00
whitequark 47244c5e89 Implement a command-line interface.
This commit adds a basic command-line interface. This interface
allows rendering thumbnails and exporting data in batch mode.
2016-11-29 04:01:07 +00:00
EvilSpirit dbc567ed89 Reload linked files before upgrading legacy data.
Before this commit, if constraints with newly introduced params were
loaded from a file that linked other files, the upgrade code would
attempt to look up a non-existent entity.
2016-11-28 16:58:31 +00:00
whitequark 9301dec98d Use the same code for loading resources in all executables.
All of our executables need resources; e.g. the vector font is
a resource and it is necessary for generation. Before this commit,
the GUI executable loaded the resources in a nice way, and everything
else did it in a very ad-hoc, fragile way.

After this commit, all executables are placed in <build>/bin and
follow the same algorithm:
  * On Windows, resources are compiled and linked into every
    executable.
  * On Linux, resources are copied into <build>/res (which is
    tried first) and <prefix>/share/solvespace (which is tried
    second).
  * On macOS, resources are copied into <build>/res (which is
    tried first) and <build>/bin/solvespace.app/Contents/Resources
    (which is tried second).

In practice this means that we can add as many executables as we want
without duplicating lots of code. In addition, on macOS, we can
place supplementary executables into the bundle, and they can use
resources from the bundle transparently.
2016-11-28 06:18:42 +00:00
EvilSpirit 7681f6df74 Refactor insertion into BSP tree.
Before this commit, inserting into BSP tree could easily overflow
the stack because we allocate very large stack frames and, on
convex geometries (e.g. a sphere), the BSP tree degenerates into
a "BSP list", thus requiring one large stack frame per triangle.
This can be reproduced by exporting a 2d shaded view of sphere.

After this commit, the stack frames only contan a pointer to
a supplementary data structure, and moreover it only allocates
its fields on demand, conserving heap memory as well.

As a side effect, an arbitrary classifier limit of 50 vertices
is removed.
2016-11-27 21:04:31 +00:00
EvilSpirit d37f53e190 Improve performance of face picking.
This commit implements two improvements. First, it rewrites
SMesh::FirstIntersectionWith() to use an optimal (as currently known)
ray tracing algorithm. Second, it rejects triangles without
an associated face entity outright.
2016-11-27 15:14:10 +00:00
whitequark 7758844f96 Do not re-solve groups that converge but fail rank test.
This partially reverts commit 3a585ea.

We no longer need this because the VectorsParallel() is gone, and
there is no chance of pivoting wrong when solving.
2016-11-27 14:25:53 +00:00
EvilSpirit f5485cbf24 Rewrite equations generated for same-orientation constraints.
This has the same motivations and implementation as in 3d6d873.
2016-11-27 14:25:50 +00:00
EvilSpirit 78d141cf9c Rewrite equations generated for curve-line tangent constraints (in 3d).
This has the same motivations and implementation as in 3d6d873.
2016-11-27 14:25:44 +00:00
EvilSpirit 3d6d873906 Rewrite equations generated for parallel constraints (in 3d).
Before this commit, parallel constraints in 3d are fragile:
constraints that are geometrically fine can end up singular anyway
because VectorsParallel() pivots wrong but converges anyway.
After this commit, much like in cc07058, the constraints are written
in a different form: instead of trying to remove two degrees of
freedom out of three, all three are removed, and one added; namely,
the constraint introduces a free parameter, signed length ratio.
2016-11-27 13:43:48 +00:00
EvilSpirit cc07058e48 Rewrite equations generated for pt-on-line constraints.
Before this commit, pt-on-line constraints are buggy. To reproduce,
extrude a circle, then add a datum point and constrain it to the
axis of the circle, then move it. The cylinder will collapse.

To quote Jonathan:

> On investigation, I (a) confirm that the problem is
> the unconstrained extrusion depth going to zero, and (b) retract
> my earlier statement blaming extrude and other similar non-entity
> parameter treatment for this problem; you can easily reproduce it
> with a point in 3d constrained to lie on any line whose length
> is free.
>
> PT_ON_LINE is written using VectorsParallel, for no obvious reason.
> Rewriting that constraint to work on two projected distances (using
> any two basis vectors perpendicular to the line) should fix that
> problem, since replacing the "point on line in 3d" constraint with
> two "point on line in 2d" constraints works. That still has
> the hairy ball problem of choosing the basis vectors, which you
> can't do with a continuous function; you'd need Vector::Normal()
> or equivalent.
>
> You could write three equations and make the constraint itself
> introduce one new parameter for t. I don't know how well that
> would work numerically, but it would avoid the hairy ball problem,
> perhaps elegant at the cost of speed.

Indeed, this commit implements the latter solution: it introduces
an additional free parameter. The point being coincident with
the start of the line corresponds to the parameter being zero, and
point being coincident with the end corresponds to one).

In effect, instead of constraining two of three degrees of freedom
(for which the equations do not exist because of the hairy ball
theorem), it constrains three and adds one more.
2016-11-26 19:35:38 +00:00
EvilSpirit 8f93136d8a DXF: Import Z coordinate from DXF/DWG files. 2016-11-26 08:25:54 +00:00
whitequark 41365c5f9f DXF: Fix export of wireframe as 3D DXF.
Before this commit, polylines got flattened but all other entities
got exported with the proper Z coordinate. After this commit, all
entities are exported with proper Z coordinate.

Also, instead of exporting LWPOLYLINE (2d only), POLYLINE (2d/3d)
is exported; as a bonus it is more compatible with 3rd party
software, since it is older.
2016-11-26 08:18:14 +00:00
EvilSpirit aaab8a09d4 Fix a crash when extruding TTF text. 2016-11-21 17:35:24 +00:00
EvilSpirit 37defcbc33 Unbreak Camera::UnProjectPoint3.
The handedness was wrong, and this resulted in weird glitches
while drawing anything that depends on AlignToPixelGrid, like
normals.
2016-11-19 09:50:00 +00:00
EvilSpirit 01ae452507 Unbreak drawing of DEPTH_ONLY meshes via OpenGL 2 batch canvas. 2016-11-19 09:04:47 +00:00
Elvira Khabirova 61f248899a Refactor expression parsing.
The new expression parser is significantly simpler, more robust
and easier to understand; it also doesn't use longjmp or pollutes
Expr::Op anymore.
2016-11-19 09:02:14 +00:00
whitequark 8dc60f61c1 Fix Windows build with -DOPENGL=1.
This is mostly useful when testing the Windows functionality
on Linux, as wine is currently unable to compile the shaders
that ANGLE outputs.
2016-11-19 05:14:06 +00:00
whitequark d3f2ac7513 Remove most dependencies on config.h.
The only thing we need it anymore is the package version and platform
configuration, so only include it for that. As a result, less files
are rebuilt when the git commit changes and config.h is regenerated.
2016-11-19 01:00:11 +00:00
whitequark 369b0a378c Optimize toggling visibility of normals, points, edges, outlines.
Before this commit, any visibility toggle would cause a regeneration.
After this commit, toggling visibility of normals and points never
causes a regeneration, and toggling visibility of edges and outlines
only causes a regeneration when they weren't already generated.
2016-11-18 15:26:01 +00:00
EvilSpirit 683ac78ca2 Optimize FromTransformationOf for performing identity transformation.
FromTransformationOf is called with an identity rotation or
translation for translation and rotation groups, and for every
group that doesn't produce a solid model. This commit omits any
calculations from it when the relevant part of transformation
would change nothing.

This commit results in a ~10% improvement on testcase
woodworking/big-big-big-woodworking-asm, and splitting the condition
into three parts results in a ~5% improvement on testcase
stress/rotate_groups_0.
2016-11-18 14:51:47 +00:00
whitequark 9a0f2c3601 Fix detection of transparent meshes.
SSurface::TriangulateInto first populates the mesh with triangles
that have no color, and then paints them, which confused the code
that detects if a mesh is transparent into thinking that all of them
are; and that broke the "draw back faces in red" feature, since it
is disabled for transparent meshes.
2016-11-18 11:38:45 +00:00
whitequark 73844f7202 Draw triangle back faces like the front, unless we draw them in red.
The configuration option "draw back faces in red" aids debugging,
in that it allows to visually identify a non-watertight mesh.
When it is disabled, or when the mesh is transparent, we used to not
draw them at all before this commit; after, they are drawn just like
the front faces.

This has two consequences:
  1. Inner surfaces of non-watertight meshes are not see-through
     anymore. That used to be the behavior in version 2.0, and it
     was accidentally broken in 2.1.
  2. Transparent meshes look *much* better.
  3. Solids made from a union of a non-transparent and a transparent
     one look sensibly at all.

This commit also updates the OpenGL 1 renderer to let it render
such meshes correctly.
2016-11-18 11:38:45 +00:00
whitequark c8ff17f4a2 Add OpenGL 2 support on Windows using ANGLE.
This commit performs two main changes:
  * Alters the shaders to use only strictly conformant GLSL 2.0.
  * Alters the Windows UI to use ANGLE via GL ES 2.0 and EGL 1.4.

This commit also drops official support for Windows XP, since ANGLE
requires a non-XP toolset to build. It is still possible to build
SolveSpace for Windows XP using:

  cmake -T v120_xp -DOPENGL=1
2016-11-18 11:38:45 +00:00
whitequark 9db50ed077 Refactor the renderer frame flush functionality.
This commit does three things:
  * Recognizes that BeginFrame()/EndFrame() are badly named, since
    BeginFrame() sets up framebuffer, and EndFrame() flushes a frame,
    and they do not have to be called in pairs; and so renames them
    to NewFrame()/FlushFrame().
  * Reduces the amount of frame flushes in GraphicsWindow::Paint()
    to two, which is the minimum since we use two different cameras
    for geometry and UI;
  * Changes the FPS measurement code to only take into account
    the time spent rendering our main geometry, and not the UI
    rendering or window system interaction time.
2016-11-18 04:05:12 +00:00
whitequark 156fe73bee Allow using z-index in UiCanvas, and use it for tooltips.
Before this commit, tooltips in the text window are drawn under
the red "X" indicating a disabled button. After this commit, they
are moved on top of that.

This commit also alters the OpenGL renderers' SetCamera() method
to clear the depth buffer, as that would interfere with drawing
the UI; the toolbar would get occluded by geometry.
2016-11-18 04:05:12 +00:00
EvilSpirit 92773a5770 Implement BatchCanvas for GL2. 2016-11-18 04:05:12 +00:00
EvilSpirit 52557ee979 Add an interface for view-independent rendering.
To actually achieve improved performance with the OpenGL 2 renderer,
we have to cache geometry that doesn't change when the viewport does
(note that the rendered pixels can change quite dramatically because
we can reconfigure shaders; e.g. stippling can be drawn in screen
coordinates).

This commit adds a BatchCanvas interface that can be implemented
by renderers, and uses it for drawing entities such as lines and
points.
2016-11-18 04:04:32 +00:00
EvilSpirit 6d2c2aecff Implement an OpenGL 2 renderer.
There are two main reasons to desire an OpenGL 2 renderer:
 1. Compatibility. The compatibility profile, ironically, does not
    offer a lot of compatibility, and our OpenGL 1 renderer will not
    run on Android, iOS, or WebGL.
 2. Performance. The immediate mode does not scale, and in fact
    becomes very slow with only a moderate amount of lines on screen,
    and only a somewhat large amount of triangles.

This commit implements a basic OpenGL 2 renderer that uses only
features from the (OpenGL 3.2) core profile. It is not yet faster
than the OpenGL 1 renderer, primarily because it uses a lot of small
draw calls.

This commit uses OpenGL 2 on Linux and Mac OS X directly (i.e. links
to the GL symbols from version 2+); on Windows this is impossible
with the default drivers, so for now OpenGL 1 is still used there.
2016-11-18 04:04:29 +00:00
EvilSpirit f8824e1fb2 Reimplement drawing of the mesh wireframe.
OpenGL 2 and newer do not have the glPolygonMode(..., GL_LINES) API,
so produce the wireframe on our side. It's somewhat slow, and draws
every line three times, but it is cached when the OpenGL 2 renderer
is used, and this should do for a debugging feature.
2016-11-18 02:40:43 +00:00
whitequark e56630e71d Fix creation of workplane based on a workplane.
This fixes functionality introduced by commit 3c45158, which did not
take into account reference groups.
2016-11-17 15:51:19 +00:00
whitequark c97ba6b928 Optimize IdList::MaximumId() from O(n) to O(1).
This specific implementation seems to have lingered from the days
before IdList was stored sorted. This commit has resulted in a ~5%
improvement in Generate::DIRTY time for modelisation.slvs on a GCC 6
release build.
2016-11-17 14:14:56 +00:00
whitequark ea0a1b743a Fix uninitialized variable warnings.
gcc 6 displays these when compiling in release mode; all of these
warnings except the rankOk one were benign because there would have
been an error about the incomplete switch statement.

The rankOk warning highlighted a real problem: bailing early to
didnt_converge would have branched on an uninitialized variable.
2016-11-17 13:59:51 +00:00
whitequark 802d092b13 When exporting files, initially fill in the basename of the sketch.
This is a common and convenient behavior; the basename is
pre-selected, so exporting multiple views requires just one keystroke
to put the cursor after the basename.
2016-11-17 12:54:02 +00:00
whitequark e681ba3218 Rephrase the error message for sketch in workplane creation.
The old message was confusing because it seemingly talked about
a point that was orthogonal to coordinate axes.
2016-11-17 10:07:33 +00:00
Elvira Khabirova 3c451586d7 Add an ability to create a workplane with another workplane.
This is useful in case one wants to create a workplane based on
one of the reference ones, to be explicit, or to avoid fishing out
again the line segments used to create a workplane at an angle.
2016-11-17 10:04:38 +00:00
whitequark c7277521f3 Fix error message shown when exporting mesh with wrong extension. 2016-11-17 06:52:44 +00:00
Elvira Khabirova 489ae66e96 Fix crash when trying to import not .dxf or .dwg files 2016-11-17 06:52:12 +00:00
Evil-Spirit fdd08cbead Warn if exporting a non-watertight mesh.
If a generated mesh is non-watertight, and this is not noticed for
some reason (e.g. the markers are dismissed), and the mesh is
exported for further processing, it could cause problems down
the line.
2016-11-17 00:53:28 +00:00
Evil-Spirit 3b241392d4 Fix rendering of horizontal/vertical constraint labels.
This was a regression from 2.2 to 3.0, caused by the Canvas
transition.
2016-11-17 00:48:47 +00:00
whitequark 1ec36fc657 Add missing newline in OutputDebugStringA invocation.
Before this commit, every debug message was correctly printed
to stdout, but they were all concatenated onto a single line in
the Visual Studio "Output" pane.
2016-11-16 05:57:06 +00:00
whitequark 9673225648 Fix a crash when adding a symmetric constraint on a line.
This is the same problem as in ffd9c62.
2016-11-16 02:25:21 +00:00
EvilSpirit a0d7f1dadb Optimize GroupsInOrder.
GroupsInOrder is an extremely hot function, especially during object
picking: before this commit, it was easy to get second plus latencies
on picking, and after this commit picking is almost real-time.
2016-11-15 08:56:43 +00:00
EvilSpirit 13d4a1bb6a Fix memory leak in RemoveTagged. 2016-11-15 08:56:40 +00:00
EvilSpirit 7b9d730a23 Hide OpenGL implementation details.
Abstract the exact details of the OpenGL renderer in the render.h
header; this allows us to use GL-specific types in the renderer
class and functions without including OpenGL (and Windows, where
applicable) headers in every source file.
2016-11-14 20:30:46 +00:00
whitequark afecbccb0f OS X: fix another out-of-bounds TW.META access.
See also f5a37ae.
2016-11-05 17:05:17 +00:00
whitequark 74cb1f589c Add two more points to the TTF text request.
These points can be used for constraining the width of the text
(or to the width of the text).

The main parts of the commit are:
  * TtfFont is restructured to be able to return the aspect ratio
    for a given string.
  * This aspect ratio is written to the savefile, such that even if
    the font is missing, the sketch would still be solved correctly.
  * The two additional points are constrained via perpendicularly
    to the two main points (which form a v vector).

The compatibility features are as follows:
  * When the font is missing in old files, 1:1 aspect ratio is used,
    which works for the replacement symbol anyhow.
  * When the two additional points are missing in old files, their
    would-be positions are calculated and they are moved there,
    avoiding 'jumping' of underconstrained sketches.
2016-11-02 09:22:18 +00:00
whitequark 23feb4cf8f TTF: use metrics of 'A' to determine cap height.
SolveSpace 2.0 used the height of 'A' (i.e. cap height) to determine
the reference height.
SolveSpace 2.1 completely broke that during transition to Freetype,
and used something more or less random, by using FT_Set_Char_Size
with units_per_EM.
SolveSpace 2.2 attempted to fix that, but also used something more
or less random, by using FT_Request_Size with "unit" values.

Turns out that Freetype actually doesn't have a concept of cap height
at all. It is possible to extract it from the TT_OS2 table that is
present in some TrueType fonts, but it is not present in Microsoft
fonts (the msttcorefonts ones), and for those Linux fonts in which
it is present it doesn't appear very reliable.

So instead, use the height of 'A' instead, like version 2.0 did.
This has the advantage that it is quite bulletproof, and also matches
exactly what the old files are measured against.

One downside is that fonts without an 'A' glyph would not render.
We can deal with that when it becomes a problem.
2016-11-02 08:59:33 +00:00
whitequark 7bd6adefd8 TTF: actually use CID as GID when CID-to-GID mapping is absent. 2016-11-02 08:47:02 +00:00
whitequark b8bec35a0c TTF: only call FT_Request_Size once after loading. 2016-11-02 08:46:36 +00:00
EvilSpirit 505f503cc3 Don't consider workplane origin point for bounding box calculation. 2016-11-02 02:43:45 +00:00
EvilSpirit 600c39db91 Don't consider arc center point for bounding box calculation. 2016-11-02 02:40:26 +00:00
whitequark f619a4b85e GTK: add a no-op glXSwapBuffers call for apitrace.
Apitrace uses swapping buffers to determine frame boundaries; before
this commit, everything solvespace renders gets put into a single
frame. Since we don't use double-buffered rendering, the call does
nothing (and is legal to perform), but apitrace output becomes
readable.
2016-10-22 07:47:13 +00:00
whitequark 345c982b3b OS X: don't crash in GetSaveFile() if default extension is invalid. 2016-10-21 20:18:45 +04:00
whitequark 90987d3ee4 Fix a rendering bug introduced in 9f97e9a. 2016-10-14 04:15:20 +00:00
EvilSpirit 3a585ea7c2 Try to re-solve groups that fail rank test.
Sometimes, after a large change in a sketch, constraints that are
geometrically fine may still cause the rank test to fail. One way
this can happen is VectorsParallel() pivoting wrong due to the big
move, converging anyways but ending up singular. It would then
re-pivot correctly on the new solution when you re-solve, making
this a transient error. This is visible when dragging the arm in
the jansen-asm.slvs example.

After this commit, if the rank test fails, equations are regenerated
the Jacobian is rewritten, and the rank test is retried, which
prevents these transient errors from interfering with dragging.

The problem described above was invisible before c011444, as rank
test was only performed before solving.
2016-10-14 00:27:38 +00:00
Evil-Spirit b2092eaea9 Write params if system is solved as REDUNDANT_OKAY.
A system solved as REDUNDANT_OKAY is still solved correctly,
even if the UI would consider this an error, in case that
g->allowRedundant==false. So there's no reason to discard this
solution; we might find it useful if a system loses a degree of
freedom while dragging, or to avoid regeneration after redundant
constraints are allowed.

This commit also reverts commit 3ff236c, as that is not necessary
anymore.
2016-10-14 00:10:41 +00:00
EvilSpirit b37aba00e2 Preserve stipple phase across separate piecewise linear segments.
This significantly increases visual clarity, especially for curves
with a low chord tolerance value.
2016-10-13 23:15:35 +00:00
whitequark 47288e9a4c Stitch outlines before display to preserve phase of stippling.
Before this commit, the outlines are generated in an arbitrary order
from the kd-tree. This worked just fine for continuous lines, but
for stippling, especially on curves, this meant that most of
the piecewise linear edges would have the stippling phase restart
from zero, leading to a very poor appearance.
2016-10-13 22:05:32 +00:00
EvilSpirit 186911a51a Factor out PolylineBuilder from DXF export code. 2016-10-13 22:05:29 +00:00
EvilSpirit d2c250324b Fix many rendering bugs introduced in df83ee4 and 9f97e9a. 2016-10-13 21:30:27 +00:00
whitequark ea52fcbce1 Remove unnecessary GenerateAll/ZoomToFit calls in AfterNewFile.
These were useful before because chord tolerance depended on the zoom
level; and so the first generation produced a crude mesh used to
set the zoom level, and the second actually did useful work.
Chord tolerance is now independent of the zoom level, so this code
is no longer useful.
2016-10-12 23:34:02 +00:00
whitequark 62f5f690c1 Print a debug message for generations that are taking a long time. 2016-10-12 23:15:24 +00:00
EvilSpirit 2ccf5954d4 Allow creating n-dimensional arrays with translate and rotate groups.
Before this commit, a translate group based on another translate
group would always use the "union" boolean operation, which does not
work at all if one wants an array with a difference operation, and
results in degraded performance if one wants an array with
an assemble operation.
2016-10-12 22:02:38 +00:00
EvilSpirit 6658b1fa2b Allow combining extrude, lathe, translate and rotate group as assemblies.
This significantly improves performance e.g. in case of a sketch
containing a multitude of wooden panels, as the meshes can be
merely transformed instead of being joined.
2016-10-12 22:02:38 +00:00
whitequark 5462fc6b3c OS X: map the backspace key to the "Delete" function.
Apple hardware does not have a discrete Delete key, so Backspace
is used for deleting stuff instead.
2016-10-12 23:42:41 +04:00
whitequark 90f10ccfa6 OS X: set scroller knob style to light.
On newer OS X versions the scrollbar is overlaid on the window
contents, so a black know is invisible.
2016-10-12 23:24:17 +04:00
whitequark b5f5e05336 OS X: don't remap OK in message boxes to Escape.
The platform convention is to use Return.
2016-10-12 18:56:31 +00:00
whitequark b0363802d8 OS X: revert "sort out window visibility and focus."
This reverts commit 1dba594949.

Turns out the old behavior was more appropriate for OS X.
2016-10-12 18:56:31 +00:00
whitequark 291e16e549 Fix a few compiler warnings. 2016-10-12 14:36:52 +00:00
EvilSpirit 363f5c1ab8 Fix BitmapFont to not lose texture updates.
Texture could also be updated by GetWidth(), which calls GetGlyph()
internally, and then the next LocateGlyph() call would return false.
2016-10-11 23:45:19 +00:00
whitequark af226b2437 Fix rendering of reference axes in bottom left corner. 2016-10-11 23:32:21 +00:00
EvilSpirit 9f97e9aad4 Allow selecting unit (px/mm) in Canvas::Stroke.
By directly specifying the desired end result to the renderer, we
can avoid regeneration of geometry.
2016-10-11 23:32:21 +00:00
whitequark a5c7fc6ad9 Disable closed contour check in the test harness.
The check was actually half-broken from the beginning and
until df83ee4; the thick red line was rendered properly but
the error text was rendered with width 0, which by chance worked
on some GL implementations. That commit has fixed the underlying
bug but left the text line width at 0 to avoid test breakage.

This commit fixes the bug, turns off the check completely, and
updates the tests to account for breakage.
2016-10-11 23:32:12 +00:00
EvilSpirit df83ee4c8f Factor out Style::Stroke. 2016-10-11 23:32:05 +00:00
Evil-Spirit 1108a6f37d Use Canvas::Stroke, not Canvas::Fill, for drawing a point.
Our points are more like fat lines than actual quads, in that they
are scale-invariant.
2016-10-11 23:32:05 +00:00
whitequark e80a3a0a71 Fix a buffer overrun in ssprintf. 2016-10-11 23:32:05 +00:00
Drew Gates ffa104602c Fix spelling error. 2016-10-11 16:47:23 +00:00
EvilSpirit f4e85127d6 Wavefront OBJ: export mesh color as well. 2016-10-11 14:54:19 +00:00
whitequark aa958504af GTK: use 3DConnexion button 0 instead of SI_APP_FIT_BUTTON.
The libspnav library doesn't even define SI_APP_FIT_BUTTON, which
appears to be Windows-specific functionality, perhaps a physical
button remapped with some logic. Just use 0 instead, since that
seems always safe.
2016-10-11 13:56:41 +00:00
whitequark b10e621fce Rephrase error messages that say "select a workplane".
This is confusing, as merely selecting one (and not activating it)
is not enough to satisfy any of the conditions leading to these
errors.
2016-10-11 13:46:05 +00:00
EvilSpirit 456c987218 Use transparent white fill color for drawing pixmaps, not black.
Textures can interact with selected color. This commit makes it
a no-op.
2016-10-11 10:53:57 +00:00
whitequark 66ed417d45 Fix a handle leak in TtfFontList::PlotString. 2016-10-10 21:16:22 +00:00
whitequark 476860acbb Normalize the string returned by Extension() to lowercase.
This would otherwise break code that branches on the extension,
such as that after 06a188cc.
2016-10-10 20:34:11 +00:00
whitequark 2371068d01 Don't regenerate the entire sketch in AddRequest().
This is unnecessary and leads to huge slowdowns on large sketches.
E.g. this speeds up import of a certain large DXF from ~60s to ~3s.
2016-10-10 20:33:02 +00:00
whitequark 0e66eafe5a OS X: correctly parse output of otool -D.
In the past this relied on otool -XD not printing the name of
the library itself, only the install name, but that doesn't work
anymore as of 10.12.
2016-10-10 23:31:15 +04:00
whitequark 3ff236c494 Mark group dirty when clicking "allow redundant constraints" link.
Otherwise, the now-valid constraint will not become satisfied.
2016-10-10 17:44:01 +00:00
whitequark 9bcba4b92c Fix incorrect rendering of XYZ axes in the bottom left corner. 2016-10-10 13:31:29 +00:00
whitequark a8e723381c Replace convenience #defines with const auto references.
These are nicer as they are scoped, and so it's clear where they
can be used.
2016-10-10 12:34:10 +00:00
whitequark f5a37ae2fd OS X: fix out-of-bounds TW.META access.
For some reason OS X can post pointer events far outside the window
rect, so be defensive here.
2016-10-10 12:25:10 +00:00
whitequark 21a4305ee1 Add "Zoom to Fit" to context menu. 2016-10-09 22:26:36 +00:00
whitequark 2f64f18095 Add "Select All" to context menu for no selection. 2016-10-09 22:26:25 +00:00
whitequark 2f4c6a6b0e Add "Toggle Construction" to context menu. 2016-10-09 22:13:01 +00:00
whitequark da2d035200 Remove exact numeric values from ContextCommand.
They carry no meaning, except for FIRST_STYLE.
2016-10-09 22:08:22 +00:00
whitequark c43a1988ae Win32: add proper Unicode support to message boxes.
Before this commit, for every non-ASCII character, a replacement
character was also printed.
2016-10-09 21:54:21 +00:00
whitequark fbd89a7e30 Update 819c4c5 for Wine compatibility.
For some reason glGetString(GL_VERSION) can return NULL at least
once even after we've started rendering.
2016-10-09 21:27:30 +00:00
whitequark 819c4c5742 GL1: work around lack of NPOT textures in Windows OpenGL renderer.
OpenGL 1.1 permits implementations to reject non-power-of-2 sized
textures. In practice this only affects the default Windows OpenGL
implementation, i.e. with no vendor drivers installed. This is still
important in case the application runs in a VM.
2016-10-09 20:24:49 +00:00
whitequark d12bf047b4 Update 58db06d8 to not even try to use std::fstream with Unicode paths.
Unfortunately there is no portable way to open an Unicode path with
std::fstream. On *nix, it is enough to call the const char*
constructor. On MSVC, it is enough to call a nonstandard
const wchar_t* constructor. However, on MinGW, there is no way at all
to construct an std::fstream with a wide path, not even using
undocumented APIs. (There used to be a const wchar_t* overload added
back in libstdc++ 4.7, but it got removed for a reason that I was not
able to find out.)
2016-10-09 20:00:02 +00:00
whitequark fb87431ba5 Fix a numeric conversion warning. 2016-10-09 15:26:05 +00:00
whitequark 58db06d845 DXF: update to use Unicode-aware file open routines on Windows. 2016-10-09 15:19:36 +00:00
whitequark fd54e5ac27 Make translate/rotate groups inherit the "suppress solid model" option. 2016-10-09 13:27:43 +00:00
whitequark 06a188cc62 GTK: show files with uppercase extensions in file open dialog.
The Windows dialog does that automatically, but the GTK one doesn't.
So this is useful for Windows interop.
2016-10-09 12:39:48 +00:00
whitequark e7edc39b34 Alias the "=" key to "+" key. 2016-10-09 10:57:25 +00:00
whitequark ffd9c6241a Fix a crash when adding a symmetric constraint on two points.
The crash was introduced in e2e91672; I have not noticed that some
of the code relies on past-the-size entities in GW.GS being empty.
2016-08-28 16:50:36 +00:00
whitequark b9d375652c Recognize .ngc as a valid G-Code export extension. 2016-08-25 02:57:29 +00:00
whitequark a1e18ae4a6 GlOffscreen: create color/depth renderbuffers separately.
This fixes a strange problem where GTK 2 (but not GTK 3) with NVidia
drivers would not have a depth buffer, but only during exporting
PNGs, despite the fact that normal rendering path and PNG rendering
path come through the same offscreen rendering code.
2016-08-21 19:58:45 +00:00
whitequark 991909d794 Show pt-ln distance projected onto workplane when one is active.
This avoids a pitfall where a point and a line are selected that are
not in the current workplane, but since the view is parallel to
the workplane, that's not visible, and incorrect measurement results.
2016-08-14 01:49:33 +00:00
whitequark f998293760 Allow displaying outlines without any other edges.
As usual, what's displayed is what's exported.
2016-08-14 01:00:10 +00:00
whitequark 4c30c09792 Correctly draw vector text for constraints free in 3d. 2016-08-13 10:51:14 +00:00
whitequark efd358d734 Unbreak PNG export.
Before this commit, on Win32 the toolbar was visible, and
the framebuffer was flipped, whereas on other platforms just a black
image was exported.
2016-08-13 09:55:37 +00:00
whitequark 6e860fb148 Make "Show/hide hidden lines" a tri-state button instead.
The states are:
  * Draw all lines (on top of shaded mesh).
  * Draw occluded (by shaded mesh) lines as stippled.
  * Do not draw occluded (by shaded mesh) lines.

As usual, the export output follows the screen output.
2016-08-13 09:44:08 +00:00
whitequark 8ce2922902 Refactor text window buttons to allow for more custom behavior. 2016-08-13 07:30:17 +00:00
whitequark e2e9167210 Get rid of the MAX_SELECTED restriction in GroupSelection(). 2016-08-13 05:20:43 +00:00
EvilSpirit e381c70842 DXF export: always declare layers before using them.
Before this commit, the #s001-active-grp layer was not declared,
and this broke some external software, such as Inkscape.
See https://bugs.launchpad.net/inkscape/+bug/1472429 for details.
2016-08-13 04:27:41 +00:00
whitequark 35a20ae260 GTK: fix an uninitialized variable. 2016-08-13 03:39:59 +00:00
EvilSpirit 065a0a8b00 Forcibly show the current group once we start a drawing operation. 2016-08-13 03:37:27 +00:00
EvilSpirit b2ab15c2e1 Do not clear selection during operations that don't need it.
Specifically, during "Align View onto Workplane" when we are locked
in workplane (in which case it always aligns onto that workplane).
2016-08-13 03:30:27 +00:00
whitequark 8bf55b3c62 Fix multiple memory leaks found with LeakSanitizer. 2016-08-07 19:33:42 +00:00
whitequark e462387fca Add tests to cover 95.3% of constrainteq.cpp branches. 2016-08-07 17:33:27 +00:00
whitequark 4b4944264b Align constraint lines to pixel grid.
This ensures that constraints always look crisp, no matter the camera
position.
2016-08-07 17:33:27 +00:00
whitequark f2633e4a57 Also consider constraints when zooming to fit.
Before this commit, when working on convex sketches, zooming to fit
was guaranteed to clip most or even all constraints, making it quite
useless.
2016-08-01 14:03:16 +00:00
whitequark 8e7d2eaa84 Implement "view → set to full scale" text window command. 2016-08-01 14:03:16 +00:00
whitequark ff23a4a471 Implement Analyze → Measure Perimeter. 2016-08-01 14:02:39 +00:00
whitequark 9a1ceaa5c8 Unbreak TTF metrics.
In 2.0, the distance between the points in the TTF request specified
cap height. In 2.1, that was accidentally changed to some arbitrary
value near cap height instead, due to a 72pt factor mess-up.
This commit restores the old behavior.
2016-08-01 12:31:00 +00:00
whitequark fd9ee94437 Add basic test coverage for curve sketching tools. 2016-08-01 11:31:38 +00:00
whitequark 4f49a8a9d4 Eliminate several memory leaks.
All leaks found with valgrind while running the test suite.
This commit also clears the Cairo cache to improve SNR of Valgrind
output.
2016-08-01 05:39:18 +00:00
whitequark 42d3ec9917 CMake: finish Clang sanitizer support.
This makes ENABLE_SANITIZERS a proper cached variable, removes some
spurious failures and configures asan/ubsan to die on an error.
2016-08-01 05:39:18 +00:00
whitequark 2fdbabc13c Add statement/condition coverage measurement for the test suite.
We're using gcov+lcov, since these tools appear to be the only
usable ones that use the SC/CC metric; and measuring just the line
coverage would be practically criminal negligence.

gcov only works with GCC and Clang, and MSVC's own coverage
measurement tools are not up to the task; so MSVC is out of luck.
2016-08-01 02:19:06 +00:00
whitequark 5e63d8301e Add a simple harness for automated, headless testing.
This commit alters the build system substantially; it adds another
platform, `headless`, that provides stubs in place of all GUI
functions, and provides a library `solvespace_headless` alongside
the main executable. To cut down build times, only the few files
that have #if defined(HEADLESS) are built twice for the executable
and the library; the rest is grouped into a new `solvespace_cad`
library. It is not usable on its own and just serves for grouping.

This commit also gates the tests behind a -DENABLE_TESTS=ON CMake
option, ON by default (but suggested as OFF in the README so that
people don't ever have to install cairo to build the executable.)

The tests introduced in this commit are (so far) rudimentary,
although functional, and they serve as a stepping point towards
introducing coverage analysis.
2016-08-01 00:48:37 +00:00
whitequark 977a0b8e6d Replace the last use of exceptions (in Expr) with setjmp/longjmp.
Without -fno-exceptions, the branch coverage information is
practically useless, as every call becomes a branch.

The functionality of Expr is retained as-is, although SjLj error
handling is a maintenance nightmare. However, the entire parser
probably should be eventually replaced, so for now it is not
a great concern.
2016-08-01 00:48:37 +00:00
whitequark 65e2cccde0 Add a Cairo rendering backend.
This backend will be used for reproducible offscreen rendering
in integration tests.
2016-08-01 00:48:37 +00:00