为GraphicElement添加了isClosed接口 | #11
parent
4c95d6e362
commit
66cde802ec
|
@ -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<QPointF>(painterPath.elementAt(0));
|
||||
auto endPoint = static_cast<QPointF>(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)
|
||||
{
|
||||
|
|
|
@ -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<LayerWrapper*>& set) const;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue