本文整理汇总了C++中TileLayer::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ TileLayer::isEmpty方法的具体用法?C++ TileLayer::isEmpty怎么用?C++ TileLayer::isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileLayer
的用法示例。
在下文中一共展示了TileLayer::isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tilePositionChanged
void BucketFillTool::tilePositionChanged(const QPoint &tilePos)
{
if (mStamp.isEmpty())
return;
bool shiftPressed = QApplication::keyboardModifiers() & Qt::ShiftModifier;
bool fillRegionChanged = false;
// Make sure that a tile layer is selected
TileLayer *tileLayer = currentTileLayer();
if (!tileLayer)
return;
// todo: When there are multiple variations, it would make sense to choose
// random variations while filling. When the variations have different
// sizes, probably the bounding box of all variations should be used.
Map *variation = mStamp.randomVariation();
TileLayer *stampLayer = static_cast<TileLayer*>(variation->layerAt(0));
// Skip filling if the stamp is empty
if (!stampLayer || stampLayer->isEmpty())
return;
TilePainter regionComputer(mapDocument(), tileLayer);
// If the stamp is a single tile, ignore it when making the region
if (stampLayer->width() == 1 && stampLayer->height() == 1 && !shiftPressed &&
stampLayer->cellAt(0, 0) == regionComputer.cellAt(tilePos.x(),
tilePos.y()))
return;
// This clears the connections so we don't get callbacks
clearConnections(mapDocument());
// Optimization: we don't need to recalculate the fill area
// if the new mouse position is still over the filled region
// and the shift modifier hasn't changed.
if (!mFillRegion.contains(tilePos) || shiftPressed != mLastShiftStatus || mIsRandom) {
// Clear overlay to make way for a new one
clearOverlay();
// Cache information about how the fill region was created
mLastShiftStatus = shiftPressed;
// Get the new fill region
if (!shiftPressed) {
// If not holding shift, a region is generated from the current pos
mFillRegion = regionComputer.computePaintableFillRegion(tilePos);
} else {
// If holding shift, the region is the selection bounds
mFillRegion = mapDocument()->selectedArea();
// Fill region is the whole map if there is no selection
if (mFillRegion.isEmpty())
mFillRegion = tileLayer->bounds();
// The mouse needs to be in the region
if (!mFillRegion.contains(tilePos))
mFillRegion = QRegion();
}
fillRegionChanged = true;
}
// Ensure that a fill region was created before making an overlay layer
if (mFillRegion.isEmpty())
return;
if (mLastRandomStatus != mIsRandom) {
mLastRandomStatus = mIsRandom;
fillRegionChanged = true;
}
if (!mFillOverlay) {
// Create a new overlay region
const QRect fillBounds = mFillRegion.boundingRect();
mFillOverlay = SharedTileLayer(new TileLayer(QString(),
fillBounds.x(),
fillBounds.y(),
fillBounds.width(),
fillBounds.height()));
}
// Paint the new overlay
if (!mIsRandom) {
if (fillRegionChanged) {
mMissingTilesets.clear();
mapDocument()->unifyTilesets(variation, mMissingTilesets);
TilePainter tilePainter(mapDocument(), mFillOverlay.data());
tilePainter.drawStamp(stampLayer, mFillRegion);
}
} else {
randomFill(mFillOverlay.data(), mFillRegion);
fillRegionChanged = true;
}
if (fillRegionChanged) {
// Update the brush item to draw the overlay
brushItem()->setTileLayer(mFillOverlay);
}
//.........这里部分代码省略.........