Fix retrieving bounding box coordinates

Bounding box coordinates have to be calculated and stored internally in device units to be independent on changes of logical coordinates between calls to wxDC::CalcBoundingBox.
These stored coordinates are converted to the logical units on demand when they are retrieved with call to wxDC::MinX, MinY, MaxX or MaxY.

Closes #17667.
This commit is contained in:
Artur Wieczorek
2016-09-16 22:04:53 +02:00
parent 4f0701c82c
commit 277f9c58a1
2 changed files with 11 additions and 6 deletions

View File

@@ -105,6 +105,7 @@ All (GUI):
- Add wxGraphicsContext::Flush() for Cairo renderer.
- Add wxStyledTextEvent::GetListCompletionMethod() (NewPagodi).
- Add wxEVT_STC_AUTOCOMP_COMPLETED event (NewPagodi).
- Fix retrieving bounding box for wxDC with transformed coordinates.
wxGTK:

View File

@@ -325,6 +325,9 @@ public:
virtual void CalcBoundingBox(wxCoord x, wxCoord y)
{
// Bounding box is internally stored in device units.
x = LogicalToDeviceX(x);
y = LogicalToDeviceY(y);
if ( m_isBBoxValid )
{
if ( x < m_minX ) m_minX = x;
@@ -349,10 +352,11 @@ public:
m_minX = m_maxX = m_minY = m_maxY = 0;
}
wxCoord MinX() const { return m_minX; }
wxCoord MaxX() const { return m_maxX; }
wxCoord MinY() const { return m_minY; }
wxCoord MaxY() const { return m_maxY; }
// Get bounding box in logical units.
wxCoord MinX() const { return m_isBBoxValid ? DeviceToLogicalX(m_minX) : 0; }
wxCoord MaxX() const { return m_isBBoxValid ? DeviceToLogicalX(m_maxX) : 0; }
wxCoord MinY() const { return m_isBBoxValid ? DeviceToLogicalY(m_minY) : 0; }
wxCoord MaxY() const { return m_isBBoxValid ? DeviceToLogicalY(m_maxY) : 0; }
// setters and getters
@@ -712,8 +716,8 @@ protected:
m_mm_to_pix_y;
// bounding and clipping boxes
wxCoord m_minX, m_minY, m_maxX, m_maxY;
wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
wxCoord m_minX, m_minY, m_maxX, m_maxY; // Bounding box is stored in device units.
wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2; // Clipping box is stored in logical units.
wxRasterOperationMode m_logicalFunction;
int m_backgroundMode;