You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.8 KiB
C++
89 lines
2.8 KiB
C++
#include "nmWxMeasuringScaleDlg.h"
|
|
|
|
#include <QVBoxLayout>
|
|
#include <QTableWidget>
|
|
#include <QHeaderView>
|
|
#include <QPushButton>
|
|
#include <QComboBox>
|
|
|
|
#include "nmDataAnalyzeManager.h"
|
|
#include "nmDataMeasuringScale.h"
|
|
#include "nmGUIComponentLineEdit.h"
|
|
|
|
Q_DECLARE_METATYPE(double *)
|
|
Q_DECLARE_METATYPE(QString *)
|
|
|
|
nmWxMeasuringScaleDlg::nmWxMeasuringScaleDlg(QPointF startPoint, QPointF endPoint, double *pLength):
|
|
m_startPoint(startPoint), m_endPoint(endPoint),
|
|
m_pLength(pLength) {
|
|
|
|
m_sStartPoint = QString("(%1, %2)").arg(m_startPoint.x()).arg(m_startPoint.y());
|
|
m_sEndPoint = QString("(%1, %2)").arg(m_endPoint.x()).arg(m_endPoint.y());
|
|
|
|
m_data.getStartPoint().setName(tr("start point: "));
|
|
m_data.getStartPoint().setValue(m_sStartPoint);
|
|
|
|
m_data.getEndPoint().setName(tr("end point: "));
|
|
m_data.getEndPoint().setValue(m_sEndPoint);
|
|
|
|
m_data.getLength().setName(tr("length: "));
|
|
m_data.getLength().setValue(*m_pLength);
|
|
|
|
this->initUI();
|
|
this->resize(520, 220);
|
|
this->setWindowTitle(tr("MeasuringScale setting"));
|
|
}
|
|
|
|
void nmWxMeasuringScaleDlg::initUI() {
|
|
m_mainLayout = new QVBoxLayout;
|
|
this->setLayout(m_mainLayout);
|
|
|
|
// 构建组件
|
|
this->initComponents();
|
|
// 底部确定和取消的按钮
|
|
QHBoxLayout* hLayout = new QHBoxLayout;
|
|
QPushButton* saveBT = new QPushButton(tr("Save"));
|
|
QPushButton* cancelBT = new QPushButton(tr("Cancel"));
|
|
connect(saveBT, SIGNAL(clicked()), this, SLOT(accept()));
|
|
connect(cancelBT, SIGNAL(clicked()), this, SLOT(reject()));
|
|
hLayout->addStretch();
|
|
hLayout->addWidget(saveBT);
|
|
hLayout->addWidget(cancelBT);
|
|
m_mainLayout->addLayout(hLayout);
|
|
}
|
|
|
|
void nmWxMeasuringScaleDlg::initComponents() {
|
|
// 起始点
|
|
nmGUIComponentBase* pStartPointCom = new nmGUIComponentLineEdit(&m_data.getStartPoint(), false);
|
|
m_mainLayout->addWidget(pStartPointCom);
|
|
|
|
// 终止点
|
|
nmGUIComponentBase* pEndPointCom = new nmGUIComponentLineEdit(&m_data.getEndPoint(), false);
|
|
m_mainLayout->addWidget(pEndPointCom);
|
|
|
|
// 长度设置
|
|
nmGUIComponentBase* pLengthCom = new nmGUIComponentLineEdit(&m_data.getLength(), true);
|
|
m_mainLayout->addWidget(pLengthCom);
|
|
|
|
m_listComUIs.append(pStartPointCom);
|
|
m_listComUIs.append(pEndPointCom);
|
|
m_listComUIs.append(pLengthCom);
|
|
}
|
|
|
|
void nmWxMeasuringScaleDlg::accept()
|
|
{
|
|
for (int i=0;i<m_listComUIs.size();i++)
|
|
{
|
|
nmGUIComponentBase* pComUI = m_listComUIs[i];
|
|
pComUI->updateValueToOrigin();
|
|
}
|
|
|
|
// 深拷贝 m_data 到堆内存
|
|
nmDataMeasuringScale *pData = new nmDataMeasuringScale(m_data); // 调用拷贝构造函数
|
|
nmDataAnalyzeManager::getCurrentInstance()->setMeasuringScaleData(pData);
|
|
|
|
*m_pLength = m_data.getLength().getValue().toDouble();
|
|
// 在这里添加预处理逻辑
|
|
iDlgBase::accept(); // 调用基类实现
|
|
}
|