Compare commits

..

386 Commits
v2.3 ... master

Author SHA1 Message Date
whitequark
911c67b2d8 Fix benchmark harness after e2e74762. 2017-03-17 15:24:32 +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
9ab37c2ebf README: update zlib package version. 2017-03-07 11:54:15 +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
e6ed36f739 Add solvespace-debugtool, to expose some internals via CLI. 2017-02-12 14:21:58 +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
whitequark
6cf5409cd7 Update testsuite after ced4244. 2017-02-06 14:50:21 +00:00
whitequark
cd26256675 Travis: run tests again.
Tests used to be included in `make all`, but not since 8d0e226.
2017-02-06 14:49:13 +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
80c7296316 Win32: do not redefine VOS_NT_WINDOWS32/VFT_APP. 2017-02-06 11:23:06 +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
51b88280e5 README: suggest release builds, as these are much faster.
Also, remove -DENABLE_TESTS=OFF, since tests are no longer run
when building the default target.
2017-02-02 17:45:55 +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
whitequark
4aae22929a Add *.slvs to gitignore.
I've committed some random sketches one time too many...
2017-01-17 11:29:18 +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
8d0e226722 CMake: do not depend on testsuite in the default target. 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
04e86d9b36 Travis: revert the hack for transient build failures. 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
0eb33decd1 Fix typo: ua-UA → uk-UA. 2017-01-07 16:37:36 +00:00
whitequark
984f74d271 Internationalize all messages without substitutions. 2017-01-07 06:47:40 +00:00
AppSoft4
4fda1e4361 Add ua-UA translation. 2017-01-07 03:28:10 +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
934f33f4c0 Update zlib, libpng and Freetype submodules to latest versions.
In particular this fixes an issue with the Freetype build system
where re-running CMake would rebuild it from scratch every time.
2017-01-03 01:28:07 +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
6b8f937894 Win32: fix compatibility with MSVC x64 builds. 2017-01-03 00:52:24 +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
f1d4c4a50c README: point to CONTRIBUTING where relevant. 2017-01-02 22:40:36 +00:00
whitequark
2eb934243b README: update Windows version requirement. 2017-01-02 22:24:27 +00:00
whitequark
e127b28a2d CMake: allow building the CLI without the GUI. 2017-01-02 22:13:20 +00:00
whitequark
9253e5f229 GTK: update gtkmm dependency.
Pre-3.22 gtkmm doesn't have Gtk::GLArea::set_use_es(), which we
require.
2017-01-02 20:46:18 +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
626ffeab1f github: add an ISSUE_TEMPLATE file. 2016-12-13 11:44:31 +00:00
whitequark
d6e2ac8328 test: add tests for ExprParser, and fix two crashes. 2016-12-13 11:27:59 +00:00
whitequark
11adaf20b7 README: update Linux dependencies. 2016-12-13 09:57:56 +00:00
whitequark
15571ef58e Fix swapped operands in boolean operators in expression parser. 2016-12-13 09:46:31 +00:00
whitequark
3dd2fc0093 Add CONTRIBUTING.md. 2016-12-10 06:10:23 +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
whitequark
d1ddc6ee07 Win32: fix inclusion of manifest, to get back visual styles.
This commit fixes four issues:
  * Instead of WRITE,APPEND, resource.rc was generated using
    WRITE,WRITE, which erased #include <windows.h> and prevented
    any symbolic definitions (like RT_MANIFEST) from working.
    This silently included them using a string type instead,
    which did nothing.
  * WINVER is bumped to Win7, since that's what we target now.
  * Index of RT_MANIFEST is changed to 2, since that's what
    it has to be when ISOLATION_AWARE_ENABLED is defined.
  * Platform is not restricted to X86 in manifest, since there
    is no point in doing so.
2016-12-04 20:33:46 +00:00
whitequark
6989a3d068 CMake: Cairo is required for CLI, not just tests. 2016-12-04 19:05:51 +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
whitequark
43629549c1 Update ANGLE. 2016-11-19 09:50:41 +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
0ae0343fc7 Add a simple benchmarking harness. 2016-11-18 13:55:24 +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
f5e955a015 README: add gdb and lldb debugging instructions. 2016-11-14 02:35:04 +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
d151eb56fc CMake: reject in-tree builds.
We do not support clobbering the source tree with build products,
nor recommend this in any documentation, and this already leads to
weird bugs with the resource system. Show an explicit error in this
case to avoid confusion.
2016-11-03 07:25:57 +00:00
whitequark
b846401c73 Update CHANGELOG. 2016-11-02 10:18:07 +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
whitequark
0e72c606ab tests: fix bugs and inefficiencies in PrepareSavefile. 2016-11-02 03:43:29 +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
cdd6174cfa tests: remove CHECK_RENDER from migrate_from_v* tests.
This is a bit slow, but more importantly creates a race condition
where e.g. a failing "normal" test will be overwritten by
a succeeding "normal_migrate_from_v20".

This shouldn't ever be a problem since saving dumps the entire
internal state, or is supposed to, at least.
2016-11-02 02:40:17 +00:00
whitequark
071a7acc9d tests: bulk add of migrate_from_v22 tests. 2016-11-02 02:33:31 +00:00
whitequark
592bea8109 Travis: add IRC notifications. 2016-10-22 07:55:42 +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
whitequark
8e329ca2b3 Fix a memory leak in test/group/translate_asy/normal_inters. 2016-10-13 23:43:36 +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
e9725bd350 Update CHANGELOG. 2016-10-10 23:43:09 +00:00
whitequark
9febc572a3 Travis: install libstdc++ 5.
The existing libstdc++ on Travis is 4.8, which has broken <regex>
and that breaks our test harness.
2016-10-10 22:48:02 +00:00
whitequark
93da88369f Debian: remove in-tree packaging.
The package is now maintained by the Debian Science team at:
https://anonscm.debian.org/git/debian-science/packages/solvespace.git
2016-10-10 22:07:32 +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
4537444db5 Travis: add a few more retries to OS X build script.
Their infra seems to be deteriorating with time, or something.
Every other build fails lately.
2016-10-09 22:32:58 +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
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
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
cd5b5b2d7c Travis: update brew installation instructions.
The `brew upgrade` is no longer needed as Travis updated the
versions in their image.
2016-10-09 11:09:21 +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
whitequark
0bf6167e16 Update CHANGELOG. 2016-08-13 05:08:34 +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
cf9c3310fc Update libdxfrw. 2016-08-13 02:19:31 +00:00
whitequark
8bf55b3c62 Fix multiple memory leaks found with LeakSanitizer. 2016-08-07 19:33:42 +00:00
whitequark
fbe2705ebe CMake: disable unsigned overflow sanitizer check.
This seems too aggressive for us; it breaks the hash function and
I would prefer to not add tool-specific exclusions in the code.
2016-08-07 19:27:58 +00:00
whitequark
415a6d36ff Travis: build with clang, so that we can use its sanitizers.
This also disables coverage, because llvm-cov 3.9 on Travis is
incompatible with genhtml 1.10. Sigh.
2016-08-07 19:22:04 +00:00
whitequark
068ed2816a CMake: fix typo. 2016-08-07 17:33:27 +00:00
whitequark
f8b6c33290 CMake: use pkg-config directories in test/.
This is required for successful linking on FreeBSD.
2016-08-07 17:33:27 +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
ba1cd83d9e README: clarify Windows instructions. 2016-08-07 17:19:47 +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
a2a50927e9 CMake: make code coverage work with Clang.
Clang uses a slightly different .gcno/.gcda format than GCC, and
it is necessary to point lcov to `llvm-cov gcov` instead of `gcov`.
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
whitequark
6963c7e25b Add Cairo (and, transitively, Pixman) dependencies. 2016-08-01 00:48:37 +00:00
whitequark
8960ee365a Add a new renderer that prepares geometry for 2d backends.
SurfaceRenderer is a new renderer implementing the Canvas interface
running entirely on the CPU; it projects strokes and triangles
in the exact same way as OpenGL would, and it can be used for
rendering into raster or vector 2d surfaces.
2016-08-01 00:48:37 +00:00
whitequark
8af3a933cf Implement SPolygon::TriangulateInto. 2016-08-01 00:48:37 +00:00
whitequark
7f0083aa1d CMake: correctly use if(STREQUAL).
If an operand is a string, it should be quoted to prevent expansion.
This doesn't matter with "GNU", but does with "MSVC" (which expands
to "YES").
2016-08-01 00:48:37 +00:00
whitequark
14cf0e09df Win32: emit dbp() output to stderr as well in Debug builds. 2016-08-01 00:48:37 +00:00
whitequark
c83421a2b5 Win32: unbreak window icon. 2016-08-01 00:46:56 +00:00
whitequark
d0e32849b2 Fix a typo in Group::DrawFilledPaths. 2016-07-31 11:58:54 +00:00
whitequark
50b2b8adfd Unbreak background image display.
Before this commit, background image was drawn with alpha=0, which
caused it to be not drawn at all. This was an error introduced
during rebasing.
2016-07-31 11:57:46 +00:00
whitequark
613aa8c579 Reimplement 6846010 correctly.
The bug was actually not in ReadPng*, but in WritePng.
2016-07-31 11:57:17 +00:00
whitequark
803665404e Add support for BGR formats to Pixmap, and RGB conversion.
The Cairo image surface backend uses the BGR format for "RGB24"
for some reason, and we need to handle that.
2016-07-25 11:00:07 +00:00
whitequark
6d5d88f01e Fix off-by-one bug in Pixmap::WritePng. 2016-07-25 10:58:25 +00:00
whitequark
6846010416 Fix a flip bug in ReadPngIntoPixmap.
The only user of that was the background image, and it was flipped
again when it was rendered, so the two bugs masked out each other.
This adds a `bool flip` to ReadPng and FromPng, since that's cheap
to do when writing the PNG file, expensive on the pixel arrays,
and sometimes inconvenient in OpenGL due to offsets.
2016-07-25 10:58:03 +00:00
whitequark
0c90cd799d Align normals and workplanes to pixel grid.
They look much sharper and nicer this way, and more similar to 2.0.
2016-07-25 10:56:36 +00:00
whitequark
bcd8c3e790 CMake: do not leak solvespace-specific compiler flags.
Before this commit, our warning flags and definitions were leaking
into the vendored dependencies.
2016-07-25 04:22:03 +00:00
whitequark
6607a48357 CMake: refactor inclusion of external libraries.
This commit makes common external packages always be included through
find_package to eliminate differences in variables set, wraps
find_package for vendored libraries on Windows to factor out common
code, and removes miscellaneous useless code elsewhere in dependency
handling.

This also fixes a problem where pkg-config would pick up `build`
libraries instead of `host` when cross-compiling.
2016-07-25 04:22:02 +00:00
whitequark
7265121b24 Refactor GlOffscreen; remove the GLEW dependency.
It was never really needed, since both Linux and OS X, where
GlOffscreen is used, guarantee that the API we need is present,
on all OS versions we're interested in.

Also, reorganize GlOffscreen consistently with the rest of our
codebase, and don't use RAII for OpenGL resource management because
of its requirement for an active context.
2016-07-25 04:21:55 +00:00
whitequark
216091a366 README: clarify binary package situation.
We now build and distribute Windows executables for every release,
so mention that. Conversely, the Debian packages are basically
unusable, so drop them for now.
2016-07-25 04:21:54 +00:00
EvilSpirit
7f411d1593 Unify displayEdges and displayOutlines.
This has the following benefits:
  * Less geometry to generate; we can do both in one pass;
  * Less geometry to draw;
  * Eliminate overdraw of outlines on top of emphasized edges;
  * In future, being able to seamlessly stitch stippled lines.

The contour edges are now also drawn before emphasized edges;
this makes intersections of contour and emphasized edges look better
as the thinner emphasized edge doesn't clobber the depth buffer.
2016-07-23 22:41:16 +00:00
whitequark
e7c8c1c8f2 Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
  * It is now possible to port SolveSpace to a later version of
    OpenGL, such as OpenGLES 2, so that it runs on platforms that
    only have that OpenGL version;
  * The majority of geometry is now rendered without references to
    the camera in C++ code, so a renderer can now submit it to
    the video card once and re-rasterize with a different projection
    matrix every time the projection is changed, avoiding expensive
    reuploads;
  * The DOGD (draw or get distance) interface is now
    a straightforward Canvas implementation;
  * There are no more direct references to SS.GW.(projection)
    in sketch rendering code, which allows rendering to multiple
    viewports;
  * There are no more unnecessary framebuffer flips on CPU on Cocoa
    and GTK;
  * The platform-dependent GL code is now confined to rendergl1.cpp.
  * The Microsoft and Apple headers required by it that are prone to
    identifier conflicts are no longer included globally;
  * The rendergl1.cpp implementation can now be omitted from
    compilation to run SolveSpace headless or with a different
    OpenGL version.

Note these implementation details of Canvas:
  * GetCamera currently always returns a reference to the field
    `Camera camera;`. This is so that a future renderer that caches
    geometry in the video memory can define it as asserting, which
    would provide assurance against code that could accidentally
    put something projection-dependent in the cache;
  * Line and triangle rendering is specified through a level of
    indirection, hStroke and hFill. This is so that a future renderer
    that batches geometry could cheaply group identical styles.
  * DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
    This is so that a future renderer into an output format that
    uses 2d transforms (e.g. SVG) could easily derive those.

Some additional internal changes were required to enable this:
  * Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
    This is so that the renderer could cache uploaded textures
    between API calls, which requires it to capture a (weak)
    reference.
  * The PlatformPathEqual function was properly extracted into
    platform-specific code. This is so that the <windows.h> header
    could be included only where needed (in platform/w32* as well
    as rendergl1.cpp).
  * The SBsp{2,3}::DebugDraw functions were removed. They can be
    rewritten using the Canvas API if they are ever needed.

While no visual changes were originally intended, some minor fixes
happened anyway:
  * The "emphasis" yellow line from top-left corner is now correctly
    rendered much wider.
  * The marquee rectangle is now pixel grid aligned.
  * The hidden entities now do not clobber the depth buffer, removing
    some minor artifacts.
  * The workplane "tab" now scales with the font used to render
    the workplane name.
  * The workplane name font is now taken from the normals style.
  * Workplane and constraint line stipple is insignificantly
    different. This is so that it can reuse the existing stipple
    codepaths; rendering of workplanes and constraints predates
    those.

Some debug functionality was added:
  * In graphics window, an fps counter that becomes red when
    rendering under 60fps is drawn.
2016-07-23 22:31:18 +00:00
whitequark
bd2da7fe3f GTK3: fix color chooser.
On GTK2, even with a modal grab, mouse button events go through
to the text window. On GTK3 this is not the case.
2016-07-21 08:49:23 +00:00
whitequark
89da072427 GTK3: fix a broken type cast introduced in 66746d1. 2016-07-21 08:48:05 +00:00
whitequark
b0d37c1e78 Replace platform-specific GetMilliseconds using std::chrono. 2016-07-21 06:07:46 +00:00
EvilSpirit
a4a121694c Reimplement commit 0b999f4 correctly. 2016-07-21 05:45:12 +00:00
EvilSpirit
6e17780e01 Draw projection lines for point-line distance constraints.
This is only visible when the point and line lie within the workplane,
but the constraint label does not.
2016-07-20 07:52:05 +00:00
whitequark
ad2371cfae Unix: compatibility with platforms where backtrace() is not in libc.
Also, don't depend on backtrace() when built as libslvs; it is not
the responsbility of the library to use it.
2016-07-19 15:40:52 +00:00
whitequark
8ccc9fe56c When snapping constraints to grid, snap the reference point. 2016-07-19 14:29:25 +00:00
whitequark
8747745a14 Multiply constraint values by scale when pasting with transformation. 2016-07-19 12:12:01 +00:00
whitequark
33e292a6bc Unix: prioritize local resource directory over installed one. 2016-07-19 09:31:58 +00:00
whitequark
cbf84a9d2b Unix: don't use argv[0] when determining resource directory.
This makes invocations like this work:
  ~/solvespace/build$ src/solvespace
2016-07-19 09:30:34 +00:00
EvilSpirit
25575b14c7 Allow indexed access to triangle vertices and normals. 2016-06-30 16:40:40 +00:00
EvilSpirit
0b999f4165 Improved outline detection condition.
Before this commit, circles parallel to the camera plane caused
some edges to be randomly marked as outlines.
2016-06-30 16:39:42 +00:00
EvilSpirit
737ff51893 Skip edges with equal L/R normals when calculating outlines. 2016-06-30 16:39:42 +00:00
EvilSpirit
5a2eb9fb50 Allow changing stipple width for default styles.
We already allow changing stipple style, so it makes sense to do
the same for width.
2016-06-30 16:39:27 +00:00
EvilSpirit
d0a0a0f8cf Use the same line width for hidden and shown edges, by default. 2016-06-30 16:21:55 +00:00
EvilSpirit
32a2a4dbd9 Fix the "Show degrees of freedom" command.
Before this commit, it never highlighted anything at all.
It was broken when chord tolerance calculation was overhauled.
2016-06-29 16:58:47 +00:00
whitequark
da1fc3fd70 DXF: export freehand and zigzag lines as continuous, with a message.
Previously, this resulted in a crash even with no such lines present.
2016-06-29 16:47:23 +00:00
whitequark
131acc5e56 CMake: add a note to packagers about GIT_COMMIT_HASH. 2016-06-28 09:49:37 +00:00
whitequark
21179c2e30 GTK: make Space Navigator actually work.
Before this commit, no events would actually be received.
2016-06-28 09:49:23 +00:00
whitequark
a1589401b6 debian: use non-ABI-versioned libpng. 2016-06-26 13:25:33 +00:00
whitequark
ced5b78420 Don't crash when hovering one of the predefined workplanes. 2016-06-23 12:10:47 +00:00
whitequark
a4e487d298 Don't crash when changing the autosave interval. 2016-06-23 11:56:13 +00:00
whitequark
5c754bd994 Freedesktop: don't hardcode binary path in .desktop file. 2016-06-23 11:25:57 +00:00
whitequark
51f4f27b2b Do not remove autosave after successfully opening file.
If SolveSpace crashes after the open, or hangs and is forcibly
killed, data would be lost. (I lost my data.) Instead, remove
autosave only in two cases: right after a successful save, or right
after a save is declined. This should be completely safe.
2016-06-23 03:00:50 +00:00
whitequark
3a34f63415 Update changelog for 2.2. 2016-06-23 03:00:08 +00:00
whitequark
85cd44df3c Show "Paste" context menu item even when only constraints are copied. 2016-06-20 13:47:14 +00:00
whitequark
e0283b2d2e OS X: fix typo in build system. 2016-06-19 19:46:51 +00:00
Thomas Buck
fb62e0494b OS X: add 3Dconnexion device support. 2016-06-19 19:25:08 +00:00
whitequark
251948bdbd GTK: don't crash if argv[0]=="solvespace". 2016-06-16 03:05:45 +00:00
whitequark
a98cdeeb16 Unix: also install the SolveSpace desktop icon in the xpm format.
This is required by e.g. Debian guidelines.
2016-06-16 02:57:24 +00:00
whitequark
0066f93fb4 Update debian/copyright. 2016-06-16 02:53:43 +00:00
whitequark
3c887d30e3 OS X: find frameworks last.
Before this commit, any available libpng or libfreetype would be
picked, e.g. from Mono.framework. After, homebrew and MacPorts
are prioritized.
2016-06-13 04:15:13 +00:00
whitequark
1dba594949 OS X: sort out window visibility and focus. 2016-06-13 02:08:42 +04:00
whitequark
afafa5ec2e Three.js: allow to configure projRight/projUp.
Also, use a more appealing isometric projection if none specified,
instead of orthographic.

Also, use the scale, offset and projection from the viewport at
the time of export.
2016-06-11 23:13:59 +00:00
whitequark
44223ea332 Three.js: correctly handle browser zoom.
Before this commit, controls went wild on zoom ratios other than 1:1,
and the rendering wasn't too good either.
2016-06-11 23:13:59 +00:00
whitequark
a425395fe3 Add CHANGELOG.md. 2016-06-11 23:13:59 +00:00
whitequark
f8f5095b3d Fix copyright. 2016-06-11 23:13:59 +00:00
whitequark
de6be52293 Fix disabling of autoconstrainter via Ctrl. 2016-06-11 23:13:59 +00:00
whitequark
215b8e4537 Unbreak importing files in the same directory as current file.
This commit fixes a bug introduced in commit 0d7aa0a1.
2016-06-06 17:48:45 +00:00
whitequark
122920d3ee Cocoa: allow dismissing Message/Error NSAlerts using Escape key. 2016-06-03 00:07:30 +00:00
whitequark
14cbd0bbee Cocoa, Win32: embed version info into distributable application.
This shows up in crash dumps, etc, and helps track them back to
a git commit.
2016-06-03 00:07:30 +00:00
Twisted Pair in my Hair
66746d151f GTK: make some dubious implicit type conversions explicit. 2016-05-31 15:40:27 +00:00
whitequark
682bfa2732 Add STL begin()/end() functions to List and IdList.
This will allow us to use it in the C++11 foreach loop, as well
as simplify use of STL <algorithms>.
2016-05-29 14:14:38 +00:00
whitequark
a4e7dea9e3 Remove "generating group 1/10" status message during generation.
It's broken. It expects a valid OpenGL context during generation
that immediately pushes changes to the screen. This is never true
on non-Windows as offscreen rendering is used, and also incompatible
with OpenGL core profile.

Further, right now it displays junk on Windows as well due to some
issue with the bitmap font texture loading.

We will restore it later, in a saner form.
2016-05-27 11:41:17 +00:00
whitequark
faa84c61cf Add SHORT_DASH stipple pattern. 2016-05-27 11:41:17 +00:00
EvilSpirit
73d82a6347 Load actual factory default, not saved style, when requested. 2016-05-26 15:49:46 +00:00
EvilSpirit
5791310bb1 Annotate constants passed as boolean function arguments.
This is to ensure that:
  * it is clear, when looking at the point of usage, what is
    the purpose of "true" or "false";
  * when refactoring, a simple search will bring up any places that
    need to be changed.

Also, argument names were synchronized between declaration and
implementation.

As an exception, these are not annotated:
  * Printf(/*halfLine=*/), to avoid pointless churn.
2016-05-26 12:43:52 +00:00
whitequark
8aab0160d3 Refactor EntReqTable to not special-case last row.
Simplify it a bit while we're at it.
2016-05-26 12:43:52 +00:00
whitequark
3cd9c28ebc Refactor Toolbar to not special-case last row. 2016-05-26 12:43:52 +00:00
whitequark
1249f8496e Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.

Moreover, we also change the switch statements in three ways:

  * Switch statements that ought to be extended every time a new
    enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
    to explicitly list every single enumerand, and not have a
    default: branch.

    Note that the assertions are kept because it is legal for
    a enumeration to have a value unlike any of its defined
    enumerands, and we can e.g. read garbage from a file, or
    an uninitialized variable. This requires some rearranging if
    a default: branch is undesired.

  * Switch statements that ought to only ever see a few select
    enumerands, are changed to always assert in the default: branch.

  * Switch statements that do something meaningful for a few
    enumerands, and ignore everything else, are changed to do nothing
    in a default: branch, under the assumption that changing them
    every time an enumerand is added or removed would just result
    in noise and catch no bugs.

This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-26 12:43:52 +00:00
EvilSpirit
4128a5d8d4 Convert GraphicsWindow::pending.operation to enum class.
This follows the previous commit. Unlike it, though, a small change
to control flow is made to separate the command and pending operation
enumerations.
2016-05-25 07:58:29 +00:00
EvilSpirit
f33ddc94fb Convert all enumerations to use enum class.
Specifically, take the old code that looks like this:

  class Foo {
    enum { X = 1, Y = 2 };
    int kind;
  }
  ... foo.kind = Foo::X; ...

and convert it to this:

  class Foo {
    enum class Kind : uint32_t { X = 1, Y = 2 };
    Kind kind;
  }
  ... foo.kind = Foo::Kind::X;

(In some cases the enumeration would not be in the class namespace,
such as when it is generally useful.)

The benefits are as follows:
  * The type of the field gives a clear indication of intent, both
    to humans and tools (such as binding generators).
  * The compiler is able to automatically warn when a switch is not
    exhaustive; but this is currently suppressed by the
      default: ssassert(false, ...)
    idiom.
  * Integers and plain enums are weakly type checked: they implicitly
    convert into each other. This can hide bugs where type conversion
    is performed but not intended. Enum classes are strongly type
    checked.
  * Plain enums pollute parent namespaces; enum classes do not.
    Almost every defined enum we have already has a kind of ad-hoc
    namespacing via `NAMESPACE_`, which is now explicit.
  * Plain enums do not have a well-defined ABI size, which is
    important for bindings. Enum classes can have it, if specified.
    We specify the base type for all enums as uint32_t, which is
    a safe choice and allows us to not change the numeric values
    of any variants.

This commit introduces absolutely no functional change to the code,
just renaming and change of types. It handles almost all cases,
except GraphicsWindow::pending.operation, which needs minor
functional change.
2016-05-25 07:17:14 +00:00
whitequark
3103728c15 Cocoa: fix warnings. 2016-05-25 07:17:13 +00:00
whitequark
7bda30aca4 Refactor SS.bgImage to use Pixmap. 2016-05-25 03:22:54 +00:00
whitequark
274233fe08 Eliminate Constraint::dogd.refp.
While we're at it, let's also emphasize both parts of a two-part
constraint to make it easier to find.
2016-05-25 03:22:54 +00:00
whitequark
23ff9fa8d1 Eliminate Entity::dogd.refp. 2016-05-25 03:22:54 +00:00
whitequark
8372154384 Remove unused includingConstruction argument of Entity::GenerateEdges. 2016-05-25 03:22:54 +00:00
whitequark
68c4d6f704 Use entity bounding boxes in SelectByMarquee.
Also, fix an insidious typo in BBox::GetOrigin that made BBox::Overlap
return nonsensical results.
2016-05-25 03:22:54 +00:00
whitequark
e2916e3e4a Factor in SOutlineList::FillOutlineTags. 2016-05-25 03:22:54 +00:00
whitequark
20d87d93c5 Add const qualifiers to functions where trivially possible.
This will allow us in future to accept `const T &` anywhere it's
necessary to reduce the amount of copying.

This commit is quite conservative: it does not attempt very hard to
refactor code that performs incidental mutation. In particular
dogd and caches are not marked with the `mutable` keyword.
dogd will be eliminated later, opening up more opportunities to
add const qualifiers.

This commit also doesn't introduce any uses of the newly added const
qualifers. This will be done later.
2016-05-25 03:22:54 +00:00
whitequark
91e18eed73 GTK: clip any editors instead of resizing GraphicsWindow.
Such resizing may well get us past OpenGL's maximum texture size
and break rendering.
2016-05-25 03:22:54 +00:00
whitequark
ddc0dd7194 Reimplement e129755d properly.
Before this commit, quitting through menu would bring up the dialog
twice when declining to save the file.
2016-05-25 03:22:54 +00:00
whitequark
9c08398f51 Fix glyph for U+0454 є in vector font. 2016-05-20 21:42:49 +00:00
EvilSpirit
def73ec118 Refactor Point2d::DistanceToLine. 2016-05-20 15:02:38 +00:00
whitequark
4c318f09c4 Bump version to 3.0. 2016-05-20 14:50:00 +00:00
whitequark
bb0eef2b96 Allow copying and pasting constraints. 2016-05-20 14:19:50 +00:00
EvilSpirit
457ff78849 DXF, DWG: allow undoing an import. 2016-05-20 14:04:21 +00:00
EvilSpirit
bbca4cc224 Rewrite declarations of form f(void) as f().
In C++ there is no difference and newly added functions are all
declared as f(), so this brings back consistency.
2016-05-20 12:43:20 +00:00
whitequark
ad4a204edf Replace all oops() checks with ssassert()s.
This includes explanation and context for non-obvious cases and
shortens debug cycles when just-in-time debugging is not available
(like on Linux) by immediately printing description of the assert
as well as symbolized backtrace.
2016-05-20 12:38:30 +00:00
whitequark
4415f5bb91 Implement ssassert(), a replacement for oops(). 2016-05-20 12:38:29 +00:00
whitequark
1b52c46b81 Remove some dead code. 2016-05-18 23:00:34 +00:00
whitequark
ab418b827e Use the override C++ keyword everywhere.
This helps to ensure that a base class that changes underneath us
would not leave any overridden functions hanging.

This already highlighted some questionable use of GTKMM's API,
which were also fixed in this commit.
2016-05-18 18:42:33 +00:00
whitequark
193477e2da GTK: set application icon. 2016-05-18 17:27:37 +00:00
whitequark
d37d77a257 CMake: require GCC 5.0+. 2016-05-18 17:27:37 +00:00
whitequark
63398ef3ba Cocoa: fix massive memory leak. 2016-05-18 18:20:43 +04:00
whitequark
45514849e2 GTK: intercept the Tab key and run MNU_SHOW_TEXT_WND. 2016-05-18 12:15:17 +00:00
whitequark
b55e096fef Rename "Browser" to "Property Browser".
Also, rename confusing "Show Text Window" menu item.
2016-05-18 12:13:59 +00:00
whitequark
432e7680a4 Three.js: put all resources into res/threejs/ and embed on export.
This means that our exported viewer is independent of internet
connection as well as any CDNs that will eventually die.
2016-05-18 11:44:32 +00:00
whitequark
4b0dc5819b CMake: correctly define and use the add_resource function. 2016-05-18 11:24:24 +00:00
whitequark
fbc5bfc27f Enable -Wfloat-conversion on Clang.
This is a high-SNR warning that's enabled by default on MSVC and
it has highlighted some bugs in glhelper.cpp (that are also fixed
in this commit).

Unfortunately GCC does not have an equivalent for that warning,
and -Wconversion is very noisy.
2016-05-18 11:24:24 +00:00
whitequark
69b8a3b3b3 In Pixmap and BitmapFont, use std::vector instead of std::unique_ptr.
MSVC 2013 keeps having aggravating bugs where its unique_ptr
implementation wants to use deleted functions.

In this case the worst that could happen is one copy per entity
once during initialization (which should in principle be elided
anyway because a return value is a prvalue... no idea if MSVC does
actually do that).
2016-05-18 11:24:24 +00:00
whitequark
56e2d451f4 MSVC: add /D_USE_MATH_DEFINES.
Turns out M_PI and friends aren't from the C standard, but rather
they are a POSIX extension. This definition is necessary to enable
them on MSVC.
2016-05-18 11:24:24 +00:00
whitequark
fc79642788 Move vector font to res/fonts/; remove lff2c.
This commit integrates the vector font in the resource system, so
that cross-compilation would be easier and a custom font could be
used without recompilation.

The font handling code was carefully written to lazily load glyphs;
as possible; in practice this means that startup is less than 15ms
slower after this commit, most of it spent in inflate().

This also reduces executable size and makes compilation of
glhelper.cpp much faster.
2016-05-18 11:24:24 +00:00
whitequark
645c2d90ac Move bitmap font to res/fonts/; remove unifont2c.
This commit integrates the bitmap font in the resource system, so
that cross-compilation would be easier.

The font handling code was carefully written to do glyph parsing
lazily; in practice this means that after this commit, startup
is less than 25ms slower, most of it spent in inflate().

This should also result in faster rendering, since there is no
rampant plane switching anymore; instead, all characters that are
actually used are stashed into same one texture.
2016-05-18 11:24:24 +00:00
whitequark
a525f03371 Move icons to res/icons/; remove png2c.
This commit integrates icons in the resource system so that they
can be loaded (or reloaded, without restarting) in @2x mode, which
will be added in a future commit. png2c is no longer necessary.

png2c used to perform the following transformation:
  if(r + g + b < 11) r = g = b = 11;

This is now achieved by switching the icons to RGBA mode and adding
alpha channel with the following imagemagick invocation, which is
equivalent to the transformation above:
  for i in *.png; do
    convert -fuzz 4% -channel rgba -matte \
            -fill "rgba(255,255,255,0)" -opaque black \
            $i $i
  done

The Debian package solvespace now includes /usr/share/solvespace;
this should be split out into solvespace-data later.
2016-05-18 11:24:24 +00:00
whitequark
fa546af28f Move all platform-specific code to src/platform/.
Without resources, it makes no sense anymore to keep these in
separate subdirectories: unixutil* is shared between Cocoa
and GTK ports, and gloffscreen* should be shared between all ports
(but it's still platform-specific).
2016-05-18 11:24:24 +00:00
whitequark
4c01461316 OS X: move resources to res/. 2016-05-18 11:24:23 +00:00
whitequark
e36ee32def freedesktop: move resources to res/. 2016-05-18 11:24:23 +00:00
whitequark
a6b6d98a94 Win32: move resources to res/. 2016-05-18 11:24:23 +00:00
whitequark
f4c01f670c Implement a resource system.
Currently, icons, fonts, etc are converted to C structures at compile
time and are hardcoded to the binary. This presents several problems:

  * Cross-compilation is complicated. Right now, it is necessary
    to be able to run executables for the target platform; this
    happens to work with wine-binfmt installed, but is rather ugly.

  * Icons can only have one resolution. On OS X, modern software is
    expected to take advantage of high-DPI ("Retina") screens and
    use so-called @2x assets when ran in high-DPI mode.

  * Localization is complicated. Win32 and OS X provide built-in
    support for loading the resource appropriate for the user's
    locale.

  * Embedding strings can only be done as raw strings, using C++'s
    R"(...)" literals. This precludes embedding sizable strings,
    e.g. JavaScript libraries as used in Three.js export, and makes
    git history less useful. Not embedding the libraries means we
    have to rely on external CDNs, which requires an Internet
    connection and adds a glaring point of failure.

  * Linux distribution guidelines are violated. All architecture-
    independent data, especially large data such as fonts, is
    expected to be in /usr/share, not in the binary.

  * Customization is impossible without recompilation. Minor
    modifications like adding a few missing vector font characters
    or adjusting localization require a complete development
    environment, which is unreasonable to expect from users of
    a mechanical CAD.

As such, this commit adds a resource system that bundles (and
sometimes builds) resources with the executable. Where they go is
platform-dependent:

  * on Win32: into resources of the executable, which allows us to
    keep distributing one file;
  * on OS X: into the app bundle;
  * on other *nix: into /usr/share/solvespace/ or ../res/ (relative
    to the executable path), the latter allowing us to run freshly
    built executables without installation.

It also subsides the platform-specific resources that are in src/.

The resource system is not yet used for anything; this will be added
in later commits.
2016-05-18 11:24:23 +00:00
whitequark
b2cdbe8c8d Properly fix workplane name overlapping workplane border.
A previous attempt to fix this was done in 0128b8679. However, it was
not rigorous. The added offset was dependent on font size and it
introduced an error into edit control positioning. Further, it is
irrelevant to non-workplanes.

After this commit, the workplane drawing code adds a fixed offset
instead. Also, the "tab" is enlarged to not overlap with #XY etc.
2016-05-18 11:24:23 +00:00
614 changed files with 122608 additions and 11354 deletions

30
.gitattributes vendored
View File

@ -1,22 +1,10 @@
# .gitattributes for SolveSpace
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.cpp text
*.h text
*.txt text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.gz binary
*.ico binary
*.jpg binary
*.lib binary
*.png binary
# end .gitattributes
*.cpp text
*.h text
*.txt text
*.gz binary
*.ico binary
*.jpg binary
*.lib binary
*.png binary
*.slvs binary

18
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,18 @@
### System information
SolveSpace version: (e.g. 3.0~3dd2fc00; go to Help → About...)
Operating system: (e.g. Debian testing)
### Expected behavior
What should have happened?
### Actual behavior
What actually happened?
### Additional information
For bugs, please attach a savefile that shows the problematic behavior.
You can attach `.slvs` files by archiving them into a `.zip` first.

5
.gitignore vendored
View File

@ -1,6 +1,8 @@
/CMakeCache.txt
/build*/
*.trace # OpenGL apitrace files
/test/**/*.diff.*
/test/**/*.curr.*
*.trace
/debian/tmp/
/debian/*.log
/debian/*.substvars
@ -10,3 +12,4 @@
/debian/libslvs1/
/debian/libslvs1-dev/
/obj-*/
/*.slvs

13
.gitmodules vendored
View File

@ -5,9 +5,18 @@
[submodule "extlib/libpng"]
path = extlib/libpng
url = https://github.com/glennrp/libpng
[submodule "extlib/libfreetype"]
path = extlib/libfreetype
[submodule "extlib/freetype"]
path = extlib/freetype
url = http://git.sv.nongnu.org/r/freetype/freetype2.git
[submodule "extlib/libdxfrw"]
path = extlib/libdxfrw
url = https://github.com/solvespace/libdxfrw.git
[submodule "extlib/pixman"]
path = extlib/pixman
url = https://github.com/solvespace/pixman
[submodule "extlib/cairo"]
path = extlib/cairo
url = https://github.com/solvespace/cairo
[submodule "extlib/angle"]
path = extlib/angle
url = https://github.com/solvespace/angle

View File

@ -4,6 +4,7 @@ os:
- osx
sudo: required
dist: trusty
osx_image: xcode8.2
install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/install-debian.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/install-macos.sh; fi
@ -20,3 +21,9 @@ deploy:
repo: solvespace/solvespace
tags: true
condition: "$TRAVIS_OS_NAME == osx"
notifications:
irc:
channels:
- "chat.freenode.net#solvespace"
use_notice: true
skip_join: true

View File

@ -4,5 +4,10 @@ if echo $TRAVIS_TAG | grep ^v; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=D
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE
# We build without the GUI until Travis updates to an Ubuntu version with GTK 3.22.
cmake .. -DCMAKE_C_COMPILER=clang-3.9 -DCMAKE_CXX_COMPILER=clang++-3.9 \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DENABLE_GUI=OFF \
-DENABLE_SANITIZERS=ON
make VERBOSE=1
make test_solvespace

View File

@ -5,10 +5,5 @@ if echo $TRAVIS_TAG | grep ^v; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=D
mkdir build
cd build
cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
if ! make VERBOSE=1; then
echo "Sigh, transient build failure. Retrying..."
if ! make VERBOSE=1; then
echo "Okay, this is probably an actual bug."
exit 1
fi
fi
make VERBOSE=1
make test_solvespace

View File

@ -1,7 +1,10 @@
#!/bin/sh -xe
wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo add-apt-repository -y 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main'
sudo apt-get update -qq
sudo apt-get install -q -y \
cmake cmake-data libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev \
libgtkmm-2.4-dev libpangomm-1.4-dev libgl1-mesa-dev libglu-dev libglew-dev \
libfreetype6-dev dpkg-dev
libgtkmm-3.0-dev libpangomm-1.4-dev libcairo2-dev libgl1-mesa-dev libglu-dev \
libfreetype6-dev dpkg-dev libstdc++-5-dev clang-3.9 clang++-3.9 lcov

View File

@ -1,3 +1,4 @@
#!/bin/sh -xe
brew update
brew install freetype cairo

View File

@ -1,6 +1,82 @@
Changelog
=========
3.0
---
New sketch features:
* Extrude, lathe, translate and rotate groups can now use the "assembly"
boolean operation, to increase performance.
* Translate and rotate groups can create n-dimensional arrays using
the "difference" and "assembly" boolean operations.
* A new sketch in workplane group can be created based on existing workplane.
* TTF text request has two additional points on the right side, which allow
constraining the width of text.
* Image requests can now be created, similar to TTF text requests.
This replaces the "style → background image" feature.
* Irrelevant points (e.g. arc center point) are not counted when estimating
the bounding box used to compute chord tolerance.
* When adding a constraint which has a label and is redundant with another
constraint, the constraint is added as a reference, avoiding an error.
* Datum points can be copied and pasted.
New constraint features:
* When dragging an arc or rectangle point, it will be automatically
constrained to other points with a click.
* When selecting a constraint, the requests it constraints can be selected
in the text window.
* When selecting an entity, the constraints applied to it can be selected
in the text window.
New export/import features:
* Three.js: allow configuring projection for exported model, and initially
use the current viewport projection.
* Wavefront OBJ: a material file is exported alongside the model, containing
mesh color information.
* DXF/DWG: 3D DXF files are imported as construction entities, in 3d.
New rendering features:
* The "Show/hide hidden lines" button is now a tri-state button that allows
showing all lines (on top of shaded mesh), stippling occluded lines
or not drawing them at all.
* The "Show/hide outlines" button is now independent from "Show/hide edges".
New measurement/analysis features:
* New command for measuring total length of selected entities,
"Analyze → Measure Perimeter".
* New command for measuring center of mass, with live updates as the sketch
changes, "Analyze → Center of Mass".
* When selecting a point and a line, projected distance to to current
workplane is displayed.
Other new features:
* New command-line interface, for batch exporting and more.
* New link to match the on-screen size of the sketch with its actual size,
"view → set to full scale".
* When zooming to fit, constraints are also considered.
* When clicking on an entity that shares a place with other entities,
the entity from the current group is selected.
* When dragging an entity that shares a place with other entities,
the entity from a request is selected. For example, dragging a point on
a face of an extrusion coincident with the source sketch plane will
drag the point from the source sketch.
* In expressions, numbers can contain the digit group separator, "_".
* The "=" key is bound to "Zoom In", like "+" key.
* The numpad decimal separator key is bound to "." regardless of locale.
* On Windows, full-screen mode is implemented.
Bugs fixed:
* A point in 3d constrained to any line whose length is free no longer
causes the line length to collapse.
* Curve-line constraints (in 3d), parallel constraints (in 3d), and
same orientation constraints are more robust.
* Adding some constraints (vertical, midpoint, etc) twice errors out
immediately, instead of later and in a confusing way.
* Constraining a newly placed point to a hovered entity does not cause
spurious changes in the sketch.
* Points highlighted with "Analyze → Show Degrees of Freedom" are drawn
on top of all other geometry.
2.3
---

View File

@ -1,5 +1,12 @@
# cmake configuration
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR
"In-tree builds are not supported; please perform an out-of-tree build:\n"
" rm -rf CMakeCache.txt CMakeFiles/\n"
" mkdir build && cd build && cmake ..")
endif()
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
cmake_policy(VERSION 3.1.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
@ -7,8 +14,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
include(CheckIncludeFile)
# for /MT on MSVC
set(CMAKE_USER_MAKE_RULES_OVERRIDE
"${CMAKE_SOURCE_DIR}/cmake/c_flag_overrides.cmake")
@ -25,29 +30,218 @@ include(GetGitCommitHash)
# set(GIT_COMMIT_HASH 0000000000000000000000000000000000000000)
project(solvespace)
set(solvespace_VERSION_MAJOR 2)
set(solvespace_VERSION_MINOR 3)
set(solvespace_VERSION_MAJOR 3)
set(solvespace_VERSION_MINOR 0)
string(SUBSTRING "${GIT_COMMIT_HASH}" 0 8 solvespace_GIT_HASH)
if(NOT WIN32 AND NOT APPLE)
set(GUI gtk2 CACHE STRING "GUI toolkit to use (one of: gtk2 gtk3)")
set(ENABLE_GUI ON CACHE BOOL
"Whether the graphical interface is enabled (command line interface always is)")
set(ENABLE_TESTS ON CACHE BOOL
"Whether the test suite will be built and run")
set(ENABLE_COVERAGE OFF CACHE BOOL
"Whether code coverage information will be collected")
set(ENABLE_SANITIZERS OFF CACHE BOOL
"Whether to enable Clang's AddressSanitizer and UndefinedBehaviorSanitizer")
set(OPENGL 2 CACHE STRING "OpenGL version to use (one of: 1 2)")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
if(NOT CMAKE_C_COMPILER_ID STREQUAL CMAKE_CXX_COMPILER_ID)
message(FATAL_ERROR "C and C++ compilers should be supplied by the same vendor")
endif()
# compiler
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
# GCC 4.8/4.9 ship with broken but present <regex>. meh.
message(FATAL_ERROR "GCC 5.0+ is required")
endif()
endif()
# common compiler flags
if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
if(TRIPLE STREQUAL "i686-w64-mingw32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
endif()
endif()
if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(ENABLE_SANITIZERS)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "Sanitizers are only available when using Clang/Clang++")
endif()
set(SANITIZE_FLAGS "-O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=address,integer")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fno-sanitize-recover=integer")
# We assume IEEE floats, which means DIV/0 is defined; but ubsan doesn't do so by default.
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fno-sanitize=float-divide-by-zero")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fno-sanitize=unsigned-integer-overflow")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZE_FLAGS}")
endif()
# dependencies
message(STATUS "Using in-tree libdxfrw")
add_subdirectory(extlib/libdxfrw)
if(WIN32)
include(FindVendoredPackage)
include(AddVendoredSubdirectory)
find_vendored_package(Freetype freetype
WITH_ZLIB OFF
WITH_BZip2 OFF
WITH_PNG OFF
WITH_HarfBuzz OFF
FREETYPE_LIBRARY freetype
FREETYPE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/freetype/include)
find_vendored_package(ZLIB zlib
ZLIB_LIBRARY zlibstatic
ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/zlib)
list(APPEND ZLIB_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/zlib)
find_vendored_package(PNG libpng
SKIP_INSTALL_ALL ON
PNG_LIBRARY png_static
PNG_PNG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/libpng)
list(APPEND PNG_PNG_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/libpng)
message(STATUS "Using in-tree pixman")
add_vendored_subdirectory(extlib/pixman)
set(PIXMAN_FOUND YES)
set(PIXMAN_LIBRARY pixman)
set(PIXMAN_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/pixman/pixman)
list(APPEND PIXMAN_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/pixman/pixman)
message(STATUS "Using in-tree cairo")
add_vendored_subdirectory(extlib/cairo)
set(CAIRO_FOUND YES)
set(CAIRO_LIBRARIES cairo)
set(CAIRO_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/cairo/src)
list(APPEND CAIRO_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/cairo/src)
if(ENABLE_GUI)
if(OPENGL STREQUAL "2")
message(STATUS "Using in-tree ANGLE")
set(ANGLE_STATIC ON CACHE INTERNAL "")
set(ANGLE_ENABLE_D3D9 ON CACHE INTERNAL "")
set(ANGLE_ENABLE_D3D11 ON CACHE INTERNAL "")
set(ANGLE_ENABLE_OPENGL OFF CACHE INTERNAL "")
set(ANGLE_ENABLE_ESSL OFF CACHE INTERNAL "")
set(ANGLE_ENABLE_GLSL OFF CACHE INTERNAL "")
set(ANGLE_ENABLE_HLSL ON CACHE INTERNAL "")
add_vendored_subdirectory(extlib/angle)
set(OPENGL_LIBRARIES EGL GLESv2)
set(OPENGL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/angle/include)
else()
find_package(OpenGL REQUIRED)
endif()
if(MSVC AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4)
message(STATUS "Using prebuilt SpaceWare")
set(SPACEWARE_FOUND TRUE)
set(SPACEWARE_INCLUDE_DIR
"${CMAKE_SOURCE_DIR}/extlib/si")
set(SPACEWARE_LIBRARIES
"${CMAKE_SOURCE_DIR}/extlib/si/siapp.lib")
endif()
endif()
elseif(APPLE)
set(CMAKE_FIND_FRAMEWORK LAST)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(Freetype REQUIRED)
find_library(CAIRO_LIBRARIES cairo REQUIRED)
find_path(CAIRO_INCLUDE_DIRS cairo.h PATH_SUFFIXES cairo)
if(ENABLE_GUI)
find_package(OpenGL REQUIRED)
find_library(APPKIT_LIBRARY AppKit REQUIRED)
endif()
else() # Linux and compatible systems
find_package(PkgConfig REQUIRED)
find_package(Backtrace)
find_package(SpaceWare)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(Freetype REQUIRED)
pkg_check_modules(CAIRO REQUIRED cairo)
if(ENABLE_GUI)
find_package(OpenGL REQUIRED)
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
pkg_check_modules(JSONC REQUIRED json-c)
pkg_check_modules(GTKMM REQUIRED gtkmm-3.0>=3.16 pangomm-1.4 x11)
endif()
endif()
if(ENABLE_COVERAGE)
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
find_program(GCOV gcov)
elseif(CMAKE_CXX_COMPILER_ID MATCHES Clang)
find_program(LLVM_COV llvm-cov)
if(LLVM_COV)
set(GCOV ${CMAKE_CURRENT_BINARY_DIR}/llvm-gcov.sh)
file(WRITE ${GCOV} "#!/bin/sh -e\n${LLVM_COV} gcov $*")
execute_process(COMMAND chmod +x ${GCOV})
endif()
endif()
find_program(LCOV lcov)
find_program(GENHTML genhtml)
if(NOT GCOV OR NOT LCOV OR NOT GENHTML)
message(FATAL_ERROR "gcov/llvm-cov and lcov are required for producing coverage reports")
endif()
endif()
find_program(XGETTEXT xgettext)
find_program(MSGINIT msginit)
find_program(MSGMERGE msgmerge)
if(XGETTEXT AND MSGINIT AND MSGMERGE)
set(HAVE_GETTEXT TRUE)
else()
message(WARNING "Gettext not found, translations will not be updated")
set(HAVE_GETTEXT FALSE)
endif()
# solvespace-only compiler flags
if(WIN32)
add_definitions(
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS
-D_SCL_SECURE_NO_WARNINGS
-D_WIN32_WINNT=0x500
-DWINVER=0x0601
-D_WIN32_WINNT=0x0601
-D_WIN32_IE=_WIN32_WINNT
-DISOLATION_AWARE_ENABLED
-DWIN32
-DWIN32_LEAN_AND_MEAN
-DUNICODE
-D_UNICODE
-DNOMINMAX
-D_UNICODE)
-D_USE_MATH_DEFINES)
endif()
if(MSVC)
@ -55,141 +249,56 @@ if(MSVC)
# they have their own __inline; this breaks `static inline` functions.
# We do not want to care and so we fix this with a definition.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline")
# Same for the (C99) __func__ special variable; we use it only in C++ code.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__func__=__FUNCTION__")
# We rely on these /we flags. They correspond to the GNU-style flags below as
# follows: /w4062=-Wswitch
set(WARNING_FLAGS "${WARNING_FLAGS} /we4062")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${WARNING_FLAGS}")
endif()
if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
endif()
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(SANITIZE)
if(NOT (CMAKE_C_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_ID STREQUAL Clang))
message(ERROR "Sanitizers are only available in Clang/Clang++")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WARNING_FLAGS "${WARNING_FLAGS} -Wfloat-conversion")
endif()
set(SANITIZE_FLAGS "-O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=address,undefined,integer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZE_FLAGS}")
# We rely on these -Werror flags.
set(WARNING_FLAGS "${WARNING_FLAGS} -Werror=switch")
endif()
# dependencies
find_package(OpenGL REQUIRED)
message(STATUS "Using in-tree libdxfrw")
add_subdirectory(extlib/libdxfrw)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
if(WIN32)
# Configure Freetype first. If done later, it will notice that
# zlib is available, try to use it and promptly break on MSVC
# in a very obscure way. Given that the only use of zlib, bzip2
# and png support is in support for extremely obsolete Unix fonts,
# we don't care.
find_package(Freetype)
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -l0")
endif()
if(NOT FREETYPE_FOUND)
message(STATUS "Using in-tree libfreetype")
add_subdirectory(extlib/libfreetype EXCLUDE_FROM_ALL)
set(FREETYPE_LIBRARY
freetype)
set(FREETYPE_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/extlib/libfreetype/include")
find_package(Freetype REQUIRED)
if(ENABLE_COVERAGE)
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
message(FATAL_ERROR "Code coverage is only available on GCC and Clang")
endif()
find_package(ZLIB)
if(NOT ZLIB_FOUND)
message(STATUS "Using in-tree zlib")
add_subdirectory(extlib/zlib EXCLUDE_FROM_ALL)
message(STATUS "Using in-tree libpng")
set(ZLIB_LIBRARY
zlibstatic)
set(ZLIB_INCLUDE_DIR
"${CMAKE_SOURCE_DIR}/extlib/zlib"
"${CMAKE_BINARY_DIR}/extlib/zlib")
find_package(ZLIB REQUIRED)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "Code coverage produces reliable results only on Debug builds")
endif()
find_package(PNG)
if(NOT PNG_FOUND)
message(STATUS "Using in-tree libpng")
set(SKIP_INSTALL_ALL
ON)
add_subdirectory(extlib/libpng EXCLUDE_FROM_ALL)
set(PNG_LIBRARY
png16_static)
set(PNG_PNG_INCLUDE_DIR
"${CMAKE_SOURCE_DIR}/extlib/libpng"
"${CMAKE_BINARY_DIR}/extlib/libpng")
find_package(PNG REQUIRED)
endif()
if(NOT MINGW)
message(STATUS "Using prebuilt SpaceWare")
set(SPACEWARE_FOUND TRUE)
set(SPACEWARE_INCLUDE_DIR
"${CMAKE_SOURCE_DIR}/extlib/si")
set(SPACEWARE_LIBRARIES
"${CMAKE_SOURCE_DIR}/extlib/si/siapp.lib")
endif()
elseif(APPLE)
set(CMAKE_FIND_FRAMEWORK LAST)
find_package(PNG REQUIRED)
find_package(Freetype REQUIRED)
find_library(APPKIT_LIBRARY AppKit REQUIRED)
else() # Linux and compatible systems
find_package(SpaceWare)
# Use freedesktop's pkg-config to locate everything.
find_package(PkgConfig REQUIRED)
pkg_check_modules(ZLIB REQUIRED zlib)
pkg_check_modules(PNG REQUIRED libpng)
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
pkg_check_modules(JSONC REQUIRED json-c)
pkg_check_modules(GLEW REQUIRED glew)
pkg_check_modules(FREETYPE REQUIRED freetype2)
set(HAVE_GTK TRUE)
if(GUI STREQUAL "gtk3")
set(HAVE_GTK3 TRUE)
pkg_check_modules(GTKMM REQUIRED gtkmm-3.0 pangomm-1.4 x11)
elseif(GUI STREQUAL "gtk2")
set(HAVE_GTK2 TRUE)
pkg_check_modules(GTKMM REQUIRED gtkmm-2.4 pangomm-1.4 x11)
else()
message(FATAL_ERROR "GUI unrecognized: ${GUI}")
endif()
# With -fexceptions, every call becomes a branch. While technically accurate,
# this is not useful for us.
set(COVERAGE_FLAGS -fno-exceptions --coverage)
set(COVERAGE_LIBRARY --coverage)
endif()
# components
add_subdirectory(tools)
add_subdirectory(res)
add_subdirectory(src)
add_subdirectory(exposed)
if(ENABLE_TESTS)
add_subdirectory(test)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_subdirectory(bench)
else()
message(STATUS "Benchmarking disabled in debug builds.")
endif()

250
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,250 @@
Contributing to SolveSpace
==========================
Contributing bug reports
------------------------
Bug reports are always welcome! When reporting a bug, please include the following:
* The version of SolveSpace (use Help → About...);
* The operating system;
* The save file that reproduces the incorrect behavior, or, if trivial or impossible,
instructions for reproducing it.
GitHub does not allow attaching `*.slvs` files, but it does allow attaching `*.zip` files,
so any savefiles should first be archived.
Contributing code
-----------------
SolveSpace is written in C++, and currently targets all compilers compliant with C++11.
This includes GCC 5 and later, Clang 3.3 and later, and Visual Studio 12 (2013) and later.
### High-level conventions
#### Portability
SolveSpace aims to consist of two general parts: a fully portable core, and platform-specific
UI and support code. Anything outside of `src/platform/` should only use standard C++11,
and rely on `src/platform/unixutil.cpp` and `src/platform/w32util.cpp` to interact with
the OS where this cannot be done through the C++11 standard library.
#### Libraries
SolveSpace primarily relies on the C++11 STL. STL has well-known drawbacks, but is also
widely supported, used, and understood. SolveSpace also includes a fair amount of use of
bespoke containers List and IdList; these provide STL iterators, and can be used when
convenient, such as when reusing other code.
One notable departure here is the STL I/O threads. SolveSpace does not use STL I/O threads
for two reasons: (i) the interface is borderline unusable, and (ii) on Windows it is not
possible to open files with Unicode paths through STL.
When using external libraries (other than to access platform features), the libraries
should satisfy the following conditions:
* Portable, and preferably not interacting with the platform at all;
* Can be included as a CMake subproject, to facilitate Windows, Android, etc. builds;
* Use a license less restrictive than GPL (BSD/MIT, Apache2, MPL, etc.)
#### String encoding
Internally, SolveSpace exclusively stores and uses UTF-8 for all purposes; any `std::string`
may be assumed to be encoded in UTF-8. On Windows, UTF-8 strings are converted to and from
wide strings at the boundary; see [UTF-8 Everywhere][utf8] for details.
[utf8]: http://utf8everywhere.org/
#### String formatting
For string formatting, a wrapper around `sprintf`, `ssprintf`, is used. A notable
pitfall when using it is trying to pass an `std::string` argument without first converting
it to a C string with `.c_str()`.
#### Filesystem access
For filesystem access, the C standard library is used. The `ssfopen` and `ssremove`
wrappers are provided that accept UTF-8 encoded paths.
#### Assertions
To ensure that internal invariants hold, the `ssassert` function is used, e.g.
`ssassert(!isFoo, "Unexpected foo condition");`. Unlike the standard `assert` function,
the `ssassert` function is always enabled, even in release builds. It is more valuable
to discover a bug through a crash than to silently generate incorrect results, and crashes
do not result in losing more than a few minutes of work thanks to the autosave feature.
### Use of C++ features
The conventions described in this section should be used for all new code, but there is a lot
of existing code in SolveSpace that does not use them. This is fine; don't touch it if it works,
but if you need to modify it anyway, might as well modernize it.
#### Exceptions
Exceptions are not used primarily because SolveSpace's testsuite uses measurement
of branch coverage, important for the critical parts such as the geometric kernel.
Every function call with exceptions enabled introduces a branch, making branch coverage
measurement useless.
#### Operator overloading
Operator overloading is not used primarily for historical reasons. Instead, method such
as `Plus` are used.
#### Member visibility
Member visibility is not used for implementation hiding. Every member field and function
is `public`.
#### Constructors
Constructors are not used for initialization, chiefly because indicating an error
in a constructor would require throwing an exception, nor does it use constructors for
blanket zero-initialization because of the performance impact of doing this for common
POD classes like `Vector`.
Instances can be zero-initialized using the aggregate-initialization syntax, e.g. `Foo foo = {};`.
This zero-initializes the POD members and default-initializes the non-POD members, generally
being an equivalent of `memset(&foo, 0, sizeof(foo));` but compatible with STL containers.
#### Input- and output-arguments
Functions accepting an input argument take it either by-value (`Vector v`) or
by-const-reference (`const Vector &v`). Generally, passing by-value is safer as the value
cannot be aliased by something else, but passing by-const-reference is faster, as a copy is
eliminated. Small values should always be passed by-value, and otherwise functions that do not
capture pointers into their arguments should take them by-const-reference. Use your judgement.
Functions accepting an output argument always take it by-pointer (`Vector *v`). This makes
it immediately visible at the call site as it is seen that the address is taken. Arguments
are never passed by-reference, except when needed for interoperability with STL, etc.
#### Iteration
`foreach`-style iteration is preferred for both STL and `List`/`IdList` containers as it indicates
intent clearly, as opposed to `for`-style.
#### Const correctness
Functions that do not mutate `this` should be marked as `const`; when iterating a collection
without mutating any of its elements, `for(const Foo &elem : collection)` is preferred to indicate
the intent.
### Coding style
Code is formatted by the following rules:
* Code is indented using 4 spaces, with no trailing spaces, and lines are wrapped
at 100 columns;
* Braces are placed at the end of the line with the declaration or control flow statement;
* Braces are used with every control flow statement, even if there is only one statement
in the body;
* There is no space after control flow keywords (`if`, `while`, etc.);
* Identifiers are formatted in camel case; variables start with a lowercase letter
(`exampleVariable`) and functions start with an uppercase letter (`ExampleFunction`).
For example:
```c++
std::string SolveSpace::Dirname(std::string filename) {
int slash = filename.rfind(PATH_SEP);
if(slash >= 0) {
return filename.substr(0, slash);
}
return "";
}
```
Debugging code
--------------
SolveSpace releases are throughly tested but sometimes they contain crash
bugs anyway. The reason for such crashes can be determined only if the executable
was built with debug information.
### Debugging a released version
The Linux distributions usually include separate debug information packages.
On a Debian derivative (e.g. Ubuntu), these can be installed with:
apt-get install solvespace-dbg
The macOS releases include the debug information, and no further action
is needed.
The Windows releases include the debug information on the GitHub
[release downloads page](https://github.com/solvespace/solvespace/releases).
### Debugging a custom build
If you are building SolveSpace yourself on a Unix-like platform,
configure or re-configure SolveSpace to produce a debug build, and
then re-build it:
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug [other cmake args...]
make
If you are building SolveSpace yourself using the Visual Studio IDE,
select Debug from the Solution Configurations list box on the toolbar,
and build the solution.
### Debugging with gdb
gdb is a debugger that is mostly used on Linux. First, run SolveSpace
under debugging:
gdb [path to solvespace executable]
(gdb) run
Then, reproduce the crash. After the crash, attach the output in
the console, as well as output of the following gdb commands to
a bug report:
(gdb) backtrace
(gdb) info locals
If the crash is not easy to reproduce, please generate a core file,
which you can use to resume the debugging session later, and provide
any other information that is requested:
(gdb) generate-core-file
This will generate a large file called like `core.1234` in the current
directory; it can be later re-loaded using `gdb --core core.1234`.
### Debugging with lldb
lldb is a debugger that is mostly used on macOS. First, run SolveSpace
under debugging:
lldb [path to solvespace executable]
(lldb) run
Then, reproduce the crash. After the crash, attach the output in
the console, as well as output of the following gdb commands to
a bug report:
(lldb) backtrace all
(lldb) frame variable
If the crash is not easy to reproduce, please generate a core file,
which you can use to resume the debugging session later, and provide
any other information that is requested:
(lldb) process save-core "core"
This will generate a large file called `core` in the current
directory; it can be later re-loaded using `lldb -c core`.
### Debugging GUI-related bugs on Linux
There are several environment variables available that make crashes
earlier and errors more informative. Before running SolveSpace, run
the following commands in your shell:
export G_DEBUG=fatal_warnings
export LIBGL_DEBUG=1
export MESA_DEBUG=1

View File

@ -9,10 +9,10 @@ This repository contains the source code of [SolveSpace][], a parametric
Installation
------------
### Mac OS X (>=10.6 64-bit), Debian (>=jessie) and Ubuntu (>=trusty)
### macOS (>=10.6 64-bit), Windows (>=Vista 32-bit)
Binary packages for Mac OS X and Debian derivatives are available
via [GitHub releases][rel].
Binary packages for macOS and Windows are available via
[GitHub releases][rel].
[rel]: https://github.com/solvespace/solvespace/releases
@ -25,14 +25,14 @@ Building on Linux
### Building for Linux
You will need CMake, libpng, zlib, json-c, fontconfig, freetype, gtkmm 2.4,
pangomm 1.4, OpenGL, OpenGL GLU and OpenGL GLEW, and optionally, the Space Navigator
client library.
You will need CMake, zlib, libpng, cairo, freetype. To build the GUI, you will need
fontconfig, gtkmm 3.0 (version 3.16 or later), pangomm 1.4, OpenGL and OpenGL GLU, and
optionally, the Space Navigator client library.
On a Debian derivative (e.g. Ubuntu) these can be installed with:
apt-get install libpng12-dev libjson-c-dev libfreetype6-dev \
libfontconfig1-dev libgtkmm-2.4-dev libpangomm-1.4-dev \
libgl-dev libglu-dev libglew-dev libspnav-dev cmake
apt-get install cmake zlib1g-dev libpng-dev libcairo2-dev libfreetype6-dev
apt-get install libjson-c-dev libfontconfig1-dev libgtkmm-3.0-dev libpangomm-1.4-dev \
libgl-dev libglu-dev libspnav-dev
Before building, check out the necessary submodules:
@ -42,19 +42,20 @@ After that, build SolveSpace as following:
mkdir build
cd build
cmake ..
cmake .. -DCMAKE_BUILD_TYPE=Release
make
sudo make install
A fully functional port to GTK3 is available, but not recommended
for use due to bugs in this toolkit.
The graphical interface is built as `build/bin/solvespace`, and the command-line interface
is built as `build/bin/solvespace-cli`. It is possible to build only the command-line interface
by passing the `-DENABLE_GUI=OFF` flag to the cmake invocation.
### Building for Windows
You will need CMake, a Windows cross-compiler, and Wine with binfmt support.
You will need CMake and a Windows cross-compiler.
On a Debian derivative (e.g. Ubuntu) these can be installed with:
apt-get install cmake mingw-w64 wine-binfmt
apt-get install cmake mingw-w64
Before building, check out the necessary submodules:
@ -64,27 +65,31 @@ After that, build 32-bit SolveSpace as following:
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake ..
make solvespace
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake \
-DCMAKE_BUILD_TYPE=Release
make
Or, build 64-bit SolveSpace as following:
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake ..
make solvespace
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake \
-DCMAKE_BUILD_TYPE=Release
make
The application is built as `build/src/solvespace.exe`.
The graphical interface is built as `build/bin/solvespace.exe`, and the command-line interface
is built as `build/bin/solvespace-cli.exe`.
Space Navigator support will not be available.
Building on Mac OS X
--------------------
Building on macOS
-----------------
You will need XCode tools, CMake, libpng and Freetype. Assuming you use
You will need XCode tools, CMake, libpng and Freetype. To build tests, you
will need cairo. Assuming you use
[homebrew][], these can be installed with:
brew install cmake libpng freetype
brew install cmake libpng freetype cairo
XCode has to be installed via AppStore; it requires a free Apple ID.
@ -96,26 +101,28 @@ After that, build SolveSpace as following:
mkdir build
cd build
cmake ..
cmake .. -DCMAKE_BUILD_TYPE=Release
make
The app bundle is built in `build/src/solvespace.app`.
The application is built in `build/bin/solvespace.app`, the graphical interface executable
is `build/bin/solvespace.app/Contents/MacOS/solvespace`, and the command-line interface executable
is `build/bin/solvespace.app/Contents/MacOS/solvespace-cli`.
[homebrew]: http://brew.sh/
Building on Windows
-------------------
You will need [cmake][cmakewin] and Visual C++.
You will need [git][gitwin], [cmake][cmakewin] and Visual C++.
### GUI build
### Building with Visual Studio IDE
Check out the git submodules. Create a directory `build` in
the source tree and point cmake-gui to the source tree and that directory.
Press "Configure" and "Generate", then open `build\solvespace.sln` with
Visual C++ and build it.
### Command-line build
### Building with Visual Studio in a command prompt
First, ensure that git and cl (the Visual C++ compiler driver) are in your
`%PATH%`; the latter is usually done by invoking `vcvarsall.bat` from your
@ -124,10 +131,10 @@ Visual Studio install. Then, run the following in cmd or PowerShell:
git submodule update --init
mkdir build
cd build
cmake .. -G "NMake Makefiles"
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
nmake
### MSVC build
### Building with MinGW
It is also possible to build SolveSpace using [MinGW][mingw], though
Space Navigator support will be disabled.
@ -138,12 +145,19 @@ in bash:
git submodule update --init
mkdir build
cd build
cmake ..
cmake .. -DCMAKE_BUILD_TYPE=Release
make
[gitwin]: https://git-scm.com/download/win
[cmakewin]: http://www.cmake.org/download/#latest
[mingw]: http://www.mingw.org/
Contributing
------------
See the [guide for contributors](CONTRIBUTING.md) for the best way to file issues, contribute code,
and debug SolveSpace.
License
-------

View File

@ -1,4 +1,4 @@
version: 2.2.{build}
version: 3.0.{build}
clone_depth: 1
before_build:
- git submodule update --init
@ -6,23 +6,25 @@ before_build:
- cd build
- set tag=x%APPVEYOR_REPO_TAG_NAME%
- if %tag:~,2% == xv (set BUILD_TYPE=RelWithDebInfo) else (set BUILD_TYPE=Debug)
- cmake -G"Visual Studio 12" -T v120_xp -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
- cmake -G"Visual Studio 12" -T v120 ..
build_script:
- msbuild "src\solvespace.vcxproj" /verbosity:minimal /property:Configuration=%BUILD_TYPE% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- msbuild "src\solvespace-cli.vcxproj" /verbosity:minimal /property:Configuration=%BUILD_TYPE% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- msbuild "test\solvespace-testsuite.vcxproj" /verbosity:minimal /property:Configuration=%BUILD_TYPE% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
test_script:
- bin\%BUILD_TYPE%\solvespace-testsuite.exe
artifacts:
- path: build\src\Debug\solvespace.exe
- path: build\bin\%BUILD_TYPE%\solvespace.exe
name: solvespace.exe
- path: build\src\Debug\solvespace.pdb
name: solvespace.pdb
- path: build\src\RelWithDebInfo\solvespace.exe
name: solvespace.exe
- path: build\src\RelWithDebInfo\solvespace.pdb
- path: build\bin\%BUILD_TYPE%\solvespace-cli.exe
name: solvespace-cli.exe
- path: build\bin\%BUILD_TYPE%\solvespace.pdb
name: solvespace.pdb
deploy:
- provider: GitHub
auth_token:
secure: P9/pf2nM+jlWKe7pCjMp41HycBNP/+5AsmE/TETrDUoBOa/9WFHelqdVFrbRn9IC
description: ""
artifact: solvespace.exe
artifact: solvespace.exe,solvespace-cli.exe,solvespace.pdb
on:
appveyor_repo_tag: true

17
bench/CMakeLists.txt Normal file
View File

@ -0,0 +1,17 @@
# benchmark runner
foreach(pkg_config_lib CAIRO)
include_directories(${${pkg_config_lib}_INCLUDE_DIRS})
link_directories(${${pkg_config_lib}_LIBRARY_DIRS})
endforeach()
add_executable(solvespace-benchmark
harness.cpp
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)
target_link_libraries(solvespace-benchmark
solvespace-core
solvespace-headless)
add_dependencies(solvespace-benchmark
resources)

78
bench/harness.cpp Normal file
View File

@ -0,0 +1,78 @@
//-----------------------------------------------------------------------------
// Our harness for running benchmarks.
//
// Copyright 2016 whitequark
//-----------------------------------------------------------------------------
#include "solvespace.h"
static bool RunBenchmark(std::function<void()> setupFn,
std::function<bool()> benchFn,
std::function<void()> teardownFn,
size_t minIter = 5, double minTime = 5.0) {
// Warmup
setupFn();
if(!benchFn()) {
fprintf(stderr, "Benchmark failed\n");
return false;
}
teardownFn();
// Benchmark
size_t iter = 0;
double time = 0.0;
while(iter < minIter || time < minTime) {
setupFn();
auto testStartTime = std::chrono::steady_clock::now();
benchFn();
auto testEndTime = std::chrono::steady_clock::now();
teardownFn();
std::chrono::duration<double> testTime = testEndTime - testStartTime;
time += testTime.count();
iter += 1;
}
// Report
fprintf(stdout, "Iterations: %zd\n", iter);
fprintf(stdout, "Time: %.3f s\n", time);
fprintf(stdout, "Per iter.: %.3f s\n", time / (double)iter);
return true;
}
int main(int argc, char **argv) {
std::vector<std::string> args = InitPlatform(argc, argv);
std::string mode;
Platform::Path filename;
if(args.size() == 3) {
mode = args[1];
filename = Platform::Path::From(args[2]);
} else {
fprintf(stderr, "Usage: %s [mode] [filename]\n", args[0].c_str());
fprintf(stderr, "Mode can be one of: load.\n");
return 1;
}
bool result = false;
if(mode == "load") {
result = RunBenchmark(
[] {
SS.Init();
},
[&] {
if(!SS.LoadFromFile(filename))
return false;
SS.AfterNewFile();
return true;
},
[] {
SK.Clear();
SS.Clear();
});
} else {
fprintf(stderr, "Unknown mode \"%s\"\n", mode.c_str());
}
return (result == true ? 0 : 1);
}

View File

@ -0,0 +1,10 @@
# Equivalent to add_subdirectory(... EXCLUDE_FROM_ALL), but also disables
# all warnings.
include(DisableWarnings)
function(add_vendored_subdirectory PATH)
disable_warnings()
add_subdirectory(${PATH} EXCLUDE_FROM_ALL)
endfunction()

View File

@ -0,0 +1,15 @@
# Disables all warnings on MSVC and GNU-compatible compilers.
function(disable_warnings)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w" PARENT_SCOPE)
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0" PARENT_SCOPE)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w" PARENT_SCOPE)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0" PARENT_SCOPE)
endif()
endfunction()

View File

@ -0,0 +1,54 @@
# Find the given library in the system locations, or build in-tree if not found.
#
# Arguments:
# PKG_NAME - name of the package as passed to find_package
# PKG_PATH - name of the source tree relative to extlib/
#
# The rest of the arguments are VARIABLE VALUE pairs. If the library is not found,
# every VARIABLE will be set to VALUE and find_package will be rerun with the REQUIRED flag.
# Regardless of where the library was found, only the specfied VARIABLEs that start with
# ${PKG_NAME} will be set in the parent scope.
#
# All warnings in the in-tree package are disabled.
include(DisableWarnings)
function(find_vendored_package PKG_NAME PKG_PATH)
find_package(${PKG_NAME})
set(cfg_name)
foreach(item ${ARGN})
if(NOT cfg_name)
set(cfg_name ${item})
else()
set(${cfg_name} ${item} CACHE INTERNAL "")
set(cfg_name)
endif()
endforeach()
disable_warnings()
string(TOUPPER ${PKG_NAME} VAR_NAME)
if(NOT ${VAR_NAME}_FOUND)
message(STATUS "Using in-tree ${PKG_PATH}")
set(${VAR_NAME}_IN_TREE YES CACHE INTERNAL "")
add_subdirectory(extlib/${PKG_PATH} EXCLUDE_FROM_ALL)
find_package(${PKG_NAME} REQUIRED)
elseif(${VAR_NAME}_IN_TREE)
add_subdirectory(extlib/${PKG_PATH} EXCLUDE_FROM_ALL)
endif()
# Now put everything we just discovered into the cache.
set(cfg_name)
foreach(item ${ARGN} ${VAR_NAME}_FOUND)
if(NOT cfg_name)
set(cfg_name ${item})
else()
if(cfg_name MATCHES "^${VAR_NAME}")
set(${cfg_name} "${${cfg_name}}" CACHE INTERNAL "")
endif()
set(cfg_name)
endif()
endforeach()
endfunction()

View File

@ -13,11 +13,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>${solvespace_VERSION_MAJOR}.${solvespace_VERSION_MINOR}</string>
<string>${solvespace_VERSION_MAJOR}.${solvespace_VERSION_MINOR}~${solvespace_GIT_HASH}</string>
<key>CFBundleShortVersionString</key>
<string>${solvespace_VERSION_MAJOR}.${solvespace_VERSION_MINOR}</string>
<key>NSHumanReadableCopyright</key>
<string>© 2008-2015 Jonathan Westhues and other authors</string>
<string>© 2008-2016 Jonathan Westhues and other authors</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSMainNibFile</key>

View File

@ -1,13 +1,15 @@
SET(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_NAME Windows)
SET(TRIPLE i686-w64-mingw32)
set(TRIPLE i686-w64-mingw32)
SET(CMAKE_C_COMPILER ${TRIPLE}-gcc)
SET(CMAKE_CXX_COMPILER ${TRIPLE}-g++)
SET(CMAKE_RC_COMPILER ${TRIPLE}-windres)
set(CMAKE_C_COMPILER ${TRIPLE}-gcc)
set(CMAKE_CXX_COMPILER ${TRIPLE}-g++)
set(CMAKE_RC_COMPILER ${TRIPLE}-windres)
SET(CMAKE_FIND_ROOT_PATH /usr/${TRIPLE})
set(CMAKE_FIND_ROOT_PATH /usr/${TRIPLE})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(ENV{PKG_CONFIG_LIBDIR} /usr/${TRIPLE}/lib/pkgconfig)

View File

@ -1,13 +1,15 @@
SET(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_NAME Windows)
SET(TRIPLE x86_64-w64-mingw32)
set(TRIPLE x86_64-w64-mingw32)
SET(CMAKE_C_COMPILER ${TRIPLE}-gcc)
SET(CMAKE_CXX_COMPILER ${TRIPLE}-g++)
SET(CMAKE_RC_COMPILER ${TRIPLE}-windres)
set(CMAKE_C_COMPILER ${TRIPLE}-gcc)
set(CMAKE_CXX_COMPILER ${TRIPLE}-g++)
set(CMAKE_RC_COMPILER ${TRIPLE}-windres)
SET(CMAKE_FIND_ROOT_PATH /usr/${TRIPLE})
set(CMAKE_FIND_ROOT_PATH /usr/${TRIPLE})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(ENV{PKG_CONFIG_LIBDIR} /usr/${TRIPLE}/lib/pkgconfig)

View File

@ -5,18 +5,13 @@
*
* Copyright 2008-2013 Jonathan Westhues.
*---------------------------------------------------------------------------*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef WIN32
# include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#include <stdint.h>
#include <slvs.h>
@ -36,7 +31,7 @@ static void *CheckMalloc(size_t n)
* An example of a constraint in 3d. We create a single group, with some
* entities and constraints.
*---------------------------------------------------------------------------*/
void Example3d(void)
void Example3d()
{
/* This will contain a single group, which will arbitrarily number 1. */
Slvs_hGroup g = 1;
@ -88,7 +83,7 @@ void Example3d(void)
* along the reference frame's xy plane. In a second group, we create some
* entities in that group and dimension them.
*---------------------------------------------------------------------------*/
void Example2d(void)
void Example2d()
{
Slvs_hGroup g;
double qw, qx, qy, qz;
@ -254,7 +249,7 @@ void Example2d(void)
}
}
int main(void)
int main()
{
sys.param = CheckMalloc(50*sizeof(sys.param[0]));
sys.entity = CheckMalloc(50*sizeof(sys.entity[0]));

1
extlib/angle Submodule

@ -0,0 +1 @@
Subproject commit 6fbcce0938caaccdbea44d826759aa2e587fe2f7

1
extlib/cairo Submodule

@ -0,0 +1 @@
Subproject commit d4724ee921c4fa399ccbd0019c3d6917452e0ffd

1
extlib/freetype Submodule

@ -0,0 +1 @@
Subproject commit 069083cccd73d1d68da68116c8d050bb62cdfe0e

@ -1 +1 @@
Subproject commit 8f958955f54668c142ded760dc951ffd16d9c71b
Subproject commit 6f362317bf3f176b613be48512a88b78125c79f4

@ -1 +0,0 @@
Subproject commit 44accb9e2e5b00696cf50a869b68afa2ce3dd389

@ -1 +1 @@
Subproject commit 5b6a6f914b734f38d3ea96d70bfc67acd8b47414
Subproject commit e9c3d83d5a04835806287f1e8c0f2d3a962d6673

1
extlib/pixman Submodule

@ -0,0 +1 @@
Subproject commit 5561dfc3f7e992454076ff3f10a0554c6b407e19

@ -1 +1 @@
Subproject commit 50893291621658f355bc5b4d450a8d06a563053d
Subproject commit 2fa463bacfff79181df1a5270fb67cc679a53e71

232
res/CMakeLists.txt Normal file
View File

@ -0,0 +1,232 @@
# First, set up registration functions for the kinds of resources we handle.
set(resource_root ${CMAKE_CURRENT_SOURCE_DIR}/)
set(resource_list)
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win32/versioninfo.rc.in
${CMAKE_CURRENT_BINARY_DIR}/win32/versioninfo.rc)
set(rc_file ${CMAKE_CURRENT_BINARY_DIR}/resources.rc)
file(WRITE ${rc_file} "// Autogenerated; do not edit\n")
file(APPEND ${rc_file} "#include <windows.h>\n")
file(APPEND ${rc_file} "#include \"${CMAKE_CURRENT_BINARY_DIR}/win32/versioninfo.rc\"\n")
function(add_resource name)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
if(${ARGC} GREATER 1)
set(id ${ARGV1})
else()
string(REPLACE ${resource_root} "" id ${source})
endif()
if(${ARGC} GREATER 2)
set(type ${ARGV2})
else()
set(type RCDATA)
endif()
file(SHA512 "${source}" hash)
file(APPEND ${rc_file} "${id} ${type} \"${source}\" // ${hash}\n")
# CMake doesn't track file dependencies across directories, so we force
# a reconfigure (which changes the RC file because of the hash above)
# every time a resource is changed.
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${source}")
endfunction()
elseif(APPLE)
set(app_resource_dir ${CMAKE_BINARY_DIR}/bin/solvespace.app/Contents/Resources)
set(cli_resource_dir ${CMAKE_BINARY_DIR}/res)
function(add_resource name)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
set(target_app ${app_resource_dir}/${name})
set(target_cli ${cli_resource_dir}/${name})
set(resource_list "${resource_list};${target_app};${target_cli}" PARENT_SCOPE)
get_filename_component(target_app_dir ${target_app} DIRECTORY)
get_filename_component(target_cli_dir ${target_cli} DIRECTORY)
add_custom_command(
OUTPUT ${target_app} ${target_cli}
COMMAND ${CMAKE_COMMAND} -E make_directory ${target_app_dir}
COMMAND ${CMAKE_COMMAND} -E copy ${source} ${target_app}
COMMAND ${CMAKE_COMMAND} -E make_directory ${target_cli_dir}
COMMAND ${CMAKE_COMMAND} -E copy ${source} ${target_cli}
COMMENT "Copying resource ${name}"
DEPENDS ${source}
VERBATIM)
endfunction()
function(add_xib name)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
get_filename_component(basename ${name} NAME_WE)
set(target ${app_resource_dir}/${basename}.nib)
set(resource_list "${resource_list};${target}" PARENT_SCOPE)
add_custom_command(
OUTPUT ${target}
COMMAND ${CMAKE_COMMAND} -E make_directory ${app_resource_dir}
COMMAND ibtool --errors --warnings --notices --output-format human-readable-text
--compile ${target} ${source}
COMMENT "Building Interface Builder file ${name}"
DEPENDS ${source}
VERBATIM)
endfunction()
function(add_iconset name)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
get_filename_component(basename ${name} NAME_WE)
set(target ${app_resource_dir}/${basename}.icns)
set(resource_list "${resource_list};${target}" PARENT_SCOPE)
add_custom_command(
OUTPUT ${target}
COMMAND ${CMAKE_COMMAND} -E make_directory ${app_resource_dir}
COMMAND iconutil -c icns -o ${target} ${source}
COMMENT "Building icon set ${name}"
DEPENDS ${source}
VERBATIM)
endfunction()
else() # Unix
include(GNUInstallDirs)
set(app_resource_dir ${CMAKE_BINARY_DIR}/res)
function(add_resource name)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
set(target ${app_resource_dir}/${name})
set(resource_list "${resource_list};${target}" PARENT_SCOPE)
get_filename_component(target_dir ${target} DIRECTORY)
add_custom_command(
OUTPUT ${target}
COMMAND ${CMAKE_COMMAND} -E make_directory ${target_dir}
COMMAND ${CMAKE_COMMAND} -E copy ${source} ${target}
COMMENT "Copying resource ${name}"
DEPENDS ${source}
VERBATIM)
get_filename_component(name_dir ${name} DIRECTORY)
install(FILES ${source}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/solvespace/${name_dir})
endfunction()
endif()
function(add_resources)
foreach(name ${ARGN})
add_resource(${name})
set(resource_list "${resource_list}" PARENT_SCOPE)
endforeach()
endfunction()
# Second, register all resources.
if(WIN32)
add_resource(win32/icon.ico 4000 ICON)
add_resource(win32/manifest.xml 2 RT_MANIFEST)
elseif(APPLE)
add_iconset (cocoa/AppIcon.iconset)
add_xib (cocoa/MainMenu.xib)
add_xib (cocoa/SaveFormatAccessory.xib)
else()
add_resource(freedesktop/solvespace-48x48.png)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/freedesktop/solvespace.desktop.in
${CMAKE_CURRENT_BINARY_DIR}/freedesktop/solvespace.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freedesktop/solvespace.desktop
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
foreach(SIZE 16x16 24x24 32x32 48x48)
install(FILES freedesktop/solvespace-${SIZE}.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}/apps
RENAME solvespace.png)
install(FILES freedesktop/solvespace-${SIZE}.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}/mimetypes
RENAME application.x-solvespace.png)
endforeach()
foreach(SIZE 16x16 24x24 32x32 48x48)
install(FILES freedesktop/solvespace-${SIZE}.xpm
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pixmaps)
endforeach()
endif()
add_resources(
banner.txt
icons/graphics-window/angle.png
icons/graphics-window/arc.png
icons/graphics-window/assemble.png
icons/graphics-window/bezier.png
icons/graphics-window/circle.png
icons/graphics-window/construction.png
icons/graphics-window/equal.png
icons/graphics-window/extrude.png
icons/graphics-window/horiz.png
icons/graphics-window/image.png
icons/graphics-window/in3d.png
icons/graphics-window/lathe.png
icons/graphics-window/length.png
icons/graphics-window/line.png
icons/graphics-window/ontoworkplane.png
icons/graphics-window/other-supp.png
icons/graphics-window/parallel.png
icons/graphics-window/perpendicular.png
icons/graphics-window/pointonx.png
icons/graphics-window/point.png
icons/graphics-window/rectangle.png
icons/graphics-window/ref.png
icons/graphics-window/same-orientation.png
icons/graphics-window/sketch-in-3d.png
icons/graphics-window/sketch-in-plane.png
icons/graphics-window/step-rotate.png
icons/graphics-window/step-translate.png
icons/graphics-window/symmetric.png
icons/graphics-window/tangent-arc.png
icons/graphics-window/text.png
icons/graphics-window/trim.png
icons/graphics-window/vert.png
icons/text-window/constraint.png
icons/text-window/edges.png
icons/text-window/faces.png
icons/text-window/occluded-visible.png
icons/text-window/occluded-stippled.png
icons/text-window/occluded-invisible.png
icons/text-window/mesh.png
icons/text-window/normal.png
icons/text-window/outlines.png
icons/text-window/point.png
icons/text-window/shaded.png
icons/text-window/workplane.png
locales.txt
locales/en_US.po
locales/uk_UA.po
fonts/unifont.hex.gz
fonts/private/0-check-false.png
fonts/private/1-check-true.png
fonts/private/2-radio-false.png
fonts/private/3-radio-true.png
fonts/private/4-stipple-dot.png
fonts/private/5-stipple-dash-long.png
fonts/private/6-stipple-dash.png
fonts/private/7-stipple-zigzag.png
fonts/unicode.lff.gz
shaders/imesh.frag
shaders/imesh.vert
shaders/imesh_point.frag
shaders/imesh_point.vert
shaders/imesh_tex.frag
shaders/imesh_texa.frag
shaders/imesh_tex.vert
shaders/mesh.frag
shaders/mesh.vert
shaders/mesh_fill.frag
shaders/mesh_fill.vert
shaders/edge.frag
shaders/edge.vert
shaders/outline.vert
threejs/three-r76.js.gz
threejs/hammer-2.0.8.js.gz
threejs/SolveSpaceControls.js)
# Third, distribute the resources.
add_custom_target(resources
DEPENDS ${resource_list})
if(WIN32)
set_property(TARGET resources PROPERTY EXTRA_SOURCES ${rc_file})
endif()

1
res/banner.txt Normal file
View File

@ -0,0 +1 @@
SolveSpace!

View File

Before

Width:  |  Height:  |  Size: 891 B

After

Width:  |  Height:  |  Size: 891 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 586 B

After

Width:  |  Height:  |  Size: 586 B

View File

Before

Width:  |  Height:  |  Size: 626 B

After

Width:  |  Height:  |  Size: 626 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 626 B

After

Width:  |  Height:  |  Size: 626 B

View File

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 746 B

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 218 B

View File

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 243 B

View File

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 228 B

View File

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 231 B

View File

Before

Width:  |  Height:  |  Size: 936 B

After

Width:  |  Height:  |  Size: 936 B

View File

Before

Width:  |  Height:  |  Size: 932 B

After

Width:  |  Height:  |  Size: 932 B

View File

Before

Width:  |  Height:  |  Size: 932 B

After

Width:  |  Height:  |  Size: 932 B

View File

Before

Width:  |  Height:  |  Size: 950 B

After

Width:  |  Height:  |  Size: 950 B

View File

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 336 B

View File

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 338 B

View File

Before

Width:  |  Height:  |  Size: 348 B

After

Width:  |  Height:  |  Size: 348 B

View File

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 352 B

View File

@ -2,7 +2,7 @@
Version=1.0
Name=SolveSpace
Comment=A parametric 2d/3d CAD
Exec=/usr/bin/solvespace
Exec=${CMAKE_INSTALL_FULL_BINDIR}/solvespace
Icon=solvespace
Type=Application
Categories=Graphics

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Some files were not shown because too many files have changed in this diff Show More