Measure Path: Add more layout options for text

Bug #1460422 reported by su_v
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
su_v

Bug Description

Interface
=========
The proposed change displays existing and new options for each of the two already existing text layout variants in a separate tab of a notebook inserted into the 'Measure' page of the main notebook.

Usage
=====
The script will use the layout variant of the tab which is current when the extension is live-previewed or applied.

Options
=======
1) Tab 'Text on path'
* Position along path: start|middle|end|custom
* Custom position: numeric input, used if Position is 'custom'
* Text anchor: left|center|right

2) Tab 'Fixed text'
* Position: start of path|center of geometric bbox
* Angle

The core features of the extensions are not modified.

Motivation
==========
Earlier commits introduced changes to the text layout which (in my opinion) are less beneficial for some basic use cases of the extension:
1) Length:
The text label for a measured length is no longer center-aligned at the midpoint of the measured path it is put on (the text is currently left-aligned i.e. it starts at the midpoint, apparently to avoid bent text when measuring polylines). This is visually displeasing when using the 'Measure Path' extension e.g. in combination with the 'Dimensioning' extension, or in general when measuring the length of lines with just one segment. The proposed change adds options to allow more fine-grained control of the position and alignment of the text put-on-path.
2) Area:
The text label for a measured area is no longer inserted near the center of the measured path (it can be positioned as 'text-put-on-path', see 1), or as "text with fixed angle" near the start node of the measured path). The proposed change adds an option to insert the text with fixed angle at the center of the geometric bounding box of the measured path.

Revision history for this message
su_v (suv-lp) wrote :
Revision history for this message
jazzynico (jazzynico) wrote :

Tested on Windows XP, Inkscape trunk rev. 14206.
Very nice improvements!

Some comments:
1. Depending on the settings, a text can be truncated or hidden. Example: with Length, Text on Path, position to Start, anchor to Center (truncated) or Right (hidden) .
2. Since we already have a function to calculate the center of mass, maybe we could use it as an option to position fixed text.
3. The custom position option fails with the following error:
----
File "measure.py", line 231, in effect
    startOffset = '{}%'.format(self.options.startOffsetCustom)
ValueError: zero length field name in format
----

Changed in inkscape:
assignee: nobody → ~suv (suv-lp)
milestone: none → 0.92
status: New → In Progress
Revision history for this message
su_v (suv-lp) wrote :

Updated patch attached.

- Presets (new tab):
Text put on path at start or end has predefined anchor position (does not get cut off)
- Text on Path:
With the custom option, the user has to take him/herself whether or not the chosen options make sense (e.g. left-align for text positioned at the end of the path -> text renders not visible since beyond the path it was put in).
- Fixed Text:
New option for Position: Center of Mass (reuses existing function)
TODO: check whether parent transforms and viewBox are handled correctly now [1]

I was not able to reproduce the failure with custom position option - any details you could share?

--
[1] https://bugs.launchpad.net/inkscape/+bug/803791/comments/12

Revision history for this message
jazzynico (jazzynico) wrote :

Thanks for the new features!

> I was not able to reproduce the failure with custom position option - any details you could share?

It seems that Python 2.6 doesn't support the string format syntax you used. Adding a positional argument (replacing '{}%' with '{0}%' line 238) fixes the issue for Windows XP and the official 32 bit devlibs, and should not cause problems with Python 2.7 and 3.1+ (see https://docs.python.org/dev/library/string.html#format-string-syntax).

Revision history for this message
jazzynico (jazzynico) wrote :

Note that the issue can also be fixed by updating Python in the devlibs, of course...

Revision history for this message
su_v (suv-lp) wrote :

On 2015-06-29 14:01 (+0200), jazzynico wrote:
> It seems that Python 2.6 doesn't support the string format syntax

Thanks for the hint - reproduced with Python 2.6.9 on OS X 10.7.5 (default Python used with my local builds is 2.7.10). Attached 3rd version of the patch was tested successfully with Python 2.5.6, 2.6.9 and 2.7.10 [1].
--
[1] Support for older Python versions matters for OS X packages too, not only for win32: the official 32bit package for Mac OS X uses Python 2.5 on Mac OS X 10.5.8, Python 2.6 on Mac OS X 10.6.8, and Python 2.7 on all later versions of OS X (python is provided by the system).

Revision history for this message
jazzynico (jazzynico) wrote :

New version tested successfully on Windows XP (32bit) with Inkscape trunk rev. 14285.
Thanks for the fix!

Revision history for this message
su_v (suv-lp) wrote :

Updated patch v4, changes:
- apply after r14384 for bug #1459295
- better UI labels for text presets option
- get values from text preset earlier, outside of the loop (it does not change per node)

Pending any objections or bugs I missed, I'll commit it tomorrow.

Revision history for this message
su_v (suv-lp) wrote :

Fix committed to trunk in rev 14388.

Changed in inkscape:
status: In Progress → Fix Committed
Bryce Harrington (bryce)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.