From 29a4b4dad4128f8d877c2d9a9df8ad7d3b483a26 Mon Sep 17 00:00:00 2001 From: codeboss <2422523675@qq.com> Date: Tue, 10 Jun 2025 23:44:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E9=80=8F=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ComponentBasic/EntityDocks.cpp | 4 ++ ComponentBasic/InvisibleComponent.cpp | 2 +- SimsBasic/internal_impl.cpp | 1 + SimsWorld.sln | 10 +++ SimsWorld/PerspectiveView.cpp | 98 +++++++++++++++++++++++++++ SimsWorld/PerspectiveView.h | 34 ++++++++++ SimsWorld/SimsWorld.vcxproj | 4 ++ SimsWorld/SimsWorld.vcxproj.filters | 6 ++ SimsWorld/TempletAssemble.cpp | 8 ++- SimsWorld/TempletAssemble.h | 9 ++- SimsWorld/main.cpp | 8 +-- SimsWorld/sims_world.cpp | 28 ++++++-- 12 files changed, 194 insertions(+), 18 deletions(-) create mode 100644 SimsWorld/PerspectiveView.cpp create mode 100644 SimsWorld/PerspectiveView.h diff --git a/ComponentBasic/EntityDocks.cpp b/ComponentBasic/EntityDocks.cpp index 5767ebe..56d3e8b 100644 --- a/ComponentBasic/EntityDocks.cpp +++ b/ComponentBasic/EntityDocks.cpp @@ -53,6 +53,8 @@ void DeduceFramework::init_framework() { auto mgr_e = std::make_shared(); mgr_e->append(this->shared_from_this()); + auto info_pulls = std::make_shared(); + mgr_e->append(info_pulls); this->_entity_map_over_0xffff[mgr_e->entityID()] = mgr_e; } @@ -160,6 +162,8 @@ void DeduceFramework::execute(std::shared_ptr map, auto ins = std::make_shared(); ins->reset(in->targetEntity(), in->sourceEntity()); ins->_component_types = this->_factory_ins->allComponentTypes(); + + ins->_entity_templets[NAME(RtEntityManager)] = RtEntityManager::const_id; for (auto ekey : this->_templets_within_0x2ff_0xffff.keys()) ins->_entity_templets[ekey] = this->_templets_within_0x2ff_0xffff[ekey]->entityID(); diff --git a/ComponentBasic/InvisibleComponent.cpp b/ComponentBasic/InvisibleComponent.cpp index 46889e2..20b77a2 100644 --- a/ComponentBasic/InvisibleComponent.cpp +++ b/ComponentBasic/InvisibleComponent.cpp @@ -44,7 +44,7 @@ void ComponentsInfoPull::execute(std::shared_ptr map, void ComponentsInfoPull::execute(std::shared_ptr map, std::shared_ptr in, QList>& out) { - auto ent_ins = std::dynamic_pointer_cast(this->_bind_entity.lock()); + auto ent_ins = std::dynamic_pointer_cast(this->_bind_entity.lock()); auto comps = ent_ins->components(); auto result = std::make_shared(); diff --git a/SimsBasic/internal_impl.cpp b/SimsBasic/internal_impl.cpp index 1e73415..86108ab 100644 --- a/SimsBasic/internal_impl.cpp +++ b/SimsBasic/internal_impl.cpp @@ -134,6 +134,7 @@ QString RtEntityManager::name() const } void RtEntityManager::append(std::shared_ptr ins) { + ins->bindEntity(this->shared_from_this()); _comps_list[ins->name()] = ins; } diff --git a/SimsWorld.sln b/SimsWorld.sln index f71c738..99d89dd 100644 --- a/SimsWorld.sln +++ b/SimsWorld.sln @@ -4,11 +4,21 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 17.13.35825.156 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimsWorld", "SimsWorld\SimsWorld.vcxproj", "{46E3FBA5-6775-4638-AE2E-935675D3B9CE}" + ProjectSection(ProjectDependencies) = postProject + {20CFC220-4F5B-4D39-97FA-74C70768F1A7} = {20CFC220-4F5B-4D39-97FA-74C70768F1A7} + {C4A07990-233A-46F5-A3A0-48544CABA594} = {C4A07990-233A-46F5-A3A0-48544CABA594} + {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0} = {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0} + {E1104048-F35B-40B7-995C-0320E689BF09} = {E1104048-F35B-40B7-995C-0320E689BF09} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimsBasic", "SimsBasic\SimsBasic.vcxproj", "{DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}" + ProjectSection(ProjectDependencies) = postProject + {C4A07990-233A-46F5-A3A0-48544CABA594} = {C4A07990-233A-46F5-A3A0-48544CABA594} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ComponentBasic", "ComponentBasic\ComponentBasic.vcxproj", "{20CFC220-4F5B-4D39-97FA-74C70768F1A7}" ProjectSection(ProjectDependencies) = postProject + {C4A07990-233A-46F5-A3A0-48544CABA594} = {C4A07990-233A-46F5-A3A0-48544CABA594} {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0} = {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0} {E1104048-F35B-40B7-995C-0320E689BF09} = {E1104048-F35B-40B7-995C-0320E689BF09} EndProjectSection diff --git a/SimsWorld/PerspectiveView.cpp b/SimsWorld/PerspectiveView.cpp new file mode 100644 index 0000000..23c4cb8 --- /dev/null +++ b/SimsWorld/PerspectiveView.cpp @@ -0,0 +1,98 @@ +#include "PerspectiveView.h" +#include +#include +#include +#include +#include + +void PerspectiveView::deduce_start() +{ + auto request = std::make_shared(); + request->reset(-1, RtEntityManager::const_id); + emit this->backend_deduce_request(request); +} + +void PerspectiveView::reply_accept(const QList>& msg_set) +{ + for (auto msg : msg_set) + { + if (msg->topicString() == TypesQueryResult().topicString()) { + _templet_model->clear(); + + auto ins_conv = std::dynamic_pointer_cast(msg); + for (auto sign : ins_conv->_entity_templets.keys()) { + auto cell = new QStandardItem(sign); + cell->setData(ins_conv->_entity_templets[sign]); + cell->setEditable(false); + _templet_model->appendRow(cell); + } + } + if (msg->topicString() == ProcedureSignatureQueryResult().topicString()) { + this->_procedure_model->removeRows(0, this->_procedure_model->rowCount()); + + auto ins_conv = std::dynamic_pointer_cast(msg); + for (auto fun_pair : ins_conv->_signature_list) { + QList row; + row << new QStandardItem(fun_pair.first); + row << new QStandardItem(fun_pair.second); + for(auto info : row) info->setEditable(false); + + this->_procedure_model->appendRow(row); + } + this->_procedure_view->resizeColumnsToContents(); + } + } +} + +void PerspectiveView::complete_accept(std::shared_ptr ins) {} + +void PerspectiveView::show_procedures_start(const QModelIndex& target) +{ + if (!target.isValid()) + return; + + auto templet_id = this->_templet_model->itemFromIndex(target)->data().toULongLong(); + auto ins = std::make_shared(); + ins->reset(-1, templet_id); + _bind_framework->accept(QList>{ins}); +} + +PerspectiveView::PerspectiveView(std::shared_ptr ins, QWidget* p /*= nullptr*/) + :QDialog(p), + _bind_framework(ins), + _bind_timer(new QTimer(this)), + _templet_types(new QListView(this)), + _templet_model(new QStandardItemModel(this)), + _procedure_view(new QTableView(this)), + _procedure_model(new QStandardItemModel(this)) +{ + connect(this, &PerspectiveView::backend_deduce_request, _bind_framework.get(), &DeduceFramework::deduceBegin); + connect(_bind_framework.get(), &DeduceFramework::reply, this, &PerspectiveView::reply_accept); + connect(_bind_framework.get(), &DeduceFramework::complete, this, &PerspectiveView::complete_accept); + connect(_templet_types, &QListView::clicked, this, &PerspectiveView::show_procedures_start); + + this->setWindowTitle(u8"调用透视视图"); + this->setMinimumSize(800, 600); + + auto layout = new QVBoxLayout(this); + auto splitter = new QSplitter(this); + layout->addWidget(splitter); + + splitter->addWidget(_templet_types); + auto groupbox = new QGroupBox(u8"调用过程签名", this); + auto glayout = new QVBoxLayout(groupbox); + glayout->addWidget(_procedure_view); + _procedure_view->setModel(_procedure_model); + splitter->addWidget(groupbox); + _templet_types->setModel(_templet_model); + + splitter->setStretchFactor(1, 1); + + auto templet_pull = std::make_shared(); + templet_pull->reset(-1, RtEntityManager::const_id); + _bind_framework->accept(QList>() << templet_pull); + connect(_bind_timer, &QTimer::timeout, this, &PerspectiveView::deduce_start); + + _bind_timer->start(100); + _procedure_model->setHorizontalHeaderLabels(QStringList()< +#include +#include +#include +#include +#include + + +class PerspectiveView : public QDialog +{ + Q_OBJECT +private: + std::shared_ptr _bind_framework; + QTimer *const _bind_timer; + + QListView *const _templet_types; + QStandardItemModel *const _templet_model; + QTableView *const _procedure_view; + QStandardItemModel *const _procedure_model; + + void deduce_start(); + void reply_accept(const QList>& set); + void complete_accept(std::shared_ptr ins); + + void show_procedures_start(const QModelIndex &target); + +public: + PerspectiveView(std::shared_ptr ins, QWidget* p = nullptr); + +signals: + void backend_deduce_request(std::shared_ptr ins); +}; + diff --git a/SimsWorld/SimsWorld.vcxproj b/SimsWorld/SimsWorld.vcxproj index d2c69f1..93d0894 100644 --- a/SimsWorld/SimsWorld.vcxproj +++ b/SimsWorld/SimsWorld.vcxproj @@ -99,6 +99,7 @@ + @@ -111,6 +112,9 @@ + + + diff --git a/SimsWorld/SimsWorld.vcxproj.filters b/SimsWorld/SimsWorld.vcxproj.filters index d64144d..d157e34 100644 --- a/SimsWorld/SimsWorld.vcxproj.filters +++ b/SimsWorld/SimsWorld.vcxproj.filters @@ -49,10 +49,16 @@ Source Files + + Source Files + Header Files + + Header Files + \ No newline at end of file diff --git a/SimsWorld/TempletAssemble.cpp b/SimsWorld/TempletAssemble.cpp index 9bf3a8c..2edb029 100644 --- a/SimsWorld/TempletAssemble.cpp +++ b/SimsWorld/TempletAssemble.cpp @@ -6,8 +6,9 @@ #include #include -TempletAssemble::TempletAssemble() - :QWidget(nullptr), +TempletAssemble::TempletAssemble(std::shared_ptr fmk, QWidget *parent) + :QDialog(parent), + _bind_framework(fmk), _templet_present(new QListView(this)), _templet_model(new QStandardItemModel(this)), _t_add(new QPushButton(u8"添加模板",this)), @@ -20,6 +21,9 @@ TempletAssemble::TempletAssemble() _component_model(new QStandardItemModel(this)), _apply(new QPushButton(u8"应用", this)) { + setWindowTitle(u8"类型模板配置"); + this->setMinimumSize(800, 600); + auto layout = new QVBoxLayout(this); auto split = new QSplitter(this); layout->addWidget(split); diff --git a/SimsWorld/TempletAssemble.h b/SimsWorld/TempletAssemble.h index 9b4fc29..accaf38 100644 --- a/SimsWorld/TempletAssemble.h +++ b/SimsWorld/TempletAssemble.h @@ -1,14 +1,17 @@ #pragma once -#include +#include #include #include #include #include +#include -class TempletAssemble : public QWidget +class TempletAssemble : public QDialog { Q_OBJECT private: + std::shared_ptr _bind_framework; + QListView *const _templet_present; QStandardItemModel *const _templet_model; QPushButton *const _t_add, *const _t_remove; @@ -21,7 +24,7 @@ private: QPushButton *const _apply; public: - TempletAssemble(); + TempletAssemble(std::shared_ptr fmk, QWidget *p = nullptr); virtual ~TempletAssemble() = default; diff --git a/SimsWorld/main.cpp b/SimsWorld/main.cpp index ac4a05a..ac128ab 100644 --- a/SimsWorld/main.cpp +++ b/SimsWorld/main.cpp @@ -5,11 +5,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - //SimsWorld w; - //w.show(); - - TempletAssemble tass; - tass.show(); - + SimsWorld w; + w.show(); return a.exec(); } diff --git a/SimsWorld/sims_world.cpp b/SimsWorld/sims_world.cpp index b6f8861..4623b14 100644 --- a/SimsWorld/sims_world.cpp +++ b/SimsWorld/sims_world.cpp @@ -1,13 +1,29 @@ #include "sims_world.h" +#include "TempletAssemble.h" +#include "PerspectiveView.h" -SimsWorld::SimsWorld(QWidget *parent) - : QMainWindow(parent), - _backend_ins(std::make_shared()) +SimsWorld::SimsWorld(QWidget* parent) + : QMainWindow(parent), + _backend_ins(std::make_shared()) { - ui.setupUi(this); + ui.setupUi(this); - _backend_ins->init_framework(); + auto file = this->menuBar()->addMenu(u8"文件"); + auto setting = this->menuBar()->addMenu(u8"基础设置"); + auto assemble = setting->addAction(u8"类型构建"); + connect(assemble, &QAction::triggered, [=]() { + TempletAssemble dia(_backend_ins, this); + dia.exec(); + }); + auto signature = setting->addAction(u8"调用透视"); + connect(signature, &QAction::triggered, [=]() { + PerspectiveView dia(_backend_ins, this); + dia.exec(); + }); + + _backend_ins->init_framework(); } SimsWorld::~SimsWorld() -{} +{ +}