Compare commits
No commits in common. "1ef08dc49e43468dbc9814957700742470b95a0d" and "e7825a06653af23b0b40fa07aabc35c6a733bb3b" have entirely different histories.
1ef08dc49e
...
e7825a0665
|
@ -180,12 +180,6 @@
|
||||||
<property name="accessibleName">
|
<property name="accessibleName">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>10</width>
|
|
||||||
<height>10</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>图层名</string>
|
<string>图层名</string>
|
||||||
|
@ -196,11 +190,6 @@
|
||||||
<string>关联图元</string>
|
<string>关联图元</string>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>可见</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -1093,7 +1093,6 @@ void main()
|
||||||
bool onVeryBegin = false;
|
bool onVeryBegin = false;
|
||||||
bool onVeryEnd = false;
|
bool onVeryEnd = false;
|
||||||
vec2 tangentEndLast;
|
vec2 tangentEndLast;
|
||||||
vec2 tangentFirstBegin;
|
|
||||||
uint lastHitIndex = 0;
|
uint lastHitIndex = 0;
|
||||||
bool lastHitElement = false;
|
bool lastHitElement = false;
|
||||||
hitElement = false;
|
hitElement = false;
|
||||||
|
@ -1109,18 +1108,6 @@ void main()
|
||||||
pBegin = path[++pathIndex];
|
pBegin = path[++pathIndex];
|
||||||
p3Last = pBegin;
|
p3Last = pBegin;
|
||||||
p2Last = pBegin;
|
p2Last = pBegin;
|
||||||
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;
|
onVeryBegin = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1132,12 +1119,6 @@ void main()
|
||||||
vec2 pTemp = path[pathIndex + 1];
|
vec2 pTemp = path[pathIndex + 1];
|
||||||
if (isinf(pTemp.x))
|
if (isinf(pTemp.x))
|
||||||
{
|
{
|
||||||
if(endType == 4)
|
|
||||||
{
|
|
||||||
//onVeryEnd = false;
|
|
||||||
tangentBeginNext = tangentFirstBegin;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
onVeryEnd = true;
|
onVeryEnd = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1199,8 +1180,6 @@ void main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tangentEndLast = tangentEnd;
|
tangentEndLast = tangentEnd;
|
||||||
if(pathIndex == 0)
|
|
||||||
tangentFirstBegin = tangentBegin;
|
|
||||||
}
|
}
|
||||||
p3Last = p[3];
|
p3Last = p[3];
|
||||||
p2Last = p[2];
|
p2Last = p[2];
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "../ColorHelper.hpp"
|
#include "../ColorHelper.hpp"
|
||||||
#include <qtmaterialraisedbutton.h>
|
#include <qtmaterialraisedbutton.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <ranges>
|
|
||||||
|
|
||||||
constexpr int COLUMN_WIDTH = 0;
|
constexpr int COLUMN_WIDTH = 0;
|
||||||
constexpr int COLUMN_COLOR = 1;
|
constexpr int COLUMN_COLOR = 1;
|
||||||
|
@ -11,22 +10,11 @@ constexpr int COLUMN_METALLIC = 2;
|
||||||
constexpr int COLUMN_ROUGHNESS = 3;
|
constexpr int COLUMN_ROUGHNESS = 3;
|
||||||
constexpr int COLUMN_OPERATIONS = 4;
|
constexpr int COLUMN_OPERATIONS = 4;
|
||||||
|
|
||||||
inline Renderer::Material newMaterial()
|
|
||||||
{
|
|
||||||
return {ColorHelper::instance().getPrimary1()};
|
|
||||||
}
|
|
||||||
|
|
||||||
StrokeStyleWidget::StrokeStyleWidget(
|
StrokeStyleWidget::StrokeStyleWidget(
|
||||||
std::shared_ptr<MaterialStyleStroke> stroke,
|
std::shared_ptr<MaterialStyleStroke> stroke,
|
||||||
QWidget* parent
|
QWidget* parent
|
||||||
) : QWidget(parent), stroke(stroke)
|
) : QWidget(parent), stroke(stroke)
|
||||||
{
|
{
|
||||||
auto& materialMap = radialStroke(stroke)->materialMap;
|
|
||||||
if (materialMap.empty())
|
|
||||||
{
|
|
||||||
materialMap[1.f] = newMaterial();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* viewLayout = new QVBoxLayout(this);
|
auto* viewLayout = new QVBoxLayout(this);
|
||||||
this->setLayout(viewLayout);
|
this->setLayout(viewLayout);
|
||||||
|
|
||||||
|
@ -42,12 +30,8 @@ StrokeStyleWidget::StrokeStyleWidget(
|
||||||
viewLayout->addWidget(strokeProperties);
|
viewLayout->addWidget(strokeProperties);
|
||||||
viewLayout->addWidget(widthField);
|
viewLayout->addWidget(widthField);
|
||||||
|
|
||||||
initTable(radialStroke(stroke));
|
initTable(std::dynamic_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke));
|
||||||
viewLayout->addWidget(strokeTable);
|
viewLayout->addWidget(strokeTable);
|
||||||
|
|
||||||
initAddButton();
|
|
||||||
viewLayout->addWidget(addButton);
|
|
||||||
|
|
||||||
this->adjustSize();
|
this->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,12 +83,13 @@ void StrokeStyleWidget::initStrokeSettings()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: 新增时参数校验
|
||||||
void StrokeStyleWidget::initTable(std::shared_ptr<Renderer::StrokeRadialGradient> materialStroke)
|
void StrokeStyleWidget::initTable(std::shared_ptr<Renderer::StrokeRadialGradient> materialStroke)
|
||||||
{
|
{
|
||||||
this->strokeTable = new QTableWidget(this);
|
this->strokeTable = new QTableWidget(this);
|
||||||
strokeTable->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
|
strokeTable->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
|
||||||
strokeTable->setColumnCount(5);
|
strokeTable->setColumnCount(5);
|
||||||
strokeTable->setRowCount(materialStroke->materialMap.size());
|
strokeTable->setRowCount(materialStroke->materialMap.size() + 1);
|
||||||
QStringList headers;
|
QStringList headers;
|
||||||
headers << QStringLiteral("ÀëÐľàÀëÕ¼±È")
|
headers << QStringLiteral("ÀëÐľàÀëÕ¼±È")
|
||||||
<< QStringLiteral("ÑÕÉ«")
|
<< QStringLiteral("ÑÕÉ«")
|
||||||
|
@ -112,45 +97,44 @@ void StrokeStyleWidget::initTable(std::shared_ptr<Renderer::StrokeRadialGradient
|
||||||
<< QStringLiteral("´Ö²Ú¶È")
|
<< QStringLiteral("´Ö²Ú¶È")
|
||||||
<< QStringLiteral("ÆäËû²Ù×÷");
|
<< QStringLiteral("ÆäËû²Ù×÷");
|
||||||
strokeTable->setHorizontalHeaderLabels(headers);
|
strokeTable->setHorizontalHeaderLabels(headers);
|
||||||
strokeTable->setMinimumHeight(strokeTable->rowHeight(0) * 5);
|
|
||||||
strokeTable->setMinimumWidth(strokeTable->sizeHint().width());
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
// ÄÚÈÝ
|
// ÄÚÈÝ
|
||||||
for (auto& [width, material] : std::views::reverse(materialStroke->materialMap))
|
for (auto & strokePair : materialStroke->materialMap)
|
||||||
{
|
{
|
||||||
setTableRow(row, width, material);
|
setTableRow(row, strokePair.first, strokePair.second);
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
connect(strokeTable, &QTableWidget::currentItemChanged, this, &StrokeStyleWidget::onCurrentItemChanged);
|
// 新增按钮
|
||||||
connect(strokeTable, &QTableWidget::cellChanged, this, &StrokeStyleWidget::onCellChanged);
|
auto* addButton = new QtMaterialRaisedButton("+", strokeTable);
|
||||||
}
|
|
||||||
|
|
||||||
void StrokeStyleWidget::initAddButton()
|
|
||||||
{
|
|
||||||
this->addButton = new QtMaterialRaisedButton("+", strokeTable);
|
|
||||||
addButton->setFixedHeight(this->strokeTable->rowHeight(0));
|
|
||||||
addButton->setBackgroundColor(ColorHelper::instance().getPrimary1());
|
addButton->setBackgroundColor(ColorHelper::instance().getPrimary1());
|
||||||
connect(addButton, &QtMaterialRaisedButton::clicked, [this] {
|
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]() {
|
||||||
handlingRowInsert = true;
|
handlingRowInsert = true;
|
||||||
auto materialMap = &radialStroke(this->stroke)->materialMap;
|
auto materialMap = &radialStroke(this->stroke)->materialMap;
|
||||||
float newWidth;
|
float newWidth;
|
||||||
if (materialMap->empty())
|
if (materialMap->empty())
|
||||||
{
|
{
|
||||||
newWidth = 1.f;
|
newWidth = 0.1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto firstPair = materialMap->begin();
|
const auto lastPair = materialMap->rbegin();
|
||||||
newWidth = firstPair->first / 2;
|
newWidth = lastPair->first + 0.01;
|
||||||
}
|
}
|
||||||
const Renderer::Material newMaterial(ColorHelper::instance().getPrimary1());
|
const Renderer::Material newMaterial(ColorHelper::instance().getPrimary1());
|
||||||
(*materialMap)[newWidth] = newMaterial;
|
(*materialMap)[newWidth] = newMaterial;
|
||||||
int newRow = this->strokeTable->rowCount();
|
int newRow = this->strokeTable->rowCount() - 1;
|
||||||
this->strokeTable->insertRow(newRow);
|
this->strokeTable->insertRow(newRow);
|
||||||
setTableRow(newRow, newWidth, (*materialMap)[newWidth]);
|
setTableRow(newRow, newWidth, (*materialMap)[newWidth]);
|
||||||
this->strokeTable->update();
|
this->strokeTable->update();
|
||||||
handlingRowInsert = false;
|
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)
|
void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& material)
|
||||||
|
@ -182,7 +166,7 @@ void StrokeStyleWidget::setTableRow(int row, float width, Renderer::Material& ma
|
||||||
removeButton->setBackgroundColor(ColorHelper::instance().getPrimary1());
|
removeButton->setBackgroundColor(ColorHelper::instance().getPrimary1());
|
||||||
removeButton->setFixedSize(20, 20);
|
removeButton->setFixedSize(20, 20);
|
||||||
strokeTable->setCellWidget(row, COLUMN_OPERATIONS, removeButton);
|
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());
|
radialStroke(this->stroke)->materialMap.erase(this->strokeTable->item(row, COLUMN_WIDTH)->text().toFloat());
|
||||||
this->strokeTable->removeRow(row);
|
this->strokeTable->removeRow(row);
|
||||||
});
|
});
|
||||||
|
@ -215,13 +199,9 @@ void StrokeStyleWidget::onCellChanged(int row, int column)
|
||||||
{
|
{
|
||||||
float oldWidth = this->currentItemValue.toFloat();
|
float oldWidth = this->currentItemValue.toFloat();
|
||||||
auto node = radialStroke(stroke)->materialMap.extract(oldWidth);
|
auto node = radialStroke(stroke)->materialMap.extract(oldWidth);
|
||||||
if (node.empty())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
node.key() = changedWidth;
|
node.key() = changedWidth;
|
||||||
radialStroke(stroke)->materialMap.insert(std::move(node));
|
radialStroke(stroke)->materialMap.insert(std::move(node));
|
||||||
strokeTable->sortItems(COLUMN_WIDTH, Qt::DescendingOrder);
|
strokeTable->sortItems(COLUMN_WIDTH);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case COLUMN_METALLIC:
|
case COLUMN_METALLIC:
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <qtmaterialtextfield.h>
|
#include <qtmaterialtextfield.h>
|
||||||
#include <qtmaterialcheckbox.h>
|
#include <qtmaterialcheckbox.h>
|
||||||
#include <qtmaterialraisedbutton.h>
|
|
||||||
class StrokeStyleWidget : public QWidget
|
class StrokeStyleWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -17,12 +16,10 @@ private:
|
||||||
QComboBox* endTypeBox;
|
QComboBox* endTypeBox;
|
||||||
QtMaterialTextField* widthField;
|
QtMaterialTextField* widthField;
|
||||||
QTableWidget* strokeTable;
|
QTableWidget* strokeTable;
|
||||||
QtMaterialRaisedButton* addButton;
|
|
||||||
bool handlingRowInsert = false;
|
bool handlingRowInsert = false;
|
||||||
|
|
||||||
void initStrokeSettings();
|
void initStrokeSettings();
|
||||||
void initTable(std::shared_ptr<Renderer::StrokeRadialGradient> materialStroke);
|
void initTable(std::shared_ptr<Renderer::StrokeRadialGradient> materialStroke);
|
||||||
void initAddButton();
|
|
||||||
void setTableRow(int row, float width, Renderer::Material& material);
|
void setTableRow(int row, float width, Renderer::Material& material);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -25,7 +25,6 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
treeWidget->refresh();
|
treeWidget->refresh();
|
||||||
previewWindow->refresh();
|
previewWindow->refresh();
|
||||||
};
|
};
|
||||||
connect(previewWindow, &PreviewWindow::triggerCentralRefresh, centralRefresh);
|
|
||||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
||||||
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
|
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
|
||||||
connect(treeWidget, &LayerTreeWidget::triggerCentralRefresh, centralRefresh);
|
connect(treeWidget, &LayerTreeWidget::triggerCentralRefresh, centralRefresh);
|
||||||
|
@ -34,15 +33,15 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
||||||
connect(previewWindow, &PreviewWindow::layerInfoChanged, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
connect(previewWindow, &PreviewWindow::layerInfoChanged, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
||||||
//connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
||||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
||||||
// &EditorWidgetItem::triggerRefreshPreview);
|
&EditorWidgetItem::triggerRefreshPreview);
|
||||||
// connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
||||||
// &EditorWidgetItem::triggerRefreshPreview);
|
&EditorWidgetItem::triggerRefreshPreview);
|
||||||
//connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireSelfRefresh, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireSelfRefresh, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
||||||
// connect(elementInfoDisplayWidget, &ElementPoolWidget::refreshLayerTree, treeWidget, &LayerTreeWidget::refresh);
|
connect(elementInfoDisplayWidget, &ElementPoolWidget::refreshLayerTree, treeWidget, &LayerTreeWidget::refresh);
|
||||||
// &EditorWidget::triggerRefreshPreview);
|
// &EditorWidget::triggerRefreshPreview);
|
||||||
// test
|
// test
|
||||||
QFile settingFile;
|
QFile settingFile;
|
||||||
|
@ -74,10 +73,9 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
this->projectName = source.value("project-name").toString();
|
this->projectName = source.value("project-name").toString();
|
||||||
qDebug() << this->backgroundColor;
|
qDebug() << this->backgroundColor;
|
||||||
qDebug() << this->projectName;
|
qDebug() << this->projectName;
|
||||||
QTimer::singleShot(300, this, [this, centralRefresh]() {
|
QTimer::singleShot(300, this, [this]() {
|
||||||
handleBackgroundColorChange(this->backgroundColor);
|
handleBackgroundColorChange(this->backgroundColor);
|
||||||
handleProjectNameChange(this->projectName);
|
handleProjectNameChange(this->projectName);
|
||||||
centralRefresh();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GroupElement::isClosed() const
|
bool GroupElement::isClosed() const
|
||||||
|
|
|
@ -13,21 +13,8 @@ LayerWrapper *LayerManager::getRoot() const
|
||||||
}
|
}
|
||||||
void LayerManager::paint(QPainter *painter, QSize size,LayerWrapper* selecetedLayer) const
|
void LayerManager::paint(QPainter *painter, QSize size,LayerWrapper* selecetedLayer) const
|
||||||
{
|
{
|
||||||
painter->save();
|
|
||||||
root->getCache();
|
root->getCache();
|
||||||
root->paint(painter);
|
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
|
bool LayerManager::singleSelectedCheck() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,6 @@ LayerWrapper::LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementM
|
||||||
transformJson.value("scale").toObject().value("y").toDouble()};
|
transformJson.value("scale").toObject().value("y").toDouble()};
|
||||||
property.rotation = {transformJson.value("rotation").toDouble()};
|
property.rotation = {transformJson.value("rotation").toDouble()};
|
||||||
selected = false;
|
selected = false;
|
||||||
hidden = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent)
|
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent)
|
||||||
|
@ -200,7 +199,6 @@ void FolderLayerWrapper::delSelf() {
|
||||||
QTreeWidgetItem* LayerWrapper::getQTreeItem()
|
QTreeWidgetItem* LayerWrapper::getQTreeItem()
|
||||||
{
|
{
|
||||||
this->qTreeWidgetItem->setData(0, Qt::UserRole, QVariant::fromValue(this));
|
this->qTreeWidgetItem->setData(0, Qt::UserRole, QVariant::fromValue(this));
|
||||||
this->qTreeWidgetItem->setCheckState(0, Qt::Checked);
|
|
||||||
return this->qTreeWidgetItem;
|
return this->qTreeWidgetItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,34 +280,31 @@ 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 ignoreSelected)
|
||||||
{
|
{
|
||||||
// if (this->selected)
|
if (!ignoreSelected && this->selected)
|
||||||
// {
|
{
|
||||||
// painter->save();
|
painter->save();
|
||||||
//painter->setPen(QPen(Qt::red, 2));
|
painter->setTransform(transform, ignoreSelected);
|
||||||
//painter->setTransform(transform);
|
painter->setPen(QPen(Qt::gray, 2));
|
||||||
//painter->drawRect(this->cache.getBoundingRect());
|
painter->setPen(Qt::DashLine);
|
||||||
//painter->restore();
|
painter->drawRect(cache.getBoundingRect());
|
||||||
// }
|
painter->restore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
|
||||||
{
|
{
|
||||||
if (hidden && !force)
|
LayerWrapper::paint(painter, transform, ignoreSelected);
|
||||||
return;
|
|
||||||
LayerWrapper::paint(painter, transform, force);
|
|
||||||
transform = property.transform * transform;
|
transform = property.transform * transform;
|
||||||
//qDebug() << transform;
|
//qDebug() << transform;
|
||||||
for (auto& child : children)
|
for (auto& child : children)
|
||||||
child->paint(painter, transform, force);
|
child->paint(painter, transform, ignoreSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
|
||||||
{
|
{
|
||||||
if (hidden && !force)
|
LayerWrapper::paint(painter, transform, ignoreSelected);
|
||||||
return;
|
|
||||||
LayerWrapper::paint(painter, transform, force);
|
|
||||||
transform = property.transform * transform;
|
transform = property.transform * transform;
|
||||||
//qDebug() << transform;
|
//qDebug() << transform;
|
||||||
if (wrappedElement != nullptr)
|
if (wrappedElement != nullptr)
|
||||||
|
@ -352,12 +347,11 @@ void FolderLayerWrapper::collectDownReachable(std::set<LayerWrapper*>& reachable
|
||||||
|
|
||||||
void LayerWrapper::refreshTreeItem()
|
void LayerWrapper::refreshTreeItem()
|
||||||
{
|
{
|
||||||
hidden = qTreeWidgetItem->checkState(0) == Qt::Unchecked;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeafLayerWrapper::refreshTreeItem()
|
void LeafLayerWrapper::refreshTreeItem()
|
||||||
{
|
{
|
||||||
LayerWrapper::refreshTreeItem();
|
|
||||||
if (typeid(*wrappedElement) == typeid(GroupElement))
|
if (typeid(*wrappedElement) == typeid(GroupElement))
|
||||||
{
|
{
|
||||||
this->qTreeWidgetItem->setText(0, "@ " + this->property.name);
|
this->qTreeWidgetItem->setText(0, "@ " + this->property.name);
|
||||||
|
@ -372,7 +366,6 @@ void LeafLayerWrapper::refreshTreeItem()
|
||||||
|
|
||||||
void FolderLayerWrapper::refreshTreeItem()
|
void FolderLayerWrapper::refreshTreeItem()
|
||||||
{
|
{
|
||||||
LayerWrapper::refreshTreeItem();
|
|
||||||
for (auto& child : this->children) {
|
for (auto& child : this->children) {
|
||||||
child->refreshTreeItem();
|
child->refreshTreeItem();
|
||||||
}
|
}
|
||||||
|
@ -436,20 +429,3 @@ bool LayerWrapper::canApplyStyles() const
|
||||||
{
|
{
|
||||||
return typeid(*this) == typeid(LeafLayerWrapper) && !referencingGroupElement();
|
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();
|
|
||||||
}
|
|
|
@ -37,7 +37,6 @@ class LayerWrapper
|
||||||
public:
|
public:
|
||||||
QTreeWidgetItem* qTreeWidgetItem;
|
QTreeWidgetItem* qTreeWidgetItem;
|
||||||
bool selected;
|
bool selected;
|
||||||
bool hidden;
|
|
||||||
struct SimpleProperty
|
struct SimpleProperty
|
||||||
{
|
{
|
||||||
QString name = "";
|
QString name = "";
|
||||||
|
@ -59,7 +58,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 ignoreSelected = false);
|
||||||
// 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
|
||||||
|
@ -75,7 +74,6 @@ class LayerWrapper
|
||||||
virtual size_t referencedCount(bool excludeSelf = false) const;
|
virtual size_t referencedCount(bool excludeSelf = false) const;
|
||||||
virtual bool deleteable(bool excludeSubTree = false) const;
|
virtual bool deleteable(bool excludeSubTree = false) const;
|
||||||
virtual bool referencingGroupElement() const;
|
virtual bool referencingGroupElement() const;
|
||||||
virtual void paintVisualBounding(QPainter* painter) const;
|
|
||||||
bool canApplyStyles() const;
|
bool canApplyStyles() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,7 +97,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 ignoreSelected = false) 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;
|
||||||
|
@ -117,7 +115,7 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
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 ignoreSelected = false) 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;
|
||||||
|
|
|
@ -78,8 +78,7 @@ PixelPath PixelPath::trans(QTransform& mat)const
|
||||||
painter.setTransform(mat);
|
painter.setTransform(mat);
|
||||||
painter.drawPixmap(0, 0, pixmap);
|
painter.drawPixmap(0, 0, pixmap);
|
||||||
result.painterPath.addPath(this->painterPath);
|
result.painterPath.addPath(this->painterPath);
|
||||||
result.painterPath = mat.map(result.painterPath);
|
result.boundingRect = mat.mapRect(boundingRect);
|
||||||
result.boundingRect = result.painterPath.boundingRect();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "PreviewWindow.h"
|
#include "PreviewWindow.h"
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
||||||
{
|
{
|
||||||
|
@ -85,17 +84,7 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
|
||||||
int dx = event->x() - m_lastPos.x();
|
int dx = event->x() - m_lastPos.x();
|
||||||
int dy = event->y() - m_lastPos.y();
|
int dy = event->y() - m_lastPos.y();
|
||||||
if (currentLayer != nullptr) {
|
if (currentLayer != nullptr) {
|
||||||
if (QApplication::keyboardModifiers() == Qt::ControlModifier && (event->buttons() & Qt::LeftButton))
|
if (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.setX(currentLayer->property.offset.x() + dx);
|
||||||
currentLayer->property.offset.setY(currentLayer->property.offset.y() + dy);
|
currentLayer->property.offset.setY(currentLayer->property.offset.y() + dy);
|
||||||
|
@ -111,18 +100,19 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
|
||||||
auto index = -1;
|
auto index = -1;
|
||||||
if (typeid(*layer) == typeid(FolderLayerWrapper))
|
if (typeid(*layer) == typeid(FolderLayerWrapper))
|
||||||
index = dynamic_cast<FolderLayerWrapper*>(layer)->getReferencedBy();
|
index = dynamic_cast<FolderLayerWrapper*>(layer)->getReferencedBy();
|
||||||
|
if (index != -1)
|
||||||
|
emit refreshElementPreviewByIndex(index);
|
||||||
layer = layer->getParent();
|
layer = layer->getParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 更新上一次的位置
|
// 更新上一次的位置
|
||||||
emit triggerCentralRefresh();
|
|
||||||
m_lastPos = event->pos();
|
m_lastPos = event->pos();
|
||||||
this->repaint();
|
this->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
|
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
//emit layerInfoChanged();
|
emit layerInfoChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::setBackgroundColor(QColor color)
|
void PreviewWindow::setBackgroundColor(QColor color)
|
||||||
|
|
|
@ -46,5 +46,4 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
void layerInfoChanged();
|
void layerInfoChanged();
|
||||||
void refreshElementPreview(GraphicElement*);
|
void refreshElementPreview(GraphicElement*);
|
||||||
void refreshElementPreviewByIndex(int);
|
void refreshElementPreviewByIndex(int);
|
||||||
void triggerCentralRefresh();
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,11 +21,12 @@ void InfoDisplayWidget::generateLayerForm()
|
||||||
{
|
{
|
||||||
while (this->layout()->count() > 0 && (item = this->layout()->takeAt(0)) != nullptr)
|
while (this->layout()->count() > 0 && (item = this->layout()->takeAt(0)) != nullptr)
|
||||||
{
|
{
|
||||||
item->widget()->deleteLater();
|
delete item->widget();
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
delete this->layout();
|
delete this->layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
QFormLayout *layout = new QFormLayout();
|
QFormLayout *layout = new QFormLayout();
|
||||||
layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
||||||
if (this->displayLayer == nullptr)
|
if (this->displayLayer == nullptr)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include "./EditorWidgetComponent/LayerCreateWidget.h"
|
#include "./EditorWidgetComponent/LayerCreateWidget.h"
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
||||||
{
|
{
|
||||||
|
@ -27,10 +26,6 @@ LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
||||||
}
|
}
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
connect(this, &QTreeWidget::itemChanged, this, [=]() {
|
|
||||||
emit triggerCentralRefresh();
|
|
||||||
});
|
|
||||||
|
|
||||||
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,9 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr
|
||||||
QPainterPath painterPath = pixelPath.getPainterPath();
|
QPainterPath painterPath = pixelPath.getPainterPath();
|
||||||
QRectF bound = painterPath.boundingRect();
|
QRectF bound = painterPath.boundingRect();
|
||||||
//qDebug() << leafLayer<<"------" << painterPath;
|
//qDebug() << leafLayer<<"------" << painterPath;
|
||||||
// transform to -1£¬ 1
|
//qDebug() << transform;
|
||||||
|
// transform to initial painterPath
|
||||||
|
// transfrom to -1£¬ 1
|
||||||
QTransform trans;
|
QTransform trans;
|
||||||
double maxLen = std::max(bound.width(), bound.height());
|
double maxLen = std::max(bound.width(), bound.height());
|
||||||
qDebug() << maxLen << bound;
|
qDebug() << maxLen << bound;
|
||||||
|
@ -100,19 +102,22 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr
|
||||||
auto baseStyles = leafLayer->styles.toBaseStyles();
|
auto baseStyles = leafLayer->styles.toBaseStyles();
|
||||||
Renderer::BaseElement element;
|
Renderer::BaseElement element;
|
||||||
element.contour = contour;
|
element.contour = contour;
|
||||||
for (auto& baseStyle : baseStyles) {
|
for (auto baseStyle : baseStyles) {
|
||||||
double lineWidth = 0;
|
double lineWidth = 0;
|
||||||
if (baseStyle.material->type() == Renderer::MaterialStyleType::kStroke) {
|
if (baseStyle.material->type() == Renderer::MaterialStyleType::kStroke) {
|
||||||
auto material = std::static_pointer_cast<MaterialStyleStroke>(baseStyle.material);
|
auto material = dynamic_cast<MaterialStyleStroke*>(baseStyle.material.get());
|
||||||
material->halfWidth /= maxLen;
|
material->halfWidth = material->halfWidth / maxLen;
|
||||||
lineWidth = material->halfWidth;
|
lineWidth = material->halfWidth;
|
||||||
qDebug() << material->halfWidth;
|
qDebug() << material->halfWidth;
|
||||||
}
|
}
|
||||||
QPainterPathStroker stroker;
|
QRectF rect = painterPath.boundingRect();
|
||||||
stroker.setWidth(lineWidth);
|
rect.setX(-lineWidth + rect.x());
|
||||||
stroker.setCapStyle(Qt::RoundCap);
|
rect.setY(-lineWidth + rect.y());
|
||||||
QPainterPath strokePath = stroker.createStroke(painterPath);
|
rect.setWidth(lineWidth * 2 + rect.width());
|
||||||
auto rect = transform.map(strokePath).boundingRect();
|
rect.setHeight(lineWidth * 2 + rect.height());
|
||||||
|
QPainterPath path;
|
||||||
|
path.addRect(rect);
|
||||||
|
rect = transform.map(path).boundingRect();
|
||||||
elementTransform.bound = glm::vec4(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
|
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;
|
qDebug() << elementTransform.bound.x << elementTransform.bound.y << elementTransform.bound.z << elementTransform.bound.z;
|
||||||
transform = transform.inverted();
|
transform = transform.inverted();
|
||||||
|
@ -120,7 +125,7 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr
|
||||||
transform.m11(), transform.m12(), transform.m21(),
|
transform.m11(), transform.m12(), transform.m21(),
|
||||||
transform.m22(), transform.m31(), transform.m32()
|
transform.m22(), transform.m31(), transform.m32()
|
||||||
);
|
);
|
||||||
//qDebug() << transform;
|
qDebug() << transform;
|
||||||
elementTransform.zIndex = 0;
|
elementTransform.zIndex = 0;
|
||||||
|
|
||||||
element.style = baseStyle.material;
|
element.style = baseStyle.material;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "MaterialStyleStroke.h"
|
#include "MaterialStyleStroke.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <array>
|
|
||||||
|
|
||||||
using namespace Renderer;
|
using namespace Renderer;
|
||||||
|
|
||||||
|
@ -118,10 +117,4 @@ float Renderer::MaterialStyleStroke::getHalfWidth() const
|
||||||
return halfWidth;
|
return halfWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define endTypeBoxLabel(start, end) QStringLiteral(start##" -> "##end)
|
|
||||||
const std::array<std::pair<QString, StrokeEndType>, 4> Renderer::MaterialStyleStroke::strokeEndTypeNames = {
|
|
||||||
std::pair{endTypeBoxLabel("Բͷ", "Բͷ"), StrokeEndType::kRound},
|
|
||||||
std::pair{endTypeBoxLabel("ƽͷ", "Բͷ"), StrokeEndType::kFlatRound},
|
|
||||||
std::pair{endTypeBoxLabel("Բͷ", "ƽͷ"), StrokeEndType::kRoundFlat},
|
|
||||||
std::pair{endTypeBoxLabel("ƽͷ", "ƽͷ"), StrokeEndType::kFlat}
|
|
||||||
};
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace Renderer
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class StrokeType { kBothSides = 2, kLeftSide = 1, kRightSide = 0 };
|
enum class StrokeType { kBothSides = 2, kLeftSide = 1, kRightSide = 0 };
|
||||||
enum class StrokeEndType { kRound = 0b00, kFlat = 0b11, kRoundFlat = 0b10, kFlatRound = 0b01, kClosed = 0b100/*用于封闭图形*/ };
|
enum class StrokeEndType { kRound = 0b00, kFlat = 0b11, kRoundFlat = 0b10, kFlatRound = 0b01 };
|
||||||
|
|
||||||
class MaterialStyleStroke : public MaterialStyle
|
class MaterialStyleStroke : public MaterialStyle
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,5 @@ namespace Renderer
|
||||||
StrokeType strokeType;
|
StrokeType strokeType;
|
||||||
StrokeEndType endType;
|
StrokeEndType endType;
|
||||||
std::shared_ptr<MaterialStroke> materialStroke;
|
std::shared_ptr<MaterialStroke> materialStroke;
|
||||||
static const std::array<std::pair<QString, StrokeEndType>, 4> strokeEndTypeNames;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,38 +42,17 @@ namespace UnitTest
|
||||||
{
|
{
|
||||||
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
||||||
{
|
{
|
||||||
return { BaseStyle(std::make_shared<TransformStyle>(),
|
|
||||||
std::make_shared<MaterialStyleFill>(std::make_shared<FillPlain>(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<Renderer::BaseStyle> toBaseStyles() const override
|
|
||||||
{
|
|
||||||
std::map<float, Material> 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<TransformStyle>(),
|
return { BaseStyle(std::make_shared<TransformStyle>(),
|
||||||
std::make_shared<MaterialStyleFill>(
|
std::make_shared<MaterialStyleFill>(
|
||||||
std::make_shared<FillPlain>(Material(QColor(255,255,0))))),
|
std::make_shared<FillPlain>(Material(QColor(255,255,0))))) };
|
||||||
BaseStyle(std::make_shared<TransformStyle>(),
|
|
||||||
std::make_shared<MaterialStyleStroke>(10, StrokeType::kBothSides, StrokeEndType::kRound,
|
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style, path);
|
TestGLWidget w(style, path);
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_CLASS(ElementRendererStokeTypeTest)
|
TEST_CLASS(ElementRendererStokeTypeTest)
|
||||||
|
|
|
@ -122,6 +122,20 @@ namespace UnitTest
|
||||||
};
|
};
|
||||||
TEST_CLASS(PaintingUtilTest)
|
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;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
"name": "Leaf2",
|
"name": "Leaf2",
|
||||||
"styles": [
|
"styles": [
|
||||||
{
|
{
|
||||||
"enableEachSideIndependent": true,
|
"enableEachSideIndependent": false,
|
||||||
"left": "AAAAQAEAIZwAf////1UA/w==",
|
"left": "AAAAQAEAIZwAf////1UA/w==",
|
||||||
"right": "AADgQAAACJw=",
|
"right": "AADgQAAACJw=",
|
||||||
"type": "stroke"
|
"type": "stroke"
|
||||||
|
|
Loading…
Reference in New Issue