Пример #1
0
void Eraser::doErase(bool mergeable)
{
    TileLayer *tileLayer = currentTileLayer();
    const QPoint tilePos = tilePosition();

    if (!tileLayer->bounds().contains(tilePos))
        return;

    QRegion eraseRegion(tilePos.x(), tilePos.y(), 1, 1);
    EraseTiles *erase = new EraseTiles(mapDocument(), tileLayer, eraseRegion);
    erase->setMergeable(mergeable);

    mapDocument()->undoStack()->push(erase);
    mapDocument()->emitRegionEdited(eraseRegion, tileLayer);
}
Пример #2
0
void Eraser::doErase(bool continuation)
{
    TileLayer *tileLayer = currentTileLayer();
    const QPoint tilePos = tilePosition();
    QRegion eraseRegion(tilePos.x(), tilePos.y(), 1, 1);

    if (continuation) {
        for (const QPoint &p : pointsOnLine(mLastTilePos, tilePos))
            eraseRegion |= QRegion(p.x(), p.y(), 1, 1);
    }
    mLastTilePos = tilePosition();

    if (!tileLayer->bounds().intersects(eraseRegion.boundingRect()))
        return;

    EraseTiles *erase = new EraseTiles(mapDocument(), tileLayer, eraseRegion);
    erase->setMergeable(continuation);

    mapDocument()->undoStack()->push(erase);
    mapDocument()->emitRegionEdited(eraseRegion, tileLayer);
}