|
|
|
|
@ -4,6 +4,11 @@
|
|
|
|
|
#include "nmDataFault.h"
|
|
|
|
|
#include "nmObjLineCrack.h"
|
|
|
|
|
#include "nmDataFracture.h"
|
|
|
|
|
#include "nmObjRoundOutline.h"
|
|
|
|
|
#include "nmObjRectOutline.h"
|
|
|
|
|
#include "nmObjPolygonOutline.h"
|
|
|
|
|
#include "nmDataOutline.h"
|
|
|
|
|
#include "nmObjBase.h"
|
|
|
|
|
#include "nmDataAnalyzeManager.h"
|
|
|
|
|
|
|
|
|
|
#include <QMetaObject>
|
|
|
|
|
@ -91,6 +96,8 @@ void nmPlotGraphicBinder::updateDataMgr(nmDataAnalyzeManager* pDataMgr)
|
|
|
|
|
m_setBoundGraphics.clear();
|
|
|
|
|
m_mapCrackData.clear();
|
|
|
|
|
m_setBoundCrackGraphics.clear();
|
|
|
|
|
m_mapOutlineData.clear();
|
|
|
|
|
m_setBoundOutlineGraphics.clear();
|
|
|
|
|
m_pDataMgr = pDataMgr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -418,3 +425,345 @@ void nmPlotGraphicBinder::onGraphicCrackVisibleChanged(bool bVisible)
|
|
|
|
|
|
|
|
|
|
pData->setPlotVisible(bVisible);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== 边界图元绑定 ====================
|
|
|
|
|
|
|
|
|
|
// 圆形边界:用户画完后创建数据并绑定
|
|
|
|
|
void nmPlotGraphicBinder::createOutlineForGraphic(nmObjRoundOutline* pGraphic)
|
|
|
|
|
{
|
|
|
|
|
if (!pGraphic || !m_pDataMgr) return;
|
|
|
|
|
|
|
|
|
|
// 清理旧边界图元的绑定(数据中心同一时间只持有一个边界数据)
|
|
|
|
|
QList<nmObjBase*> oldGraphics = m_mapOutlineData.keys();
|
|
|
|
|
foreach (nmObjBase* pOld, oldGraphics) {
|
|
|
|
|
if (pOld != pGraphic) {
|
|
|
|
|
_disconnectOutline(pOld);
|
|
|
|
|
m_mapOutlineData.remove(pOld);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmDataOutline* pData = m_pDataMgr->createOutline();
|
|
|
|
|
pData->setName(pGraphic->getName());
|
|
|
|
|
pData->setOutlinePoints(pGraphic->getAllValues());
|
|
|
|
|
pData->setFlowTypeList(pGraphic->m_vFlowTypeList);
|
|
|
|
|
pData->setOutlineType(NM_Data_Outline_Type::NM_Round_Outline_Type);
|
|
|
|
|
|
|
|
|
|
// 视觉属性同步到数据
|
|
|
|
|
pData->setPenWidth(pGraphic->getPen().widthF());
|
|
|
|
|
QColor roundClr = pGraphic->getBackgrdColor();
|
|
|
|
|
pData->setBackgrdColor(roundClr);
|
|
|
|
|
pData->setBackgrdAlpha(roundClr.alpha());
|
|
|
|
|
pData->setVisualPropsValid(true);
|
|
|
|
|
|
|
|
|
|
double qradius = pGraphic->getAllValues()[2].y() - pGraphic->getAllValues()[0].y();
|
|
|
|
|
pData->setRadius(qradius);
|
|
|
|
|
pData->setCenter(pGraphic->getAllValues()[0]);
|
|
|
|
|
|
|
|
|
|
m_mapOutlineData[pGraphic] = pData;
|
|
|
|
|
m_setBoundOutlineGraphics.insert(pGraphic);
|
|
|
|
|
_connectOutline(pGraphic, pData);
|
|
|
|
|
|
|
|
|
|
if (m_pDataMgr) {
|
|
|
|
|
m_pDataMgr->notifyDataChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 矩形边界:用户画完后创建数据并绑定
|
|
|
|
|
void nmPlotGraphicBinder::createOutlineForGraphic(nmObjRectOutline* pGraphic)
|
|
|
|
|
{
|
|
|
|
|
if (!pGraphic || !m_pDataMgr) return;
|
|
|
|
|
|
|
|
|
|
// 清理旧边界图元的绑定(数据中心同一时间只持有一个边界数据)
|
|
|
|
|
QList<nmObjBase*> oldGraphics = m_mapOutlineData.keys();
|
|
|
|
|
foreach (nmObjBase* pOld, oldGraphics) {
|
|
|
|
|
if (pOld != pGraphic) {
|
|
|
|
|
_disconnectOutline(pOld);
|
|
|
|
|
m_mapOutlineData.remove(pOld);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmDataOutline* pData = m_pDataMgr->createOutline();
|
|
|
|
|
pData->setName(pGraphic->getName());
|
|
|
|
|
pData->setOutlinePoints(pGraphic->getAllValues());
|
|
|
|
|
pData->setFlowTypeList(pGraphic->m_vFlowTypeList);
|
|
|
|
|
pData->setOutlineType(NM_Data_Outline_Type::NM_Rect_Outline_Type);
|
|
|
|
|
|
|
|
|
|
pData->setPenWidth(pGraphic->getPen().widthF());
|
|
|
|
|
pData->setBackgrdColor(pGraphic->getBackgrdColor());
|
|
|
|
|
pData->setBackgrdAlpha(pGraphic->getBackgrdAlpha());
|
|
|
|
|
pData->setVisualPropsValid(true);
|
|
|
|
|
|
|
|
|
|
m_mapOutlineData[pGraphic] = pData;
|
|
|
|
|
m_setBoundOutlineGraphics.insert(pGraphic);
|
|
|
|
|
_connectOutline(pGraphic, pData);
|
|
|
|
|
|
|
|
|
|
if (m_pDataMgr) {
|
|
|
|
|
m_pDataMgr->notifyDataChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 多边形边界:用户画完后创建数据并绑定
|
|
|
|
|
void nmPlotGraphicBinder::createOutlineForGraphic(nmObjPolygonOutline* pGraphic)
|
|
|
|
|
{
|
|
|
|
|
if (!pGraphic || !m_pDataMgr) return;
|
|
|
|
|
|
|
|
|
|
// 清理旧边界图元的绑定(数据中心同一时间只持有一个边界数据)
|
|
|
|
|
QList<nmObjBase*> oldGraphics = m_mapOutlineData.keys();
|
|
|
|
|
foreach (nmObjBase* pOld, oldGraphics) {
|
|
|
|
|
if (pOld != pGraphic) {
|
|
|
|
|
_disconnectOutline(pOld);
|
|
|
|
|
m_mapOutlineData.remove(pOld);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmDataOutline* pData = m_pDataMgr->createOutline();
|
|
|
|
|
pData->setName(pGraphic->getName());
|
|
|
|
|
pData->setOutlinePoints(pGraphic->getAllValues());
|
|
|
|
|
pData->setFlowTypeList(pGraphic->m_vFlowTypeList);
|
|
|
|
|
pData->setOutlineType(NM_Data_Outline_Type::NM_Polygon_Outline_Type);
|
|
|
|
|
|
|
|
|
|
pData->setPenWidth(pGraphic->getPen().widthF());
|
|
|
|
|
pData->setBackgrdColor(pGraphic->getBackgrdColor());
|
|
|
|
|
pData->setBackgrdAlpha(pGraphic->getBackgrdAlpha());
|
|
|
|
|
pData->setVisualPropsValid(true);
|
|
|
|
|
|
|
|
|
|
m_mapOutlineData[pGraphic] = pData;
|
|
|
|
|
m_setBoundOutlineGraphics.insert(pGraphic);
|
|
|
|
|
_connectOutline(pGraphic, pData);
|
|
|
|
|
|
|
|
|
|
if (m_pDataMgr) {
|
|
|
|
|
m_pDataMgr->notifyDataChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 从文件加载,绑定已有边界数据到已有图元
|
|
|
|
|
void nmPlotGraphicBinder::bindOutlineToGraphic(nmObjBase* pGraphic, nmDataOutline* pData)
|
|
|
|
|
{
|
|
|
|
|
if (!pGraphic || !pData) return;
|
|
|
|
|
|
|
|
|
|
m_mapOutlineData[pGraphic] = pData;
|
|
|
|
|
m_setBoundOutlineGraphics.insert(pGraphic);
|
|
|
|
|
|
|
|
|
|
_pushOutlineDataToGraphic(pGraphic, pData);
|
|
|
|
|
_connectOutline(pGraphic, pData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 删除边界图元前,断开绑定并从数据中心移除
|
|
|
|
|
void nmPlotGraphicBinder::removeOutlineBinding(nmObjBase* pGraphic)
|
|
|
|
|
{
|
|
|
|
|
if (!pGraphic) return;
|
|
|
|
|
|
|
|
|
|
_disconnectOutline(pGraphic);
|
|
|
|
|
m_mapOutlineData.remove(pGraphic);
|
|
|
|
|
|
|
|
|
|
if (m_pDataMgr) {
|
|
|
|
|
m_pDataMgr->removeOutlineData();
|
|
|
|
|
m_pDataMgr->notifyDataChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查找边界图元对应的数据指针
|
|
|
|
|
nmDataOutline* nmPlotGraphicBinder::getOutlineDataFor(nmObjBase* pGraphic)
|
|
|
|
|
{
|
|
|
|
|
return m_mapOutlineData.value(pGraphic, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 名称同步:setName 不发信号,由图元在 paintBack 中调用
|
|
|
|
|
void nmPlotGraphicBinder::syncOutlineName(nmObjBase* pGraphic)
|
|
|
|
|
{
|
|
|
|
|
if (!pGraphic) return;
|
|
|
|
|
nmDataOutline* pData = m_mapOutlineData.value(pGraphic, nullptr);
|
|
|
|
|
if (pData && pData->getName() != pGraphic->getName()) {
|
|
|
|
|
pData->setName(pGraphic->getName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 视觉属性兜底同步:paintBack 中调用,确保画笔宽度、填充色、透明度始终同步到数据中心
|
|
|
|
|
void nmPlotGraphicBinder::syncOutlineVisual(nmObjBase* pGraphic)
|
|
|
|
|
{
|
|
|
|
|
if (!pGraphic) return;
|
|
|
|
|
nmDataOutline* pData = m_mapOutlineData.value(pGraphic, nullptr);
|
|
|
|
|
if (!pData) return;
|
|
|
|
|
|
|
|
|
|
// 画笔宽度
|
|
|
|
|
QPen pen = pGraphic->getPen();
|
|
|
|
|
double penWidth = pen.widthF();
|
|
|
|
|
if (pData->getPenWidth() != penWidth) {
|
|
|
|
|
pData->setPenWidth(penWidth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 填充背景色和透明度
|
|
|
|
|
QColor backgrdColor;
|
|
|
|
|
int backgrdAlpha = 0;
|
|
|
|
|
if (nmObjRectOutline* pRect = dynamic_cast<nmObjRectOutline*>(pGraphic)) {
|
|
|
|
|
backgrdColor = pRect->getBackgrdColor();
|
|
|
|
|
backgrdAlpha = pRect->getBackgrdAlpha();
|
|
|
|
|
} else if (nmObjRoundOutline* pRound = dynamic_cast<nmObjRoundOutline*>(pGraphic)) {
|
|
|
|
|
backgrdColor = pRound->getBackgrdColor();
|
|
|
|
|
backgrdAlpha = backgrdColor.alpha(); // 圆形透明度嵌入在 QColor 中
|
|
|
|
|
} else if (nmObjPolygonOutline* pPolygon = dynamic_cast<nmObjPolygonOutline*>(pGraphic)) {
|
|
|
|
|
backgrdColor = pPolygon->getBackgrdColor();
|
|
|
|
|
backgrdAlpha = pPolygon->getBackgrdAlpha();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pData->getBackgrdColor().rgb() != backgrdColor.rgb()) {
|
|
|
|
|
pData->setBackgrdColor(backgrdColor);
|
|
|
|
|
}
|
|
|
|
|
if (pData->getBackgrdAlpha() != backgrdAlpha) {
|
|
|
|
|
pData->setBackgrdAlpha(backgrdAlpha);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pData->setVisualPropsValid(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 建立边界图元与数据的信号连接(三条信号)
|
|
|
|
|
void nmPlotGraphicBinder::_connectOutline(nmObjBase* pGraphic, nmDataOutline* pData)
|
|
|
|
|
{
|
|
|
|
|
QObject::connect(pGraphic, SIGNAL(sigOutlinePointsChanged()),
|
|
|
|
|
this, SLOT(onGraphicOutlinePointsChanged()));
|
|
|
|
|
|
|
|
|
|
QObject::connect(pGraphic, SIGNAL(sigOutlineFlowTypeChanged()),
|
|
|
|
|
this, SLOT(onGraphicOutlineFlowTypeChanged()));
|
|
|
|
|
|
|
|
|
|
QObject::connect(pGraphic, SIGNAL(sigObjVisibleChanged(bool)),
|
|
|
|
|
this, SLOT(onGraphicOutlineVisibleChanged(bool)));
|
|
|
|
|
|
|
|
|
|
m_setBoundOutlineGraphics.insert(pGraphic);
|
|
|
|
|
|
|
|
|
|
// 注入 Binder 指针到图元
|
|
|
|
|
if (nmObjRoundOutline* pRound = dynamic_cast<nmObjRoundOutline*>(pGraphic)) {
|
|
|
|
|
pRound->setGraphicBinder(this);
|
|
|
|
|
} else if (nmObjRectOutline* pRect = dynamic_cast<nmObjRectOutline*>(pGraphic)) {
|
|
|
|
|
pRect->setGraphicBinder(this);
|
|
|
|
|
} else if (nmObjPolygonOutline* pPolygon = dynamic_cast<nmObjPolygonOutline*>(pGraphic)) {
|
|
|
|
|
pPolygon->setGraphicBinder(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 断开边界图元与本 Binder 的信号连接
|
|
|
|
|
void nmPlotGraphicBinder::_disconnectOutline(nmObjBase* pGraphic)
|
|
|
|
|
{
|
|
|
|
|
QObject::disconnect(pGraphic, SIGNAL(sigOutlinePointsChanged()),
|
|
|
|
|
this, SLOT(onGraphicOutlinePointsChanged()));
|
|
|
|
|
|
|
|
|
|
QObject::disconnect(pGraphic, SIGNAL(sigOutlineFlowTypeChanged()),
|
|
|
|
|
this, SLOT(onGraphicOutlineFlowTypeChanged()));
|
|
|
|
|
|
|
|
|
|
QObject::disconnect(pGraphic, SIGNAL(sigObjVisibleChanged(bool)),
|
|
|
|
|
this, SLOT(onGraphicOutlineVisibleChanged(bool)));
|
|
|
|
|
|
|
|
|
|
m_setBoundOutlineGraphics.remove(pGraphic);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 从边界数据对象读取值,写入图元本地副本(加载时用)
|
|
|
|
|
void nmPlotGraphicBinder::_pushOutlineDataToGraphic(nmObjBase* pGraphic, nmDataOutline* pData)
|
|
|
|
|
{
|
|
|
|
|
pGraphic->blockSignals(true);
|
|
|
|
|
|
|
|
|
|
pGraphic->setName(pData->getName());
|
|
|
|
|
|
|
|
|
|
QVector<int> flowTypes = pData->getFlowTypeList();
|
|
|
|
|
|
|
|
|
|
bool bPushVisual = pData->hasVisualProps();
|
|
|
|
|
|
|
|
|
|
if (nmObjRoundOutline* pRound = dynamic_cast<nmObjRoundOutline*>(pGraphic)) {
|
|
|
|
|
pRound->m_vFlowTypeList = flowTypes;
|
|
|
|
|
if (bPushVisual) {
|
|
|
|
|
QPen pen = pRound->getPen();
|
|
|
|
|
pen.setWidthF(pData->getPenWidth());
|
|
|
|
|
pRound->setPen(pen);
|
|
|
|
|
QColor clr = pData->getBackgrdColor();
|
|
|
|
|
clr.setAlpha(pData->getBackgrdAlpha());
|
|
|
|
|
pRound->setBackgrdColor(clr);
|
|
|
|
|
}
|
|
|
|
|
} else if (nmObjRectOutline* pRect = dynamic_cast<nmObjRectOutline*>(pGraphic)) {
|
|
|
|
|
pRect->m_vFlowTypeList = flowTypes;
|
|
|
|
|
if (bPushVisual) {
|
|
|
|
|
QPen pen = pRect->getPen();
|
|
|
|
|
pen.setWidthF(pData->getPenWidth());
|
|
|
|
|
pRect->setPen(pen);
|
|
|
|
|
pRect->setBackgrdColor(pData->getBackgrdColor());
|
|
|
|
|
pRect->setBackgrdAlpha(pData->getBackgrdAlpha());
|
|
|
|
|
}
|
|
|
|
|
} else if (nmObjPolygonOutline* pPolygon = dynamic_cast<nmObjPolygonOutline*>(pGraphic)) {
|
|
|
|
|
pPolygon->m_vFlowTypeList = flowTypes;
|
|
|
|
|
if (bPushVisual) {
|
|
|
|
|
QPen pen = pPolygon->getPen();
|
|
|
|
|
pen.setWidthF(pData->getPenWidth());
|
|
|
|
|
pPolygon->setPen(pen);
|
|
|
|
|
pPolygon->setBackgrdColor(pData->getBackgrdColor());
|
|
|
|
|
pPolygon->setBackgrdAlpha(pData->getBackgrdAlpha());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pGraphic->blockSignals(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== 边界图元信号 → 数据同步 ====================
|
|
|
|
|
|
|
|
|
|
// 边界点坐标变更
|
|
|
|
|
void nmPlotGraphicBinder::onGraphicOutlinePointsChanged()
|
|
|
|
|
{
|
|
|
|
|
nmObjBase* pGraphic = qobject_cast<nmObjBase*>(sender());
|
|
|
|
|
if (!pGraphic) return;
|
|
|
|
|
|
|
|
|
|
nmDataOutline* pData = m_mapOutlineData.value(pGraphic, nullptr);
|
|
|
|
|
if (!pData) return;
|
|
|
|
|
|
|
|
|
|
pData->setOutlinePoints(pGraphic->getAllValues());
|
|
|
|
|
|
|
|
|
|
// 圆形边界额外同步 radius 和 center
|
|
|
|
|
if (nmObjRoundOutline* pRound = dynamic_cast<nmObjRoundOutline*>(pGraphic)) {
|
|
|
|
|
QVector<QPointF> pts = pRound->getAllValues();
|
|
|
|
|
if (pts.count() >= 3) {
|
|
|
|
|
double radius = pts[2].y() - pts[0].y();
|
|
|
|
|
pData->setRadius(radius);
|
|
|
|
|
pData->setCenter(pts[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_pDataMgr) {
|
|
|
|
|
m_pDataMgr->notifyDataChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 边界流动类型变更
|
|
|
|
|
void nmPlotGraphicBinder::onGraphicOutlineFlowTypeChanged()
|
|
|
|
|
{
|
|
|
|
|
nmObjBase* pGraphic = qobject_cast<nmObjBase*>(sender());
|
|
|
|
|
if (!pGraphic) return;
|
|
|
|
|
|
|
|
|
|
nmDataOutline* pData = m_mapOutlineData.value(pGraphic, nullptr);
|
|
|
|
|
if (!pData) return;
|
|
|
|
|
|
|
|
|
|
QVector<int> flowTypes;
|
|
|
|
|
if (nmObjRoundOutline* pRound = dynamic_cast<nmObjRoundOutline*>(pGraphic)) {
|
|
|
|
|
flowTypes = pRound->m_vFlowTypeList;
|
|
|
|
|
} else if (nmObjRectOutline* pRect = dynamic_cast<nmObjRectOutline*>(pGraphic)) {
|
|
|
|
|
flowTypes = pRect->m_vFlowTypeList;
|
|
|
|
|
} else if (nmObjPolygonOutline* pPolygon = dynamic_cast<nmObjPolygonOutline*>(pGraphic)) {
|
|
|
|
|
flowTypes = pPolygon->m_vFlowTypeList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pData->setFlowTypeList(flowTypes);
|
|
|
|
|
|
|
|
|
|
if (m_pDataMgr) {
|
|
|
|
|
m_pDataMgr->notifyDataChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 边界可见性变更
|
|
|
|
|
void nmPlotGraphicBinder::onGraphicOutlineVisibleChanged(bool bVisible)
|
|
|
|
|
{
|
|
|
|
|
nmObjBase* pGraphic = qobject_cast<nmObjBase*>(sender());
|
|
|
|
|
if (!pGraphic) return;
|
|
|
|
|
|
|
|
|
|
nmDataOutline* pData = m_mapOutlineData.value(pGraphic, nullptr);
|
|
|
|
|
if (!pData) return;
|
|
|
|
|
|
|
|
|
|
pData->setPlotVisible(bVisible);
|
|
|
|
|
|
|
|
|
|
if (m_pDataMgr) {
|
|
|
|
|
m_pDataMgr->notifyDataChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|