diff --git a/ui/zenoedit/dock/docktabcontent.cpp b/ui/zenoedit/dock/docktabcontent.cpp index ff62ef3846..dd297c26e0 100644 --- a/ui/zenoedit/dock/docktabcontent.cpp +++ b/ui/zenoedit/dock/docktabcontent.cpp @@ -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); @@ -294,7 +297,6 @@ DockContent_Editor::DockContent_Editor(QWidget* parent) , m_pEditor(nullptr) , m_btnRun(nullptr) , m_btnKill(nullptr) - , m_btnAlways(nullptr) { } @@ -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")); @@ -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; @@ -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 mgr = zenoApp->cacheMgr(); - ZASSERT_EXIT(mgr); - mgr->setCacheOpt(ZCacheMgr::Opt_AlwaysOn); - ZenoMainWindow *pMainWin = zenoApp->getMainWindow(); - ZASSERT_EXIT(pMainWin); - std::function resetAlways = [=]() { - m_btnAlways->setCurrentText(tr("disable")); - pMainWin->setAlwaysLightCameraMaterial(false, false); - }; - QVector 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()); @@ -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); @@ -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 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 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 += "%"; @@ -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 mgr = zenoApp->cacheMgr(); diff --git a/ui/zenoedit/dock/docktabcontent.h b/ui/zenoedit/dock/docktabcontent.h index 60b8bcc801..5980be5a8a 100644 --- a/ui/zenoedit/dock/docktabcontent.h +++ b/ui/zenoedit/dock/docktabcontent.h @@ -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; @@ -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; }; diff --git a/ui/zenoedit/res/icons.qrc b/ui/zenoedit/res/icons.qrc index aea3353022..4a15ffd72a 100644 --- a/ui/zenoedit/res/icons.qrc +++ b/ui/zenoedit/res/icons.qrc @@ -182,6 +182,8 @@ icons/subnet-general.svg icons/always-on.svg icons/always-off.svg + icons/Always.svg + icons/AlwaysOn.svg icons/run-off.svg icons/run-on.svg icons/kill-on.svg diff --git a/ui/zenoedit/res/icons/Always.svg b/ui/zenoedit/res/icons/Always.svg new file mode 100644 index 0000000000..ed62aefc83 --- /dev/null +++ b/ui/zenoedit/res/icons/Always.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/ui/zenoedit/res/icons/AlwaysOn.svg b/ui/zenoedit/res/icons/AlwaysOn.svg new file mode 100644 index 0000000000..ed62aefc83 --- /dev/null +++ b/ui/zenoedit/res/icons/AlwaysOn.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/ui/zenoedit/res/languages/zh.qm b/ui/zenoedit/res/languages/zh.qm index baed5668b3..13c332d618 100644 Binary files a/ui/zenoedit/res/languages/zh.qm and b/ui/zenoedit/res/languages/zh.qm differ diff --git a/ui/zenoedit/res/languages/zh.ts b/ui/zenoedit/res/languages/zh.ts index 06a861f70d..58d1287fa2 100644 --- a/ui/zenoedit/res/languages/zh.ts +++ b/ui/zenoedit/res/languages/zh.ts @@ -255,6 +255,10 @@ Curve Link 曲线连接 + + Always mode + 预览模式 + DockContent_Log diff --git a/zenovis/src/optx/RenderEngineOptx.cpp b/zenovis/src/optx/RenderEngineOptx.cpp index 4289e43874..c776d55e87 100644 --- a/zenovis/src/optx/RenderEngineOptx.cpp +++ b/zenovis/src/optx/RenderEngineOptx.cpp @@ -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){