Implement platform-specific coordinate conversion functions
Generic wxDC::DeviceToLogical{X|Y}() and wxDC::LogicalToDevice{X|Y}() functions don't take into account transformations applied with wxDC::SetTransformMatrix() so conversion results are invalid if wxDC is transformed with both e.g. wxDC::SetUserScale() and wxDC::SetTransformMatrix(). We need to implement functions in wxDCImpl and its platform-specific derivates to do this conversion with taking into account all applied transformations. See #18916.
This commit is contained in:
@@ -487,6 +487,8 @@ void wxGCDCImpl::ComputeScaleAndOrigin()
|
||||
m_matrixCurrent.Concat(mtxExt);
|
||||
#endif // wxUSE_DC_TRANSFORM_MATRIX
|
||||
m_graphicContext->ConcatTransform( m_matrixCurrent );
|
||||
m_matrixCurrentInv = m_matrixCurrent;
|
||||
m_matrixCurrentInv.Invert();
|
||||
m_isClipBoxValid = false;
|
||||
}
|
||||
}
|
||||
@@ -594,6 +596,23 @@ void wxGCDCImpl::ResetTransformMatrix()
|
||||
|
||||
#endif // wxUSE_DC_TRANSFORM_MATRIX
|
||||
|
||||
// coordinates conversions and transforms
|
||||
wxPoint wxGCDCImpl::DeviceToLogical(wxCoord x, wxCoord y) const
|
||||
{
|
||||
wxDouble px = x;
|
||||
wxDouble py = y;
|
||||
m_matrixCurrentInv.TransformPoint(&px, &py);
|
||||
return wxPoint(wxRound(px), wxRound(py));
|
||||
}
|
||||
|
||||
wxPoint wxGCDCImpl::LogicalToDevice(wxCoord x, wxCoord y) const
|
||||
{
|
||||
wxDouble px = x;
|
||||
wxDouble py = y;
|
||||
m_matrixCurrent.TransformPoint(&px, &py);
|
||||
return wxPoint(wxRound(px), wxRound(py));
|
||||
}
|
||||
|
||||
bool wxGCDCImpl::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
|
||||
const wxColour& WXUNUSED(col),
|
||||
wxFloodFillStyle WXUNUSED(style))
|
||||
|
Reference in New Issue
Block a user