FreeCAD icon indicating copy to clipboard operation
FreeCAD copied to clipboard

Core / Measure: Introduce QuickMeasure

Open PaddleStroke opened this issue 2 years ago • 22 comments

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

PaddleStroke avatar Jan 31 '24 20:01 PaddleStroke

Here's how it looks : image

PaddleStroke avatar Jan 31 '24 20:01 PaddleStroke

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.

chennes avatar Feb 01 '24 11:02 chennes

Bugs are fixed. Order in status bar is fixed too.

PaddleStroke avatar Feb 01 '24 16:02 PaddleStroke

@chennes I fixed the end of files and changed to enum class.

PaddleStroke avatar Feb 05 '24 09:02 PaddleStroke

The CI is failing for MacOS but I can't understand why. Any idea @chennes ?

PaddleStroke avatar Feb 05 '24 10:02 PaddleStroke

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.

chennes avatar Feb 05 '24 14:02 chennes

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

adrianinsaval avatar Feb 05 '24 18:02 adrianinsaval

@hlorus - comments re umf work in progress?

WandererFan avatar Feb 10 '24 04:02 WandererFan

@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.

hlorus avatar Feb 10 '24 12:02 hlorus

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

PaddleStroke avatar Feb 13 '24 09:02 PaddleStroke

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.

DanMiel avatar Feb 17 '24 03:02 DanMiel

So that it doesn't get lost...

  1. Total length for adjacent edges is 0:

image

  1. Volume is in ml for some reason, shouldn't it be cm^3?

image

prokoudine avatar Apr 15 '24 14:04 prokoudine

1 Body is selected 2 Two edges selected @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 avatar Apr 15 '24 18:04 DanMiel

@DanMiel I am commenting on the code submitted in this pull request, naturally :)

prokoudine avatar Apr 15 '24 18:04 prokoudine

The unified measurement tool is merged now, could this PR be completed now?

maxwxyz avatar Apr 30 '24 04:04 maxwxyz

Rebased on main after the Unified measurement tool merged. So I'll mark this PR as ready now.

PaddleStroke avatar Apr 30 '24 15:04 PaddleStroke

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?

maxwxyz avatar May 02 '24 14:05 maxwxyz

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 avatar May 02 '24 14:05 PaddleStroke

@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.

maxwxyz avatar May 02 '24 17:05 maxwxyz

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.

PaddleStroke avatar May 03 '24 08:05 PaddleStroke

@maxwxyz can you please test and feedback if everything is fine now?

PaddleStroke avatar May 03 '24 09:05 PaddleStroke

looks good!

maxwxyz avatar May 03 '24 12:05 maxwxyz

Looks to me as this code makes no use or almost of the new measurement framework. Am I correct ?

0penBrain avatar May 09 '24 15:05 0penBrain

Well, the framework was merged to main only last week. The Quick Measure feature developed over main is months old.

prokoudine avatar May 09 '24 15:05 prokoudine

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.

0penBrain avatar May 09 '24 16:05 0penBrain

Depending on unmerged patch sounds risky, but now that both are in main, code can be deduplicated

prokoudine avatar May 09 '24 17:05 prokoudine

Why are square millimeters written as mm^2 and not as mm²?

DrD4ffy avatar May 09 '24 18:05 DrD4ffy

Depending on unmerged patch sounds risky

Depending on self-coded things is even more. Trust me on this. :smile:

0penBrain avatar May 09 '24 18:05 0penBrain

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.

PaddleStroke avatar May 10 '24 08:05 PaddleStroke

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.

0penBrain avatar May 10 '24 15:05 0penBrain