PDA

View Full Version : QRegion multiply



xgoan
4th August 2006, 09:48
Hi,

I'm doing a map creator for a isometric game and I use a zoom (qreal) for scale the QPainter surface for zoom, also I use a QRegion (polygon not rectangle) and need to multiply the area for know the square that is below the cursor. How can I do it?

Thank's bye.

Sample code

Square *square=map.getSquare(i,j);
QRegion region(square->region());
if(square->region().contains(cursorPos)){
//if(region.contains(cursorPos)){
painter.setPen(Qt::red);
selectedSquarePosX=i; selectedSquarePosY=j;
}

xgoan
4th August 2006, 09:54
Hehehe I have a valid solution:


Square *square=map.getSquare(i,j);
QPolygon zoomedPoly;
zoomedPoly<<square->left()*zoom
<<square->up()*zoom
<<square->right()*zoom
<<square->down()*zoom;
QRegion region(zoomedPoly);
if(region.contains(cursorPos)){
painter.setPen(Qt::red);
selectedSquarePosX=i; selectedSquarePosY=j;
}

Square inherits from QPolygon and has defined up(), right(), down(), left() as points of the polygon.

Anyway is there a better solution for it?