Commit Graph

83 Commits (7f86a784724298b87e169d1f0fe431119a427115)

Author SHA1 Message Date
tomsci e1b0784b31
mac: Support for pan, zoom and rotate trackpad gestures (#1093)
* mac: Support for pan, zoom and rotate trackpad gestures

Currently SolveSpace is nearly unusable on a mac if you only have a
buttonless trackpad and not a mouse, because there's no way to pan
(ie right-click-drag) or rotate (ie middle-click-drag). You can zoom,
but only by using two-finger-drag up and down, which ends up getting
interpreted as a scrollwheel event.

This change makes the app behave much more like any other mac app, by
adding 2-finger-drag pan gesture support and pinch-gesture zooming, and
3D rotate using shift-2-finger-drag.

I've also added support for the rotate two-finger trackpad gesture,
which rotates directly around the screen Z axis (rather than in all 3
dimensions) which is actually something I've found myself wanting to do
with the mouse but afaik there's no equivalent way of achieving that.

While I was there, I fixed a bugette in convertMouseEvent which was
incorrectly translating the NSEvent coordinates, and then fixing up the
fact that the sign of the y-coordinate was wrong as a result. Using the
convertPoint API correctly means that fixup is not required because
convertPoint handles it for you.

* Don't do trackpad gestures on anything except the toplevel window

* mac: Fix non-functional scrollbar on text window

Which has not worked quite right since the last major refactor.

* Don't pass right-button drags to the toolbar

This improves the behaviour of trackpad pan/rotate on mac which uses
simulated right-button events.

* Don't pass cmd/ctrl modifier through on trackpad pan/rotate MouseEvents
2021-08-27 01:58:33 +02:00
Tom Sutcliffe 2fb6119de8 Add option for displaying dimensions in feet and inches 2021-08-15 18:18:41 -04:00
Eric Chan 37de364257 Addition of ArcLength Ratio and ArcLength Difference constraints to Constraints list 2021-06-28 11:31:53 -04:00
Přemysl Eric Janouch 9dd67c7ba0 Use Range-based for Loops Instead of NextAfter for all IdList Objects
Based on commit '3b395bb5a7' by pjanx

Resolves a performance regression of iteration being O(n * log n)
rather than O(n).
2021-05-12 19:50:23 -04:00
robnee e15ccdd477 Update property browser display live when dragging
Keep items in selected state while dragging so that property browser
will track them until the left mouse button is released.  Also, trigger
a property browser update on mouse move while dragging to make the
display "live"
2021-05-02 19:51:00 -04:00
robnee cc52eb237d Allow right click to end sketching of all entities 2021-04-03 12:53:04 -04:00
robnee 3309181773 fix problems with ctrl/shift key drag modifiers
When dragging points we must always update position and mark them dirty
through all code paths.
Ensure the ctrl and shift modifier rotation quarternion is always set to
something reasonable.
separate extraLine tracking code from drag tracking code
2021-03-01 21:09:36 -05:00
robnee 745a12c3c4 permit construction geometry toggle while drawing 2021-02-23 10:13:29 -05:00
robnee 11a8a0abd5 do not Invalidate() when dragging new points to prevent refresh bugs on Windows 2021-01-30 21:36:54 -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
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
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
Tim 647171017a
Fix more segfaults in mouse.cpp lambdas (#574)
This changes all the lambdas to have explicit captures, since the use of
implicit captures has led to some memory errors, especially segfaults in
the right-click menu.

I'm not 100% sure that the code is correct anyway - it really needs auditing
to ensure all referenced values are still valid when the menu item is clicked
(e.g. can you change stuff with keyboard shortcuts while the context menu is
visible?), but it should at least be *more* correct!
2020-03-29 01:46:34 +00:00
Tim 485fd012b4
Fix segfault in Remove Spline Point context menu
This was incorrectly capturing `r` by reference and using it after it left
its scope. Changed to  capture by value, and also explicitly capture `this`
in case we were accidentally capturing any other scope variables by reference.

Fixes #571
2020-03-28 15:28:12 +00:00
Koen Schmeets dcdfdec564 Add an option to edit dimension immediately after adding. 2019-11-26 22:34:53 +00:00
Ryan Pavlik 5ada4dbd9c Add and use IdList::IsEmpty. NFC.
Removes consuming code from the implementation details, easing swap of
the underlying container, etc.
2019-08-20 15:57:11 +00:00
Ryan Pavlik 5efb09e6d4 Use the new equality/inequality operators of handles to reduce references to .v. NFC. 2019-07-10 15:40:21 +00:00
whitequark 6352405206 Deselect entities with Ctrl-LMB.
In other words, Ctrl inverts the normal action of LMB. It is already
possible to deselect entities through the context menu, but that
can be very awkward on laptop touchpads with a crowded sketch; with
Ctrl, a misclick is easily corrected without moving cursor at all.
2019-05-24 19:11:56 +00:00
whitequark 549565958f Skip creating an automatic H/V constraint if it would be redundant.
This means that automatically added H/V constraints now will never
cause the sketch to become overconstrained, which currently makes
that feature almost unusable.
2019-05-24 15:06:53 +00:00
whitequark ac7b82d7c1 Allow configuring the amount of digits displayed after decimal point.
This is useful in niche cases, like making angular measurement tools.

Also, use simpler and more principled code for numeric precision
while editing constraints: don't special-case angles, but use up to
10 digits after the decimal point for everything.
2019-05-23 17:53:53 +00:00
Dynamo Dan e67f967933 Implement turntable (SketchUp-like) mouse navigation. 2019-05-23 15:45:15 +00:00
EvilSpirit c9397eaa07 Make help text for image and TTF request creation reflect reality.
Before this commit it would prompt for top left and bottom left
corner, neither of which was what in fact was being used. Those two
specific points cannot be used because of the way equations are
written, so instead change that to top left and bottom right, which
is more convenient anyway.
2019-05-23 14:05:09 +00:00
whitequark a7b2f28999 Silence some gcc 7 warnings.
* Mark switch fallthrough
    (-Wfallthrough);
  * Initialize variables to avoid false positives
    (-Wmaybe-uninitialized);
  * Fudge indentation to avoid false positives
    (-Wmisleading-indentation).
2019-03-28 09:46:16 +00:00
whitequark 94b26ddfac Add a built-in Bitstream Vera Sans Roman font.
Before this commit, the default font chosen for TTF text is Arial
(chosen by the basename of arial.ttf), which isn't present on most
Linux systems, and cannot be redistributed. After this commit, it is
replaced with Bitstream Vera Sans, which can be. Existing files
are not affected.

The font name in the TTF file was artificially modified to add
the (built-in) suffix, which will need to be done if more built-in
fonts are added.
2019-02-11 11:03:47 +00:00
whitequark 7630e0e4e2 Make some dubious type conversions explicit.
This is to address MSVC warnings.

This commit changes a few configuration fields to use double instead
of float. There doesn't seem to be any reason these use float except
for the legacy Windows code using float for saved configuration.
Changing their type to double improves consistency.
2018-07-18 01:14:59 +00:00
whitequark c1f1c7c409 Add a platform abstraction for 6-DOF input devices.
This commit mostly just moves code around.
2018-07-18 01:05:19 +00:00
whitequark f324477dd0 Implement a platform abstraction for windows.
This commit removes a large amount of code partially duplicated
between the text and the graphics windows, and opens the path to
having more than one model window on screen at any given time,
as well as simplifies platform work.

This commit also adds complete support for High-DPI device pixel
ratio. It adds support for font scale factor (a fractional factor
on top of integral device pixel ratio) on the platform side, but not
on the application side.

This commit also adds error checking to all Windows API calls
(within the abstracted code) and fixes a significant number of
misuses and non-future-proof uses of Windows API.

This commit also makes uses of Windows API idiomatic, e.g. using
the built-in vertical scroll bar, native tooltips, control
subclassing instead of hooks in the global dispatch loop, and so on.

It reinstates tooltip support and removes menu-related hacks.
2018-07-17 13:31:17 +00:00
whitequark 55baaf310f Implement a platform abstraction for menus.
This commit removes a large amount of redundant code that needed
to be kept in sync between platforms and also makes it much easier
to add new menu-related functionality since little to no platform
code needs to be altered anymore.

This commit also greatly improves code locality in context menu
handling by allowing context menu click handlers to be closures.

This commit temporarily introduces a SetMainMenu API, which is rather
hacky but only necessary until an abstraction for windows is added.
2018-07-16 11:21:30 +00:00
whitequark 7ab87caa88 Implement a platform abstraction for timers.
This commit temporarily disables tooltip functionality; it will
be handled natively in a platform abstraction for windows using
much simpler code.
2018-07-16 11:21:30 +00:00
EvilSpirit 5744d1d599 Implement an image request. 2017-03-12 00:13:56 +00:00
EvilSpirit 97e71856b3 Snap point to entity when constraining to a hovered entity.
Before this commit, when a point is constrained to an entity (point,
circle, arc of circle or line segment) by clicking on it,
the resulting constraint is not necessarily satisfied, and the next
regeneration may place the newly constrained point somewhere other
than the intended position. After this commit, the parameters
are modified to satisfy the constraint.
2017-02-06 14:20:19 +00:00
EvilSpirit d4b052d34d Fix logic introduced in 55ae10b.
Before this commit, the effect of the AddPending() call was
immediately reversed by ClearSuper.
2017-01-24 20:30:48 +00:00
EvilSpirit 669e6f0dcb Select the appropriate entity when dragging a circle or a normal.
This commit adds logic that was missed in 25631d4.
2017-01-20 11:54:56 +00:00
EvilSpirit 119b17ac75 Fix an occasional crash when starting to drag an entity. 2017-01-20 11:48:47 +00:00
EvilSpirit c00ab25740 Don't move points when automatically constraining coincident.
This can change the sketch dramatically, e.g. extrude a rectangle
and draw a line diagonally from the top to the bottom face.
2017-01-11 04:34:11 +00:00
whitequark 855de072be Automatically constrain arc or rectangle points. 2017-01-11 04:17:14 +00:00
EvilSpirit 55ae10b5b8 Do not hover or select entities from any pending request. 2017-01-11 04:16:59 +00:00
whitequark 984f74d271 Internationalize all messages without substitutions. 2017-01-07 06:47:40 +00:00
whitequark 00dda08917 Internationalize the context menu. 2017-01-05 12:35:50 +00:00
EvilSpirit 25631d4fb2 Choose entities to select in a way appropriate for the operation.
Before this commit, when an entity is clicked at or dragged, and it
shares a place with other entities, which of them is selected is
decided more or less at random. This is particularly annoying when
dragging.

After this commit, when clicking, an entity from the current group
is given preference, and when dragging, an entity from a request
is given preference. This allows e.g. dragging points of a sketch
even when an extrusion of that sketch is active.
2017-01-02 12:21:01 +00:00
Evil-Spirit d99a133982 Do ScheduleGenerateAll in MarkGroupDirty.
This generally simplifies code, and also fixes a bug where adding
a datum point would not regenerate the sketch.
2016-12-26 07:58:00 +00:00
whitequark b10e621fce Rephrase error messages that say "select a workplane".
This is confusing, as merely selecting one (and not activating it)
is not enough to satisfy any of the conditions leading to these
errors.
2016-10-11 13:46:05 +00:00
whitequark 2371068d01 Don't regenerate the entire sketch in AddRequest().
This is unnecessary and leads to huge slowdowns on large sketches.
E.g. this speeds up import of a certain large DXF from ~60s to ~3s.
2016-10-10 20:33:02 +00:00
whitequark 21a4305ee1 Add "Zoom to Fit" to context menu. 2016-10-09 22:26:36 +00:00
whitequark 2f64f18095 Add "Select All" to context menu for no selection. 2016-10-09 22:26:25 +00:00
whitequark 2f4c6a6b0e Add "Toggle Construction" to context menu. 2016-10-09 22:13:01 +00:00
whitequark e7edc39b34 Alias the "=" key to "+" key. 2016-10-09 10:57:25 +00:00
EvilSpirit 065a0a8b00 Forcibly show the current group once we start a drawing operation. 2016-08-13 03:37:27 +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 85cd44df3c Show "Paste" context menu item even when only constraints are copied. 2016-06-20 13:47:14 +00:00