diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
index c403fad..7414c08 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
@@ -202,6 +202,7 @@
+
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
index e198184..835a354 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
@@ -519,6 +519,9 @@
Header Files\Editor\Layer
+
+ Header Files
+
diff --git a/ArchitectureColoredPainting/EditorWidgetItem.ui b/ArchitectureColoredPainting/EditorWidgetItem.ui
index e269e9d..b8eb51c 100644
--- a/ArchitectureColoredPainting/EditorWidgetItem.ui
+++ b/ArchitectureColoredPainting/EditorWidgetItem.ui
@@ -180,6 +180,12 @@
+
+
+ 10
+ 10
+
+
图层名
@@ -190,6 +196,11 @@
关联图元
+
+
+ 可见
+
+
diff --git a/ArchitectureColoredPainting/res/Shaders/element.comp b/ArchitectureColoredPainting/res/Shaders/element.comp
index fd09af8..511c470 100644
--- a/ArchitectureColoredPainting/res/Shaders/element.comp
+++ b/ArchitectureColoredPainting/res/Shaders/element.comp
@@ -1093,6 +1093,7 @@ void main()
bool onVeryBegin = false;
bool onVeryEnd = false;
vec2 tangentEndLast;
+ vec2 tangentFirstBegin;
uint lastHitIndex = 0;
bool lastHitElement = false;
hitElement = false;
@@ -1108,7 +1109,19 @@ void main()
pBegin = path[++pathIndex];
p3Last = pBegin;
p2Last = pBegin;
- onVeryBegin = true;
+ if(endType == 4)
+ {
+ //onVeryBegin = false;
+ vec2 lastP1 = path[pathSize-3];
+ vec2 lastP2 = path[pathSize-2];
+ vec2 lastP3 = path[pathSize-1];
+ if (lastP3 != lastP2)
+ tangentEndLast = normalize(lastP3 - lastP2);
+ else
+ tangentEndLast = normalize(lastP3 - lastP1);
+ }
+ else
+ onVeryBegin = true;
continue;
}
mat4x2 p = mat4x2(p3Last, pTemp, path[++pathIndex], path[++pathIndex]);
@@ -1119,7 +1132,13 @@ void main()
vec2 pTemp = path[pathIndex + 1];
if (isinf(pTemp.x))
{
- onVeryEnd = true;
+ if(endType == 4)
+ {
+ //onVeryEnd = false;
+ tangentBeginNext = tangentFirstBegin;
+ }
+ else
+ onVeryEnd = true;
}
else
{
@@ -1180,6 +1199,8 @@ void main()
}
}
tangentEndLast = tangentEnd;
+ if(pathIndex == 0)
+ tangentFirstBegin = tangentBegin;
}
p3Last = p[3];
p2Last = p[2];
diff --git a/ArchitectureColoredPainting/src/ColorHelper.hpp b/ArchitectureColoredPainting/src/ColorHelper.hpp
new file mode 100644
index 0000000..f337382
--- /dev/null
+++ b/ArchitectureColoredPainting/src/ColorHelper.hpp
@@ -0,0 +1,49 @@
+#pragma once
+#include
+#include
+#include
+
+class ColorHelper
+{
+ QtMaterialTheme theme;
+ QColor primary1;
+public:
+
+ void setPrimary1(const QColor& color)
+ {
+ theme.setColor("primary1", color);
+ primary1 = color;
+ }
+
+ [[nodiscard]] QColor getPrimary1() const
+ {
+ return primary1;
+ }
+
+ ColorHelper()
+ {
+ setPrimary1(QColor::fromRgb(0, 90, 158));
+ QtMaterialStyle::instance().setTheme(&theme);
+ }
+
+ static ColorHelper& instance()
+ {
+ static ColorHelper instance;
+ return instance;
+ }
+
+ static QColor execColorDialog(
+ const QColor& initial = instance().getPrimary1(),
+ QWidget* parent = nullptr,
+ const QString& title = ""
+ ) {
+ auto dialog = QColorDialog(initial, parent);
+ if (!title.isEmpty())
+ {
+ dialog.setWindowTitle(title);
+ }
+ dialog.adjustSize();
+ dialog.exec();
+ return dialog.selectedColor();
+ }
+};
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.cpp
index 7010ae4..4ccb504 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.cpp
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.cpp
@@ -1,5 +1,6 @@
#include "ColorPicker.h"
#include
+#include
QString getStyleSheet(const QColor& color)
{
@@ -26,9 +27,8 @@ QColor ColorPicker::getColor() const
void ColorPicker::onClicked()
{
- QColorDialog dialog(this->color, this);
- dialog.exec();
- QColor newColor = dialog.selectedColor();
+ //const QColor newColor = QColorDialog::getColor(this->color, this);
+ const QColor newColor = ColorHelper::execColorDialog(this->color, this);
if (newColor.isValid() && this->color != newColor)
{
this->color = newColor;
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.h b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.h
index a8edd67..50c1c34 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.h
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/ColorPicker.h
@@ -1,4 +1,5 @@
#pragma once
+#include "../ColorHelper.hpp"
#include
class ColorPicker : public QPushButton
{
@@ -6,7 +7,7 @@ class ColorPicker : public QPushButton
private:
QColor color;
public:
- ColorPicker(const QColor& color = QColor::fromRgb(0, 0, 0), QWidget* parent = nullptr);
+ ColorPicker(const QColor& color = ColorHelper::instance().getPrimary1(), QWidget* parent = nullptr);
QColor getColor() const;
public slots:
void onClicked();
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/FillStyleWidget.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/FillStyleWidget.cpp
index bf78dbc..662ff47 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/FillStyleWidget.cpp
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/FillStyleWidget.cpp
@@ -4,7 +4,7 @@
#include
#include
-FillStyleWidget::FillStyleWidget(std::shared_ptr fill, QWidget* parent)
+FillStyleWidget::FillStyleWidget(std::shared_ptr fill, QWidget* parent)
: QWidget(parent), fill(fill)
{
auto* layout = new QGridLayout(this);
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/LayerStyleDialog.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/LayerStyleDialog.cpp
index 33a3568..40c2555 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/LayerStyleDialog.cpp
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/LayerStyleDialog.cpp
@@ -1,28 +1,25 @@
#include "LayerStyleDialog.h"
#include
#include
-#include
#include
LayerStyleDialog::LayerStyleDialog(
LayerStyleContainer& styles,
- std::shared_ptr existedStyle,
+ const std::shared_ptr& existedStyle,
QWidget* parent
) : QDialog(parent), styles(&styles)
{
- auto* dialogLayout = new QVBoxLayout(this);
+ dialogLayout = new QGridLayout;
dialogLayout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
this->setLayout(dialogLayout);
if (existedStyle)
{
this->modifyingStyle = existedStyle->clone();
-
- this->styleContainer = nullptr;
+
this->styleWidget = modifyingStyle->getInputWidget();
this->styleWidget->setParent(this);
- dialogLayout->addWidget(styleWidget);
- // do something
+ dialogLayout->addWidget(styleWidget, 1, 0);
}
else
{
@@ -34,13 +31,12 @@ LayerStyleDialog::LayerStyleDialog(
typeSelector->addItems(unusedStyleNames);
this->modifyingStyle = std::move(styles.makeUnusedStyle(unusedStyleNames[0]));
- dialogLayout->addWidget(typeSelector);
- this->styleContainer = new QGridLayout(this);
- dialogLayout->addLayout(styleContainer);
+ dialogLayout->addWidget(typeSelector, 0, 0);
+
this->styleWidget = this->modifyingStyle->getInputWidget();
this->styleWidget->setParent(this);
- this->styleContainer->addWidget(styleWidget);
+ this->dialogLayout->addWidget(styleWidget, 1, 0);
connect(typeSelector, &QComboBox::currentTextChanged,
this, &LayerStyleDialog::onStyleTypeSelectorChanged);
}
@@ -48,7 +44,8 @@ LayerStyleDialog::LayerStyleDialog(
auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
connect(buttonBox, &QDialogButtonBox::accepted, this, &LayerStyleDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &LayerStyleDialog::reject);
- dialogLayout->addWidget(buttonBox);
+ dialogLayout->addWidget(buttonBox, 2, 0);
+ this->adjustSize();
}
void LayerStyleDialog::accept()
@@ -61,14 +58,14 @@ void LayerStyleDialog::onStyleTypeSelectorChanged(const QString& current)
{
if (this->styleWidget)
{
- this->styleContainer->removeWidget(this->styleWidget);
+ this->dialogLayout->removeWidget(this->styleWidget);
this->styleWidget->setParent(nullptr);
delete styleWidget;
}
this->modifyingStyle = std::move(styles->makeUnusedStyle(current));
this->styleWidget = this->modifyingStyle->getInputWidget();
this->styleWidget->setParent(this);
- this->styleContainer->addWidget(styleWidget, 0, 0, 1, 1);
+ this->dialogLayout->addWidget(styleWidget, 1, 0);
this->styleWidget->adjustSize();
this->adjustSize();
}
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/LayerStyleDialog.h b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/LayerStyleDialog.h
index b703e80..485b58c 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/LayerStyleDialog.h
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/LayerStyleDialog.h
@@ -8,13 +8,13 @@ class LayerStyleDialog : public QDialog
Q_OBJECT
private:
QWidget* styleWidget;
- QGridLayout* styleContainer;
+ QGridLayout* dialogLayout;
LayerStyleContainer* styles;
std::unique_ptr modifyingStyle;
public:
LayerStyleDialog(
LayerStyleContainer& styles,
- std::shared_ptr existedStyle = nullptr,
+ const std::shared_ptr& existedStyle = nullptr,
QWidget* parent = nullptr
);
std::shared_ptr layerStyle;
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp
index e2c9ce7..7422763 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.cpp
@@ -1,8 +1,11 @@
#include "StrokeStyleWidget.h"
#include "ColorPicker.h"
+#include "../ColorHelper.hpp"
#include
#include
-#include
+#include
+#include
+#include
constexpr int COLUMN_WIDTH = 0;
constexpr int COLUMN_COLOR = 1;
@@ -10,11 +13,27 @@ constexpr int COLUMN_METALLIC = 2;
constexpr int COLUMN_ROUGHNESS = 3;
constexpr int COLUMN_OPERATIONS = 4;
+inline Renderer::Material newMaterial()
+{
+ return {ColorHelper::instance().getPrimary1()};
+}
+
+inline bool isClosedStroke(const std::shared_ptr& stroke)
+{
+ return stroke->endType == Renderer::StrokeEndType::kClosed;
+}
+
StrokeStyleWidget::StrokeStyleWidget(
- std::shared_ptr stroke,
+ const std::shared_ptr& stroke,
QWidget* parent
) : QWidget(parent), stroke(stroke)
{
+ auto& materialMap = radialStroke(stroke)->materialMap;
+ if (materialMap.empty())
+ {
+ materialMap[1.f] = newMaterial();
+ }
+
auto* viewLayout = new QVBoxLayout(this);
this->setLayout(viewLayout);
@@ -25,13 +44,20 @@ StrokeStyleWidget::StrokeStyleWidget(
strokeProperties->setLayout(strokePropertiesLayout);
strokePropertiesLayout->addWidget(enableGradual);
- strokePropertiesLayout->addWidget(endTypeBox);
+ if (!isClosedStroke(stroke))
+ {
+ strokePropertiesLayout->addWidget(endTypeBox);
+ }
viewLayout->addWidget(strokeProperties);
viewLayout->addWidget(widthField);
- initTable(std::dynamic_pointer_cast(stroke->materialStroke));
+ initTable(radialStroke(stroke));
viewLayout->addWidget(strokeTable);
+
+ initAddButton();
+ viewLayout->addWidget(addButton);
+
this->adjustSize();
}
@@ -44,30 +70,23 @@ void StrokeStyleWidget::initStrokeSettings()
radialStroke(this->stroke)->gradual = checked;
});
-#define endTypeBoxLabel(start, end) QStringLiteral(start##" -> "##end)
- this->endTypeBox = new QComboBox(this);
- endTypeBox->addItem(endTypeBoxLabel("Բͷ", "Բͷ")); // kRound
- endTypeBox->addItem(endTypeBoxLabel("ƽͷ", "Բͷ")); // kFlatRound
- endTypeBox->addItem(endTypeBoxLabel("Բͷ", "ƽͷ")); // kRoundFlat
- endTypeBox->addItem(endTypeBoxLabel("ƽͷ", "ƽͷ")); // kFlat
- endTypeBox->setCurrentIndex(static_cast(this->stroke->endType));
- connect(endTypeBox, QOverload::of(&QComboBox::currentIndexChanged), [this](int index) {
- switch (index)
+ if (!isClosedStroke(stroke))
+ {
+ this->endTypeBox = new QComboBox(this);
+ for (const auto& displayName : MaterialStyleStroke::strokeEndTypeNames | std::views::keys)
{
- case 0:
- this->stroke->endType = Renderer::StrokeEndType::kRound;
- break;
- case 1:
- this->stroke->endType = Renderer::StrokeEndType::kFlatRound;
- break;
- case 2:
- this->stroke->endType = Renderer::StrokeEndType::kRoundFlat;
- break;
- case 3:
- this->stroke->endType = Renderer::StrokeEndType::kFlat;
- break;
+ endTypeBox->addItem(displayName);
}
- });
+ endTypeBox->setCurrentIndex(static_cast(this->stroke->endType));
+ connect(endTypeBox, QOverload::of(&QComboBox::currentIndexChanged), [this](int index) {
+ const auto& [displayName, endType] = MaterialStyleStroke::strokeEndTypeNames[index];
+ this->stroke->endType = endType;
+ });
+ }
+ else
+ {
+ this->endTypeBox = nullptr;
+ }
this->widthField = new QtMaterialTextField(this);
widthField->setLabel(QStringLiteral("߿"));
@@ -83,13 +102,12 @@ void StrokeStyleWidget::initStrokeSettings()
});
}
-// TODO: ʱУ
-void StrokeStyleWidget::initTable(std::shared_ptr materialStroke)
+void StrokeStyleWidget::initTable(const std::shared_ptr& materialStroke)
{
this->strokeTable = new QTableWidget(this);
strokeTable->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
strokeTable->setColumnCount(5);
- strokeTable->setRowCount(materialStroke->materialMap.size() + 1);
+ strokeTable->setRowCount(materialStroke->materialMap.size());
QStringList headers;
headers << QStringLiteral("ľռ")
<< QStringLiteral("ɫ")
@@ -97,44 +115,45 @@ void StrokeStyleWidget::initTable(std::shared_ptrsetHorizontalHeaderLabels(headers);
+ strokeTable->setMinimumHeight(strokeTable->rowHeight(0) * 5);
+ strokeTable->setMinimumWidth(strokeTable->sizeHint().width());
int row = 0;
//
- for (auto & strokePair : materialStroke->materialMap)
+ for (auto& [width, material] : std::views::reverse(materialStroke->materialMap))
{
- setTableRow(row, strokePair.first, strokePair.second);
+ setTableRow(row, width, material);
row++;
}
- // ť
- QtMaterialRaisedButton* addButton = new QtMaterialRaisedButton("+", strokeTable);
- addButton->setBackgroundColor(QtMaterialStyle::instance().themeColor("primary1"));
- strokeTable->setSpan(row, 0, 1, 5);
- strokeTable->setCellWidget(row, 0, addButton);
- strokeTable->setMinimumHeight(strokeTable->rowHeight(row) * 5);
- strokeTable->setMinimumWidth(strokeTable->sizeHint().width());
- addButton->setFixedHeight(strokeTable->rowHeight(row));
- connect(addButton, &QtMaterialRaisedButton::clicked, [this]() {
+ connect(strokeTable, &QTableWidget::currentItemChanged, this, &StrokeStyleWidget::onCurrentItemChanged);
+ connect(strokeTable, &QTableWidget::cellChanged, this, &StrokeStyleWidget::onCellChanged);
+}
+
+void StrokeStyleWidget::initAddButton()
+{
+ this->addButton = new QtMaterialRaisedButton("+", strokeTable);
+ addButton->setFixedHeight(this->strokeTable->rowHeight(0));
+ addButton->setBackgroundColor(ColorHelper::instance().getPrimary1());
+ connect(addButton, &QtMaterialRaisedButton::clicked, [this] {
handlingRowInsert = true;
- auto materialMap = &(radialStroke(this->stroke)->materialMap);
- float newWidth = 0;
- if (materialMap->size() == 0)
+ auto& materialMap = radialStroke(this->stroke)->materialMap;
+ float newWidth;
+ if (materialMap.empty())
{
- newWidth = 0.1;
+ newWidth = 1.f;
}
else
{
- auto lastPair = materialMap->rbegin();
- newWidth = lastPair->first + 0.01;
+ const auto firstPair = materialMap.begin();
+ newWidth = firstPair->first / 2;
}
- Renderer::Material newMaterial(QColor::fromRgb(0, 0, 0));
- (*materialMap)[newWidth] = newMaterial;
- int newRow = this->strokeTable->rowCount() - 1;
+ const Renderer::Material newMaterial(ColorHelper::instance().getPrimary1());
+ materialMap[newWidth] = newMaterial;
+ const int newRow = this->strokeTable->rowCount();
this->strokeTable->insertRow(newRow);
- setTableRow(newRow, newWidth, (*materialMap)[newWidth]);
+ setTableRow(newRow, newWidth, materialMap[newWidth]);
this->strokeTable->update();
handlingRowInsert = false;
});
- connect(strokeTable, &QTableWidget::currentItemChanged, this, &StrokeStyleWidget::onCurrentItemChanged);
- connect(strokeTable, &QTableWidget::cellChanged, this, &StrokeStyleWidget::onCellChanged);
}
void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& material)
@@ -143,14 +162,14 @@ void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& ma
widthItem->setData(Qt::EditRole, width);
strokeTable->setItem(row, COLUMN_WIDTH, widthItem);
- QColor* colorPtr = &(material.color);
+ QColor* colorPtr = &material.color;
auto* colorItem = new QTableWidgetItem;
colorItem->setData(Qt::DisplayRole, *colorPtr);
strokeTable->setItem(row, COLUMN_COLOR, colorItem);
auto* colorPicker = new ColorPicker(*colorPtr, strokeTable);
strokeTable->setCellWidget(row, COLUMN_COLOR, colorPicker);
connect(colorPicker, &ColorPicker::colorChanged, [this, colorPtr](QColor color) {
- *colorPtr = color;
+ *colorPtr = std::move(color);
this->strokeTable->update();
});
@@ -163,10 +182,10 @@ void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& ma
strokeTable->setItem(row, COLUMN_ROUGHNESS, roughnessItem);
auto* removeButton = new QtMaterialRaisedButton("-", strokeTable);
- removeButton->setBackgroundColor(QtMaterialStyle::instance().themeColor("primary1"));
+ removeButton->setBackgroundColor(ColorHelper::instance().getPrimary1());
removeButton->setFixedSize(20, 20);
strokeTable->setCellWidget(row, COLUMN_OPERATIONS, removeButton);
- connect(removeButton, &QtMaterialRaisedButton::clicked, [this, row]() {
+ connect(removeButton, &QtMaterialRaisedButton::clicked, [this, row] {
radialStroke(this->stroke)->materialMap.erase(this->strokeTable->item(row, COLUMN_WIDTH)->text().toFloat());
this->strokeTable->removeRow(row);
});
@@ -175,7 +194,7 @@ void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& ma
void StrokeStyleWidget::onCurrentItemChanged(QTableWidgetItem* current, QTableWidgetItem* previous)
{
if (!current) return;
- int column = current->column();
+ const int column = current->column();
if (column != COLUMN_COLOR && column != COLUMN_OPERATIONS)
{
this->currentItemValue = current->data(Qt::EditRole);
@@ -185,23 +204,27 @@ void StrokeStyleWidget::onCurrentItemChanged(QTableWidgetItem* current, QTableWi
void StrokeStyleWidget::onCellChanged(int row, int column)
{
if (handlingRowInsert) return;
- auto changedItem = strokeTable->item(row, column);
- auto changedItemValue = changedItem->text().toFloat();
+ const auto changedItem = strokeTable->item(row, column);
+ const auto changedItemValue = changedItem->text().toFloat();
if (changedItemValue < 0 || 1 < changedItemValue)
{
changedItem->setData(Qt::EditRole, this->currentItemValue.toFloat());
return;
}
- auto changedWidth = strokeTable->item(row, COLUMN_WIDTH)->data(Qt::EditRole).toFloat();
+ const auto changedWidth = strokeTable->item(row, COLUMN_WIDTH)->data(Qt::EditRole).toFloat();
switch (column)
{
case COLUMN_WIDTH:
{
float oldWidth = this->currentItemValue.toFloat();
auto node = radialStroke(stroke)->materialMap.extract(oldWidth);
+ if (node.empty())
+ {
+ break;
+ }
node.key() = changedWidth;
radialStroke(stroke)->materialMap.insert(std::move(node));
- strokeTable->sortItems(COLUMN_WIDTH);
+ strokeTable->sortItems(COLUMN_WIDTH, Qt::DescendingOrder);
break;
}
case COLUMN_METALLIC:
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.h b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.h
index 6d5dbdd..c4d1bfc 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.h
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetComponent/StrokeStyleWidget.h
@@ -6,6 +6,7 @@
#include
#include
#include
+#include
class StrokeStyleWidget : public QWidget
{
Q_OBJECT
@@ -16,15 +17,17 @@ private:
QComboBox* endTypeBox;
QtMaterialTextField* widthField;
QTableWidget* strokeTable;
+ QtMaterialRaisedButton* addButton;
bool handlingRowInsert = false;
void initStrokeSettings();
- void initTable(std::shared_ptr materialStroke);
+ void initTable(const std::shared_ptr& materialStroke);
+ void initAddButton();
void setTableRow(int row, float width, Renderer::Material& material);
public:
- StrokeStyleWidget(std::shared_ptr stroke, QWidget* parent = nullptr);
- std::shared_ptr stroke;
+ StrokeStyleWidget(const std::shared_ptr& stroke, QWidget* parent = nullptr);
+ std::shared_ptr stroke;
protected slots:
void onCurrentItemChanged(QTableWidgetItem* current, QTableWidgetItem* previous);
diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidgetItem.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidgetItem.cpp
index eb5f228..2693b45 100644
--- a/ArchitectureColoredPainting/src/Editor/EditorWidgetItem.cpp
+++ b/ArchitectureColoredPainting/src/Editor/EditorWidgetItem.cpp
@@ -25,6 +25,7 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
treeWidget->refresh();
previewWindow->refresh();
};
+ connect(previewWindow, &PreviewWindow::triggerCentralRefresh, centralRefresh);
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
connect(treeWidget, &LayerTreeWidget::triggerCentralRefresh, centralRefresh);
@@ -33,15 +34,15 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
connect(previewWindow, &PreviewWindow::layerInfoChanged, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
- connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
- connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
+ //connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
+ // connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
- connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
- &EditorWidgetItem::triggerRefreshPreview);
- connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
- &EditorWidgetItem::triggerRefreshPreview);
- connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireSelfRefresh, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
- connect(elementInfoDisplayWidget, &ElementPoolWidget::refreshLayerTree, treeWidget, &LayerTreeWidget::refresh);
+ // connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
+ // &EditorWidgetItem::triggerRefreshPreview);
+ // connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
+ // &EditorWidgetItem::triggerRefreshPreview);
+ //connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireSelfRefresh, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
+ // connect(elementInfoDisplayWidget, &ElementPoolWidget::refreshLayerTree, treeWidget, &LayerTreeWidget::refresh);
// &EditorWidget::triggerRefreshPreview);
// test
QFile settingFile;
@@ -73,9 +74,10 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
this->projectName = source.value("project-name").toString();
qDebug() << this->backgroundColor;
qDebug() << this->projectName;
- QTimer::singleShot(300, this, [this]() {
+ QTimer::singleShot(300, this, [this, centralRefresh]() {
handleBackgroundColorChange(this->backgroundColor);
handleProjectNameChange(this->projectName);
+ centralRefresh();
});
}
diff --git a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp
index 4cc2ef3..01f6df5 100644
--- a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp
+++ b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp
@@ -127,7 +127,7 @@ bool SimpleElement::isClosed() const
void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
{
- sourceLayer->paint(painter, transform);
+ sourceLayer->paint(painter, transform, true);
}
bool GroupElement::isClosed() const
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/LayerStyle.cpp b/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp
index 2e13f68..0eb7864 100644
--- a/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp
+++ b/ArchitectureColoredPainting/src/Editor/LayerStyle.cpp
@@ -2,6 +2,7 @@
#include "./EditorWidgetComponent/StrokeStyleWidget.h"
#include "./EditorWidgetComponent/FillStyleWidget.h"
#include "./util/EncodeUtil.hpp"
+#include "../ColorHelper.hpp"
#include
#include
#include
@@ -77,7 +78,7 @@ QWidget* StrokeElementLayerStyle::getListDisplayWidget() const
void LayerStyleContainer::computeNewHash()
{
hash = 0;
- for (auto& f : styles
+ for (auto& f : styles
| std::views::values
| std::views::transform(&LayerStyle::toBaseStyles)
| std::views::join
@@ -206,11 +207,11 @@ bool LayerStyleContainer::dropStyle(const QString& styleName)
float LayerStyleContainer::boundingBoxAffectValue() const {
float maxLineWidth = 0;
- const auto strokeStyle = styles.at(StrokeElementLayerStyle::displayName());
- if (strokeStyle != nullptr)
+ const auto strokeStyle = styles.find(StrokeElementLayerStyle::displayName());
+ if (strokeStyle != styles.end())
{
if (const auto strokeElementLayerStyle =
- std::dynamic_pointer_cast(strokeStyle);
+ std::dynamic_pointer_cast(strokeStyle->second);
strokeElementLayerStyle != nullptr)
{
const auto& leftStyleStroke = strokeElementLayerStyle->strokePair.first;
@@ -247,18 +248,18 @@ std::unique_ptr StrokeElementLayerStyle::fromJson(const
return ptr;
}
-StrokeElementLayerStyle::StrokeElementLayerStyle()
+StrokeElementLayerStyle::StrokeElementLayerStyle(bool isClosed)
{
const auto materialMap = std::map();
this->strokePair.first = std::make_shared(
7,
- Renderer::StrokeType::kLeftSide, Renderer::StrokeEndType::kFlat,
+ Renderer::StrokeType::kLeftSide, isClosed ? Renderer::StrokeEndType::kClosed : Renderer::StrokeEndType::kFlat,
std::make_shared(materialMap, false)
);
this->strokePair.second = std::make_shared(
7,
- Renderer::StrokeType::kRightSide, Renderer::StrokeEndType::kFlat,
+ Renderer::StrokeType::kRightSide, isClosed ? Renderer::StrokeEndType::kClosed : Renderer::StrokeEndType::kFlat,
std::make_shared(materialMap, false)
);
@@ -536,7 +537,7 @@ FillElementLayerStyle::FillElementLayerStyle(const PMaterialStyleFill& fillMater
if (!fillMaterialStyle)
{
this->fillMaterialStyle = std::make_shared(
- std::make_shared(Renderer::Material(QColor::fromRgb(0, 0, 0)))
+ std::make_shared(ColorHelper::instance().getPrimary1())
);
}
}
diff --git a/ArchitectureColoredPainting/src/Editor/LayerStyle.h b/ArchitectureColoredPainting/src/Editor/LayerStyle.h
index 9274732..3eba1ad 100644
--- a/ArchitectureColoredPainting/src/Editor/LayerStyle.h
+++ b/ArchitectureColoredPainting/src/Editor/LayerStyle.h
@@ -46,7 +46,7 @@ public:
STYLE_NAME("", "stroke")
static std::unique_ptr fromJson(const QJsonObject& json);
- StrokeElementLayerStyle();
+ StrokeElementLayerStyle(bool isClosed);
StrokeElementLayerStyle(const PMaterialStyleStroke& left, const PMaterialStyleStroke& right = nullptr);
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
~StrokeElementLayerStyle() override = default;
@@ -88,17 +88,23 @@ public:
class LayerStyleContainer : public Renderer::ElementStyle
{
using DisplayNameWithSupplier = std::map()>>;
-private:
- inline const static DisplayNameWithSupplier commonStyles = { {
+private:
+ inline const static DisplayNameWithSupplier commonStyles = { };
+ inline const static DisplayNameWithSupplier closedOnlyStyles = {
+ {
+ FillElementLayerStyle::displayName(),
+ [] { return std::make_unique(); }
+ },
+ {
+ StrokeElementLayerStyle::displayName(),
+ [] { return std::make_unique(true); }
+ }
+ };
+ inline const static DisplayNameWithSupplier unclosedOnlyStyles = { {
StrokeElementLayerStyle::displayName(),
- [] { return std::make_unique(); }
+ [] { return std::make_unique(false); }
} };
- inline const static DisplayNameWithSupplier closedOnlyStyles = { {
- FillElementLayerStyle::displayName(),
- [] { return std::make_unique(); }
- } };
- inline const static DisplayNameWithSupplier unclosedOnlyStyles = { };
DisplayNameWithSupplier unusedStyles;
DisplayNameWithSupplier usedStyles;
diff --git a/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp
index bf0222b..d2f1453 100644
--- a/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp
+++ b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp
@@ -47,6 +47,7 @@ LayerWrapper::LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementM
transformJson.value("scale").toObject().value("y").toDouble()};
property.rotation = {transformJson.value("rotation").toDouble()};
selected = false;
+ hidden = false;
}
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent)
@@ -199,6 +200,7 @@ void FolderLayerWrapper::delSelf() {
QTreeWidgetItem* LayerWrapper::getQTreeItem()
{
this->qTreeWidgetItem->setData(0, Qt::UserRole, QVariant::fromValue(this));
+ this->qTreeWidgetItem->setCheckState(0, Qt::Checked);
return this->qTreeWidgetItem;
}
@@ -280,31 +282,34 @@ int FolderLayerWrapper::getReferencedBy()const
return -1;
}
-void LayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
+void LayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
{
- if (!ignoreSelected && this->selected)
- {
- painter->save();
- painter->setTransform(transform, ignoreSelected);
- painter->setPen(QPen(Qt::gray, 2));
- painter->setPen(Qt::DashLine);
- painter->drawRect(cache.getBoundingRect());
- painter->restore();
- }
+ // 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 ignoreSelected)
+void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
{
- LayerWrapper::paint(painter, transform, ignoreSelected);
+ if (hidden && !force)
+ return;
+ LayerWrapper::paint(painter, transform, force);
transform = property.transform * transform;
//qDebug() << transform;
for (auto& child : children)
- child->paint(painter, transform, ignoreSelected);
+ child->paint(painter, transform, force);
}
-void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
+void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
{
- LayerWrapper::paint(painter, transform, ignoreSelected);
+ if (hidden && !force)
+ return;
+ LayerWrapper::paint(painter, transform, force);
transform = property.transform * transform;
//qDebug() << transform;
if (wrappedElement != nullptr)
@@ -347,11 +352,12 @@ void FolderLayerWrapper::collectDownReachable(std::set& reachable
void LayerWrapper::refreshTreeItem()
{
-
+ hidden = qTreeWidgetItem->checkState(0) == Qt::Unchecked;
}
void LeafLayerWrapper::refreshTreeItem()
{
+ LayerWrapper::refreshTreeItem();
if (typeid(*wrappedElement) == typeid(GroupElement))
{
this->qTreeWidgetItem->setText(0, "@ " + this->property.name);
@@ -366,6 +372,7 @@ void LeafLayerWrapper::refreshTreeItem()
void FolderLayerWrapper::refreshTreeItem()
{
+ LayerWrapper::refreshTreeItem();
for (auto& child : this->children) {
child->refreshTreeItem();
}
@@ -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 947d90c..c45ec21 100644
--- a/ArchitectureColoredPainting/src/Editor/LayerWrapper.h
+++ b/ArchitectureColoredPainting/src/Editor/LayerWrapper.h
@@ -37,6 +37,7 @@ class LayerWrapper
public:
QTreeWidgetItem* qTreeWidgetItem;
bool selected;
+ bool hidden;
struct SimpleProperty
{
QString name = "";
@@ -58,7 +59,7 @@ class LayerWrapper
FolderLayerWrapper*getParent() const; // invoke by manager, then invoke parent's applyStyles
LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementManager* elementManager=nullptr);
LayerWrapper() = default;
- virtual void paint(QPainter* painter, QTransform transform=QTransform(), bool ignoreSelected = false);
+ virtual void paint(QPainter* painter, QTransform transform=QTransform(), bool force = false);
// TODO : export Function
// virtual LayerWrapper *addChild() = 0; // Leaf Child Only
// virtual LayerWrapper *addParent() = 0; // Folder Parent Only
@@ -74,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;
};
@@ -97,7 +99,7 @@ class FolderLayerWrapper : public LayerWrapper
QTreeWidgetItem* getQTreeItem() override;
QJsonObject toJson() const override;
int getReferencedBy()const;
- void paint(QPainter* painter, QTransform transform = QTransform(), bool ignoreSelected = false) override;
+ void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false) override;
void collectDownReachable(std::set& reachable) override;
void refreshTreeItem() override;
size_t referencedCount(bool excludeSelf = false) const override;
@@ -115,7 +117,7 @@ class LeafLayerWrapper : public LayerWrapper
void refresh(LayerWrapper* layer = nullptr) override;
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
QJsonObject toJson() const override;
- void paint(QPainter* painter, QTransform transform = QTransform(), bool ignoreSelected = false) override;
+ void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false) override;
void collectDownReachable(std::set& reachable) override;
QTreeWidgetItem* getQTreeItem() override;
void refreshTreeItem() override;
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;
}
diff --git a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp
index c4a03b5..410b8af 100644
--- a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp
+++ b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp
@@ -1,4 +1,5 @@
#include "PreviewWindow.h"
+#include
PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
{
@@ -84,7 +85,17 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
int dx = event->x() - m_lastPos.x();
int dy = event->y() - m_lastPos.y();
if (currentLayer != nullptr) {
- if (event->buttons() & Qt::LeftButton) {
+ if (QApplication::keyboardModifiers() == Qt::ControlModifier && (event->buttons() & Qt::LeftButton))
+ {
+ currentLayer->property.scale.setX(std::max(0.0, currentLayer->property.scale.x() + dx / 50.0));
+ currentLayer->property.scale.setY(std::max(0.0, currentLayer->property.scale.y() + dy / 50.0));
+ }
+ else if (QApplication::keyboardModifiers() == (Qt::ControlModifier | Qt::ShiftModifier) && (event->buttons() & Qt::LeftButton))
+ {
+ currentLayer->property.scale.setX(std::max(0.0, currentLayer->property.scale.x() * (1.0 + dx / 50.0)));
+ currentLayer->property.scale.setY(std::max(0.0, currentLayer->property.scale.y() * (1.0 + dx / 50.0)));
+ }
+ else if (event->buttons() & Qt::LeftButton) {
// µôƽͼ
currentLayer->property.offset.setX(currentLayer->property.offset.x() + dx);
currentLayer->property.offset.setY(currentLayer->property.offset.y() + dy);
@@ -100,19 +111,18 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
auto index = -1;
if (typeid(*layer) == typeid(FolderLayerWrapper))
index = dynamic_cast(layer)->getReferencedBy();
- if (index != -1)
- emit refreshElementPreviewByIndex(index);
layer = layer->getParent();
}
}
// һελ
+ emit triggerCentralRefresh();
m_lastPos = event->pos();
this->repaint();
}
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
{
- emit layerInfoChanged();
+ //emit layerInfoChanged();
}
void PreviewWindow::setBackgroundColor(QColor color)
diff --git a/ArchitectureColoredPainting/src/Editor/PreviewWindow.h b/ArchitectureColoredPainting/src/Editor/PreviewWindow.h
index 9f9d07c..4fd002d 100644
--- a/ArchitectureColoredPainting/src/Editor/PreviewWindow.h
+++ b/ArchitectureColoredPainting/src/Editor/PreviewWindow.h
@@ -46,4 +46,5 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
void layerInfoChanged();
void refreshElementPreview(GraphicElement*);
void refreshElementPreviewByIndex(int);
+ void triggerCentralRefresh();
};
diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/EditorSettingWidget.cpp b/ArchitectureColoredPainting/src/Editor/RightBar/EditorSettingWidget.cpp
index 2f54a22..979af0b 100644
--- a/ArchitectureColoredPainting/src/Editor/RightBar/EditorSettingWidget.cpp
+++ b/ArchitectureColoredPainting/src/Editor/RightBar/EditorSettingWidget.cpp
@@ -1,6 +1,6 @@
#include "EditorSettingWidget.h"
+#include "../ColorHelper.hpp"
#include
-#include
#include
EditorSettingWidget::EditorSettingWidget(QWidget* parent)
@@ -8,7 +8,7 @@ EditorSettingWidget::EditorSettingWidget(QWidget* parent)
{
ui.setupUi(this);
connect(ui.backgroundColorButton, &QPushButton::clicked, this, [this]() {
- QColor color = QColorDialog::getColor(Qt::white, this, QString::fromLocal8Bit("ѡɫ"));
+ QColor color = ColorHelper::execColorDialog(Qt::white, this, QString::fromLocal8Bit("ѡɫ"));
if (color.isValid())
{
emit backgroundColorChanged(color);
diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp
index 6869729..56e46b4 100644
--- a/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp
+++ b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp
@@ -21,12 +21,11 @@ void InfoDisplayWidget::generateLayerForm()
{
while (this->layout()->count() > 0 && (item = this->layout()->takeAt(0)) != nullptr)
{
- delete item->widget();
- delete item;
+ item->widget()->deleteLater();
+ delete item;
}
delete this->layout();
}
-
QFormLayout *layout = new QFormLayout();
layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
if (this->displayLayer == nullptr)
diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp b/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp
index a8ba44e..5090342 100644
--- a/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp
+++ b/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp
@@ -2,6 +2,7 @@
#include
#include
#include "./EditorWidgetComponent/LayerCreateWidget.h"
+#include
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
{
@@ -26,6 +27,10 @@ LayerTreeWidget::LayerTreeWidget(QWidget *parent)
}
emit triggerCentralRefresh();
});
+ connect(this, &QTreeWidget::itemChanged, this, [=]() {
+ emit triggerCentralRefresh();
+ });
+
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
}
diff --git a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp
index 39daca5..318f14a 100644
--- a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp
+++ b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp
@@ -5,7 +5,7 @@
#include
using Renderer::Painting;
-using Renderer::Element;
+using Renderer::BaseElement;
using Renderer::ElementTransform;
using Renderer::BaseElement;
using glm::bvec2;
@@ -18,231 +18,119 @@ using std::queue;
const double PaintingUtil::pi = acos(-1);
struct LayerNode {
- LayerWrapper* nowLayer;
- QTransform transfrom;
+ LayerWrapper* nowLayer;
+ QTransform transfrom;
};
QJsonObject PaintingUtil::readJsonFile(QString jsonFilePath) {
- QFile jsonFile(jsonFilePath);
- jsonFile.open(QFile::ReadOnly);
- QByteArray fileContent = jsonFile.readAll().trimmed();
- jsonFile.close();
- QJsonParseError jError;
- QJsonDocument jsonDoc(QJsonDocument::fromJson(fileContent, &jError));
- return jsonDoc.object();
+ QFile jsonFile(jsonFilePath);
+ qDebug() << jsonFilePath;
+ jsonFile.open(QFile::ReadOnly);
+ QByteArray fileContent = jsonFile.readAll().trimmed();
+ jsonFile.close();
+ QJsonParseError jError;
+ QJsonDocument jsonDoc(QJsonDocument::fromJson(fileContent, &jError));
+ return jsonDoc.object();
}
Painting PaintingUtil::transfromToPainting(QString jsonFilePath) {
- Painting painting;
- glm::bvec2 flip(0, 0);
- QJsonObject jsonObj = readJsonFile(jsonFilePath);
- qDebug() << jsonObj;
- shared_ptr elementManager = make_shared(jsonObj, Renderer::ElementRenderer::instance());
- shared_ptr layerManager = make_shared(jsonObj, elementManager.get());
- //qDebug() << elementManager->toJson();
- //qDebug() << layerManager->toJson();
+ Painting painting;
+ glm::bvec2 flip(0, 0);
+ QJsonObject jsonObj = readJsonFile(jsonFilePath);
+ qDebug() << jsonObj;
+ shared_ptr elementManager = make_shared(jsonObj, Renderer::ElementRenderer::instance());
+ shared_ptr layerManager = make_shared(jsonObj, elementManager.get());
+ //qDebug() << elementManager->toJson();
+ //qDebug() << layerManager->toJson();
//qDebug() << ((SimpleElement*)((LeafLayerWrapper*)((FolderLayerWrapper*)((FolderLayerWrapper*)layerManager->getRoot())->children[0].get())->children[0].get())->wrappedElement)->painterPath;
- //qDebug() << ((LeafLayerWrapper*)((FolderLayerWrapper*)((FolderLayerWrapper*)layerManager->getRoot())->children[0].get())->children[0].get())->getCache().painterPath;
- queue layerQueue;
- LayerWrapper* root = layerManager->getRoot();
- root->getCache();
- double maxLineWidth = getMaxLineWidth(root);
- layerQueue.push({ root, root->property.transform });
- while (!layerQueue.empty()) {
- auto layerNode = layerQueue.front();
- layerQueue.pop();
- FolderLayerWrapper* nowLayer = handleLayerWrapper(layerNode.nowLayer, maxLineWidth, layerNode.transfrom, painting);
- if (nowLayer != nullptr) {
- for (auto sonLayer : nowLayer->children) {
- layerQueue.push({ sonLayer.get(), layerNode.transfrom});
- }
- }
- }
-
- return painting;
+ //qDebug() << ((LeafLayerWrapper*)((FolderLayerWrapper*)((FolderLayerWrapper*)layerManager->getRoot())->children[0].get())->children[0].get())->getCache().painterPath;
+ //qDebug() << elementManager->toJson();
+ //qDebug() << layerManager->toJson();
+ //qDebug() << ((SimpleElement*)((LeafLayerWrapper*)((FolderLayerWrapper*)((FolderLayerWrapper*)layerManager->getRoot())->children[0].get())->children[0].get())->wrappedElement)->painterPath;
+ //qDebug() << ((LeafLayerWrapper*)((FolderLayerWrapper*)((FolderLayerWrapper*)layerManager->getRoot())->children[0].get())->children[0].get())->getCache().painterPath;
+ queue layerQueue;
+ LayerWrapper* root = layerManager->getRoot();
+ root->getCache();
+ //double maxLineWidth = getMaxLineWidth(root);
+ layerQueue.push({ root, root->property.transform });
+ while (!layerQueue.empty()) {
+ auto layerNode = layerQueue.front();
+ layerQueue.pop();
+ FolderLayerWrapper* nowLayer = handleLayerWrapper(layerNode.nowLayer, layerNode.transfrom, painting);
+ if (nowLayer != nullptr) {
+ for (auto sonLayer : nowLayer->children) {
+ layerQueue.push({ sonLayer.get(), layerNode.transfrom });
+ }
+ }
+ }
+
+ return painting;
}
-FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, double& maxLineWidth, QTransform& transform, Painting& painting) {
- LeafLayerWrapper* leafLayer = dynamic_cast(nowLayer);
+FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTransform& transform, Painting& painting) {
+ LeafLayerWrapper* leafLayer = dynamic_cast(nowLayer);
- transform = nowLayer->property.transform * transform;
+ transform = nowLayer->property.transform * transform;
- if (leafLayer != nullptr) {
+ if (leafLayer != nullptr) {
- GroupElement* wrapperElement = dynamic_cast(leafLayer->wrappedElement);
- if (wrapperElement != nullptr) {
- transform = wrapperElement->sourceLayer->property.transform * transform;
- return wrapperElement->sourceLayer;
- }
+ GroupElement* wrapperElement = dynamic_cast(leafLayer->wrappedElement);
+ if (wrapperElement != nullptr) {
+ transform = wrapperElement->sourceLayer->property.transform * transform;
+ return wrapperElement->sourceLayer;
+ }
- PixelPath pixelPath = nowLayer->getCache();
- QPainterPath painterPath = pixelPath.getPainterPath();
- QRectF bound = painterPath.boundingRect();
- //qDebug() << leafLayer<<"------" << painterPath;
- //qDebug() << transform;
- //Element element;
- //ElementTransform elementTrans;
- //element.ratio = bound.width() / bound.height();
- // transform to initial painterPath
- // transfrom to -1 1
- QTransform trans;
- trans.translate(-centerX, -centerY)
- .scale(1 / nowLayer->property.scale.x(), 1 / nowLayer->property.scale.y())
- .rotate(-nowLayer->property.rotation)
- .translate(centerX, centerY)
- .translate(-nowLayer->property.offset.x(), -nowLayer->property.offset.y());
- QPainterPath painterPath = trans.map(pixelPath.getPainterPath());
- // transfrom to -1 1
- QTransform trans;
- double maxLen = std::max(bound.width(), bound.height()) + maxLineWidth * 2;
- qDebug() << maxLen << bound;
- trans.scale(1 / maxLen, 1 / maxLen);
- trans.translate(-bound.center().x(), -bound.center().y());
-
- qDebug() << trans.map(painterPath);
- shared_ptr >> contour = std::make_shared >>(PainterPathUtil::transformToLines(trans.map(painterPath)));
- QSize screenSize = QSize(1024, 1024);
- //element.style = std::make_shared(0.06);
-
-
- painterPath = transform.map(painterPath);
- qDebug() << painterPath;
- bound = painterPath.boundingRect();
+ PixelPath pixelPath = nowLayer->getCache();
+ QPainterPath painterPath = pixelPath.getPainterPath();
+ QRectF bound = painterPath.boundingRect();
+ //qDebug() << leafLayer<<"------" << painterPath;
+ // transform to -1 1
+ QTransform trans;
+ double maxLen = std::max(bound.width(), bound.height());
+ qDebug() << maxLen << bound;
+ trans.scale(1 / maxLen, 1 / maxLen);
+ trans.translate(-bound.center().x(), -bound.center().y());
- ElementTransform elementTransform;
- transform = transform * trans;
- //elementTransform.bound = glm::vec4(-1, -1, 1, 1);
- elementTransform.bound = glm::vec4(
- 2 * (bound.x() - maxLineWidth) / screenSize.width() - 1,
- 2 * (bound.y() - maxLineWidth) / screenSize.height() - 1,
- 2 * (bound.x() + bound.width() + maxLineWidth) / screenSize.width() - 1,
- 2 * (bound.y() + bound.height() + maxLineWidth) / screenSize.height() - 1
- );
- qDebug() << elementTransform.bound.x << elementTransform.bound.y << elementTransform.bound.z << elementTransform.bound.z;
- transform = transform.inverted();
- elementTransform.transform = glm::mat3x2(
- transform.m11(), transform.m12(), transform.m21(),
- transform.m22(), transform.m31(), transform.m32()
- );
- qDebug() << transform;
- elementTransform.zIndex = 0;
+ painterPath = trans.map(painterPath);
+ shared_ptr >> contour = std::make_shared >>(PainterPathUtil::transformToLines(painterPath));
+ QSize screenSize = QSize(1024, 1024);
- auto baseStyles = leafLayer->styles.toBaseStyles();
- BaseElement element; element.contour = contour;
- for (auto baseStyle : baseStyles) {
- if (baseStyle.material->type() == Renderer::MaterialStyleType::kStroke) {
- auto material = dynamic_cast(baseStyle.material.get());
- material->halfWidth = material->halfWidth / maxLen;
- qDebug() << material->halfWidth;
- }
- element.style = baseStyle.material;
- painting.addElement(element, elementTransform);
- }
+ ElementTransform elementTransform;
+ transform = trans.inverted() * transform * QTransform::fromScale(2. / screenSize.width(), 2. / screenSize.height()) * QTransform::fromTranslate(-1, -1) * QTransform::fromScale(1, -1);
- //qDebug() << bound;
+ auto baseStyles = leafLayer->styles.toBaseStyles();
+ Renderer::BaseElement element;
+ element.contour = contour;
+ for (auto& baseStyle : baseStyles) {
+ double lineWidth = 0;
+ if (baseStyle.material->type() == Renderer::MaterialStyleType::kStroke) {
+ auto material = std::static_pointer_cast(baseStyle.material);
+ material->halfWidth /= maxLen;
+ lineWidth = material->halfWidth;
+ qDebug() << material->halfWidth;
+ }
+ QPainterPathStroker stroker;
+ stroker.setWidth(lineWidth);
+ stroker.setCapStyle(Qt::RoundCap);
+ QPainterPath strokePath = stroker.createStroke(painterPath);
+ auto rect = transform.map(strokePath).boundingRect();
+ elementTransform.bound = glm::vec4(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
+ qDebug() << elementTransform.bound.x << elementTransform.bound.y << elementTransform.bound.z << elementTransform.bound.z;
+ transform = transform.inverted();
+ elementTransform.transform = glm::mat3x2(
+ transform.m11(), transform.m12(), transform.m21(),
+ transform.m22(), transform.m31(), transform.m32()
+ );
+ //qDebug() << transform;
+ elementTransform.zIndex = 0;
- // TODO þ
+ element.style = baseStyle.material;
+ painting.addElement(element, elementTransform);
+ }
- /* elementTrans.center = glm::vec2(
- (2 * bound.center().x() - screenSize.width()) / screenSize.width(),
- (2 * bound.center().y() - screenSize.height()) / screenSize.height()
- );
- qDebug() << elementTrans.center.x << elementTrans.center.y;
- decomposeTransform(transform, elementTrans.rotation, elementTrans.scale);
- elementTrans.scale = glm::vec2(
- bound.width() * 2 / screenSize.width(),
- bound.height() * 2 / screenSize.height()
- );
- elementTrans.flip = glm::bvec2(
- nowLayer->property.flipHorizontally,
- nowLayer->property.flipVertically
- );
- qDebug() << elementTrans.scale.x << elementTrans.scale.y;
- painting.addElement(element, elementTrans);*/
- return nullptr;
- }
-
- FolderLayerWrapper* folderLayer = dynamic_cast(nowLayer);
- return folderLayer;
-}
-void PaintingUtil::decomposeTransform(QTransform trans, float& angle, glm::vec2& scale) {
- //qDebug() << trans;
- trans.setMatrix(
- trans.m11(), trans.m12(), trans.m13(),
- trans.m21(), trans.m22(), trans.m23(),
- 0, 0, 1);
- //qDebug() << trans.dx() << trans.dy();
- int count = 0;
- double norm = 0, n = 0;
- QTransform R = trans, Rit, Rnext;
- do {
- ++count;
- Rit = R.transposed().inverted();
- Rnext.setMatrix(
- (R.m11() + Rit.m11()) / 2,
- (R.m12() + Rit.m12()) / 2,
- (R.m13() + Rit.m13()) / 2,
- (R.m21() + Rit.m21()) / 2,
- (R.m22() + Rit.m22()) / 2,
- (R.m23() + Rit.m23()) / 2,
- (R.m31() + Rit.m31()) / 2,
- (R.m32() + Rit.m32()) / 2,
- (R.m33() + Rit.m33()) / 2
- );
- norm = 0;
- norm = max(norm,
- fabs(R.m11() - Rnext.m11())
- + fabs(R.m12() - Rnext.m12())
- + fabs(R.m13() - Rnext.m13()));
- norm = max(norm,
- fabs(R.m21() - Rnext.m21())
- + fabs(R.m22() - Rnext.m22())
- + fabs(R.m23() - Rnext.m23()));
- norm = max(norm,
- fabs(R.m31() - Rnext.m31())
- + fabs(R.m32() - Rnext.m32())
- + fabs(R.m33() - Rnext.m33()));
- R = Rnext;
- } while (count < 100 && norm > 0.0001);
- double cosValue = max(-1.0, min(R.m11(), 1.0));
- double sinValue = max(-1.0, min(R.m12(), 1.0));
- angle = acos(cosValue) * 180 / pi;
- if (sinValue < 0) {
- angle = 360 - angle;
- }
- qDebug() << angle;
- //R = R.inverted() * trans;
- //scale = glm::vec2(R.m11(), R.m22());
- //qDebug() << scale.x << scale.y;
- return;
-}
+ return nullptr;
+ }
-double PaintingUtil::getMaxLineWidth(LayerWrapper* root) {
- double maxWidth = 0;
- queue layerQueue;
- layerQueue.push(root);
- while (!layerQueue.empty()) {
- auto layer = layerQueue.front();
- layerQueue.pop();
- FolderLayerWrapper* nextLayer = nullptr;
- LeafLayerWrapper* leafLayer = dynamic_cast(layer);
- if (leafLayer != nullptr) {
- GroupElement* wrapperElement = dynamic_cast(leafLayer->wrappedElement);
- if (wrapperElement != nullptr) {
- nextLayer = wrapperElement->sourceLayer;
- }
- else {
- maxWidth = std::max(maxWidth, (double)leafLayer->styles.boundingBoxAffectValue());
- }
- }
- else {
- nextLayer = dynamic_cast(layer);
- }
- if (nextLayer != nullptr) {
- for (auto sonLayer : nextLayer->children) {
- layerQueue.push(sonLayer.get());
- }
- }
- }
- return maxWidth;
+ FolderLayerWrapper* folderLayer = dynamic_cast(nowLayer);
+ return folderLayer;
}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h
index 9c2ebc1..850bfc0 100644
--- a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h
+++ b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h
@@ -7,11 +7,9 @@ class PaintingUtil
private:
static const double pi;
static QJsonObject readJsonFile(QString jsonFilePath);
- static FolderLayerWrapper* handleLayerWrapper(LayerWrapper* nowLayer, double& maxLineWidth, QTransform& transform, Renderer::Painting& painting);
- static double getMaxLineWidth(LayerWrapper* root);
-public:
+ static FolderLayerWrapper* handleLayerWrapper(LayerWrapper* nowLayer, QTransform& transform, Renderer::Painting& painting);
+ //static double getMaxLineWidth(LayerWrapper* root);
+public:
static Renderer::Painting transfromToPainting(QString jsonFilePath);
- static void decomposeTransform(QTransform trans, float& angle, glm::vec2& scale);
-
};
diff --git a/ArchitectureColoredPainting/src/FluentMenu.cpp b/ArchitectureColoredPainting/src/FluentMenu.cpp
index 42b0f7d..2119311 100644
--- a/ArchitectureColoredPainting/src/FluentMenu.cpp
+++ b/ArchitectureColoredPainting/src/FluentMenu.cpp
@@ -21,4 +21,9 @@ void ::FluentMenu::paintEvent(QPaintEvent* event)
painter.drawRoundedRect(QRectF(shadowRadius - i, shadowRadius - i, width() - (shadowRadius - i) * 2, height() - (shadowRadius - i) * 2), borderRadius + i, borderRadius + i);
}
QMenu::paintEvent(event);
-}
\ No newline at end of file
+}
+
+QAction* FluentMenu::exec(const QPoint& pos, QAction* at)
+{
+ return QMenu::exec(parentWidget()->mapToGlobal(parentWidget()->mapFromGlobal(pos) + QPoint(-shadowRadius, -shadowRadius)), at);
+}
diff --git a/ArchitectureColoredPainting/src/FluentMenu.h b/ArchitectureColoredPainting/src/FluentMenu.h
index 480f6e2..f0ac3fe 100644
--- a/ArchitectureColoredPainting/src/FluentMenu.h
+++ b/ArchitectureColoredPainting/src/FluentMenu.h
@@ -7,6 +7,7 @@ class FluentMenu : public QMenu
public:
explicit FluentMenu(QWidget* parent = nullptr);
void paintEvent(QPaintEvent* event) override;
+ QAction* exec(const QPoint& pos, QAction* at = nullptr);
int shadowRadius = 16;
int borderRadius = 6;
int itemBorderRadius = 4;
diff --git a/ArchitectureColoredPainting/src/Renderer/Model.cpp b/ArchitectureColoredPainting/src/Renderer/Model.cpp
index d2dc3d2..2c54f32 100644
--- a/ArchitectureColoredPainting/src/Renderer/Model.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Model.cpp
@@ -244,8 +244,9 @@ GLuint Renderer::Model::loadPainting(std::string path)
return iter->second;
Painting painting;
+ path = "../test.json";
if (auto file = QFileInfo(QString(path.c_str())); file.isFile())
- painting = PaintingUtil::transfromToPainting(file.path());
+ painting = PaintingUtil::transfromToPainting(file.filePath());
else
{
qDebug() << path.c_str() << "Not Found, Using Default Painting";
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.cpp
index 6b3e6c7..000fec3 100644
--- a/ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.cpp
@@ -20,8 +20,7 @@ QVector4D BvhTree::Union(QVector4D a, QVector4D b) {
QVector4D BvhTree::merge(BvhPtr lp, BvhPtr rp) {
QVector4D a = lp->bound, b = rp->bound;
- /*
- if (lp->isLeaf) {
+ /*if (lp->isLeaf) {
a = BvhTreeData::boundWithRotation(a, lp->getRightSon());
}
if (rp->isLeaf) {
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp
index 0d72542..9919f73 100644
--- a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp
@@ -1,5 +1,6 @@
#include "MaterialStyleStroke.h"
#include
+#include
using namespace Renderer;
@@ -105,8 +106,8 @@ std::unique_ptr Renderer::MaterialStyleStroke::clone() const
bool Renderer::MaterialStyleStroke::operator==(const MaterialStyle& m) const
{
- return type() == m.type()
- && halfWidth == static_cast(m).halfWidth
+ return type() == m.type()
+ && halfWidth == static_cast(m).halfWidth
&& strokeType == static_cast(m).strokeType
&& endType == static_cast(m).endType
&& *materialStroke == *static_cast(m).materialStroke;
@@ -117,4 +118,10 @@ float Renderer::MaterialStyleStroke::getHalfWidth() const
return halfWidth;
}
-
+#define endTypeBoxLabel(start, end) QStringLiteral(start##" -> "##end)
+const std::array, 4> Renderer::MaterialStyleStroke::strokeEndTypeNames = {
+ std::pair{endTypeBoxLabel("Բͷ", "Բͷ"), StrokeEndType::kRound},
+ std::pair{endTypeBoxLabel("ƽͷ", "Բͷ"), StrokeEndType::kFlatRound},
+ std::pair{endTypeBoxLabel("Բͷ", "ƽͷ"), StrokeEndType::kRoundFlat},
+ std::pair{endTypeBoxLabel("ƽͷ", "ƽͷ"), StrokeEndType::kFlat}
+};
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.h b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.h
index 29fd55b..e6bf8af 100644
--- a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.h
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.h
@@ -43,7 +43,7 @@ namespace Renderer
};
enum class StrokeType { kBothSides = 2, kLeftSide = 1, kRightSide = 0 };
- enum class StrokeEndType { kRound = 0b00, kFlat = 0b11, kRoundFlat = 0b10, kFlatRound = 0b01 };
+ enum class StrokeEndType { kRound = 0b00, kFlat = 0b11, kRoundFlat = 0b10, kFlatRound = 0b01, kClosed = 0b100/*ڷͼ*/ };
class MaterialStyleStroke : public MaterialStyle
{
@@ -59,5 +59,6 @@ namespace Renderer
StrokeType strokeType;
StrokeEndType endType;
std::shared_ptr materialStroke;
+ static const std::array, 4> strokeEndTypeNames;
};
}
diff --git a/ArchitectureColoredPainting/src/Renderer/RendererWidget.cpp b/ArchitectureColoredPainting/src/Renderer/RendererWidget.cpp
index d0df771..7e1e03a 100644
--- a/ArchitectureColoredPainting/src/Renderer/RendererWidget.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/RendererWidget.cpp
@@ -29,7 +29,7 @@ Renderer::RendererWidget::RendererWidget(QWidget* parent)
ui.openButton->setChecked(false);
});
QObject::connect(ui.openButton, &QPushButton::clicked, [&, menu]() {
- menu->exec(ui.openButton->mapToGlobal(QPoint(-menu->shadowRadius, ui.openButton->height() - menu->shadowRadius)));
+ menu->exec(ui.openButton->mapToGlobal(QPoint(0, ui.openButton->height())));
});
QObject::connect(ui.horizontalSlider, &QSlider::valueChanged,
diff --git a/ArchitectureColoredPainting/src/main.cpp b/ArchitectureColoredPainting/src/main.cpp
index 5bf6bbe..0e3d73b 100644
--- a/ArchitectureColoredPainting/src/main.cpp
+++ b/ArchitectureColoredPainting/src/main.cpp
@@ -1,11 +1,11 @@
#include "MainWindow.h"
+#include "ColorHelper.hpp"
#include
#include
#include
#include
#include
#include "consoleapi2.h"
-#include
extern "C"
{
@@ -51,9 +51,7 @@ int main(int argc, char* argv[])
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
QApplication a(argc, argv);
Q_INIT_RESOURCE(resources);
- QtMaterialTheme theme;
- theme.setColor("primary1", QColor(0, 90, 158));
- QtMaterialStyle::instance().setTheme(&theme);
+ ColorHelper::instance();
//FramelessHelper::Core::setApplicationOSThemeAware();
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
//FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
diff --git a/UnitTest/ElementRendererTest.cpp b/UnitTest/ElementRendererTest.cpp
index aba0474..5760980 100644
--- a/UnitTest/ElementRendererTest.cpp
+++ b/UnitTest/ElementRendererTest.cpp
@@ -42,17 +42,38 @@ namespace UnitTest
{
virtual std::vector toBaseStyles() const override
{
-
return { BaseStyle(std::make_shared(),
- std::make_shared(
- std::make_shared(Material(QColor(255,255,0))))) };
+ std::make_shared(std::make_shared(Material(QColor(255,255,0))))) };
+ }
+ } style;
+ TestGLWidget w(style, path);
+ w.show();
+ a.exec();
+ }
+ TEST_METHOD(TestFillPlainAndStrokeRadialGradient)
+ {
+ QApplication a(argc, argv);
+ class Style : public Renderer::ElementStyle
+ {
+ virtual std::vector toBaseStyles() const override
+ {
+ std::map materialMap = {
+ {0.20, Material{QColor(255,255,255)}},
+ {0.60, Material{QColor(165,176,207)}},
+ {1.00, Material{QColor(58,64,151)}}
+ };
+ return { BaseStyle(std::make_shared(),
+ std::make_shared(
+ std::make_shared(Material(QColor(255,255,0))))),
+ BaseStyle(std::make_shared(),
+ std::make_shared(10, StrokeType::kBothSides, StrokeEndType::kRound,
+ std::make_shared(materialMap, false))) };
}
} style;
TestGLWidget w(style, path);
w.show();
a.exec();
}
-
};
TEST_CLASS(ElementRendererStokeTypeTest)
diff --git a/UnitTest/UnitTest.cpp b/UnitTest/UnitTest.cpp
index 25bcf67..0005c41 100644
--- a/UnitTest/UnitTest.cpp
+++ b/UnitTest/UnitTest.cpp
@@ -122,20 +122,6 @@ namespace UnitTest
};
TEST_CLASS(PaintingUtilTest)
{
- TEST_METHOD(TransfromTest)
- {
- qInstallMessageHandler(messageHandler);
- QPainterPath path;
- path.addRect(0, 0, 20, 20);
- QTransform trans;
- qDebug() << path.boundingRect();
- //qDebug() << trans;
- //qDebug() << acos(-0.707107);
- glm::vec2 scale;
- float rotate;
- PaintingUtil::decomposeTransform(trans, rotate, scale);
- qDebug() << rotate;
- qDebug() << scale.x << scale.y;
- }
+
};
}
diff --git a/test.json b/test.json
index ecd3b3c..2a78a01 100644
--- a/test.json
+++ b/test.json
@@ -24,7 +24,7 @@
}
],
"height": 1080,
- "project-name": "",
+ "project-name": "1",
"root-layer": {
"children": [
{
@@ -36,7 +36,7 @@
"styles": [
{
"enableEachSideIndependent": false,
- "left": "AACgQAEAIZwAf///AAAA/w==",
+ "left": "AAAAQAEAIZwAf///qqr//w==",
"right": "AADgQAAACJw=",
"type": "stroke"
}
@@ -52,6 +52,30 @@
"y": 1
}
}
+ },
+ {
+ "element": 0,
+ "is-folder": false,
+ "name": "Leaf2",
+ "styles": [
+ {
+ "enableEachSideIndependent": true,
+ "left": "AAAAQAEAIZwAf////1UA/w==",
+ "right": "AADgQAAACJw=",
+ "type": "stroke"
+ }
+ ],
+ "transform": {
+ "offset": {
+ "x": 150,
+ "y": 0
+ },
+ "rotation": 0,
+ "scale": {
+ "x": 1.5,
+ "y": 1.5
+ }
+ }
}
],
"is-folder": true,
@@ -68,6 +92,24 @@
"y": 1
}
}
+ },
+ {
+ "element": 1,
+ "is-folder": false,
+ "name": "ReferencingGroupLayer",
+ "styles": [
+ ],
+ "transform": {
+ "offset": {
+ "x": 100,
+ "y": 0
+ },
+ "rotation": 45,
+ "scale": {
+ "x": 1,
+ "y": 1
+ }
+ }
}
],
"is-folder": true,