|
|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
#include "nmWxVolumeSliceSettingsDlg.h"
|
|
|
|
|
#include "nmParameterField.h"
|
|
|
|
|
#include "nmNumericDisplayFormat.h"
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
@ -21,7 +20,8 @@ nmWxVolumeSliceSettingsDlg::nmWxVolumeSliceSettingsDlg(QWidget* pParent)
|
|
|
|
|
{
|
|
|
|
|
createUi();
|
|
|
|
|
writeSettings(m_oApplied);
|
|
|
|
|
resize(minimumWidth(), sizeHint().height());
|
|
|
|
|
// 与测量工具一致,由字体、主题和布局计算初始大小,后续仍允许用户调整窗口。
|
|
|
|
|
adjustSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxVolumeSliceSettingsDlg::createUi()
|
|
|
|
|
@ -36,8 +36,6 @@ void nmWxVolumeSliceSettingsDlg::createUi()
|
|
|
|
|
setIgnoreEsc(false);
|
|
|
|
|
|
|
|
|
|
// 六个分量各占一行,共用标签列和输入列;原点区与法向区分别放置对应快捷操作。
|
|
|
|
|
const int nEditorHeight = nmParameterField::editorHeight();
|
|
|
|
|
const int nEditorMinimumWidth = nmParameterField::editorMinimumWidth();
|
|
|
|
|
QGroupBox* pPlaneGroup = new QGroupBox(tr("Plane Parameters"), this);
|
|
|
|
|
pPlaneGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
QGridLayout* pPlaneLayout = new QGridLayout(pPlaneGroup);
|
|
|
|
|
@ -45,15 +43,15 @@ void nmWxVolumeSliceSettingsDlg::createUi()
|
|
|
|
|
pPlaneLayout->setHorizontalSpacing(6);
|
|
|
|
|
pPlaneLayout->setVerticalSpacing(6);
|
|
|
|
|
pPlaneLayout->setColumnStretch(1, 1);
|
|
|
|
|
int nFieldLabelWidth = 0;
|
|
|
|
|
const char* pAxes[3] = { "X", "Y", "Z" };
|
|
|
|
|
for(int nAxis = 0; nAxis < 3; ++nAxis) {
|
|
|
|
|
QLabel* pOriginLabel = new QLabel(tr("Origin %1").arg(QLatin1String(pAxes[nAxis])), pPlaneGroup);
|
|
|
|
|
QLabel* pNormalLabel = new QLabel(tr("Normal %1").arg(QLatin1String(pAxes[nAxis])), pPlaneGroup);
|
|
|
|
|
pOriginLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
|
|
|
pNormalLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
|
|
|
nFieldLabelWidth = qMax(nFieldLabelWidth,
|
|
|
|
|
qMax(pOriginLabel->sizeHint().width(), pNormalLabel->sizeHint().width()));
|
|
|
|
|
// 标签列由布局按文字自然取宽;不缓存像素尺寸,便于适应字体和主题变化。
|
|
|
|
|
pOriginLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
|
|
|
pNormalLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
|
|
|
pPlaneLayout->addWidget(pOriginLabel, nAxis, 0);
|
|
|
|
|
pPlaneLayout->addWidget(pNormalLabel, nAxis + 5, 0);
|
|
|
|
|
m_pOriginEdits[nAxis] = new QLineEdit(pPlaneGroup);
|
|
|
|
|
@ -62,10 +60,7 @@ void nmWxVolumeSliceSettingsDlg::createUi()
|
|
|
|
|
m_pNormalEdits[nAxis]->setObjectName(QString::fromLatin1("sliceNormal") + QLatin1String(pAxes[nAxis]));
|
|
|
|
|
m_pOriginEdits[nAxis]->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
|
m_pNormalEdits[nAxis]->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
|
m_pOriginEdits[nAxis]->setMinimumWidth(nEditorMinimumWidth);
|
|
|
|
|
m_pNormalEdits[nAxis]->setMinimumWidth(nEditorMinimumWidth);
|
|
|
|
|
m_pOriginEdits[nAxis]->setFixedHeight(nEditorHeight);
|
|
|
|
|
m_pNormalEdits[nAxis]->setFixedHeight(nEditorHeight);
|
|
|
|
|
// 横向随输入列伸展;纵向 Fixed 使用主题推荐高度,不指定固定像素高度。
|
|
|
|
|
m_pOriginEdits[nAxis]->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
m_pNormalEdits[nAxis]->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
pPlaneLayout->addWidget(m_pOriginEdits[nAxis], nAxis, 1);
|
|
|
|
|
@ -77,9 +72,9 @@ void nmWxVolumeSliceSettingsDlg::createUi()
|
|
|
|
|
// 模型中心仅调整原点,放在原点 Z 下方,保持按钮紧凑并与输入框右边界对齐。
|
|
|
|
|
QToolButton* pCenterButton = new QToolButton(pPlaneGroup);
|
|
|
|
|
pCenterButton->setText(tr("Model Center"));
|
|
|
|
|
pCenterButton->setToolTip(tr("Move the plane origin to the model center without changing its normal."));
|
|
|
|
|
pCenterButton->setAutoRaise(true);
|
|
|
|
|
pCenterButton->setMinimumWidth(72);
|
|
|
|
|
pCenterButton->setFixedHeight(nEditorHeight);
|
|
|
|
|
// 工具按钮按文字与主题计算尺寸,保持紧凑且不裁剪翻译后的标题。
|
|
|
|
|
pCenterButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
|
pPlaneLayout->addWidget(pCenterButton, 3, 1, Qt::AlignRight);
|
|
|
|
|
pPlaneLayout->setRowMinimumHeight(4, 6);
|
|
|
|
|
@ -102,10 +97,10 @@ void nmWxVolumeSliceSettingsDlg::createUi()
|
|
|
|
|
for(int nPlane = 0; nPlane < 3; ++nPlane) {
|
|
|
|
|
QToolButton* pButton = new QToolButton(pPlaneGroup);
|
|
|
|
|
pButton->setText(QString::fromLatin1(pPlanes[nPlane]));
|
|
|
|
|
pButton->setToolTip(tr("Set the plane parallel to %1 without changing its origin.")
|
|
|
|
|
.arg(QString::fromLatin1(pPlanes[nPlane])));
|
|
|
|
|
pButton->setProperty("normalAxis", 2 - nPlane);
|
|
|
|
|
pButton->setAutoRaise(true);
|
|
|
|
|
pButton->setMinimumWidth(44);
|
|
|
|
|
pButton->setFixedHeight(nEditorHeight);
|
|
|
|
|
pButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
pShortcutLayout->addWidget(pButton, 1);
|
|
|
|
|
setTabOrder(pPreviousShortcutWidget, pButton);
|
|
|
|
|
@ -117,26 +112,19 @@ void nmWxVolumeSliceSettingsDlg::createUi()
|
|
|
|
|
// 着色属性及渲染模式统一使用旧底栏;浮动窗口只保留平面相关的显示选项。
|
|
|
|
|
QGroupBox* pDisplayGroup = new QGroupBox(tr("Display Options"), this);
|
|
|
|
|
pDisplayGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
QGridLayout* pDisplayLayout = new QGridLayout(pDisplayGroup);
|
|
|
|
|
// 显示选项没有标签列,直接从分组左边距排列,避免沿用参数区的空列缩进。
|
|
|
|
|
QHBoxLayout* pDisplayLayout = new QHBoxLayout(pDisplayGroup);
|
|
|
|
|
pDisplayLayout->setContentsMargins(8, 15, 8, 10);
|
|
|
|
|
pDisplayLayout->setHorizontalSpacing(6);
|
|
|
|
|
pDisplayLayout->setVerticalSpacing(6);
|
|
|
|
|
pPlaneLayout->setColumnMinimumWidth(0, nFieldLabelWidth);
|
|
|
|
|
pDisplayLayout->setColumnMinimumWidth(0, nFieldLabelWidth);
|
|
|
|
|
pDisplayLayout->setColumnStretch(1, 1);
|
|
|
|
|
pDisplayLayout->setSpacing(12);
|
|
|
|
|
m_pShowPlaneCheck = new QCheckBox(tr("Show Plane"), pDisplayGroup);
|
|
|
|
|
m_pShowSourceCheck = new QCheckBox(tr("Show Original Model"), pDisplayGroup);
|
|
|
|
|
m_pShowPlaneCheck->setObjectName(QLatin1String("sliceShowPlane"));
|
|
|
|
|
m_pShowSourceCheck->setObjectName(QLatin1String("sliceShowSource"));
|
|
|
|
|
// 拖动说明放在显示平面的悬停提示中,减少常驻文字对参数布局的干扰。
|
|
|
|
|
m_pShowPlaneCheck->setToolTip(tr("Drag the center or outline to move the plane; drag arrows to rotate."));
|
|
|
|
|
QHBoxLayout* pDisplayOptionsLayout = new QHBoxLayout;
|
|
|
|
|
pDisplayOptionsLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
pDisplayOptionsLayout->setSpacing(12);
|
|
|
|
|
pDisplayOptionsLayout->addWidget(m_pShowPlaneCheck);
|
|
|
|
|
pDisplayOptionsLayout->addWidget(m_pShowSourceCheck);
|
|
|
|
|
pDisplayOptionsLayout->addStretch();
|
|
|
|
|
pDisplayLayout->addLayout(pDisplayOptionsLayout, 0, 1);
|
|
|
|
|
pDisplayLayout->addWidget(m_pShowPlaneCheck);
|
|
|
|
|
pDisplayLayout->addWidget(m_pShowSourceCheck);
|
|
|
|
|
pDisplayLayout->addStretch();
|
|
|
|
|
setTabOrder(pPreviousShortcutWidget, m_pShowPlaneCheck);
|
|
|
|
|
setTabOrder(m_pShowPlaneCheck, m_pShowSourceCheck);
|
|
|
|
|
connect(m_pShowPlaneCheck, SIGNAL(toggled(bool)), this, SLOT(onDisplayOptionsChanged()));
|
|
|
|
|
@ -154,24 +142,25 @@ void nmWxVolumeSliceSettingsDlg::createUi()
|
|
|
|
|
pFooterLayout->setContentsMargins(4, 5, 4, 5);
|
|
|
|
|
pFooterLayout->setSpacing(8);
|
|
|
|
|
pFooterLayout->addStretch();
|
|
|
|
|
QPushButton* pResetButton = new QPushButton(tr("Reset"), this);
|
|
|
|
|
QPushButton* pRestoreButton = new QPushButton(tr("Restore"), this);
|
|
|
|
|
// 还原仅撤销未应用的平面编辑,恢复最近一次成功应用的参数,不恢复初始截面。
|
|
|
|
|
pRestoreButton->setToolTip(tr("Restore the last applied plane parameters."));
|
|
|
|
|
m_pApplyButton = new QPushButton(tr("Apply"), this);
|
|
|
|
|
QPushButton* pCloseButton = new QPushButton(tr("Close"), this);
|
|
|
|
|
m_pApplyButton->setObjectName(QLatin1String("sliceApplyButton"));
|
|
|
|
|
m_pApplyButton->setDefault(true);
|
|
|
|
|
pResetButton->setAutoDefault(false);
|
|
|
|
|
pRestoreButton->setAutoDefault(false);
|
|
|
|
|
pCloseButton->setAutoDefault(false);
|
|
|
|
|
pResetButton->setMinimumWidth(72);
|
|
|
|
|
m_pApplyButton->setMinimumWidth(72);
|
|
|
|
|
pCloseButton->setMinimumWidth(72);
|
|
|
|
|
pCloseButton->setIcon(zxLoadIcon("Cancel"));
|
|
|
|
|
pCloseButton->setIconSize(QSize(16, 16));
|
|
|
|
|
pFooterLayout->addWidget(pResetButton);
|
|
|
|
|
pFooterLayout->addWidget(pRestoreButton);
|
|
|
|
|
pFooterLayout->addWidget(m_pApplyButton);
|
|
|
|
|
pFooterLayout->addWidget(pCloseButton);
|
|
|
|
|
connect(m_pApplyButton, SIGNAL(clicked()), this, SLOT(onApplyRequested()));
|
|
|
|
|
connect(pResetButton, SIGNAL(clicked()), this, SLOT(onResetRequested()));
|
|
|
|
|
connect(pRestoreButton, SIGNAL(clicked()), this, SLOT(onRestoreRequested()));
|
|
|
|
|
connect(pCloseButton, SIGNAL(clicked()), this, SLOT(close()));
|
|
|
|
|
setTabOrder(m_pShowSourceCheck, pRestoreButton);
|
|
|
|
|
setTabOrder(pRestoreButton, m_pApplyButton);
|
|
|
|
|
setTabOrder(m_pApplyButton, pCloseButton);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout* pMainLayout = new QVBoxLayout(this);
|
|
|
|
|
pMainLayout->setContentsMargins(12, 10, 12, 0);
|
|
|
|
|
@ -179,9 +168,9 @@ void nmWxVolumeSliceSettingsDlg::createUi()
|
|
|
|
|
pMainLayout->addWidget(pPlaneGroup);
|
|
|
|
|
pMainLayout->addWidget(pDisplayGroup);
|
|
|
|
|
pMainLayout->addWidget(m_pErrorLabel);
|
|
|
|
|
// 初始高度按内容收紧;手动纵向拉伸的余量留在底部,不拉长输入框或分组行距。
|
|
|
|
|
pMainLayout->addStretch();
|
|
|
|
|
pMainLayout->addLayout(pFooterLayout);
|
|
|
|
|
setMinimumWidth(400);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxVolumeSliceSettingsDlg::setData(const QSharedPointer<const nmVolumeData>& pData, const nmVolumeSliceSettings& oApplied)
|
|
|
|
|
@ -198,7 +187,7 @@ void nmWxVolumeSliceSettingsDlg::setAppliedSettings(const nmVolumeSliceSettings&
|
|
|
|
|
|
|
|
|
|
void nmWxVolumeSliceSettingsDlg::setAppliedProperty(const QString& sPropertyId)
|
|
|
|
|
{
|
|
|
|
|
// 底栏属性立即生效;重置、关闭窗口及再次应用平面时也应继续使用此属性。
|
|
|
|
|
// 底栏属性立即生效;还原、关闭窗口及再次应用平面时也应继续使用此属性。
|
|
|
|
|
m_oApplied.m_sPropertyId = sPropertyId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -313,7 +302,7 @@ void nmWxVolumeSliceSettingsDlg::onCenterRequested()
|
|
|
|
|
onDraftChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxVolumeSliceSettingsDlg::onResetRequested()
|
|
|
|
|
void nmWxVolumeSliceSettingsDlg::onRestoreRequested()
|
|
|
|
|
{
|
|
|
|
|
writeSettings(m_oApplied);
|
|
|
|
|
emit previewChanged();
|
|
|
|
|
|