Commit Graph

996 Commits (37de36425770880032bd281efe069a1c0b8daea9)

Author SHA1 Message Date
phkahler 440ea554c9 Add menu checkbox Dim Solid for Sketch Groups.
Makes shadowing the solid optional for sketch in 2d/3d groups. Handy for making dimensioned drawings by putting dims in their own group. #834
2020-12-29 14:08:45 -05:00
ruevs 14e837a45f Clean up paste transformed and constrain operations a bit. 2020-12-22 20:40:50 +02:00
Koen Schmeets 96958f4663
Fix paste transformed not correcting tangent arcs when mirrored (#833) 2020-12-22 14:09:31 +01:00
Koen Schmeets 679e2b9202 Fix an off-by-one error that missed the last point when generating screen bounding boxes 2020-12-21 23:00:51 +02:00
Koen Schmeets 0e5a246a70 Fix normal selection with marquee 2020-12-21 23:00:51 +02:00
Koen Schmeets f343bbc4f4 Fix marquee selection when the view is rotated away from the working plane 2020-12-21 23:00:51 +02:00
Koen Schmeets 4275fb1202 Fix snap to grid not working in some situations 2020-12-20 13:34:28 -05:00
Koen Schmeets 2939abf5f8 Improve zooming with trackpad and scrollwheel
On macOS actual scroll delta is used for the zoom amount.
On Windows WHEEL_DELTA is used to allow smooth scrolling if supported.
Shift+Scroll is added for 10x finer zooming.
2020-12-11 07:26:02 -05:00
phkahler 640a1b913a Use good default filenames on Linux/GTK 2020-12-10 05:15:18 -05:00
наб e59186a413 Suggest sensible defaults in file dialogs
Went through first the diff of the referenced commit,
then all instances of "Create(Open|Save)FileDialog";
added SuggestFilename() calls where a default exists

This has been previously removed in
6b5db58971
Closes #538
2020-12-09 20:42:13 -05:00
наб a8b8a347c1 Make Path::SetExtension("") not include a dot 2020-12-09 20:42:13 -05:00
Koen Schmeets f5086b62cc Analyze | Stop Tracing (Ctrl+Shift+S) saves CSV only if a point is being traced
This avoids confusion with "Ctrl+Shift+S" being used as "Save As..." shortcut
on some platforms.
2020-12-09 18:57:31 +02:00
Koen Schmeets b316a8863b Use EXACT for checking theta 2020-11-30 08:50:06 -05:00
Koen Schmeets 6b91ab5778 Better rotating 2020-11-30 08:50:06 -05:00
Koen Schmeets aa78043fa2 Swap vertical and horizontal constraints when rotating 90/270 degrees 2020-11-30 08:50:06 -05:00
ruevs 9390ab02d5 Set the default font for text objects correctly.
The default font is BitstreamVeraSans-Roman-builtin.ttf since 94b26ddfac,
but on Win32 it needs to be `res://fonts/...` URI to work.

Fixes: https://github.com/solvespace/solvespace/issues/821
2020-11-27 18:24:49 +02:00
ruevs a2b5d0d45c Win32: Remove sscheck on IsWindowVisible and ShowWindow
The return value of these functions is not an error code and according to
the Win32 API documentation they can not affect `GetLastError`.

Calling sscheck on them normally does not fail since it does
SetLastError(0) before running the checked expression and only then
GetLastError(). However in issue 817 a user discovered that when running
"DisplayFusion" software GetLastError does return an error and SolveSpace
closes.

So while not a strict bug-fix this is a "correctness improvement" for
SolveSpace and works around a possible bug in DisplayFusion.

Similarly the return value of Reg*** functions is now compared to
ERROR_SUCCESS which is zero. Before the sschecks were strictly wrong but
did not cause problems for the same reason as above.
2020-11-25 16:43:39 -05:00
phkahler 22dea59077 "Edit newly added dimensions" is now turned on by default. issue826 2020-11-25 11:55:08 +02:00
ruevs 5d173694e7 Win32: Remove sscheck on SetScrollInfo - it returns the scrollbar position
...which can be zero.

Fixes: https://github.com/solvespace/solvespace/issues/817
2020-11-24 18:18:48 -05:00
ruevs bb5994ed70 UI: Display "err" in the property browser only if "check sketch for closed contour"
... is enabled.
"err" was first introduced in c2c26e95ad to indicate sketches that may cause
problems in the subsequent 3D groups. But is makes sense not to display the
error if the "check sketch for closed contour" option is turned off. The user
obviously does not want to be warned.

Based on a suggestion in https://github.com/solvespace/solvespace/issues/819
2020-11-24 18:18:11 -05:00
Koen Schmeets f2850246fa Move z-index of construction segments behind normal segments 2020-11-23 18:32:59 -05:00
phkahler 08f37deadd Make better choices of SI units by considering order. 2020-11-22 18:33:36 -05:00
ruevs 5137da295a Win32: Mouse wheel zooming always remains properly centered
On scroll wheel events convert the mouse coordinates from screen to client
area so that scroll wheel zooming remains centered irrespective of the
window position.

Fixes https://github.com/solvespace/solvespace/issues/806
2020-11-22 18:32:14 -05:00
ruevs bdd2be6041 Translations: Add solvespace.cpp to the translations...
...since it currently contains many relevant strings.
2020-11-22 17:34:14 -05:00
ruevs 942bf3f354 Remove Q3DO export.
It was added in 3a3a2755b as a potential way to export colorful meshes
to Horizon EDA but ended up being supported only by SolveSpace. Since no
software can consume the exported q3do files the feature is superfluous.

See https://github.com/solvespace/solvespace/issues/795 for details.
2020-11-21 13:02:39 -05:00
ruevs bcb8cd2c03 Fix unsequenced modification and access warnings.
Found by clang 11. They are a potential problem.

[ 21%] Building CXX object src/CMakeFiles/solvespace-core.dir/exportstep.cpp.obj
.\src\exportstep.cpp:293:61: warning: unsequenced modification and access to 'id'      [-Wunsequenced]
        fprintf(f, "#%d=FILL_AREA_STYLE_COLOUR('',#%d);\n", ++id, id - 1);
                                                            ^     ~~
.\src\exportstep.cpp:294:56: warning: unsequenced modification and access to 'id'      [-Wunsequenced]
        fprintf(f, "#%d=FILL_AREA_STYLE('',(#%d));\n", ++id, id - 1);
                                                       ^     ~~
.\src\exportstep.cpp:295:59: warning: unsequenced modification and access to 'id'      [-Wunsequenced]
        fprintf(f, "#%d=SURFACE_STYLE_FILL_AREA(#%d);\n", ++id, id - 1);
                                                          ^     ~~
.\src\exportstep.cpp:297:98: warning: unsequenced modification and access to 'id'      [-Wunsequenced]
        fprintf(f, "#%d=SURFACE_STYLE_RENDERING_WITH_PROPERTIES(.NORMAL_SHADING.,#%d,(#%d));\n", ++id, id - 5, id - 1);
                                                                                                 ^     ~~
.\src\exportstep.cpp:298:64: warning: unsequenced modification and access to 'id'      [-Wunsequenced]
        fprintf(f, "#%d=SURFACE_SIDE_STYLE('',(#%d, #%d));\n", ++id, id - 3, id - 1);
                                                               ^     ~~
.\src\exportstep.cpp:300:62: warning: unsequenced modification and access to 'id'      [-Wunsequenced]
        fprintf(f, "#%d=SURFACE_STYLE_USAGE(.BOTH.,#%d);\n", ++id, id - 1);
                                                             ^     ~~
.\src\exportstep.cpp:301:67: warning: unsequenced modification and access to 'id'      [-Wunsequenced]
        fprintf(f, "#%d=PRESENTATION_STYLE_ASSIGNMENT((#%d));\n", ++id, id - 1);
                                                                  ^     ~~
.\src\exportstep.cpp:302:56: warning: unsequenced modification and access to 'id'      [-Wunsequenced]
        fprintf(f, "#%d=STYLED_ITEM('',(#%d),#%d);\n", ++id, id - 1, advFaceId);
                                                       ^     ~~
8 warnings generated.
2020-11-18 17:07:56 +02:00
phkahler 142252ddf8 Add z distance checking to entity picking. Fixes issue 521 2020-11-17 18:58:18 -05:00
phkahler 5945d556a6 Add end marker to text window and increase max rows. 2020-11-07 21:57:15 +01:00
phkahler 6ff8db93e8 Use zOrder for selections within the same group 2020-10-31 11:58:14 -04:00
phkahler 8a3e5b4d56 Don't do numeric surface intersections if an exact curve has been copied. We don't want 2 overlapping but different sets of PWLs. 2020-10-29 14:02:57 -04:00
phkahler eadeac44f0 use VERY_NEGATIVE and VERY_POSITIVE instead of numeric values which is some cases were 1e-10 instead of -1e10 2020-10-28 13:37:54 -04:00
phkahler 6c4b075eef Increase MAX_UNDO to 100 2020-10-28 13:37:54 -04:00
ruevs 7e99ba0096 UI: Fix the Property Browser window scrollbar
- Scrolling with the scrollbar now works properly.

- Do not scroll with the mouse wheel while an edit field is active in
  the property browser.

Fixes: https://github.com/solvespace/solvespace/issues/782
2020-10-28 13:37:30 -04:00
Koen Schmeets 73bbbdef83 Travis: include libomp in macOS .app 2020-10-26 02:26:54 +01:00
ruevs 88b26aabdb Update the year in the About dialog 2020-10-25 19:16:34 -04:00
ruevs 7292c32e6f Performance: inline the Bernstein functions
This is another small profiling driven optimization.
Moving the initialization of `const double *c` as part of the definition
also helps with the generated assembler.
2020-10-25 19:16:22 -04:00
Maximilian Federle 24720a0024 Revert "CMake: use sanitizer flags for internal targets only"
This reverts commit 68b1abf77f.

The warnings are valuable and shouldn't be cast aside.
As of 8f509f1, we special case macOS and don't set -fno-sanitize-recover
to allow CI to succeed.
In the future, this could be made stricter again by only suppressing
known bugs, which ideally should also be fixed or reported upstream.
2020-10-24 17:10:47 +02:00
ruevs 7035071526 Performance optimization of the Vector class
Profiling with MSVC 2019 showed that many of the Vector methods are on
a critical path (not surprising). They are changed to be inline and
unnecessary temporaries are removed.

On the example below generate times decreased from 102s. to 64s.
At the same time the executable size shrank from 5569536	to 5150208 bytes
in release mode (with global optimizations).

This should not stop us from working on optimizing inner loops e.g. https://github.com/solvespace/solvespace/issues/759 .

[Test model](https://github.com/solvespace/solvespace/files/5414683/PrismConeNURBSNormalsTangents300.zip)
2020-10-23 20:08:43 -04:00
Maximilian Federle 68b1abf77f CMake: use sanitizer flags for internal targets only
Previously sanitizer flags were set unconditionally for
all code, including that of external libraries.
Set them only for targets in src/, tests/ and exposed/.

Unfortunately, the linker equivalent to add_compile_options,
add_link_options, is only available for CMake version >= 3.13.
So add the sanitizer flags manually to each target's linker options.
2020-10-23 19:39:36 +02:00
phkahler c674bc8fb9 Add OpenMP parallel for to SShell::CopyCurvesSplitAgainst 2020-10-23 12:53:54 -04:00
phkahler 0f1ece2b8e Resovle a huge performance regression introduced by commit ab10e38 while still fixing the NURBS issues resolved by that commit with only modest speed penalty. The performance is significantly improved by using bounding box tests on curves prior to doing complex intersection testing. 2020-10-23 12:52:27 -04:00
ruevs 0761339ec9 STEP Export: include colors and alpha
Make the color export work in KiCAD and Horison EDA which do not support
transparency.

Fixes: https://github.com/solvespace/solvespace/issues/452
https://github.com/solvespace/solvespace/pull/763
2020-10-22 09:59:35 +03:00
ruevs 32e695bfee STEP Export: include colors and alpha
The implementation may be sub-optimal, since the colour and alpha is
defined for each NURBS surface instead of on group level, but the STEP
export currently does not represent group structure at all and I am not
familiar with the format in order to change this.

Fixes: https://github.com/solvespace/solvespace/issues/452
2020-10-21 17:19:12 -04:00
phkahler ab10e38d44 Add vertexes to curve intersection list in addition to surface intersections.
Sometimes a vertex can be used to split a curve where surface intersections can't. Those unsplit curves can cause boolean failures.
2020-10-20 12:37:18 -04:00
Koen Schmeets 3af8127e8f macOS: add NSOpenGLPFADoubleBuffer to NSOpenGLPixelFormatAttribute 2020-10-20 10:59:58 -04:00
Koen Schmeets 8e7416f3fd
Travis: Build improvements and fixes (#751)
- Add OpenMP to macOS build
- Use as many cores as possible in CI
- Update travis osx image to xcode12.2
- Ignore .vscode folder
- In `.travis/sign-macos.sh`, only create keychain when `CI` variable is present
- Only run macOS deploy stage when a tag is pushed
2020-10-20 09:39:26 +02:00
phkahler b28499ea48 initial support (disabled) for keepout regions in IDF files. 2020-10-19 18:26:45 -04:00
phkahler b12bcc5889 Fix some IDF file curves. 2020-10-19 18:26:45 -04:00
Koen Schmeets 0548702043 macOS CI fixes 2020-10-19 09:36:52 -04:00
phkahler 408128a138 Avoid zero tangnet vectors on degenerate NURBS edges. Fixes #652 2020-10-18 14:54:00 -04:00
ruevs 6558cb9ebe Fix crash in solvespace-cli
`window` is a `nullptr` with guinone.cpp - avoid dereferencing it.

Fixes: https://github.com/solvespace/solvespace/issues/567
2020-10-16 17:44:58 -04:00
ruevs 3ea8ebfaf5 Win32: Fix "File|Open...", "Save" and "Save As" when a command line argument is used.
`GetSaveFileNameA` `OPENFILENAMEA` does not like UNC ( "\\\\?\\C:\\..." ) file prefixes in `lpstrFile`.
Work around it by not `Expand`-ing parameters passed on the command line too early.

The only user visible change is that "File|Open Recent" will show items as they
were passed instead of expanded to full path for example:
"..\..\NURBSTests\Intersection2.slvs"

Fixes: https://github.com/solvespace/solvespace/issues/622
2020-10-16 17:44:27 -04:00
phkahler d72eba8039 Create intersection curves from existing ones.
When a plane coinsides with a seam we need to copy that trim curve. The existing curve belongs to the original shell surfaces and an intersection is otherwise not found. Fixes #540.
2020-10-10 02:02:34 -04:00
julien581 c514ddad54 Fix for https://github.com/solvespace/solvespace/issues/248 2020-10-03 15:27:14 -04:00
phkahler c021df33c0 Fix issue 684 as whitequark suggested via WM_KEYDOWN->WMCHAR change. 2020-10-01 13:55:40 -04:00
Johannes Rehnman 3ce8c29982 Allow DXF import of 3D arcs and circles
Extrusion direction (normal) of arcs and circles were not taken into
account when importing.

- Add method for calculating a quaternion from extrusion direction
  according to DXF arbitrary axis algorithm
- Add required workplanes for arcs not on XY origin plane
- Adjust addDimRadial and addDimDiametric to include normal when
  creating associated circle request
2020-10-01 12:59:43 -04:00
phkahler 8cf9d68ecf IDF file Linking.
Can read PCB outlines and cutouts, as well as Pin and Mounting holes. A simple PPCB model sans components is added to the assembly.
2020-09-30 14:20:35 -04:00
phkahler 0a061b6f9e NFC: Performance. For step-and-repeat groups, create the copies first (in parallel) and then combine them using unions of equal size shells to reduce the total time spent on booleans. 2020-09-22 16:30:03 -04:00
phkahler d49c8a1aef add debug message showing the name of a group whose linked file can't be found. 2020-09-22 15:28:17 -04:00
phkahler 39f419e28c Flip sign of exportCanvas dx and dy. Fixes issue #523 2020-09-20 19:54:26 -04:00
phkahler 704bb4a3be Fix view centering and directions or cli thumbnail function. 2020-09-19 15:03:01 -04:00
Christoph Dittmann 34328c9756 solvespace-cli: Fix --view
This fixes issues #499. The --view option changes projUp and
projRight. For --view to affect the camera, the camera needs to be
initialized using these values.
2020-09-18 21:15:53 -04:00
phkahler 6e515b6735 Fix 699: Allow dragging linked objects in an assembly. 2020-09-17 17:55:04 -04:00
phkahler 094eff755b Fix 197 Update the state of checkboxes in menus after failed workplace activation. 2020-09-17 11:34:22 -04:00
phkahler 668fe6f493 Make the redundant constraint timeout a configuration value and add the config UI elements to edit that value. 2020-09-16 16:39:43 -04:00
phkahler 615708440f Fix #131. Prevent UI freeze by having a timeout when finding which constraints can be removed to fix jacobian. 2020-09-16 16:39:43 -04:00
phkahler e74185b639 Fix #696. Account for multiple coincident edges when looking for naked edges. 2020-09-14 12:07:17 -04:00
phkahler d8f5a8da32 Fix issue #296.
We need to recognize two consecutive bridges as a non-ear.
2020-09-08 18:54:02 -04:00
phkahler 705249627a Fix #693 issues.
This set of changes covers all triangulation errors in issue 693. A point coincident with a triangle vertex is OK and needed for bridges, but sometimes the middle point has edges cutting through the triangle that make it a non-ear. We fix that and a couple of off-by-one error (that fixes one of the test cases).
2020-09-08 18:54:02 -04:00
phkahler 0413c1b926 NFC:Triangulation - don't add zero-length bridges to avoid list. 2020-09-08 18:54:02 -04:00
phkahler b208cd8cae NFC, Performance: Use OpenMP for boolean function MakeItersectionCurvesAgainst.
This is the last long-running single-threaded part of the boolean code. On one test model this took Regenerate form 27 seconds down to 18s. The critical sections needed a name (into) because that object must not be modified while in use in different places.
2020-09-06 12:43:24 -04:00
nabijaczleweli 360b347ad7 Export backgrounds in vector files
VectorFileWriter::Background() is an empty impl, except that it writes
  * a rectangle the size of the output for EPS and PDF, and
  * a <style> element setting background-color for SVG

Ref: #525
2020-09-05 20:58:07 -04:00
nabijaczleweli 028b613f10 Add ExportBackgroundColor config to GUI and CLI 2020-09-05 20:58:07 -04:00
phkahler d3da2c8b22 Performance: Don't call std::inplace_merge for IdList::AddAndAssignID() via Add() because it is redundant. 2020-08-29 15:34:48 -04:00
phkahler 6894b0c9c3 NFC: remove a critical section, runs faster. 2020-08-19 17:55:42 -04:00
phkahler d974615d0e NFC replace 2 nested loops with 1 loop and a lookup for speed improvement. 2020-08-19 17:55:42 -04:00
phkahler bc4924ae47 Don't duplicate points when connecting contours with zero length bridge. Fixes #303 2020-08-14 16:39:09 -04:00
phkahler 04b332dfd0 Ratpoly - Less noise in terminal. Comment out expected dbg print and try harder to converge. 2020-08-13 16:56:18 -04:00
Paul 4cceaa5310 NURBS boolean improvement.
The 3-plane intersection code fails to converge when a curve joins two tangent NURBS patches. This adds a new function for intersecting exact curves with a surface to avoid those failures. Fixes simplified test model for issue #315.
2020-08-13 16:56:18 -04:00
phkahler f9529916c4 Fix issue161 and 174. Use the same logic for selction and dragging, but ignore entites that are inherently undraggable.
This allows the selection to reach through entities to their corresponding ones on the underlying sketch which can be dragged if they are not fully constrained. This is decided in a new function Entity::CanBeDragged().
2020-08-09 19:55:33 -04:00
phkahler 575ddb5aaa Add a pass in triangulation to create convex triangle fans. These triangles will have smaller bounding boxes and look better. 2020-08-07 15:47:01 -04:00
phkahler b3eb589240 Fix issue659 - Problems constraining to ends of Helix.
Create a new copy type for faces that includes the translation aspect of helical extrusions. Also swap the end remappings when the shell is inside out - this was also affecting some Revolve extrusions.
2020-08-07 15:16:47 -04:00
whitequark a2962207dd Improve text screen for a selected entity.
* Add a link to its request, unless it's the first entity in that
    request (which would just select the same entity again).
  * Add a link to its group.
  * Add a link to its workplane.
  * Add a link to its style; and hide the style row for entities that
    aren't stylable.
  * Show constraints and measurements (reference constraints) in
    separate lists.
  * For curve entities, show constraints that apply to the points
    related to the curve, not just to the curve itself.
2020-08-07 18:06:42 +00:00
whitequark afa9e2890e Improve text screen for a selected constraint.
* Show the type of a constraint.
  * Show the workplane a constraint is in, for constraints which can
    be both projected to workplane or be free in 3d space.
  * Clearly distinguish reference from non-reference constraints.
  * Add a checkbox for toggling the reference option.
  * When showing requests a constraint applies to, highlight on hover
    the specific entity being constrained, not just the first one.
2020-08-07 18:06:42 +00:00
phkahler fef6a39a17 Don't init srand(0) because rand isn't used any more. 2020-08-03 15:41:47 -04:00
phkahler 3c2f82b7f1 Remove the Random() function and use a fixed table of arbitrary vectors in raycast.cpp
This also fixes issue #666.
2020-08-03 10:30:54 -04:00
phkahler fd2dfe87f6 Fix #656 by making SSurface::SplitInHalf thread safe.
SSurface::SplitInHalf was modifying the surface and then restoring it at the end. Make temporary copy instead.
2020-08-01 11:52:20 -04:00
whitequark d8b76ef7f1 Drop backtrace generation.
This has been completely broken since 2018 (commit a93283df), and no
one noticed, so it probably wasn't useful. Instead of fixing it, just
drop the feature and a bunch of odd nonportable code.
2020-07-28 14:56:55 +00:00
whitequark bbf402bfe3 Fix "Sketch → In Workplane" not updating the UI immediately. 2020-07-28 14:10:19 +00:00
whitequark 56e2592e2a Make "Toggle Reference" remember undo state.
Turning a reference dimension into a constraint one can make
the sketch unsolvable, which suggests Edit → Undo, which would undo
either too much or nothing at all.
2020-07-28 13:12:14 +00:00
phkahler e0fa99bad4 remove another redundant pass checking earness 2020-07-22 10:27:01 -04:00
phkahler 2640034124 NFC: Remove a redundant pass over all verticies in ear triangulation. 2020-07-22 10:27:01 -04:00
whitequark b0fc1912ea Create mimalloc heaps only when necessary.
The mimalloc temporary heap is a thread-local object that uses RAII
to manage heap lifetimes even in threads that are created implicitly,
e.g. by OpenMP. However, not all threads are necessarily created by
the application; graphics drivers may create their own threads, and
this can lead to deadlocks when combined with library unloading.

Fixes #657.
2020-07-22 11:05:01 +00:00
phkahler 188b2e26ce Implement #524 Allow flat colors. Adds an edit control for Ambient lighting. 2020-07-18 02:15:41 +00:00
phkahler c75b2e473e Fix #647 Helix mesh defects.
Use the grid spacing algorithm for helical curve PWL creation.
This makes the grid and trim curves have similar spacing.
2020-07-12 19:09:26 -04:00
наб c4ca4be91e Replace {Alloc,FreeAll}Temporary() with mimalloc
The heaps are wrapped in a RAIIish thread_local handler,
since being affined affined to a single thread for allocations is
required by the API

Ref: #642
2020-07-12 02:37:07 +00:00
наб cbac182edf Add and build mimalloc at 07c6e60a5a3bd7de09e4a170cd97bafba59cfafd 2020-07-12 02:37:07 +00:00
phkahler 9802b5d1ee Better helical triangulation - issue 489.
Resolve issue #489 helix has stairsteps.
Force helix axis line to 8 segments.
Grid triangulation to use a minimum of 4 segments for degree>1.
Adds twist dependence for grid triangulation with degree=1.
Added a max_dt parameter for PWL creation and use that for helical edges.
2020-07-11 14:29:18 -04:00
whitequark 211ae8c446 Show area of closed contour with SI units.
Similar to the way that Analyze → Measure Area... works.

Fixes #639.
2020-06-23 02:39:57 +00:00
whitequark 35c6af4929 Show center of mass using the same format as for constraints. 2020-06-23 01:16:58 +00:00