modify entity brower
This commit is contained in:
parent
e153ea5e8f
commit
53b8bb5099
@ -56,22 +56,13 @@ bool EntitiesManager::Parse(const tinyxml2::XMLElement* element, WorkSpace* work
|
|||||||
Entity* parent = nullptr;
|
Entity* parent = nullptr;
|
||||||
while (nullptr != xmlElement) {
|
while (nullptr != xmlElement) {
|
||||||
const char* name = xmlElement->Name();
|
const char* name = xmlElement->Name();
|
||||||
Entity* entity = Create(name);
|
Entity* entity = Create(xmlElement, parent, workspce);
|
||||||
if (nullptr == entity) {
|
if (nullptr == entity) {
|
||||||
xmlElement = xmlElement->NextSiblingElement();
|
xmlElement = xmlElement->NextSiblingElement();
|
||||||
LOG_WARN("Create entity failed {}", name);
|
LOG_WARN("Create entity failed {}", name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity->Serialize(xmlElement);
|
|
||||||
AddEntity(entity);
|
|
||||||
|
|
||||||
entity->SetParent(parent);
|
|
||||||
if (nullptr == parent) {
|
|
||||||
workspce->AddEntity(entity);
|
|
||||||
}
|
|
||||||
//parent = entity;
|
|
||||||
|
|
||||||
xmlElement = xmlElement->NextSiblingElement();
|
xmlElement = xmlElement->NextSiblingElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +76,28 @@ Entity* EntitiesManager::Create(const QString& name) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Entity* EntitiesManager::Create(const tinyxml2::XMLElement* element, Entity* parent, WorkSpace* workspce) {
|
||||||
|
const char* name = element->Name();
|
||||||
|
if (strcmp(name, "Entity") != 0) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity* entity = new Entity(this);
|
||||||
|
if (nullptr == entity) {
|
||||||
|
LOG_WARN("create entity failed");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity->Serialize(element);
|
||||||
|
AddEntity(entity);
|
||||||
|
|
||||||
|
entity->SetParent(parent);
|
||||||
|
if (nullptr == parent) {
|
||||||
|
workspce->AddEntity(entity);
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
Entity* EntitiesManager::CreateMesh(const QString& mesh) {
|
Entity* EntitiesManager::CreateMesh(const QString& mesh) {
|
||||||
Entity* entity = Create("Entity");
|
Entity* entity = Create("Entity");
|
||||||
AddEntity(entity);
|
AddEntity(entity);
|
||||||
|
@ -28,6 +28,8 @@ public:
|
|||||||
|
|
||||||
Entity* GetEntity(const QString& uuid);
|
Entity* GetEntity(const QString& uuid);
|
||||||
|
|
||||||
|
Entity* Create(const tinyxml2::XMLElement* element, Entity* parent, WorkSpace* workspce);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddEntity(Entity* entity);
|
void AddEntity(Entity* entity);
|
||||||
void RemoveEntity(Entity* entity);
|
void RemoveEntity(Entity* entity);
|
||||||
|
@ -45,6 +45,8 @@ void Entity::Serialize(const tinyxml2::XMLElement* element) {
|
|||||||
const char* name = xmlElement->Name();
|
const char* name = xmlElement->Name();
|
||||||
SceneComponent* conponent = ComponentFactory::Create(name, rootComponet_);
|
SceneComponent* conponent = ComponentFactory::Create(name, rootComponet_);
|
||||||
if (nullptr == conponent) {
|
if (nullptr == conponent) {
|
||||||
|
EntitiesManager::Get().Create(xmlElement, this, workspace_);
|
||||||
|
|
||||||
xmlElement = xmlElement->NextSiblingElement();
|
xmlElement = xmlElement->NextSiblingElement();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,10 @@ public:
|
|||||||
return rootComponet_;
|
return rootComponet_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<Entity*> GetChilder() const {
|
||||||
|
return childer_;
|
||||||
|
}
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void NameChanged(const QString& name);
|
void NameChanged(const QString& name);
|
||||||
|
|
||||||
|
@ -401,57 +401,57 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>ModelTreeWidget</name>
|
<name>ModelTreeWidget</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="110"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="96"/>
|
||||||
<source>Release Track</source>
|
<source>Release Track</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="127"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="113"/>
|
||||||
<source>Add boke Entity</source>
|
<source>Add boke Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="134"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="120"/>
|
||||||
<source>Add lsjhqt Entity</source>
|
<source>Add lsjhqt Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="141"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="127"/>
|
||||||
<source>Add nimizi Entity</source>
|
<source>Add nimizi Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="148"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="134"/>
|
||||||
<source>Add tkdlj Entity</source>
|
<source>Add tkdlj Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="155"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="141"/>
|
||||||
<source>Add jiaofan Entity</source>
|
<source>Add jiaofan Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="162"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="148"/>
|
||||||
<source>Add satellite Entity</source>
|
<source>Add satellite Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="264"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="250"/>
|
||||||
<source>Track</source>
|
<source>Track</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="272"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="258"/>
|
||||||
<source>Add Mesh Component</source>
|
<source>Add Mesh Component</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="276"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="262"/>
|
||||||
<source>Add Path Component</source>
|
<source>Add Path Component</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="283"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="269"/>
|
||||||
<source>Delete</source>
|
<source>Delete</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -61,19 +61,32 @@ void EntityListDialog::InitEintities() {
|
|||||||
|
|
||||||
const std::vector<class Entity*>& entities = workSpace->GetEntities();
|
const std::vector<class Entity*>& entities = workSpace->GetEntities();
|
||||||
for (const auto& entity : entities) {
|
for (const auto& entity : entities) {
|
||||||
const QString& entityName = entity->GetName();
|
AddEntity(nullptr, entity);
|
||||||
|
}
|
||||||
QTreeWidgetItem* item = new QTreeWidgetItem;
|
}
|
||||||
connect(entity, &Entity::NameChanged, [item](const QString& name) {
|
|
||||||
LOG_WARN("entity name changed: {}", name.toStdString());
|
void EntityListDialog::AddEntity(class QTreeWidgetItem* parent, Entity* entity) {
|
||||||
item->setText(0, name);
|
const QString& entityName = entity->GetName();
|
||||||
}
|
|
||||||
);
|
QTreeWidgetItem* item = new QTreeWidgetItem;
|
||||||
item->setText(0, entityName);
|
connect(entity, &Entity::NameChanged, [item](const QString& name) {
|
||||||
QVariant root;
|
LOG_WARN("entity name changed: {}", name.toStdString());
|
||||||
root.setValue(entity);
|
item->setText(0, name);
|
||||||
item->setData(0, E_Entity, root);
|
}
|
||||||
item->setData(0, E_UUid, entity->GetUUid());
|
);
|
||||||
ui->modelTreeWidget->addTopLevelItem(item);
|
item->setText(0, entityName);
|
||||||
|
QVariant root;
|
||||||
|
root.setValue(entity);
|
||||||
|
item->setData(0, E_Entity, root);
|
||||||
|
item->setData(0, E_UUid, entity->GetUUid());
|
||||||
|
if (nullptr == parent) {
|
||||||
|
ui->modelTreeWidget->addTopLevelItem(item);
|
||||||
|
} else {
|
||||||
|
parent->addChild(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Entity*>& children = entity->GetChilder();
|
||||||
|
for (const auto& child : children) {
|
||||||
|
AddEntity(item, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@ private:
|
|||||||
void initUI();
|
void initUI();
|
||||||
void InitEintities();
|
void InitEintities();
|
||||||
|
|
||||||
|
void AddEntity(class QTreeWidgetItem* parent, Entity* entity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::EntityListDialog* ui;
|
Ui::EntityListDialog* ui;
|
||||||
|
|
||||||
|
@ -53,21 +53,7 @@ void ModelTreeWidget::OnWorkspaceChange(WorkSpace* workSpace) {
|
|||||||
|
|
||||||
const std::vector<Entity*>& entities = currentWorkSpace_->GetEntities();
|
const std::vector<Entity*>& entities = currentWorkSpace_->GetEntities();
|
||||||
for (const auto& entity : entities) {
|
for (const auto& entity : entities) {
|
||||||
const QString& entityName = entity->GetName();
|
AddEntity(root_, entity);
|
||||||
|
|
||||||
QTreeWidgetItem* item = new QTreeWidgetItem;
|
|
||||||
connect(entity, &Entity::NameChanged, [item](const QString& name) {
|
|
||||||
LOG_WARN("entity name changed: {}", name.toStdString());
|
|
||||||
item->setText(0, name);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
item->setText(0, entityName);
|
|
||||||
QVariant root;
|
|
||||||
root.setValue(entity);
|
|
||||||
item->setData(0, E_Entity, root);
|
|
||||||
item->setData(0, E_UUid, entity->GetUUid());
|
|
||||||
root_->addChild(item);
|
|
||||||
//addTopLevelItem(root_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,3 +343,25 @@ void ModelTreeWidget::OnTrackEntity(Entity* entity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelTreeWidget::AddEntity(class QTreeWidgetItem* parent, Entity* entity) {
|
||||||
|
const QString& entityName = entity->GetName();
|
||||||
|
|
||||||
|
QTreeWidgetItem* item = new QTreeWidgetItem;
|
||||||
|
connect(entity, &Entity::NameChanged, [item](const QString& name) {
|
||||||
|
LOG_WARN("entity name changed: {}", name.toStdString());
|
||||||
|
item->setText(0, name);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
item->setText(0, entityName);
|
||||||
|
QVariant root;
|
||||||
|
root.setValue(entity);
|
||||||
|
item->setData(0, E_Entity, root);
|
||||||
|
item->setData(0, E_UUid, entity->GetUUid());
|
||||||
|
parent->addChild(item);
|
||||||
|
|
||||||
|
const std::vector<Entity*>& childer = entity->GetChilder();
|
||||||
|
for (const auto& child : childer) {
|
||||||
|
AddEntity(item, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -46,6 +46,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
//void initUI();
|
//void initUI();
|
||||||
|
void AddEntity(class QTreeWidgetItem* parent, Entity* entity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WorkSpace* currentWorkSpace_{ nullptr };
|
WorkSpace* currentWorkSpace_{ nullptr };
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
<MeshComponent mesh="boke/boke.ive" location="90.000000,30.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="5.000000,5.000000,5.000000">
|
<MeshComponent mesh="boke/boke.ive" location="90.000000,30.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="5.000000,5.000000,5.000000">
|
||||||
<PathComponent path="workspace/chuan3.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000"/>
|
<PathComponent path="workspace/chuan3.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000"/>
|
||||||
</MeshComponent>
|
</MeshComponent>
|
||||||
|
<Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9851a4d}" name="船5">
|
||||||
|
<MeshComponent mesh="boke/boke.ive" location="10.000000,30.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000">
|
||||||
|
<PathComponent path="workspace/chuan2.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000"/>
|
||||||
|
</MeshComponent>
|
||||||
|
</Entity>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity uuid="{b99a4401-9cc6-493e-a42e-655b81997eb3}" name="卫星">
|
<Entity uuid="{b99a4401-9cc6-493e-a42e-655b81997eb3}" name="卫星">
|
||||||
<MeshComponent mesh="satellite/satellite.ive" location="0.000000,0.000000,100.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000" uuid="{5b764fc4-89ad-4bac-b961-abf310a552fd}">
|
<MeshComponent mesh="satellite/satellite.ive" location="0.000000,0.000000,100.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000" uuid="{5b764fc4-89ad-4bac-b961-abf310a552fd}">
|
||||||
|
Loading…
Reference in New Issue
Block a user