# QG_GraphicView::paintEvent conditions

4 messages
Open this post in threaded view
|

## QG_GraphicView::paintEvent conditions

 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, then 0xffff alone will evaluate to true. 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) ?
Open this post in threaded view
|

## Re: QG_GraphicView::paintEvent conditions

 Administrator 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 truethen 0xffff alone will evaluate to true. 0xffff & 0 evaluates to 0, there is no 0xffff alone hereIf 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::RedrawGridand a other methods says:redrawMethod = redrawMethod | RS2::RedrawOverlayThen only these two get executed, but not redraw of the drawing.makes sense?