When logical coordinates of wxPaintDC (under wxGTK3) are changed with transformation matrix (with SetTransformMatrix()), clipping region is invalid after call toDestroyClippingRegion() .
This issue is not seen when logical coordinates are changed with other functions, like SetDeviceOrigin(), SetUserScale(), SetLogicalOrigin(), etc.
ClippingBoxTestCase::wxPaintDC tests (currently disabled for wxGTK3): https://github.com/wxWidgets/wxWidgets/blob/6ba55b96b84ae4f2dc1e9ad324e7620738991842/tests/graphics/clippingbox.cpp#L4156Clipping region after call to SetTransformMatrix():

Reported coordinates of clipping region:
Debug: Invalid position: Actual: (0, 0) Expected: (-20, -25)
Debug: Invalid size: Actual: 180 x 29 Expected: 200 x 54
Clipping region after call to SetDeviceOrigin() etc.:

--- a/samples/minimal/minimal.cpp +++ b/samples/minimal/minimal.cpp @@ -63,6 +63,7 @@ public: // event handlers (these functions should _not_ be virtual) void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); + void OnPaint(wxPaintEvent& evt); private: // any class wishing to process wxWidgets events must use this macro @@ -175,11 +176,52 @@ MyFrame::MyFrame(const wxString& title) CreateStatusBar(2); SetStatusText("Welcome to wxWidgets!"); #endif // wxUSE_STATUSBAR + Bind(wxEVT_PAINT, &MyFrame::OnPaint, this); } // event handlers +void MyFrame::OnPaint(wxPaintEvent&) +{ + wxPaintDC dc(this); + if ( true ) + { + wxAffineMatrix2D m; + m.Translate(40, 75); + m.Scale(2.0, 3.0); + dc.SetTransformMatrix(m); + } + else + { + dc.SetDeviceOrigin(10, 15); + dc.SetUserScale(0.5, 1.5); + dc.SetLogicalScale(4.0, 2.0); + dc.SetLogicalOrigin(-15, -20); + } + + dc.DestroyClippingRegion(); + dc.SetBackground(*wxYELLOW_BRUSH); + dc.Clear(); + + // Logical coordinates of painting area + wxPoint orig = dc.DeviceToLogical(0, 0); + wxSize dim = dc.DeviceToLogicalRel(dc.GetSize()); + + wxRect clip; + dc.GetClippingBox(clip); + + wxString msg; + if ( orig != clip.GetPosition() ) + { + wxLogDebug("Invalid position: Actual: (%i, %i) Expected: (%i, %i)", clip.x, clip.y, orig.x, orig.y); + } + if ( dim != clip.GetSize() ) + { + wxLogDebug("Invalid size: Actual: %i x %i Expected: %i x %i", clip.width, clip.height, dim.x, dim.y); + } +} + void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { // true is to force the frame to close
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Closed #23046 as completed via #23052.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()