Core / Measure: Introduce QuickMeasure
Introduce quick measure. This adds a small label on the status bar on the right side that gives basic information about selection :
- lenght of edges
- Area of faces
- Volume of solids
- distances ...
Also as a small thing, it makes the text of the status bar label selectable so you can select it and copy it.
Fixes https://github.com/FreeCAD/FreeCAD/issues/12049
Here's how it looks :
There seem to be a couple of small bugs here: in my testing, parallel edges don't show their distance, nor do two selected points.
Bugs are fixed. Order in status bar is fixed too.
@chennes I fixed the end of files and changed to enum class.
The CI is failing for MacOS but I can't understand why. Any idea @chennes ?
Don't worry about it, that CI has been giving us problems quite frequently due to some sort of timeout. I believe @adrianinsaval in aware of the issue.
I'll see if I can manage to reproduce the CI problem on the m1 mac once I get home, for now first just try re triggering the CI if you see mac failing every now and then
@hlorus - comments re umf work in progress?
@hlorus - comments re umf work in progress?
UMF doesn't utilize the Measurement class in Measurement.h, so conflicts should be minimal. However, there might be some code duplication, which would probably be nice to avoid.
Ah indeed we are bound to have conflicts here, as for a start we both introduce the Measure/Gui module. And yes we must have some code duplication as its doing something similar
I would like to comment on putting the measurements on the bottom or top of the screen. I wrote the QuickMeasure Add-on and had the output going to the status bar. I found it awkward to move my eyes from what I was measuring to the status line and then back up to the part, I found it easier to create the existing text box and put it by what I was measuring, thereby keeping my eyes on the part and on the output. Dan Miel.
This is copied from pull request #12049 which was closed before I wrote to it.
So that it doesn't get lost...
- Total length for adjacent edges is 0:
- Volume is in ml for some reason, shouldn't it be cm^3?
@prokoudine;
I’m using the original Quick Measure WB in these pictures. At this point I am not sure which program you are using.
In picture 1 I have selected a body from the tree. It is a block 3x1x1/2. In the text box it gives the both the volume and the surface area of the body. Your program may be reporting both but missing the ^3.
In picture 2 Two lines are selected. The angle is 90 degrees, total length of the lines is 4 inches, and the closest they come to each other is .5 inches. Your program might be reporting the distance they come to each other which is 0.
Dan Miel
@DanMiel I am commenting on the code submitted in this pull request, naturally :)
The unified measurement tool is merged now, could this PR be completed now?
Rebased on main after the Unified measurement tool merged. So I'll mark this PR as ready now.
I could see a slowdown when changing selection in big documents with complex geometry if always the volume/area is calculated (just selecting/organizing items in the tree view). Maybe selection in the tree view could be excluded?
I think the problem is that the function that gets the volume/area from the shape is a bit slow because its computing them everytime its called.
This also causes some annoying issues in assembly and MBD as well. I'll open an issue about this.
@PaddleStroke could we comment out or deactivate COM and Volume for now? Most of the time when selecting objects in the tree view the user is not interested in these measures. When it's needed, the new measurement tool can provide them. COM would also be more relevant if a coordinate system or datum point could be created at it's location.
Yes I think we are going to disable area / volume for solids because there are no obvious way to solve this. And as you say volume/area are not so often needed. When it is the UMT can be used.
@maxwxyz can you please test and feedback if everything is fine now?
looks good!
Looks to me as this code makes no use or almost of the new measurement framework. Am I correct ?
Well, the framework was merged to main only last week. The Quick Measure feature developed over main is months old.
Well, the framework was merged to main only last week. The Quick Measure feature developed over main is months old.
Framework dev is available as a PR for months so doesn't look as a sensible argument.
Depending on unmerged patch sounds risky, but now that both are in main, code can be deduplicated
Why are square millimeters written as mm^2 and not as mm²?
Depending on unmerged patch sounds risky
Depending on self-coded things is even more. Trust me on this. :smile:
I based QuickMeasure on the pre-existing Measurement class and extended it. At that time I had not seen the UMT work which was a draft PR.
It seems UMT is introducing measurement document objects for each type of measurement. Quickmeasure does not need to create objects. So it can hardly reuse UMT framework.
However it stands that there is duplication of the functions calculating the values (length, area...). But then I would say they do not belong to the measure document objects, as one (such as quickmeasure) can need to calculate measures without needing to create document objects. So those would belong to the pre-existing measurement class, where quickMeasure is using them.
It seems UMT is introducing measurement document objects for each type of measurement.
I don't think so. When you use the tool, the result is displayed in the Task panel without any object created. 😉
EDIT: @PaddleStroke I'm wrong here, I just checked and an object is created, then discarded if the measurement isn't validated.