initial commit

This commit is contained in:
2026-04-07 20:55:30 +08:00
commit 81d1fb7856
84 changed files with 11929 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
#include "props/BackgroundPropertySection.h"
#include <QCheckBox>
#include <QFormLayout>
#include <QLabel>
#include <QVBoxLayout>
namespace gui {
BackgroundPropertySection::BackgroundPropertySection(QWidget* parent)
: PropertySectionWidget(parent) {
auto* lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(6);
auto* form = new QFormLayout();
form->setContentsMargins(0, 0, 0, 0);
form->setSpacing(6);
m_sizeLabel = new QLabel(QStringLiteral("-"), this);
m_sizeLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
form->addRow(QStringLiteral("背景尺寸"), m_sizeLabel);
m_showBackground = new QCheckBox(QStringLiteral("显示背景"), this);
m_showBackground->setToolTip(QStringLiteral("是否绘制背景图"));
form->addRow(QString(), m_showBackground);
m_depthOverlay = new QCheckBox(QStringLiteral("叠加深度"), this);
m_depthOverlay->setToolTip(QStringLiteral("在背景上叠加深度伪彩图"));
form->addRow(QString(), m_depthOverlay);
lay->addLayout(form);
lay->addStretch(1);
connect(m_showBackground, &QCheckBox::toggled, this, &BackgroundPropertySection::backgroundVisibleToggled);
connect(m_depthOverlay, &QCheckBox::toggled, this, &BackgroundPropertySection::depthOverlayToggled);
}
void BackgroundPropertySection::setBackgroundSizeText(const QString& text) {
if (m_sizeLabel) {
m_sizeLabel->setText(text);
}
}
void BackgroundPropertySection::syncBackgroundVisible(bool visible, bool controlsEnabled) {
if (!m_showBackground) {
return;
}
m_showBackground->blockSignals(true);
m_showBackground->setChecked(visible);
m_showBackground->setEnabled(controlsEnabled);
m_showBackground->blockSignals(false);
}
void BackgroundPropertySection::syncDepthOverlayChecked(bool on) {
if (!m_depthOverlay) {
return;
}
m_depthOverlay->blockSignals(true);
m_depthOverlay->setChecked(on);
m_depthOverlay->blockSignals(false);
}
void BackgroundPropertySection::setDepthOverlayCheckEnabled(bool on) {
if (m_depthOverlay) {
m_depthOverlay->setEnabled(on);
}
}
void BackgroundPropertySection::setProjectClosedAppearance() {
setBackgroundSizeText(QStringLiteral("-"));
syncBackgroundVisible(true, false);
syncDepthOverlayChecked(false);
setDepthOverlayCheckEnabled(false);
}
} // namespace gui

View File

@@ -0,0 +1,32 @@
#pragma once
#include "props/PropertySectionWidget.h"
class QLabel;
class QCheckBox;
namespace gui {
// 背景相关属性:尺寸、显隐、深度叠加(可嵌入 QStackedWidget 的一页)
class BackgroundPropertySection final : public PropertySectionWidget {
Q_OBJECT
public:
explicit BackgroundPropertySection(QWidget* parent = nullptr);
void setBackgroundSizeText(const QString& text);
void syncBackgroundVisible(bool visible, bool controlsEnabled);
void syncDepthOverlayChecked(bool on);
void setDepthOverlayCheckEnabled(bool on);
void setProjectClosedAppearance();
signals:
void backgroundVisibleToggled(bool on);
void depthOverlayToggled(bool on);
private:
QLabel* m_sizeLabel = nullptr;
QCheckBox* m_showBackground = nullptr;
QCheckBox* m_depthOverlay = nullptr;
};
} // namespace gui

View File

@@ -0,0 +1,108 @@
#include "props/EntityPropertySection.h"
#include "params/ParamControls.h"
#include <QDoubleSpinBox>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QVBoxLayout>
namespace gui {
EntityPropertySection::EntityPropertySection(QWidget* parent)
: PropertySectionWidget(parent) {
auto* lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(6);
auto* form = new QFormLayout();
form->setContentsMargins(0, 0, 0, 0);
form->setSpacing(6);
m_name = new QLineEdit(this);
m_name->setPlaceholderText(QStringLiteral("显示名称"));
m_name->setToolTip(QStringLiteral("仅显示用;内部 id 不变"));
form->addRow(QStringLiteral("名称"), m_name);
m_depth = new QLabel(QStringLiteral("-"), this);
m_distScale = new QLabel(QStringLiteral("-"), this);
for (QLabel* lab : {m_depth, m_distScale}) {
lab->setTextInteractionFlags(Qt::TextSelectableByMouse);
}
form->addRow(QStringLiteral("深度"), m_depth);
form->addRow(QStringLiteral("距离缩放"), m_distScale);
m_pivot = new Vec2ParamControl(this);
m_pivot->setToolTip(QStringLiteral("枢轴在世界坐标中的位置(限制在轮廓包络内),用于重定位局部原点"));
form->addRow(QStringLiteral("中心坐标"), m_pivot);
m_centroid = new Vec2ParamControl(this);
m_centroid->setToolTip(QStringLiteral("实体几何质心的世界坐标;修改将整体平移实体"));
form->addRow(QStringLiteral("位置"), m_centroid);
m_userScale = new QDoubleSpinBox(this);
m_userScale->setRange(0.05, 20.0);
m_userScale->setDecimals(3);
m_userScale->setSingleStep(0.05);
m_userScale->setValue(1.0);
m_userScale->setToolTip(QStringLiteral("人为整体缩放,与深度距离缩放相乘"));
form->addRow(QStringLiteral("整体缩放"), m_userScale);
lay->addLayout(form);
lay->addStretch(1);
connect(m_name, &QLineEdit::editingFinished, this, [this]() {
if (m_name) {
emit displayNameCommitted(m_name->text());
}
});
connect(m_pivot, &Vec2ParamControl::valueChanged, this, &EntityPropertySection::pivotEdited);
connect(m_centroid, &Vec2ParamControl::valueChanged, this, &EntityPropertySection::centroidEdited);
connect(m_userScale, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &EntityPropertySection::userScaleEdited);
}
void EntityPropertySection::clearDisconnected() {
setEditingEnabled(false);
if (m_name) {
m_name->blockSignals(true);
m_name->clear();
m_name->blockSignals(false);
}
if (m_depth) m_depth->setText(QStringLiteral("-"));
if (m_distScale) m_distScale->setText(QStringLiteral("-"));
if (m_pivot) m_pivot->setValue(0.0, 0.0);
if (m_centroid) m_centroid->setValue(0.0, 0.0);
if (m_userScale) {
m_userScale->blockSignals(true);
m_userScale->setValue(1.0);
m_userScale->blockSignals(false);
}
}
void EntityPropertySection::applyState(const EntityPropertyUiState& s) {
setEditingEnabled(true);
if (m_name) {
m_name->blockSignals(true);
m_name->setText(s.displayName);
m_name->blockSignals(false);
}
if (m_depth) m_depth->setText(QString::number(s.depthZ));
if (m_distScale) m_distScale->setText(s.distanceScaleText);
if (m_pivot) m_pivot->setValue(s.pivot.x(), s.pivot.y());
if (m_centroid) m_centroid->setValue(s.centroid.x(), s.centroid.y());
if (m_userScale) {
m_userScale->blockSignals(true);
m_userScale->setValue(s.userScale);
m_userScale->blockSignals(false);
}
}
void EntityPropertySection::setEditingEnabled(bool on) {
if (m_name) m_name->setEnabled(on);
if (m_pivot) m_pivot->setEnabled(on);
if (m_centroid) m_centroid->setEnabled(on);
if (m_userScale) m_userScale->setEnabled(on);
}
} // namespace gui

View File

@@ -0,0 +1,52 @@
#pragma once
#include "props/PropertySectionWidget.h"
#include <QPointF>
#include <QString>
class QLabel;
class QLineEdit;
class QDoubleSpinBox;
namespace gui {
class Vec2ParamControl;
}
namespace gui {
struct EntityPropertyUiState {
QString displayName;
int depthZ = 0;
QString distanceScaleText;
QPointF pivot;
QPointF centroid;
double userScale = 1.0;
};
// 实体相关属性(可嵌入 QStackedWidget 的一页)
class EntityPropertySection final : public PropertySectionWidget {
Q_OBJECT
public:
explicit EntityPropertySection(QWidget* parent = nullptr);
void clearDisconnected();
void applyState(const EntityPropertyUiState& s);
void setEditingEnabled(bool on);
signals:
void displayNameCommitted(const QString& text);
void pivotEdited(double x, double y);
void centroidEdited(double x, double y);
void userScaleEdited(double value);
private:
QLineEdit* m_name = nullptr;
QLabel* m_depth = nullptr;
QLabel* m_distScale = nullptr;
Vec2ParamControl* m_pivot = nullptr;
Vec2ParamControl* m_centroid = nullptr;
QDoubleSpinBox* m_userScale = nullptr;
};
} // namespace gui

View File

@@ -0,0 +1,13 @@
#pragma once
#include <QWidget>
namespace gui {
// 属性 dock 中可切换的「一节」的公共基类:便于以后扩展更多对象类型(灯光、相机等)
class PropertySectionWidget : public QWidget {
public:
explicit PropertySectionWidget(QWidget* parent = nullptr) : QWidget(parent) {}
};
} // namespace gui