Skip to content

Commit

Permalink
Merge pull request #1453 from ziqidong/master
Browse files Browse the repository at this point in the history
change always combobox to button
  • Loading branch information
legobadman authored Oct 9, 2023
2 parents 7c33474 + 3f04603 commit a702df7
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 57 deletions.
109 changes: 55 additions & 54 deletions ui/zenoedit/dock/docktabcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,17 @@ ZToolMenuButton::ZToolMenuButton() {
connect(run, &QAction::triggered, this, [=]() {
setText(tr("Run"));
this->setMinimumWidth(sizeHint().width());
emit runModeChanged();
});
connect(runLightCamera, &QAction::triggered, this, [=]() {
setText(tr("RunLightCamera"));
this->setMinimumWidth(sizeHint().width());
emit runModeChanged();
});
connect(runMaterial, &QAction::triggered, this, [=]() {
setText(tr("RunMaterial"));
this->setMinimumWidth(sizeHint().width());
emit runModeChanged();
});
menu->addAction(run);
menu->addAction(runLightCamera);
Expand Down Expand Up @@ -294,7 +297,6 @@ DockContent_Editor::DockContent_Editor(QWidget* parent)
, m_pEditor(nullptr)
, m_btnRun(nullptr)
, m_btnKill(nullptr)
, m_btnAlways(nullptr)
{
}

Expand All @@ -312,6 +314,7 @@ void DockContent_Editor::initToolbar(QHBoxLayout* pToolLayout)
pSearchBtn = new ZToolBarButton(true, ":/icons/toolbar_search_idle.svg", ":/icons/toolbar_search_light.svg");
pSettings = new ZToolBarButton(false, ":/icons/toolbar_localSetting_idle.svg", ":/icons/toolbar_localSetting_light.svg");
pLinkLineShape = new ZToolBarButton(true, ":/icons/timeline-curvemap.svg",":/icons/timeline-curvemap.svg");
pAlways = new ZToolBarButton(true, ":/icons/Always.svg", ":/icons/AlwaysOn.svg");

pListView->setToolTip(tr("Subnet List"));
pTreeView->setToolTip(tr("Node List"));
Expand All @@ -322,6 +325,7 @@ void DockContent_Editor::initToolbar(QHBoxLayout* pToolLayout)
pGroup->setToolTip(tr("Create Group"));
pSearchBtn->setToolTip(tr("Search"));
pSettings->setToolTip(tr("Settings"));
pAlways->setToolTip(tr("Always mode"));

m_btnRun = new ZToolMenuButton;
m_btnKill = new ZToolButton;
Expand Down Expand Up @@ -356,59 +360,7 @@ void DockContent_Editor::initToolbar(QHBoxLayout* pToolLayout)
m_btnKill->setCursor(QCursor(Qt::PointingHandCursor));
m_btnKill->setEnabled(false);

QStringList runList{tr("disable"), tr("alwaysAll"), tr("alwaysLightCamera"), tr("alwaysMaterial")};
m_btnAlways = new ZComboBox(this);
m_btnAlways->addItems(runList);
m_btnAlways->setEditable(false);
m_btnAlways->setFixedHeight(ZenoStyle::dpiScaled(22));
m_btnAlways->setFont(fnt);
m_btnAlways->setProperty("focusBorder", "none");
QFontMetrics fontMetrics(fnt);
m_btnAlways->view()->setMinimumWidth(fontMetrics.horizontalAdvance(tr("alwaysLightCamera")) + ZenoStyle::dpiScaled(30));
QObject::connect(m_btnAlways, &ZComboBox::_textActivated, [=](const QString &text) {
std::shared_ptr<ZCacheMgr> mgr = zenoApp->cacheMgr();
ZASSERT_EXIT(mgr);
mgr->setCacheOpt(ZCacheMgr::Opt_AlwaysOn);
ZenoMainWindow *pMainWin = zenoApp->getMainWindow();
ZASSERT_EXIT(pMainWin);
std::function<void()> resetAlways = [=]() {
m_btnAlways->setCurrentText(tr("disable"));
pMainWin->setAlwaysLightCameraMaterial(false, false);
};
QVector<DisplayWidget *> views = pMainWin->viewports();
for (auto displayWid : views) {
if (!displayWid->isGLViewport()) {
displayWid->setRenderSeparately(false, false);
}
}
connect(zenoApp->graphsManagment(), &GraphsManagment::fileOpened, this, resetAlways);
connect(zenoApp->graphsManagment(), &GraphsManagment::modelInited, this, resetAlways);
if (text == tr("alwaysAll"))
{
pMainWin->setAlways(true);
pMainWin->setAlwaysLightCameraMaterial(false, false);
}
else if (text == tr("alwaysLightCamera") || text == tr("alwaysMaterial")) {
QSettings settings(zsCompanyName, zsEditor);
if (!settings.value("zencache-enable").toBool()) {
QMessageBox::warning(nullptr, text, tr("This function can only be used in cache mode."));
m_btnAlways->setCurrentIndex(0);
} else {
if (text == tr("alwaysLightCamera")) {
pMainWin->setAlwaysLightCameraMaterial(true, false);
} else if (text == tr("alwaysMaterial")) {
pMainWin->setAlwaysLightCameraMaterial(false, true);
}
pMainWin->setAlways(false);
}
}
else {
pMainWin->setAlways(false);
pMainWin->setAlwaysLightCameraMaterial(false, false);
}
m_btnAlways->setFixedWidth(fontMetrics.horizontalAdvance(text) + ZenoStyle::dpiScaled(26));
});
m_btnAlways->setFixedWidth(fontMetrics.horizontalAdvance(tr("disable")) + ZenoStyle::dpiScaled(26));

pListView->setChecked(false);
pShowGrid->setChecked(ZenoSettingsManager::GetInstance().getValue(zsShowGrid).toBool());
Expand Down Expand Up @@ -459,10 +411,10 @@ void DockContent_Editor::initToolbar(QHBoxLayout* pToolLayout)
pToolLayout->addWidget(pCustomParam);
pToolLayout->addWidget(pGroup);
pToolLayout->addWidget(pLinkLineShape);
pToolLayout->addWidget(pAlways);

pToolLayout->addWidget(new ZLineWidget(false, QColor("#121416")));

pToolLayout->addWidget(m_btnAlways);
pToolLayout->addWidget(m_btnRun);
pToolLayout->addWidget(m_btnKill);

Expand Down Expand Up @@ -532,6 +484,52 @@ void DockContent_Editor::initConnections()
connect(pLinkLineShape, &ZToolBarButton::toggled, this, [=](bool bChecked) {
ZenoSettingsManager::GetInstance().setValue(zsLinkLineShape, bChecked);
});

ZenoMainWindow* pMainWin = zenoApp->getMainWindow();
ZASSERT_EXIT(pMainWin);
std::function<void()> resetAlways = [=]() {
pAlways->toggle(false);
pMainWin->setAlways(false);
pMainWin->setAlwaysLightCameraMaterial(false, false);
};
connect(zenoApp->graphsManagment(), &GraphsManagment::fileOpened, this, resetAlways);
connect(zenoApp->graphsManagment(), &GraphsManagment::modelInited, this, resetAlways);
connect(m_btnRun, &ZToolMenuButton::runModeChanged, this, [=]() {
if (pAlways->isChecked())
emit pAlways->toggled(true);
});
connect(pAlways, &ZToolBarButton::toggled, this, [=](bool bChecked) {
if (bChecked)
{
QSettings settings(zsCompanyName, zsEditor);
if (!settings.value("zencache-enable").toBool()) {
QMessageBox::warning(nullptr, tr("RunLightCamera"), tr("This function can only be used in cache mode."));
return;
}
QVector<DisplayWidget*> views = pMainWin->viewports();
for (auto displayWid : views) {
if (!displayWid->isGLViewport()) {
displayWid->setRenderSeparately(false, false);
}
}
if (m_btnRun->text() == tr("Run"))
{
pMainWin->setAlways(true);
pMainWin->setAlwaysLightCameraMaterial(false, false);
}
else {
if (m_btnRun->text() == tr("RunLightCamera"))
pMainWin->setAlwaysLightCameraMaterial(true, false);
else if (m_btnRun->text() == tr("RunMaterial"))
pMainWin->setAlwaysLightCameraMaterial(false, true);
pMainWin->setAlways(false);
}
}
else {
pMainWin->setAlways(false);
pMainWin->setAlwaysLightCameraMaterial(false, false);
}
});
connect(m_pEditor, &ZenoGraphsEditor::zoomed, [=](qreal newFactor) {
QString percent = QString::number(int(newFactor * 100));
percent += "%";
Expand All @@ -553,6 +551,9 @@ void DockContent_Editor::initConnections()
});

connect(m_btnRun, &ZToolMenuButton::clicked, this, [=]() {
IGraphsModel* pGraphsModel = zenoApp->graphsManagment()->currentModel();
if (!pGraphsModel)
return;
m_btnRun->setEnabled(false);
m_btnKill->setEnabled(true);
std::shared_ptr<ZCacheMgr> mgr = zenoApp->cacheMgr();
Expand Down
5 changes: 4 additions & 1 deletion ui/zenoedit/dock/docktabcontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class ZToolMenuButton : public ZToolButton {
public:
ZToolMenuButton();

signals:
void runModeChanged();

protected:
virtual void mouseReleaseEvent(QMouseEvent* e) override;
virtual QSize sizeHint() const override;
Expand Down Expand Up @@ -111,12 +114,12 @@ class DockContent_Editor : public DockToolbarWidget
ZToolBarButton *pCustomParam;
ZToolBarButton *pGroup;
ZToolBarButton *pLinkLineShape;
ZToolBarButton *pAlways;
ZToolBarButton *pSearchBtn;
ZToolBarButton *pSettings;

ZToolMenuButton *m_btnRun;
ZToolButton* m_btnKill;
ZComboBox *m_btnAlways;

QComboBox* cbZoom;
};
Expand Down
2 changes: 2 additions & 0 deletions ui/zenoedit/res/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@
<file>icons/subnet-general.svg</file>
<file>icons/always-on.svg</file>
<file>icons/always-off.svg</file>
<file>icons/Always.svg</file>
<file>icons/AlwaysOn.svg</file>
<file>icons/run-off.svg</file>
<file>icons/run-on.svg</file>
<file>icons/kill-on.svg</file>
Expand Down
6 changes: 6 additions & 0 deletions ui/zenoedit/res/icons/Always.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions ui/zenoedit/res/icons/AlwaysOn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ui/zenoedit/res/languages/zh.qm
Binary file not shown.
4 changes: 4 additions & 0 deletions ui/zenoedit/res/languages/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
<source>Curve Link</source>
<translation>曲线连接</translation>
</message>
<message>
<source>Always mode</source>
<translation>预览模式</translation>
</message>
</context>
<context>
<name>DockContent_Log</name>
Expand Down
10 changes: 8 additions & 2 deletions zenovis/src/optx/RenderEngineOptx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,15 @@ struct RenderEngineOptx : RenderEngine, zeno::disable_copy {
xinxinoptix::cleanupSpheresCPU();

xinxinoptix::optixupdateend();
std::cout<<"Finish optix update" << std::endl;
std::cout<< "Finish optix update" << std::endl;
}


if (scene->drawOptions->updateMatlOnly && !bMeshMatLUTChanged)
{
xinxinoptix::optixupdateend();
std::cout << "Finish optix update" << std::endl;
}

}

if(lightNeedUpdate){
Expand Down

0 comments on commit a702df7

Please sign in to comment.