丰富配置面板
This commit is contained in:
parent
8d42261f18
commit
7614790ce2
|
@ -4,33 +4,20 @@
|
|||
ActionNodeConfiguration::ActionNodeConfiguration(QWidget* p)
|
||||
:QFrame(p),
|
||||
_execute_select(new QComboBox(this)),
|
||||
_variables_input(new QTableView(this)),
|
||||
_input_model(new QStandardItemModel(this)),
|
||||
_variables_output(new QTableView(this)),
|
||||
_output_model(new QStandardItemModel(this))
|
||||
_vars_configuration(new VariablesConfigurationPanel(this))
|
||||
{
|
||||
this->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
|
||||
auto p_layout = new QGridLayout(this);
|
||||
|
||||
p_layout->addWidget(new QLabel(u8"执行器类型:", this));
|
||||
p_layout->addWidget(_execute_select, 0, 1, 1, 4);
|
||||
auto vars_tabw = new QTabWidget(this);
|
||||
p_layout->addWidget(vars_tabw, 1, 0, 3, 5);
|
||||
vars_tabw->setTabPosition(QTabWidget::West);
|
||||
|
||||
vars_tabw->addTab(_variables_input, u8"输入变量");
|
||||
_variables_input->setModel(_input_model);
|
||||
vars_tabw->addTab(_variables_output, u8"输出变量");
|
||||
_variables_output->setModel(_output_model);
|
||||
p_layout->addWidget(_vars_configuration, 1, 0, 3, 5);
|
||||
|
||||
p_layout->setColumnStretch(1, 1);
|
||||
|
||||
_input_model->setHorizontalHeaderLabels(QStringList()
|
||||
<< u8"变量名" << u8"变量类型" << u8"关联转换器类型"<< u8"关联输入序列" );
|
||||
_output_model->setHorizontalHeaderLabels(QStringList()
|
||||
<< u8"变量名" << u8"变量类型" << u8"关联转换器类型"<< u8"关联目标变量" );
|
||||
}
|
||||
|
||||
#include "BehaviorEditor.h"
|
||||
void ActionNodeConfiguration::setTarget(NodePresent* ins)
|
||||
{
|
||||
this->_vars_configuration->bindNode(ins->logicalBind());
|
||||
}
|
||||
|
|
|
@ -6,15 +6,16 @@
|
|||
#include <QTableView>
|
||||
#include <qstandarditemmodel.h>
|
||||
#include "sims_world.h"
|
||||
#include "VariablesConfiguration.h"
|
||||
|
||||
/// <summary>
|
||||
/// 动作执行节点配置面板
|
||||
/// </summary>
|
||||
class ActionNodeConfiguration : public QFrame, public NodeConfiguration
|
||||
{
|
||||
private:
|
||||
QComboBox *const _execute_select;
|
||||
QTableView* const _variables_input;
|
||||
QStandardItemModel *const _input_model;
|
||||
QTableView* const _variables_output;
|
||||
QStandardItemModel* const _output_model;
|
||||
VariablesConfigurationPanel *const _vars_configuration;
|
||||
|
||||
public:
|
||||
ActionNodeConfiguration(QWidget *p = nullptr);
|
||||
|
|
|
@ -2,15 +2,26 @@
|
|||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QStackedWidget>
|
||||
#include "VariablesConfiguration.h"
|
||||
|
||||
BehaviorMapConfigurationPanel::BehaviorMapConfigurationPanel(QWidget* p)
|
||||
:QFrame(p),
|
||||
_stacked_widget(new QStackedWidget(this)),
|
||||
_root_name(new QLineEdit(this)),
|
||||
_select_map(new QComboBox(this)),
|
||||
_variable_table(new QTableView(this)),
|
||||
_variable_model(new QStandardItemModel(this))
|
||||
_variable_model(new QStandardItemModel(this)),
|
||||
_output_panel(new VariablesConfigurationPanel(this))
|
||||
{
|
||||
setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
|
||||
auto p_layout = new QGridLayout(this);
|
||||
auto vlayout = new QVBoxLayout(this);
|
||||
vlayout->addWidget(_stacked_widget);
|
||||
|
||||
// 内部变量编辑面板
|
||||
auto internal_edit = new QWidget(this);
|
||||
_stacked_widget->addWidget(internal_edit);
|
||||
auto p_layout = new QGridLayout(internal_edit);
|
||||
p_layout->addWidget(new QLabel(u8"行为树名称:", this));
|
||||
p_layout->addWidget(_root_name, 0, 1, 1, 3);
|
||||
|
||||
|
@ -25,12 +36,19 @@ BehaviorMapConfigurationPanel::BehaviorMapConfigurationPanel(QWidget* p)
|
|||
<< u8"输入/输出" << u8"变量名" << u8"变量类型");
|
||||
|
||||
p_layout->setColumnStretch(1, 1);
|
||||
|
||||
|
||||
connect(addVar, &QPushButton::clicked, [=](){
|
||||
VariableAdd dia(this->_bind_node, this);
|
||||
dia.exec();
|
||||
});
|
||||
|
||||
// 外部变量编辑面板
|
||||
auto outlinks_edit = new QWidget(this);
|
||||
_stacked_widget->addWidget(outlinks_edit);
|
||||
p_layout = new QGridLayout(outlinks_edit);
|
||||
p_layout->addWidget(new QLabel(u8"行为树名称:", this));
|
||||
p_layout->addWidget(_select_map, 0, 1, 1, 3);
|
||||
p_layout->addWidget(_output_panel, 1, 0, 3, 4);
|
||||
p_layout->setColumnStretch(1, 1);
|
||||
}
|
||||
|
||||
#include <BehaviorEditor.h>
|
||||
|
@ -38,47 +56,56 @@ void BehaviorMapConfigurationPanel::setTarget(NodePresent* ins)
|
|||
{
|
||||
this->_bind_graph = ins;
|
||||
this->_bind_node = std::dynamic_pointer_cast<BehaviorMapNode>(ins->logicalBind());
|
||||
_variable_model->removeRows(0, _variable_model->rowCount());
|
||||
|
||||
_root_name->setText(_bind_node->typeName());
|
||||
for (auto key : _bind_node->inputVariableKeys()) {
|
||||
auto ins_prop = _bind_node->getVariable(key);
|
||||
QList<QStandardItem*> row;
|
||||
row << new QStandardItem(u8"ĘäČë");
|
||||
row << new QStandardItem(key);
|
||||
row << new QStandardItem(ins_prop->topicString());
|
||||
std::for_each(row.begin(), row.end(),
|
||||
[](QStandardItem* ins) {ins->setEditable(false); }
|
||||
);
|
||||
if (this->_bind_node && !this->_bind_node->bindMap()) {
|
||||
_stacked_widget->setCurrentIndex(0);
|
||||
_variable_model->removeRows(0, _variable_model->rowCount());
|
||||
|
||||
_variable_model->appendRow(row);
|
||||
_root_name->setText(_bind_node->typeName());
|
||||
for (auto key : _bind_node->inputVariableKeys()) {
|
||||
auto ins_prop = _bind_node->getVariable(key);
|
||||
QList<QStandardItem*> row;
|
||||
row << new QStandardItem(u8"输入");
|
||||
row << new QStandardItem(key);
|
||||
row << new QStandardItem(ins_prop->topicString());
|
||||
std::for_each(row.begin(), row.end(),
|
||||
[](QStandardItem* ins) {ins->setEditable(false); }
|
||||
);
|
||||
|
||||
_variable_model->appendRow(row);
|
||||
}
|
||||
|
||||
for (auto key : _bind_node->outputVariableKeys()) {
|
||||
auto ins_prop = _bind_node->getVariable(key);
|
||||
QList<QStandardItem*> row;
|
||||
row << new QStandardItem(u8"输出");
|
||||
row << new QStandardItem(key);
|
||||
row << new QStandardItem(ins_prop->topicString());
|
||||
std::for_each(row.begin(), row.end(),
|
||||
[](QStandardItem* ins) { ins->setEditable(false); }
|
||||
);
|
||||
|
||||
_variable_model->appendRow(row);
|
||||
}
|
||||
|
||||
for (auto key : _bind_node->internalVariableKeys()) {
|
||||
auto ins_prop = _bind_node->getVariable(key);
|
||||
QList<QStandardItem*> row;
|
||||
row << new QStandardItem(u8"内部");
|
||||
row << new QStandardItem(key);
|
||||
row << new QStandardItem(ins_prop->topicString());
|
||||
std::for_each(row.begin(), row.end(),
|
||||
[](QStandardItem* ins) {ins->setEditable(false); }
|
||||
);
|
||||
|
||||
_variable_model->appendRow(row);
|
||||
}
|
||||
}
|
||||
else if (this->_bind_node) {
|
||||
_stacked_widget->setCurrentIndex(1);
|
||||
this->_output_panel->bindNode(this->_bind_node);
|
||||
}
|
||||
|
||||
for (auto key : _bind_node->outputVariableKeys()) {
|
||||
auto ins_prop = _bind_node->getVariable(key);
|
||||
QList<QStandardItem*> row;
|
||||
row << new QStandardItem(u8"Ęäłö");
|
||||
row << new QStandardItem(key);
|
||||
row << new QStandardItem(ins_prop->topicString());
|
||||
std::for_each(row.begin(), row.end(),
|
||||
[](QStandardItem* ins) { ins->setEditable(false); }
|
||||
);
|
||||
|
||||
_variable_model->appendRow(row);
|
||||
}
|
||||
|
||||
for (auto key : _bind_node->internalVariableKeys()) {
|
||||
auto ins_prop = _bind_node->getVariable(key);
|
||||
QList<QStandardItem*> row;
|
||||
row << new QStandardItem(u8"ÄÚ˛ż");
|
||||
row << new QStandardItem(key);
|
||||
row << new QStandardItem(ins_prop->topicString());
|
||||
std::for_each(row.begin(), row.end(),
|
||||
[](QStandardItem* ins) {ins->setEditable(false); }
|
||||
);
|
||||
|
||||
_variable_model->appendRow(row);
|
||||
}
|
||||
}
|
||||
|
||||
VariableAdd::VariableAdd(std::shared_ptr<BehaviorMapNode> node, QWidget* parent)
|
||||
|
|
|
@ -24,14 +24,21 @@ public:
|
|||
};
|
||||
|
||||
class NodePresent;
|
||||
class VariablesConfigurationPanel;
|
||||
#include <QStackedWidget>
|
||||
class BehaviorMapConfigurationPanel : public QFrame, public NodeConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QStackedWidget *const _stacked_widget;
|
||||
|
||||
QLineEdit *const _root_name;
|
||||
QComboBox *const _select_map;
|
||||
QTableView *const _variable_table;
|
||||
QStandardItemModel *const _variable_model;
|
||||
|
||||
VariablesConfigurationPanel *const _output_panel;
|
||||
|
||||
std::shared_ptr<BehaviorMapNode> _bind_node; // 绑定内容结点
|
||||
NodePresent *_bind_graph = nullptr; // 绑定图形显示结点
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@
|
|||
<ClCompile Include="ModifyNodeConfiguration.cpp" />
|
||||
<ClCompile Include="PerspectiveView.cpp" />
|
||||
<ClCompile Include="TempletAssemble.cpp" />
|
||||
<ClCompile Include="VariablesConfiguration.cpp" />
|
||||
<QtRcc Include="sims_world.qrc" />
|
||||
<QtUic Include="sims_world.ui" />
|
||||
<QtMoc Include="sims_world.h" />
|
||||
|
@ -124,6 +125,7 @@
|
|||
<ClInclude Include="ActionNodeConfiguration.h" />
|
||||
<ClInclude Include="CompareNodeConfiguration.h" />
|
||||
<ClInclude Include="ModifyNodeConfiguration.h" />
|
||||
<ClInclude Include="VariablesConfiguration.h" />
|
||||
<QtMoc Include="BehaviorConfigurationPanel.h" />
|
||||
<QtMoc Include="BehaviorEditor.h" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -67,6 +67,9 @@
|
|||
<ClCompile Include="ModifyNodeConfiguration.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VariablesConfiguration.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="TempletAssemble.h">
|
||||
|
@ -92,5 +95,8 @@
|
|||
<ClInclude Include="ModifyNodeConfiguration.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VariablesConfiguration.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,37 @@
|
|||
#include "VariablesConfiguration.h"
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
||||
VariablesConfigurationPanel::VariablesConfigurationPanel(QWidget* p /*= nullptr*/)
|
||||
:QWidget(p),
|
||||
_input_vars_model(new QStandardItemModel(this)),
|
||||
_output_vars_model(new QStandardItemModel(this)),
|
||||
_input_table(new QTableView(this)),
|
||||
_output_table(new QTableView(this))
|
||||
{
|
||||
auto vbox = new QVBoxLayout(this);
|
||||
|
||||
auto tabw = new QTabWidget(this);
|
||||
vbox->addWidget(tabw);
|
||||
|
||||
tabw->addTab(_input_table, u8"输入变量");
|
||||
tabw->addTab(_output_table, u8"输出变量");
|
||||
tabw->setTabPosition(QTabWidget::West);
|
||||
|
||||
vbox->setMargin(0);
|
||||
_input_table->setModel(_input_vars_model);
|
||||
_output_table->setModel(_output_vars_model);
|
||||
_input_vars_model->setHorizontalHeaderLabels(QStringList()
|
||||
<< u8"变量名" << u8"变量类型" << u8"关联转换器类型" << u8"关联输入序列");
|
||||
_output_vars_model->setHorizontalHeaderLabels(QStringList()
|
||||
<< u8"变量名" << u8"变量类型" << u8"关联转换器类型" << u8"关联目标变量");
|
||||
}
|
||||
|
||||
#include <QDebug>
|
||||
void VariablesConfigurationPanel::bindNode(std::shared_ptr<LogicalNode> inst)
|
||||
{
|
||||
this->_active_node = inst;
|
||||
|
||||
qDebug() << __FILE__ << __LINE__ << inst->rtName();
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTableView>
|
||||
#include <BehaviorPerform.h>
|
||||
|
||||
/// <summary>
|
||||
/// ½Úµã±äÁ¿ÅäÖÃÃæ°å
|
||||
/// </summary>
|
||||
class VariablesConfigurationPanel : public QWidget
|
||||
{
|
||||
private:
|
||||
QStandardItemModel* const _input_vars_model;
|
||||
QStandardItemModel* const _output_vars_model;
|
||||
QTableView *const _input_table;
|
||||
QTableView *const _output_table;
|
||||
|
||||
std::shared_ptr<LogicalNode> _active_node = nullptr;
|
||||
|
||||
public:
|
||||
VariablesConfigurationPanel(QWidget *p = nullptr);
|
||||
|
||||
void bindNode(std::shared_ptr<LogicalNode> inst);
|
||||
};
|
||||
|
Loading…
Reference in New Issue