diff --git a/ArchitectureColoredPainting/src/Editor/LayerManager.cpp b/ArchitectureColoredPainting/src/Editor/LayerManager.cpp index 06f0170..b1d2e60 100644 --- a/ArchitectureColoredPainting/src/Editor/LayerManager.cpp +++ b/ArchitectureColoredPainting/src/Editor/LayerManager.cpp @@ -13,8 +13,21 @@ LayerWrapper *LayerManager::getRoot() const } void LayerManager::paint(QPainter *painter, QSize size,LayerWrapper* selecetedLayer) const { + painter->save(); root->getCache(); root->paint(painter); + painter->restore(); + painter->save(); + // painter->setBrush(QBrush(Qt::white)); + //painter->setCompositionMode(QPainter::CompositionMode_Difference); + if (selecetedLayer != nullptr) + { + painter->setPen(QPen(Qt::gray, 2, Qt::DashLine)); + selecetedLayer->paintVisualBounding(painter); + //painter->setPen(QPen(Qt::gray, 2, Qt::DashDotLine)); + //selecetedLayer->paintVisualBounding(painter); + } + painter->restore(); } bool LayerManager::singleSelectedCheck() const { diff --git a/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp index 1240eb2..d2f1453 100644 --- a/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp +++ b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp @@ -284,7 +284,14 @@ int FolderLayerWrapper::getReferencedBy()const void LayerWrapper::paint(QPainter* painter, QTransform transform, bool force) { - + // if (this->selected) + // { + // painter->save(); + //painter->setPen(QPen(Qt::red, 2)); + //painter->setTransform(transform); + //painter->drawRect(this->cache.getBoundingRect()); + //painter->restore(); + // } } void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool force) @@ -428,4 +435,21 @@ bool LeafLayerWrapper::referencingGroupElement() const bool LayerWrapper::canApplyStyles() const { return typeid(*this) == typeid(LeafLayerWrapper) && !referencingGroupElement(); +} + +void LayerWrapper::paintVisualBounding(QPainter* painter) const +{ + if (hidden) + return; + QTransform transform; + auto layer = this->parent; + while (layer != nullptr) + { + transform = transform * layer->property.transform; + layer = layer->parent; + } + painter->save(); + painter->setTransform(transform); + painter->drawRect(cache.getBoundingRect()); + painter->restore(); } \ No newline at end of file diff --git a/ArchitectureColoredPainting/src/Editor/LayerWrapper.h b/ArchitectureColoredPainting/src/Editor/LayerWrapper.h index 6312f12..c45ec21 100644 --- a/ArchitectureColoredPainting/src/Editor/LayerWrapper.h +++ b/ArchitectureColoredPainting/src/Editor/LayerWrapper.h @@ -75,6 +75,7 @@ class LayerWrapper virtual size_t referencedCount(bool excludeSelf = false) const; virtual bool deleteable(bool excludeSubTree = false) const; virtual bool referencingGroupElement() const; + virtual void paintVisualBounding(QPainter* painter) const; bool canApplyStyles() const; }; diff --git a/ArchitectureColoredPainting/src/Editor/PixelPath.cpp b/ArchitectureColoredPainting/src/Editor/PixelPath.cpp index 3087f39..e673504 100644 --- a/ArchitectureColoredPainting/src/Editor/PixelPath.cpp +++ b/ArchitectureColoredPainting/src/Editor/PixelPath.cpp @@ -78,7 +78,8 @@ PixelPath PixelPath::trans(QTransform& mat)const painter.setTransform(mat); painter.drawPixmap(0, 0, pixmap); result.painterPath.addPath(this->painterPath); - result.boundingRect = mat.mapRect(boundingRect); + result.painterPath = mat.map(result.painterPath); + result.boundingRect = result.painterPath.boundingRect(); return result; }