Re: QG_GraphicView::paintEvent conditions
Posted by
R. van Twisk on
Oct 12, 2015; 7:26pm
URL: https://forum.librecad.org/QG-GraphicView-paintEvent-conditions-tp5712414p5712415.html
On Oct 12, 2015, at 9:20 PM, ravas [via LibreCAD] <
[hidden email]> wrote:
if (redrawMethod & RS2::RedrawGrid)
...
if (redrawMethod & RS2::RedrawDrawing)
...
if (redrawMethod & RS2::RedrawOverlay)
...
RedrawNone = 0
RedrawGrid = 1
RedrawOverlay = 2
RedrawDrawing = 4
RedrawAll = 0xffff
https://en.wikipedia.org/wiki/Bitwise_operation#ANDI don't understand the point of these expressions.
If 0xffff & 2 evaluates to true,
It evaluates to 2, not to true
then 0xffff alone will evaluate to true.
0xffff & 0 evaluates to 0, there is no 0xffff alone here
If 0 & 2 evaluates to false, then 0 alone will evaluate to false.
Isn't the right side superfluous?
In otherwords, can't we just simplify it to one condition: if (redrawMethod) ?
If one method says
redrawMethod = redrawMethod | RS2::RedrawGrid
and a other methods says:
redrawMethod = redrawMethod | RS2::RedrawOverlay
Then only these two get executed, but not redraw of the drawing.
makes sense?