Compare commits

..

732 Commits

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
whitequark
1e2f199633 Update CI scripts to respect the vA.B tag name format. 2016-05-17 14:53:36 +00:00
whitequark
0d7aa0a1a3 When opening imported files, first try relative path.
Without this, if we have e.g.:
  * a/x.slvs
  * a/y.slvs importing a/x.slvs
and copy a/ to b/, then loading b/y.slvs would load a/x.slvs, which
is rather surprising.
2016-05-17 14:44:33 +00:00
whitequark
3bdaa53725 MSVC: expand C99's inline to MSVC's __inline.
This is not done for C++ as C++ has a proper inline keyword, and
MSVC's C++ standard library will not like it becoming a macro.
2016-05-17 12:54:51 +00:00
EvilSpirit
ae60187322 DXF: export the right supplementary angle.
Before this commit, e.g. a 120° angle could be exported as its
supplementary 60° angle but it would still say 120° in the label.

After this commit, the right angle is selected in DXF-based software.
Similarly, it roundtrips through SolveSpace correctly.
2016-05-17 12:34:35 +00:00
EvilSpirit
11919bf0c1 DXF: import "actual measurement" for dimensions. 2016-05-17 12:34:35 +00:00
EvilSpirit
63abcc379d DXF: export "actual measurement" for dimensions.
The "actual measurement" DXF field contains the size of the dimension
as scaled on the drawing, as opposed to the size as written on
the label.
2016-05-17 12:34:35 +00:00
EvilSpirit
7b8e8b0b41 DXF: export color as indexed, not RGB.
The version of AutoCAD we advertise is unable to read RGB color, so
software attempting to be compatible with it ignores color attributes.
2016-05-17 11:47:49 +00:00
whitequark
e129755d66 Offer to save file when closing if it is unsaved. 2016-05-11 07:43:04 +00:00
whitequark
005ff7e31b GTK: fix GTK3 build. 2016-05-10 13:10:41 +00:00
whitequark
ab8fdcb273 GTK: don't set the "Keep above" hint on text window.
This hint is not recommended for direct use by applications, and for
a good reason: it's very annoying. Moreover, what we want is not
"keep above" but rather "keep on the same layer as graphics window",
which is already achieved by setting window type to "utility"
on GNOME and Unity WMs, and by setting the transient window hint
for the text window on KDE WM.
2016-05-10 01:21:36 +00:00
whitequark
4a8675c120 DXF: regenerate after importing.
Without this, some freshly imported entities appear with incorrect
styles.
2016-05-09 12:43:52 +00:00
whitequark
8f515f3b90 GTK: don't raise graphics window in HideTextEditControl().
This screws up window managers like fvwm, which don't respect
the ICCCM "Keep Above" flag. I don't remember why it's there and
it doesn't appear that removing it has any ill effect.
2016-05-08 00:02:21 +00:00
whitequark
e969bc94ad Enable -Wall -Wextra -Wno-unused-parameter on GCC/Clang.
This is good practice and helps to catch bugs. Several changes
were made to accomodate the newly enabled warnings:
  * -Wunused-function:
    * in exposed/, static functions that were supposed to be inlined
      were explicitly marked as inline;
    * some actually unused functions were removed;
  * -Wsign-compare: explicit conversions were added, and in
    the future we should find a nicer way than aux* fields;
  * -Wmissing-field-initializers: added initializers;
  * -Wreorder: reordered properly;
  * -Wunused-but-set-variable: remove variable.

-Wunused-parameter was turned off as enabling it would result in
massive amount of churn in UI code. Despite that, we should enable
it at some point as it has a fairly high SNR otherwise.
2016-05-08 00:01:35 +00:00
whitequark
ee30fa2b0d Work around an MSVC 2013 bug related to unique_ptr.
The following bug is tickled by calling emplace() on a map with
non-copyable but moveable values:
https://connect.microsoft.com/VisualStudio/feedbackdetail/view/960021

Fortunately, we don't actually need emplace() here as operator[]
will create values if they aren't there.
2016-05-07 22:36:41 +00:00
whitequark
12c9858d06 Only flip extrusion normal when transitioning between union and difference.
After commit a8465cbc8, extrusion normal would be adjusted when
switching between union and assembly groups, if ever implemented.
2016-05-07 06:36:30 +00:00
EvilSpirit
a44a4665a8 In GenerateAll, accept explicitly permitted redundant sketches as OK.
Before this commit, they were considered unsolved and were re-solved
over and over unnecessarily.
2016-05-07 05:43:16 +00:00
whitequark
febe0f5282 Rename the old "Import / Assemble" feature to "Link / Assemble".
This better reflects what it does and avoids clashes with the new
DXF import feature.
2016-05-07 05:27:54 +00:00
whitequark
d05e9a938b DWG: implement import.
Before this commit, the file filter suggested that DWG was readable,
but it wasn't.

Also, report any failures while reading DWG and DXF files.
2016-05-07 05:17:23 +00:00
whitequark
7da5cfbaae Don't hold all existing system fonts open.
On Windows, this exhausts file descriptors and everything (e.g.
opening and saving files) breaks.
2016-05-07 04:20:06 +00:00
EvilSpirit
a21a327a97 DXF: create certain constraints during import.
Specifically:
  * point-coincident, horizontal and vertical constraints (inferred);
  * point-point and point-line distance, angle, radius and diameter
    constraints (based on DXF dimensions).
2016-05-07 04:02:34 +00:00
EvilSpirit
70d84b30e8 DXF: implement import. 2016-05-07 04:02:34 +00:00
EvilSpirit
a8465cbc8a Flip extrusion normal when switching between union and difference.
This is done because a meaningful union extrusion is almost never
a meaningful difference extrusion, and saves a bunch of common
manual work.

To avoid creating invalid sketches this isn't done when there are any
constraints.
2016-05-06 23:07:19 +00:00
whitequark
affc88f342 Three.js: various control improvements.
Specifically:
  * touchscreen devices are now supported;
  * rotation is now more like what SolveSpace itself does.

The code is split in two parts because MSVC can't handle string
literals longer than 16Ki.
2016-05-06 17:42:01 +00:00
EvilSpirit
e1f614101f Only generate split triangles when exporting if needed.
Before this commit, when exporting a vector file without the shaded
model shown, or similarly when using formats that we do not export
the mesh to, we still generate (and then discard) the mesh in paint
order. This is a waste of time.
2016-05-04 04:48:24 +00:00
EvilSpirit
a75bf6e216 Fix incorrect condition ordering that causes a crash. 2016-05-04 04:34:03 +00:00
EvilSpirit
f5d8b1dc6b Implement missing parts of 09f59ddb.
This caused no crashes, but some extrusions resulted in a wrong mesh.
2016-05-04 03:21:12 +00:00
whitequark
ba4cb28251 Fix uninitialized variable access. 2016-05-04 03:21:12 +00:00
whitequark
7f79461d5d CMake: build with sanitizers if -DSANITIZE=TRUE passed. 2016-05-04 03:21:12 +00:00
whitequark
e61bac2797 Refactor file filters to not use preprocessor magic.
The immediate reason for refactoring this was that the GTK port broke
after 52af7256 since config.h is not included anymore, but it was
a fragile piece of code I will shed no tears for.

While we're at it, get rid of the mutable std::string &file to be
consistent with our conventions.
2016-05-04 03:21:12 +00:00
whitequark
52af725606 Only #include "config.h" when we need something from it.
config.h now includes the git hash and so, as long as it's included
in solvespace.h, any change of git HEAD will trigger a complete
recompilation, which makes bisecting especially annoying.

While we're at it, remove HAVE_STDINT_H from it, since we require
C++11 and all MSVC versions that include C++11 also include stdint.h.
2016-04-23 23:06:31 +00:00
whitequark
2fed0587ea Embed git commit hash in the "About" dialog.
Also, remove usage of __DATE__ and __TIME__ to make the build fully
deterministic. They are redundant once we have the commit hash,
anyway.
2016-04-23 22:53:21 +00:00
whitequark
c6747438e0 CMake: properly invoke buildsystems of vendored libraries.
Before this commit, running "make" would build e.g. zlib's tests
and fail because they are not designed to work when zlib is included
as a subproject.

After this commit, EXCLUDE_FROM_ALL, which I did not know about,
prevents any actions from being done by default in these subprojects.
2016-04-23 19:39:40 +00:00
whitequark
ab710f7ed3 CI: work around transient OS X failures.
Travis OS X builders randomly break in ways that aren't reproducible
outside of their VMs, have no Google hits, and are very aggravating;
the two common ones are:
  * hdiutil: create failed - Resource busy
  * make[2]: write error

This commit drags SNR back into a tolerable range with a gross hack.
2016-04-23 19:39:40 +00:00
whitequark
ddbb041995 CI: use verbose builds on OS X as well. 2016-04-23 19:39:39 +00:00
whitequark
c2373e7b3a CI: make appveyor.yml independent of Appveyor project name. 2016-04-23 19:39:39 +00:00
EvilSpirit
1c51205a11 DXF: reassemble piecewise linear fragments into polylines. 2016-04-23 19:39:39 +00:00
whitequark
04a79b4308 OS X: correctly make text window the key window.
This is a refactoring bug introduced in 23dc36d.
2016-04-23 19:39:39 +00:00
EvilSpirit
dabd57847e MSVC: work around binary size explosion. 2016-04-23 19:39:39 +00:00
whitequark
d2b21666e1 Move everything from whitequark/solvespace to solvespace/solvespace. 2016-04-23 19:39:39 +00:00
whitequark
2edc61d072 Prepare CI for release builds. 2016-04-23 04:38:32 +00:00
whitequark
c17f1160dc Allow snapping constraint labels to grid.
This is pretty much the only way to get a sketch with tidily placed
dimensions.
2016-04-23 04:38:32 +00:00
whitequark
1142f85ff5 Fix edit control width calculation on GTK3.
Also, bring the GTK2 width calculation in line with the GTK3 one.
2016-04-23 04:38:32 +00:00
whitequark
6cb6a2cf27 Forcibly show text window on some context menu actions.
Specifically:
  * Group Info
  * Style Info
  * Assign to Style → Newly Created Custom Style...

These context actions are meaningless without viewing or manipulating
text window.
2016-04-23 04:38:32 +00:00
whitequark
a61544ea9c Fix empty space at the end of the tooltips.
Also, bring MakeAcceleratorLabel to modernity.
2016-04-23 04:38:32 +00:00
EvilSpirit
accd73fe02 Improve rendering of workplane stipple lines.
After this commit, a workplane perpendicular to the camera is
rendered with all dashes aligned, making it look more tidy.
2016-04-17 03:11:19 +00:00
whitequark
efb9fa3d69 Actually display the "zero-length edge!" polygon error.
Before this commit, the initial state allCoplanar=false took
precedence over allNonZeroLen=false, since detecting a zero-length
edge short-circuits AssembleLoops.
2016-04-17 01:33:15 +00:00
whitequark
b3df595769 Don't crash after right-clicking on derived entities. 2016-04-17 01:16:47 +00:00
EvilSpirit
a4a353f01b Reverse arrows on an angle constraint when the label is outside. 2016-04-16 12:05:10 +00:00
EvilSpirit
3b7e7289c8 Continue an extension arc towards angle constraint label. 2016-04-16 09:05:21 +00:00
EvilSpirit
92f5bd450c Display angle in the middle of its dimension line, not adjacent.
Less visual clutter and more consistency with distance constraints.
2016-04-16 09:05:21 +00:00
EvilSpirit
07f3ab95e4 Draw extension lines for angle constraints between line segments. 2016-04-16 09:05:21 +00:00
whitequark
1098e598ae Quit export mode after new file. 2016-04-16 09:05:21 +00:00
whitequark
6b123f2d34 Refactor Style::LoadFactoryDefaults.
This also fixes a bug where the hidden-edge style would be reset
to continuous when factory defaults are loaded.
2016-04-16 05:49:37 +00:00
whitequark
a7f4d0fffc Fully reinitialize graphics window in AfterNewFile().
Before this commit it was possible to cause a crash by e.g. selecting
a face and pressing Ctrl+N, or numerous other glitches.
2016-04-16 04:19:14 +00:00
EvilSpirit
e74ccb3010 Perform grid fitting on the builtin vector font.
Grid fitting is performed only on glyph boundaries, since glyphs
include curves converted to pwl, which would be mangled by per-point
grid fitting.

Grid fitting is only performed when the plane in which text is
laid out is parallel to the viewing plane.

Grid fitting is only performed when rendering for display; there
are no devices with dpi low enough for grid fitting to become
profitable, and in any case we cannot predict what the dpi would
be anyway.
2016-04-16 04:19:14 +00:00
EvilSpirit
bd6c4c0cbd Use 16-bit integers to store builtin vector font data.
This significantly increases font legibility, since curves are
represented more precisely. The file size is increased by mere ~1M
(from 7M).
2016-04-16 03:10:56 +00:00
whitequark
0128b86796 Improve builtin vector font positioning.
First, a larger origin offset is applied in ssglWriteText. This moves
the text so that it doesn't overlap the workplane boundary.

Second, a different offset is applied in ssglWriteTextRefCenter.
After this, the middle stroke of "E" is vertically aligned with
the reference point, and the overall label is horizontally aligned
with the reference point more precisely.
2016-04-16 03:10:56 +00:00
whitequark
bcb484e941 Do not display trailing zeroes for integer angles.
Angles that aren't an integral number of degrees are extremely
rare, and the label is often in a tight space, which warrants
special-casing this.
2016-04-16 03:10:56 +00:00
whitequark
7a01c840d3 Display and edit length difference constraints as lengths.
Before this commit, they worked sort of like length ratio
constraints, leading to wildly incorrect results in inch mode.
2016-04-16 03:10:56 +00:00
whitequark
bd51a9edac Use the Unicode diameter symbol ⌀ in diameter constraints.
Before this commit, the diameter symbol was drawn using custom code,
which is not necessary anymore.
2016-04-16 03:10:56 +00:00
whitequark
23dc36da9b Make graphics window edit control width fit the content.
Before this commit, the graphics window edit control always had
a width of 30 average character widths.

After this commit, the edit control has a width of 5 average
character widths (for numeric constraints) or 30 average character
widths (for comment constraints), or just enough to display
the entire value being edited, whichever is greater.

This makes the edit control overlap the sketch less in case of
editing numeric constraints (since in most cases, the numbers being
edited are short), and removes annoying scrolling in case of editing
long comments.
2016-04-16 03:10:56 +00:00
whitequark
d17771064a Ensure edit control font size matches font size of text being edited.
Before this commit, the position of the edit box was adjusted
by trial and error, as far as I can tell. This commit changes
the positioning machinery for edit controls as follows:

The coordinates passed to ShowTextEditControl/ShowGraphicsEditControl
now denote: X the left bound, and Y the baseline.

The font height passed to ShowGraphicsEditControl denotes
the absolute font height in pixels, i.e. ascent plus descent.

Platform-dependent code uses these coordinates, the font metrics
for the font appropriate for the platform, and the knowledge of
the decorations drawn around the text by the native edit control
to position the edit control in a way that overlays the text inside
the edit control with the rendered text.

On OS X, GNU Unifont (of height 16) has metrics identical to
Monaco (of height 15) and so as an exception, the edit control
is nudged slightly for a pixel-perfect fit.

Also, since the built-in vector font is proportional, this commit
also switches the edit control font to proportional when editing
constraints.
2016-04-15 21:53:08 +00:00
whitequark
0f304b4c64 Rigorously treat font scale factors.
The old values were chosen without a good understanding of font
metrics.
2016-04-15 21:53:08 +00:00
whitequark
e7057418df When there's a shell, always render solids using sharp edges solids.
Before this commit, solids in the viewport were rendered with
"emphasized edges", with the intention to highlight selectable faces.
However, selectable faces are already surrounded by entities, and
so rendering emphasized edges adds little value.

After this commit, solids in the viewport are always rendered with
"sharp edges", like they are exported.
2016-04-15 21:53:08 +00:00
EvilSpirit
24fc65a71c Allow rendering solid outlines using a distinct style.
A new button is added, "Show/hide outline of solid model".

When the outline is hidden, it is rendered using the "solid edge"
style. When the outline is shown, it is rendered using the "outline"
style.

In SolveSpace's true WYSIWYG tradition, the 2d view export follows
the rendered view exactly.

Moreover, shell edges are not rendered anymore, since there is not
much need in them anymore and not drawing them lessens the overlap
between various kinds of lines, which already includes entities,
solid edges and outlines.
2016-04-15 21:53:08 +00:00
EvilSpirit
d1a2eb6d18 Allow rendering hidden solid edges using a distinct style.
Before this change, the two buttons "Show/hide shaded model" (S) and
"Show/hide hidden lines" (H) resulted in drawing the following
elements in the following styles:

  Button | Non-occluded | Non-occluded |  Occluded   |   Occluded
  state  | solid edges  |   entities   | solid edges |   entities
 --------+--------------+--------------+-------------+--------------
  !S !H  |              |              | solid-edge  | entity style
 --------+              |              +-------------+--------------
   S !H  |              |              |         invisible
 --------+  solid-edge  | entity style +-------------+--------------
  !S  H  |              |              |             |
 --------+              |              | solid-edge  | entity style
   S  H  |              |              |             |
 --------+--------------+--------------+-------------+--------------

After this change, they are drawn as follows:

  Button | Non-occluded | Non-occluded |  Occluded   |   Occluded
  state  | solid edges  |   entities   | solid edges |   entities
 --------+--------------+--------------+-------------+--------------
  !S !H  |              |              | solid-edge  | entity style
 --------+              |              +-------------+--------------
   S !H  |              |              |         invisible
 --------+  solid-edge  | entity style +-------------+--------------
  !S  H  |              |              |             |
 --------+              |              | hidden-edge |  stippled¹
   S  H  |              |              |             |
 --------+--------------+--------------+-------------+--------------

  ¹ entity style, but the stipple parameters taken from hidden-edge

In SolveSpace's true WYSIWYG tradition, the 2d view export follows
the rendered view exactly.

Also, it is now possible to edit the stipple parameters of built-in
styles, so that by changing the hidden-edge style to non-stippled
it is possible to regain the old behavior.
2016-04-15 21:53:08 +00:00
EvilSpirit
d55300232f Don't generate each edge twice in MakeCertainEdgesInto.
This messes up edges when they are rendered stippled, and
unnecessarily makes exported files bigger.
2016-04-15 21:53:08 +00:00
EvilSpirit
1bf7777815 Only export sharp edges of the triangle mesh.
Before this commit, "emphasized edges" were displayed as well as
exported. An "emphasized edge" is an edge between triangles that
come from different faces. They are helpful in the rendered
display because they hint at the locations of faces, but not
in the 2d export since they just clutter the drawing.

After this commit, "emphasized edges" are displayed but "sharp
edges" are exported. A "sharp edge" is an edge between triangles
where the two matching vertexes have different normals, indicating
a discontiguity in the surface. "Sharp edges" are also displayed
while post-viewing the exported geometry.
2016-04-15 21:53:08 +00:00
EvilSpirit
7e6a11c958 Refactor SKdNode::FindEdgeOn.
Extract output parameters into a separate structure.
2016-04-15 21:53:08 +00:00
EvilSpirit
7c60be8203 Remove overlapping line segments when exporting a 2d view.
This adds a new style attribute, "Z-index", which is not currently
displayed and cannot be modified. It may be exposed in the UI later.
2016-04-15 21:53:08 +00:00
EvilSpirit
16ea824456 Allow adding spline points. 2016-04-15 06:11:03 +00:00
EvilSpirit
77d8291216 Allow removing spline points. 2016-04-15 06:11:03 +00:00
whitequark
2d25bdb51f When choosing color for a new group, consider active, not last, group. 2016-04-15 06:11:03 +00:00
EvilSpirit
98e0a30a98 Consider plane faces when zooming to fit. 2016-04-15 06:11:03 +00:00
whitequark
83f5b60228 Fix a macro redefinition warning.
Including windows.h defines "IN".
2016-04-15 06:11:03 +00:00
EvilSpirit
09f59ddbc0 Get rid of if(!this).
According to the C++ standard, "this" is never NULL, so checks
of the form "if(!this)" can be legally optimized out. This
breaks SolveSpace on GCC 6, and probably on other compilers and
configurations.
2016-04-15 06:11:03 +00:00
whitequark
11565e081d Refactor export code to pass around hStyle, not uint32_t. 2016-04-14 18:54:09 +00:00
EvilSpirit
27b403faf5 DXF: refactor. 2016-04-14 18:54:09 +00:00
EvilSpirit
f88cb1195b DXF: split entities by layers according to their line styles. 2016-04-14 18:54:09 +00:00
EvilSpirit
d88149e705 SVG: export stippled lines.
Also, factor out styles in the exported file, making it much
smaller.
2016-04-14 18:54:09 +00:00
EvilSpirit
94cba11f2a PDF, EPS: export stippled lines. 2016-04-08 11:32:16 +00:00
EvilSpirit
a6f7200092 Display point-circle or point-arc distance, when selected. 2016-04-08 11:21:51 +00:00
EvilSpirit
55e3162a05 When creating a new group, use the color of last requested solid. 2016-04-08 11:21:40 +00:00
EvilSpirit
29296447a9 Add the Ukrainian letters [ЄІЇєіїҐґ] to builtin vector font. 2016-04-08 11:01:29 +00:00
EvilSpirit
d72b250a64 Don't draw zero-length lines.
Causes "Vector::WithMagnitude(...) of zero vector!"
2016-04-08 10:55:31 +00:00
EvilSpirit
e19a2f4f35 Accept maybeFat in ssglStippledLine. 2016-04-08 10:55:11 +00:00
whitequark
1e0fcf1e6c OS X: bundle Freetype.
I erroneously believed that Freetype was shipped with OS X, whereas
it is not, and so we need to ship it ourselves.
2016-04-08 10:47:25 +00:00
EvilSpirit
46b67d5457 Three.js: apply export scale factor to edges. 2016-04-08 10:19:55 +00:00
EvilSpirit
e17a24814b DXF: only export visible constraints. 2016-04-08 10:15:29 +00:00
EvilSpirit
73f28b9731 Make normals and workplanes non-stylable.
This does not seem to have any useful application, and it can
result in odd misrenderings with some styles.
2016-04-08 10:12:28 +00:00
EvilSpirit
614902ebdd Don't create multiple undo steps when pasting. 2016-04-08 09:54:46 +00:00
EvilSpirit
3d334d153d Disable autoconstrainer while Ctrl is held. 2016-04-08 09:51:10 +00:00
whitequark
6f67ec2d48 GTK: make the file filter hack more robust. 2016-03-25 11:08:04 +00:00
whitequark
fb0aee91ea Add a degree symbol to angle constraints. 2016-03-23 14:16:17 +00:00
whitequark
63d48e7840 Update README. 2016-03-19 16:36:07 +00:00
whitequark
c061fb9416 Restore sensible order of group creation toolicons.
They now have a similar function within each row.
2016-03-19 13:24:52 +00:00
whitequark
762af7d2ad Regenerate the sketch after allowing redundant constraints. 2016-03-18 20:46:46 +00:00
whitequark
7c2200584a Update README: update prerequisites for OS X. 2016-03-18 20:24:17 +00:00
Adam Jaremko
b76d7026e0 OS X: Fix iconutil build error.
Fix iconutil build errors: “Iconset contains no image resources.”,
followed by “Failed to generate ICNS.”

The error is produced by iconutil because the AppIcon.iconset contains
only symbolic links to the icon resources which aren’t followed.

Replace the symbolic links with duplicates of the original resources,
as well as conform to the “High Resolution Guidelines for OS X” by
adding additional sizes and dpi.
2016-03-17 00:31:32 -04:00
whitequark
4376f178fc Update README: add instructions for checking out libdxfrw on *nix. 2016-03-16 20:58:02 +00:00
whitequark
e87e787d3f Add "Paste Transformed..." to context menu, when applicable. 2016-03-15 12:11:00 +00:00
whitequark
6e56b00b9a Don't perform hit testing if we haven't painted the graphics window.
This change is quite subtle. The goal is to improve responsiveness
of highlighting even further. To understand this change you need
to keep in mind that Windows and Gtk have dramatically different
behavior for paint (WM_PAINT in Windows, expose in Gtk) and
mouse move events.

In Windows, WM_PAINT and WM_MOUSEMOVE, unless sent explicitly,
are synthesized: WM_MOUSEMOVE is delivered when there are no other
messages and the current cursor position doesn't match the remembered
one, and WM_PAINT is delivered when there are no other messages,
even WM_MOUSEMOVE. This is pretty clever because it doesn't swamp
programs that are slow to process either of those events with even
more of them, ensuring they remain responsive.

In Gtk, expose events are delivered at the end of the frame whenever
there is an invalid view, and every single mouse move that happened
will result in a separate event.

If mouse move events are handled quickly, then the behavior is
identical in either case:
  * process mouse move event
    * perform hit testing
    * invalidate view
  * no more events to process!
    * there are invalid views
      * repaint

If, however, mouse move events are handled slower, then the behavior
diverges. With Gtk:
  * process mouse move event
    * perform hit testing (slow)
      * while this happens, ten more mouse move events are added
    * invalidate view
  * end of frame!
    * there are invalid views
      * repaint
  * process mouse move event...
As a result, the Gtk-hosted UI hopelessly lags behind user input.
This is very irritating.

With Windows:
  * process mouse move event
    * perform hit testing (slow)
      * while this happens, mouse was moved
    * invalidate view
  * process mouse move event...
As a result, the Windows-hosted UI never repaints while the mouse
is moved. This is also very irritating.

Commit HEAD^ has fixed the problems with Gtk-based UI by making
hit testing so fast that mouse move events never quite overflow
the queue. There's still a barely noticeable lag but it's better.

However, the problems with Windows remained because while the queue
doesn't *overflow* with the faster hit testing code, it doesn't go
*empty* either! Thus we still don't repaint.

This commit builds on top of HEAD^ and makes it so that we don't
actually hit test anything if we haven't painted the result of
the previous hit test already. This fixes the problem on Windows
but also helps Gtk a little bit.

Curiously, the Cocoa-based UI never suffered from any of these
problems. To my understanding (it's somewhat underdocumented), it
processes mouse moves like Windows, but paints like Gtk.
2016-03-07 16:03:20 +00:00
whitequark
bda2835e9f Cache bounding boxes.
This results in massive performance improvements for hit testing.
Files with very large amounts of entities (e.g. [1]) inflict
a delay of several seconds between moving the pointer and
highlighting an entity in commit HEAD^^^, whereas in this commit
the delay is barely perceptible.

[1]: http://solvespace.com/forum.pl?action=viewthread&parent=872
2016-03-05 16:48:56 +00:00
EvilSpirit
e99eedd7a3 Check entity bounding box before hit testing edges. 2016-03-05 16:48:56 +00:00
EvilSpirit
b054b9682a Cache generated bezier curves and edges in Entity. 2016-03-05 16:48:16 +00:00
EvilSpirit
a0576e2a50 Allow changing text size for default styles.
This is especially useful for High-DPI displays on non-OS X.
2016-03-05 12:02:13 +00:00
EvilSpirit
96344c85a6 Eliminate DEFAULT_TEXT_HEIGHT from drawing code.
Instead, query the text height for constraint style.
2016-03-05 12:02:13 +00:00
EvilSpirit
1f0649d1bb Remove merge artifact. 2016-03-05 12:02:13 +00:00
EvilSpirit
1814cf3c0f DXF: export stippled line styles. 2016-03-05 12:02:13 +00:00
EvilSpirit
1170a91875 Implement stippled line styles from ISO 128.
Now it's possible to use a styled line to indicate e.g.
a centerline.
2016-03-05 12:02:13 +00:00
EvilSpirit
171f208cfb Extract Style::FillDefaultStyle. 2016-03-04 15:13:09 +00:00
whitequark
c9a2092b9c Fix image export on *nix.
Before this commit, trying to export image on *nix platforms yielded
a black rectangle, since since there is nowhere to render to
when we're not in a GUI toolkit draw callback.

On Windows, nothing changes: we do a repaint without the toolbar,
glReadPixels, export. On *nix, we create another offscreen rendering
context, render into it, then destroy it. As a bonus this avoids
some minor flickering that would happen if we reused the regular
rendering path.
2016-03-04 15:11:14 +00:00
EvilSpirit
a886746e71 DXF: export entities, dimensions and comments on separate layers. 2016-02-19 23:16:36 +00:00
EvilSpirit
df0a1d64e4 DXF: include compatible AutoCAD version in format selector. 2016-02-19 23:16:36 +00:00
EvilSpirit
f87152e8c0 DXF: export constraints with labels as DXF constraints, not pwl.
Specifically, the following constraint types:
  * pt-pt-distance
  * pt-line-distance
  * diameter
  * angle
  * comment
2016-02-19 23:16:36 +00:00
EvilSpirit
e377eb8851 DXF: export color and line width. 2016-02-19 23:16:36 +00:00
EvilSpirit
3fdfca10f6 DXF: export non-rational beziers as splines instead of pwl. 2016-02-19 23:16:36 +00:00
EvilSpirit
c469af6600 DXF: rewrite DxfFileWriter using libdxfrw. 2016-02-19 23:16:36 +00:00
whitequark
20a041e0ef DXF: initial libdxfrw import.
We had to fork libdxfrw since the upstream doesn't have a git
repository, a CMake buildsystem, and is quite buggy.

libdxfrw is also used in LibreCAD, but they just vendored
their version.
2016-02-19 23:16:36 +00:00
EvilSpirit
a71d5894aa Draw extension lines from pt-line-distance to line ends.
Before this commit, if a pt-line-distance constraint is placed so
that the dimension line doesn't touch the line, no extension is
drawn. After this commit, an extension line will be drawn towards
the nearest end of the line.
2016-02-19 23:00:35 +00:00
whitequark
b3fa8dca37 Allow removing active group.
This is an artificial restriction that serves no useful purpose.
Just switch to the previous group if asked to delete the current
one.

The ClearSuper() calls are reshuffled, since TW.ClearSuper() calls
TW.Show() and so has to be called while the sketch is still valid,
whereas GW.ClearSuper() also recreates the default group and thus
it should be called after the first RemoveById+GenerateAll pair,
or it'll recreate the default group before the entities on it have
a chance to be pruned.
2016-02-19 10:23:24 +00:00
whitequark
27d0dedbd1 Add new group after active group, not after all groups. 2016-02-19 10:23:24 +00:00
whitequark
c9648805ea Allow generating groups in arbitrary order. 2016-02-19 10:23:24 +00:00
EvilSpirit
df87ac6e6f Preserve entity visibility while switching active group.
Switching active group by itself is not an editing but a viewing
action; the active group is not recorded in the savefile. However,
the entity visibility status is, and this is annoying when source
control is used, because e.g. looking up dimensions in one of
the inner groups whose display was turned off ends up changing
the savefile.

When the display has to be turned on manually, this modification
of the file becomes explicit, so there's no longer any question
of what action modified the file.

This can also be convenient when inserting a group in the middle
of the stack, which will be implemented in the future.
2016-02-19 10:23:24 +00:00
whitequark
d4ecf155f6 Include invisible entities when calculating BBox for chord tolerance.
Otherwise, loading a file with all entities invisible becomes
pathologically slow.
2016-02-19 10:23:24 +00:00
whitequark
bdd02ac3a8 Fix usage of uninitialized BBox. 2016-02-19 10:23:24 +00:00
whitequark
cd6d891100 Use U+FFFD instead of crashing when encountering unknown characters.
Also, use a nicer U+FFFD glyph in the builtin vector font.
2016-02-19 10:23:23 +00:00
whitequark
923374b305 Set the correct scale for vector font.
This was adjusted so that the height of "A" when exported to a vector
file would be 10mm in a style configured for 10mm font height.
2016-02-19 10:22:53 +00:00
whitequark
5c15cbf5f6 Remove extraneous instances of .c_str().
Most of these were just converting char* into std::string back and
forth; some more used ReadUTF8, which was converted to use nicer
STL-style iterators over UTF-8 text.

The remaining ones are:
  * arguments to Expr::From, which we'll change when refactoring
    the expression lexer;
  * arguments to varargs functions, which we'll change when adding
    localization (that requires custom printf-style functions to
    allow for changing argument order);
  * arguments where only string literals are ever passed, which
    are OK;
  * in platform-specific code, which is OK.
2016-02-19 10:22:53 +00:00
whitequark
a1a624da12 Rigorously treat quoting in CMake.
CMake can properly quote inputs to custom commands itself; this is
governed by the VERBATIM flag. If we pass this flag, no quoting
needs to be done except for compiler/linker flags and diagnostic
messages, as CMake doesn't treat whitespace expanded from variables
the same way it treats whitespace that separates arguments.
2016-02-19 10:22:51 +00:00
whitequark
575146b975 Use GNUInstallDirs CMake module when installing files.
This should handle platform conventions more correctly, especially
on 64-bit or multiarch systems.
2016-02-17 06:23:01 +00:00
whitequark
7c2ec8f80e Always build in C++11 mode on GCC and Clang.
This will weed out compilers that are too old to build our code
(among others, recent gtkmm and glibmm have a hard dependency on
C++11, not even C++0x) and also properly communicate our wish to GCC
(Clang defaults to C++11 these days).
2016-02-15 20:08:46 +00:00
whitequark
f20a044837 CI: Use Ubuntu Trusty for Travis builds.
Trusty has newer software and most importantly GCC with proper C++11
support, not just C++0x.
2016-02-15 19:58:14 +00:00
EvilSpirit
cf38bdfebd Only consider selected entities, when any, when doing Zoom to Fit.
Scoped "Zoom to Fit" is convenient for working on large models.
I (whitequark) have considered a separate shortcut, but its
usefulness is unclear and in any case it can be easily added
if desired.
2016-02-14 14:29:47 +00:00
EvilSpirit
dd5feb5724 Refactor Point2d to take advantage of const correctness. 2016-02-14 14:29:47 +00:00
whitequark
29ad1acdfe Enable and mollify -Wunused-variable.
In my (whitequark's) experience this warning tends to expose
copy-paste errors with a high SNR, so making a few fragments
slightly less symmetric is worth it.

Also mollify -Wlogical-op-parentheses while we're at it.
2016-02-14 14:29:47 +00:00
whitequark
d43bd93060 Only consider groups until active when checking for solver failure.
After commit 2f734d9, inactive groups are no longer regenerated
for trivial changes, e.g. changing parameters, so it's possible to
switch to an earlier group and work on it without incurring
the computational (slowdown) and cognitive (annoyance by red
background) overhead of later groups failing to solve.

However, if a group--any group anywhere--was not solved OK,
the interface reacted accordingly, which diminished usefulness of
the change, especially given that, if we have groups A and B with
B depending on A, if B is broken by a change in A and we activate A
and fix it, B will not be regenerated.

After this commit, only active groups are considered when deciding
if generating the entire sketch would fail.
2016-02-14 14:09:36 +00:00
EvilSpirit
57fb3bf3dc Replace internal vector font with LibreCAD's GPLv2+ vector font.
This font is less complete than our bitmap font, Unifont: Unifont
has essentially complete Unicode coverage and LibreCAD's font only
has Latin, Cyrillic and Japanese, but it can be extended rather
easily, so this should be fine for now.

These embedded fonts fatten glhelper.o quite a bit:
bitmapfont.table.h is about 8M in gzip-compressed bitmaps and
vectorfont.table.h is about 2M in raw vector data.
In spite of that it takes just around five seconds to build
glhelper.c on my laptop, so it should be fine.

The final executable grows from about 2M to about 8M, but this
is a small price to pay for fairly extensive i18n support.

The new font has somewhat different metrics, so the rendering
code has been fudged to make it look good.
2016-02-14 14:09:36 +00:00
Peter Barfuss
784f3e5548 Rewrite TTF to Bezier conversion using Freetype.
Benefits:
  * Much simpler code.
  * Handles the entire TTF spec, not just a small subset that
    only really worked well on Windows fonts.
  * Handles all character sets as well as accented characters.
  * Much faster parsing, since Freetype lazily loads and
    caches glyphs.
  * Support for basically every kind of font that was invented,
    not just TTF.

Note that OpenType features, e.g. ligatures, are not yet supported.
This means that Arabic and Devanagari scripts, among others, will
not be rendered in their proper form.

RTL scripts are not supported either, neither in TTF nor in
the text window. Adding RTL support is comparatively easy, but
given that Arabic would not be legibly rendered anyway, this is not
done so far.
2016-02-13 21:08:18 +00:00
whitequark
e5294eef9d Add freetype dependency.
We are going to use freetype instead of the old custom TTF parser,
since the old parser has many annoying bugs when handling non-Latin
fonts and fixing it is not really worth the time.

On Windows, Freetype is built from a submodule.
On Linux and OS X, Freetype is provided together with the desktop,
though development files have to be installed separately.
2016-02-13 21:08:18 +00:00
EvilSpirit
f82767ae79 Break the dependency between an imported group and its parent.
Per correspondence with Jonathan the dependency serves no
useful purpose. It also prevents safely deleting groups preceding
imported groups.
2016-02-13 21:08:18 +00:00
EvilSpirit
34a5d87011 Use relative chord tolerance instead of absolute.
Commit 89eb208 has improved the overall situation with chord
tolerance, but it changed the display chord tolerance to use
an absolute value in millimeters as a stopgap measure.

This commit changes the display chord tolerance to be specified
in percents of entity bounding box instead of millimeters.
As a result, the linearized curves are both zoom level and sketch
scale independent.

In order to compute the bounding box, all entities are generated
twice. However, this shouldn't result in a noticeable slowdown,
since the bounding box calculation does not need the expensive
triangle mesh generation and the solver will converge immediately
on the second run.

Since the meaning of the preference has changed, a new name is
used (ChordTolerancePct instead of ChordTolerance), so that it
would be reset to the default value after updating SolveSpace.

The default value, 0.5%, was selected using trial and error by
judging whether cylinders of moderate dimensions were looking
aesthetically pleasing enough.

After this change, the only real function of the spacebar
shortcut is to reload imported groups, since manual regeneration
should not change anything anymore unless there is a bug.
2016-02-13 16:16:56 +00:00
EvilSpirit
fc68804f65 Add BBox class for calculating entity bounding boxes. 2016-02-13 16:16:47 +00:00
EvilSpirit
89eb208660 Use a separate value of chord tolerance for exporting.
Before this commit, a single chord tolerance was used for both
displaying and exporting geometry. Moreover, this chord tolerance
was specified in screen pixels, and as such depended on zoom level.
This was inconvenient: exporting geometry with a required level of
precision required awkward manipulations of viewport. Moreover,
since some operations, e.g. mesh watertightness checking, were done
on triangle meshes which are generated differently depending on
the zoom level, these operations could report wildly different
and quite confusing results depending on zoom level.

The chord tolerance for display and export pursue completely distinct
goals: display chord tolerance should be set high enough to achieve
both fast regeneration and legible rendering, whereas export chord
tolerance should be set to match the dimension tolerance of
the fabrication process.

This commit introduces two distinct chord tolerances: a display
and an export one. Both chord tolerances are absolute and expressed
in millimeters; this is inappropriate for display purposes but
will be fixed in the next commits.

After exporting, the geometry is redrawn with the chord tolerance
configured for the export and an overlay message is displayed;
pressing Esc clears the message and returns the display back to
normal.
2016-02-13 16:16:47 +00:00
EvilSpirit
139dd80b48 Improve Bezier to piecewise linear conversion.
Instead of always using two points on every curve, with a hack for
some cubics edge case, use three points on the first iteration and
one point on every further iteration. This both faster and more
correct.
2016-02-13 16:16:47 +00:00
whitequark
1e2a899ba2 Avoid spurious double to float conversion.
MSVC (mostly rightly) complains about this, even if our particular
case is irrelevant.
2016-02-12 05:26:26 +00:00
whitequark
8c83a4a212 Use size_t for indexing where appropriate.
MSVC (rightly) complains about this.
2016-02-12 05:26:26 +00:00
whitequark
062344e40d Define _SCL_SECURE_NO_WARNINGS on Windows.
This is required to squash warnings about 'checked iterators'.
Regardless of their utility we can't use them on other platforms,
so we don't care.
2016-02-12 05:00:29 +00:00
whitequark
f3b232238c Remove mention of Launchpad PPA from README.
I do not update it anymore and it's probably not the best solution
for distributing SolveSpace on Linux. In the meantime, the builds
from GitHub releases should be convenient enough.
2016-02-10 12:06:30 +00:00
whitequark
293eedc85e Add command-line Windows build instructions to README. 2016-02-10 10:48:42 +00:00
EvilSpirit
b28fa34e4a Use an enum to select the mode of operation for GenerateAll. 2016-01-27 09:19:37 +00:00
EvilSpirit
2f734d9cfa When explicitly regenerating groups, only generate until active group.
Before this change, groups and their meshes were generated even past
the active group, which, in cause the mesh was broken, caused red
marks to appear for no apparent reason. Furthermore, it unnecessarily
slows down regeneration.
2016-01-27 09:14:00 +00:00
EvilSpirit
76d582720a Don't calculate halfRow for ShowEditControl manually.
Instead, grab it from hoveredRow, since almost always (with only one
exception) this is where the edit control has to be shown.

This makes it much easier to adjust views, e.g. add a new editable
field in the middle of configuration view, because it's not necessary
to manually change and test all the indexes below the row being
changed.

Additionally, it removes a lot of awkward and opaque row calculations.
2016-01-27 09:09:18 +00:00
EvilSpirit
fd0b7fbc29 Update remaining sprintf calls with a stack buffer to use ssprintf.
The commit 11f29b123 has replaced most of the uses of sprintf,
but there were still many remaining in Screen* functions, and it
was annoyingly inconsistent. Moreover, while most usage of sprintf
there was fine, it is bad hygiene to leave stack overflow prone
code around.
2016-01-27 09:09:18 +00:00
EvilSpirit
b7409b8ad6 Rework SAVEDptr to be a struct with accessors instead of an union.
It's not possible to put non-POD elements in a union, and a struct
with accessors is a more elegant solution than a union with POD
elements and explicit casts for the rest.
2016-01-27 09:09:18 +00:00
EvilSpirit
3af4e1c5b0 Define NOMINMAX for Windows builds.
Without #define NOMINMAX, <windows.h> defines min and max as macros,
which shadows the definitions from <algorithm> and makes them
unusable with multiple arguments.
2016-01-27 09:09:18 +00:00
whitequark
46ab541444 Add a setting that permits a group to include redundant constraints.
This setting is generally useful, but it especially shines when
assembling, since the "same orientation" and "parallel" constraints
remove three and two rotational degrees of freedom, which makes them
impossible to use with 3d "point on line" constraint that removes
two spatial and two rotational degrees of freedom.

The setting is not enabled for all imported groups by default
because it exhibits some edge case failures. For example:
  * draw two line segments sharing a point,
  * constrain lengths of line segments,
  * constrain line segments perpendicular,
  * constrain line segments to a 90° angle.

This is a truly degenerate case and so it is not considered very
important. However, we can fix this later by using Eigen::SparseQR.
2016-01-22 08:53:04 +00:00
EvilSpirit
2b388e7da4 Try to solve even very overconstrained systems.
Before this commit, overconstraining a system past a certain point
resulted in a wrong error message: instead of "redundant constraints",
"unsolvable constraints" was displayed.

To reproduce, place more six or more length constraints with the same
value onto the same line segment.
2016-01-22 07:41:30 +00:00
EvilSpirit
804761da88 Distinguish overconstrained and redundantly constrained sketches.
When a solver error arises after a change to the sketch, it should
be easy to understand exactly why it happened. Before this change,
two functionally distinct modes of failure were lumped into one:
the same "redundant constraints" message was displayed when all
degrees of freedom were exhausted and the had a solution, but also
when it had not.

To understand why this is problematic, let's examine several ways
in which we can end up with linearly dependent equations in our
system:
  0) create a triangle, then constrain two different pairs of edges
     to be perpendicular
  1) add two distinct distance constraints on the same segment
  2) add two identical distance constraints on the same segment
  3) create a triangle, then constrain edges to lengths a, b, and c
     so that a+b=c

The case (0) is our baseline case: the constraints in it make
the system unsolvable yet they do not remove more degrees of freedom
than the amount we started with. So the displayed error is
"unsolvable constraints".

The constraints in case (1) remove one too many degrees of freedom,
but otherwise are quite like the case (0): the cause of failure that
is useful to the user is that the constraints are mutually
incompatible.

The constraints in cases (2) and (3) however are not like the others:
there is a set of parameters that satisfies all of the constraints,
but the constraints still remove one degree of freedom too many.

It makes sense to display a different error message for cases (2)
and (3) because in practice, cases like this are likely to arise from
adjustment of constraint values on sketches corresponding to systems
that have a small amount of degenerate solutions, and this is very
different from systems arising in cases like (0) where no adjustment
of constraint values will ever result in a successful solution.
So the error message displayed is "redundant constraints".

At last, this commit makes cases (0) and (1) display a message
with only a minor difference in wording. This is deliberate.
The reason is that the facts "the system is unsolvable" and
"the system is unsolvable and also has linearly dependent equations"
present no meaningful, actionable difference to the user, and placing
emphasis on it would only cause confusion.

However, they are still distinguished, because in case (0) we
list all relevant constraints (and thus we say they are "mutually
incompatible") but in case (1) we only list the ones that constrain
the sketch further than some valid solution (and we say they are
"unsatisfied").
2016-01-21 14:15:05 +00:00
whitequark
c011444045 Perform rank test after solving the system.
Before this change, it was possible to adjust constraints in a way
that removes a degree of freedom and makes the sketch unsolvable,
but rank test was performed before solving the system, and an error
was not displayed immediately. Instead, a solution would seemingly
be found, but it would be very unstable--unrelated changes to
the sketch would cause rank test to fail.

To reproduce the bug, do this:
  * Draw a triangle.
  * Create a length constraint for all sides.
  * Set side lengths to a, b, and c such that a + b = c.
  * Add a line segment.
2016-01-21 12:39:22 +00:00
whitequark
55cde18c5a Reword error messages that are displayed when a group fails to solve.
The current messages accurately reflect what happens to the system
of equations that represents the sketch, but can be quite confusing
to users that only think in terms of the constraints.

We use "unsolvable" and not "impossible" because while most of
the cases that result in this error message will indeed stem from
mutually exclusive sets of constraints, it is still possible that
there is some solution that our solver is unable to find using
numeric methods.
2016-01-21 12:39:18 +00:00
whitequark
30d9bb0479 Add lathe button to toolbar. 2016-01-18 05:31:31 +00:00
whitequark
ef5db2132e Ignore text window scroll events if edit control is visible.
After commit 11f29b12, we no longer have a convenient way to indicate
that the edit control should be moved without changing its contents;
the old code trying to do this caused a crash, since constructing
an std::string from a NULL char* is invalid.

This went undetected during testing, since on Linux, recent
GTK versions will munge scroll events while the edit box has
a modal grab.

I could've fixed the feature, but opted to remove it, since being able
to scroll the edit box out of visible region is more likely to result
in confusion than ever be useful.
2016-01-13 11:55:45 +00:00
whitequark
5e5ef3be3e Build Debian packages with debug symbols. 2016-01-13 06:45:17 +00:00
whitequark
28a6e04f33 Ask the user to locate imported files if they cannot be loaded. 2016-01-13 06:45:17 +00:00
whitequark
54d8957bfe Only advise to Edit -> Undo if undo stack is not empty. 2016-01-13 06:45:17 +00:00
whitequark
86315b2b1f Allow exporting Three.js either as bare mesh or mesh with viewer.
Most people just want a single self-contained .html file, but more
advanced usage will involve embedding in a webpage, where the default
viewer would be copied and customized, and fed with bare mesh export.
2016-01-13 06:45:17 +00:00
whitequark
750842610c Simplify file saving code.
There is no need to record default file format choice, as
the first one is selected when an empty string is passed.
2016-01-13 06:45:17 +00:00
whitequark
259d8e0d38 Remember last used file type for all export dialogs. 2016-01-13 06:45:17 +00:00
whitequark
310fa9a817 Export vertex normals, not just face normals, for Three.js.
This causes NURBS models to render smoothly, like they do
in SolveSpace itself.
2016-01-13 06:45:17 +00:00
whitequark
1160b5d335 Fix OS X build. 2016-01-13 06:45:17 +00:00
EvilSpirit
6dced8052b Generate primitives for lathe groups.
The primitives that are generated are circles from points and
faces from axis-perpendicular line segments.
2016-01-13 06:45:17 +00:00
EvilSpirit
9c4d1cb9b0 Remove unused Expr operations ENTITY and POINT.
These weren't even used in any code, only defined.
2016-01-13 06:45:17 +00:00
EvilSpirit
c5082f73a4 Remove unused field Expr::marker. 2016-01-13 06:45:17 +00:00
EvilSpirit
84a6511cfc Simplify layout of Expr.
Make the union anonymous so that its elements can be addressed
directly. Then, move the Expr *b field into the union, as it
already is never used at the same time as any of the union members.
2016-01-13 06:45:17 +00:00
EvilSpirit
158c66b1b4 Do not pass objects to Printf.
This seems to have worked by accident everywhere.
Interestingly, clang -Wall did not warn about this, but MSVC did.
2016-01-13 06:45:17 +00:00
whitequark
818436c57d Copy any constraints that only refer to entities in the clipboard. 2016-01-13 06:45:17 +00:00
whitequark
869404a8ec Fix GTK3 build. 2016-01-13 06:45:17 +00:00
whitequark
b8e8da0c0b Add Unicode support to TTF renderer.
It works. Mostly. Sort of. Only on Windows fonts. Sometimes it
randomly refuses to render glyphs (try `х`, that's not a latin ex).
I'm not really sure why, the logic seems right.

Why do we have a homegrown TTF parser anyway? It's kind of awful.
It breaks on any slightly unusual input. It plows through UTF-16BE
font names like a nuclear-powered steamroller. It outright ignores
composite glyphs (is that why it's broken this time?). The kerning
is seizure-inducing. It ignores any characters outside BMP by design.

Maybe we should just replace it with freetype.
2016-01-13 06:45:17 +00:00
whitequark
11f29b1231 Replace NameStr with std::string.
This removes the arbitrary 64 byte restriction (which effectively
limits us to as little as 16 Unicode characters with CJK encodings),
makes classes smaller, and is easier to use.

As a consequence of making the length of all ex-NameStr fields
unbounded, all functions that returned a buffer derived from those
were changed to return std::string. Then, functions that are
contextually similar to the ones described above were changed
to return std::string. Then, functions that now happened to mostly
take an std::string argument converted to a C string were changed
to accept std::string.

This has produced a bit of churn, but is probably for the better.
2016-01-13 06:45:17 +00:00
whitequark
86f0439521 Work around an MSVC2013 value-initialization bug.
See https://connect.microsoft.com/VisualStudio/feedback/details/793506.
2016-01-13 06:45:17 +00:00
whitequark
9d2a035a71 Rasterize non-ASCII glyphs in the UI.
Now it is possible to give non-ASCII names to groups
as well as see non-ASCII filenames of imported files.
In the future this makes localization possible.

This works for LTR languages, such as European and CJK,
but not RTL such as Arabic. Does Arabic even exist in
monospaced form? I have no idea.
2016-01-13 06:45:16 +00:00
whitequark
31fd64af0a Remove platform checks for UTF-8 characters in the source. 2016-01-13 06:45:16 +00:00
whitequark
ba10a75a7d Use Unicode-aware fopen and remove on Windows.
After this commit, SolveSpace can robustly handle non-ASCII filenames
on every OS. Additionally, on Windows, filenames longer than 260
characeters can be used, and files on network shares can be opened
directly, without mounting them as a network drive.
2016-01-13 06:45:16 +00:00
whitequark
97a9b4743e Make sure only *W functions from Win32 API are called.
After this commit, SolveSpace always uses UTF-8 strings internally
(represented as char* and std::string) on every OS, for everything:
UI labels, paths and user input. OS X always uses UTF-8; on Windows,
strings are converted at boundary; and on Linux/BSD/etc SolveSpace
refuses to start unless the current locale is UTF-8. This will
negatively affect literally no one.

This commit does not bring forth any user-visible improvement yet;
in order to correctly handle Unicode in filenames, it is still
necessary to change the fopen calls to _wfopen on Windows.
2016-01-13 06:45:16 +00:00
whitequark
5c9c32cfc7 Rigorously treat paths on every platform.
After this commit, SolveSpace deals with paths as follows:

  * Paths are generally treated as opaque platform-specific strings.
    This helps on Linux, because paths on Linux don't have any
    specific encoding and it helps to avoid any operations on them.

  * The UI in some places wants to get a basename. In this case,
    the newly introduced PATH_SEP is used. This allows to treat
    backslash as a regular character, which it is on Linux and OS X.

  * The only place where any nontrivial operations on paths are
    performed is the g->impFile/impFileRel logic.

    Specifically, when saved, g->impFile always contains an absolute
    path with separators of the current platform, and g->impFileRel
    always contains a relative path with UNIX separators. This allows
    to treat backslash as a regular character.

    Old files will contain g->impFileRel with Windows separators;
    these are detected by looking for a drive letter in g->impFile
    and in that case mapping Windows separators to UNIX ones.

There is no need to treat UNIX separators (forward slashes) in
any special way on Windows because there is no way on Windows,
not even via UNC paths, to create or address a directory entry
with a forward slash in its name.
2016-01-13 06:45:16 +00:00
whitequark
32383d22bf Rewrite all path handling with std::string.
What do we gain from this? Several things.

 * First, usage of PATH_MAX (the POSIX constant) is eliminated.
   PATH_MAX is actually a lie; Linux and OS X (and probably other BSDs
   too) do not have an actual path length limit. Linux claims 4096,
   OS X claims 1024, but it is trivial to construct paths that are
   longer.

 * Second, while Windows does enforce a limit of MAX_PATH (the Win32
   constant) for its ASCII functions, the Unicode variants, when
   used with UNC paths, do not have this restriction.
   The capability to use UNC paths is useful by itself, as it allows
   to access files on network shares directly.

 * Third, representing paths as std::string will make it easier to
   interoperate with *W WinAPI functions later.
2016-01-13 06:45:16 +00:00
whitequark
3ffbac38c6 Refactor Cnf* functions.
On Windows, freeze.{cpp,h} was factored into w32main.cpp.
The old implementation was too redundant and leaked registry
key handles.

On all platforms, Cnf* functions now use std::string.
This simplifies code everywhere, but will be particularly useful
when the Windows port switches to the *W WinAPI functions.
2016-01-13 06:45:16 +00:00
whitequark
c84a3b6de3 Call constructors and destructors in List and IdList.
This is necessary to store non-POD classes in these containers.

Note that List and IdList do not use MemRealloc anymore;
this is necessarily (slightly) less efficient, but is the right
semantics, as you cannot just move non-POD types, e.g. std::string,
around in memory. All STL containers provide the same guarantees
and share the performance hit.

The slowdown is mostly mitigated by moving the contained objects,
so that no additional heap allocations or copies occur beyond
that of the object itself.
2016-01-13 06:45:16 +00:00
whitequark
97fa6355cc Fix memory leaks in IdList::{MoveSelfInto,DeepCopyInto}.
Note that this requires IdLists to be zero-initialized
to work correctly.
2016-01-13 06:45:16 +00:00
whitequark
45f056c852 Replace all ZERO and memset with C++11 brace-initialization.
This will allow us to use non-POD classes inside these objects
in future and is otherwise functionally equivalent, as well
as more concise.

Note that there are some subtleties with handling of
brace-initialization. Specifically:

On aggregates (e.g. simple C-style structures) using an empty
brace-initializer zero-initializes the aggregate, i.e. it makes
all members zero.

On non-aggregates an empty brace-initializer calls the default
constructor. And if the constructor doesn't explicitly initialize
the members (which the auto-generated constructor doesn't) then
the members will be constructed but otherwise uninitialized.

So, what is an aggregate class? To quote the C++ standard
(C++03 8.5.1 §1):

An aggregate is an array or a class (clause 9) with no
user-declared constructors (12.1), no private or protected
non-static data members (clause 11), no base classes (clause 10),
and no virtual functions (10.3).

In SolveSpace, we only have to handle the case of base classes;
Constraint and Entity have those. Thus, they had to gain a default
constructor that does nothing but initializes the members to zero.
2016-01-13 06:45:16 +00:00
whitequark
02c30e6f87 Rewrite ttf2c to use GNU Unifont and merge with pngchar2c.pl.
After this change, SolveSpace does not contain nonfree assets.
Additionally, Perl is not required for the build.

Note that in the US, case law suggests that copyright does
not apply to bitmap fonts:
  http://www.renpy.org/wiki/renpy/misc/Bitmap_Fonts_and_Copyright

Nevertheless, it was prudent to replace the asset with something
that is unambiguously free.
2015-12-29 11:15:50 +08:00
whitequark
f76f76ff60 Rewrite png2c.pl in C++.
This allows us to always generate icons during build,
and in the future remove a Perl dependency.
2015-12-29 11:15:50 +08:00
ruevs
b23336b589 Add a new length-difference constraint.
This constraint requires the lengths of two line segments to
differ by a constant.
It can be useful to define the tolerances when making joints.
2015-12-28 21:37:07 +08:00
whitequark
8c2e94a01a Add a shortcut for drawing construction line segments.
Almost all construction requests are lines, and allowing to
draw them as construction obviates the need to select them one
by one afterwards to convert them. Also, it removes the "not closed
contour" error message, which is a nice usability improvement.
2015-12-28 21:37:07 +08:00
whitequark
e40929afca Add a shortcut for adding a reference dimension or angle.
This is equivalent to adding a constraint, then making it a reference.
The benefits are that:
 * it's quicker;
 * it avoids having an over-constrained system, with an associated
   angry red flash and a regeneration delay.
The latter in particular is a very substantial usability improvement.

The reference distance command is useful most of the time,
but the reference angle one is also added for consistency.
2015-12-28 21:37:07 +08:00
William D. Jones
4b02bf1e81 Implement Three.js export. 2015-12-28 21:37:07 +08:00
EvilSpirit
3c917ebac9 Use relative tolerance for axis-parallel autoconstrainter.
This works better than absolute tolerance in display pixels
for small lines.
2015-12-28 21:37:07 +08:00
whitequark
c6194d439c Allow using the constant "pi" in expressions. 2015-12-28 21:37:07 +08:00
EvilSpirit
ef3ee55d42 Optimize Expr::From(double) by statically allocating common constants. 2015-12-28 21:37:07 +08:00
whitequark
0933bbf687 Add Windows nightly builds. 2015-12-28 21:37:07 +08:00
whitequark
09c072fdfd Add Debian nightly builds. 2015-12-28 21:37:07 +08:00
whitequark
cdc384e44d Add OS X nightly builds. 2015-12-28 21:37:07 +08:00
whitequark
7c3c20161b Allow building on FreeBSD. 2015-12-28 21:37:07 +08:00
ruevs
922a6260d7 Allow building with MinGW on Windows. 2015-12-28 21:37:06 +08:00
whitequark
28166e6200 Use C++ std::{min,max,swap} instead of custom ones.
The main benefit is that std::swap will ensure that the type
of arguments is copy-constructible and move-constructible.
It is more concise as well.

When min and max are defined as macros, they will conflict
with STL header files included by other C++ libraries;
in this case STL will #undef any other definition.
2015-12-28 21:37:06 +08:00
whitequark
063dfc4f98 Require cmake 3.1.0 and C++11.
We plan to use C++11 features in the future. Moreover, recent gtkmm
has a hard requirement on C++11.
2015-12-28 21:37:06 +08:00
whitequark
1b6cd0d632 Make in-tree zlib more robust. 2015-12-28 21:37:06 +08:00
EvilSpirit
4d5a92e9b2 Make faces selectable again after undo. 2015-12-28 21:37:06 +08:00
whitequark
fdc39edfd8 Fix AllocTemporary on *nix. 2015-12-28 21:37:06 +08:00
whitequark
06be0d1157 Fix read of uninitialized memory. 2015-12-28 21:37:06 +08:00
whitequark
1422d3abd2 Fix initialization order issue. 2015-12-28 21:37:06 +08:00
whitequark
4260a91a99 Update libpng to 1.6.20.
libpng <=1.6.19 has security vulnerabilities.
2015-12-26 14:07:11 +08:00
whitequark
68f85587cb SourceForge is dead; fix libpng submodule URL.
https://github.com/glennrp/libpng is the official libpng repository.
2015-12-26 00:08:34 +08:00
whitequark
0159a87a8a Add support for cross-compiling from Linux.
As a side effect, zlib and libpng are now git submodules,
based on their respective official git repositories.
This is necessary, because MinGW has a different ABI and
it cannot use the prebuilt binaries built by MSVC.

The submodules are also used for Windows, for several reasons:
  * to allow 64-bit builds;
  * to allow using newer MSVC, which doesn't like the prebuilt
    libraries;
  * to keep the libraries updated.
2015-07-10 15:59:12 +03:00
whitequark
5e7c7fce7e Rename RgbColor to RgbaColor. 2015-07-10 15:59:12 +03:00
whitequark
75a3936b64 Add support for transparent solids.
Some extra code is necessary to determine that the back faces
should not be drawn in red for transparent solids. It is expected
that the user will first ensure that the shell is watertight
and then set the opacity; back faces are still drawn if
the opacity is exactly 1.

The savefile format is changed backwards-compatibly by stashing
the alpha value in uppermost byte of 4-byte hex color value
in Surface and Triangle clauses. The existing files have 00
in the high byte, so RgbColor::FromPackedInt treats that
as "opaque".
2015-07-10 15:59:12 +03:00
whitequark
1b69032d99 Allow displaying and editing diameter constraints as radius.
The savefile format is not changed; the display option is
stored in Constraint::other.
2015-07-10 15:59:12 +03:00
whitequark
f62e95d7b6 Replace \ with / slashes in assembly relative paths on *nix.
This is done specifically targeting the case where an assembly
initially made on Windows is transported to an *nix machine.
On *nix, the paths will be already saved with /, and correctly
read on Windows. On Windows however / is not a first-class separator,
in particular it cannot be used in UNC-style paths \\?\ (which
are the only paths that work with Unicode).

See also:
http://msdn.microsoft.com/en-us/library/aa365247.aspx
2015-07-10 15:59:12 +03:00
whitequark
69c509064c Automatically add horz/vert constraints to lines if close enough. 2015-07-10 15:59:12 +03:00
whitequark
f89020ad26 Highlight pending operation on toolbar, even if started via keyboard. 2015-07-10 15:59:12 +03:00
whitequark
46db5378dc Add Travis CI and Appveyor CI configurations. 2015-07-10 15:59:12 +03:00
whitequark
71b7ad7f99 Add an autosave timer.
Original patch by Marc Britten <marc.britten@gmail.com>.
2015-07-10 15:59:12 +03:00
whitequark
22d43d5b83 Remember the last format used to export 2D Views.
This helps a lot when exporting a lot of views, e.g.
for shop drawings.
2015-07-10 15:59:12 +03:00
whitequark
d585f0d1ff Make "Align view onto workplane" switch to locked workplane, if any.
Original patch by yugami
(http://solvespace.com/forum.pl?action=viewthread&parent=508).
2015-07-10 15:59:12 +03:00
whitequark
636b20bfa9 Add README. 2015-07-10 15:59:12 +03:00
whitequark
d0c0a7ae5a Remove FLTK port.
It provides no value over the native GTK and Cocoa ports.
2015-07-10 15:59:12 +03:00
whitequark
bbe4999033 Make sure all DrawOrGetDistance style code only draws in Paint();
Otherwise, GL reports errors when used with FBOs, as well as
creates visual artifacts, especially when UI is also drawn
with OpenGL.
2015-07-10 15:59:12 +03:00
whitequark
4b86fb89f8 Make "Show Menu Bar" and "Full Screen" use Ctrl/Cmd+Fn.
On OS X F11 and F12 are system-global shortcuts. I could switch
them only on Apple platforms, but for consistency I decided not to.
Anyway, neither of those appeared in an official release.
2015-07-10 15:59:12 +03:00
whitequark
d76d59ea64 Build Mac OS X dmg installation image. 2015-07-10 15:59:12 +03:00
whitequark
95ab80d0ee Implement OS X port. 2015-07-10 15:59:12 +03:00
whitequark
5d7a5bf3a7 Pack everything into namespace SolveSpace.
This is required to avoid name conflicts with the Cocoa libraries
on OS X.

I renamed the `class SolveSpace` to `class SolveSpaceUI`, because
that's what it does, and because otherwise the namespace would
have to be called something else than `namespace SolveSpace`.
2015-07-10 15:59:12 +03:00
whitequark
0807c2fdfe Add a native Debian package. 2015-07-10 15:59:12 +03:00
whitequark
d3dbf23725 Add a desktop file in the format understandable by Ubuntu. 2015-07-10 15:59:12 +03:00
whitequark
2ce12155bf Add bug compatibility with Chromium GL (VirtualBox).
I question the life choices that led me here.
2015-07-10 15:59:12 +03:00
whitequark
88e4163970 Use the extension version of FBO extension instead of core.
This will allow solvespace to run on pre-OpenGL 3.0 implementations,
such as VirtualBox (and possibly others).

However, VirtualBox's handling of framebuffer objects is buggy;
it tries to draw over our X window and fails to do either.

I hate OpenGL.
2015-07-10 15:59:12 +03:00
whitequark
e27c6b56c3 Implement offscreen rendering using GL framebuffer objects.
Apparently pbuffers are also a deprecated and unportable
way of offscreen rendering. They're not supported by
Chromium OpenGL implementation, which is what 3D-accelerated
VirtualBox uses.

This would also help a future OS X port.
2015-07-10 15:59:12 +03:00
whitequark
622c9efadb Use GL pbuffers instead of GLX pixmaps.
Apparently GLX pixmaps are an antiquated and unsupported method
for offscreen rendering in OpenGL. Specifically this broke
software and VirtualBox accelerated rendering in Ubuntu trusty
and who knows which other systems.

This commit switches the rendering to use pbuffers instead,
while retaining all other logic. The pbuffers are fixed-size,
because reallocating pbuffers during a resize sometimes results
in segfaults in glXMakeCurrent despite apparently correct
API usage.
2015-07-10 15:59:12 +03:00
whitequark
2c39f259db Add a GTK2/3 port.
In principle, GTK3 is the way forward, and GTK2 is officially
deprecated, though still maintained. In practice however, GTK3
is often unbearably buggy; e.g. on my system, combo boxes
don't ever roll up in GTK3 windows. So I have added support
for both.

This required a few minor changes to the core, namely:
  * GTK wants to know beforehand whether a menu item is a check
    menu item or a regular one.
  * GTK doesn't give us an easy way to execute something after
    any event is processed, so an explicit idle timer is added.
    This is a no-op on Win32.
  * A few function signatures were const'ed, since GTK expects
    immutable strings when converting to Glib::ustring.
2015-07-10 15:59:12 +03:00
whitequark
b68631ee56 Make fltkutil.cpp independent of FLTK and rename it to unixutil.cpp.
fltkutil.cpp should be independent of FLTK so that it can be linked
into libslvs while neither requiring every user of the library to
reimplement these support routines nor requiring linking in FLTK.
2015-07-10 15:59:11 +03:00
whitequark
5db5f1e152 Add a CMake buildsystem.
Additionally, update build tools so that no stdio redirection
is necessary.
2015-07-10 15:59:11 +03:00
whitequark
c5364fe7a8 Trim trailing whitespace. 2015-07-10 15:59:11 +03:00
whitequark
7c7ac17e4b Remove all legacy buildsystems. 2015-07-10 15:59:11 +03:00
whitequark
3a42a8d8cb catc 2015-07-10 15:59:11 +03:00
whitequark
62af550c0b Fix try..catch clauses dealing with C strings.
On *nix, a thrown string literal cannot be caught using
catch(char*), resulting in crashes.
2015-07-10 15:58:56 +03:00
whitequark
024a26bf57 Explicitly request a 24-bit depth buffer in FLTK port.
See http://solvespace.com/forum.pl?action=viewthread&parent=417.
2015-07-05 06:20:25 +03:00
whitequark
14690e6e42 Work around poor line rendering with Intel Mesa-based drivers.
However, don't use ssglLineWidth for UI drawing operations.
These only draw horizontal or vertical lines that don't need to
be antialiased, and thus don't require the workaround. In fact
the workaround would make them thicker than needed.
2015-07-05 06:20:25 +03:00
whitequark
13afcb310e Fix fontconfig detection code in FLTK.
Either clang is stricter than the compiler the authors of that
code used, or fontconfig detection never worked.
2015-07-05 06:20:25 +03:00
whitequark
80046672ef Use Command instead of Control key for shortcuts on OS X.
It is the OS X convention.
2015-07-05 06:20:25 +03:00
whitequark
84f2a59993 Use the degree symbol on non-Windows.
The Windows code uses a degree symbol in Latin-1, which
crashes FLTK on OS X.
2015-07-05 06:20:25 +03:00
whitequark
ffd2df9494 Fix dbg() not writing a newline.
puts() appends a newline, but fputs() does not.
Who needs consistency when you have undefined behavior? Oh, wait.
2015-07-05 06:20:25 +03:00
whitequark
1bbf61b8a2 Fix accidental glibc dependency.
fltkmain accidentally used optind instead of optndx. optind is
defined as an extern int in glibc but not on BSD systems.
This also broke passing a filename on command line.
2015-07-05 06:20:25 +03:00
whitequark
604c4bbea3 Fix oops() to not have UB.
Writing to NULL is undefined behavior and it is legal for the
compiler to simply remove it; clang will do so. abort()
or __builtin_trap() would produce the desirable result.
abort() is used as it is more portable.
2015-07-05 06:20:25 +03:00
whitequark
1cd2e2be2f Add Apple-specific OpenGL include statements. 2015-07-05 06:20:25 +03:00
whitequark
55e2d6b06d Fix stdint.h dependency in slvs.h.
Since SolveSpace's config.h is not exported, we cannot depend
on HAVE_C99_INTEGER_TYPES or similar variables. It's simplest
to just define it from scratch in the same way as MSVC does.
2015-07-05 06:20:25 +03:00
whitequark
5894efcfe5 Fix unresolved symbols in src/constraint.cpp when building libslvs. 2015-07-05 06:20:25 +03:00
Jonathan Westhues
ba8202d54a Don't falsely detect inconsistent systems with small angle constraints. 2015-06-08 11:19:29 -07:00
Jonathan Westhues
403d3c04d2 Improve relative paths for file import.
Don't break on case-sensitive filesystems, and don't require an explicit
regen after initial save of the assembly.
2015-05-21 05:26:29 -07:00
Jonathan Westhues
044a4ea8fc Don't offset SVG width and height by one. 2015-04-12 14:24:55 -07:00
Jonathan Westhues
9c9a0d8c28 Merge commit 'refs/merge-requests/16' of https://gitorious.org/solvespace/solvespace 2015-03-10 22:50:31 -07:00
Marc Britten
3b587d022a Updated Freeze to be multi monitor friendly 2015-03-10 22:05:29 -05:00
Roland Lutz
48880f6fe9 Apply automake option `subdir-objects' globally 2015-03-02 21:46:11 +01:00
Roland Lutz
6c4eacf237 Add files generated by autotools to `.gitignore' 2015-03-02 21:46:11 +01:00
Roland Lutz
8401dbd84a Use separate directories for macros and auxiliary build tools 2015-03-02 21:46:11 +01:00
Roland Lutz
f2cbdd36a9 Don't remove autoconf cache/backup files automatically 2015-03-02 21:46:11 +01:00
Roland Lutz
a9590dc271 Treat automake warnings as errors 2015-03-02 21:46:11 +01:00
Roland Lutz
790b241f56 Fix automake warning about missing `AM_PROG_AR' 2015-03-02 21:46:11 +01:00
Roland Lutz
40552a0066 Always enable warnings, even when not using `autogen.sh' 2015-03-02 21:46:11 +01:00
Roland Lutz
8d0c2f77ec Don't try to distribute files that don't exist 2015-03-02 21:46:11 +01:00
Roland Lutz
f5e4e02bac Remove duplicate entries from list of distributed files 2015-03-02 21:46:11 +01:00
Roland Lutz
f5de3faedb Remove missing script from list of distributed files 2015-03-02 21:46:11 +01:00
Roland Lutz
9b68bf8f7b Move library source to src/ directory 2015-03-02 21:46:11 +01:00
Roland Lutz
ae37fb783e Control libslvs compilation from src/Makefile.am 2015-03-02 21:46:11 +01:00
Roland Lutz
413ab5f578 Move library header to include/ directory 2015-03-02 21:46:11 +01:00
Roland Lutz
2622684ed5 Force object renaming to avoid constraint.o being overwritten
The GUI application and library share some object files but don't
enable object renaming resulting in the second compilation overwriting
the results of the first compilation.  This can be fixed by setting
explicit preprocessor flags for one compilation.  The actual problem,
however, is that recursive make is used in an inappropriate way; two
Makefiles shouldn't refer to the same source files.  In this case,
libslvs should be under src/ and handled by the same Makefile, in
which case the issue would have been obvious when the Makefile was
written in the first place.
2015-03-02 21:46:11 +01:00
Roland Lutz
3b4897c833 Add check for GL/GLU library
Requested by yugami:
> might I suggest explicitly including libGL as well as libpng.
> One of the previous builders errors needed that explicitly added in
2015-03-02 21:46:11 +01:00
Roland Lutz
afdf3145b2 Add missing check for PNG library
As Peter Stuge pointed out, it works anyway if fltk is built with png
support because solvespace uses the flags returned by fltk-config.
If fltk was built with png support enabled, these include -lpng.
2015-03-02 21:46:11 +01:00
Andrew Downing
6cfa884406 fix GraphicsEditControlWindow placement, and fix error due to cmath being included instead of math.h 2015-02-26 12:22:42 -05:00
Andrew Downing
252f4128b7 add includes to dsc.h to fix errors in it's own context (not real errors since dsc.h isnt compiled by itself, just screws up the code model in QtCreator without them) 2015-02-26 09:19:15 -05:00
Andrew Downing
023f404475 add LDFLAGS for FLTK to exposed/Makefile.am and src/Makefile.am 2015-02-25 22:47:35 -05:00
Andrew Downing
ce77197dac display GraphicsEditControl in its own tooltip window avoiding the need to hack FLTKs internals 2015-02-25 12:43:01 -05:00
Andrew Downing
396b1c63a4 fix fltk code 2015-02-24 16:07:32 -05:00
Andrew Downing
1bfba0df5f fix fltk code 2015-02-24 15:54:27 -05:00
Marc Britten
0f334cc040 Added updated header information for surfaces 2015-02-08 10:43:19 -06:00
Petteri Aimonen
12a29ddce0 FLTK: Don't oops() when unknown mouse button is pressed.
For example forward/backward buttons are present on many mouses
but are not used by solvespace. This oops() caused solvespace to
crash whenever those buttons were (accidentally) pressed.
2014-12-29 22:33:19 +02:00
Petteri Aimonen
8996833989 Fix crash on Ubuntu when opening assembly files.
Ubuntu enables GCC's buffer overflow checks by default. In SAVEDptr
union, the path was declared as 'char', even though MAX_PATH memory
was actually allocated. The buffer overflow check mistakenly thought
that the buffer size was only 1 and aborted the program whenever it
tried to read a path from a file.
2014-12-29 22:16:21 +02:00
Jonathan Westhues
e587d0ebee Fix GUI bugs in FLTK port, per Xavier Thomas's forum post:
"There was some small but annoying bugs with the FLTK port:
-cursor disappear sometimes
-not all the area of the windows (graphic and text windows) is accessible
by the mouse after a re-size
-input widget for editing constraints value are not correctly placed"
2014-05-11 15:43:03 -07:00
Ilya Novoselov
f5297093c0 Fix automake "option 'subdir-objects' is disabled" warning 2014-04-10 23:05:17 +06:00
Ilya Novoselov
01213bcafb Rest of code assumes that allocated memory is filled with zeroes 2014-04-08 07:56:57 +06:00
Jonathan Westhues
f4916f9ee4 Compare ((char *)p)[0] against '\0', not (char *)p.
Also make the library example compile again under MSVC, and make the
perl scripts to build the image tables work.
2013-12-08 00:32:50 -08:00
Daniel Richard G
1bc73c4a75 Renamed the RGB() macro to RGBi() to avoid collisions with Microsoft
Microsoft defines an RGB() macro that at one point was compatible with our
version (returning a packed integer containing 8-bit red, green and blue
channels), but is no longer, and the incompatibility led to an awkward
situation in w32main.cpp where we had to restore Microsoft's form of the
macro in order for the commctrl.h header to compile. By renaming the macro
to RGBi()---analogous to the RGBf() macro we already define---we avoid the
hassle entirely.
2013-12-02 04:27:34 -05:00
Daniel Richard G
f9f321ca84 Warning fixes 2013-12-02 04:27:33 -05:00
Daniel Richard G
3cc520e98c Overhauled the exposed/ Makefile for MSVC++ 2013-12-02 04:27:33 -05:00
Daniel Richard G
fd9dc19a34 Added the exposed/ library and demo program to the Autotools build
The libslvs library and CDemo program can now be built by Autotools. A few
code changes were needed for this: C++ comments in C code had to be
converted, constraint.cpp required some massaging, and fltkutil.cpp needed
a stub for InitHeaps().
2013-12-02 04:27:33 -05:00
Daniel Richard G
6c68294249 Improved handling of generated files
Place a pre-built copy of generated source files in src/built/, so that
users building SolveSpace from Git without the tools or setup necessary to
generate these can still complete the process.

Makefile.msvc: Use slashes consistently, and added rules to copy files from
src/built/ if needed

configure.ac: Check for presence of src/built/ at configure time

src/Makefile.am: Handle the generated *.table.h files together with
icon*.h; updated the source-generation rules so that the files are created
in builddir, not srcdir; added rules to copy files from src/built/ if
needed
2013-11-20 01:25:48 -05:00
Daniel Richard G
174ed76ef9 Added libspnav configure option and support to the Autotools build system 2013-11-19 18:17:55 -05:00
Daniel Richard G
4dffdb20e2 Added a .gitattributes file
This will allow checkouts of the SolveSpace source tree on Unix and Windows
to use the system's native line endings (i.e. LF vs. CRLF), while keeping
Unix line endings in the repository.

Created using the template at

	https://help.github.com/articles/dealing-with-line-endings
2013-11-19 18:17:55 -05:00
Daniel Richard G
bb3e5e9bb1 Minor follow-up changes
solvespace.h: Need to #define MAX_PATH on POSIX systems

resource.rc: icon.ico now lives in the same directory as this file
2013-11-19 18:17:55 -05:00
Daniel Richard G
0a24cf40f0 Moved most of the source into a src/ subdirectory
The SolveSpace top-level directory was getting a bit cluttered, so
following the example of numerous other free-software projects, we move the
main application source into a subdirectory and adjust the build systems
accordingly.

Also, got rid of the obj/ directory in favor of creating it on the fly in
Makefile.msvc.
2013-11-19 18:17:32 -05:00
Daniel Richard G
5429295492 Use a union for pointer polymorphism in the .slvs file I/O routines
The .slvs file I/O code was using "*((type *)pointer) = value" type-punning
dereferences, which are syntactically unwieldy and prone to annoying modern
compilers. A union pointer is more elegant, and better expresses the
polymorphism at issue.
2013-11-13 00:46:40 -05:00
Daniel Richard G
442197c907 Updated the bundled LibPNG/zlib, and polished the MSVC makefile further
The bundled copies of LibPNG and zlib have been updated to the versions
shipped with FLTK (as these were convenient to build), and I've put in new
static libraries compiled with Visual Studio 2003 .NET. These libraries
link cleanly even with Visual Studio 2013 Express, so they should work for
just about every version of MSVC out there that can compile SolveSpace.

The MSVC makefile is also now a little nicer, and the SpaceWare Input
library header #includes have been adjusted to drop the si/ prefix (for
consistency with how LibPNG/zlib are handled).
2013-11-13 00:33:23 -05:00
Daniel Richard G
3a46c97fd0 Reorganized the extlib/ subdirectory
LibPNG and zlib have been moved into their own subdirectories, consistent
with the SpaceWare Input library
2013-11-13 00:23:06 -05:00
Jonathan Westhues
511c513035 Oops, fix Style.fillColor export/import too. 2013-11-03 15:41:11 -08:00
Jonathan Westhues
f09ae15586 Fix broken colors in file import/export.
The move to RgbColor() missed the code that reads and writes Style.color
and Group.color. Also clarify redefinition of RGB() in w32main.cpp.
2013-11-03 15:09:17 -08:00
Daniel Richard G
c60e3dd34e Initial Autotools and FLTK support
With this commit, SolveSpace gains an Autotools build system and a new
platform-dependent backend implemented using the FLTK GUI toolkit. These
will allow the application to be built and run on Linux and other Unix-like
operating systems, and prospectively, MacOS X.

A number of new files have been added:

* Makefile.am: Automake makefile template; this contains some experimental
  support for MinGW and MSVC++ builds that needs further development

* ac-aux/ax_fltk.m4: Autoconf M4 macro to locate and query the system's
  installation of FLTK; this will eventually be contributed to the GNU
  Autoconf Archive

* autogen.sh: Script to bootstrap the Autotools build system, usually for a
  tree just checked out from source control

* configure.ac: Source for the Autoconf configure script; note that this
  file specifies a version of 2.1, near the top

* fltk/fltkmain.cpp: Main FLTK backend implementation

* fltk/fltkutil.cpp: Utility functions for the FLTK backend

* fltk/xFl_Gl_Window_Group.{H,cxx}: Implementation of a new
  Fl_Gl_Window_Group widget for FLTK, needed to facilitate drawing FLTK
  widgets on top of OpenGL graphics as SolveSpace does. This has been
  submitted to the FLTK project for (hopefully) eventual upstream
  inclusion:

    http://www.fltk.org/str.php?L2992

The following minor changes are also a part of this commit:

* Makefile.msvc: Define PACKAGE_VERSION=2.1 for the benefit of
  solvespace.cpp in MSVC++ builds

* solvespace.cpp: In the About dialog text, use PACKAGE_VERSION rather than
  hard-coding the version of the program

* solvespace.h: Don't define the C99 integer types if
  HAVE_C99_INTEGER_TYPES is defined, to facilitate MinGW builds
2013-10-28 01:28:42 -04:00
Daniel Richard G
7ca137f5fe Changed GetMilliseconds() to return a 64-bit value
This function previously returned an int32_t. Presuming that it measures
the length of time since the application was started, the 32-bit type would
cause the returned value to wrap from 2^31-1 to -2^31 after a little less
than twenty-five days.
2013-10-28 00:43:38 -04:00
Daniel Richard G
873811d865 Preliminary changes for FLTK support
* Added "Show Menu Bar" and "Full Screen" menu items, which will be
  implemented in the FLTK interface. These are currently prevented from
  appearing in the Win32 interface by the HAVE_FLTK and
  HAVE_FLTK_FULLSCREEN macros.

* Moved the "Show Text Window" down below the "Show Toolbar" item, so that
  "Show Menu Bar", "Show Toolbar" and "Show Text Window" are in the same
  vertical order as their corresponding UI elements typically take on

* Added new platform-dependent routines to back the new menu items:

    void ToggleMenuBar(void);
    bool MenuBarIsVisible(void);
    void ToggleFullScreen(void);
    bool FullScreenIsActive(void);

  These are stubs in the Win32 code.

* Fleshed out the system header #includes in solvespace.h, and moved them
  to the top of the file per convention

* Rewrote the file dialog selection patterns in terms of macros that allow
  them to expand to either the FLTK or Windows formats

* Don't use __stdcall in SSGL_CALLBACK, and make SSGL_CALLBACK 'extern "C"'
  as OpenGL usually expects function pointers to point to C functions
2013-10-28 00:43:38 -04:00
Daniel Richard G
c6203678e1 Renamed GL helper routines/identifiers to use "ssgl" prefix instead of "glx"
The "glx" prefix on the names of SolveSpace's various GL helper routines
was confusingly similar to those used by official OpenGL-associated
libraries (e.g. "glu" used by the GL Utility library, and "glX" used by
GLX), and could thus give the erroneous impression that it represented a
system API rather than ordinary application logic. We thus rename these
routines to have an "ssgl" prefix, clearly identifying them with SolveSpace
while retaining some visual kinship to GL function names.
2013-10-28 00:43:38 -04:00
Daniel Richard G
0afb5618ce Quash warnings for floating-point equality comparisons
GCC and Clang's -Wfloat-equal warning notes that comparing floating-point
values with == or != may be questionable. But the few instances of these in
SolveSpace are defensibly correct (as discussed with Jonathan), so to keep
folks from getting nervous that a CAD application isn't handling its floats
correctly, we define an EXACT() macro inside which the -Wfloat-equal
warning is disabled. This macro will also serve as a source-code
annotation, like a comment but better.

(The warning is only disabled for Clang, alas, because GCC is particular
about where _Pragma() can be used. This isn't so bad, however, because the
warning is much easier to enable on Clang [thanks to -Weverything], whereas
with GCC it has to be requested explicitly.)
2013-10-28 00:43:37 -04:00
Daniel Richard G
8bc322eb47 Various fixes for warnings and minutia
This commit consists of numerous small changes, none significant enough to
merit a commit on their own:

* Added extra braces to quash for-loop variable scoping issues for older
  compilers (or "g++ -fno-for-scope")

* Appeased "unreachable code" warnings, spurious or otherwise

* Added casts to fix integer-variable signedness warnings

* Added a dummy virtual method to the VectorFileWriter class to silence the
  -Wweak-vtables warning from Clang++

* Renamed some parameters in the Expr and GraphicsWindow classes to
  eliminate "parameter shadows a field" warnings

* Removed an inert "0 ||" from a conditional, and changed a "&& 0" into an
  "#if 0"

* Added missing elements to array/struct/class initializers to zap further
  warnings

* Indented some cpp conditionals where appropriate

* Qualified some variables and functions as static to quiet "no previous
  declaration" warnings

* toolbar.cpp needed to #include<icons-proto.h> to fix those same "no
  previous declaration" warnings from icons.h

* Added some casts and const qualifiers to the Win32 code to address
  warnings produced by g++ when compiling under MinGW

* Rewrote Cnf{Freeze,Thaw}Float() to use a union rather than pointer
  aliasing; this makes g++ a lot happier

* Removed redundant #includes from win32/w32util.cpp

* With Jonathan's blessing, shortened the last line of the About dialog
  text to better match the preceding lines
2013-10-28 00:42:39 -04:00
Daniel Richard G
a5176f4545 Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)

Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.

RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.

(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)

Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.

(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)

In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-25 01:49:12 -04:00
Daniel Richard G
dd168ad22c Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:

    QWORD  --> uint64_t
    SQWORD --> int64_t
    DWORD  --> uint32_t
    SDWORD --> int32_t
    WORD   --> uint16_t
    SWORD  --> int16_t
    BYTE   --> uint8_t
    BOOL   --> bool
    TRUE   --> true
    FALSE  --> false

The following related changes are also included:

* Added C99 integer type definitions for Windows, as stdint.h is not
  available prior to Visual Studio 2010

* Changed types of some variables in the SolveSpace class from 'int' to
  'bool', as they actually represent boolean settings

* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
  variables in the Registry

* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()

* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
  inspired by the OpenType spec)

* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
  in a few places, these were represented by an int; these have been
  corrected to uint32_t
2013-10-02 01:45:13 -04:00
Jonathan Westhues
505e3d869c Update Help -> About to note that license is GPLv3. 2013-09-22 03:50:59 -07:00
Daniel Richard G
e7f3a3c0db Build fix for Visual Studio 2003
INT_MAX was not being defined, so #include <limits.h>.
2013-09-20 21:38:53 -04:00
Daniel Richard G
fb766d1cf9 Make optional the use of the SpaceNavigator libraries 2013-09-20 15:25:14 -04:00
Daniel Richard G
3cfe6b6da1 Synthesize accelerator labels (e.g. "Ctrl+S") instead of hard-coding them
GraphicsWindow::menu[] previously recorded both item names (e.g. "Open...")
and accelerator labels ("Ctrl+O") in .label, and accelerator key/mask
values in .accel. Not only were the accelerator labels redundant given the
latter, they are not needed by GUI toolkits like FLTK, which generate them
from key/mask values.

So we remove the accelerator portion from each menu-item label, and define
a new MakeAcceleratorLabel() routine which takes a key/mask value and
returns the appropriate label. We make use of this new routine in
CreateGraphicsWindowMenus() and GraphicsWindow::ToolbarDrawOrHitTest().
2013-09-20 15:01:00 -04:00
Daniel Richard G
2499a02f2f Minor changes to GraphicsWindow::menu[]
* Added a comment header identifying the columns

* Added Ctrl-Q accelerator for "Exit", as this is standard

* Replaced a Latin-1 "degree" character with an octal escape, to avoid
  source-file encoding issues

* Undefine (some of) the convenience macros used to define the table
  (the method aliases are numerous and unlikely to collide with anything)
2013-09-20 14:34:03 -04:00
Daniel Richard G
4a2711476c Record accelerator for "Show Snap Grid" as '>' instead of Shift-'.'
If we are to synthesize accelerator labels from values of
GraphicsWindow::menu[].accel, it will be more straightforward if
accelerators are represented in the same way that they appear in the menu.
(Windows does return the keystroke as VK_OEM_PERIOD with a Shift modifier,
so we add some special-case logic to recognize that.)
2013-09-20 14:01:31 -04:00
Daniel Richard G
9da2a3a6c7 Use symbolic names for special keys and modifiers
Easier to remember e.g. DELETE_KEY instead of 127 or CTRL_MASK instead of
0x200, and better to have a single definition of each.
2013-09-20 13:54:57 -04:00
Daniel Richard G
37063840db Don't use magic values in GraphicsWindow::menu[].level
We can identify the "Open Recent" and "Import Recent" submenus just as
easily by looking at the value of the .id field (MNU_OPEN_RECENT and
MNU_GROUP_RECENT, respectively).
2013-09-20 13:40:17 -04:00
Daniel Richard G
66758b9595 Miscellaneous adjustments for warnings and code quality
This commit contains a grab bag of minor changes not worth committing
individually:

* Replaced raw Latin-1 characters with octal escapes to avoid source-file
  encoding issues

* Undefined some convenience macros after they've served their purpose

* Rewrote SEdge::From() to avoid confusing less-capable C++ compilers

* Have oops() print a newline at the end of its message

* Removed "static" keyword from the Bernstein() function definition, as it
  has a non-static prototype in srf/surface.h

* Added casts (and changed a variable type) to quell warnings about integer
  size and signedness

* Simplified an expression with our handy arraylen() macro
2013-09-19 02:35:56 -04:00
Daniel Richard G
07b128b877 Define some menu-bar menu items as radio buttons
Some menu items in the menu-bar are toggles (each representing an option
that can be turned on or off independently), and some are 1-of-N selections
(e.g. mm or inches), like tuner buttons on a car radio. Windows can draw an
optional check-mark besides a menu item, and SolveSpace has been using this
feature to implement both kinds of menu items, with the backend logic
making them behave as a toggle or radio button as appropriate.

Other GUI platforms can draw proper radio-button menu items that are
distinct from toggles, however. To allow the platform-specific logic to
tell the two kinds of menu items apart, this change adds the
RadioMenuById() routine, and replaces the appropriate calls to
CheckMenuById() with it. (Note that nothing is changed in the Windows GUI
code; radio-menu items are still drawn with check-marks.)
2013-09-19 00:59:18 -04:00
Daniel Richard G
30ca4ec8ac Use a '*' printf() field width rather than an intermediate format string 2013-09-19 00:50:11 -04:00
Daniel Richard G
16179f34cd Enabled freeing of (most) allocated memory on program exit
The Valgrind tool can give a full accounting of what memory allocations
have yet to be free()d when the program exits. It is easier to find actual
memory leaks in the code if all non-leaked allocations are elided from that
accounting, which is most easily accomplished by free()ing them.

The "most" qualifier is there because some allocations are difficult/
impossible to free, as they are internal to libraries like OpenGL and Xft.
The best we can hope for is to cover all allocations made by SolveSpace
directly.
2013-09-19 00:33:12 -04:00
Daniel Richard G
42a46e83fa Use system-agnostic return values for SaveFileYesNoCancel()
This function was returning ID{YES,NO,CANCEL}, which are specific to
Windows as return values for MessageBox(). These have been replaced with
SAVE_{YES,NO,CANCEL}, which we define ourselves.
2013-09-18 16:49:32 -04:00
Daniel Richard G
70b6bad551 Use '\b' instead of ('h' - 'a' + 1) 2013-09-18 16:41:23 -04:00
Daniel Richard G
718d411699 Renamed *.table files to *.table.h
The *.table files are in fact C header files, and with an *.h extension,
tools will be able to recognize them as such
2013-09-16 17:14:53 -04:00
Daniel Richard G
93145387f4 Fixed uninitialized-memory errors detected by Valgrind 2013-09-16 16:22:14 -04:00
Daniel Richard G
44a3981fbf Use png_get_image_{width,height}() instead of info_ptr->{width,height}
Later versions of libpng (1.5.x) have made the png_info structure opaque,
breaking direct access to its fields. Fortunately, the library also
provides getter routines, and these are available in the more-widely-
deployed 1.2.x series.
2013-09-16 15:57:32 -04:00
Daniel Richard G
66315d5eea Added const qualifiers to edit-control string handling
FLTK's Fl_Input widget, instantiated as {Graphics,Text}EditControl, returns
a 'const char *' string. In order to handle this properly, several of
SolveSpace's internal routines needed to gain a "const" qualifier on the
edit-control string argument.
2013-09-16 15:51:20 -04:00
Daniel Richard G
bcb6c7b19b OpenGL fixes
glGetError() was returning GL_INVALID_OPERATION due to some minor missteps
2013-09-09 16:05:33 -04:00
Daniel Richard G
5cca524c62 Changed "static const int" class members into enums
Not only is the enum syntax more compact, it avoids inadvertent link
failures resulting from how C++ treats "static const int" members:

http://stackoverflow.com/questions/5391973/undefined-reference-to-static-const-int
http://stackoverflow.com/questions/5508182/static-const-int-causes-linking-error-undefined-reference

(And for what it's worth, MSVC6 gave silly errors for these members
wherever a non-zero value was assigned.)
2013-09-09 15:50:32 -04:00
Daniel Richard G
a2a78b923f Renamed the MSVC makefile to Makefile.msvc
Automake and CMake both generate a makefile named "Makefile", so this will
prevent the hand-written MSVC makefile from getting clobbered.
2013-08-27 16:46:24 -04:00
Daniel Richard G
74b65e14f9 Revised the MSVC Makefile and build
* Generate icons.h and icons-proto.h in the source directory instead of
  obj/, so that pre-generated copies of these files can be distributed
  without being blown away by "make clean"; also updated the source files
  that #include these to reflect the new location

* Compilation rules rewritten as batch-mode inference rules

* Use Windows commands instead of Unix ones ("del" instead of "rm", "move"
  instead of "mv", etc.)

* Sorted the object lists

* Use tabs to indent rule bodies
2013-08-27 16:44:48 -04:00
Daniel Richard G
398e09fe9e Revised the Perl scripts
* Use "#!/usr/bin/env perl" instead of "#!/usr/bin/perl", as this is better
  practice (it allows e.g. /usr/local/bin/perl to work when executing via
  the shebang)

* Use "use strict" and "use warnings"

* Declare variables with "my" as required by "use strict"

* Take an optional "srcdir" argument so that the scripts can find the icon
  files in a location other than ./icons/ -- this will make building
  outside of the source tree possible in the future

* Add a "this is a generated file" banner to the output, so that it can be
  clearly recognized as a machine-generated file that should not be
  hand-edited

* Minor regex tweaks
2013-08-26 17:45:09 -04:00
Daniel Richard G
0f7a34ccca Fixed a typo: "==" was intended, not "=" 2013-08-26 17:06:53 -04:00
Daniel Richard G
e256956d12 Added missing items to GraphicsWindow::menu[] elements
Several MenuEntry elements in GraphicsWindow::menu[] were being initialized
with four items instead of the requisite five, due to a missing fourth
column (corresponding to the .accel field of MenuEntry). This change simply
adds zeroes as the missing column to the appropriate elements.
2013-08-26 17:00:02 -04:00
Daniel Richard G
66f46b7b67 General compiler warning/error fixes
This addresses a grab bag of compiler grievances relating to C++ syntax,
type, and scope, as observed on Linux with g++ and Solaris with Sun
WorkShop 6.
2013-08-26 16:54:04 -04:00
Daniel Richard G
7715fd1bb8 Don't ignore the return value of fgets() and fread() 2013-08-26 16:48:41 -04:00
Daniel Richard G
1b00c8c3ab Use size_t instead of int in the memory allocation routines
size_t is the correct type to use when specifying the memory-size of an
object. That is why sizeof(), strlen() and malloc() all use it.
2013-08-26 16:40:25 -04:00
Daniel Richard G
dcc963aa4b Modified Get{BYTE,WORD,DWORD}() to return the respective type
Having e.g. GetWORD() return a WORD rather than int eliminates the need for
a cast when assigning to WORD variables. We use casts only when assigning
to a different (but same-sized) type.

Also, check for EOF explicitly when calling fgetc().
2013-08-26 16:24:16 -04:00
Daniel Richard G
a72575d04e Use casts to bridge mismatches in integer-type sizes and signedness
The compiler gets nervous when we (for example) pass in a size_t as an int
parameter, or assign an int to a char, or assign -1 to an unsigned type. By
adding appropriate casts, we inform the compiler that, yes, we know what
we're doing.

This change also upgrades a va_arg() type from char to int, as char is
always promoted to int when passed through '...'.
2013-08-26 16:19:23 -04:00
Daniel Richard G
8913d11fa5 Quash "variable may be used uninitialized" warnings
Whether or not there is any actual danger of these variables being used
without initialization, the warnings are noise, and getting rid of them is
trivial.
2013-08-26 15:36:00 -04:00
Daniel Richard G
df6125efee Fix "jump to label 'foo' crosses initialization of 'bar'" errors
Newer C++ compilers do not allow goto-ing over an initialized variable
declaration, as this violates C++98. We address this by (in most cases)
separating the initialization from the declaration, or moving the goto to
an equivalent location.

Refer to the following discussions for more background:

http://stackoverflow.com/questions/11306799/why-does-c-enforce-such-behavior-in-crosses-initialization
http://stackoverflow.com/questions/12992108/crosses-initialization-of-variable-only-when-initialization-combined-with-decl
2013-08-26 15:24:50 -04:00
Daniel Richard G
02776ea535 Added const qualifiers
String literals in C++ are implicitly typed as 'const char *', and with
this change, their const-ness is maintained when assigning them to
variables or passing them as arguments. This significantly cuts down the
number of warnings generated by the compiler.
2013-08-26 14:58:35 -04:00
Jonathan Westhues
affbeafc6c Make a copy of "freeze" library for storing stuff in registry, to
make //depot/solvespace/... entirely self-contained.

[git-p4: depot-paths = "//depot/solvespace/": change = 2216]
2013-08-20 21:54:54 -08:00
580 changed files with 150857 additions and 3116 deletions

10
.gitattributes vendored Normal file
View File

@ -0,0 +1,10 @@
* text=auto
*.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.

16
.gitignore vendored
View File

@ -1 +1,15 @@
/build* /CMakeCache.txt
/build*/
/test/**/*.diff.*
/test/**/*.curr.*
*.trace
/debian/tmp/
/debian/*.log
/debian/*.substvars
/debian/*.debhelper
/debian/files
/debian/solvespace/
/debian/libslvs1/
/debian/libslvs1-dev/
/obj-*/
/*.slvs

22
.gitmodules vendored Normal file
View File

@ -0,0 +1,22 @@
[submodule "extlib/zlib"]
path = extlib/zlib
url = https://github.com/madler/zlib
ignore = dirty
[submodule "extlib/libpng"]
path = extlib/libpng
url = https://github.com/glennrp/libpng
[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

29
.travis.yml Normal file
View File

@ -0,0 +1,29 @@
language: c
os:
- linux
- 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
script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/build-debian.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/build-macos.sh; fi
deploy:
- provider: releases
api_key:
secure: dDlkIawHcODlW9B/20/cQCtzeoocvs0hKuNngRKXKqzXLWTRq33oq/B7+39tAixWbmv6exTpijiKrRNFiSCW5Z4iwHLwaRD4XJznxw63e/Hus/dxg2Tvqx7XFpkCz8mT1Z+gZQE5YxAngeZPpI/sZbZtF1UO3yH5eLeeokZ15p26ZskQUPoYuzrTgTzYL3XfpG3F+20rNBawH1ycsCTVD/08/n31d2m3CrKAsbW7er92ek6w4fzKr7NW8WeXjrPJETVpw5fQg1Od3pRGW8dPQaJcvKQEogMp8Mm0ETYd0qigg89/giBz7QwOgmAWQ4dH+DfZH4Ojl//127QztBolMvyDMQBykWrtJoGcij05sT6K2IJr2FHeUBO12MAEdjiVvhQj3DtTzjPiZAHHDBSLWxLKWWhlhHE4pq7g1MQhqXkaAHI2BLNzwLmaowbMT0bECf9yfz6xx18h6XPQFX44oOktraobVALFlyHqeKa8zdcUt22LF6uAL1m5dxL0tny3eXCIPE4UH/RZgua/cHV9G3cUvKQa/QnFSLRhvWVSbGB+7YsHouBJcsUOOW1gmd5442XuC7mpppccRldh+GSxUk6TBJRAx7TeQ0ybDUaoco9MUqp2twv3KreR2+8Q12PDaAhfQVNEGdF3wTm1sShImjCN4VN3eSLlBEbve1QRQXM=
skip_cleanup: true
file: build/solvespace.dmg
on:
repo: solvespace/solvespace
tags: true
condition: "$TRAVIS_OS_NAME == osx"
notifications:
irc:
channels:
- "chat.freenode.net#solvespace"
use_notice: true
skip_join: true

13
.travis/build-debian.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh -xe
if echo $TRAVIS_TAG | grep ^v; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=Debug; fi
mkdir build
cd build
# 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

9
.travis/build-macos.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh -xe
if echo $TRAVIS_TAG | grep ^v; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=Debug; fi
mkdir build
cd build
cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
make VERBOSE=1
make test_solvespace

10
.travis/install-debian.sh Executable file
View File

@ -0,0 +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-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

4
.travis/install-macos.sh Executable file
View File

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

203
CHANGELOG.md Normal file
View File

@ -0,0 +1,203 @@
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
---
Bug fixes:
* Do not crash when applying a symmetry constraint to two points.
* Fix TTF font metrics again (properly this time).
* Fix the "draw back faces in red" option.
* Fix export of wireframe as 3D DXF.
* Various minor crashes.
2.2
---
Other new features:
* OS X: support 3Dconnexion devices (SpaceMouse, SpaceNavigator, etc).
* GTK: files with uppercase extensions can be opened.
Bug fixes:
* Do not remove autosaves after successfully opening a file, preventing
data loss in case of two abnormal terminations in a row.
* Do not crash when changing autosave interval.
* Unbreak the "Show degrees of freedom" command.
* Three.js: correctly respond to controls when browser zoom is used.
* OS X: do not completely hide main window when defocused.
* GTK: unbreak 3Dconnexion support.
* When pasting transformed entities, multiply constraint values by scale.
* Fix TTF font metrics (restore the behavior from version 2.0).
* Forcibly show the current group once we start a drawing operation.
* DXF export: always declare layers before using them.
* Do not truncate operations on selections to first 32 selected entities.
* Translate and rotate groups inherit the "suppress solid model" setting.
* DXF: files with paths containing non-ASCII or spaces can be exported
or imported.
* Significantly improved performance when dragging an entity.
* Various crashes and minor glitches.
2.1
---
New sketch features:
* Lathe groups create circle and face entities.
* New toolbar button for creating lathe groups.
* Chord tolerance is separated into two: display chord tolerance (specified
in percents, relative to model bounding box), and export chord tolerance
(specified in millimeters as absolute value).
* Bezier spline points can be added and removed after the spline is created.
* When an unconstrained extrusion is switched between "union" and
"difference", its normal is flipped.
* Groups can be added in the middle of the stack. Note that this results
in files incompatible with version 2.0.
* Active group can be removed.
* Removing an imported group does not cause all subsequent groups to also
be removed.
* When a new group with a solid is created, the color is taken from
a previous group with a solid, if any.
* Entities in a newly active group do not become visible.
* When entities are selected, "Zoom to fit" zooms to fit only these
entities and not the entire sketch.
* Zero-length edges are reported with a "zero-length error", not
"points not all coplanar".
New constraint features:
* Height of the font used for drawing constraint labels can be changed.
* New constraint, length difference, placed with J.
(Patch by Peter Ruevski)
* Horizontal/vertical constraints are automatically added if a line segment
is close enough to being horizontal/vertical. This can be disabled by
holding Ctrl.
* Reference dimensions and angles can be placed with Shift+D and Shift+N.
* Copying and pasting entities duplicates any constraints that only involve
entities in the clipboard, as well as selected comments.
* Diameter constraints can be shown as radius.
* The "pi" identifier can be used in expressions.
* Constraint labels can be snapped to grid.
* Integer angles are displayed without trailing zeroes.
* Angle constraints have proper reference lines and arrowheads.
* Extension lines are drawn for point-line distance constraints.
New solver features:
* Sketches with redundant and unsolvable constraints are distinguished.
* New group setting, "allow redundant constraints". Note that it makes
the solver less stable.
New rendering and styling features:
* New line style parameter: stippling, based on ISO 128.
* Outlines of solids can be drawn in a particular style (by default, thick
lines) controlled by the "Show outline of solid model" button.
* Occluded edges can be drawn in a particular style (by default, stippled
with short dashes) controlled by the "Show hidden lines" button.
* Solids can be made transparent.
New export/import features:
* The old "import" command (for .slvs files) is renamed to "link".
* If a linked .slvs file is not found, first the relative path recorded
in the .slvs file is checked and then the absolute path; this is
an inversion of the previously used order. If it is still not found,
a dialog appears offering to locate it.
* DXF and DWG files can be imported, with point-coincident, horizontal and
vertical constraints automatically inferred from geometry, and distance
and angle constraints created when a dimension placed against geometry
exists.
* Triangle mesh can be exported for viewing in the browser through WebGL.
* Export dialogs remember the last file format used, and preselect it.
* Exported DXF files have exact circles, arcs and splines instead of
a piecewise linear approximation (unless hidden line removal was needed).
* Exported DXF files preserve color and line thickness.
* In exported DXF files, constraints are represented as DXF dimensions,
instead of piecewise linear geometry.
* When exporting 2d views, overlapping lines are removed.
Other new features:
* Native Linux (GTK 2 and GTK 3) and Mac OS X ports.
* Automatically save and then restore sketches if SolveSpace crashes.
(Patch by Marc Britten)
* Unicode is supported everywhere (filenames, group names, TTF text,
comments), although RTL scripts and scripts making heavy use of ligatures
are not rendered correctly.
* The vector font is grid-fitted when rendered on screen to make it easier
to read regardless of its size.
2.0
---
Initial public release.

View File

@ -1,23 +1,230 @@
# cmake configuration # 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_minimum_required(VERSION 3.1.0 FATAL_ERROR)
cmake_policy(VERSION 3.1.0) cmake_policy(VERSION 3.1.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
# for /MT on MSVC
set(CMAKE_USER_MAKE_RULES_OVERRIDE
"${CMAKE_SOURCE_DIR}/cmake/c_flag_overrides.cmake")
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
"${CMAKE_SOURCE_DIR}/cmake/cxx_flag_overrides.cmake")
# project # project
# NOTE TO PACKAGERS: The embedded git commit hash is critical for rapid bug triage when the builds
# can come from a variety of sources. If you are mirroring the sources or otherwise build when
# the .git directory is not present, please comment the following line:
include(GetGitCommitHash)
# and instead uncomment the following, adding the complete git hash of the checkout you are using:
# set(GIT_COMMIT_HASH 0000000000000000000000000000000000000000)
project(solvespace) project(solvespace)
set(solvespace_VERSION_MAJOR 3)
set(solvespace_VERSION_MINOR 0)
string(SUBSTRING "${GIT_COMMIT_HASH}" 0 8 solvespace_GIT_HASH)
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()
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 # common compiler flags
if(MINGW) if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") 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() endif()
if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif() 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 # solvespace-only compiler flags
if(WIN32) if(WIN32)
@ -25,7 +232,8 @@ if(WIN32)
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS
-D_SCL_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
-D_WIN32_WINNT=0x500 -DWINVER=0x0601
-D_WIN32_WINNT=0x0601
-D_WIN32_IE=_WIN32_WINNT -D_WIN32_IE=_WIN32_WINNT
-DISOLATION_AWARE_ENABLED -DISOLATION_AWARE_ENABLED
-DWIN32 -DWIN32
@ -61,7 +269,36 @@ endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
if(WIN32)
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -l0")
endif()
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()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "Code coverage produces reliable results only on Debug builds")
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 # components
add_subdirectory(res)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(exposed) 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

164
README.md Normal file
View File

@ -0,0 +1,164 @@
SolveSpace
==========
This repository contains the source code of [SolveSpace][], a parametric
2d/3d CAD.
[solvespace]: http://solvespace.com
Installation
------------
### macOS (>=10.6 64-bit), Windows (>=Vista 32-bit)
Binary packages for macOS and Windows are available via
[GitHub releases][rel].
[rel]: https://github.com/solvespace/solvespace/releases
### Other systems
See below.
Building on Linux
-----------------
### Building for Linux
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 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:
git submodule update --init extlib/libdxfrw
After that, build SolveSpace as following:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
sudo make install
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 and a Windows cross-compiler.
On a Debian derivative (e.g. Ubuntu) these can be installed with:
apt-get install cmake mingw-w64
Before building, check out the necessary submodules:
git submodule update --init
After that, build 32-bit SolveSpace as following:
mkdir build
cd build
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 \
-DCMAKE_BUILD_TYPE=Release
make
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 macOS
-----------------
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 cairo
XCode has to be installed via AppStore; it requires a free Apple ID.
Before building, check out the necessary submodules:
git submodule update --init extlib/libdxfrw
After that, build SolveSpace as following:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
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 [git][gitwin], [cmake][cmakewin] and Visual C++.
### 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.
### 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
Visual Studio install. Then, run the following in cmd or PowerShell:
git submodule update --init
mkdir build
cd build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
nmake
### Building with MinGW
It is also possible to build SolveSpace using [MinGW][mingw], though
Space Navigator support will be disabled.
First, ensure that git and gcc are in your `$PATH`. Then, run the following
in bash:
git submodule update --init
mkdir build
cd build
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
-------
SolveSpace is distributed under the terms of the [GPL3 license](COPYING.txt).

30
appveyor.yml Normal file
View File

@ -0,0 +1,30 @@
version: 3.0.{build}
clone_depth: 1
before_build:
- git submodule update --init
- mkdir 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 ..
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\bin\%BUILD_TYPE%\solvespace.exe
name: solvespace.exe
- 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,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()

28
cmake/FindSpaceWare.cmake Normal file
View File

@ -0,0 +1,28 @@
# Find the libspnav library and header.
#
# Sets the usual variables expected for find_package scripts:
#
# SPACEWARE_INCLUDE_DIR - header location
# SPACEWARE_LIBRARIES - library to link against
# SPACEWARE_FOUND - true if pugixml was found.
if(UNIX)
find_path(SPACEWARE_INCLUDE_DIR
spnav.h)
find_library(SPACEWARE_LIBRARY
NAMES spnav libspnav)
# Support the REQUIRED and QUIET arguments, and set SPACEWARE_FOUND if found.
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SPACEWARE DEFAULT_MSG
SPACEWARE_LIBRARY SPACEWARE_INCLUDE_DIR)
if(SPACEWARE_FOUND)
set(SPACEWARE_LIBRARIES ${SPACEWARE_LIBRARY})
endif()
mark_as_advanced(SPACEWARE_LIBRARY SPACEWARE_INCLUDE_DIR)
endif()

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

@ -0,0 +1,35 @@
function(get_git_commit_hash)
get_filename_component(GIT_DESCRIBE_CMAKE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
get_filename_component(GIT_ROOT ${GIT_DESCRIBE_CMAKE_DIR} PATH)
set(GIT_DIR "${GIT_ROOT}/.git")
# Add a CMake configure dependency to the currently checked out revision.
set(GIT_DEPENDS ${GIT_DIR}/HEAD)
file(READ ${GIT_DIR}/HEAD HEAD_REF)
if(HEAD_REF MATCHES "ref: (.+)\n")
set(HEAD_REF ${CMAKE_MATCH_1})
if(EXISTS "${GIT_DIR}/${HEAD_REF}")
list(APPEND GIT_DEPENDS ${GIT_DIR}/${HEAD_REF})
file(READ ${GIT_DIR}/${HEAD_REF} HEAD_REF)
elseif(EXISTS "${GIT_DIR}/packed-refs")
list(APPEND GIT_DEPENDS ${GIT_DIR}/packed-refs)
file(READ "${GIT_DIR}/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_REF ${CMAKE_MATCH_1})
else()
set(HEAD_REF "")
endif()
else()
set(HEAD_REF "")
endif()
endif()
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${GIT_DEPENDS})
string(STRIP ${HEAD_REF} HEAD_REF)
if(HEAD_REF STREQUAL "")
message(WARNING "Cannot determine git HEAD")
else()
set(GIT_COMMIT_HASH ${HEAD_REF} PARENT_SCOPE)
endif()
endfunction()
get_git_commit_hash()

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>solvespace</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>SolveSpace</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<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-2016 Jonathan Westhues and other authors</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>slvs</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>AppIcon.icns</string>
<key>CFBundleTypeName</key>
<string>SolveSpace sketch</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>slvs</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
</dict>
</plist>

View File

@ -0,0 +1,15 @@
set(CMAKE_SYSTEM_NAME Windows)
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_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

@ -0,0 +1,15 @@
set(CMAKE_SYSTEM_NAME Windows)
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_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

@ -0,0 +1,6 @@
if(MSVC)
set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG")
set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG")
endif()

View File

@ -0,0 +1,6 @@
if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG")
endif()

View File

@ -1,17 +1,23 @@
//----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
// Some sample code for slvs.dll. We draw some geometric entities, provide * Some sample code for slvs.dll. We draw some geometric entities, provide
// initial guesses for their positions, and then constrain them. The solver * initial guesses for their positions, and then constrain them. The solver
// calculates their new positions, in order to satisfy the constraints. * calculates their new positions, in order to satisfy the constraints.
// *
// Copyright 2008-2013 Jonathan Westhues. * Copyright 2008-2013 Jonathan Westhues.
//----------------------------------------------------------------------------- *---------------------------------------------------------------------------*/
#ifdef WIN32
# include <windows.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "slvs.h" #include <slvs.h>
Slvs_System sys; static Slvs_System sys;
void *CheckMalloc(size_t n) static void *CheckMalloc(size_t n)
{ {
void *r = malloc(n); void *r = malloc(n);
if(!r) { if(!r) {
@ -21,30 +27,30 @@ void *CheckMalloc(size_t n)
return r; return r;
} }
//----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
// An example of a constraint in 3d. We create a single group, with some * An example of a constraint in 3d. We create a single group, with some
// entities and constraints. * entities and constraints.
//----------------------------------------------------------------------------- *---------------------------------------------------------------------------*/
void Example3d(void) void Example3d()
{ {
// This will contain a single group, which will arbitrarily number 1. /* This will contain a single group, which will arbitrarily number 1. */
int g = 1; Slvs_hGroup g = 1;
// A point, initially at (x y z) = (10 10 10) /* A point, initially at (x y z) = (10 10 10) */
sys.param[sys.params++] = Slvs_MakeParam(1, g, 10.0); sys.param[sys.params++] = Slvs_MakeParam(1, g, 10.0);
sys.param[sys.params++] = Slvs_MakeParam(2, g, 10.0); sys.param[sys.params++] = Slvs_MakeParam(2, g, 10.0);
sys.param[sys.params++] = Slvs_MakeParam(3, g, 10.0); sys.param[sys.params++] = Slvs_MakeParam(3, g, 10.0);
sys.entity[sys.entities++] = Slvs_MakePoint3d(101, g, 1, 2, 3); sys.entity[sys.entities++] = Slvs_MakePoint3d(101, g, 1, 2, 3);
// and a second point at (20 20 20) /* and a second point at (20 20 20) */
sys.param[sys.params++] = Slvs_MakeParam(4, g, 20.0); sys.param[sys.params++] = Slvs_MakeParam(4, g, 20.0);
sys.param[sys.params++] = Slvs_MakeParam(5, g, 20.0); sys.param[sys.params++] = Slvs_MakeParam(5, g, 20.0);
sys.param[sys.params++] = Slvs_MakeParam(6, g, 20.0); sys.param[sys.params++] = Slvs_MakeParam(6, g, 20.0);
sys.entity[sys.entities++] = Slvs_MakePoint3d(102, g, 4, 5, 6); sys.entity[sys.entities++] = Slvs_MakePoint3d(102, g, 4, 5, 6);
// and a line segment connecting them. /* and a line segment connecting them. */
sys.entity[sys.entities++] = Slvs_MakeLineSegment(200, g, sys.entity[sys.entities++] = Slvs_MakeLineSegment(200, g,
SLVS_FREE_IN_3D, 101, 102); SLVS_FREE_IN_3D, 101, 102);
// The distance between the points should be 30.0 units. /* The distance between the points should be 30.0 units. */
sys.constraint[sys.constraints++] = Slvs_MakeConstraint( sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
1, g, 1, g,
SLVS_C_PT_PT_DISTANCE, SLVS_C_PT_PT_DISTANCE,
@ -52,13 +58,13 @@ void Example3d(void)
30.0, 30.0,
101, 102, 0, 0); 101, 102, 0, 0);
// Let's tell the solver to keep the second point as close to constant /* Let's tell the solver to keep the second point as close to constant
// as possible, instead moving the first point. * as possible, instead moving the first point. */
sys.dragged[0] = 4; sys.dragged[0] = 4;
sys.dragged[1] = 5; sys.dragged[1] = 5;
sys.dragged[2] = 6; sys.dragged[2] = 6;
// Now that we have written our system, we solve. /* Now that we have written our system, we solve. */
Slvs_Solve(&sys, g); Slvs_Solve(&sys, g);
if(sys.result == SLVS_RESULT_OKAY) { if(sys.result == SLVS_RESULT_OKAY) {
@ -72,25 +78,25 @@ void Example3d(void)
} }
} }
//----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
// An example of a constraint in 2d. In our first group, we create a workplane * An example of a constraint in 2d. In our first group, we create a workplane
// along the reference frame's xy plane. In a second group, we create some * along the reference frame's xy plane. In a second group, we create some
// entities in that group and dimension them. * entities in that group and dimension them.
//----------------------------------------------------------------------------- *---------------------------------------------------------------------------*/
void Example2d(void) void Example2d()
{ {
int g; Slvs_hGroup g;
double qw, qx, qy, qz; double qw, qx, qy, qz;
g = 1; g = 1;
// First, we create our workplane. Its origin corresponds to the origin /* First, we create our workplane. Its origin corresponds to the origin
// of our base frame (x y z) = (0 0 0) * of our base frame (x y z) = (0 0 0) */
sys.param[sys.params++] = Slvs_MakeParam(1, g, 0.0); sys.param[sys.params++] = Slvs_MakeParam(1, g, 0.0);
sys.param[sys.params++] = Slvs_MakeParam(2, g, 0.0); sys.param[sys.params++] = Slvs_MakeParam(2, g, 0.0);
sys.param[sys.params++] = Slvs_MakeParam(3, g, 0.0); sys.param[sys.params++] = Slvs_MakeParam(3, g, 0.0);
sys.entity[sys.entities++] = Slvs_MakePoint3d(101, g, 1, 2, 3); sys.entity[sys.entities++] = Slvs_MakePoint3d(101, g, 1, 2, 3);
// and it is parallel to the xy plane, so it has basis vectors (1 0 0) /* and it is parallel to the xy plane, so it has basis vectors (1 0 0)
// and (0 1 0). * and (0 1 0). */
Slvs_MakeQuaternion(1, 0, 0, Slvs_MakeQuaternion(1, 0, 0,
0, 1, 0, &qw, &qx, &qy, &qz); 0, 1, 0, &qw, &qx, &qy, &qz);
sys.param[sys.params++] = Slvs_MakeParam(4, g, qw); sys.param[sys.params++] = Slvs_MakeParam(4, g, qw);
@ -101,12 +107,12 @@ void Example2d(void)
sys.entity[sys.entities++] = Slvs_MakeWorkplane(200, g, 101, 102); sys.entity[sys.entities++] = Slvs_MakeWorkplane(200, g, 101, 102);
// Now create a second group. We'll solve group 2, while leaving group 1 /* Now create a second group. We'll solve group 2, while leaving group 1
// constant; so the workplane that we've created will be locked down, * constant; so the workplane that we've created will be locked down,
// and the solver can't move it. * and the solver can't move it. */
g = 2; g = 2;
// These points are represented by their coordinates (u v) within the /* These points are represented by their coordinates (u v) within the
// workplane, so they need only two parameters each. * workplane, so they need only two parameters each. */
sys.param[sys.params++] = Slvs_MakeParam(11, g, 10.0); sys.param[sys.params++] = Slvs_MakeParam(11, g, 10.0);
sys.param[sys.params++] = Slvs_MakeParam(12, g, 20.0); sys.param[sys.params++] = Slvs_MakeParam(12, g, 20.0);
sys.entity[sys.entities++] = Slvs_MakePoint2d(301, g, 200, 11, 12); sys.entity[sys.entities++] = Slvs_MakePoint2d(301, g, 200, 11, 12);
@ -115,11 +121,11 @@ void Example2d(void)
sys.param[sys.params++] = Slvs_MakeParam(14, g, 10.0); sys.param[sys.params++] = Slvs_MakeParam(14, g, 10.0);
sys.entity[sys.entities++] = Slvs_MakePoint2d(302, g, 200, 13, 14); sys.entity[sys.entities++] = Slvs_MakePoint2d(302, g, 200, 13, 14);
// And we create a line segment with those endpoints. /* And we create a line segment with those endpoints. */
sys.entity[sys.entities++] = Slvs_MakeLineSegment(400, g, sys.entity[sys.entities++] = Slvs_MakeLineSegment(400, g,
200, 301, 302); 200, 301, 302);
// Now three more points. /* Now three more points. */
sys.param[sys.params++] = Slvs_MakeParam(15, g, 100.0); sys.param[sys.params++] = Slvs_MakeParam(15, g, 100.0);
sys.param[sys.params++] = Slvs_MakeParam(16, g, 120.0); sys.param[sys.params++] = Slvs_MakeParam(16, g, 120.0);
sys.entity[sys.entities++] = Slvs_MakePoint2d(303, g, 200, 15, 16); sys.entity[sys.entities++] = Slvs_MakePoint2d(303, g, 200, 15, 16);
@ -132,12 +138,12 @@ void Example2d(void)
sys.param[sys.params++] = Slvs_MakeParam(20, g, 115.0); sys.param[sys.params++] = Slvs_MakeParam(20, g, 115.0);
sys.entity[sys.entities++] = Slvs_MakePoint2d(305, g, 200, 19, 20); sys.entity[sys.entities++] = Slvs_MakePoint2d(305, g, 200, 19, 20);
// And arc, centered at point 303, starting at point 304, ending at /* And arc, centered at point 303, starting at point 304, ending at
// point 305. * point 305. */
sys.entity[sys.entities++] = Slvs_MakeArcOfCircle(401, g, 200, 102, sys.entity[sys.entities++] = Slvs_MakeArcOfCircle(401, g, 200, 102,
303, 304, 305); 303, 304, 305);
// Now one more point, and a distance /* Now one more point, and a distance */
sys.param[sys.params++] = Slvs_MakeParam(21, g, 200.0); sys.param[sys.params++] = Slvs_MakeParam(21, g, 200.0);
sys.param[sys.params++] = Slvs_MakeParam(22, g, 200.0); sys.param[sys.params++] = Slvs_MakeParam(22, g, 200.0);
sys.entity[sys.entities++] = Slvs_MakePoint2d(306, g, 200, 21, 22); sys.entity[sys.entities++] = Slvs_MakePoint2d(306, g, 200, 21, 22);
@ -145,13 +151,13 @@ void Example2d(void)
sys.param[sys.params++] = Slvs_MakeParam(23, g, 30.0); sys.param[sys.params++] = Slvs_MakeParam(23, g, 30.0);
sys.entity[sys.entities++] = Slvs_MakeDistance(307, g, 200, 23); sys.entity[sys.entities++] = Slvs_MakeDistance(307, g, 200, 23);
// And a complete circle, centered at point 306 with radius equal to /* And a complete circle, centered at point 306 with radius equal to
// distance 307. The normal is 102, the same as our workplane. * distance 307. The normal is 102, the same as our workplane. */
sys.entity[sys.entities++] = Slvs_MakeCircle(402, g, 200, sys.entity[sys.entities++] = Slvs_MakeCircle(402, g, 200,
306, 102, 307); 306, 102, 307);
// The length of our line segment is 30.0 units. /* The length of our line segment is 30.0 units. */
sys.constraint[sys.constraints++] = Slvs_MakeConstraint( sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
1, g, 1, g,
SLVS_C_PT_PT_DISTANCE, SLVS_C_PT_PT_DISTANCE,
@ -159,45 +165,46 @@ void Example2d(void)
30.0, 30.0,
301, 302, 0, 0); 301, 302, 0, 0);
// And the distance from our line segment to the origin is 10.0 units. /* And the distance from our line segment to the origin is 10.0 units. */
sys.constraint[sys.constraints++] = Slvs_MakeConstraint( sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
2, g, 2, g,
SLVS_C_PT_LINE_DISTANCE, SLVS_C_PT_LINE_DISTANCE,
200, 200,
10.0, 10.0,
101, 0, 400, 0); 101, 0, 400, 0);
// And the line segment is vertical. /* And the line segment is vertical. */
sys.constraint[sys.constraints++] = Slvs_MakeConstraint( sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
3, g, 3, g,
SLVS_C_VERTICAL, SLVS_C_VERTICAL,
200, 200,
0.0, 0.0,
0, 0, 400, 0); 0, 0, 400, 0);
// And the distance from one endpoint to the origin is 15.0 units. /* And the distance from one endpoint to the origin is 15.0 units. */
sys.constraint[sys.constraints++] = Slvs_MakeConstraint( sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
4, g, 4, g,
SLVS_C_PT_PT_DISTANCE, SLVS_C_PT_PT_DISTANCE,
200, 200,
15.0, 15.0,
301, 101, 0, 0); 301, 101, 0, 0);
/* #if 0
// And same for the other endpoint; so if you add this constraint then /* And same for the other endpoint; so if you add this constraint then
// the sketch is overconstrained and will signal an error. * the sketch is overconstrained and will signal an error. */
sys.constraint[sys.constraints++] = Slvs_MakeConstraint( sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
5, g, 5, g,
SLVS_C_PT_PT_DISTANCE, SLVS_C_PT_PT_DISTANCE,
200, 200,
18.0, 18.0,
302, 101, 0, 0); */ 302, 101, 0, 0);
#endif /* 0 */
// The arc and the circle have equal radius. /* The arc and the circle have equal radius. */
sys.constraint[sys.constraints++] = Slvs_MakeConstraint( sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
6, g, 6, g,
SLVS_C_EQUAL_RADIUS, SLVS_C_EQUAL_RADIUS,
200, 200,
0.0, 0.0,
0, 0, 401, 402); 0, 0, 401, 402);
// The arc has radius 17.0 units. /* The arc has radius 17.0 units. */
sys.constraint[sys.constraints++] = Slvs_MakeConstraint( sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
7, g, 7, g,
SLVS_C_DIAMETER, SLVS_C_DIAMETER,
@ -205,11 +212,11 @@ void Example2d(void)
17.0*2, 17.0*2,
0, 0, 401, 0); 0, 0, 401, 0);
// If the solver fails, then ask it to report which constraints caused /* If the solver fails, then ask it to report which constraints caused
// the problem. * the problem. */
sys.calculateFaileds = 1; sys.calculateFaileds = 1;
// And solve. /* And solve. */
Slvs_Solve(&sys, g); Slvs_Solve(&sys, g);
if(sys.result == SLVS_RESULT_OKAY) { if(sys.result == SLVS_RESULT_OKAY) {
@ -242,9 +249,8 @@ void Example2d(void)
} }
} }
int main(void) int main()
{ {
memset(&sys, 0, sizeof(sys));
sys.param = CheckMalloc(50*sizeof(sys.param[0])); sys.param = CheckMalloc(50*sizeof(sys.param[0]));
sys.entity = CheckMalloc(50*sizeof(sys.entity[0])); sys.entity = CheckMalloc(50*sizeof(sys.entity[0]));
sys.constraint = CheckMalloc(50*sizeof(sys.constraint[0])); sys.constraint = CheckMalloc(50*sizeof(sys.constraint[0]));
@ -252,7 +258,7 @@ int main(void)
sys.failed = CheckMalloc(50*sizeof(sys.failed[0])); sys.failed = CheckMalloc(50*sizeof(sys.failed[0]));
sys.faileds = 50; sys.faileds = 50;
// Example3d(); /*Example3d();*/
for(;;) { for(;;) {
Example2d(); Example2d();
sys.params = sys.constraints = sys.entities = 0; sys.params = sys.constraints = sys.entities = 0;

View File

@ -313,6 +313,10 @@ SLVS_C_LENGTH_RATIO*
The length of line entityA divided by the length of line entityB is The length of line entityA divided by the length of line entityB is
equal to valA. equal to valA.
SLVS_C_LENGTH_DIFFERENCE*
The lengths of line entityA and line entityB differ by valA.
SLVS_C_EQ_LEN_PT_LINE_D* SLVS_C_EQ_LEN_PT_LINE_D*
The length of the line entityA is equal to the distance from point The length of the line entityA is equal to the distance from point

View File

@ -511,6 +511,7 @@ Module VbDemo
Public Const SLVS_C_PROJ_PT_DISTANCE As Integer = 100030 Public Const SLVS_C_PROJ_PT_DISTANCE As Integer = 100030
Public Const SLVS_C_WHERE_DRAGGED As Integer = 100031 Public Const SLVS_C_WHERE_DRAGGED As Integer = 100031
Public Const SLVS_C_CURVE_CURVE_TANGENT As Integer = 100032 Public Const SLVS_C_CURVE_CURVE_TANGENT As Integer = 100032
Public Const SLVS_C_LENGTH_DIFFERENCE As Integer = 100033
<StructLayout(LayoutKind.Sequential)> Public Structure Slvs_Constraint <StructLayout(LayoutKind.Sequential)> Public Structure Slvs_Constraint
Public h As UInteger Public h As UInteger

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
extlib/libdxfrw Submodule

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

1
extlib/libpng Submodule

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

1
extlib/pixman Submodule

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

373
extlib/si/si.h Normal file
View File

@ -0,0 +1,373 @@
/*----------------------------------------------------------------------
* si.h -- SpaceWare input library header
*
* $Id: si.h,v 1.22 1998/03/12 11:07:03 mfarr Exp $
*
* SpaceWare input library
*
*----------------------------------------------------------------------
*
* (C) 1998-2001 3Dconnexion. All rights reserved.
* Permission to use, copy, modify, and distribute this software for all
* purposes and without fees is hereby grated provided that this copyright
* notice appears in all copies. Permission to modify this software is granted
* and 3Dconnexion will support such modifications only is said modifications are
* approved by 3Dconnexion.
*
*/
#ifndef _SI_H_
#define _SI_H_
static char incFileNameCvsId[]="(C) 1996 Spacetec IMC Corporation: $Id: si.h,v 1.22 1998/03/12 11:07:03 mfarr Exp $";
#include <windows.h>
#include "spwmacro.h"
#include "spwdata.h"
#include "siSync.h"
#include <stdio.h>
#include "spwerror.h"
/*
* UI modes
*/
#define SI_UI_ALL_CONTROLS 0xffffffffL
#define SI_UI_NO_CONTROLS 0x00000000L
/*
* These UI modes are left here for legacy applications.
*/
#define SI_UI_FILTERS 0x00000001L
#define SI_UI_FUNC_BUTTONS 0x00000002L
#define SI_UI_RESET_BUTTONS 0x00000004L
#define SI_UI_SENSITIVITY 0x00000008L
#define SI_UI_TUNING 0x00000010L
#define SI_UI_DIALOG_POPUP 0x00000020L
/*
* Device types and classes
*/
typedef enum
{
SI_ALL_TYPES = -1,
SI_UNKNOWN_DEVICE = 0,
SI_SPACEBALL_2003 = 1,
SI_SPACEBALL_3003 = 2,
SI_SPACE_CONTROLLER = 3,
SI_AVENGER = 4,
SI_SPACEORB_360 = 5,
SI_NAVIGATOR = 6,
SI_SPACEBALL_2003A = 7,
SI_SPACEBALL_2003B = 8,
SI_SPACEBALL_2003C = 9,
SI_SPACEBALL_3003A = 10,
SI_SPACEBALL_3003B = 11,
SI_SPACEBALL_3003C = 12,
SI_SPACEBALL_4000 = 13,
SI_SPACEMOUSE_CLASSIC = 14,
SI_SPACEMOUSE_PLUS = 15,
SI_SPACEMOUSE_XT = 16,
SI_CYBERMAN = 17,
SI_CADMAN = 18,
SI_SPACEMOUSE_CLASSIC_PROMO = 19,
SI_SERIAL_CADMAN = 20,
SI_SPACEBALL_5000 = 21,
SI_TEST_NO_DEVICE = 22,
SI_3DX_KEYBOARD_BLACK = 23,
SI_3DX_KEYBOARD_WHITE = 24,
SI_TRAVELER = 25,
SI_TRAVELER1 = 26,
SI_SPACEBALL_5000A = 27,
SI_SPACEDRAGON = 28,
SI_SPACEPILOT = 29,
SI_NUM_DEV_TYPES /* Leave this last, add before it */
} SiDevType;
/*
* These defintions of device classes are left in for legacy applications.
*/
#define SI_HIGH_END 63
#define SI_MED_END 62
#define SI_LOW_END 61
/*
* Data retrieval mode, only SI_EVENT is currently supported.
*/
#define SI_EVENT 0x0001
#define SI_POLL 0x0002
/*
* Get event flags
*/
#define SI_AVERAGE_EVENTS 0x0001
/*
* This is an INTERNAL flag used by the polling mechanism, user applications
* should NOT send this flag.
*/
#define SI_POLLED_REQUEST 0x0100
/*
* SpaceWare event types
*/
typedef enum
{
SI_BUTTON_EVENT = 1,
SI_MOTION_EVENT,
SI_COMBO_EVENT, /* Not implemented */
SI_ZERO_EVENT,
SI_EXCEPTION_EVENT,
SI_OUT_OF_BAND,
SI_ORIENTATION_EVENT,
SI_KEYBOARD_EVENT,
SI_LPFK_EVENT,
SI_APP_EVENT, /* Application functions */
SI_SYNC_EVENT, /* GUI synchronization events */
SI_BUTTON_PRESS_EVENT, /* Single button events (replace SI_BUTTON_EVENT) */
SI_BUTTON_RELEASE_EVENT /* Single button events (replace SI_BUTTON_EVENT) */
} SiEventType;
/*
* Data modes
*/
#define SI_MODE_NORMALIZE 0x0001
#define SI_MODE_COMPRESS 0x0002
#define SI_MODE_SENSITIVITY 0x0004
#define SI_MODE_TUNING 0x0008
/*
* Motion data offsets
*/
#define SI_TX 0 /* Translation X value */
#define SI_TY 1 /* Translation Y value */
#define SI_TZ 2 /* Translation Z value */
#define SI_RX 3 /* Rotation X value */
#define SI_RY 4 /* Rotation Y value */
#define SI_RZ 5 /* Rotation Z value */
/*
* Reserved buttons
*/
#define SI_RESET_DEVICE_BIT 0x00000001L
#define SI_APP_FIT_BIT 0x80000000L
#define SI_APP_DIALOG_BIT 0x40000000L
#define SI_RESET_DEVICE_BUTTON 0
#define SI_APP_FIT_BUTTON 31
#define SI_APP_DIALOG_BUTTON 30
/*
* Miscellaneous
*/
#define SI_END_ARGS 0
#define SI_NO_HANDLE ((SiHdl) NULL)
#define SI_ALL_HANDLES ((SiHdl) NULL)
#define SI_ANY_HANDLE ((SiHdl) NULL)
#define SI_NO_TRANSCTL ((SiTransCtl) NULL)
#define SI_NO_MASK ((SiTypeMask *) NULL)
#define SI_ANY_DEVICE -1
#define SI_NO_DEVICE -1
#define SI_NO_TYPE -1
#define SI_NO_LIST -1
#define SI_NO_BUTTON -1
#define SI_STRSIZE 128
#define SI_MAXBUF 128
#define SI_KEY_MAXBUF 5120
typedef int SiDevID; /* Device ID */
typedef void *SiHdl; /* SpaceWare handle */
typedef void *SiTransCtl; /* SpaceWare transport control handle */
typedef struct /* Open data */
{
HWND hWnd; /* Window handle for SpaceWare messages. */
SiTransCtl transCtl; /* SpaceWare transport control handle. Reserved */
/* for the s80 transport mechanism. */
DWORD processID; /* The process ID for this application. */
char exeFile[MAX_PATH]; /* The executable name of the process. */
SPWint32 libFlag; /* Library version flag. */
} SiOpenData;
typedef struct /* Get event Data */
{
UINT msg;
WPARAM wParam;
LPARAM lParam;
} SiGetEventData;
typedef struct /* Device type mask */
{
unsigned char mask[8];
} SiTypeMask;
typedef struct /* Device port information */
{
SiDevID devID; /* Device ID */
int devType; /* Device type */
int devClass; /* Device class */
char devName[SI_STRSIZE]; /* Device name */
char portName[SI_STRSIZE]; /* Port name */
} SiDevPort;
typedef struct /* Device information */
{
char firmware[SI_STRSIZE]; /* Firmware version */
int devType; /* Device type */
int numButtons; /* Number of buttons */
int numDegrees; /* Number of degrees of freedom */
SPWbool canBeep; /* Device beeps */
int majorVersion; /* Major version number */
int minorVersion; /* Minor version number */
} SiDevInfo;
typedef struct /* Button information */
{
char name[SI_STRSIZE]; /* Contains the name of a button for display in an app's GUI */
} SiButtonName;
typedef struct /* Button information */
{
char name[SI_STRSIZE]; /* Contains the name of a device for display in an app's GUI */
} SiDeviceName;
typedef struct /* Version information */
{
int major; /* Major version number */
int minor; /* Minor version number */
int build; /* Build number */
char version[SI_STRSIZE]; /* Version string */
char date[SI_STRSIZE]; /* Date string */
} SiVerInfo;
typedef struct /* Sensitivity parameters */
{
char dummy;
} SiSensitivity;
typedef struct /* Tuning parameters */
{
char dummy;
} SiTuning;
typedef struct
{
SPWuint8 code; /* Out of band message code */
union {
SPWuint8 message[SI_MAXBUF-1]; /* The actual message */
void *pvoid[SI_MAXBUF/8]; /* void ptrs. Enough room for 64bit ptrs */
};
} SiSpwOOB;
typedef struct
{
SPWuint8 string[SI_KEY_MAXBUF]; /* String for keyboard data */
} SiKeyboardData;
typedef struct
{
SPWuint32 lpfk; /* LPFK number to send */
} SiLpfkData;
typedef enum
{
SI_LEFT = 0,
SI_RIGHT
} SiOrientation;
typedef struct /* Bitmasks of button states */
{
SPWuint32 last; /* Buttons pressed as of last event */
SPWuint32 current; /* Buttons pressed as of this event */
SPWuint32 pressed; /* Buttons pressed this event */
SPWuint32 released; /* Buttons released this event */
} SiButtonData;
/*
* SI_BUTTON_PRESS_EVENT & SI_BUTTON_RELEASE_EVENT are hardware button
* events. Meaning that they are meant to be sent when a specific hardware
* button is pressed. The correlation between the actual hardware button
* and the resulting button number could be broken by careful editing of
* a config file, but it is intended that the correlation be intact.
* This is basically the same as SI_BUTTON_EVENT, but allows
* more than 29 buttons because it isn't limited to a 32-bit mask.
* Different entries in the config file determine whether SI_BUTTON_PRESS/RELEASE_EVENTs
* or SI_BUTTON_EVENTs will be generated.
* This event was introduced in 3DxWare 5.2.
*/
typedef struct /* Data for SI_BUTTON_PRESS/RELEASE_EVENT */
{
SPWuint32 buttonNumber; /* The button number that went down/up in a *
* SI_BUTTON_PRESS/RELEASE_EVENT event */
} SiHWButtonData;
typedef struct /* Data for SI_APP_EVENT */
{
SPWuint32 functionNumber; /* The Application-specific function number
* invoked by the user in a SI_APP_EVENT */
} SiAppEventData;
typedef struct /* SpaceWare data */
{
SiButtonData bData; /* Button data */
long mData[6]; /* Motion data (index via SI_TX, etc) */
long period; /* Period (milliseconds) */
} SiSpwData;
typedef struct /* SpaceWare event */
{
int type; /* Event type */
union
{
SiSpwData spwData; /* Button, motion, or combo data */
SiSpwOOB spwOOB; /* Out of band message */
SiOrientation spwOrientation;/* Which hand orientation is the device */
char exData[SI_MAXBUF]; /* Exception data */
SiKeyboardData spwKeyData; /* String for keyboard data */
SiLpfkData spwLpfkData; /* LPFK data */
SiSyncPacket siSyncPacket; /* GUI SyncPacket sent to applications */
SiHWButtonData hwButtonEvent;/* ButtonNumber that goes with *
* SI_BUTTON_PRESS/RELEASE_EVENT */
SiAppEventData appEventData; /* Application event function data that *
* goes with an SI_APP_EVENT event */
} u;
} SiSpwEvent;
typedef struct /* Event handler (for SiDispatch) */
{
int (*func) (SiOpenData *, SiGetEventData *, SiSpwEvent *, void *);
void *data;
} SiEventHandler;
typedef struct /* SpaceWare event handlers */
{
SiEventHandler button; /* Button event handler */
SiEventHandler motion; /* Motion event handler */
SiEventHandler combo; /* Combo event handler */
SiEventHandler zero; /* Zero event handler */
SiEventHandler exception; /* Exception event handler */
} SiSpwHandlers;
#ifdef __cplusplus
extern "C" {
#endif
enum SpwRetVal SiAndTypeMask (SiTypeMask *pTMaskA, SiTypeMask *pTMaskB);
int SiGetPortList (SiDevPort **ppPort);
void SiFreePortList (SiDevPort *pPort);
void SiTune2003 (SiSpwEvent *pEvent);
void SiTuneSC (SiSpwEvent *pEvent);
#ifdef __cplusplus
}
#endif
#endif /* _SI_H_ */

206
extlib/si/siSync.h Normal file
View File

@ -0,0 +1,206 @@
/*----------------------------------------------------------------------
* siSync.h -- 3DxWare GUI Synchronization header
*
* Written: September 2004
* Author: Jim Wick
*
*----------------------------------------------------------------------
*
* (c) 1998-2005 3Dconnexion. All rights reserved.
* Permission to use, copy, modify, and distribute this software for all
* purposes and without fees is hereby grated provided that this copyright
* notice appears in all copies. Permission to modify this software is granted
* and 3Dconnexion will support such modifications only is said modifications are
* approved by 3Dconnexion.
*
*/
#ifndef _SISYNC_H_
#define _SISYNC_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* Constants
*/
#define SI_SYNC_PACKET_ID 27711
#define SI_SYNC_VERSION_MAJOR 1
#define SI_SYNC_VERSION_MINOR 0
/*
* Absolute Internal Function Numbers
* These are function numbers that will never change.
* For use with Set BUTTON_ASSIGNMENT_ABSOLUTE packets, and some INVOKE items.
* Some functions (keys) can not be INVOKED because there is a separate
* press and release and that difference is not exposed.
*/
typedef enum
{
SI_SYNC_FUNCTION_MENU_TOGGLE = 12,
SI_SYNC_FUNCTION_TRANS_TOGGLE = 13,
SI_SYNC_FUNCTION_ROT_TOGGLE = 14,
SI_SYNC_FUNCTION_HPV_TOGGLE = 15,
SI_SYNC_FUNCTION_DEC_SENS = 16,
SI_SYNC_FUNCTION_INC_SENS = 17,
SI_SYNC_FUNCTION_RESTORE_DEF = 18,
SI_SYNC_FUNCTION_PAN = 19,
SI_SYNC_FUNCTION_ZOOM = 20,
SI_SYNC_FUNCTION_TX = 21,
SI_SYNC_FUNCTION_TY = 22,
SI_SYNC_FUNCTION_TZ = 23,
SI_SYNC_FUNCTION_RX = 24,
SI_SYNC_FUNCTION_RY = 25,
SI_SYNC_FUNCTION_RZ = 26,
SI_SYNC_FUNCTION_REZERO_DEVICE = 27,
SI_SYNC_FUNCTION_SAVE = 33,
SI_SYNC_FUNCTION_RELOAD = 57,
SI_SYNC_FUNCTION_SHIFT_KEY = 60,
SI_SYNC_FUNCTION_CTRL_KEY = 61,
SI_SYNC_FUNCTION_ALT_KEY = 62,
SI_SYNC_FUNCTION_RESTORE_SENS = 63,
SI_SYNC_FUNCTION_SPACE_KEY = 64,
SI_SYNC_FUNCTION_CTRL_SHIFT_KEY = 65,
SI_SYNC_FUNCTION_CTRL_ALT_KEY = 66,
SI_SYNC_FUNCTION_SHIFT_ALT_KEY = 67,
SI_SYNC_FUNCTION_TAB_KEY = 68,
SI_SYNC_FUNCTION_RETURN_KEY = 69,
SI_SYNC_FUNCTION_DEC_TRANS_SENS = 70,
SI_SYNC_FUNCTION_INC_TRANS_SENS = 71,
SI_SYNC_FUNCTION_DEC_ROT_SENS = 72,
SI_SYNC_FUNCTION_INC_ROT_SENS = 73,
SI_SYNC_FUNCTION_DEC_PAN_SENS = 74,
SI_SYNC_FUNCTION_INC_PAN_SENS = 75,
SI_SYNC_FUNCTION_DEC_ZOOM_SENS = 76,
SI_SYNC_FUNCTION_INC_ZOOM_SENS = 77,
SI_SYNC_FUNCTION_ESC_KEY = 78,
SI_SYNC_FUNCTION_3DX_HELP = 94,
SI_SYNC_FUNCTION_APP_HELP = 95,
SI_SYNC_FUNCTION_DIALOG_TOGGLE_FN= 96,
SI_SYNC_FUNCTION_FIT_FN = 97
} SiSyncAbsFunctionNumber;
/*
* Sync Op Codes
*/
typedef enum
{
SI_SYNC_OP_COMMAND = 1,
SI_SYNC_OP_GET = 2,
SI_SYNC_OP_SET = 3
} SiSyncOpCode;
/*
* Sync Item Codes
*/
typedef enum
{
SI_SYNC_ITEM_VERSION = 1,
SI_SYNC_ITEM_QUERY = 2,
SI_SYNC_ITEM_SAVE_CONFIG = 3,
SI_SYNC_ITEM_NUMBER_OF_FUNCTIONS = 4,
SI_SYNC_ITEM_FUNCTION = 5,
SI_SYNC_ITEM_BUTTON_ASSIGNMENT = 6,
SI_SYNC_ITEM_BUTTON_ASSIGNMENT_ABSOLUTE = 7,
SI_SYNC_ITEM_BUTTON_NAME = 8,
SI_SYNC_ITEM_AXIS_LABEL = 9,
SI_SYNC_ITEM_ORIENTATION = 10,
SI_SYNC_ITEM_FILTER = 11,
SI_SYNC_ITEM_AXES_STATE = 12,
SI_SYNC_ITEM_INFO_LINE = 13,
SI_SYNC_ITEM_SCALE_OVERALL = 14,
SI_SYNC_ITEM_SCALE_TX = 15,
SI_SYNC_ITEM_SCALE_TY = 16,
SI_SYNC_ITEM_SCALE_TZ = 17,
SI_SYNC_ITEM_SCALE_RX = 18,
SI_SYNC_ITEM_SCALE_RY = 19,
SI_SYNC_ITEM_SCALE_RZ = 20,
SI_SYNC_ITEM_INVOKE_ABSOLUTE_FUNCTION = 21,
SI_SYNC_ITEM_BUTTON_STATE = 22
} SiSyncItemCode;
/*
* Filters
*/
typedef enum
{
SI_SYNC_FILTER_TRANSLATIONS = 1,
SI_SYNC_FILTER_ROTATIONS = 2,
SI_SYNC_FILTER_DOMINANT = 3
} SiSyncFilter;
typedef enum
{
SI_SYNC_FILTER_OFF = 0,
SI_SYNC_FILTER_ON = 1,
SI_SYNC_FILTER_IN_BETWEEN = 2
} SiSyncFilterValue;
/*
* Axes State
*/
typedef enum
{
SI_SYNC_AXES_STATE_TX = (1<<0),
SI_SYNC_AXES_STATE_TY = (1<<1),
SI_SYNC_AXES_STATE_TZ = (1<<2),
SI_SYNC_AXES_STATE_RX = (1<<3),
SI_SYNC_AXES_STATE_RY = (1<<4),
SI_SYNC_AXES_STATE_RZ = (1<<5)
} SiSyncAxesStateBits;
typedef struct
{
int state; /* VURZYX (Tx = LSB (& 1<<0) */
} SiSyncAxesState;
/*
* Button State
* For indicating the state of whatever the button sets (in the LCD at this point).
* E.g., to show that Translations are currently OFF for the Translations Toggle button.
* OFF: reverse video, flag is not set
* ON: normal video, flag is set
* DISABLED: (greyed), status of flag is invalid at this time
*/
typedef enum
{
SI_SYNC_BUTTON_STATE_OFF = 0,
SI_SYNC_BUTTON_STATE_ON = 1,
SI_SYNC_BUTTON_STATE_DISABLED = 2,
} SiSyncButtonState;
/*
* Private / implementation structures
*
* We suggest you leave these hidden and use the accessor functions rather than
* directly accessing the structures.
*/
#include "siSyncPriv.h"
/*
* Accessor Function headers
*/
SPWuint32 SiSyncGetSize(SiSyncPacket p);
void SiSyncSetSize(SiSyncPacket *p, SPWuint32 size);
SPWuint32 SiSyncGetHashCode(SiSyncPacket p);
void SiSyncSetHashCode(SiSyncPacket *p, SPWuint32 hashCode);
SiSyncOpCode SiSyncGetOpCode(SiSyncPacket p);
void SiSyncSetOpCode(SiSyncPacket *p, SPWuint32 opCode);
SiSyncItemCode SiSyncGetItemCode(SiSyncPacket p);
void SiSyncSetItemCode(SiSyncPacket *p, SPWuint32 itemCode);
#ifdef __cplusplus
}
#endif
#endif /* _SI_SYNC_H_ */

127
extlib/si/siSyncPriv.h Normal file
View File

@ -0,0 +1,127 @@
/*----------------------------------------------------------------------
* siSyncPriv.h -- 3DxWare GUI Synchronization Private header
*
* Written: June 2005
* Author: Jim Wick
*
*----------------------------------------------------------------------
*
* (c) 1998-2005 3Dconnexion. All rights reserved.
* Permission to use, copy, modify, and distribute this software for all
* purposes and without fees is hereby grated provided that this copyright
* notice appears in all copies. Permission to modify this software is granted
* and 3Dconnexion will support such modifications only is said modifications are
* approved by 3Dconnexion.
*
*/
#ifndef _SISYNCPRIV_H_
#define _SISYNCPRIV_H_
/*
* All packets start with the same fields.
* Many packets have data following the itemCode.
*/
typedef struct /* Sync Packet */
{
SPWuint32 size; /* total packet size */
SPWuint32 hashCode; /* Hash code that syncs a question with an answer */
SiSyncOpCode opCode; /* OpCode */
SiSyncItemCode itemCode; /* itemCode */
/* There will, generally, be more data starting here.
* There will not be any pointers, the data will be in here.
*/
} SiSyncPacketHeader;
/*
* I've enumerated all the possible packets here, not because they are all different,
* but mostly just for documentation. So the developer knows what parameters are
* expected with which packet type.
*/
typedef struct { SiSyncPacketHeader h; } SiSyncGetVersionPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 major; SPWint32 minor; } SiSyncSetVersionPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncCommandQueryPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncCommandSaveConfigPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetNumberOfFunctionsPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 n; } SiSyncSetNumberOfFunctionsPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 i; } SiSyncGetFunctionPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 i; SPWint32 n; WCHAR name[1];} SiSyncSetFunctionPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 i; } SiSyncGetButtonAssignmentPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 i; SPWint32 n; } SiSyncSetButtonAssignmentPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 i; SPWint32 n; } SiSyncSetButtonAssignmentAbsolutePacket;
typedef struct { SiSyncPacketHeader h; SPWint32 i; WCHAR name[1]; } SiSyncSetButtonNamePacket;
typedef struct { SiSyncPacketHeader h; SPWint32 i; } SiSyncGetAxisLabelPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 i; WCHAR name[1]; } SiSyncSetAxisLabelPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetOrientationPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 a[6]; } SiSyncSetOrientationPacket;
typedef struct { SiSyncPacketHeader h; SiSyncFilter i; } SiSyncGetFilterPacket;
typedef struct { SiSyncPacketHeader h; SiSyncFilter i; SiSyncFilterValue v; } SiSyncSetFilterPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetAxesStatePacket;
typedef struct { SiSyncPacketHeader h; SiSyncAxesState a; } SiSyncSetAxesStatePacket;
typedef struct { SiSyncPacketHeader h; SPWint32 duration; WCHAR s[1]; } SiSyncSetInfoLinePacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetScaleOverallPacket;
typedef struct { SiSyncPacketHeader h; SPWfloat32 v; } SiSyncSetScaleOverallPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetScaleTxPacket;
typedef struct { SiSyncPacketHeader h; SPWfloat32 v; } SiSyncSetScaleTxPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetScaleTyPacket;
typedef struct { SiSyncPacketHeader h; SPWfloat32 v; } SiSyncSetScaleTyPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetScaleTzPacket;
typedef struct { SiSyncPacketHeader h; SPWfloat32 v; } SiSyncSetScaleTzPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetScaleRxPacket;
typedef struct { SiSyncPacketHeader h; SPWfloat32 v; } SiSyncSetScaleRxPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetScaleRyPacket;
typedef struct { SiSyncPacketHeader h; SPWfloat32 v; } SiSyncSetScaleRyPacket;
typedef struct { SiSyncPacketHeader h; } SiSyncGetScaleRzPacket;
typedef struct { SiSyncPacketHeader h; SPWfloat32 v; } SiSyncSetScaleRzPacket;
typedef struct { SiSyncPacketHeader h; SiSyncAbsFunctionNumber i; } SiSyncAbsFunctionPacket;
typedef struct { SiSyncPacketHeader h; SPWint32 i; SPWbool state; } SiSyncSetButtonStatePacket;
typedef struct
{
union
{
SiSyncPacketHeader h;
SiSyncGetVersionPacket gv;
SiSyncSetVersionPacket sv;
SiSyncCommandQueryPacket cq;
SiSyncCommandSaveConfigPacket cs;
SiSyncGetNumberOfFunctionsPacket gnf;
SiSyncSetNumberOfFunctionsPacket snf;
SiSyncGetFunctionPacket gf;
SiSyncSetFunctionPacket sf;
SiSyncGetButtonAssignmentPacket gba;
SiSyncSetButtonAssignmentPacket sba;
SiSyncSetButtonAssignmentAbsolutePacket sbaa;
SiSyncSetButtonNamePacket sbn;
SiSyncGetAxisLabelPacket ga;
SiSyncSetAxisLabelPacket sa;
SiSyncGetOrientationPacket go;
SiSyncSetOrientationPacket so;
SiSyncGetFilterPacket gfi;
SiSyncSetFilterPacket sfi;
SiSyncGetAxesStatePacket gas;
SiSyncSetAxesStatePacket sas;
SiSyncSetInfoLinePacket si;
SiSyncGetScaleOverallPacket gso;
SiSyncSetScaleOverallPacket sso;
SiSyncGetScaleTxPacket gtx;
SiSyncSetScaleTxPacket stx;
SiSyncGetScaleTyPacket gty;
SiSyncSetScaleTyPacket sty;
SiSyncGetScaleTzPacket gtz;
SiSyncSetScaleTzPacket stz;
SiSyncGetScaleRxPacket grx;
SiSyncSetScaleRxPacket srx;
SiSyncGetScaleRyPacket gry;
SiSyncSetScaleRyPacket sry;
SiSyncGetScaleRzPacket grz;
SiSyncSetScaleRzPacket srz;
SiSyncAbsFunctionPacket absf;
SiSyncSetButtonStatePacket sbs;
};
} SiSyncPacket;
#endif /* _SI_SYNCPRIV_H_ */

121
extlib/si/siapp.h Normal file
View File

@ -0,0 +1,121 @@
/*-----------------------------------------------------------------------------
*
* siapp.h -- Si static library interface header file
*
* $Id: siapp.h,v 1.3 2001/01/16 01:18:49 HJin Exp $
*
* Contains function headers and type definitions for siapp.c.
*
*-----------------------------------------------------------------------------
*
* (c) 1998-2005 3Dconnexion. All rights reserved.
* Permission to use, copy, modify, and distribute this software for all
* purposes and without fees is hereby grated provided that this copyright
* notice appears in all copies. Permission to modify this software is granted
* and 3Dconnexion will support such modifications only if said modifications are
* approved by 3Dconnexion.
*
*/
#ifndef SIAPP_H
#define SIAPP_H
static char SiAppCvsId[]="(c) 1998-2005 3Dconnexion: $Id: siapp.h,v 1.3 2001/01/16 01:18:49 HJin Exp $";
#ifdef __cplusplus
extern "C" {
#endif
/* some enumerated types used in siapp.c */
enum InitResult
{
NOT_LOADED,
FAILED,
LOADED
};
enum ErrorCode
{
NO_DLL_ERROR=0,
DLL_LOAD_FAILURE,
DLL_FUNCTION_LOAD_FAILURE,
DLL_VAR_LOAD_FAILURE
};
/* externally used functions */
enum SpwRetVal SiInitialize(void);
void SiTerminate(void);
int SiGetNumDevices (void);
SiDevID SiDeviceIndex (int idx);
int SiDispatch (SiHdl hdl, SiGetEventData *pData,
SiSpwEvent *pEvent, SiSpwHandlers *pDHandlers);
void SiOpenWinInit (SiOpenData *pData, HWND hWnd);
SiHdl SiOpen (char *pAppName, SiDevID devID, SiTypeMask *pTMask, int mode,
SiOpenData *pData);
enum SpwRetVal SiClose (SiHdl hdl);
void SiGetEventWinInit (SiGetEventData *pData,
UINT msg, WPARAM wParam, LPARAM lParam);
enum SpwRetVal SiGetEvent (SiHdl hdl, int flags, SiGetEventData *pData,
SiSpwEvent *pEvent);
enum SpwRetVal SiBeep (SiHdl hdl, char *string);
enum SpwRetVal SiRezero (SiHdl hdl);
enum SpwRetVal SiGrabDevice (SiHdl hdl, SPWbool exclusive);
enum SpwRetVal SiReleaseDevice (SiHdl hdl);
int SiButtonPressed (SiSpwEvent *pEvent);
int SiButtonReleased (SiSpwEvent *pEvent);
enum SpwRetVal SiSetUiMode (SiHdl hdl, SPWuint32 mode);
enum SpwRetVal SiSetTypeMask (SiTypeMask *pTMask, int type1, ...);
enum SpwRetVal SiGetDevicePort (SiDevID devID, SiDevPort *pPort);
enum SpwRetVal SiGetDriverInfo (SiVerInfo *pInfo);
void SiGetLibraryInfo (SiVerInfo *pInfo);
enum SpwRetVal SiGetDeviceInfo (SiHdl hdl, SiDevInfo *pInfo);
char * SpwErrorString (enum SpwRetVal val);
enum SpwRetVal SiSyncSendQuery(SiHdl hdl);
enum SpwRetVal SiSyncGetVersion(SiHdl hdl, SPWuint32 *pmajor, SPWuint32 *pminor);
enum SpwRetVal SiSyncGetNumberOfFunctions(SiHdl hdl, SPWuint32 *pnumberOfFunctions);
enum SpwRetVal SiSyncGetFunction(SiHdl hdl, SPWuint32 index, SPWint32 *pabsoluteFunctionNumber, WCHAR name[], SPWuint32 *pmaxNameLen);
enum SpwRetVal SiSyncGetButtonAssignment(SiHdl hdl, SPWuint32 buttonNumber, SPWint32 *passignedFunctionIndex);
enum SpwRetVal SiSyncSetButtonAssignment(SiHdl hdl, SPWuint32 buttonNumber, SPWint32 functionIndex);
enum SpwRetVal SiSyncSetButtonAssignmentAbsolute(SiHdl hdl, SPWuint32 buttonNumber, SPWint32 absoluteFunctionNumber );
enum SpwRetVal SiSyncSetButtonName(SiHdl hdl, SPWuint32 buttonNumber, WCHAR name[]);
enum SpwRetVal SiSyncGetAxisLabel (SiHdl hdl, SPWuint32 axisNumber, WCHAR name[], SPWuint32 *pmaxNameLen );
enum SpwRetVal SiSyncSetAxisLabel (SiHdl hdl, SPWuint32 axisNumber, WCHAR name[] );
enum SpwRetVal SiSyncGetOrientation (SiHdl hdl, SPWint32 axes[6] );
enum SpwRetVal SiSyncSetOrientation (SiHdl hdl, SPWint32 axes[6] );
enum SpwRetVal SiSyncGetFilter (SiHdl hdl, SiSyncFilter i, SiSyncFilterValue *pv );
enum SpwRetVal SiSyncSetFilter (SiHdl hdl, SiSyncFilter i, SiSyncFilterValue v );
enum SpwRetVal SiSyncGetAxesState (SiHdl hdl, SiSyncAxesState *pa );
enum SpwRetVal SiSyncSetAxesState (SiHdl hdl, SiSyncAxesState a );
enum SpwRetVal SiSyncSetInfoLine (SiHdl hdl, SPWint32 duration, WCHAR text[] );
enum SpwRetVal SiSyncGetScaleOverall (SiHdl hdl, SPWfloat32 *pv );
enum SpwRetVal SiSyncSetScaleOverall (SiHdl hdl, SPWfloat32 v );
enum SpwRetVal SiSyncGetScaleTx (SiHdl hdl, SPWfloat32 *pv );
enum SpwRetVal SiSyncSetScaleTx (SiHdl hdl, SPWfloat32 v );
enum SpwRetVal SiSyncGetScaleTy (SiHdl hdl, SPWfloat32 *pv );
enum SpwRetVal SiSyncSetScaleTy (SiHdl hdl, SPWfloat32 v );
enum SpwRetVal SiSyncGetScaleTz (SiHdl hdl, SPWfloat32 *pv );
enum SpwRetVal SiSyncSetScaleTz (SiHdl hdl, SPWfloat32 v );
enum SpwRetVal SiSyncGetScaleRx (SiHdl hdl, SPWfloat32 *pv );
enum SpwRetVal SiSyncSetScaleRx (SiHdl hdl, SPWfloat32 v );
enum SpwRetVal SiSyncGetScaleRy (SiHdl hdl, SPWfloat32 *pv );
enum SpwRetVal SiSyncSetScaleRy (SiHdl hdl, SPWfloat32 v );
enum SpwRetVal SiSyncGetScaleRz (SiHdl hdl, SPWfloat32 *pv );
enum SpwRetVal SiSyncSetScaleRz (SiHdl hdl, SPWfloat32 v );
enum SpwRetVal SiSyncInvokeAbsoluteFunction (SiHdl hdl, SiSyncAbsFunctionNumber i );
enum SpwRetVal SiSyncSetButtonState (SiHdl hdl, SPWuint32 buttonNumber, SiSyncButtonState state );
enum SpwRetVal SiGetButtonName (SiHdl hdl, SPWuint32 buttonNumber, SiButtonName *pname);
enum SpwRetVal SiGetDeviceName (SiHdl hdl, SiDeviceName *pname);
enum SpwRetVal SiGetDeviceImageFileName (SiHdl hdl, char name[], SPWuint32 *pmaxNameLen);
HICON SiGetCompanyIcon(void);
enum SpwRetVal SiGetCompanyLogoFileName (char name[], SPWuint32 *pmaxNameLen);
#ifdef __cplusplus
}
#endif
#endif /* #ifndef SIAPP_H */

BIN
extlib/si/siapp.lib Normal file

Binary file not shown.

63
extlib/si/spwdata.h Normal file
View File

@ -0,0 +1,63 @@
/*----------------------------------------------------------------------
* spwdata.h -- datatypes
*
*
* $Id: spwdata.h,v 1.4 1996/10/08 23:01:39 chris Exp $
*
* This contains the only acceptable type definitions for 3Dconnexion
* products. Needs more work.
*
*----------------------------------------------------------------------
*
* (c) 1996-2005 3Dconnexion. All rights reserved.
*
* The computer codes included in this file, including source code and
* object code, constitutes the proprietary and confidential information of
* 3Dconnexion, and are provided pursuant to a license
* agreement. These computer codes are protected by international, federal
* and state law, including United States Copyright Law and international
* treaty provisions. Except as expressly authorized by the license
* agreement, or as expressly permitted under applicable laws of member
* states of the European Union and then only to the extent so permitted,
* no part of these computer codes may be reproduced or transmitted in any
* form or by any means, electronic or mechanical, modified, decompiled,
* disassembled, reverse engineered, sold, transferred, rented or utilized
* for any unauthorized purpose without the express written permission of
* 3Dconnexion.
*
*----------------------------------------------------------------------
*
*/
#ifndef SPWDATA_H
#define SPWDATA_H
static char spwdataCvsId[]="(C) 1996-2005 3Dconnexion: $Id: spwdata.h,v 1.4 1996/10/08 23:01:39 chris Exp $";
#include <tchar.h>
#define tchar_t _TCHAR
#define char_t char
#define uint32_t unsigned long
#define sint32_t long
#define boolean_t unsigned char
#define void_t void
#define window_handle_t HWND
typedef long SPWint32;
typedef short SPWint16;
typedef char SPWint8;
typedef int SPWbool;
typedef unsigned long SPWuint32;
typedef unsigned short SPWuint16;
typedef unsigned char SPWuint8;
typedef _TCHAR SPWchar;
typedef _TCHAR* SPWstring;
typedef float SPWfloat32;
typedef double SPWfloat64;
#endif /* SPWDATA_H */

64
extlib/si/spwerror.h Normal file
View File

@ -0,0 +1,64 @@
/*----------------------------------------------------------------------
* spwerror.h -- Standard Spacetec IMC function return values
*
* $Id: spwerror.h,v 1.10.4.1 1998/05/26 17:30:21 equerze Exp $
*
* This file contains all the Spacetec IMC standard error return
* return values for functions
*
*----------------------------------------------------------------------
*
* (C) 1998-2001 3Dconnexion. All rights reserved.
* Permission to use, copy, modify, and distribute this software for all
* purposes and without fees is hereby grated provided that this copyright
* notice appears in all copies. Permission to modify this software is granted
* and 3Dconnexion will support such modifications only is said modifications are
* approved by 3Dconnexion.
*
*/
#ifndef _SPWERROR_H_
#define _SPWERROR_H_
#include "spwdata.h"
static char spwerrorCvsId[]="(C) 1996 Spacetec IMC Corporation: $Id: spwerror.h,v 1.10.4.1 1998/05/26 17:30:21 equerze Exp $";
enum SpwRetVal /* Error return values. */
{
SPW_NO_ERROR, /* No error. */
SPW_ERROR, /* Error -- function failed. */
SI_BAD_HANDLE, /* Invalid SpaceWare handle. */
SI_BAD_ID, /* Invalid device ID. */
SI_BAD_VALUE, /* Invalid argument value. */
SI_IS_EVENT, /* Event is a SpaceWare event. */
SI_SKIP_EVENT, /* Skip this SpaceWare event. */
SI_NOT_EVENT, /* Event is not a SpaceWare event. */
SI_NO_DRIVER, /* SpaceWare driver is not running. */
SI_NO_RESPONSE, /* SpaceWare driver is not responding. */
SI_UNSUPPORTED, /* The function is unsupported by this version. */
SI_UNINITIALIZED, /* SpaceWare input library is uninitialized. */
SI_WRONG_DRIVER, /* Driver is incorrect for this SpaceWare version.*/
SI_INTERNAL_ERROR, /* Internal SpaceWare error. */
SI_BAD_PROTOCOL, /* The transport protocol is unknown. */
SI_OUT_OF_MEMORY, /* Unable to malloc space required. */
SPW_DLL_LOAD_ERROR, /* Could not load siapp dlls */
SI_NOT_OPEN, /* Spaceball device not open */
SI_ITEM_NOT_FOUND, /* Item not found */
SI_UNSUPPORTED_DEVICE, /* The device is not supported */
SI_NOT_ENOUGH_MEMORY, /* Not enough memory (but not a malloc problem) */
SI_SYNC_WRONG_HASHCODE /* Wrong hash code sent to a Sync function */
};
typedef enum SpwRetVal SpwReturnValue;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SPWERROR_H_ */

48
extlib/si/spwmacro.h Normal file
View File

@ -0,0 +1,48 @@
/*----------------------------------------------------------------------
* spwmacro.h -- cpp macros we ALWAYS use.
*
<<<<<<< spwmacro.h
* $Id: spwmacro.h,v 1.3 2001/01/16 01:18:40 HJin Exp $
=======
* $Id: spwmacro.h,v 1.3 2001/01/16 01:18:40 HJin Exp $
>>>>>>> 1.1.1.1.4.1
*
* We always seem to use the same macros.
* This is the place we define them.
*
*----------------------------------------------------------------------
*/
#ifndef SPWMACRO_H
#define SPWMACRO_H
#define SPW_FALSE (0)
#define SPW_TRUE (!SPW_FALSE)
#define SPW_MAX(a,b) (((a)>(b))?(a):(b))
#define SPW_MIN(a,b) (((a)<(b))?(a):(b))
#define SPW_ABS(a) (((a)<0)?(-(a)):(a))
#define SPW_SIGN(a) ((a)>=0?1:-1)
#define SPW_BIND(min,n,max) (SPW_MIN((max),SPW_MAX((min),(n))))
#define SPW_NUM_ELEMENTS_IN(a) (sizeof(a)/sizeof((a)[0]))
#define SPW_PI 3.14159265358979324f
#define SPW_DEG_TO_RAD(d) ((d)*SPW_PI/180.0f)
#define SPW_RAD_TO_DEG(r) ((r)*180.0f/SPW_PI)
#define SPW_LENGTH_OF(a) (sizeof(a)/sizeof((a)[0]))
#define SPW_END_OF(a) (&(a)[SPW_LENGTH_OF(a)-1])
#define SPW_SQ(a) ((a)*(a))
#define SPW_ABSDIFF(a, b) (fabs((double) (a) - (b)))
#endif

1
extlib/zlib Submodule

@ -0,0 +1 @@
Subproject commit 2fa463bacfff79181df1a5270fb67cc679a53e71

View File

@ -1,38 +1,42 @@
//----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
// Data structures and prototypes for slvs.lib, a geometric constraint solver. * Data structures and prototypes for slvs.lib, a geometric constraint solver.
// *
// See the comments in this file, the accompanying sample code that uses * See the comments in this file, the accompanying sample code that uses
// this library, and the accompanying documentation (DOC.txt). * this library, and the accompanying documentation (DOC.txt).
// *
// Copyright 2009-2013 Jonathan Westhues. * Copyright 2009-2013 Jonathan Westhues.
//----------------------------------------------------------------------------- *---------------------------------------------------------------------------*/
#ifndef __SLVS_H #ifndef __SLVS_H
#define __SLVS_H #define __SLVS_H
#include <stdint.h> #ifdef WIN32
# ifdef EXPORT_DLL
#if defined(WIN32) # define DLL __declspec( dllexport )
#ifdef slvs_EXPORTS # else
#define DLL __declspec( dllexport ) # define DLL __declspec( dllimport )
# endif
#else #else
#define DLL __declspec( dllimport ) # define DLL
#endif
#else
#define DLL
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef _MSC_VER
typedef unsigned __int32 uint32_t;
#else
#include <stdint.h>
#endif
typedef uint32_t Slvs_hParam; typedef uint32_t Slvs_hParam;
typedef uint32_t Slvs_hEntity; typedef uint32_t Slvs_hEntity;
typedef uint32_t Slvs_hConstraint; typedef uint32_t Slvs_hConstraint;
typedef uint32_t Slvs_hGroup; typedef uint32_t Slvs_hGroup;
// To obtain the 3d (not projected into a workplane) of a constraint or /* To obtain the 3d (not projected into a workplane) of a constraint or
// an entity, specify this instead of the workplane. * an entity, specify this instead of the workplane. */
#define SLVS_FREE_IN_3D 0 #define SLVS_FREE_IN_3D 0
@ -51,9 +55,9 @@ typedef struct {
#define SLVS_E_DISTANCE 70000 #define SLVS_E_DISTANCE 70000
// The special point, normal, and distance types used for parametric step /* The special point, normal, and distance types used for parametric step
// and repeat, extrude, and assembly are currently not exposed. Please * and repeat, extrude, and assembly are currently not exposed. Please
// contact us if you are interested in using these. * contact us if you are interested in using these. */
#define SLVS_E_WORKPLANE 80000 #define SLVS_E_WORKPLANE 80000
#define SLVS_E_LINE_SEGMENT 80001 #define SLVS_E_LINE_SEGMENT 80001
@ -108,6 +112,7 @@ typedef struct {
#define SLVS_C_PROJ_PT_DISTANCE 100030 #define SLVS_C_PROJ_PT_DISTANCE 100030
#define SLVS_C_WHERE_DRAGGED 100031 #define SLVS_C_WHERE_DRAGGED 100031
#define SLVS_C_CURVE_CURVE_TANGENT 100032 #define SLVS_C_CURVE_CURVE_TANGENT 100032
#define SLVS_C_LENGTH_DIFFERENCE 100033
typedef struct { typedef struct {
Slvs_hConstraint h; Slvs_hConstraint h;
@ -131,16 +136,15 @@ typedef struct {
typedef struct { typedef struct {
//// INPUT VARIABLES /*** INPUT VARIABLES
// *
// Here, we specify the parameters and their initial values, the entities, * Here, we specify the parameters and their initial values, the entities,
// and the constraints. For example, param[] points to the array of * and the constraints. For example, param[] points to the array of
// parameters, which has length params, so that the last valid element * parameters, which has length params, so that the last valid element
// is param[params-1]. * is param[params-1].
// *
// param[] is actually an in/out variable; if the solver is successful, * param[] is actually an in/out variable; if the solver is successful,
// then the new values (that satisfy the constraints) are written to it. * then the new values (that satisfy the constraints) are written to it. */
//
Slvs_Param *param; Slvs_Param *param;
int params; int params;
Slvs_Entity *entity; Slvs_Entity *entity;
@ -148,56 +152,55 @@ typedef struct {
Slvs_Constraint *constraint; Slvs_Constraint *constraint;
int constraints; int constraints;
// If a parameter corresponds to a point (distance, normal, etc.) being /* If a parameter corresponds to a point (distance, normal, etc.) being
// dragged, then specify it here. This will cause the solver to favor * dragged, then specify it here. This will cause the solver to favor
// that parameter, and attempt to change it as little as possible even * that parameter, and attempt to change it as little as possible even
// if that requires it to change other parameters more. * if that requires it to change other parameters more.
// *
// Unused members of this array should be set to zero. * Unused members of this array should be set to zero. */
Slvs_hParam dragged[4]; Slvs_hParam dragged[4];
// If the solver fails, then it can determine which constraints are /* If the solver fails, then it can determine which constraints are
// causing the problem. But this is a relatively slow process (for * causing the problem. But this is a relatively slow process (for
// a system with n constraints, about n times as long as just solving). * a system with n constraints, about n times as long as just solving).
// If calculateFaileds is true, then the solver will do so, otherwise * If calculateFaileds is true, then the solver will do so, otherwise
// not. * not. */
int calculateFaileds; int calculateFaileds;
//// OUTPUT VARIABLES /*** OUTPUT VARIABLES
// *
// If the solver fails, then it can report which constraints are causing * If the solver fails, then it can report which constraints are causing
// the problem. The caller should allocate the array failed[], and pass * the problem. The caller should allocate the array failed[], and pass
// its size in faileds. * its size in faileds.
// *
// The solver will set faileds equal to the number of problematic * The solver will set faileds equal to the number of problematic
// constraints, and write their Slvs_hConstraints into failed[]. To * constraints, and write their Slvs_hConstraints into failed[]. To
// ensure that there is sufficient space for any possible set of * ensure that there is sufficient space for any possible set of
// failing constraints, faileds should be greater than or equal to * failing constraints, faileds should be greater than or equal to
// constraints. * constraints. */
Slvs_hConstraint *failed; Slvs_hConstraint *failed;
int faileds; int faileds;
// The solver indicates the number of unconstrained degrees of freedom. /* The solver indicates the number of unconstrained degrees of freedom. */
int dof; int dof;
// The solver indicates whether the solution succeeded. /* The solver indicates whether the solution succeeded. */
#define SLVS_RESULT_OKAY 0 #define SLVS_RESULT_OKAY 0
#define SLVS_RESULT_REDUNDANT_OKAY 1 #define SLVS_RESULT_INCONSISTENT 1
#define SLVS_RESULT_REDUNDANT_DIDNT_CONVERGE 2 #define SLVS_RESULT_DIDNT_CONVERGE 2
#define SLVS_RESULT_DIDNT_CONVERGE 3 #define SLVS_RESULT_TOO_MANY_UNKNOWNS 3
#define SLVS_RESULT_TOO_MANY_UNKNOWNS 4
int result; int result;
} Slvs_System; } Slvs_System;
DLL void Slvs_Solve(Slvs_System *sys, Slvs_hGroup hg); DLL void Slvs_Solve(Slvs_System *sys, Slvs_hGroup hg);
// Our base coordinate system has basis vectors /* Our base coordinate system has basis vectors
// (1, 0, 0) (0, 1, 0) (0, 0, 1) * (1, 0, 0) (0, 1, 0) (0, 0, 1)
// A unit quaternion defines a rotation to a new coordinate system with * A unit quaternion defines a rotation to a new coordinate system with
// basis vectors * basis vectors
// U V N * U V N
// which these functions compute from the quaternion. * which these functions compute from the quaternion. */
DLL void Slvs_QuaternionU(double qw, double qx, double qy, double qz, DLL void Slvs_QuaternionU(double qw, double qx, double qy, double qz,
double *x, double *y, double *z); double *x, double *y, double *z);
DLL void Slvs_QuaternionV(double qw, double qx, double qy, double qz, DLL void Slvs_QuaternionV(double qw, double qx, double qy, double qz,
@ -205,18 +208,18 @@ DLL void Slvs_QuaternionV(double qw, double qx, double qy, double qz,
DLL void Slvs_QuaternionN(double qw, double qx, double qy, double qz, DLL void Slvs_QuaternionN(double qw, double qx, double qy, double qz,
double *x, double *y, double *z); double *x, double *y, double *z);
// Similarly, compute a unit quaternion in terms of two basis vectors. /* Similarly, compute a unit quaternion in terms of two basis vectors. */
DLL void Slvs_MakeQuaternion(double ux, double uy, double uz, DLL void Slvs_MakeQuaternion(double ux, double uy, double uz,
double vx, double vy, double vz, double vx, double vy, double vz,
double *qw, double *qx, double *qy, double *qz); double *qw, double *qx, double *qy, double *qz);
//------------------------------------- /*-------------------------------------
// These are just convenience functions, to save you the trouble of filling * These are just convenience functions, to save you the trouble of filling
// out the structures by hand. The code is included in the header file to * out the structures by hand. The code is included in the header file to
// let the compiler inline them if possible. * let the compiler inline them if possible. */
static Slvs_Param Slvs_MakeParam(Slvs_hParam h, Slvs_hGroup group, double val) static inline Slvs_Param Slvs_MakeParam(Slvs_hParam h, Slvs_hGroup group, double val)
{ {
Slvs_Param r; Slvs_Param r;
r.h = h; r.h = h;
@ -224,9 +227,9 @@ static Slvs_Param Slvs_MakeParam(Slvs_hParam h, Slvs_hGroup group, double val)
r.val = val; r.val = val;
return r; return r;
} }
static Slvs_Entity Slvs_MakePoint2d(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakePoint2d(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hEntity wrkpl, Slvs_hEntity wrkpl,
Slvs_hParam u, Slvs_hParam v) Slvs_hParam u, Slvs_hParam v)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -238,8 +241,8 @@ static Slvs_Entity Slvs_MakePoint2d(Slvs_hEntity h, Slvs_hGroup group,
r.param[1] = v; r.param[1] = v;
return r; return r;
} }
static Slvs_Entity Slvs_MakePoint3d(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakePoint3d(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hParam x, Slvs_hParam y, Slvs_hParam z) Slvs_hParam x, Slvs_hParam y, Slvs_hParam z)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -252,8 +255,9 @@ static Slvs_Entity Slvs_MakePoint3d(Slvs_hEntity h, Slvs_hGroup group,
r.param[2] = z; r.param[2] = z;
return r; return r;
} }
static Slvs_Entity Slvs_MakeNormal3d(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakeNormal3d(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hParam qw, Slvs_hParam qx, Slvs_hParam qy, Slvs_hParam qz) Slvs_hParam qw, Slvs_hParam qx,
Slvs_hParam qy, Slvs_hParam qz)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -267,8 +271,8 @@ static Slvs_Entity Slvs_MakeNormal3d(Slvs_hEntity h, Slvs_hGroup group,
r.param[3] = qz; r.param[3] = qz;
return r; return r;
} }
static Slvs_Entity Slvs_MakeNormal2d(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakeNormal2d(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hEntity wrkpl) Slvs_hEntity wrkpl)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -278,8 +282,8 @@ static Slvs_Entity Slvs_MakeNormal2d(Slvs_hEntity h, Slvs_hGroup group,
r.wrkpl = wrkpl; r.wrkpl = wrkpl;
return r; return r;
} }
static Slvs_Entity Slvs_MakeDistance(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakeDistance(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hEntity wrkpl, Slvs_hParam d) Slvs_hEntity wrkpl, Slvs_hParam d)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -290,9 +294,9 @@ static Slvs_Entity Slvs_MakeDistance(Slvs_hEntity h, Slvs_hGroup group,
r.param[0] = d; r.param[0] = d;
return r; return r;
} }
static Slvs_Entity Slvs_MakeLineSegment(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakeLineSegment(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hEntity wrkpl, Slvs_hEntity wrkpl,
Slvs_hEntity ptA, Slvs_hEntity ptB) Slvs_hEntity ptA, Slvs_hEntity ptB)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -304,10 +308,10 @@ static Slvs_Entity Slvs_MakeLineSegment(Slvs_hEntity h, Slvs_hGroup group,
r.point[1] = ptB; r.point[1] = ptB;
return r; return r;
} }
static Slvs_Entity Slvs_MakeCubic(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakeCubic(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hEntity wrkpl, Slvs_hEntity wrkpl,
Slvs_hEntity pt0, Slvs_hEntity pt1, Slvs_hEntity pt0, Slvs_hEntity pt1,
Slvs_hEntity pt2, Slvs_hEntity pt3) Slvs_hEntity pt2, Slvs_hEntity pt3)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -321,11 +325,11 @@ static Slvs_Entity Slvs_MakeCubic(Slvs_hEntity h, Slvs_hGroup group,
r.point[3] = pt3; r.point[3] = pt3;
return r; return r;
} }
static Slvs_Entity Slvs_MakeArcOfCircle(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakeArcOfCircle(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hEntity wrkpl, Slvs_hEntity wrkpl,
Slvs_hEntity normal, Slvs_hEntity normal,
Slvs_hEntity center, Slvs_hEntity center,
Slvs_hEntity start, Slvs_hEntity end) Slvs_hEntity start, Slvs_hEntity end)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -339,10 +343,10 @@ static Slvs_Entity Slvs_MakeArcOfCircle(Slvs_hEntity h, Slvs_hGroup group,
r.point[2] = end; r.point[2] = end;
return r; return r;
} }
static Slvs_Entity Slvs_MakeCircle(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakeCircle(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hEntity wrkpl, Slvs_hEntity wrkpl,
Slvs_hEntity center, Slvs_hEntity center,
Slvs_hEntity normal, Slvs_hEntity radius) Slvs_hEntity normal, Slvs_hEntity radius)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -355,8 +359,8 @@ static Slvs_Entity Slvs_MakeCircle(Slvs_hEntity h, Slvs_hGroup group,
r.distance = radius; r.distance = radius;
return r; return r;
} }
static Slvs_Entity Slvs_MakeWorkplane(Slvs_hEntity h, Slvs_hGroup group, static inline Slvs_Entity Slvs_MakeWorkplane(Slvs_hEntity h, Slvs_hGroup group,
Slvs_hEntity origin, Slvs_hEntity normal) Slvs_hEntity origin, Slvs_hEntity normal)
{ {
Slvs_Entity r; Slvs_Entity r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));
@ -369,15 +373,15 @@ static Slvs_Entity Slvs_MakeWorkplane(Slvs_hEntity h, Slvs_hGroup group,
return r; return r;
} }
static Slvs_Constraint Slvs_MakeConstraint(Slvs_hConstraint h, static inline Slvs_Constraint Slvs_MakeConstraint(Slvs_hConstraint h,
Slvs_hGroup group, Slvs_hGroup group,
int type, int type,
Slvs_hEntity wrkpl, Slvs_hEntity wrkpl,
double valA, double valA,
Slvs_hEntity ptA, Slvs_hEntity ptA,
Slvs_hEntity ptB, Slvs_hEntity ptB,
Slvs_hEntity entityA, Slvs_hEntity entityA,
Slvs_hEntity entityB) Slvs_hEntity entityB)
{ {
Slvs_Constraint r; Slvs_Constraint r;
memset(&r, 0, sizeof(r)); memset(&r, 0, sizeof(r));

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!

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

65
res/cocoa/MainMenu.xib Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="12F45" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
</dependencies>
<objects>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-4" userLabel="Application Delegate" customClass="ApplicationDelegate"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="SolveSpace" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="SolveSpace" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About SolveSpace" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW">
<connections>
<action selector="preferences:" target="-4" id="xyv-2f-7kO"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
<menuItem title="Services" id="NMo-om-nkz">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide SolveSpace" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="-1" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit SolveSpace" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="-3" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</objects>
</document>

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="12F45" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
<capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSViewController">
<connections>
<outlet property="button" destination="nNy-fR-AhK" id="w3z-a4-Khs"/>
<outlet property="view" destination="c22-O7-iKe" id="w2z-a4-Khs"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="294" height="51"/>
<subviews>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nNy-fR-AhK">
<rect key="frame" x="105" y="12" width="34" height="26"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="f8z-Qp-Igm">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="VgN-HZ-Q4a"/>
</popUpButtonCell>
<connections>
<binding destination="-2" name="selectedIndex" keyPath="index" id="AXx-uh-tee"/>
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="z9Z-cA-QIW">
<rect key="frame" x="17" y="17" width="73" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="File Format:" id="2vD-ht-BhF">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="nNy-fR-AhK" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" constant="15" id="B3P-9V-lvu"/>
<constraint firstItem="nNy-fR-AhK" firstAttribute="leading" secondItem="z9Z-cA-QIW" secondAttribute="trailing" constant="20" id="Uex-s1-7UF"/>
<constraint firstAttribute="bottom" secondItem="nNy-fR-AhK" secondAttribute="bottom" constant="15" id="pPM-eQ-gOD"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="nNy-fR-AhK" secondAttribute="trailing" constant="20" id="rPT-bl-Md7"/>
<constraint firstItem="z9Z-cA-QIW" firstAttribute="baseline" secondItem="nNy-fR-AhK" secondAttribute="baseline" constant="1" id="spD-eU-Frq"/>
<constraint firstItem="nNy-fR-AhK" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="centerX" constant="-40" id="whX-1w-qMB"/>
</constraints>
</customView>
<userDefaultsController representsSharedInstance="YES" id="ybp-e7-hms"/>
</objects>
</document>

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

BIN
res/fonts/unicode.lff.gz Normal file

Binary file not shown.

BIN
res/fonts/unifont.hex.gz Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

View File

@ -0,0 +1,27 @@
/* XPM */
static char *solvespace_16x16[] = {
/* columns rows colors chars-per-pixel */
"16 16 5 1 ",
" c black",
". c #1ED500",
"X c #DE00D6",
"o c #CBCBCB",
"O c None",
/* pixels */
"OOO OOOOOOOOOOOO",
"OOO OOOOOOOOOOOO",
"OOO OOOOOOOOOOOO",
"OOO OOOOOXOOOOOO",
"OOO OOOOOXoOOOOO",
"OOO OOOOOXoOOOOO",
"OOO OOOOOXoOOOOO",
"OOO OOOOOXoOOOOO",
"OOO OOOOOXoOOOOO",
"OOO OOXXXXXXXOOO",
"OOO OOOoooooooOO",
"OO...OOOOOOOOOOO",
" ... ",
"OO...OOOOOOOOOOO",
"OOO OOOOOOOOOOOO",
"OOO OOOOOOOOOOOO"
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

View File

@ -0,0 +1,35 @@
/* XPM */
static char *solvespace_24x24[] = {
/* columns rows colors chars-per-pixel */
"24 24 5 1 ",
" c black",
". c #1ED500",
"X c #DE00D6",
"o c #CBCBCB",
"O c None",
/* pixels */
"OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOO OOOOOOOOOOOOOOOO",
"OOOOOOO OOOOOOOOOOOOOOOO",
"OOOOOOO OOOOOOOOOOOOOOOO",
"OOOOOOO OOOOOXOOOOOOOOOO",
"OOOOOOO OOOOOXoOOOOOOOOO",
"OOOOOOO OOOOOXoOOOOOOOOO",
"OOOOOOO OOOOOXoOOOOOOOOO",
"OOOOOOO OOOOOXoOOOOOOOOO",
"OOOOOOO OOOOOXoOOOOOOOOO",
"OOOOOOO OOXXXXXXXOOOOOOO",
"OOOOOOO OOOoooooooOOOOOO",
"OOOOOO...OOOOOOOOOOOOOOO",
"OOOO ... OOOO",
"OOOOOO...OOOOOOOOOOOOOOO",
"OOOOOOO OOOOOOOOOOOOOOOO",
"OOOOOOO OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOO"
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

View File

@ -0,0 +1,43 @@
/* XPM */
static char *solvespace_32x32[] = {
/* columns rows colors chars-per-pixel */
"32 32 5 1 ",
" c black",
". c #1ED500",
"X c #DE00D6",
"o c #CBCBCB",
"O c None",
/* pixels */
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOXXoOOOOOOOOOOOO",
"OOOOOO OOOOXXXXXXXXXXXXOOOOOOOO",
"OOOOOO OOOOXXXXXXXXXXXXOOOOOOOO",
"OOOOOO OOOOOooooooooooooOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOO......OOOOOOOOOOOOOOOOOOOOOO",
"OOOO......OOOOOOOOOOOOOOOOOOOOOO",
" ...... ",
" ...... ",
"OOOO......OOOOOOOOOOOOOOOOOOOOOO",
"OOOO......OOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOO OOOOOOOOOOOOOOOOOOOOOOOO"
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

View File

@ -0,0 +1,59 @@
/* XPM */
static char *solvespace_48x48[] = {
/* columns rows colors chars-per-pixel */
"48 48 5 1 ",
" c black",
". c #1ED500",
"X c #DE00D6",
"o c #CBCBCB",
"O c None",
/* pixels */
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOXXoOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOXXXXXXXXXXXXOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOXXXXXXXXXXXXOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOooooooooooooOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOO......OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOO......OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOO ...... OOOOOOOO",
"OOOOOOOO ...... OOOOOOOO",
"OOOOOOOOOOOO......OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOO......OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
};

View File

@ -0,0 +1,9 @@
[Desktop Entry]
Version=1.0
Name=SolveSpace
Comment=A parametric 2d/3d CAD
Exec=${CMAKE_INSTALL_FULL_BINDIR}/solvespace
Icon=solvespace
Type=Application
Categories=Graphics
Keywords=parametric;cad;2d;3d;

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

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