Skip to content

Commit

Permalink
Merge pull request #1603 from 1445643474/master
Browse files Browse the repository at this point in the history
preset regularTypeMat and carPaintTypeMat
  • Loading branch information
zhxx1987 authored Dec 11, 2023
2 parents 865e98b + 010df00 commit c8d15f4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
36 changes: 35 additions & 1 deletion ui/zenoedit/nodesview/zenographseditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ void ZenoGraphsEditor::initSignals()
connect(m_ui->graphsViewTab, &QTabWidget::tabCloseRequested, this, [=](int index) {
m_ui->graphsViewTab->removeTab(index);
});
connect(m_ui->graphsViewTab, &QTabWidget::currentChanged, this, [=](int index) {
if (m_ui->graphsViewTab->tabText(index).compare("main", Qt::CaseInsensitive) == 0)
{
ZenoSettingsManager::GetInstance().setValue(zsSubgraphType, SUBGRAPH_NOR);
}
});
connect(m_ui->searchEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onSearchEdited(const QString&)));
connect(m_ui->searchResView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(onSearchItemClicked(const QModelIndex&)));

Expand Down Expand Up @@ -190,6 +196,8 @@ void ZenoGraphsEditor::resetModel(IGraphsModel* pModel)
proxyModel->invalidate();
int type = ZenoSettingsManager::GetInstance().getValue(zsName).toInt();
m_ui->label->setText(type == SUBGRAPH_TYPE::SUBGRAPH_NOR ? tr("Subnet") : type == SUBGRAPH_TYPE::SUBGRAPH_METERIAL ? tr("Material Subnet") : tr("Preset Subnet"));
if (type != SUBGRAPH_METERIAL)
closeMaterialTab();
}
});
activateTab("main");
Expand Down Expand Up @@ -469,6 +477,25 @@ int ZenoGraphsEditor::tabIndexOfName(const QString& subGraphName)
return -1;
}

void ZenoGraphsEditor::closeMaterialTab()
{
for (int i = 0; i < m_ui->graphsViewTab->count(); i++)
{
QString subGraphName = m_ui->graphsViewTab->tabText(i);
auto graphsMgm = zenoApp->graphsManagment();
IGraphsModel* pModel = graphsMgm->currentModel();
ZASSERT_EXIT(pModel);
if (pModel->index(subGraphName).isValid())
{
if (pModel->index(subGraphName).data(ROLE_SUBGRAPH_TYPE).toInt() == SUBGRAPH_METERIAL)
{
m_ui->graphsViewTab->removeTab(i);
break;
}
}
}
}

void ZenoGraphsEditor::onListItemActivated(const QModelIndex& index)
{
const QString& subgraphName = index.data().toString();
Expand Down Expand Up @@ -525,11 +552,18 @@ void ZenoGraphsEditor::activateTab(const QString& subGraphName, const QString& p

if (!pModel->index(subGraphName).isValid())
return;

if (subGraphName.compare("main", Qt::CaseInsensitive) == 0)
{
closeMaterialTab();
}
int idx = tabIndexOfName(subGraphName);
if (idx == -1)
{
const QModelIndex& subgIdx = pModel->index(subGraphName);
if (subgIdx.data(ROLE_SUBGRAPH_TYPE).toInt() == SUBGRAPH_METERIAL)
{
closeMaterialTab();
}

ZenoSubGraphScene* pScene = qobject_cast<ZenoSubGraphScene*>(graphsMgm->gvScene(subgIdx));
if (!pScene)
Expand Down
1 change: 1 addition & 0 deletions ui/zenoedit/nodesview/zenographseditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private slots:
void toggleViewForSelected(bool bOn);
int tabIndexOfName(const QString& subGraphName);
void markSubgError(const QStringList &lst);
void closeMaterialTab();

ZenoMainWindow* m_mainWin;
Ui::GraphsEditor* m_ui;
Expand Down
12 changes: 10 additions & 2 deletions ui/zenoedit/panel/zenospreadsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ ZenoSpreadsheet::ZenoSpreadsheet(QWidget *parent) : QWidget(parent) {
});

connect(prim_attr_view, &QTableView::doubleClicked, this, [=](const QModelIndex& index) {
int type = ZenoSettingsManager::GetInstance().getValue(zsSubgraphType).toInt();
QString label = prim_attr_view->model()->headerData(index.row(), Qt::Vertical).toString();
if (type == SUBGRAPH_METERIAL && label.contains("Material", Qt::CaseInsensitive))
if (label.contains("Material", Qt::CaseInsensitive))
{
QString mtlid = index.data(Qt::DisplayRole).toString();
IGraphsModel* pGraphsModel = zenoApp->graphsManagment()->currentModel();
Expand All @@ -131,6 +130,7 @@ ZenoSpreadsheet::ZenoSpreadsheet(QWidget *parent) : QWidget(parent) {
QString subgraph_name = subgIdx.data(ROLE_OBJNAME).toString();
ZenoMainWindow* pWin = zenoApp->getMainWindow();
if (pWin) {
ZenoSettingsManager::GetInstance().setValue(zsSubgraphType, SUBGRAPH_METERIAL);
ZenoGraphsEditor* pEditor = pWin->getAnyEditor();
if (pEditor)
pEditor->activateTab(subgraph_name, "", "");
Expand Down Expand Up @@ -273,6 +273,14 @@ bool ZenoSpreadsheet::eventFilter(QObject* watched, QEvent* event)
{
map[mtlid] = "TransmitTypeMat";
}
else if (mtlid.contains("Paint", Qt::CaseInsensitive))
{
map[mtlid] = "CarPaintTypeMat";
}
else
{
map[mtlid] = "RegularTypeMat";
}
}
ZForkSubgraphDlg dlg(map, this);
dlg.exec();
Expand Down

0 comments on commit c8d15f4

Please sign in to comment.