DYTSrouce/src/ui/PropertyBrowser.cpp
2025-11-15 21:44:17 +08:00

1375 lines
55 KiB
C++

#include "PropertyBrowser.h"
#include <QBoxLayout>
#include <QDebug>
#include <QSet>
#include "PropertyBrowser/qttreepropertybrowser.h"
#include "PropertyBrowser/qtpropertymanager.h"
#include "PropertyBrowser/qteditorfactory.h"
#include "DockTitleBar.h"
#include "DockWidget.h"
#include "workspace/WorkSpace.h"
#include "workspace/WorkSpaceManager.h"
#include "entities/Entity.h"
#include "entities/MeshComponent.h"
#include "common/SpdLogger.h"
PropertyBrowser::PropertyBrowser(QWidget *parent) :
QWidget(parent) {
InitUI();
//Test();
}
PropertyBrowser::~PropertyBrowser() {
}
void PropertyBrowser::AttachDock(DockWidget* dockWidget) {
if (nullptr == dockWidget) {
LOG_WARN("dockwidget is nullptr");
return;
}
dockWidget->SetDockWidgetTitleBar(nullptr);
dockWidget->setWidget(this);
DockTitleBar* dockTitleBar = new DockTitleBar;
dockTitleBar->SetTitle(tr("attribute"));
dockWidget->SetDockWidgetTitleBar(dockTitleBar);
}
void PropertyBrowser::OnWorkSpaceChange(const QVariant& value) {
inFileEntryView_ = false;
WorkSpace* workspace = value.value<WorkSpace*>();
if (nullptr == workspace) {
LOG_WARN("workspace is nullptr");
// 如果没有属性对象,清空属性面板
browser_->clear();
propertyToId_.clear();
idToProperty_.clear();
idToExpanded_.clear();
colorSetters_.clear();
return;
}
// 点击根项目需要清空属性面板,不展示工作区属性
browser_->clear();
propertyToId_.clear();
idToProperty_.clear();
idToExpanded_.clear();
colorSetters_.clear();
QtProperty* property;
property = workSpaceManager_->addProperty(tr("WorkSpace"));
QWorkspaceAttribute worksapceAttribute(workspace);
workSpaceManager_->setValue(property, worksapceAttribute);
addProperty(property, tr("WorkSpace"));
// 保持对运行时工作区变更的监听(树刷新所需),但属性面板保持清空
if (currentWorkspace_) {
QObject::disconnect(currentWorkspace_, nullptr, this, nullptr);
}
currentWorkspace_ = workspace;
QObject::connect(currentWorkspace_, &WorkSpace::FilesChanged,
this, &PropertyBrowser::OnWorkspaceFilesChanged);
// 属性面板清空,文件项属性由 FileEntry 点击时单独处理
}
void PropertyBrowser::OnEntityChange(const QVariant& value) {
inFileEntryView_ = false;
Entity* entity = value.value<Entity*>();
if (nullptr == entity) {
LOG_WARN("engity is nullptr");
// 如果没有属性对象,清空属性面板
browser_->clear();
propertyToId_.clear();
idToProperty_.clear();
idToExpanded_.clear();
colorSetters_.clear();
return;
}
browser_->clear();
QtProperty* property;
property = entityManager_->addProperty(tr("Entity"));
QEntityAttribute entityAttribute(entity);
entityManager_->setValue(property, entityAttribute);
addProperty(property, tr("Entity"));
SceneComponent* component = entity->GetRootComponent();
if (nullptr == component) {
LOG_WARN("component is nullptr");
return;
}
QtComponentPropertyManager* componentManager = GetCompononetPropertyManager(component->GetSelfTypeName().c_str());
if (nullptr == componentManager) {
LOG_WARN("component is nullptr");
return;
}
property = componentManager->AddProperty();
componentManager->SetPropertyValue(property, component);
addProperty(property, componentManager->GetPropertyId());
std::vector<SceneComponent*> children = component->GetChildren();
for (auto child : children) {
componentManager = GetCompononetPropertyManager(child->GetSelfTypeName().c_str());
if (nullptr == componentManager) {
LOG_WARN("component is nullptr id {}", child->GetSelfTypeName());
continue;
}
if (nullptr == child) {
LOG_WARN("component is nullptr id {}", child->GetSelfTypeName());
return;
}
property = componentManager->AddProperty();
componentManager->SetPropertyValue(property, child);
addProperty(property, componentManager->GetPropertyId());
}
}
void PropertyBrowser::OnFileEntryChange(const QVariant& value) {
FileEntry* entry = value.value<FileEntry*>();
if (!entry) {
LOG_WARN("file entry is nullptr");
// 如果没有属性对象,清空属性面板
inFileEntryView_ = false;
browser_->clear();
propertyToId_.clear();
idToProperty_.clear();
idToExpanded_.clear();
colorSetters_.clear();
stringSetters_.clear();
intSetters_.clear();
doubleSetters_.clear();
return;
}
// Enter single FileEntry view mode and clear existing panels
inFileEntryView_ = true;
browser_->clear();
propertyToId_.clear();
idToProperty_.clear();
idToExpanded_.clear();
colorSetters_.clear();
stringSetters_.clear();
intSetters_.clear();
doubleSetters_.clear();
// Compute our id and ensure the property exists (create if missing)
//const QString id = QString("CurveEntry:%1").arg(entry->GetFileName());
//auto curve = entry->AsCurve();
//if (!curve)
{
LOG_WARN("file entry not a curve: %s", entry->GetFileName().toStdString().c_str());
// 基础信息组
const QString idBasic = QString("FileEntry:%1").arg(entry->GetFileName());
const QString titleBasic = QString("File Entry - %1").arg(entry->GetName());
QtProperty* groupBasic = groupManager_->addProperty(tr("Basic"));
QtProperty* typeProp = stringManager_->addProperty(tr("Type"));
stringManager_->setValue(typeProp, QString::fromStdString(FileEntryTypeToString(entry->GetType())));
typeProp->setEnabled(false);
groupBasic->addSubProperty(typeProp);
QtProperty* nameProp = stringManager_->addProperty(tr("Name"));
stringManager_->setValue(nameProp, entry->GetName());
groupBasic->addSubProperty(nameProp);
stringSetters_[nameProp] = [entry](const QString& s)
{
entry->SetName(s);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* fileProp = stringManager_->addProperty(tr("FileName"));
stringManager_->setValue(fileProp, entry->GetFileName());
fileProp->setEnabled(false);
groupBasic->addSubProperty(fileProp);
QtProperty* pathProp = stringManager_->addProperty(tr("Path"));
stringManager_->setValue(pathProp, entry->GetPath());
pathProp->setEnabled(false);
groupBasic->addSubProperty(pathProp);
addProperty(groupBasic, idBasic);
// 类型专属属性显示
switch (entry->GetType())
{
case FileEntryType::Curve:
{
auto curve = entry->AsCurve();
if (curve)
{
const QString titleChart = QString(tr("Chart"));
QtProperty* chartGroup = groupManager_->addProperty(titleChart);
const auto& chart = curve->GetChartProperties();
QtProperty* typeProp = enumManager_->addProperty(tr("Curve Type"));
enumManager_->setEnumNames(typeProp, QStringList() << ("Wave") << ("Report"));
int enumVal = (chart.chartType == ChartType::Report) ? 1 : 0;
enumManager_->setValue(typeProp, enumVal);
typeProp->setEnabled(false);
chartGroup->addSubProperty(typeProp);
QtProperty* xCountProp = intManager_->addProperty(tr("xCount"));
intManager_->setValue(xCountProp, chart.xCount);
chartGroup->addSubProperty(xCountProp);
intSetters_[xCountProp] = [curve, entry](const int& value)
{
auto prop = curve->GetChartProperties();
prop.xCount = value;
curve->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* yCountProp = intManager_->addProperty(tr("yCount"));
intManager_->setValue(yCountProp, chart.yCount);
chartGroup->addSubProperty(yCountProp);
intSetters_[yCountProp] = [curve, entry](const int& value)
{
auto prop = curve->GetChartProperties();
prop.yCount = value;
curve->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* xTitleProp = stringManager_->addProperty(tr("xTitle"));
stringManager_->setValue(xTitleProp, chart.xTitle);
chartGroup->addSubProperty(xTitleProp);
stringSetters_[xTitleProp] = [curve, entry](const QString& s)
{
auto prop = curve->GetChartProperties();
prop.xTitle = s;
curve->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* yTitleProp = stringManager_->addProperty(tr("yTitle"));
stringManager_->setValue(yTitleProp, chart.yTitle);
chartGroup->addSubProperty(yTitleProp);
stringSetters_[yTitleProp] = [curve, entry](const QString& s)
{
auto prop = curve->GetChartProperties();
prop.yTitle = s;
curve->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* xMinProp = doubleManager_->addProperty(tr("xMin"));
doubleManager_->setValue(xMinProp, chart.xMin);
chartGroup->addSubProperty(xMinProp);
doubleSetters_[xMinProp] = [curve, entry](const double& value)
{
auto prop = curve->GetChartProperties();
prop.xMin = value;
curve->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* xMaxProp = doubleManager_->addProperty(tr("xMax"));
doubleManager_->setValue(xMaxProp, chart.xMax);
chartGroup->addSubProperty(xMaxProp);
doubleSetters_[xMaxProp] = [curve, entry](const double& value)
{
auto prop = curve->GetChartProperties();
prop.xMax = value;
curve->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* yMinProp = doubleManager_->addProperty(tr("yMin"));
doubleManager_->setValue(yMinProp, chart.yMin);
chartGroup->addSubProperty(yMinProp);
doubleSetters_[yMinProp] = [curve, entry](const double& value)
{
auto prop = curve->GetChartProperties();
prop.yMin = value;
curve->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* yMaxProp = doubleManager_->addProperty(tr("yMax"));
doubleManager_->setValue(yMaxProp, chart.yMax);
chartGroup->addSubProperty(yMaxProp);
doubleSetters_[yMaxProp] = [curve, entry](const double& value)
{
auto prop = curve->GetChartProperties();
prop.yMax = value;
curve->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* tProp = intManager_->addProperty(tr("timeParam"));
intManager_->setValue(tProp, chart.timeParam);
chartGroup->addSubProperty(tProp);
intSetters_[tProp] = [curve, entry](const int& value)
{
auto prop = curve->GetChartProperties();
prop.timeParam = value;
curve->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
addProperty(chartGroup, "CurveChart");
QtProperty* itemsGroup = groupManager_->addProperty(tr("CurveProperty"));
const auto& items = curve->GetCurveProperties();
for (int i = 0; i < items.size(); ++i)
{
const auto& s = items[i];
QtProperty* itemGroup = groupManager_->addProperty(QString("Curve[%1]").arg(i));
QtProperty* nm = stringManager_->addProperty(tr("name"));
stringManager_->setValue(nm, s.name);
itemGroup->addSubProperty(nm);
stringSetters_[nm] = [curve, entry, i](const QString& s)
{
auto props = curve->GetCurveProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.name = s;
curve->SetCurveProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QtProperty* col = colorManager_->addProperty(tr("color"));
colorManager_->setValue(col, s.color);
itemGroup->addSubProperty(col);
colorSetters_[col] = [curve, entry, i](const QColor& c)
{
auto props = curve->GetCurveProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.color = c;
curve->SetCurveProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
if (chart.chartType == ChartType::Wave)
{
QtProperty* st = intManager_->addProperty(tr("start"));
intManager_->setValue(st, s.data.wave.start);
itemGroup->addSubProperty(st);
QtProperty* sp = intManager_->addProperty(tr("stop"));
intManager_->setValue(sp, s.data.wave.stop);
itemGroup->addSubProperty(sp);
intSetters_[st] = [curve, entry, i](const int& value)
{
auto props = curve->GetCurveProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.data.wave.start = value;
curve->SetCurveProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
intSetters_[sp] = [curve, entry, i](const int& value)
{
auto props = curve->GetCurveProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.data.wave.stop = value;
curve->SetCurveProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
}
else if (chart.chartType == ChartType::Report)
{
QtProperty* st = intManager_->addProperty(tr("x"));
intManager_->setValue(st, s.data.report.x);
itemGroup->addSubProperty(st);
QtProperty* sp = intManager_->addProperty(tr("y"));
intManager_->setValue(sp, s.data.report.y);
itemGroup->addSubProperty(sp);
intSetters_[st] = [curve, entry, i](const int& value)
{
auto props = curve->GetCurveProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.data.report.x = value;
curve->SetCurveProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
intSetters_[sp] = [curve, entry, i](const int& value)
{
auto props = curve->GetCurveProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.data.report.y = value;
curve->SetCurveProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
}
itemsGroup->addSubProperty(itemGroup);
}
addProperty(itemsGroup, "CurveItems");
}
break;
}
case FileEntryType::Surface:
{
auto surf = entry->AsSurface();
if (surf)
{
const QString idChart = QString("SurfaceChart:%1").arg(entry->GetFileName());
const QString idItems = QString("SurfaceItems:%1").arg(entry->GetFileName());
const QString titleChart = QString("Surface Chart - %1").arg(entry->GetName());
const QString titleItems = QString("Surfaces - %1").arg(entry->GetName());
// Chart 属性
QtProperty* chartGroup = groupManager_->addProperty(tr("Chart"));
const auto& chart = surf->GetChartProperties();
QtProperty* xCountProp = intManager_->addProperty(tr("xCount"));
intManager_->setValue(xCountProp, chart.xCount);
chartGroup->addSubProperty(xCountProp);
QtProperty* yCountProp = intManager_->addProperty(tr("yCount"));
intManager_->setValue(yCountProp, chart.yCount);
chartGroup->addSubProperty(yCountProp);
QtProperty* zCountProp = intManager_->addProperty(tr("zCount"));
intManager_->setValue(zCountProp, chart.zCount);
chartGroup->addSubProperty(zCountProp);
intSetters_[xCountProp] = [surf, entry](const int& value)
{
auto prop = surf->GetChartProperties();
prop.xCount = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
intSetters_[yCountProp] = [surf, entry](const int& value)
{
auto prop = surf->GetChartProperties();
prop.yCount = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
intSetters_[zCountProp] = [surf, entry](const int& value)
{
auto prop = surf->GetChartProperties();
prop.zCount = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* xTitleProp = stringManager_->addProperty(tr("xTitle"));
stringManager_->setValue(xTitleProp, chart.xTitle);
chartGroup->addSubProperty(xTitleProp);
QtProperty* yTitleProp = stringManager_->addProperty(tr("yTitle"));
stringManager_->setValue(yTitleProp, chart.yTitle);
chartGroup->addSubProperty(yTitleProp);
QtProperty* zTitleProp = stringManager_->addProperty(tr("zTitle"));
stringManager_->setValue(zTitleProp, chart.zTitle);
chartGroup->addSubProperty(zTitleProp);
stringSetters_[xTitleProp] = [surf, entry](const QString& s)
{
auto prop = surf->GetChartProperties();
prop.xTitle = s;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
stringSetters_[yTitleProp] = [surf, entry](const QString& s)
{
auto prop = surf->GetChartProperties();
prop.yTitle = s;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
stringSetters_[zTitleProp] = [surf, entry](const QString& s)
{
auto prop = surf->GetChartProperties();
prop.zTitle = s;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* xMinProp = doubleManager_->addProperty(tr("xMin"));
doubleManager_->setValue(xMinProp, chart.xMin);
chartGroup->addSubProperty(xMinProp);
QtProperty* xMaxProp = doubleManager_->addProperty(tr("xMax"));
doubleManager_->setValue(xMaxProp, chart.xMax);
chartGroup->addSubProperty(xMaxProp);
doubleSetters_[xMinProp] = [surf, entry](const double& value)
{
auto prop = surf->GetChartProperties();
prop.xMin = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
doubleSetters_[xMaxProp] = [surf, entry](const double& value)
{
auto prop = surf->GetChartProperties();
prop.xMax = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* yMinProp = doubleManager_->addProperty(tr("yMin"));
doubleManager_->setValue(yMinProp, chart.yMin);
chartGroup->addSubProperty(yMinProp);
QtProperty* yMaxProp = doubleManager_->addProperty(tr("yMax"));
doubleManager_->setValue(yMaxProp, chart.yMax);
chartGroup->addSubProperty(yMaxProp);
doubleSetters_[yMinProp] = [surf, entry](const double& value)
{
auto prop = surf->GetChartProperties();
prop.yMin = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
doubleSetters_[yMaxProp] = [surf, entry](const double& value)
{
auto prop = surf->GetChartProperties();
prop.yMax = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* zMinProp = doubleManager_->addProperty(tr("zMin"));
doubleManager_->setValue(zMinProp, chart.zMin);
chartGroup->addSubProperty(zMinProp);
QtProperty* zMaxProp = doubleManager_->addProperty(tr("zMax"));
doubleManager_->setValue(zMaxProp, chart.zMax);
chartGroup->addSubProperty(zMaxProp);
doubleSetters_[zMinProp] = [surf, entry](const double& value)
{
auto prop = surf->GetChartProperties();
prop.zMin = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
doubleSetters_[zMaxProp] = [surf, entry](const double& value)
{
auto prop = surf->GetChartProperties();
prop.zMax = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* tProp = intManager_->addProperty(tr("timeParam"));
intManager_->setValue(tProp, chart.timeParam);
chartGroup->addSubProperty(tProp);
intSetters_[zCountProp] = [surf, entry](const int& value)
{
auto prop = surf->GetChartProperties();
prop.timeParam = value;
surf->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
addProperty(chartGroup, idChart);
// Surface 列表
QtProperty* itemsGroup = groupManager_->addProperty(tr("SurfacesProp"));
const auto& items = surf->GetSurfaceProperties();
for (int i = 0; i < items.size(); ++i)
{
const auto& s = items[i];
QtProperty* itemGroup = groupManager_->addProperty(QString("Surface[%1]").arg(i));
QtProperty* nm = stringManager_->addProperty(tr("name"));
stringManager_->setValue(nm, s.name);
itemGroup->addSubProperty(nm);
stringSetters_[nm] = [surf, entry, i](const QString& s)
{
auto props = surf->GetSurfaceProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.name = s;
surf->SetSurfaceProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QtProperty* col = colorManager_->addProperty(tr("color"));
colorManager_->setValue(col, s.color);
itemGroup->addSubProperty(col);
// 写回 Surface 条目颜色
colorSetters_[col] = [surf, entry, i](const QColor& c)
{
auto props = surf->GetSurfaceProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.color = c;
surf->SetSurfaceProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QtProperty* st = intManager_->addProperty(tr("start"));
intManager_->setValue(st, s.start);
itemGroup->addSubProperty(st);
QtProperty* sp = intManager_->addProperty(tr("stop"));
intManager_->setValue(sp, s.stop);
itemGroup->addSubProperty(sp);
intSetters_[st] = [surf, entry, i](const int& value)
{
auto props = surf->GetSurfaceProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.start = value;
surf->SetSurfaceProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
intSetters_[sp] = [surf, entry, i](const int& value)
{
auto props = surf->GetSurfaceProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.stop = value;
surf->SetSurfaceProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QtProperty* x = stringManager_->addProperty(tr("x"));
stringManager_->setValue(x, s.x);
itemGroup->addSubProperty(x);
QtProperty* y = stringManager_->addProperty(tr("y"));
stringManager_->setValue(y, s.y);
itemGroup->addSubProperty(y);
QtProperty* z = stringManager_->addProperty(tr("z"));
stringManager_->setValue(z, s.z);
itemGroup->addSubProperty(z);
stringSetters_[x] = [surf, entry, i](const QString& s)
{
auto props = surf->GetSurfaceProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.x = s;
surf->SetSurfaceProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
stringSetters_[y] = [surf, entry, i](const QString& s)
{
auto props = surf->GetSurfaceProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.y = s;
surf->SetSurfaceProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
stringSetters_[z] = [surf, entry, i](const QString& s)
{
auto props = surf->GetSurfaceProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.z = s;
surf->SetSurfaceProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
itemsGroup->addSubProperty(itemGroup);
}
addProperty(itemsGroup, idItems);
}
break;
}
case FileEntryType::Table:
{
auto tbl = entry->AsTable();
if (tbl)
{
const QString idChart = QString("TableChart:%1").arg(entry->GetFileName());
const QString idItems = QString("TableItems:%1").arg(entry->GetFileName());
const QString titleChart = QString("Table Chart - %1").arg(entry->GetName());
const QString titleItems = QString("Tables - %1").arg(entry->GetName());
QtProperty* chartGroup = groupManager_->addProperty(tr("Chart"));
const auto& chart = tbl->GetChartProperties();
QtProperty* headerProp = stringManager_->addProperty(tr("headerString"));
stringManager_->setValue(headerProp, chart.headerString);
chartGroup->addSubProperty(headerProp);
stringSetters_[headerProp] = [tbl, entry](const QString& s)
{
auto prop = tbl->GetChartProperties();
prop.headerString = s;
tbl->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
QtProperty* tProp = intManager_->addProperty(tr("timeParam"));
intManager_->setValue(tProp, chart.timeParam);
chartGroup->addSubProperty(tProp);
intSetters_[tProp] = [tbl, entry](const int& value)
{
auto prop = tbl->GetChartProperties();
prop.timeParam = value;
tbl->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
addProperty(chartGroup, idChart);
// QtProperty* itemsGroup = groupManager_->addProperty(titleItems);
// const auto& items = tbl->GetTableProperties();
// for (int i = 0; i < items.size(); ++i)
//{
// const auto& t = items[i];
// QtProperty* itemGroup = groupManager_->addProperty(QString("Table[%1]").arg(i));
// QtProperty* nm = stringManager_->addProperty(tr("name"));
// stringManager_->setValue(nm, t.name);
// itemGroup->addSubProperty(nm);
// QtProperty* col = colorManager_->addProperty(tr("color"));
// colorManager_->setValue(col, t.color);
// itemGroup->addSubProperty(col);
// // 写回 Table 条目颜色
// colorSetters_[col] = [tbl, entry, i](const QColor& c){
// auto props = tbl->GetTableProperties();
// if (i >= 0 && i < props.size()) {
// auto item = props[i];
// item.color = c;
// tbl->SetTableProperty(i, item);
// if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
// }
// };
// // datas 展示为拼接字符串
// QStringList values;
// for (const auto& v : t.datas) values << QString::number(v);
// QtProperty* ds = stringManager_->addProperty(tr("datas"));
// stringManager_->setValue(ds, values.join(", "));
// itemGroup->addSubProperty(ds);
// itemsGroup->addSubProperty(itemGroup);
// }
// addProperty(itemsGroup, idItems);
}
break;
}
case FileEntryType::Light:
{
auto lt = entry->AsLight();
if (lt)
{
const QString idColor = QString("LightColors:%1").arg(entry->GetFileName());
const QString idRows = QString("LightRows:%1").arg(entry->GetFileName());
const QString titleColor = QString("Light Colors - %1").arg(entry->GetName());
const QString titleRows = QString("Light Rows - %1").arg(entry->GetName());
// 颜色与时间
QtProperty* colorGroup = groupManager_->addProperty(tr("Chart"));
const auto& colorProps = lt->GetColorProperties();
QtProperty* oc = colorManager_->addProperty(tr("openColor"));
colorManager_->setValue(oc, colorProps.openColor);
colorGroup->addSubProperty(oc);
QtProperty* cc = colorManager_->addProperty(tr("closeColor"));
colorManager_->setValue(cc, colorProps.closeColor);
colorGroup->addSubProperty(cc);
QtProperty* tProp = intManager_->addProperty(tr("timeParam"));
intManager_->setValue(tProp, colorProps.timeParam);
colorGroup->addSubProperty(tProp);
intSetters_[tProp] = [lt, entry](const int& value)
{
auto prop = lt->GetColorProperties();
prop.timeParam = value;
lt->SetColorProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
addProperty(colorGroup, idColor);
// 写回处理:颜色变化更新到 FileEntryLight 并通知 Workspace
colorSetters_[oc] = [lt, entry](const QColor& c)
{
auto props = lt->GetColorProperties();
props.openColor = c;
lt->SetColorProperties(props);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
colorSetters_[cc] = [lt, entry](const QColor& c)
{
auto props = lt->GetColorProperties();
props.closeColor = c;
lt->SetColorProperties(props);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
// 行数据
QtProperty* rowsGroup = groupManager_->addProperty(tr("Light Rows"));
const auto& rows = lt->GetLightProperties();
for (int i = 0; i < rows.size(); ++i)
{
const auto& r = rows[i];
QtProperty* row = groupManager_->addProperty(QString("Row[%1]").arg(i));
QtProperty* names = stringManager_->addProperty(tr("names"));
stringManager_->setValue(names, r.name.join(", "));
row->addSubProperty(names);
stringSetters_[names] = [lt, entry, i](const QString& s)
{
auto props = lt->GetLightProperties();
if (i >= 0 && i < props.size())
{
QStringList names = s.split(",", Qt::SkipEmptyParts);
for (int i = 0; i < names.size(); ++i) {
names[i] = names[i].trimmed();
}
auto item = props[i];
item.name = names;
lt->SetLightProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QStringList values;
for (const auto& v : r.data) values << QString::number(v);
QtProperty* ds = stringManager_->addProperty(tr("data"));
stringManager_->setValue(ds, values.join(", "));
row->addSubProperty(ds);
stringSetters_[ds] = [lt, entry, i](const QString& s)
{
auto props = lt->GetLightProperties();
if (i >= 0 && i < props.size())
{
QStringList dataStrings = s.split(",", Qt::SkipEmptyParts);
QList<int> dataValues;
for (const QString& str : dataStrings)
{
bool ok;
int dataValue = str.trimmed().toInt(&ok);
if (ok) {
dataValues.append(dataValue);
}
}
auto item = props[i];
item.data = dataValues;
lt->SetLightProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
rowsGroup->addSubProperty(row);
}
addProperty(rowsGroup, idRows);
}
break;
}
case FileEntryType::Polar:
{
auto pl = entry->AsPolar();
if (pl)
{
const QString idChart = QString("PolarChart:%1").arg(entry->GetFileName());
const QString idLines = QString("PolarLines:%1").arg(entry->GetFileName());
const QString titleChart = QString("Polar Chart - %1").arg(entry->GetName());
const QString titleLines = QString("Lines - %1").arg(entry->GetName());
QtProperty* chartGroup = groupManager_->addProperty(tr("Chart"));
const auto& chart = pl->GetChartProperties();
auto addInt = [&](const QString& label, int v, const QString& key)
{
QtProperty* p=intManager_->addProperty(label);
intManager_->setValue(p, v);
chartGroup->addSubProperty(p);
intSetters_[p] = [pl, entry, key](const int& value)
{
pl->UpdateChartProperties(key, QVariant(value));
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
};
auto addStr = [&](const QString& label, const QString& v, const QString& key)
{
QtProperty* p=stringManager_->addProperty(label);
stringManager_->setValue(p, v);
chartGroup->addSubProperty(p);
stringSetters_[p] = [pl, entry, key](const QString& value)
{
pl->UpdateChartProperties(key, QVariant(value));
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
};
auto addDbl = [&](const QString& label, double v, const QString& key)
{
QtProperty* p=doubleManager_->addProperty(label);
doubleManager_->setValue(p, v);
chartGroup->addSubProperty(p);
doubleSetters_[p] = [pl, entry, key](const double& value)
{
pl->UpdateChartProperties(key, QVariant(value));
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
};
addInt(tr("AngularCount"), chart.AngularCount, "AngularCount");
addInt(tr("RadialCount"), chart.RadialCount, "RadialCount");
addStr(tr("AngularTitle"), chart.AngularTitle, "AngularTitle");
addStr(tr("RadialTitle"), chart.RadialTitle, "RadialTitle");
addDbl(tr("AngularMin"), chart.AngularMin, "AngularMin");
addDbl(tr("AngularMax"), chart.AngularMax, "AngularMax");
addDbl(tr("RadialMin"), chart.RadialMin, "RadialMin");
addDbl(tr("RadialMax"), chart.RadialMax, "RadialMax");
addStr(tr("AngularUnit"), chart.AngularUnit, "AngularUnit");
addStr(tr("RadialUnit"), chart.RadialUnit, "RadialUnit");
addInt(tr("timeParam"), chart.timeParam, "timeParam");
addProperty(chartGroup, idChart);
QtProperty* linesGroup = groupManager_->addProperty(tr("Lines Prop"));
const auto& lines = pl->GetLineProperties();
for (int i = 0; i < lines.size(); ++i)
{
const auto& ln = lines[i];
QtProperty* line = groupManager_->addProperty(QString("Line[%1]").arg(i));
QtProperty* nm = stringManager_->addProperty(tr("name"));
stringManager_->setValue(nm, ln.name);
line->addSubProperty(nm);
stringSetters_[nm] = [pl, entry, i](const QString& s)
{
auto props = pl->GetLineProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.name = s;
pl->SetLineProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QtProperty* col = colorManager_->addProperty(tr("color"));
colorManager_->setValue(col, ln.color);
line->addSubProperty(col);
// 写回 Polar 线颜色
colorSetters_[col] = [pl, entry, i](const QColor& c)
{
auto props = pl->GetLineProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.color = c;
pl->SetLineProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QtProperty* ag = intManager_->addProperty(tr("Angular"));
intManager_->setValue(ag, ln.Angular);
line->addSubProperty(ag);
intSetters_[ag] = [pl, entry, i](const int& value)
{
auto props = pl->GetLineProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.Angular = value;
pl->SetLineProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QtProperty* rd = intManager_->addProperty(tr("Radial"));
intManager_->setValue(rd, ln.Radial);
line->addSubProperty(rd);
intSetters_[rd] = [pl, entry, i](const int& value)
{
auto props = pl->GetLineProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.Radial = value;
pl->SetLineProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
linesGroup->addSubProperty(line);
}
addProperty(linesGroup, idLines);
}
break;
}
case FileEntryType::Image:
{
auto img = entry->AsImage();
if (img)
{
const QString idChart = QString("ImageChart:%1").arg(entry->GetFileName());
const QString idItems = QString("Images:%1").arg(entry->GetFileName());
const QString titleChart = QString("Image Chart - %1").arg(entry->GetName());
const QString titleItems = QString("Image Set - %1").arg(entry->GetName());
QtProperty* chartGroup = groupManager_->addProperty(tr("Chart"));
const auto& chart = img->GetChartProperties();
QtProperty* tProp = intManager_->addProperty(tr("timeParam"));
intManager_->setValue(tProp, chart.timeParam);
chartGroup->addSubProperty(tProp);
intSetters_[tProp] = [img, entry](const int& value)
{
auto prop = img->GetChartProperties();
prop.timeParam = value;
img->SetChartProperties(prop);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
};
addProperty(chartGroup, idChart);
QtProperty* itemsGroup = groupManager_->addProperty(tr("Image Prop"));
const auto& items = img->GetImageProperties();
for (int i = 0; i < items.size(); ++i)
{
const auto& im = items[i];
QtProperty* item = groupManager_->addProperty(QString("Image[%1]").arg(i));
QtProperty* names = stringManager_->addProperty(tr("names"));
names->setToolTip(tr("File name list"));
stringManager_->setValue(names, im.names.join(", "));
item->addSubProperty(names);
stringSetters_[names] = [img, entry, i](const QString& s)
{
auto props = img->GetImageProperties();
if (i >= 0 && i < props.size())
{
QStringList names = s.split(",", Qt::SkipEmptyParts);
for (int i = 0; i < names.size(); ++i) {
names[i] = names[i].trimmed();
}
auto item = props[i];
item.names = names;
img->SetImageProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QStringList values;
for (const auto& v : im.datas) values << QString::number(v);
QtProperty* ds = stringManager_->addProperty(tr("datas"));
ds->setToolTip(tr("Image data per file"));
stringManager_->setValue(ds, values.join(", "));
item->addSubProperty(ds);
stringSetters_[ds] = [img, entry, i](const QString& s)
{
auto props = img->GetImageProperties();
if (i >= 0 && i < props.size())
{
QStringList dataStrings = s.split(",", Qt::SkipEmptyParts);
QList<int> dataValues;
for (const QString& str : dataStrings)
{
bool ok;
int dataValue = str.trimmed().toInt(&ok);
if (ok) {
dataValues.append(dataValue);
}
}
auto item = props[i];
item.datas = dataValues;
img->SetImageProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QtProperty* pth = stringManager_->addProperty(tr("path"));
stringManager_->setValue(pth, im.path);
pth->setEnabled(false);
item->addSubProperty(pth);
stringSetters_[ds] = [img, entry, i](const QString& s)
{
auto props = img->GetImageProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.path = s;
img->SetImageProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
QtProperty* sfx = stringManager_->addProperty(tr("suffix"));
stringManager_->setValue(sfx, im.suffix);
item->addSubProperty(sfx);
stringSetters_[ds] = [img, entry, i](const QString& s)
{
auto props = img->GetImageProperties();
if (i >= 0 && i < props.size())
{
auto item = props[i];
item.suffix = s;
img->SetImageProperty(i, item);
if (auto ws = WorkSpaceManager::Get().GetCurrent()) ws->NotifyFileEntryUpdated(entry->GetType());
}
};
itemsGroup->addSubProperty(item);
}
addProperty(itemsGroup, idItems);
}
break;
}
default:
break;
}
// 聚焦基础信息组
if (groupBasic) {
QtBrowserItem* item = browser_->topLevelItem(groupBasic);
if (item) {
browser_->setExpanded(item, true);
browser_->setCurrentItem(item);
}
}
return;
}
//const QString title = QString("CurveEntry - %1").arg(entry->GetName());
//QtProperty* prop = curveEntryManager_->addProperty(title);
//QCurveEntryAttribute attr(curve);
//curveEntryManager_->setValue(prop, attr);
//addProperty(prop, id);
//// Focus the corresponding group: expand and select it
//if (prop) {
// QtBrowserItem* item = browser_->topLevelItem(prop);
// if (item) {
// browser_->setExpanded(item, true);
// browser_->setCurrentItem(item);
// }
//}
}
void PropertyBrowser::OnGroupChange(const QVariant& value) {
browser_->clear();
}
void PropertyBrowser::InitUI() {
QBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
browser_ = new QtTreePropertyBrowser;
layout->addWidget(browser_);
browser_->setHeaderVisible(true);
//browser_->setResizeMode(QtTreePropertyBrowser::Stretch);
InitPropertyManager();
InitComponentPropertyManager();
}
void PropertyBrowser::InitPropertyManager() {
enumManager_ = new QtEnumPropertyManager(this);
intManager_ = new QtIntPropertyManager(this);
boolManager_ = new QtBoolPropertyManager(this);
doubleManager_ = new QtDoublePropertyManager(this);
stringManager_ = new QtStringPropertyManager(this);
colorManager_ = new QtColorPropertyManager(this);
fontManager_ = new QtFontPropertyManager(this);
pointManager_ = new QtPointPropertyManager(this);
sizeManager_ = new QtSizePropertyManager(this);
modelBaseManager_ = new QtModelBasePropertyManager(this);
workSpaceManager_ = new QtWorkspacePropertyManager(this);
entityManager_ = new QtEntityPropertyManager(this);
curveEntryManager_ = new QtCurveEntryPropertyManager(this);
groupManager_ = new QtGroupPropertyManager(this);
QtDoubleSpinBoxFactory* doubleSpinBoxFactory = new QtDoubleSpinBoxFactory(this);
QtCheckBoxFactory* checkBoxFactory = new QtCheckBoxFactory(this);
QtSpinBoxFactory* spinBoxFactory = new QtSpinBoxFactory(this);
QtLineEditFactory* lineEditFactory = new QtLineEditFactory(this);
QtEnumEditorFactory* comboBoxFactory = new QtEnumEditorFactory(this);
QtFilePathFactory* filePathFactory = new QtFilePathFactory(this);
QtColorEditorFactory* colorFactory = new QtColorEditorFactory(this);
//QtTransfromEditorFactory* transformFactory = new QtTransfromEditorFactory(this);
browser_->setFactoryForManager(intManager_, spinBoxFactory);
browser_->setFactoryForManager(boolManager_, checkBoxFactory);
browser_->setFactoryForManager(doubleManager_, doubleSpinBoxFactory);
browser_->setFactoryForManager(stringManager_, lineEditFactory);
// Color properties: use a color dialog editor for the top-level color, keep sub-channel ints editable
browser_->setFactoryForManager(colorManager_, colorFactory);
browser_->setFactoryForManager(colorManager_->subIntPropertyManager(), spinBoxFactory);
browser_->setFactoryForManager(fontManager_->subIntPropertyManager(), spinBoxFactory);
browser_->setFactoryForManager(fontManager_->subBoolPropertyManager(), checkBoxFactory);
browser_->setFactoryForManager(fontManager_->subEnumPropertyManager(), comboBoxFactory);
browser_->setFactoryForManager(pointManager_->subIntPropertyManager(), spinBoxFactory);
browser_->setFactoryForManager(sizeManager_->subIntPropertyManager(), spinBoxFactory);
browser_->setFactoryForManager(workSpaceManager_->subStringProperyManager(), lineEditFactory);
browser_->setFactoryForManager(workSpaceManager_->subFilesProperyManager(), filePathFactory);
// Enable editing for grouped file entry counts
browser_->setFactoryForManager(workSpaceManager_->subIntProperyManager(), spinBoxFactory);
// Enable editing for Workspace double sub-properties (e.g., HomeViewpoint fields)
browser_->setFactoryForManager(workSpaceManager_->subDoubleProperyManager(), doubleSpinBoxFactory);
browser_->setFactoryForManager(entityManager_->subStringProperyManager(), lineEditFactory);
browser_->setFactoryForManager(entityManager_->subBoolProperyManager(), checkBoxFactory);
browser_->setFactoryForManager(
entityManager_->subTransfromProperyManager()->subVec3TPropertyManager()->subDoublePropertyManager(),
doubleSpinBoxFactory);
browser_->setFactoryForManager(
entityManager_->subTransfromProperyManager()->subVec3RPropertyManager()->subDoublePropertyManager(),
doubleSpinBoxFactory);
browser_->setFactoryForManager(
entityManager_->subTransfromProperyManager()->subVec3SPropertyManager()->subDoublePropertyManager(),
doubleSpinBoxFactory);
// Curve entry sub editors
browser_->setFactoryForManager(curveEntryManager_->subStringProperyManager(), lineEditFactory);
browser_->setFactoryForManager(curveEntryManager_->subEnumProperyManager(), comboBoxFactory);
browser_->setFactoryForManager(curveEntryManager_->subIntProperyManager(), spinBoxFactory);
browser_->setFactoryForManager(curveEntryManager_->subDoubleProperyManager(), doubleSpinBoxFactory);
browser_->setFactoryForManager(curveEntryManager_->subColorProperyManager(), colorFactory);
// 颜色属性变更信号:触发对应写回处理器
connect(colorManager_, &QtColorPropertyManager::valueChanged, this,
[this](QtProperty* prop, const QColor& color){
if (colorSetters_.contains(prop)) {
colorSetters_[prop](color);
}
});
connect(stringManager_, &QtStringPropertyManager::valueChanged, this,
[this](QtProperty* prop, const QString& str) {
if (stringSetters_.contains(prop)) {
stringSetters_[prop](str);
}
});
connect(intManager_, &QtIntPropertyManager::valueChanged, this,
[this](QtProperty* prop, const int& value) {
if (intSetters_.contains(prop)) {
intSetters_[prop](value);
}
});
connect(doubleManager_, &QtDoublePropertyManager::valueChanged, this,
[this](QtProperty* prop, const double& value) {
if (doubleSetters_.contains(prop)) {
doubleSetters_[prop](value);
}
});
}
void PropertyBrowser::OnWorkspaceFilesChanged(FileEntryType type, std::shared_ptr<FileEntry> fileEntry) {
if (!currentWorkspace_) return;
// In single FileEntry view, skip workspace-driven group refresh to keep panel clean
if (inFileEntryView_) return;
// Refresh workspace group
{
auto it = idToProperty_.find(tr("WorkSpace"));
if (it != idToProperty_.end()) {
QtProperty* property = it.value();
QWorkspaceAttribute worksapceAttribute(currentWorkspace_);
workSpaceManager_->setValue(property, worksapceAttribute);
}
}
}
void PropertyBrowser::InitComponentPropertyManager() {
QtDoubleSpinBoxFactory* doubleSpinBoxFactory = new QtDoubleSpinBoxFactory(this);
QtCheckBoxFactory* checkBoxFactory = new QtCheckBoxFactory(this);
QtSpinBoxFactory* spinBoxFactory = new QtSpinBoxFactory(this);
QtLineEditFactory* lineEditFactory = new QtLineEditFactory(this);
QtColorEditorFactory* colorFactory = new QtColorEditorFactory(this);
QtFilePathFactory* filePathFactory = new QtFilePathFactory(this);
QtModelFilePathFactory* modelFileFactory = new QtModelFilePathFactory(this);
QtEntityUUIDEditorFactory* entityUUIDFactory = new QtEntityUUIDEditorFactory(this);
QtMeshComponetManager* meshComponentManager = new QtMeshComponetManager(this);
browser_->setFactoryForManager(meshComponentManager->subModelFileProperyManager(), modelFileFactory);
componetManager_[meshComponentManager->GetPropertyId()] = meshComponentManager;
QtPathComponentManager* pathComponentManager = new QtPathComponentManager(this);
browser_->setFactoryForManager(pathComponentManager->subFilesProperyManager(), filePathFactory);
componetManager_[pathComponentManager->GetPropertyId()] = pathComponentManager;
QtConeWaveComponentManager* coneWaveComponentManager = new QtConeWaveComponentManager(this);
browser_->setFactoryForManager(coneWaveComponentManager->subDoubleProperyManager(), doubleSpinBoxFactory);
browser_->setFactoryForManager(coneWaveComponentManager->subIntProperyManager(), spinBoxFactory);
browser_->setFactoryForManager(coneWaveComponentManager->subColorProperyManager(), colorFactory);
componetManager_[coneWaveComponentManager->GetPropertyId()] = coneWaveComponentManager;
QtDashedLineComponentManager* dashedLineComponentManager = new QtDashedLineComponentManager(this);
browser_->setFactoryForManager(dashedLineComponentManager->subEntityProperyManager(), entityUUIDFactory);
browser_->setFactoryForManager(dashedLineComponentManager->subDoubleProperyManager(), doubleSpinBoxFactory);
browser_->setFactoryForManager(dashedLineComponentManager->subColorProperyManager(), colorFactory);
componetManager_[dashedLineComponentManager->GetPropertyId()] = dashedLineComponentManager;
}
void PropertyBrowser::addProperty(QtProperty* property, const QString& id) {
propertyToId_[property] = id;
idToProperty_[id] = property;
QtBrowserItem* item = browser_->addProperty(property);
if (idToExpanded_.contains(id))
browser_->setExpanded(item, idToExpanded_[id]);
}
QtComponentPropertyManager* PropertyBrowser::GetCompononetPropertyManager(const QString& id) {
if (!componetManager_.contains(id)) {
return nullptr;
}
return componetManager_[id];
}
void PropertyBrowser::Test() {
QtProperty* property;
property = modelBaseManager_->addProperty(tr("ModelBase"));
QModelAttbute modelAttr(QString("test"), QString("test222"), true, 1.0 , true);
modelBaseManager_->setValue(property, modelAttr);
addProperty(property, QLatin1String("brush"));
property = colorManager_->addProperty(tr("color base"));
colorManager_->setValue(property, QColor(255, 12, 231, 252));
addProperty(property, QLatin1String("bda"));
}