Skip to content

Commit ff5ac33

Browse files
author
Davide Faconti
committed
FIx issue #98
1 parent bb237bd commit ff5ac33

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

bt_editor/mainwindow.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,13 @@ MainWindow::MainWindow(GraphicMode initial_mode, QWidget *parent) :
162162
}
163163
});
164164

165+
auto createSingleTabBehaviorTree = [this](const AbsBehaviorTree &tree, const QString &bt_name)
166+
{
167+
onCreateAbsBehaviorTree(tree, bt_name, false);
168+
};
169+
165170
connect( _replay_widget, &SidepanelReplay::loadBehaviorTree,
166-
this, &MainWindow::onCreateAbsBehaviorTree );
171+
this, createSingleTabBehaviorTree);
167172

168173
connect( _replay_widget, &SidepanelReplay::addNewModel,
169174
this, &MainWindow::onAddToModelRegistry);
@@ -183,7 +188,7 @@ MainWindow::MainWindow(GraphicMode initial_mode, QWidget *parent) :
183188
this, &MainWindow::onChangeNodesStatus);
184189

185190
connect( _monitor_widget, &SidepanelMonitor::loadBehaviorTree,
186-
this, &MainWindow::onCreateAbsBehaviorTree );
191+
this, createSingleTabBehaviorTree );
187192
#endif
188193

189194
ui->tabWidget->tabBar()->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -246,7 +251,10 @@ GraphicContainer* MainWindow::createTab(const QString &name)
246251
this, &MainWindow::onRequestSubTreeExpand );
247252

248253
connect( ti, &GraphicContainer::requestSubTreeCreate,
249-
this, &MainWindow::onCreateAbsBehaviorTree);
254+
this, [this](const AbsBehaviorTree &tree, const QString &bt_name)
255+
{
256+
onCreateAbsBehaviorTree(tree, bt_name, false);
257+
});
250258

251259
connect( ti, &GraphicContainer::addNewModel,
252260
this, &MainWindow::onAddToModelRegistry);
@@ -1120,7 +1128,9 @@ void MainWindow::clearUndoStacks()
11201128
onPushUndo();
11211129
}
11221130

1123-
void MainWindow::onCreateAbsBehaviorTree(const AbsBehaviorTree &tree, const QString &bt_name)
1131+
void MainWindow::onCreateAbsBehaviorTree(const AbsBehaviorTree &tree,
1132+
const QString &bt_name,
1133+
bool secondary_tabs)
11241134
{
11251135
auto container = getTabByName(bt_name);
11261136
if( !container )
@@ -1131,15 +1141,16 @@ void MainWindow::onCreateAbsBehaviorTree(const AbsBehaviorTree &tree, const QStr
11311141
container->loadSceneFromTree( tree );
11321142
container->nodeReorder();
11331143

1134-
for(const auto& node: tree.nodes())
1135-
{
1144+
if( secondary_tabs ){
1145+
for(const auto& node: tree.nodes())
1146+
{
11361147
if( node.model.type == NodeType::SUBTREE && getTabByName(node.model.registration_ID) == nullptr)
11371148
{
1138-
createTab(node.model.registration_ID);
1149+
createTab(node.model.registration_ID);
11391150
}
1151+
}
11401152
}
11411153

1142-
// TODO_ clear or not?
11431154
clearUndoStacks();
11441155
}
11451156

bt_editor/mainwindow.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ public slots:
9494

9595
void on_toolButtonCenterView_pressed();
9696

97-
void onCreateAbsBehaviorTree(const AbsBehaviorTree &tree, const QString &bt_name);
97+
void onCreateAbsBehaviorTree(const AbsBehaviorTree &tree,
98+
const QString &bt_name,
99+
bool secondary_tabs = true);
98100

99101
void onChangeNodesStatus(const QString& bt_name, const std::vector<std::pair<int, NodeStatus>>& node_status);
100102

0 commit comments

Comments
 (0)