From 233e5c94f16c894beaf5ec2b3ab49dbf1c5ad071 Mon Sep 17 00:00:00 2001 From: YingQ Date: Tue, 19 Sep 2023 18:48:39 +0800 Subject: [PATCH] ImageAlphacheckboard --- ui/zenoedit/panel/zenoimagepanel.cpp | 21 ++++++++++++++++++++- ui/zenoedit/panel/zenoimagepanel.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ui/zenoedit/panel/zenoimagepanel.cpp b/ui/zenoedit/panel/zenoimagepanel.cpp index 3d0fc32392..9ec9ea65ba 100644 --- a/ui/zenoedit/panel/zenoimagepanel.cpp +++ b/ui/zenoedit/panel/zenoimagepanel.cpp @@ -111,6 +111,7 @@ void ZenoImagePanel::setPrim(std::string primid) { return; bool enableGamma = pGamma->checkState() == Qt::Checked; + bool enableAlpha = pAlpha->checkState() == Qt::Checked; bool found = false; for (auto const &[key, ptr]: scene->objectsMan->pairs()) { if ((key.substr(0, key.find(":"))) != primid) { @@ -127,7 +128,7 @@ void ZenoImagePanel::setPrim(std::string primid) { if (image_view) { QImage img(width, height, QImage::Format_RGB32); int gridSize = 50; - if (obj->verts.has_attr("alpha")) { + if (obj->verts.has_attr("alpha")&&enableAlpha) { auto &alpha = obj->verts.attr("alpha"); for (auto i = 0; i < obj->verts.size(); i++) { int h = i / width; @@ -207,6 +208,10 @@ ZenoImagePanel::ZenoImagePanel(QWidget *parent) : QWidget(parent) { pGamma->setCheckState(Qt::Checked); pTitleLayout->addWidget(pGamma); + pAlpha->setStyleSheet("color: white;"); + pAlpha->setCheckState(Qt::Unchecked); + pTitleLayout->addWidget(pAlpha); + pFit->setProperty("cssClass", "grayButton"); pTitleLayout->addWidget(pFit); @@ -260,6 +265,20 @@ ZenoImagePanel::ZenoImagePanel(QWidget *parent) : QWidget(parent) { } } }); + connect(pAlpha, &QCheckBox::stateChanged, this, [=](int state) { + std::string prim_name = pPrimName->text().toStdString(); + Zenovis* zenovis = wids[0]->getZenoVis(); + ZASSERT_EXIT(zenovis); + auto session = zenovis->getSession(); + ZASSERT_EXIT(session); + auto scene = session->get_scene(); + ZASSERT_EXIT(scene); + for (auto const &[key, ptr]: scene->objectsMan->pairs()) { + if (key.find(prim_name) == 0) { + setPrim(key); + } + } + }); connect(pFit, &QPushButton::clicked, this, [=](bool _) { image_view->fitMode = true; diff --git a/ui/zenoedit/panel/zenoimagepanel.h b/ui/zenoedit/panel/zenoimagepanel.h index 2e97311353..a9e18b71c2 100644 --- a/ui/zenoedit/panel/zenoimagepanel.h +++ b/ui/zenoedit/panel/zenoimagepanel.h @@ -14,6 +14,7 @@ class ZenoImagePanel : public QWidget { QLabel* pStatusBar = new QLabel(); QLabel* pPrimName = new QLabel(); QCheckBox *pGamma = new QCheckBox("Gamma"); + QCheckBox *pAlpha = new QCheckBox("Checkerboard"); QPushButton *pFit = new QPushButton("Fit"); ZenoImageView *image_view = nullptr;