Commit Graph

512 Commits (55ae10b5b84ce51042ac9957cfbf01e70d48c952)

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

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

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

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

The functionality of Expr is retained as-is, although SjLj error
handling is a maintenance nightmare. However, the entire parser
probably should be eventually replaced, so for now it is not
a great concern.
2016-08-01 00:48:37 +00:00
whitequark 65e2cccde0 Add a Cairo rendering backend.
This backend will be used for reproducible offscreen rendering
in integration tests.
2016-08-01 00:48:37 +00:00
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 14cf0e09df Win32: emit dbp() output to stderr as well in Debug builds. 2016-08-01 00:48:37 +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 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
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 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 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 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 85cd44df3c Show "Paste" context menu item even when only constraints are copied. 2016-06-20 13:47:14 +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 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 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
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
EvilSpirit def73ec118 Refactor Point2d::DistanceToLine. 2016-05-20 15:02:38 +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 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 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 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 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
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 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
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 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 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
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 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