wxPdfDocument

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
PythagorasSvenne
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Nov 15, 2013 1:46 pm

wxPdfDocument

Post by PythagorasSvenne »

I'm using wxPdfDocument and tries to create rotated texts. My problem is that I can't understand how the text is rotated. So my question is which Point should i send to this method? The following code creates two texts:

this->_dc->DrawRotatedText(str, p, angle);
this->_dc->DrawText(str, p);
Depending on the angle the text behaves a bit strange.

Regards,
Sven
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument

Post by utelle »

PythagorasSvenne wrote:I'm using wxPdfDocument and tries to create rotated texts. My problem is that I can't understand how the text is rotated. So my question is which Point should i send to this method? The following code creates two texts:

this->_dc->DrawRotatedText(str, p, angle);
this->_dc->DrawText(str, p);
Depending on the angle the text behaves a bit strange.
As far as I understand the wxDC method DrawRotatedText the point passed to this method will be the center of the rotation (and corresponds to the left corner of the text string) and the angle is measured in degrees counterclockwise, where a value of 0 corresponds to unrotated text.

Please explain "behaves a bit strange". What's wrong?

Regards,

Ulrich
PythagorasSvenne
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Nov 15, 2013 1:46 pm

Re: wxPdfDocument

Post by PythagorasSvenne »

utelle wrote:
PythagorasSvenne wrote:I'm using wxPdfDocument and tries to create rotated texts. My problem is that I can't understand how the text is rotated. So my question is which Point should i send to this method? The following code creates two texts:

this->_dc->DrawRotatedText(str, p, angle);
this->_dc->DrawText(str, p);
Depending on the angle the text behaves a bit strange.
As far as I understand the wxDC method DrawRotatedText the point passed to this method will be the center of the rotation (and corresponds to the left corner of the text string) and the angle is measured in degrees counterclockwise, where a value of 0 corresponds to unrotated text.

Please explain "behaves a bit strange". What's wrong?

Regards,

Ulrich
Try this and look at the result. The rotation center is not top left corner of the text:

_dc->DrawText(txt, p);
for ( double xa = 45.0; xa < 359; xa+= 45.0)
{
_dc->DrawRotatedText(txt, p, xa);
}

The rotation center is rotated in an unlogic way.

Regards,
Sven
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument

Post by utelle »

PythagorasSvenne wrote: Try this and look at the result. The rotation center is not top left corner of the text:

_dc->DrawText(txt, p);
for ( double xa = 45.0; xa < 359; xa+= 45.0)
{
_dc->DrawRotatedText(txt, p, xa);
}

The rotation center is rotated in an unlogic way.
This might be related to the map mode style. For wxPDF_MAPMODESTYLE_PDF the rotation center is the left edge of the base line. Try a different map mode style with wxPdfDC method SetMapModeStyle. Maybe this solves the issue.

Regards,

Ulrich
PythagorasSvenne
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Nov 15, 2013 1:46 pm

Re: wxPdfDocument

Post by PythagorasSvenne »

utelle wrote:
PythagorasSvenne wrote: Try this and look at the result. The rotation center is not top left corner of the text:

_dc->DrawText(txt, p);
for ( double xa = 45.0; xa < 359; xa+= 45.0)
{
_dc->DrawRotatedText(txt, p, xa);
}

The rotation center is rotated in an unlogic way.
This might be related to the map mode style. For wxPDF_MAPMODESTYLE_PDF the rotation center is the left edge of the base line. Try a different map mode style with wxPdfDC method SetMapModeStyle. Maybe this solves the issue.

Regards,

Ulrich
Thanks for this! When using drawRotatedText the map mode must be set to wxPDF_MAPMODESTYLE_PDF and lower left corner must be used.

Thanks for your help!
Sven
Post Reply