Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2008-06

qt tshapes arm

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Terry Kemp

Hi,
can anyone help me understand a bit more about the GetWindowOrgEx and QMatrix stuff in qtwinapi.inc.

I am trying to find out why TShapes are always drawn at 0,0 of the parent on arm machine (using project -qws not qtopia). its OK on host x11.
If I have one (tshape) center of screen it gets drawn correct shape and size but at 0, 0. if I put one in the middle of a groupbox it goes to 0,0 of the groupbox.

the extracts from enabling -dVerboseQtWinAPI -dVerboseQt are below. The problem is obviously the QMatrix_Dx and QMatrix_Dy returning garbage on arm but what is the likely cause of this?

Any clues - anybody?

Terry

as a side note I noticed today the problem with tpanels borders on arm has fixed itself :)

logs...

X11 (x86_64) running...
------------------------------------------
TQtWidget.SlotPaint Form1:TForm1
Trace:> [WinAPI BeginPaint] Handle=753030
TQtDeviceContext.Create ( WidgetHandle: 22820B0 FromPaintEvent:-1 ) TQtFont.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
TQtPen.Create CreateHandle: False
TQtRegion.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
Trace:< [WinAPI BeginPaint] Result=1815D0
[WinAPI SetWindowOrgEx] DC: 1815D0 NewX: 0 NewY: 0 Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 0
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY0
Trace: < [WinAPI GetWindowOrgEx] Result=(x=0,y=0)
TQtDeviceContext.translate()
[WinAPI RectVisible]
Trace:> [WinAPI SaveDC] DC=1815D0
TQtDeviceContext.CreateDCData()
Trace:< [WinAPI SaveDC] result=1
Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 0
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY0
Trace: < [WinAPI GetWindowOrgEx] Result=(x=0,y=0)
[WinAPI SetWindowOrgEx] DC: 1815D0 NewX: -48 NewY: -32 Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 0
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY0
Trace: < [WinAPI GetWindowOrgEx] Result=(x=0,y=0)
TQtDeviceContext.translate()
***** [WinAPI TQtWidgetSet.IntersectClipRect]
TQtPen.Create CreateHandle: True
--------------------------------------------

qt-embedded running on arm...
-----------------------------------
TQtWidget.SlotPaint Form1:TForm1
Trace:> [WinAPI BeginPaint] Handle=410D6020
TQtDeviceContext.Create ( WidgetHandle: 207260 FromPaintEvent:-1 ) TQtFont.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
TQtPen.Create CreateHandle: False
TQtRegion.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
Trace:< [WinAPI BeginPaint] Result=40F91380
[WinAPI SetWindowOrgEx] DC: 40F91380 NewX: 0 NewY: 0 Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 4.04058555339178E-308 Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY4.05214618646096E-308 Trace: < [WinAPI GetWindowOrgEx] Result=(x=-1030,y=0) TQtDeviceContext.translate()
[WinAPI RectVisible]
Trace:> [WinAPI SaveDC] DC=40F91380
TQtDeviceContext.CreateDCData()
Trace:< [WinAPI SaveDC] result=1
Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 4.04058555339178E-308 Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY4.05214618646096E-308 Trace: < [WinAPI GetWindowOrgEx] Result=(x=0,y=0)
[WinAPI SetWindowOrgEx] DC: 40F91380 NewX: -48 NewY: -32 Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 4.04058555339178E-308 Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY4.05214618646096E-308 Trace: < [WinAPI GetWindowOrgEx] Result=(x=-1030,y=0) TQtDeviceContext.translate()
***** [WinAPI TQtWidgetSet.IntersectClipRect]
TQtPen.Create CreateHandle: True
---------------------------------------------------------------

Terry Kemp
to Terry Kemp

Sorry,
looking closer at the panel painting on arm it has the same rubbish in QMatrix_Dx,Dy but draws correctly.

So confusing - what am I missing here?

TQtWidget.SlotPaint Panel1:TPanel
Trace:> [WinAPI BeginPaint] Handle=40F14980
TQtDeviceContext.Create ( WidgetHandle: 20FDE8 FromPaintEvent:-1 ) TQtFont.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
TQtPen.Create CreateHandle: False
TQtRegion.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
Trace:< [WinAPI BeginPaint] Result=40F91440
[WinAPI SetWindowOrgEx] DC: 40F91440 NewX: 0 NewY: 0 Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 4.04927724815157E-308 Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY4.06083788122075E-308 Trace: < [WinAPI GetWindowOrgEx] Result=(x=0,y=0)
TQtDeviceContext.translate()
Trace:> [WinAPI SelectObject] DC=40F91440 GDIObj=40EEAFC0 TQtDeviceContext.pen() TQtDeviceContext.setPen() TQtDeviceContext.pen() Trace:< [WinAPI SelectObject] Result=40EEAE00 ObjectType=Pen [WinAPI MoveToEx] DC:40F91440 X:0 Y:0
Trace:> [WinAPI CreateBrushIndirect] Style: 0, Color: FFFF00 (clAqua) TQtBrush.Create CreateHandle: True
Trace:< [WinAPI CreateBrushIndirect] Result: 40EEB120 Trace:> [WinAPI SelectObject] DC=40F91440 GDIObj=40EEB120 TQtDeviceContext.brush() TQtDeviceContext.setBrush() Trace:< [WinAPI SelectObject] Result=40EEA880 ObjectType=Brush
Trace:> [WinAPI SetBkColor] DC: 40F91440 Color: 16776960 TQtDeviceContext.setBKColor() TQtDeviceContext.backgroundBrush() TQtDeviceContext.backgroundBrush() Trace:> [WinAPI SetBkMode] DC=40F91440 BkMode=2
TQtDeviceContext.setBKMode() [TQtWidgetSet.Frame3d Rect= x1=0,y1=0,x2=170,y2=50
[TQtWidgetSet.Frame3d Rect= x1=6,y1=6,x2=164,y2=44 Trace:> [WinAPI SaveDC] DC=40F91440
TQtDeviceContext.CreateDCData()
Trace:< [WinAPI SaveDC] result=1
Trace:> [WinAPI GetStockObject] Value: 17
TQtFont.Create CreateHandle: True
Trace:< [WinAPI GetStockObject] Value: 17
Trace:> [WinAPI SelectObject] DC=40F91440 GDIObj=40EEB180 TQtDeviceContext.font()TQtDeviceContext.setFont() Trace:< [WinAPI SelectObject] Result=40EEAEA0 ObjectType=Font
[WinAPI DrawText] DC: 40F91440 Str: Panel1 CalcRect: True TQtDeviceContext.font()[WinAPI DrawText] Rect= x1=12,y1=12,x2=50,y2=30 Trace:> [WinAPI SetBkMode] DC=40F91440 BkMode=1
TQtDeviceContext.setBKMode() [WinAPI SetTextColor] DC: 40F91440 [WinAPI DrawText] DC: 40F91440 Str: Panel1 CalcRect: False TQtDeviceContext.font()TQtDeviceContext.drawText x: 66 Y: 16 w: 38 h: 18TQtDeviceContext.font()TQtDeviceContext.RestoreTextColor() TQtDeviceContext.RestorePenColor()
Trace:> [WinAPI RestoreDC] DC=40F91440 SavedDC=1
TQtDeviceContext.RestoreDCData()
Trace:< [WinAPI RestoreDC]
Trace:> [WinAPI SelectObject] DC=40F91440 GDIObj=40EEA880 TQtDeviceContext.brush() TQtDeviceContext.setBrush() Trace:< [WinAPI SelectObject] Result=40EEB120 ObjectType=Brush
Trace:> [WinAPI SelectObject] DC=40F91440 GDIObj=40EEAE00 TQtDeviceContext.pen() TQtDeviceContext.setPen() TQtDeviceContext.pen() Trace:< [WinAPI SelectObject] Result=40EEAFC0 ObjectType=Pen [WinAPI EndPaint] Handle: 40F14980 PS.HDC: 40F91440

Paul Ishenin
to Terry Kemp: can anyone help me understand a bit more about the GetWindowOrgEx and QMatrix stuff in…
Terry Kemp wrote 16 lines
Hi, can anyone help me understand a bit more about the GetWindowOrgEx and QMatrix stuff in qtwinapi.inc. I am trying to find out why TShapes are always drawn at 0,0 of the parent on arm machine (using project -qws not qtopia). its OK on host x11. If I have one (tshape) center of screen it gets drawn correct shape and size but at 0, 0. if I put one in the middle of a groupbox it goes to 0,0 of the groupbox. the extracts from enabling -dVerboseQtWinAPI -dVerboseQt are below. The problem is obviously the QMatrix_Dx and QMatrix_Dy returning garbage on arm but what is the likely cause of this? Any clues - anybody?

SetWindowOrgEx is a winapi compatibility function which moves your (0,0) coord to another point. So all your drawings after that will be shifted by that offset. Qt do the same by QPainter.translate method. We can query offsets by accessing QPainter.Matrix which is QMatrix class. On your arm QMatrix.dx and QMatrix.dy returns values which are very close to zero - and I dont see any problem here. But maybe qt dont do matrix transforms properly on arm? Or maybe we are passing incorrect values.

Is it possible to install emulator of your arm device and repeat the same on usual pc?

Best regards,
Paul Ishenin.

Terry Kemp
to Paul Ishenin
Show quoted text 13 lines
SetWindowOrgEx is a winapi compatibility function which moves your (0,0) coord to another point. So all your drawings after that will be shifted by that offset. Qt do the same by QPainter.translate method. We can query offsets by accessing QPainter.Matrix which is QMatrix class. On your arm QMatrix.dx and QMatrix.dy returns values which are very close to zero - and I dont see any problem here. But maybe qt dont do matrix transforms properly on arm? Or maybe we are passing incorrect values. Is it possible to install emulator of your arm device and repeat the same on usual pc? Best regards, Paul Ishenin.

Actually it is any TControl- TGraphicControl descendant that does this - not just shape. I see there is no specific implementation for these so they are drawn on the parent DC yes.
Everything looks OK except that in qtwinapi.inc,
TQtWidgetSet.SetWindowOrgEx the call to
TQtDeviceContext(DC).translate(-NewX, -NewY) seems to have no effect. I need some way of checking what the device translations are before and after this call, QPainter::deviceTransform or QPainter::deviceMatrix?

I wonder if this is some limitation in the paintengine capabilities for LinuxFB vs X11.

I will

Terry

Terry Kemp
to Terry Kemp
Show quoted text 18 lines
Actually it is any TControl- TGraphicControl descendant that does this - not just shape. I see there is no specific implementation for these so they are drawn on the parent DC yes. Everything looks OK except that in qtwinapi.inc, TQtWidgetSet.SetWindowOrgEx the call to TQtDeviceContext(DC).translate(-NewX, -NewY) seems to have no effect. I need some way of checking what the device translations are before and after this call, QPainter::deviceTransform or QPainter::deviceMatrix? I wonder if this is some limitation in the paintengine capabilities for LinuxFB vs X11. I will keep at it. Thanks Terry

The problem is with the matrix...

I added this in function TQtWidgetSet.SetWindowOrgEx(DC : HDC; NewX,
NewY : Integer; OldPoint: PPoint) : Boolean;
  matrix := TQtDeviceContext(DC).getworldmatrix;
  WriteLn('[WinAPI SetWindowOrgEx] MATRIX dx: ',
floattostr(qmatrix_dx(matrix)));
  WriteLn('[WinAPI SetWindowOrgEx] MATRIX dy: ',
floattostr(qmatrix_dy(matrix)));
  WriteLn('[WinAPI SetWindowOrgEx] MATRIX m11: ',
floattostr(qmatrix_m11(matrix)));
  WriteLn('[WinAPI SetWindowOrgEx] MATRIX m12: ',
floattostr(qmatrix_m12(matrix)));
  WriteLn('[WinAPI SetWindowOrgEx] MATRIX m21: ',
floattostr(qmatrix_m21(matrix)));
  WriteLn('[WinAPI SetWindowOrgEx] MATRIX m22: ',
floattostr(qmatrix_m22(matrix)));

and on X11 machine I get this...

TQtWidget.SlotPaint GroupBox1:TGroupBox
Trace:> [WinAPI BeginPaint] Handle=75C1B0
TQtDeviceContext.Create ( WidgetHandle: DDA570 FromPaintEvent:-1 ) AWidget = DDA570
TQtFont.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
TQtPen.Create CreateHandle: False
TQtRegion.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
Trace:< [WinAPI BeginPaint] Result=1815D0
[WinAPI SetWindowOrgEx] DC: 1815D0 NewX: -2 NewY: -23 [WinAPI SetWindowOrgEx] MATRIX dx: 0
[WinAPI SetWindowOrgEx] MATRIX dy: 0
[WinAPI SetWindowOrgEx] MATRIX m11: 1
[WinAPI SetWindowOrgEx] MATRIX m12: 0
[WinAPI SetWindowOrgEx] MATRIX m21: 0
[WinAPI SetWindowOrgEx] MATRIX m22: 1
Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 0
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY0
Trace: < [WinAPI GetWindowOrgEx] Result=(x=0,y=0)
[WinAPI SetWindowOrgEx] DC: 1815D0 P.X: 0 P.Y: 0
[WinAPI SetWindowOrgEx] OldPoint: 0
TQtDeviceContext.drawRect() x1: 2 y1: 23 w: 10 h: 10 TQtDeviceContext.translate()
TQtDeviceContext.drawRect() x1: 0 y1: 0 w: 12 h: 12 [WinAPI RectVisible]
Trace:> [WinAPI SaveDC] DC=1815D0
TQtDeviceContext.CreateDCData()
Trace:< [WinAPI SaveDC] result=1
Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 2
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY23
Trace: < [WinAPI GetWindowOrgEx] Result=(x=-2,y=-23) [WinAPI SetWindowOrgEx] DC: 1815D0 NewX: -64 NewY: -24 [WinAPI SetWindowOrgEx] MATRIX dx: 2
[WinAPI SetWindowOrgEx] MATRIX dy: 23
[WinAPI SetWindowOrgEx] MATRIX m11: 1
[WinAPI SetWindowOrgEx] MATRIX m12: 0
[WinAPI SetWindowOrgEx] MATRIX m21: 0
[WinAPI SetWindowOrgEx] MATRIX m22: 1
Trace: > [WinAPI GetWindowOrgEx]

all good, and on arm I get this...

TQtWidget.SlotPaint GroupBox1:TGroupBox
Trace:> [WinAPI BeginPaint] Handle=40F14860
TQtDeviceContext.Create ( WidgetHandle: 212778 FromPaintEvent:-1 ) AWidget = 212778
TQtFont.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
TQtPen.Create CreateHandle: False
TQtRegion.Create CreateHandle: False
TQtBrush.Create CreateHandle: False
Trace:< [WinAPI BeginPaint] Result=40F91380
[WinAPI SetWindowOrgEx] DC: 40F91380 NewX: -2 NewY: -19 [WinAPI SetWindowOrgEx] MATRIX dx: 4.05408993460549E-308 [WinAPI SetWindowOrgEx] MATRIX dy: 4.05408993460549E-308 [WinAPI SetWindowOrgEx] MATRIX m11: 4.0540904609599E-308 [WinAPI SetWindowOrgEx] MATRIX m12: 4.05408993460549E-308 [WinAPI SetWindowOrgEx] MATRIX m21: 4.05408993460549E-308 [WinAPI SetWindowOrgEx] MATRIX m22: 4.0540904609599E-308 Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 4.0425293015363E-308 Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY4.05408993460549E-308 Trace: < [WinAPI GetWindowOrgEx] Result=(x=0,y=0)
[WinAPI SetWindowOrgEx] DC: 40F91380 P.X: 0 P.Y: 0 [WinAPI SetWindowOrgEx] OldPoint: 0
TQtDeviceContext.drawRect() x1: 2 y1: 19 w: 10 h: 10 TQtDeviceContext.translate()
TQtDeviceContext.drawRect() x1: 0 y1: 0 w: 12 h: 12 [WinAPI RectVisible]
Trace:> [WinAPI SaveDC] DC=40F91380
TQtDeviceContext.CreateDCData()
Trace:< [WinAPI SaveDC] result=1
Trace: > [WinAPI GetWindowOrgEx]
Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DX 4.0425293015363E-308 Trace: < [WinAPI GetWindowOrgEx] QMATRIX_DY4.05409046510443E-308 Trace: < [WinAPI GetWindowOrgEx] Result=(x=0,y=0)
[WinAPI SetWindowOrgEx] DC: 40F91380 NewX: -62 NewY: -1 [WinAPI SetWindowOrgEx] MATRIX dx: 4.05408993460549E-308 [WinAPI SetWindowOrgEx] MATRIX dy: 4.05409046510443E-308 [WinAPI SetWindowOrgEx] MATRIX m11: 4.0540904609599E-308 [WinAPI SetWindowOrgEx] MATRIX m12: 4.05408993460549E-308 [WinAPI SetWindowOrgEx] MATRIX m21: 4.05408993460549E-308 [WinAPI SetWindowOrgEx] MATRIX m22: 4.0540904609599E-308

Where has my matrix gone??????
I tried creating one and setting worldmatrix etc but it always returns these negative numbers.

doesn't this look like some sort of an integer overflow type of problem?

I have run the Qt mainwindow demo on the arm (which uses qpainter.translate) from the qt-embedded-linux-opensource-src-4.4.0 arm build I am using and there are no problems so its not a Qt prob.

Terry (smacking head against brick wall) Kemp

Paul Ishenin
to Terry Kemp
Terry Kemp wrote 10 lines
Where has my matrix gone?????? I tried creating one and setting worldmatrix etc but it always returns these negative numbers. doesn't this look like some sort of an integer overflow type of problem? I have run the Qt mainwindow demo on the arm (which uses qpainter.translate) from the qt-embedded-linux-opensource-src-4.4.0 arm build I am using and there are no problems so its not a Qt prob.

Maybe some fpc troubles? We are calling translate so:

TQtDeviceContext(DC).translate(P.X, P.Y);

where P.X and P.Y are integers but translate arguments are doubles. So maybe fpc wrongly converts integers to double? Can you check what do you get in TQtDeviceContext.translate. I mean arguments dx and dy.

Btw, what fpc version do you use?

Best regards,
Paul Ishenin.