Commit Graph

1080 Commits

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