Bug 90027 - ENHANCEMENT: Draw: Measure shape area, length of paths... in the status bar and/or dedicated dialog
Summary: ENHANCEMENT: Draw: Measure shape area, length of paths... in the status bar a...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL: https://ask.libreoffice.org/t/how-to-...
Whiteboard:
Keywords:
: 137126 (view as bug list)
Depends on:
Blocks: Draw-UX Shapes
  Show dependency treegraph
 
Reported: 2015-03-15 19:14 UTC by Robert Gonzalez MX
Modified: 2023-09-05 10:36 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Some shapes (12.62 KB, application/vnd.oasis.opendocument.graphics)
2015-03-15 19:20 UTC, Robert Gonzalez MX
Details
Statusbar (137.02 KB, image/png)
2023-09-04 13:26 UTC, Heiko Tietze
Details
Self-intersecting polygon (11.54 KB, image/png)
2023-09-05 10:36 UTC, Vincent Boudry
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Gonzalez MX 2015-03-15 19:14:36 UTC
Hello.

Currently the status bar shows the position and the size of the selected object, but this size refers to the size delimited by the handles of the shape, that is a four side polygon or rectangle.

It will be good to have an automatic area calculation of the shape itself in the status bar and in the dialog of position and size.

For basic shapes, like square, rectangle, triangle and circle, a think the calculation could be simple, because the length of the handles polygon match some of the measures needed for the calculation.

For example, in the square and rectangle is as simple as multiplying the width by the height.

For the triangle, the width match the base and the height is the same needed for the calculation of base of triangle by height divided by two.

In the case of a regular circle, the size of the width is equal the diameter needed for the area calculation. Even with the ellipsis, the size of the width is equal to the long diameter and the height is equal to the short diameter, which can be used to calculate the area.

I know that some shapes will require a more complex procedures to calculate, and I don't have the programming skills to develop this feature. So I hope that this enhancement goes to the right people thinking on improve the Draw module of LibreOffice.

Thanks.
Comment 1 Robert Gonzalez MX 2015-03-15 19:20:54 UTC
Created attachment 114114 [details]
Some shapes
Comment 2 Buovjaga 2015-03-20 19:12:35 UTC
Sounds useful -> NEW.
Comment 3 Heiko Tietze 2016-06-12 09:36:11 UTC
What is the use case for this calculation? I mean to calculate the area size is rather a question after the drawing, or is it necessary for some reason to know it precisely?
Comment 4 putt1ck 2020-07-15 06:44:56 UTC
One use case is probably pretty common: calculating the floor area of a room or bit of land that is oddly shaped or contains fixtures that result in the area being oddly shaped.

This is useful for example when working out how much flooring is required, or the amount of fertiliser needed to maximise yield from a particular crop. You would simply set the scale used on an imported graphic layer and then draw a polygon over it.

As the original poster noted this is easy for regular shapes, but within Draw it should be relatively easy to calculate the area within any closed polygon (because it's routinely done in GIS, so the calculations must be well known - could ask the QGIS devs how it is done).
Comment 5 Raju. N 2020-12-02 09:16:54 UTC Comment hidden (spam)
Comment 6 KobyVon 2021-10-26 10:20:25 UTC Comment hidden (spam)
Comment 7 Stéphane Guillou (stragu) 2023-08-30 09:11:41 UTC
*** Bug 137126 has been marked as a duplicate of this bug. ***
Comment 8 Stéphane Guillou (stragu) 2023-08-30 09:22:40 UTC
I've marked bug 137126 as a duplicate, even though it also asked for perimeter.

I can see how area and perimeter (or "total length of all paths") can be useful values in various use cases (see also bug 156549).

Question is:
- what can realistically fit in the status bar, e.g. what would be most useful? Does it need to be configurable?
- should extra statistics live in a dedicated "object statistics" dialog, just like we have document stats in Writer? For a selection of objects, could be numbers like: number of objects, total length of paths, total area, total length of paths with a style, total filled area...
Comment 9 Heiko Tietze 2023-09-04 13:26:17 UTC
Created attachment 189340 [details]
Statusbar

Both shapes are 1x1cm - the statusbar shows the size of the selection. What is missing?
Comment 10 Stéphane Guillou (stragu) 2023-09-04 16:25:31 UTC
(In reply to Heiko Tietze from comment #9)
> Created attachment 189340 [details]
> Statusbar
> 
> Both shapes are 1x1cm - the statusbar shows the size of the selection. What
> is missing?

In this particular case, how I picture it would be having (as well as the _selection frame_ info we already have):
- Shape area = 2 cm²
- Total path length = 8 cm
Comment 11 Heiko Tietze 2023-09-05 06:42:32 UTC
(In reply to Stéphane Guillou (stragu) from comment #10)
> - Total path length = 8 cm

My point was that we actually show all information and I wonder if the simple math  is worth all the effort.

But no objection to a statistics dialog similar to Writer.
Comment 12 Stéphane Guillou (stragu) 2023-09-05 07:43:39 UTC
(In reply to Heiko Tietze from comment #11)
> (In reply to Stéphane Guillou (stragu) from comment #10)
> > - Total path length = 8 cm
> 
> My point was that we actually show all information and I wonder if the
> simple math  is worth all the effort.
> 
> But no objection to a statistics dialog similar to Writer.

It's simple maths for a 1 × 1 square but not for (groups of) more complex shapes.
And we show some information for the selection rectangle, not for the objects.
Comment 13 Vincent Boudry 2023-09-05 10:34:12 UTC
(In reply to Stéphane Guillou (stragu) from comment #12)
> (In reply to Heiko Tietze from comment #11)
> > (In reply to Stéphane Guillou (stragu) from comment #10)
> > > - Total path length = 8 cm
> > 
> > My point was that we actually show all information and I wonder if the
> > simple math  is worth all the effort.
> > 
> > But no objection to a statistics dialog similar to Writer.
> 
> It's simple maths for a 1 × 1 square but not for (groups of) more complex
> shapes.
> And we show some information for the selection rectangle, not for the
> objects.

It is rather simple for regular "non self-intersecting" forms, see e.g.:
https://www.wikihow.com/Calculate-the-Area-of-a-Polygon, based on https://www.mathopenref.com/polygonregulararea.html
and https://www.mathsisfun.com/geometry/area-irregular-polygons.html
in the later there is even a interactive tool to calculate this:
   https://www.mathsisfun.com/geometry/area-polygon-drawing.html.

For self-intersecting polygons, this is more tricky. I guess the easiest is to split them in two separate polygons.
This is properly handled for the drawing of filled polygons (see attachment).


Beyond precise calculations, there are also a very nice way of calculating on integer coordinates, covering all cases:
   https://en.wikipedia.org/wiki/Pick's_theorem
that could be used if the coordinates are quantized with a reasonable large step.
Comment 14 Vincent Boudry 2023-09-05 10:36:21 UTC
Created attachment 189366 [details]
Self-intersecting polygon