Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced Snap Middle Manual Tool #1424

Closed
wants to merge 9 commits into from

Conversation

melwyncarlo
Copy link
Contributor


This tool can snap (set) the relative-zero marker in the middle between two points chosen by the user.

The middle point, by default, rests at a poistion 50% relative to the position of the first point chosen, that is, at the center of the imaginary line connecting the two user-defined points.

This percentage, however, can be modified by the user in order to place the marker at a different position along the imaginary line.


Video link : https://youtu.be/XZU929ykxvg


In the video, the dotted lines seemed too faint, so I changed them to dots-and-dashes, as seen below:

Screenshot from 2021-11-20 22-53-07

@dellus
Copy link

dellus commented Nov 20, 2021

A nice to have feature. A bit clumsy to use, though. I would prefer it to be integrated into the drawing workflow. Like draw a line from an existing point A to the middle of point B and C. I think this is called a transparent command, a sub command used within a main command. Probably not that easy. Do you think you could tackle this? Or are inclined to at all?
If it's too much effort we can discuss whether it is better to have it this way (defining relative zero) than not to have it at all.

A similar and even more valuable feature would be Snap to the imaginary intersection of two not really intersecting lines.
More can be considered like Snap to perpendicular basepoint from a point to a line, but not so important.

Where to place it in the user interface? You have put it at Tools. Maybe the snaps or relative zero bar is a better place.

@melwyncarlo
Copy link
Contributor Author

melwyncarlo commented Nov 21, 2021

I did not have all this in mind. My aim was to simply accomplish the exact feature from the newer version of QCAD as requested by @gerardbm. It seems to do the exact same thing as mentioned in his reference video, but slightly improvised.

The icon seems a little faint. I'm wondering if I should thicken the lines.
I basically mimicked QCAD's tool icon, but styled it as per the other LibreCAD icons.
(I referred to the other LibreCAD icons for color and line thickness.)

I put it in the tool bar, because it is a tool and not just a setting.
Though I might be wrong.

@melwyncarlo
Copy link
Contributor Author

A similar and even more valuable feature would be Snap to the imaginary intersection of two not really intersecting lines.
More can be considered like Snap to perpendicular basepoint from a point to a line, but not so important.

Both these seem interesting.

@lordofbikes
Copy link
Member

@dellus nailed, what I already meant on Zulip, that this may be more complex than it looks on first sight.

We have no similar function in LibreCAD currently, both mentioned features don't work like common snap functions.
The snap functions work in background and are implemented in each entities code. They already do lots of work on each mouse move trigger. Iterating the document, finding nearest entities and then acquire nearest snap point from activated snap functions.

For these new features we can't implement them the same way. In a complex drawing, finding imaginary intersection or middle points on each mouse move event, will end in drastic rise of computing time and therefor slow down GUI reaction time. Also there would be a bunch of snap points for which it is not obvious to which entities they belong.

So these features need a new implementation. They work more similar to trim function or tangent drawing tools. The user must activate this function, then select two entities and the resulting intersection or middle point must be sourced to the active function. This can be drawing or modifying functions, so these features have to be implemented for all kind of tools and functions.
And copy/paste a possible implementation over and over for each entity and tool is not an acceptable solution.

Some tools need one point, some two and others even more. But possibly these imaginary points are not needed for all points of an action. So a kind of single shot activation would be appropriate I think.

  1. activate any tool (e.g. draw or modify)
  2. activate imaginary snap
  3. select the number of entities to find the imaginary snap point
  4. source the point to the tool
  5. deactivate imaginary snap
  6. select any other point for active tool or return back to 2. to use imaginary snap again

So this is a nice case study and a good training project, but far from implementation in main code base.

With all that said, I expect, that this feature will never be realized for LibreCAD 2.
It's not only about the efforts you may put into this. The expected global changes for this new kind of functionality will also need extensive testing and reviewing, for what we don't have the resources in foreseeable future.
I'll comment this in #1421 too, for better understanding.

@melwyncarlo
Copy link
Contributor Author

A nice to have feature. A bit clumsy to use, though. I would prefer it to be integrated into the drawing workflow. Like draw a line from an existing point A to the middle of point B and C. I think this is called a transparent command, a sub command used within a main command. Probably not that easy. Do you think you could tackle this? Or are inclined to at all? If it's too much effort we can discuss whether it is better to have it this way (defining relative zero) than not to have it at all.

I can surely tackle it if I correctly understand it's implementation. A graphical representation would surely help.
Point A to the middle of point B and C? I'm assuming here that you are talking about the Snap to perpendicular basepoint tool?

@melwyncarlo
Copy link
Contributor Author

@lordofbikes Instead of sourcing the point, can't the other tools just read the zero-marker position instead?

Maybe set the zero-marker position as a private variable, and create a public void getRelativeZeroMarkerPosition()?

Or create a slot function to pass that information through a variable by reference?

These tools basically (in the end) just re-position the marker, that's all!
Nothing that special about them.
It's mostly about ensuring that the marker is re-positioned correctly.


It is indeed a very nice case study. While I do not hope for its implementation, I will still try to create those two tools in my free time. I'm wondering if I should create pull-requests for those two tools, or if there is another means of publishing it?

@dellus
Copy link

dellus commented Nov 22, 2021

"Point A to the middle of point B and C? I'm assuming here that you are talking about the Snap to perpendicular basepoint tool?"
I mean the "Snap middle manual" tool.
I don't manage to upload an image here. So imagine there is a square, with the lower left corner as point A, lower right corner as point B and upper left corner is point C. Now I want to draw a line from point A to the center of the square. I start with the ordinary line command. When asked to specify the first point I do so with selecting point A, probably by using ordinary "Snap on Endpoints". When asked to specify the next point, I trigger the "Snap middle manual" tool, for instance by pressing the according button you have designed. It will ask me to specify two points, which I do with ordinary snap again. After having specified the second point my line command is instantly completed ending at the center of the square and also relative zero resting there.
This is just for explanation. Lordofbikes has closed the pull request. He would rather like to see you spending your efforts on LibreCAD 3. But in your "free time" you may have your private ventures...

@melwyncarlo
Copy link
Contributor Author

melwyncarlo commented Nov 22, 2021

Now I've understood it, and to me, that seems doable. But the question is, how do I implement the connectivity (sending data from one tool to another)?

Earlier I've mentioned two options. But @lordofbikes is not fond of adding snippets to all the action tool files.

Without touching the other tool files, the only other option that I can think of is deliberately simulating a mouse-click, using the <QTest> header file, like in this solution:

https://stackoverflow.com/questions/21680565/qt5-c-automated-mouse-clicking

Now, that seems more like a hack than a conventional solution. Wonder if that's acceptable?

@melwyncarlo
Copy link
Contributor Author

I've created the other two mentioned tools; though they're just standalone for now.


  1. Snap bilinear intersection tool

Code : melwyncarlo@e8a99a4

Video link : https://youtu.be/tim_ZlNXp5E


  1. Snap point line intersection tool

Code : melwyncarlo@86b5828

Video link : https://youtu.be/pkdx8qKABLw

@dellus
Copy link

dellus commented Nov 23, 2021

Oh sweet dreams...
We have to find a subversive workaround to use these tools in LibreCAD 2. Mmmm..., what files will have to be replaced or added in an existing LibreCAD installation? An .exe that does this all?
And the question of workflow integration...
Never mind, just fantasies.

@gerardbm
Copy link

Oh sweet dreams... We have to find a subversive workaround to use these tools in LibreCAD 2. Mmmm..., what files will have to be replaced or added in an existing LibreCAD installation? An .exe that does this all? And the question of workflow integration... Never mind, just fantasies.

I think that this could be a specific branch, or even a fork of LibreCAD for this purpose.

@melwyncarlo
Copy link
Contributor Author

@gerardbm My changes are merely less than 1% of the total code. 😄

@melwyncarlo
Copy link
Contributor Author

@dellus Not fantasies, it is possible; and no subversion, just tactical fixtures.
I've been busy lately. Regardless, there is a workaround.
A tool can be kept running whilst using another tool.
I've seen another tool utilise this technique, just can't remember which, for now.

@lordofbikes lordofbikes added PR xlarge pull request, very large diff size PR feature pull request, integrating a new feature PR pending pull request, decision outstanding labels Apr 28, 2022
@lordofbikes lordofbikes added PR next release pull request, to be considered for next release and removed PR pending pull request, decision outstanding labels Jun 6, 2022
@gerardbm
Copy link

Could this be added (merged) in the version 2?

dxli added a commit that referenced this pull request Feb 28, 2024
* Advanced Snap Middle Manual Tool

* Update rs_actionsnapmiddlemanual.cpp

* Update rs_actionsnapmiddlemanual.h

* Update lc_actionfactory.h

* Update lc_actionfactory.cpp

* Update rs_actionsnapmiddlemanual.h

* Embedded the tool

* Embedded tool - Made some corrections

* Embedded tool - Tiny code addition to disable tool button

* merging

* cleanup

* cleanup

---------

Co-authored-by: Melwyn Francis Carlo <melwyncarlo@gmail.com>
Co-authored-by: Melwyn Francis Carlo <66683108+melwyncarlo@users.noreply.github.com>
@dxli
Copy link
Member

dxli commented Jun 6, 2024

Merged. Closing now.

@dxli dxli closed this Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR feature pull request, integrating a new feature PR next release pull request, to be considered for next release PR xlarge pull request, very large diff size
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants