实现【位置错误的】LayerBounding虚线框
parent
0d42af9200
commit
ed4c3c0064
|
@ -14,6 +14,7 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
elementInfoDisplayWidget = dynamic_cast<ElementPoolWidget *>(tabWidget->widget(1));
|
||||
qDebug() << layerInfoDisplayWidget;
|
||||
qDebug() << elementInfoDisplayWidget;
|
||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
||||
connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
||||
|
|
|
@ -47,6 +47,7 @@ PixelPath SimpleElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>
|
|||
PixelPath result;
|
||||
Renderer::ElementStyleStrokeDemo demo(2);
|
||||
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0);
|
||||
//qDebug() << mov;
|
||||
//qDebug() << img << " ------";
|
||||
result.addImage(img, mov);
|
||||
//result.addPath(painterPath);
|
||||
|
|
|
@ -10,6 +10,7 @@ PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent)
|
|||
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
layerManager = nullptr;
|
||||
currentLayer = nullptr;
|
||||
}
|
||||
|
||||
void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize)
|
||||
|
@ -47,6 +48,14 @@ void PreviewWindow::paintGL()
|
|||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -57,3 +66,13 @@ void PreviewWindow::resizeGL(int w, int h)
|
|||
Renderer::ElementRenderer* const PreviewWindow::getRenderer()const {
|
||||
return this->renderer;
|
||||
}
|
||||
|
||||
void PreviewWindow::currentLayerChanged(LayerWrapper* layer)
|
||||
{
|
||||
this->currentLayer = layer;
|
||||
}
|
||||
|
||||
void PreviewWindow::refresh()
|
||||
{
|
||||
this->repaint();
|
||||
}
|
|
@ -19,6 +19,8 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
LayerManager *layerManager;
|
||||
Renderer::ElementRenderer* renderer;
|
||||
QSize logicalSize;
|
||||
QRectF viewportRect;
|
||||
LayerWrapper* currentLayer;
|
||||
|
||||
public:
|
||||
PreviewWindow(QWidget *parent = nullptr);
|
||||
|
@ -28,4 +30,8 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
void paintGL() override;
|
||||
void resizeGL(int w, int h) override;
|
||||
Renderer::ElementRenderer* const getRenderer()const;
|
||||
|
||||
public slots:
|
||||
void currentLayerChanged(LayerWrapper*);
|
||||
void refresh();
|
||||
};
|
||||
|
|
|
@ -13,10 +13,14 @@ LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
|||
connect(this, &QTreeWidget::customContextMenuRequested, this, &LayerTreeWidget::popMenu);
|
||||
connect(this, &QTreeWidget::currentItemChanged, [=](QTreeWidgetItem *currentItem) {
|
||||
this->selectedItem = currentItem;
|
||||
if(this->selectedItem !=nullptr)
|
||||
emit displayLayerChange(this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper *>());
|
||||
else
|
||||
if (this->selectedItem != nullptr) {
|
||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||
emit displayLayerChange(layer);
|
||||
}
|
||||
else {
|
||||
emit displayLayerChange(nullptr);
|
||||
}
|
||||
emit requireRefreshPreview();
|
||||
});
|
||||
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class LayerTreeWidget : public QTreeWidget
|
|||
// void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
// void onItemDoubleClicked(QTreeWidgetItem *item, int column = 0);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void displayLayerChange(LayerWrapper *);
|
||||
void requireRefreshPreview();
|
||||
void requireRefreshElementWidget();
|
||||
|
|
Loading…
Reference in New Issue