QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
Line drift in PhAB |
Ref. No. |
QNX.000009905 |
Category(ies) |
Development |
Issue |
In our application we use some PtLine geometry. When we quit the application then restart PhAB, our line is no longer in the position where we placed it (it drifted up on pixel). Did we forget to set a resource? Does it happen with only single horizontal line or in combination with their widgets? What are the size and position of the line?
|
Solution |
You need to set a line thickness > 2 pixels. This behaviour is actually caused by one of the flags on the PtLine and other graphics subclass widgets.
Pt_ARG_GRAPHIC_FLAGS: Pt_FLOAT_POS (set by default) Pt_FLOAT_ORIGIN (cleared by default).
The Pt_FLOAT_POS flag indicates that the widget may adjust its position in order to prevent clipping the upper-left corner of the graphics. So a line at 3,3 which has a thickness of 3 pixels would reposition itself to 3,2 so the center of the line is still at 3,3. If you record the position of the widget and recreate it at 3,2, it will reposition itself at 3,1 in order to keep the line centered at 3,2.
The Pt_FLOAT_ORIGIN flag will shift the graphics such that the upper left corner is visible within the widgets canvas.
To use the above example position the line at 3,3, give it a line thickness of 3 because of the Pt_FLOAT_ORIGIN flag, the widget remains at 3,3 but its relative origin will increment by 1 in the y direction. If the resize policy is set to 'always', the widget will resize so the entire line is visible. The line will not 'drift'.
|
|