Skip to content

Conversation

@dustinhartlyn
Copy link
Contributor

When creating any multi point shape (such as rectangle), if zoom in/out is used from the keyboard or menu after setting the first point of the object, the mouse will be misaligned with the current point.

  • Select rectangle from tool window
  • Click on sketch to set first point-point
  • Press – or + on keyboard to zoom in or out to see alignment issue that occurs.

When I dug into the code I found that there are two different function responsible for zooming in/out. It seems the first was originally created in graphicswin.cpp for the menu option while the second was made in mouse.cpp for the scroll-wheel

Unfortunately having two different functions created to accomplish the same behavior left the opportunity for anomalies and I believe I have fixed the problem by making a single zoom function in graphicswin.cpp. This function takes a single argument which is the zoom multiplier and adjusts the scale centered on the mouse position (same behavior as the zoom function on mouse.cpp). The scroll-wheel event goes to the same function in mouse.cpp, but instead of performing actions directly it points to the shared ZoomToMouse function placed bellow the ZoomToFit function in graphicswin.cpp. The keyboard also points to this function instead of modifying the 'scale' variable directly. Triggering the event from the menu appears to work naturally even though the mouse is positioned over the menu.

In addition to fixing the bug and eliminating a redundant function, I think the ZoomToMouse function offers the opportunity for future development where a call can be easily made to zoom in/out. It could also be modified to be a ZoomToPoint function if needed. The ZoomToMouse function would be changed to forward the mouse position as the point of focus, but I did not see a need to go that far just yet.

dustinhartlyn and others added 8 commits March 30, 2021 22:05
On windows 10 the open/save dialogue box has an minor error, and I believe I fixed it. 

When "Open" is selected from the menu, the title of the dialogue box says "SolveSpace - Save File" and the entered file name is "united". My fix correctly titles the dialoged box, and leaves the address bar blank when a file is being opened because "united" is only needed as a default name when a file being saved. 

I found that class FileDialogImplWin32 from guiwin.cpp contains two if statements for "isSaveDialog". This is redundant. I removed the first where the title was originally set, but not working. I then set the title in the second if statement and moved the 'if isEmpty'' to this section.
replaced tabs with spaces
…mouse position directly. Simplified MouseScroll in mouse.cpp to point to this function instead of altering zoom directly. Also pointed zoom commpand from keyboard and menu to ZoomToMouse so that it works avoids different behavior.
Created ZoomToMouse function in graphicswin.cpp which referances the …
@ruevs ruevs self-requested a review February 21, 2022 11:59
@phkahler
Copy link
Member

Also want to bring in @vespakoen since he's been in the mouse code and has pending PR #1218 which might conflict?

@dustinhartlyn
Copy link
Contributor Author

Just following up on rather this code conflicts with work from @vespakoen
I looked over the edits of PR #1218 and don't see any conflicts myself. Especially since I left the original function used for zooming in/out within mouse.cpp, I think the edits I made are fairly sensitive to any work being done by others.

@phkahler
Copy link
Member

@dustinhartlyn thanks for that update.

@phkahler phkahler merged commit fc16cdb into solvespace:master Feb 28, 2022
@ruevs
Copy link
Member

ruevs commented Mar 7, 2022

@phkahler @dustinhartlyn I am not sure if this is an improvement. It depends whether one considers the old behaviour a bug or a feature.

Before this pull request was merged scroll wheel zooming was centered on the mouse pointer and + - zooming was centered on the view-port (the center of the drawing area). To me this was a feature.

@phkahler
Copy link
Member

phkahler commented Mar 7, 2022

Before this pull request was merged scroll wheel zooming was centered on the mouse pointer and + - zooming was centered on the view-port (the center of the drawing area). To me this was a feature.

@ruevs I still see that behavior on Windows. Have not specifically checked in Linux yet.

@dustinhartlyn If I draw a rectangle and zoom while dragging, the zoom with mouse wheel is centered on the point/mouse pointer. If I zoom with +/- it zooms relative to the screen center, but the point being dragged is no longer under the mouse pointer. This seems like the "bug" you set out to fix, or is it different. Either way I don't think this is done yet.

On a somewhat related note, I've always wanted the ability to select a point and have rotation be around that point. As it is, rotation when zoomed in usually results if seeing a completely different part of the model.

@ruevs
Copy link
Member

ruevs commented Mar 8, 2022

@ruevs I still see that behavior on Windows. Have not specifically checked in Linux yet.

@phkahler strange... Ara you sure you have master at fc16cdb ?

With that commit I see that zooming in both ways (scroll wheeel and +-) is always "centered" on the mouse pointer - irrespective of whether one is still drawing a rectangle or not and whether LMB is pressed or not.

@phkahler
Copy link
Member

phkahler commented Mar 8, 2022

@phkahler strange... Ara you sure you have master at fc16cdb ?

I'll check on my linux system later. I used the latest edge build on windows, but that may not have updated with recent commits.

@ruevs
Copy link
Member

ruevs commented Mar 10, 2022

Hmmm the latest edge build on windows is from this commit c5ea9a44
Something is wrong...

Yes the snap build is failing:
https://github.com/solvespace/solvespace/actions/runs/1912157466

Executing: 'snap run snapcraft '
aa_is_enabled() failed unexpectedly (No such file or directory): No such file or directory
Error: No snap files produced by build

I re-started the job to see if it will behave differently and it failed again.

@ppd do you have an idea what might be happening?

devin-ai-integration bot pushed a commit to erkinalp/solvespace that referenced this pull request Apr 3, 2025
* minor fix open/save dialogue on windows 

On windows 10 the open/save dialogue box has an minor error, and I believe I fixed it. 

When "Open" is selected from the menu, the title of the dialogue box says "SolveSpace - Save File" and the entered file name is "united". My fix correctly titles the dialoged box, and leaves the address bar blank when a file is being opened because "united" is only needed as a default name when a file being saved. 

I found that class FileDialogImplWin32 from guiwin.cpp contains two if statements for "isSaveDialog". This is redundant. I removed the first where the title was originally set, but not working. I then set the title in the second if statement and moved the 'if isEmpty'' to this section.

* Update guiwin.cpp

replaced tabs with spaces

* Created ZoomToMouse function in graphicswin.cpp which referances the mouse position directly. Simplified MouseScroll in mouse.cpp to point to this function instead of altering zoom directly. Also pointed zoom commpand from keyboard and menu to ZoomToMouse so that it works avoids different behavior.

* clean up some comments
dennisyangji pushed a commit to Orthogonalpub/ode_solvespace that referenced this pull request Nov 25, 2025
* minor fix open/save dialogue on windows 

On windows 10 the open/save dialogue box has an minor error, and I believe I fixed it. 

When "Open" is selected from the menu, the title of the dialogue box says "SolveSpace - Save File" and the entered file name is "united". My fix correctly titles the dialoged box, and leaves the address bar blank when a file is being opened because "united" is only needed as a default name when a file being saved. 

I found that class FileDialogImplWin32 from guiwin.cpp contains two if statements for "isSaveDialog". This is redundant. I removed the first where the title was originally set, but not working. I then set the title in the second if statement and moved the 'if isEmpty'' to this section.

* Update guiwin.cpp

replaced tabs with spaces

* Created ZoomToMouse function in graphicswin.cpp which referances the mouse position directly. Simplified MouseScroll in mouse.cpp to point to this function instead of altering zoom directly. Also pointed zoom commpand from keyboard and menu to ZoomToMouse so that it works avoids different behavior.

* clean up some comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants