|
|
|
|
@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
#include "zxLogInstance.h"
|
|
|
|
|
#include "ZxResolutionHelper.h"
|
|
|
|
|
#include "zxSysUtils.h"
|
|
|
|
|
|
|
|
|
|
#include "mModuleDefines.h"
|
|
|
|
|
|
|
|
|
|
#include "iParaItemCtrl.h"
|
|
|
|
|
#include "iParameterUtils.h"
|
|
|
|
|
|
|
|
|
|
#include "iGridRowItem.h"
|
|
|
|
|
#include "nmGridRowUtils.h"
|
|
|
|
|
|
|
|
|
|
#include "nmWxParaPropertyPebi.h"
|
|
|
|
|
|
|
|
|
|
nmWxParaPropertyPebi::nmWxParaPropertyPebi(QWidget* parent) :
|
|
|
|
|
iDlgBase(parent)
|
|
|
|
|
{
|
|
|
|
|
m_pMainLayout = nullptr;
|
|
|
|
|
m_listParas.clear();
|
|
|
|
|
m_pGridItemUtils = nullptr;
|
|
|
|
|
m_pHelpBox = nullptr;
|
|
|
|
|
|
|
|
|
|
setWindowTitle(tr("Numerical para property"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmWxParaPropertyPebi::~nmWxParaPropertyPebi()
|
|
|
|
|
{
|
|
|
|
|
if (nullptr != m_pGridItemUtils)
|
|
|
|
|
{
|
|
|
|
|
delete m_pGridItemUtils;
|
|
|
|
|
m_pGridItemUtils = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxParaPropertyPebi::initUI()
|
|
|
|
|
{
|
|
|
|
|
m_pMainLayout = new QVBoxLayout();
|
|
|
|
|
Q_ASSERT(nullptr != m_pMainLayout);
|
|
|
|
|
m_pMainLayout->setSpacing(0);
|
|
|
|
|
m_pMainLayout->setMargin(0);
|
|
|
|
|
m_pMainLayout->setSizeConstraint(QVBoxLayout::SetMinAndMaxSize);
|
|
|
|
|
|
|
|
|
|
// 以ScrollArea来显示,出现滚动条
|
|
|
|
|
{
|
|
|
|
|
QWidget* pWxBk = new QWidget();
|
|
|
|
|
Q_ASSERT(nullptr != pWxBk);
|
|
|
|
|
pWxBk->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
pWxBk->setAutoFillBackground(true);
|
|
|
|
|
pWxBk->setLayout(m_pMainLayout);
|
|
|
|
|
|
|
|
|
|
// Area, 设置Widget
|
|
|
|
|
QScrollArea* pArea = new QScrollArea();
|
|
|
|
|
pArea->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
|
|
|
|
pArea->setWidgetResizable(true);
|
|
|
|
|
pArea->setWidget(pWxBk);
|
|
|
|
|
pArea->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
|
|
|
|
// Layout, 设置Area
|
|
|
|
|
QVBoxLayout* pLayoutBk = new QVBoxLayout();
|
|
|
|
|
pLayoutBk->setSpacing(0);
|
|
|
|
|
pLayoutBk->setMargin(0);
|
|
|
|
|
pLayoutBk->addWidget(pArea);
|
|
|
|
|
|
|
|
|
|
initUI_HelpBox();
|
|
|
|
|
if (nullptr != m_pHelpBox)
|
|
|
|
|
{
|
|
|
|
|
pLayoutBk->addWidget(m_pHelpBox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setLayout(pLayoutBk);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxParaPropertyPebi::initUI_HelpBox()
|
|
|
|
|
{
|
|
|
|
|
// Sub: HelpBox
|
|
|
|
|
m_pHelpBox = new QTextEdit();
|
|
|
|
|
Q_ASSERT(nullptr != m_pHelpBox);
|
|
|
|
|
|
|
|
|
|
m_pHelpBox->setMaximumHeight(_resoSizeH(65));
|
|
|
|
|
m_pHelpBox->setReadOnly(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxParaPropertyPebi::refreshUIs(QStringList& listParas, bool bReserveOlds /*= true*/)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr == m_pMainLayout)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_listParas = listParas;
|
|
|
|
|
|
|
|
|
|
// 备份原有的参数内容
|
|
|
|
|
QMap<QString, QVariant> mapOldParas;
|
|
|
|
|
mapOldParas.clear();
|
|
|
|
|
if (bReserveOlds)
|
|
|
|
|
{
|
|
|
|
|
backupOldParas(mapOldParas, listParas);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear Old
|
|
|
|
|
QVBoxLayout* pLayout = m_pMainLayout;
|
|
|
|
|
clearChildrenOfLayout(pLayout, this);
|
|
|
|
|
|
|
|
|
|
// 创建PEBI求解器专用的GridRowUtils
|
|
|
|
|
m_pGridItemUtils = new nmGridRowUtils(true);
|
|
|
|
|
Q_ASSERT(nullptr != m_pGridItemUtils);
|
|
|
|
|
m_pGridItemUtils->setParent(this);
|
|
|
|
|
m_pGridItemUtils->setParaSrcTag(s_Nm_Serie);
|
|
|
|
|
connect(m_pGridItemUtils, SIGNAL(sigHelpMsg(QString&)),
|
|
|
|
|
this, SLOT(slotHelpMsg(QString&)));
|
|
|
|
|
m_pMainLayout->addWidget(m_pGridItemUtils);
|
|
|
|
|
m_pGridItemUtils->buildRowUtils(listParas, false, this);
|
|
|
|
|
|
|
|
|
|
// 恢复原有的参数内容
|
|
|
|
|
if (bReserveOlds && !mapOldParas.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
restoreOldParas(mapOldParas);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxParaPropertyPebi::backupOldParas(QMap<QString, QVariant>& map,
|
|
|
|
|
QStringList& listParas)
|
|
|
|
|
{
|
|
|
|
|
map.clear();
|
|
|
|
|
if (nullptr != m_pGridItemUtils)
|
|
|
|
|
{
|
|
|
|
|
foreach (QString s, listParas)
|
|
|
|
|
{
|
|
|
|
|
map[s] = m_pGridItemUtils->getItemValueByPara(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxParaPropertyPebi::restoreOldParas(QMap<QString, QVariant>& map)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr == m_pGridItemUtils)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// 恢复先前备份的数据
|
|
|
|
|
QMap<QString, QVariant>::iterator iter = map.begin();
|
|
|
|
|
for (; iter != map.end(); iter++)
|
|
|
|
|
{
|
|
|
|
|
QString sPara = iter.key();
|
|
|
|
|
|
|
|
|
|
iParameter* p = _paraHelper->getPara(sPara, s_Nm_Serie);
|
|
|
|
|
if (nullptr == p || p->m_bReadonly)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant o = iter.value();
|
|
|
|
|
if (!o.isValid())
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
m_pGridItemUtils->setParaValue(sPara, o);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxParaPropertyPebi::setParaValue(QString sPara, QVariant o)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr != m_pGridItemUtils &&
|
|
|
|
|
m_pGridItemUtils->setParaValue(sPara, o))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxParaPropertyPebi::getParaValue(QString sPara, QVariant& o)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr != m_pGridItemUtils)
|
|
|
|
|
{
|
|
|
|
|
if (m_pGridItemUtils->getParaValue(sPara, o))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxParaPropertyPebi::getAllParaValues(QMap<QString, QVariant>& map,
|
|
|
|
|
bool bOnlyFitted/* = false*/,
|
|
|
|
|
bool bClearMap /*= true*/)
|
|
|
|
|
{
|
|
|
|
|
if (bClearMap)
|
|
|
|
|
{
|
|
|
|
|
map.clear();
|
|
|
|
|
}
|
|
|
|
|
if (nullptr != m_pGridItemUtils)
|
|
|
|
|
{
|
|
|
|
|
if (!m_pGridItemUtils->getAllParaValues(map, bOnlyFitted, false))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxParaPropertyPebi::getAllParaUnits(QMap<QString, QString>& map,
|
|
|
|
|
bool bOnlyFitted/* = false*/,
|
|
|
|
|
bool bClearMap /*= true*/)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr != m_pGridItemUtils &&
|
|
|
|
|
!m_pGridItemUtils->getAllParaUnits(map, bOnlyFitted, false))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxParaPropertyPebi::onSerialize(ZxSerializer* ser)
|
|
|
|
|
{
|
|
|
|
|
iDlgBase::onSerialize(ser);
|
|
|
|
|
|
|
|
|
|
ser->write("ParaLists", m_listParas);
|
|
|
|
|
if (nullptr != m_pGridItemUtils)
|
|
|
|
|
{
|
|
|
|
|
m_pGridItemUtils->onSerialize(ser);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxParaPropertyPebi::onDeserialize(ZxSerializer* ser)
|
|
|
|
|
{
|
|
|
|
|
iDlgBase::onDeserialize(ser);
|
|
|
|
|
|
|
|
|
|
m_bUnableSP = true;
|
|
|
|
|
|
|
|
|
|
m_listParas.clear();
|
|
|
|
|
ser->read("ParaLists", m_listParas);
|
|
|
|
|
|
|
|
|
|
refreshUIs(m_listParas);
|
|
|
|
|
|
|
|
|
|
if (nullptr != m_pGridItemUtils)
|
|
|
|
|
{
|
|
|
|
|
m_pGridItemUtils->onDeserialize(ser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_bUnableSP = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// help msg
|
|
|
|
|
void nmWxParaPropertyPebi::slotHelpMsg(QString& s)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr == m_pHelpBox)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_pHelpBox->setHtml(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxParaPropertyPebi::paintEvent(QPaintEvent* e)
|
|
|
|
|
{
|
|
|
|
|
iDlgBase::paintEvent(e);
|
|
|
|
|
}
|