diff --git a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp index 5c0acb0..4cc2ef3 100644 --- a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp +++ b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp @@ -17,7 +17,10 @@ void SimpleElement::loadSvgFile(const QString& filePath) // TODO 样式问题 SvgFileLoader loader; loader.loadSvgFile(filePath, painterPath); - qDebug() << "load svg file success " << painterPath.elementCount(); + auto startPoint = static_cast(painterPath.elementAt(0)); + auto endPoint = static_cast(painterPath.elementAt(painterPath.elementCount() - 1)); + this->closed = startPoint == endPoint; + qDebug() << "load svg file success " << painterPath.elementCount() << (isClosed() ? "is" : "not") << "closed"; } SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource) @@ -117,11 +120,21 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt painter->restore(); } +bool SimpleElement::isClosed() const +{ + return closed; +} + void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) { sourceLayer->paint(painter, transform); } +bool GroupElement::isClosed() const +{ + return false; +} + QPixmap SimpleElement::getPreview(QSize size) { diff --git a/ArchitectureColoredPainting/src/Editor/GraphicElement.h b/ArchitectureColoredPainting/src/Editor/GraphicElement.h index d0500b2..377b9e5 100644 --- a/ArchitectureColoredPainting/src/Editor/GraphicElement.h +++ b/ArchitectureColoredPainting/src/Editor/GraphicElement.h @@ -28,11 +28,14 @@ public: virtual PixelPath getPaintObject() const = 0; virtual PixelPath getPaintObject(const LayerStyleContainer& styles) const = 0; virtual void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) = 0; + virtual bool isClosed() const = 0; virtual QPixmap getPreview(QSize size) = 0; }; class SimpleElement : public GraphicElement { +private: + bool closed; public: QJsonObject jsonSource; // TODO: 改为ComposedPainterPath @@ -48,6 +51,7 @@ public: PixelPath getPaintObject() const override; PixelPath getPaintObject(const LayerStyleContainer& styles) const override; void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override; + bool isClosed() const override; QPixmap getPreview(QSize size) override; }; @@ -65,6 +69,7 @@ public: PixelPath getPaintObject(const LayerStyleContainer& styles) const override; void setSourceLayer(FolderLayerWrapper* sourceLayer); void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override; + bool isClosed() const override; QPixmap getPreview(QSize size) override; void collectReachable(std::set& set) const; };