Gravity labels rendered incorrectly

Bug #998121 reported by Sibi Antony
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stellarium
Fix Released
Low
Sibi Antony

Bug Description

The gravity labels option has the text rendered in an incorrect way.
Working with the TUI menu, the text can get lengthy and jumps off the dome circle often. Attached is a screenshot with problem areas encircled.

The problems are that
* The text is not strictly following a circular path, rather the angles are incorrectly computed at many places.
* shifting - xhift, yshift does not really offer a workaround.
* The cardinal points are drawn over while using the disk viewport.

Related branches

Revision history for this message
Sibi Antony (sibi-antony) wrote :
Revision history for this message
Sibi Antony (sibi-antony) wrote :

The problem seems to be with the circle algorithm. I checked history of drawGravityText180() and stellarium was using a totally different algorithm in the beginning. (Which was based on projection transforms).

With the current implementation it is intended to follow circular path around the projection center, it doesn't always. Since the coordinates are calculated incrementally from the previous ones, there is always an error involved.

The attached patch should address the problem. This uses a much simpler algorithm to make sure that the distance with the projection center is constant. Takes into account the width of each character relative to the average width, to compute angles for each character.

Revision history for this message
Sibi Antony (sibi-antony) wrote :

As for the cardinal points, the problem is with the shifting of the text for centering.
But this adds to clipped text while using disk viewport. Not sure of a better way than to disable shifting for disk viewport.

Revision history for this message
Sibi Antony (sibi-antony) wrote :

A screenshot with the changes applied.

Revision history for this message
Alexander Wolf (alexwolf) wrote :

I'll review patches tonight later. Thanks!

Changed in stellarium:
milestone: none → 0.11.3
Revision history for this message
Alexander Wolf (alexwolf) wrote :
Changed in stellarium:
assignee: nobody → Sibi Antony (sibi-antony)
status: New → Fix Committed
importance: Undecided → Low
Revision history for this message
Sibi Antony (sibi-antony) wrote :

Thank you Alex!
A small optimization. The statement to check (theta > 2 * M_PI) is not necessary, which has no effect after subtracting 2 * M_PI.
I had this line while debugging, to see the angles spanned. So you can remove them.

- // Lengthy string. Text wraps around!
- if (theta > 2. * M_PI)
- theta -= 2.*M_PI;

..

- if (theta > 2. * M_PI)
- theta -= 2.*M_PI;

Revision history for this message
Khalid AlAjaji (kajaji) wrote :

Gravity labels for Right-to-Left language Arabic bug #801668 is fixed partially. The remaining problem is to draw text word by word rather than letter by letter because in Arabic individual letters shapes are different than when they are part of words.

See treaves comment there: "This is going to be the case for any languange where a character is different depending on it's context. When gravity labels are in effect, the label is drawn one character at a time ( see http://bazaar.launchpad.net/~stellarium/stellarium/trunk/view/head:/src/core/StelPainter.cpp#L628 ). What needs to happen is to draw the text with a transform in place, instead of drawing each character transformed."

Revision history for this message
Sibi Antony (sibi-antony) wrote :

Khalid: this bug was merely intended to fix the circle rendering, as it is implemented in the current algorithm.

For the Right to left languages problem we may have to track it separately. Besides, I think the point you've brought up is not specific to Right-to-Left languages itself, there are many other languages (For eg: Hindi) that can break while drawing text character-by-character.

In my opinion too, drawing with a transform would be a better idea. That was how it was done in the earlier stellarium code. http://bazaar.launchpad.net/~stellarium/stellarium/trunk/view/4735/src/core/StelPainter.cpp#L593

I don't know on what reasons this was changed (in trunk revision 4736). Perhaps old developers can throw some light.

Revision history for this message
Sibi Antony (sibi-antony) wrote :

Sorry, wrong revision. It was always character-wise in stellarium. I have seen the transforms in nightshade ( Projector::print_gravity180() ), thought that stellarium had the same code once.

Revision history for this message
Khalid AlAjaji (kajaji) wrote :

Thanks for your attention.

Changed in stellarium:
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.