Commit Graph

24 Commits (d973405c8c71ab807622c809b88e745fda8ddffb)

Author SHA1 Message Date
whitequark 1442ee5ec3 Refactor InitPlatform.
This commit performs three related cleanups:
  * The slvs library no longer uses explicit platform initialization
    (which drags in the side effects of InitPlatform that are not
    desirable in a library). Instead, it just ensures that it has
    the temporary heap, which is what it was callingInitPlatform for.
  * InitPlatform is simplified and moved to platform.cpp, next to
    other path related functions.
  * InitPlatform is renamed to InitCli and is called from InitGui
    implementations. GUI toolkits sometimes have options they use
    internally (that's the case for for GTK and Cocoa at least),
    and we shouldn't try to parse those as a file to open.
2020-05-10 08:29:25 +00:00
nabijaczleweli aeaece53e1 Accept both slashes in test harness on Win32
This fixes tests when __FILE__ produces output separated with / instead
of \, like on my Windows+MSYS2+GCC config

Fixes #563
2020-03-23 01:07:40 +00:00
whitequark 65d0bdffdb Split Canvas::FinishFrame out of Canvas::FlushFrame.
When drawing the graphics window, we flush it twice: once to draw
the geometry, and another time to draw the UI overlay (toolbar,
selection marquee, and FPS counter). Calling glFinish() each time
is (on most platforms) just pointlessly slow, but on macOS Catalina,
without offscreen rendering, it causes the toolbar to flicker.

Instead of calling glFinish() twice per frame in that case, call
glFlush() twice and then glFinish() once we really are done.
2019-11-23 13:35:16 +00:00
whitequark b3f739f2c4 Improve layout for reference axes with very vertically small windows. 2019-07-12 11:23:28 +00:00
Ryan Pavlik c18deb2d81 test harness: Identify build host system in CMake to use for path separator.
Before, would guess incorrectly if the CMake source tree was specified
via a relative path (since then the path would not start with /).
Now, directly asks CMake if building on Windows or something else,
and sets a define.
2019-05-20 16:47:38 +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 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 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 7e2b1b1d8d Add a test for the link group. 2017-03-10 21:19:02 +00:00
whitequark d6e2ac8328 test: add tests for ExprParser, and fix two crashes. 2016-12-13 11:27:59 +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 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
whitequark 0e72c606ab tests: fix bugs and inefficiencies in PrepareSavefile. 2016-11-02 03:43:29 +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 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
whitequark 7787923d05 MinGW: unbreak the test harness.
_set_abort_behavior() is an MSVCRT function, not a Win32 one,
and it is not available in MinGW builds.
2016-10-09 20:03:50 +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 e462387fca Add tests to cover 95.3% of constrainteq.cpp branches. 2016-08-07 17:33:27 +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 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