|
|
|
|
@ -11,8 +11,7 @@
|
|
|
|
|
#include "ZxObjText.h"
|
|
|
|
|
|
|
|
|
|
#include "nmObjLineMeasure.h"
|
|
|
|
|
#include "nmDataAnalyzeManager.h"
|
|
|
|
|
#include "nmDataMeasure.h"
|
|
|
|
|
#include "nmPlotGraphicBinder.h"
|
|
|
|
|
|
|
|
|
|
ZX_DEFINE_DYNAMIC(nObjLineMeasure, nmObjLineMeasure)
|
|
|
|
|
|
|
|
|
|
@ -20,7 +19,7 @@ nmObjLineMeasure::nmObjLineMeasure()
|
|
|
|
|
: nmObjLine("", NULL, NULL)
|
|
|
|
|
{
|
|
|
|
|
m_dLength = 0.0;
|
|
|
|
|
m_pMeasureData = nmDataAnalyzeManager::getCurrentInstance()->getMeasureData();
|
|
|
|
|
m_pGraphicBinder = nullptr;
|
|
|
|
|
m_sObjTag = "nObjLineMeasure";
|
|
|
|
|
nmObjPoint::initFlags();
|
|
|
|
|
m_oDot = ZxDot(DTS_Circle, QColor(255, 165, 0), 0.5f, true);
|
|
|
|
|
@ -35,7 +34,7 @@ nmObjLineMeasure::nmObjLineMeasure(const QString& sName, \
|
|
|
|
|
ZxSubAxisY* pAxisY)
|
|
|
|
|
: nmObjLine(sName, pAxisX, pAxisY) {
|
|
|
|
|
m_dLength = 0.0;
|
|
|
|
|
m_pMeasureData = nmDataAnalyzeManager::getCurrentInstance()->getMeasureData();
|
|
|
|
|
m_pGraphicBinder = nullptr;
|
|
|
|
|
m_sObjTag = "nObjLineMeasure";
|
|
|
|
|
nmObjPoint::initFlags();
|
|
|
|
|
m_oDot = ZxDot(DTS_Circle, QColor(255, 165, 0), 0.5f, true);
|
|
|
|
|
@ -59,8 +58,12 @@ void nmObjLineMeasure::initSubObjs() {
|
|
|
|
|
|
|
|
|
|
void nmObjLineMeasure::paintBack(QPainter* painter, const ZxPaintParam& param) {
|
|
|
|
|
Q_ASSERT(m_vecPoints.count() >= 2);
|
|
|
|
|
m_vecPoints[0] = m_pMeasureData->getStartPoint();
|
|
|
|
|
m_vecPoints[1] = m_pMeasureData->getEndPoint();
|
|
|
|
|
|
|
|
|
|
// 坐标同步:拟合功能修改数据后,在绘制时将新坐标推回图元
|
|
|
|
|
if (m_pGraphicBinder) {
|
|
|
|
|
m_pGraphicBinder->syncMeasurePoints(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPointF pt1 = getPosOf(m_vecPoints[0]);
|
|
|
|
|
QPointF pt2 = getPosOf(m_vecPoints[1]);
|
|
|
|
|
QLineF oLine = QLineF(pt1, pt2);
|
|
|
|
|
@ -113,28 +116,19 @@ bool nmObjLineMeasure::drawSelStates(QPainter* painter, QLineF& oLine) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmObjLineMeasure::afterCreated() {
|
|
|
|
|
// <20><><EFBFBD>㳤<EFBFBD><E3B3A4>
|
|
|
|
|
QPointF pStart = m_vecPoints[0];
|
|
|
|
|
QPointF pEnd = m_vecPoints[1];
|
|
|
|
|
double dLength = QLineF(pStart, pEnd).length();
|
|
|
|
|
if (m_pMeasureData != nullptr && pEnd != pStart) {
|
|
|
|
|
m_pMeasureData->setStartPoint(pStart);
|
|
|
|
|
m_pMeasureData->setEndPoint(pEnd);
|
|
|
|
|
nmDataAttribute lenAttr = m_pMeasureData->getLength();
|
|
|
|
|
lenAttr.setValue(dLength);
|
|
|
|
|
m_pMeasureData->setLength(lenAttr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_pMeasureData != nullptr && pEnd == pStart) {
|
|
|
|
|
m_pMeasureData->setCurrentPoint(pStart);
|
|
|
|
|
nmDataAttribute lenAttr = m_pMeasureData->getLength();
|
|
|
|
|
lenAttr.setValue(dLength);
|
|
|
|
|
m_pMeasureData->setLength(lenAttr);
|
|
|
|
|
if (m_pGraphicBinder) {
|
|
|
|
|
m_pGraphicBinder->createMeasureForGraphic(this);
|
|
|
|
|
}
|
|
|
|
|
this->setLockPos(true);
|
|
|
|
|
this->setReadOnly(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmObjLineMeasure::removeData() {
|
|
|
|
|
if (m_pGraphicBinder) {
|
|
|
|
|
m_pGraphicBinder->removeMeasureBinding(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmObjLineMeasure::onSerialize(ZxSerializer* ser) {
|
|
|
|
|
nmObjLine::onSerialize(ser);
|
|
|
|
|
ser->write("Length", m_dLength);
|
|
|
|
|
|