#include "PropertyBrowser.h" #include #include #include #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(); 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(); 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 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(); if (!entry) { LOG_WARN("file entry is nullptr"); // 如果没有属性对象,清空属性面板 inFileEntryView_ = false; browser_->clear(); propertyToId_.clear(); idToProperty_.clear(); idToExpanded_.clear(); colorSetters_.clear(); return; } // Enter single FileEntry view mode and clear existing panels inFileEntryView_ = true; browser_->clear(); propertyToId_.clear(); idToProperty_.clear(); idToExpanded_.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(titleBasic); QtProperty* typeProp = stringManager_->addProperty(tr("Type")); stringManager_->setValue(typeProp, QString::fromStdString(FileEntryTypeToString(entry->GetType()))); groupBasic->addSubProperty(typeProp); QtProperty* nameProp = stringManager_->addProperty(tr("Name")); stringManager_->setValue(nameProp, entry->GetName()); groupBasic->addSubProperty(nameProp); QtProperty* fileProp = stringManager_->addProperty(tr("FileName")); stringManager_->setValue(fileProp, entry->GetFileName()); groupBasic->addSubProperty(fileProp); QtProperty* pathProp = stringManager_->addProperty(tr("Path")); stringManager_->setValue(pathProp, entry->GetPath()); groupBasic->addSubProperty(pathProp); addProperty(groupBasic, idBasic); // 类型专属属性显示 switch (entry->GetType()) { 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(titleChart); 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); 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); 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); 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); 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); QtProperty* tProp = doubleManager_->addProperty(tr("timeParam")); doubleManager_->setValue(tProp, chart.timeParam); chartGroup->addSubProperty(tProp); addProperty(chartGroup, idChart); // Surface 列表 QtProperty* itemsGroup = groupManager_->addProperty(titleItems); 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); 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); 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); 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(titleChart); const auto& chart = tbl->GetChartProperties(); QtProperty* headerProp = stringManager_->addProperty(tr("headerString")); stringManager_->setValue(headerProp, chart.headerString); chartGroup->addSubProperty(headerProp); QtProperty* tProp = doubleManager_->addProperty(tr("timeParam")); doubleManager_->setValue(tProp, chart.timeParam); chartGroup->addSubProperty(tProp); 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(titleColor); 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 = doubleManager_->addProperty(tr("timeParam")); doubleManager_->setValue(tProp, colorProps.timeParam); colorGroup->addSubProperty(tProp); 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(titleRows); 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); 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); 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(titleChart); const auto& chart = pl->GetChartProperties(); auto addInt = [&](const QString& label, int v){ QtProperty* p=intManager_->addProperty(label); intManager_->setValue(p, v); chartGroup->addSubProperty(p); }; auto addStr = [&](const QString& label, const QString& v){ QtProperty* p=stringManager_->addProperty(label); stringManager_->setValue(p, v); chartGroup->addSubProperty(p); }; auto addDbl = [&](const QString& label, double v){ QtProperty* p=doubleManager_->addProperty(label); doubleManager_->setValue(p, v); chartGroup->addSubProperty(p); }; addInt(tr("AngularCount"), chart.AngularCount); addInt(tr("RadialCount"), chart.RadialCount); addStr(tr("AngularTitle"), chart.AngularTitle); addStr(tr("RadialTitle"), chart.RadialTitle); addDbl(tr("AngularMin"), chart.AngularMin); addDbl(tr("AngularMax"), chart.AngularMax); addDbl(tr("RadialMin"), chart.RadialMin); addDbl(tr("RadialMax"), chart.RadialMax); addStr(tr("AngularUnit"), chart.AngularUnit); addStr(tr("RadialUnit"), chart.RadialUnit); addDbl(tr("timeParam"), chart.timeParam); addProperty(chartGroup, idChart); QtProperty* linesGroup = groupManager_->addProperty(titleLines); 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); 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); QtProperty* rd = intManager_->addProperty(tr("Radial")); intManager_->setValue(rd, ln.Radial); line->addSubProperty(rd); 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(titleChart); const auto& chart = img->GetChartProperties(); QtProperty* tProp = doubleManager_->addProperty(tr("timeParam")); doubleManager_->setValue(tProp, chart.timeParam); chartGroup->addSubProperty(tProp); addProperty(chartGroup, idChart); QtProperty* itemsGroup = groupManager_->addProperty(titleItems); 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); 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); QtProperty* pth = stringManager_->addProperty(tr("path")); stringManager_->setValue(pth, im.path); item->addSubProperty(pth); QtProperty* sfx = stringManager_->addProperty(tr("suffix")); stringManager_->setValue(sfx, im.suffix); item->addSubProperty(sfx); 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() { 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); 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); } }); } void PropertyBrowser::OnWorkspaceFilesChanged(FileEntryType type, std::shared_ptr 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")); }