Commit Graph

1278 Commits (4d1e1341d926ac356b295d5cc3d61c7a6cd7d07d)

Author SHA1 Message Date
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