添加了所有Layer的styles成员
parent
a55a38385e
commit
a3d39b32e5
|
@ -141,7 +141,7 @@ bool SimpleElement::isClosed() const
|
||||||
|
|
||||||
void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
|
void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
|
||||||
{
|
{
|
||||||
sourceLayer->paint(painter, transform, true);
|
sourceLayer->paint(painter, transform, true, styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GroupElement::isClosed() const
|
bool GroupElement::isClosed() const
|
||||||
|
|
|
@ -61,10 +61,10 @@ bool LayerManager::combine() const
|
||||||
for (auto &layer : selectedLayers)
|
for (auto &layer : selectedLayers)
|
||||||
if (layer->getParent() != prevCommonFather)
|
if (layer->getParent() != prevCommonFather)
|
||||||
return false;
|
return false;
|
||||||
auto newCommonFather = new FolderLayerWrapper();
|
//auto newCommonFather = new FolderLayerWrapper();
|
||||||
newCommonFather->setParent(static_cast<FolderLayerWrapper*>(prevCommonFather));
|
//newCommonFather->setParent(static_cast<FolderLayerWrapper*>(prevCommonFather));
|
||||||
for (auto &layer : selectedLayers)
|
//for (auto &layer : selectedLayers)
|
||||||
layer->setParent(newCommonFather);
|
// layer->setParent(newCommonFather);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool LayerManager::changeParent(FolderLayerWrapper *newParent) const
|
bool LayerManager::changeParent(FolderLayerWrapper *newParent) const
|
||||||
|
|
|
@ -59,6 +59,7 @@ FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *element
|
||||||
qDebug() << json.value("name").toString() << " " << this;
|
qDebug() << json.value("name").toString() << " " << this;
|
||||||
QJsonArray childrenJson = json.value("children").toArray();
|
QJsonArray childrenJson = json.value("children").toArray();
|
||||||
QJsonValue referencedJson = json.value("referenced-by");
|
QJsonValue referencedJson = json.value("referenced-by");
|
||||||
|
styles = new LayerStyleContainer(LayerStyleContainer::TYPE_ALL);
|
||||||
if (!referencedJson.isNull())
|
if (!referencedJson.isNull())
|
||||||
{
|
{
|
||||||
auto p = reinterpret_cast<GroupElement *>(elementManager->getElementById(referencedJson.toInt()));
|
auto p = reinterpret_cast<GroupElement *>(elementManager->getElementById(referencedJson.toInt()));
|
||||||
|
@ -79,11 +80,11 @@ FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *element
|
||||||
|
|
||||||
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager* elementManager, FolderLayerWrapper* parent)
|
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager* elementManager, FolderLayerWrapper* parent)
|
||||||
: LayerWrapper(json, parent, elementManager),
|
: LayerWrapper(json, parent, elementManager),
|
||||||
wrappedElement(elementManager->getElementById(json.value("element").toInt())),
|
wrappedElement(elementManager->getElementById(json.value("element").toInt()))
|
||||||
styles(LayerStyleContainer::fromJson(
|
|
||||||
wrappedElement->isClosed() ? LayerStyleContainer::TYPE_CLOSED : LayerStyleContainer::TYPE_UNCLOSED,
|
|
||||||
json.value("styles").toArray()))
|
|
||||||
{
|
{
|
||||||
|
styles = new LayerStyleContainer(LayerStyleContainer::fromJson(
|
||||||
|
wrappedElement->isClosed() ? LayerStyleContainer::TYPE_CLOSED : LayerStyleContainer::TYPE_UNCLOSED,
|
||||||
|
json.value("styles").toArray()));
|
||||||
qDebug() << json.value("name").toString() << " " << this;
|
qDebug() << json.value("name").toString() << " " << this;
|
||||||
if(wrappedElement != nullptr)
|
if(wrappedElement != nullptr)
|
||||||
wrappedElement->referencedCount++;
|
wrappedElement->referencedCount++;
|
||||||
|
@ -157,7 +158,7 @@ void LeafLayerWrapper::refresh(LayerWrapper* layer)
|
||||||
cache.clear();
|
cache.clear();
|
||||||
if (wrappedElement != nullptr)
|
if (wrappedElement != nullptr)
|
||||||
{
|
{
|
||||||
cache.addPath(wrappedElement->getPaintObject(this->styles));
|
cache.addPath(wrappedElement->getPaintObject(*this->styles));
|
||||||
}
|
}
|
||||||
LayerWrapper::refresh();
|
LayerWrapper::refresh();
|
||||||
}
|
}
|
||||||
|
@ -291,7 +292,7 @@ QJsonObject LeafLayerWrapper::toJson() const
|
||||||
QJsonObject json = LayerWrapper::toJson();
|
QJsonObject json = LayerWrapper::toJson();
|
||||||
json.insert("element", elementManager->getElementIndex(wrappedElement));
|
json.insert("element", elementManager->getElementIndex(wrappedElement));
|
||||||
json.insert("is-folder", false);
|
json.insert("is-folder", false);
|
||||||
json.insert("styles", styles.toJson());
|
json.insert("styles", styles->toJson());
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +304,7 @@ int FolderLayerWrapper::getReferencedBy()const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
void LayerWrapper::paint(QPainter* painter, QTransform transform, bool force, LayerStyleContainer styles)
|
||||||
{
|
{
|
||||||
// if (this->selected)
|
// if (this->selected)
|
||||||
// {
|
// {
|
||||||
|
@ -315,26 +316,24 @@ void LayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool force, LayerStyleContainer styles)
|
||||||
{
|
{
|
||||||
if (hidden && !force)
|
if (hidden && !force)
|
||||||
return;
|
return;
|
||||||
LayerWrapper::paint(painter, transform, force);
|
|
||||||
transform = property.transform * transform;
|
transform = property.transform * transform;
|
||||||
for (auto it = children.rbegin(); it != children.rend(); ++it)
|
for (auto it = children.rbegin(); it != children.rend(); ++it)
|
||||||
(*it)->paint(painter, transform, force);
|
(*it)->paint(painter, transform, force, styles | *this->styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool force, LayerStyleContainer styles)
|
||||||
{
|
{
|
||||||
if (hidden && !force)
|
if (hidden && !force)
|
||||||
return;
|
return;
|
||||||
LayerWrapper::paint(painter, transform, force);
|
|
||||||
transform = property.transform * transform;
|
transform = property.transform * transform;
|
||||||
//qDebug() << transform;
|
//qDebug() << transform;
|
||||||
if (wrappedElement != nullptr)
|
if (wrappedElement != nullptr)
|
||||||
{
|
{
|
||||||
wrappedElement->paint(painter, transform, styles);
|
wrappedElement->paint(painter, transform, styles | *this->styles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +453,8 @@ bool LeafLayerWrapper::referencingGroupElement() const
|
||||||
|
|
||||||
bool LayerWrapper::canApplyStyles() const
|
bool LayerWrapper::canApplyStyles() const
|
||||||
{
|
{
|
||||||
return typeid(*this) == typeid(LeafLayerWrapper) && !referencingGroupElement();
|
return true;
|
||||||
|
//return typeid(*this) == typeid(LeafLayerWrapper) && !referencingGroupElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerWrapper::paintVisualBounding(QPainter* painter) const
|
void LayerWrapper::paintVisualBounding(QPainter* painter) const
|
||||||
|
|
|
@ -39,6 +39,7 @@ class LayerWrapper
|
||||||
QTreeWidgetItem* qTreeWidgetItem;
|
QTreeWidgetItem* qTreeWidgetItem;
|
||||||
bool selected;
|
bool selected;
|
||||||
bool hidden;
|
bool hidden;
|
||||||
|
LayerStyleContainer* styles;
|
||||||
struct SimpleProperty
|
struct SimpleProperty
|
||||||
{
|
{
|
||||||
QString name = "";
|
QString name = "";
|
||||||
|
@ -61,7 +62,7 @@ class LayerWrapper
|
||||||
FolderLayerWrapper*getParent() const; // invoke by manager, then invoke parent's applyStyles
|
FolderLayerWrapper*getParent() const; // invoke by manager, then invoke parent's applyStyles
|
||||||
LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementManager* elementManager=nullptr);
|
LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementManager* elementManager=nullptr);
|
||||||
LayerWrapper() = default;
|
LayerWrapper() = default;
|
||||||
virtual void paint(QPainter* painter, QTransform transform=QTransform(), bool force = false);
|
virtual void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false, LayerStyleContainer styles = LayerStyleContainer(LayerStyleContainer::TYPE_ALL));
|
||||||
// TODO : export Function
|
// TODO : export Function
|
||||||
// virtual LayerWrapper *addChild() = 0; // Leaf Child Only
|
// virtual LayerWrapper *addChild() = 0; // Leaf Child Only
|
||||||
// virtual LayerWrapper *addParent() = 0; // Folder Parent Only
|
// virtual LayerWrapper *addParent() = 0; // Folder Parent Only
|
||||||
|
@ -102,7 +103,7 @@ class FolderLayerWrapper : public LayerWrapper
|
||||||
QTreeWidgetItem* getQTreeItem() override;
|
QTreeWidgetItem* getQTreeItem() override;
|
||||||
QJsonObject toJson() const override;
|
QJsonObject toJson() const override;
|
||||||
int getReferencedBy()const;
|
int getReferencedBy()const;
|
||||||
void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false) override;
|
void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false, LayerStyleContainer styles = LayerStyleContainer(LayerStyleContainer::TYPE_ALL)) override;
|
||||||
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
||||||
void refreshTreeItem() override;
|
void refreshTreeItem() override;
|
||||||
size_t referencedCount(bool excludeSelf = false) const override;
|
size_t referencedCount(bool excludeSelf = false) const override;
|
||||||
|
@ -114,14 +115,13 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GraphicElement *wrappedElement;
|
GraphicElement *wrappedElement;
|
||||||
LayerStyleContainer styles;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~LeafLayerWrapper();
|
~LeafLayerWrapper();
|
||||||
void refresh(LayerWrapper* layer = nullptr) override;
|
void refresh(LayerWrapper* layer = nullptr) override;
|
||||||
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
|
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
|
||||||
QJsonObject toJson() const override;
|
QJsonObject toJson() const override;
|
||||||
void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false) override;
|
void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false, LayerStyleContainer styles = LayerStyleContainer(LayerStyleContainer::TYPE_ALL)) override;
|
||||||
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
||||||
QTreeWidgetItem* getQTreeItem() override;
|
QTreeWidgetItem* getQTreeItem() override;
|
||||||
void refreshTreeItem() override;
|
void refreshTreeItem() override;
|
||||||
|
|
|
@ -102,7 +102,7 @@ void InfoDisplayWidget::refresh()
|
||||||
if (this->displayLayer->canApplyStyles())
|
if (this->displayLayer->canApplyStyles())
|
||||||
{
|
{
|
||||||
ui.styleList->setDisabled(false);
|
ui.styleList->setDisabled(false);
|
||||||
ui.styleList->setStyleContainer(&static_cast<LeafLayerWrapper*>(this->displayLayer)->styles);
|
ui.styleList->setStyleContainer(static_cast<LayerWrapper*>(this->displayLayer)->styles);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,7 +113,7 @@ void PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTransform transfo
|
||||||
QTransform transformInverted = leafTransform.inverted();
|
QTransform transformInverted = leafTransform.inverted();
|
||||||
|
|
||||||
//++zIndexCount;
|
//++zIndexCount;
|
||||||
auto baseStyles = leafLayer->styles.toBaseStyles();
|
auto baseStyles = leafLayer->styles->toBaseStyles();
|
||||||
qDebug() << baseStyles.size();
|
qDebug() << baseStyles.size();
|
||||||
for (auto& baseStyle : std::views::reverse(baseStyles)) {
|
for (auto& baseStyle : std::views::reverse(baseStyles)) {
|
||||||
double lineWidth = 0;
|
double lineWidth = 0;
|
||||||
|
|
Loading…
Reference in New Issue