Skip to content

Commit

Permalink
ImageAlphacheckboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashheer committed Sep 19, 2023
1 parent 0d8f14a commit 233e5c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ui/zenoedit/panel/zenoimagepanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<float>("alpha");
for (auto i = 0; i < obj->verts.size(); i++) {
int h = i / width;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ui/zenoedit/panel/zenoimagepanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 233e5c9

Please sign in to comment.