Commit Graph

890 Commits (7265121b24c2d9db79a13c42be34903c2a7d78e2)

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