Compare commits
No commits in common. "de9d7143b6260f606cfe37f6cb1a9a2cb8d50731" and "0d42af920074ee7847e50fab0988f078dd8e7b31" have entirely different histories.
de9d7143b6
...
0d42af9200
|
@ -14,8 +14,6 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
elementInfoDisplayWidget = dynamic_cast<ElementPoolWidget *>(tabWidget->widget(1));
|
elementInfoDisplayWidget = dynamic_cast<ElementPoolWidget *>(tabWidget->widget(1));
|
||||||
qDebug() << layerInfoDisplayWidget;
|
qDebug() << layerInfoDisplayWidget;
|
||||||
qDebug() << elementInfoDisplayWidget;
|
qDebug() << elementInfoDisplayWidget;
|
||||||
connect(previewWindow, &PreviewWindow::layerInfoChanged, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
|
||||||
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);
|
||||||
|
|
|
@ -47,7 +47,6 @@ PixelPath SimpleElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>
|
||||||
PixelPath result;
|
PixelPath result;
|
||||||
Renderer::ElementStyleStrokeDemo demo(2);
|
Renderer::ElementStyleStrokeDemo demo(2);
|
||||||
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0);
|
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0);
|
||||||
//qDebug() << mov;
|
|
||||||
//qDebug() << img << " ------";
|
//qDebug() << img << " ------";
|
||||||
result.addImage(img, mov);
|
result.addImage(img, mov);
|
||||||
//result.addPath(painterPath);
|
//result.addPath(painterPath);
|
||||||
|
|
|
@ -10,7 +10,6 @@ PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
||||||
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
layerManager = nullptr;
|
layerManager = nullptr;
|
||||||
currentLayer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
||||||
|
@ -48,14 +47,6 @@ void PreviewWindow::paintGL()
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
layerManager->paint(painter,this->size());
|
layerManager->paint(painter,this->size());
|
||||||
if (currentLayer != nullptr)
|
|
||||||
{
|
|
||||||
QPen pen = painter->pen(); // 获取当前的画笔
|
|
||||||
pen.setStyle(Qt::DashLine); // 设置画笔样式为虚线
|
|
||||||
painter->setPen(pen); // 应用画笔设置
|
|
||||||
painter->drawRect(this->currentLayer->getCache().getBoundingRect()); // 绘制矩形
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->end();
|
painter->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,49 +57,3 @@ void PreviewWindow::resizeGL(int w, int h)
|
||||||
Renderer::ElementRenderer* const PreviewWindow::getRenderer()const {
|
Renderer::ElementRenderer* const PreviewWindow::getRenderer()const {
|
||||||
return this->renderer;
|
return this->renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWindow::currentLayerChanged(LayerWrapper* layer)
|
|
||||||
{
|
|
||||||
this->currentLayer = layer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewWindow::refresh()
|
|
||||||
{
|
|
||||||
this->repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewWindow::mousePressEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
// 当鼠标按下时,记录当前的位置
|
|
||||||
m_lastPos = event->pos();
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
// 如果按下的是左键,那么平移图形
|
|
||||||
currentLayer->property.offset.setX(currentLayer->property.offset.x() + dx);
|
|
||||||
currentLayer->property.offset.setY(currentLayer->property.offset.y() + dy);
|
|
||||||
qDebug() << dx << "----" << dy;
|
|
||||||
emit layerInfoChanged();
|
|
||||||
}
|
|
||||||
else if (event->buttons() & Qt::RightButton) {
|
|
||||||
// 如果按下的是右键,那么旋转图形
|
|
||||||
qreal angle = -sqrt(dx * dx + dy * dy) / 1.0;
|
|
||||||
currentLayer->property.rotation += angle;
|
|
||||||
emit layerInfoChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 更新上一次的位置
|
|
||||||
m_lastPos = event->pos();
|
|
||||||
this->repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
// 当鼠标释放时,不做任何操作
|
|
||||||
}
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include "../Renderer/Preview/ElementRenderer.h"
|
#include "../Renderer/Preview/ElementRenderer.h"
|
||||||
|
|
||||||
|
@ -20,12 +19,6 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
LayerManager *layerManager;
|
LayerManager *layerManager;
|
||||||
Renderer::ElementRenderer* renderer;
|
Renderer::ElementRenderer* renderer;
|
||||||
QSize logicalSize;
|
QSize logicalSize;
|
||||||
QRectF viewportRect;
|
|
||||||
LayerWrapper* currentLayer;
|
|
||||||
QPointF m_lastPos;
|
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
|
||||||
void mouseMoveEvent(QMouseEvent* event) override;
|
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PreviewWindow(QWidget *parent = nullptr);
|
PreviewWindow(QWidget *parent = nullptr);
|
||||||
|
@ -35,11 +28,4 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
void resizeGL(int w, int h) override;
|
void resizeGL(int w, int h) override;
|
||||||
Renderer::ElementRenderer* const getRenderer()const;
|
Renderer::ElementRenderer* const getRenderer()const;
|
||||||
|
|
||||||
public slots:
|
|
||||||
void currentLayerChanged(LayerWrapper*);
|
|
||||||
void refresh();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void layerInfoChanged();
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,14 +13,10 @@ LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
||||||
connect(this, &QTreeWidget::customContextMenuRequested, this, &LayerTreeWidget::popMenu);
|
connect(this, &QTreeWidget::customContextMenuRequested, this, &LayerTreeWidget::popMenu);
|
||||||
connect(this, &QTreeWidget::currentItemChanged, [=](QTreeWidgetItem *currentItem) {
|
connect(this, &QTreeWidget::currentItemChanged, [=](QTreeWidgetItem *currentItem) {
|
||||||
this->selectedItem = currentItem;
|
this->selectedItem = currentItem;
|
||||||
if (this->selectedItem != nullptr) {
|
if(this->selectedItem !=nullptr)
|
||||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
emit displayLayerChange(this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper *>());
|
||||||
emit displayLayerChange(layer);
|
else
|
||||||
}
|
|
||||||
else {
|
|
||||||
emit displayLayerChange(nullptr);
|
emit displayLayerChange(nullptr);
|
||||||
}
|
|
||||||
emit requireRefreshPreview();
|
|
||||||
});
|
});
|
||||||
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue