|
|
#include "ZxBaseUtil.h"
|
|
|
#include "zxLogInstance.h"
|
|
|
|
|
|
#include <QDebug>
|
|
|
#include <QDir>
|
|
|
#include <QFileDialog>
|
|
|
#include <QFileInfo>
|
|
|
#include <QHash>
|
|
|
#include <QImageReader>
|
|
|
#include <QScopedPointer>
|
|
|
#include <QSet>
|
|
|
#include <QTemporaryFile>
|
|
|
#include <QUndoStack>
|
|
|
|
|
|
#include "ZxSubAxisX.h"
|
|
|
#include "ZxSubAxisY.h"
|
|
|
#include "ZxSubTitle.h"
|
|
|
|
|
|
#include "ZxPlot.h"
|
|
|
#include "ZxObjCurve.h"
|
|
|
#include "nmPlotScene.h"
|
|
|
#include "nmPlotView.h"
|
|
|
|
|
|
#include "nmObjPoint.h"
|
|
|
#include "nmObjLine.h"
|
|
|
#include "nmObjPolygon.h"
|
|
|
#include "nmObjPolygonOutline.h"
|
|
|
#include "nmObjLineCrack.h"
|
|
|
#include "nmObjLineFault.h"
|
|
|
#include "nmObjLineMeasuringScale.h"
|
|
|
#include "nmObjPointWell.h"
|
|
|
#include "nmObjLineMeasure.h"
|
|
|
#include "nmGuiPlotCmdHelper.h"
|
|
|
#include "nmGuiPlot.h"
|
|
|
#include "nmMapObjectState.h"
|
|
|
#include "nmPlotDialogContext.h"
|
|
|
#include "nmPlotDialogContextProvider.h"
|
|
|
|
|
|
#include "nmDataLogFile.h"
|
|
|
#include "nmDataMeasuringScale.h"
|
|
|
#include "nmSingalCenter.h"
|
|
|
|
|
|
#include "ZxDataProject.h"
|
|
|
#include "TreeWxMain.h"
|
|
|
|
|
|
#include "Defines.h"
|
|
|
#include "zxSysUtils.h"
|
|
|
|
|
|
#include "nmObjRectOutline.h"
|
|
|
#include "nmObjRect.h"
|
|
|
|
|
|
#include "nmObjRoundOutline.h"
|
|
|
#include "nmObjRound.h"
|
|
|
|
|
|
#include "nmObjRegion.h"
|
|
|
#include "nmObjRegionMark.h"
|
|
|
|
|
|
#include "nmObjDeleteTool.h"
|
|
|
|
|
|
#include "nmDataAnalyzeManager.h"
|
|
|
#include "nmDataFault.h"
|
|
|
#include "nmDataFracture.h"
|
|
|
#include "nmDataOutline.h"
|
|
|
#include "nmDataRegionMark.h"
|
|
|
#include "nmDataRegion.h"
|
|
|
#include "nmDataAxis.h"
|
|
|
#include "nmDataWellBase.h"
|
|
|
|
|
|
#include "nmPlotGraphicBinder.h"
|
|
|
|
|
|
#include "ZxDataWell.h"
|
|
|
|
|
|
#include "ZxDataGaugeP.h"
|
|
|
#include "ZxDataGaugeF.h"
|
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
#include <QCoreApplication>
|
|
|
#include <QLineF>
|
|
|
#include <QPointer>
|
|
|
#include <QResizeEvent>
|
|
|
#include <QTimer>
|
|
|
#include <QWidget>
|
|
|
|
|
|
// 新增、删除和边界替换共用此命令,一次提交对应一个撤销记录。
|
|
|
class nmMapObjectCommand : public QUndoCommand
|
|
|
{
|
|
|
public:
|
|
|
// before 为空表示新增,after 为空表示删除,两者均存在表示替换。
|
|
|
nmMapObjectCommand(nmGuiPlot* plot, const QSharedPointer<nmMapObjectState>& before,
|
|
|
const QSharedPointer<nmMapObjectState>& after, QUndoCommand* parent = nullptr)
|
|
|
: QUndoCommand(parent), m_plot(plot), m_manager(plot->boundDataManager()),
|
|
|
m_before(before), m_after(after), m_initialRedo(true)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
// 撤销时移除提交后的图元,恢复提交前的图元及数据。
|
|
|
virtual void undo() override { apply(m_after, m_before); }
|
|
|
|
|
|
// 重做时从提交前的状态恢复到提交后的状态。
|
|
|
virtual void redo() override
|
|
|
{
|
|
|
if (m_initialRedo) {
|
|
|
m_initialRedo = false;
|
|
|
} else {
|
|
|
apply(m_before, m_after);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
// 应用一侧快照。切换分析后,原命令不能写入当前分析的业务数据。
|
|
|
void apply(QSharedPointer<nmMapObjectState>& current,
|
|
|
const QSharedPointer<nmMapObjectState>& target)
|
|
|
{
|
|
|
if (m_plot.isNull() || m_manager.isNull() ||
|
|
|
m_plot->boundDataManager() != m_manager.data()) return;
|
|
|
if (current) {
|
|
|
nmObjBase* object = nmObjBase::findHistoryObject(m_plot->m_pPlot, current->id);
|
|
|
// 保存移除前的当前状态,恢复时保留后续修改的业务参数和样式。
|
|
|
const QSharedPointer<nmMapObjectState> snapshot = m_plot->captureMapObject(object);
|
|
|
if (!snapshot || !m_plot->removeMapObject(object)) return;
|
|
|
current = snapshot;
|
|
|
}
|
|
|
if (target && !m_plot->restoreMapObject(*target) && current) {
|
|
|
// 替换恢复失败时,尽量还原事务开始前的对象。
|
|
|
m_plot->restoreMapObject(*current);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
QPointer<nmGuiPlot> m_plot; ///< 操作所属地图的弱引用。
|
|
|
QPointer<nmDataAnalyzeManager> m_manager; ///< 操作发生时绑定的数据管理器,用于校验恢复范围。
|
|
|
QSharedPointer<nmMapObjectState> m_before; ///< 提交前快照,为空时撤销仅移除新增对象。
|
|
|
QSharedPointer<nmMapObjectState> m_after; ///< 提交后快照,为空时重做仅执行删除。
|
|
|
bool m_initialRedo; ///< 入栈会调用一次 redo,原操作已提交,首次跳过应用。
|
|
|
};
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
void includeMapPoint(const QPointF& oPoint,
|
|
|
bool& bHasBounds,
|
|
|
double& dMinX,
|
|
|
double& dMaxX,
|
|
|
double& dMinY,
|
|
|
double& dMaxY)
|
|
|
{
|
|
|
if(!qIsFinite(oPoint.x()) || !qIsFinite(oPoint.y())) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if(!bHasBounds) {
|
|
|
dMinX = dMaxX = oPoint.x();
|
|
|
dMinY = dMaxY = oPoint.y();
|
|
|
bHasBounds = true;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
dMinX = qMin(dMinX, oPoint.x());
|
|
|
dMaxX = qMax(dMaxX, oPoint.x());
|
|
|
dMinY = qMin(dMinY, oPoint.y());
|
|
|
dMaxY = qMax(dMaxY, oPoint.y());
|
|
|
}
|
|
|
|
|
|
void includeMapPoints(const QVector<QPointF>& vecPoints,
|
|
|
bool& bHasBounds,
|
|
|
double& dMinX,
|
|
|
double& dMaxX,
|
|
|
double& dMinY,
|
|
|
double& dMaxY)
|
|
|
{
|
|
|
foreach(const QPointF& oPoint, vecPoints) {
|
|
|
includeMapPoint(oPoint, bHasBounds,
|
|
|
dMinX, dMaxX, dMinY, dMaxY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
nmGuiPlot::nmGuiPlot(bool bUseBtns, QWidget *parent) :
|
|
|
iGuiPlot(bUseBtns, parent),
|
|
|
m_pBackgroundImageCache(NULL),
|
|
|
m_nBackgroundImageCacheKey(0),
|
|
|
m_pGraphicBinder(NULL),
|
|
|
m_pDataManager(nmDataAnalyzeManager::getCurrentInstance()),
|
|
|
m_bApplyingAxisRange(false),
|
|
|
m_bAxisInitializationPending(false),
|
|
|
m_bMeasureEditingLocked(false),
|
|
|
m_bMapEditingLocked(false)
|
|
|
{
|
|
|
m_bUseBtns = bUseBtns;
|
|
|
|
|
|
if(NULL != m_pCmdHelper) {
|
|
|
delete m_pCmdHelper;
|
|
|
m_pCmdHelper = NULL;
|
|
|
}
|
|
|
|
|
|
m_pCmdHelper = new nmGuiPlotCmdHelper(this);
|
|
|
Q_ASSERT(NULL != m_pCmdHelper);
|
|
|
connect(m_pCmdHelper, SIGNAL(sigMeasureCommitted()), this, SIGNAL(sigMeasureCommitted()));
|
|
|
|
|
|
m_sChartCmdType = "NmDemo2DType";
|
|
|
|
|
|
setWindowTitle(tr("nmGuiPlot"));
|
|
|
|
|
|
m_pGraphicBinder = new nmPlotGraphicBinder(m_pDataManager, this);
|
|
|
|
|
|
}
|
|
|
|
|
|
nmGuiPlot::~nmGuiPlot()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initUI(QString sTitle,
|
|
|
QSize szDefault /*= QSize(265, 203)*/)
|
|
|
{
|
|
|
iGuiPlot::initUI(sTitle, szDefault);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initSheets()
|
|
|
{
|
|
|
// iGuiPlot::initSheets();
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initMainLayout()
|
|
|
{
|
|
|
iGuiPlot::initMainLayout();
|
|
|
}
|
|
|
|
|
|
QWidget* nmGuiPlot::initChartLayout(QString sTitle, QSize szDefault)
|
|
|
{
|
|
|
return iGuiPlot::initChartLayout(sTitle, szDefault);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initChartView(QString sTitle, QSize szDefault)
|
|
|
{
|
|
|
// iGuiPlot::initChartView(sTitle, szDefault);
|
|
|
m_pPlotView = new nmPlotView();
|
|
|
Q_ASSERT(NULL != m_pPlotView);
|
|
|
m_pPlotScene = new nmPlotScene();
|
|
|
Q_ASSERT(NULL != m_pPlotScene);
|
|
|
m_pPlotView->setScene(m_pPlotScene);
|
|
|
m_pPlotScene->init(m_pPlotView, sTitle, szDefault);
|
|
|
|
|
|
//m_pPlotView->setSimpleMode(true);
|
|
|
|
|
|
m_pPlot = m_pPlotScene->m_pPlot;
|
|
|
m_pPlotView->setMargins(0, 0, 0, 0);
|
|
|
m_pPlotView->setZoomMode(ZxRenderView::eZoomFitWindow, true);
|
|
|
connectSignals();
|
|
|
|
|
|
initDefultGeoObj();
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::connectSignals()
|
|
|
{
|
|
|
iGuiPlot::connectSignals();
|
|
|
|
|
|
if (nmPlotView* view = qobject_cast<nmPlotView*>(m_pPlotView)) {
|
|
|
connect(view, SIGNAL(sigMapHistoryActionRequested(QString)),
|
|
|
this, SLOT(runAction(QString)), Qt::UniqueConnection);
|
|
|
}
|
|
|
|
|
|
// your owns
|
|
|
if(NULL != m_pPlot) {
|
|
|
// disconnect(m_pPlot, SIGNAL(sigUpdate()), \
|
|
|
// m_pPlotView->viewport(), SLOT(update()));
|
|
|
// connect(m_pPlot, SIGNAL(sigUpdate()), \
|
|
|
// m_pPlotView->viewport(), SLOT(update()));
|
|
|
}
|
|
|
|
|
|
nmSingalCenter* sCenter = nmSingalCenter::getInstance();
|
|
|
connect(sCenter, SIGNAL(sigDeleteWell(QString)), this, SLOT(slotDeleteWell(QString)));
|
|
|
// 初始化和成果恢复都会连接信号,同一窗口只能响应一次比例尺操作。
|
|
|
connect(sCenter, SIGNAL(sigMeasuringScale(QPointF, QPointF, void*)),
|
|
|
this, SLOT(slotMeasuringScale(QPointF, QPointF, void*)),
|
|
|
Qt::UniqueConnection);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::runUpdate()
|
|
|
{
|
|
|
// iGuiPlot::updatePlots();
|
|
|
if(NULL != m_pPlot) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::runAction(QString sAction)
|
|
|
{
|
|
|
Q_ASSERT(NULL != m_pCmdHelper);
|
|
|
return m_pCmdHelper->runAction(sAction);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::cancelActiveTools()
|
|
|
{
|
|
|
nmGuiPlotCmdHelper* helper = dynamic_cast<nmGuiPlotCmdHelper*>(m_pCmdHelper);
|
|
|
if(helper != NULL) {
|
|
|
helper->cancelActiveTools();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void nmGuiPlot::initDefultGeoObj()
|
|
|
{
|
|
|
nmDataAnalyzeManager* pDataManager = dataManager();
|
|
|
if(pDataManager == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
nmDataAxis* pAxisData = pDataManager->getAxisData();
|
|
|
|
|
|
if(pAxisData == nullptr) {
|
|
|
pAxisData = new nmDataAxis;
|
|
|
// 将 pAxisData 存入数据中心
|
|
|
pDataManager->setAxisData(pAxisData);
|
|
|
}
|
|
|
|
|
|
// 获取井数据,来自数据中心
|
|
|
QVector<nmDataWellBase*> vecWellDatas = pDataManager->getWellDataList();
|
|
|
|
|
|
// 数据中心没有一口井数据,添加默认井数据
|
|
|
if(vecWellDatas.isEmpty()) {
|
|
|
// 获取当前默认井数据
|
|
|
ZxDataWell* pWellData = zxCurWell;
|
|
|
|
|
|
if(pWellData == nullptr) {
|
|
|
this->setPlotsByDataManger(pDataManager);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 判断是哪一种井类型,初始化对应的参数
|
|
|
QString wellClass = pWellData->getWellClassEn();
|
|
|
|
|
|
QVector<nmPressureGaugeRecord> vecPressureRecords;
|
|
|
QVector<nmFlowGaugeRecord> vecFlowRecords;
|
|
|
NM_WELL_CATEGORY eWellCategory = NM_WellCategory_Unknown;
|
|
|
if(!nmDataAnalyzeManager::readFrameworkWellCurves(
|
|
|
pWellData,
|
|
|
vecPressureRecords,
|
|
|
vecFlowRecords,
|
|
|
eWellCategory)) {
|
|
|
this->setPlotsByDataManger(pDataManager);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if(ZxBaseUtil::isSameStr(wellClass, "VerticalWell")) {
|
|
|
// 初始化直井默认参数
|
|
|
nmDataWellBase* pWell = pDataManager->createWell(NM_WELL_MODEL::Vertical_Well);
|
|
|
nmDataVerticalWell* m_VerticalWell = dynamic_cast<nmDataVerticalWell*>(pWell);
|
|
|
|
|
|
if(m_VerticalWell == nullptr) {
|
|
|
this->setPlotsByDataManger(pDataManager);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_VerticalWell->setWellName(pWellData->getName());
|
|
|
m_VerticalWell->setWellCode(pWellData->getCode());
|
|
|
m_VerticalWell->setWellCategory(eWellCategory);
|
|
|
nmDataAttribute tempAttr = m_VerticalWell->getX();
|
|
|
tempAttr.setValue(pWellData->getLocationX());
|
|
|
m_VerticalWell->setX(tempAttr);
|
|
|
tempAttr = m_VerticalWell->getY();
|
|
|
tempAttr.setValue(pWellData->getLocationY());
|
|
|
m_VerticalWell->setY(tempAttr);
|
|
|
tempAttr = m_VerticalWell->getRadius();
|
|
|
tempAttr.setValue(pWellData->getWellRadius());
|
|
|
m_VerticalWell->setRadius(tempAttr);
|
|
|
|
|
|
// 设置井的压力、流量记录列表,并按默认规则选中当前记录
|
|
|
nmDataAnalyzeManager::applyGaugeRecordsToWell(
|
|
|
m_VerticalWell, vecPressureRecords, vecFlowRecords);
|
|
|
|
|
|
pDataManager->updateWellHistoryData(m_VerticalWell);
|
|
|
|
|
|
// 设置为当前查看的井
|
|
|
pDataManager->setCurWellData(m_VerticalWell);
|
|
|
} else if(ZxBaseUtil::isSameStr(wellClass, "VerticalFracturedWell")) {
|
|
|
|
|
|
// 初始化垂直裂缝井默认参数
|
|
|
nmDataWellBase* pWell = pDataManager->createWell(NM_WELL_MODEL::Vertical_Fractured_Well);
|
|
|
nmDataVerticalFracturedWell* m_VFracturedWell = dynamic_cast<nmDataVerticalFracturedWell*>(pWell);
|
|
|
|
|
|
if(m_VFracturedWell == nullptr) {
|
|
|
this->setPlotsByDataManger(pDataManager);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_VFracturedWell->setWellName(pWellData->getName());
|
|
|
m_VFracturedWell->setWellCode(pWellData->getCode());
|
|
|
m_VFracturedWell->setWellCategory(eWellCategory);
|
|
|
nmDataAttribute tempAttr = m_VFracturedWell->getX();
|
|
|
tempAttr.setValue(pWellData->getLocationX());
|
|
|
m_VFracturedWell->setX(tempAttr);
|
|
|
tempAttr = m_VFracturedWell->getY();
|
|
|
tempAttr.setValue(pWellData->getLocationY());
|
|
|
m_VFracturedWell->setY(tempAttr);
|
|
|
tempAttr = m_VFracturedWell->getRadius();
|
|
|
tempAttr.setValue(pWellData->getWellRadius());
|
|
|
m_VFracturedWell->setRadius(tempAttr);
|
|
|
|
|
|
// 设置井的压力、流量记录列表,并按默认规则选中当前记录
|
|
|
nmDataAnalyzeManager::applyGaugeRecordsToWell(
|
|
|
m_VFracturedWell, vecPressureRecords, vecFlowRecords);
|
|
|
|
|
|
pDataManager->updateWellHistoryData(m_VFracturedWell);
|
|
|
|
|
|
// 更新裂缝位置信息
|
|
|
m_VFracturedWell->setFracs();
|
|
|
|
|
|
// 设置为当前查看的井
|
|
|
pDataManager->setCurWellData(m_VFracturedWell);
|
|
|
} else if(ZxBaseUtil::isSameStr(wellClass, "HorizontalMultiFracturedWell")) {
|
|
|
|
|
|
// 初始化多段压裂水平井默认参数
|
|
|
nmDataWellBase* pWell = pDataManager->createWell(NM_WELL_MODEL::Horizontal_Fractured_Well);
|
|
|
nmDataHorizontalFracturedWell* m_HFracturedWell = dynamic_cast<nmDataHorizontalFracturedWell*>(pWell);
|
|
|
|
|
|
if(m_HFracturedWell == nullptr) {
|
|
|
this->setPlotsByDataManger(pDataManager);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_HFracturedWell->setWellName(pWellData->getName());
|
|
|
m_HFracturedWell->setWellCode(pWellData->getCode());
|
|
|
m_HFracturedWell->setWellCategory(eWellCategory);
|
|
|
nmDataAttribute tempAttr = m_HFracturedWell->getX();
|
|
|
tempAttr.setValue(pWellData->getLocationX());
|
|
|
m_HFracturedWell->setX(tempAttr);
|
|
|
tempAttr = m_HFracturedWell->getY();
|
|
|
tempAttr.setValue(pWellData->getLocationY());
|
|
|
m_HFracturedWell->setY(tempAttr);
|
|
|
tempAttr = m_HFracturedWell->getRadius();
|
|
|
tempAttr.setValue(pWellData->getWellRadius());
|
|
|
m_HFracturedWell->setRadius(tempAttr);
|
|
|
|
|
|
// 设置井的压力、流量记录列表,并按默认规则选中当前记录
|
|
|
nmDataAnalyzeManager::applyGaugeRecordsToWell(
|
|
|
m_HFracturedWell, vecPressureRecords, vecFlowRecords);
|
|
|
|
|
|
pDataManager->updateWellHistoryData(m_HFracturedWell);
|
|
|
|
|
|
// 计算裂缝数据
|
|
|
m_HFracturedWell->setFracs();
|
|
|
|
|
|
// 设置为当前查看的井
|
|
|
pDataManager->setCurWellData(m_HFracturedWell);
|
|
|
}
|
|
|
|
|
|
// 重新获取添加后的井数据
|
|
|
pDataManager->appendNmWellData(pDataManager->getCurWellData());
|
|
|
vecWellDatas = pDataManager->getWellDataList();
|
|
|
}
|
|
|
|
|
|
// 极端兼容入口没有预先建立边界时,也按当前井位置创建一次性默认边界。
|
|
|
if(pDataManager->getOutlineData() == nullptr) {
|
|
|
pDataManager->createDefaultOutlineFromWells();
|
|
|
}
|
|
|
|
|
|
// 根据数据中心的数据渲染所有的图元,上面只是为了保证打开时有一口井和边界
|
|
|
this->setPlotsByDataManger(pDataManager);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initAxisFromData(nmDataAnalyzeManager* pDataManager)
|
|
|
{
|
|
|
Q_ASSERT(nullptr != pDataManager);
|
|
|
// 0.坐标轴
|
|
|
// 0.1 获取坐标轴数据,来自数据中心
|
|
|
nmDataAxis* pAxisData = pDataManager->getAxisData();
|
|
|
Q_ASSERT(nullptr != pAxisData);
|
|
|
if (nmPlotView* view = qobject_cast<nmPlotView*>(m_pPlotView)) {
|
|
|
view->setScaleBarVisible(pAxisData->isScaleBarVisible());
|
|
|
}
|
|
|
|
|
|
// 0.2 获取 X 最大值
|
|
|
nmDataAttribute xMaxAttr = pAxisData->getXMax();
|
|
|
double xMaxValue = xMaxAttr.getValue().toDouble();
|
|
|
|
|
|
// 0.3 获取 Y 最大值
|
|
|
nmDataAttribute yMaxAttr = pAxisData->getYMax();
|
|
|
double yMaxValue = yMaxAttr.getValue().toDouble();
|
|
|
|
|
|
// 0.4 获取 X 最小值
|
|
|
nmDataAttribute xMinAttr = pAxisData->getXMin();
|
|
|
double xMinValue = xMinAttr.getValue().toDouble();
|
|
|
|
|
|
// 0.5 获取 Y 最小值
|
|
|
nmDataAttribute yMinAttr = pAxisData->getYMin();
|
|
|
double yMinValue = yMinAttr.getValue().toDouble();
|
|
|
|
|
|
if(qIsFinite(xMinValue) && qIsFinite(xMaxValue) &&
|
|
|
qIsFinite(yMinValue) && qIsFinite(yMaxValue) &&
|
|
|
xMaxValue > xMinValue && yMaxValue > yMinValue) {
|
|
|
applyAxisRange(xMinValue, xMaxValue, yMinValue, yMaxValue);
|
|
|
} else {
|
|
|
pAxisData->setInitialViewFitted(false);
|
|
|
}
|
|
|
|
|
|
connect(m_pPlot->getMainAxisX(), SIGNAL(sigRangeChanged(double, double, bool, bool)),
|
|
|
this, SLOT(onRangeXChanged(double, double, bool, bool)),
|
|
|
Qt::UniqueConnection);
|
|
|
connect(m_pPlot->getMainAxisY(), SIGNAL(sigRangeChanged(double, double, bool, bool)),
|
|
|
this, SLOT(onRangeYChanged(double, double, bool, bool)),
|
|
|
Qt::UniqueConnection);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initBoundaryObjFromData(nmDataAnalyzeManager* pDataManager)
|
|
|
{
|
|
|
Q_ASSERT(nullptr != pDataManager);
|
|
|
|
|
|
if(pDataManager == nullptr || m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 1.边界
|
|
|
// 1.1 获取边界数据,来自数据中心
|
|
|
nmDataOutline* pOutlineData = pDataManager->getOutlineData();
|
|
|
Q_ASSERT(nullptr != pOutlineData);
|
|
|
|
|
|
if(pOutlineData == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 1.2 获取边界位置
|
|
|
QVector<QPointF> vecOutlinePoints = pOutlineData->getOutlinePoints();
|
|
|
// 1.3 获取边界名称
|
|
|
QString sOutlineName = pOutlineData->getName();
|
|
|
// 1.4 转换坐标
|
|
|
QVector<QPointF> vecConvertPoints = m_pPlot->getPosForValue(vecOutlinePoints);
|
|
|
|
|
|
// 1.5 根据边界类型绘制不同类型的边界
|
|
|
if(pOutlineData->getOutlineType() == NM_Data_Outline_Type::NM_Rect_Outline_Type) {
|
|
|
// 矩形边界
|
|
|
// 将当前矩形边界对象添加到地图
|
|
|
nmObjRectOutline* pRectOutlinePlot = (nmObjRectOutline*)appendOneObj(NMOT_RectOutline, sOutlineName, vecConvertPoints);
|
|
|
|
|
|
if(pRectOutlinePlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 通过 Binder 绑定边界数据到图元对象
|
|
|
m_pGraphicBinder->bindOutlineToGraphic(pRectOutlinePlot, pOutlineData);
|
|
|
} else if(pOutlineData->getOutlineType() == NM_Data_Outline_Type::NM_Round_Outline_Type) {
|
|
|
// 圆形边界
|
|
|
// 将当前多边形边界对象添加到地图
|
|
|
nmObjRoundOutline* pPRoundOutlinePlot = (nmObjRoundOutline*)appendOneObj(NMOT_RoundOutline, sOutlineName, vecConvertPoints);
|
|
|
|
|
|
if(pPRoundOutlinePlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 通过 Binder 绑定边界数据到图元对象
|
|
|
m_pGraphicBinder->bindOutlineToGraphic(pPRoundOutlinePlot, pOutlineData);
|
|
|
} else if(pOutlineData->getOutlineType() == NM_Data_Outline_Type::NM_Polygon_Outline_Type) {
|
|
|
// 多边形边界
|
|
|
// 将当前多边形边界对象添加到地图
|
|
|
nmObjPolygonOutline* pPolygonOutlinePlot = (nmObjPolygonOutline*)appendOneObj(NMOT_PolygonOutline, sOutlineName, vecConvertPoints);
|
|
|
|
|
|
if(pPolygonOutlinePlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 通过 Binder 绑定边界数据到图元对象
|
|
|
m_pGraphicBinder->bindOutlineToGraphic(pPolygonOutlinePlot, pOutlineData);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initWellObjsFromData(nmDataAnalyzeManager* pDataManager)
|
|
|
{
|
|
|
Q_ASSERT(nullptr != pDataManager);
|
|
|
|
|
|
if(pDataManager == nullptr || m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 参数提交原地修改井数据,按数据对象复用已注册的井图元。
|
|
|
nmPlotView* view = qobject_cast<nmPlotView*>(m_pPlotView);
|
|
|
const bool recordPositionEdit = view != nullptr && view->mapGeometryEditGroup() != nullptr;
|
|
|
QHash<nmDataWellBase*, nmObjPointWell*> existingWells;
|
|
|
if (m_pGraphicBinder != nullptr) {
|
|
|
for (int i = 0; i < m_pPlot->getObjCount(); ++i) {
|
|
|
if (nmObjPointWell* well = qobject_cast<nmObjPointWell*>(m_pPlot->getObjByIndex(i))) {
|
|
|
if (nmDataWellBase* data = m_pGraphicBinder->getWellDataFor(well)) {
|
|
|
existingWells.insert(data, well);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 2.井
|
|
|
// 2.1 获取井数据,来自数据中心
|
|
|
QVector<nmDataWellBase*> vecWellDatas = pDataManager->getWellDataList();
|
|
|
|
|
|
// 2.2 编辑井数组,获取具体的井数据
|
|
|
for(int i = 0; i < vecWellDatas.size(); i++) {
|
|
|
nmDataWellBase* pWellData = vecWellDatas[i];
|
|
|
Q_ASSERT(nullptr != pWellData);
|
|
|
|
|
|
if(pWellData == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (nmObjPointWell* well = existingWells.value(pWellData, nullptr)) {
|
|
|
well->setName(pWellData->getWellName());
|
|
|
m_pGraphicBinder->bindWellToGraphic(well, pWellData, recordPositionEdit);
|
|
|
static_cast<nmObjBase*>(well)->update();
|
|
|
setModified(true);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 2.3 获取当前井坐标
|
|
|
QPointF ptWell(pWellData->getX().getValue().toDouble(), pWellData->getY().getValue().toDouble());
|
|
|
QVector<QPointF> vecPtWell;
|
|
|
vecPtWell.append(ptWell);
|
|
|
|
|
|
// 2.4 获取井名
|
|
|
QString sCurWellName = pWellData->getWellName();
|
|
|
// 2.5 构建井图元
|
|
|
nmObjPointWell* pWellPlot = (nmObjPointWell*)appendOneObj(NMOT_Point_Well, sCurWellName, vecPtWell);
|
|
|
|
|
|
if(pWellPlot == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 2.9 通过 Binder 绑定井数据(推值 + 建立信号连接)
|
|
|
if (m_pGraphicBinder) {
|
|
|
m_pGraphicBinder->bindWellToGraphic(pWellPlot, pWellData);
|
|
|
}
|
|
|
pWellPlot->afterCreated();
|
|
|
}
|
|
|
refreshEditingLocks();
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initFaultObjsFromData(nmDataAnalyzeManager* pDataManager)
|
|
|
{
|
|
|
Q_ASSERT(nullptr != pDataManager);
|
|
|
|
|
|
if(pDataManager == nullptr || m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 3.断层
|
|
|
// 3.1 获取断层数据,来自数据中心
|
|
|
QVector<nmDataFault*> vecFaultData = pDataManager->getFaultDataList();
|
|
|
|
|
|
// 3.2 遍历断层数组的数据
|
|
|
for(int i = 0; i < vecFaultData.size(); i++) {
|
|
|
nmDataFault* pDataFault = vecFaultData[i];
|
|
|
Q_ASSERT(nullptr != pDataFault);
|
|
|
|
|
|
if(pDataFault == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 3.3 获取断层位置
|
|
|
QVector<QPointF> vecFaultPoints = pDataFault->getFaultPoints();
|
|
|
// 3.4 获取断层名称
|
|
|
QString sFaultName = pDataFault->getFaultName();
|
|
|
// 3.5 转换坐标
|
|
|
QVector<QPointF> vecConvertPoints = m_pPlot->getPosForValue(vecFaultPoints);
|
|
|
|
|
|
// 3.6 将当前断层对象添加到地图
|
|
|
nmObjLineFault* pFaultPlot = (nmObjLineFault*)appendOneObj(NMOT_Line_Fault, sFaultName, vecConvertPoints);
|
|
|
|
|
|
if(pFaultPlot == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 3.7 通过 Binder 绑定数据(推值 + 建立信号连接)
|
|
|
m_pGraphicBinder->bindFaultToGraphic(pFaultPlot, pDataFault);
|
|
|
|
|
|
// TODO: 设置断层其他属性
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initFractureObjsFromData(nmDataAnalyzeManager* pDataManager)
|
|
|
{
|
|
|
initFractureObjsFromData(pDataManager, false);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initFractureObjsFromData(nmDataAnalyzeManager* pDataManager, bool bDfnOnly)
|
|
|
{
|
|
|
Q_ASSERT(nullptr != pDataManager);
|
|
|
|
|
|
if(pDataManager == nullptr || m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 4.裂缝
|
|
|
// 4.1 获取裂缝数据,来自数据中心
|
|
|
QVector<nmDataFracture*> vecFractureData = pDataManager->getFractureDataList();
|
|
|
|
|
|
// 4.2 遍历裂缝数组的数据
|
|
|
for(int i = 0; i < vecFractureData.size(); i++) {
|
|
|
nmDataFracture* pDataFracture = vecFractureData[i];
|
|
|
Q_ASSERT(nullptr != pDataFracture);
|
|
|
|
|
|
if(pDataFracture == nullptr || m_pGraphicBinder == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
const bool bDfn = pDataFracture->getFractureType().getValue().toString() == "DFN";
|
|
|
if (bDfnOnly && !bDfn) continue;
|
|
|
|
|
|
// 4.3 获取裂缝位置
|
|
|
QVector<QPointF> vecFracturePoints = pDataFracture->getFracturePoints();
|
|
|
// 4.4 获取裂缝名称
|
|
|
QString sFractureName = pDataFracture->getFractureName();
|
|
|
// 4.5 转换坐标
|
|
|
QVector<QPointF> vecConvertPoints = m_pPlot->getPosForValue(vecFracturePoints);
|
|
|
|
|
|
// 4.6 将当前裂缝对象添加到地图
|
|
|
nmObjLineCrack* pFracturePlot = (nmObjLineCrack*)appendOneObj(NMOT_Line_Fracture, sFractureName, vecConvertPoints);
|
|
|
|
|
|
if(pFracturePlot == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 4.7 通过 Binder 绑定数据(推值 + 建立信号连接)
|
|
|
m_pGraphicBinder->bindCrackToGraphic(pFracturePlot, pDataFracture);
|
|
|
|
|
|
// DFN 统一由专用窗口管理,重建后保持专用颜色、锁定状态和原可见性。
|
|
|
if (bDfn) {
|
|
|
pFracturePlot->setPen(QPen(QBrush(QColor("#00bfff")), 0.4f, Qt::SolidLine));
|
|
|
pFracturePlot->setLockForDFN();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initRegionObjsFromData(nmDataAnalyzeManager* pDataManager)
|
|
|
{
|
|
|
Q_ASSERT(nullptr != pDataManager);
|
|
|
|
|
|
if(pDataManager == nullptr || m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 5.区域
|
|
|
// 5.1 获取区域数据,来自数据中心
|
|
|
QVector<nmDataRegion*> vecRegionData = pDataManager->getRegionDataList();
|
|
|
|
|
|
// 5.2 遍历区域数组的数据
|
|
|
for(int i = 0; i < vecRegionData.size(); i++) {
|
|
|
nmDataRegion* pDataRegion = vecRegionData[i];
|
|
|
Q_ASSERT(nullptr != pDataRegion);
|
|
|
|
|
|
if(pDataRegion == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 5.3 获取区域位置
|
|
|
QVector<QPointF> vecRegionPoints = pDataRegion->getVecPts();
|
|
|
// 5.4 获取区域名称
|
|
|
QString sRegionName = pDataRegion->getRegoinName();
|
|
|
// 5.5 转换坐标
|
|
|
QVector<QPointF> vecConvertPoints = m_pPlot->getPosForValue(vecRegionPoints);
|
|
|
|
|
|
// 5.6 将当前区域对象添加到地图
|
|
|
nmObjRegion* pRegionPlot = (nmObjRegion*)appendOneObj(NMOT_Region, sRegionName, vecConvertPoints);
|
|
|
|
|
|
if(pRegionPlot == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 5.7 通过 Binder 绑定区域数据到图元
|
|
|
if (m_pGraphicBinder) {
|
|
|
m_pGraphicBinder->bindRegionToGraphic(pRegionPlot, pDataRegion);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initRegionMarkObjsFromData(nmDataAnalyzeManager* pDataManager)
|
|
|
{
|
|
|
Q_ASSERT(nullptr != pDataManager);
|
|
|
|
|
|
if(pDataManager == nullptr || m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 6.区域标记
|
|
|
// 6.1 获取区域标记数据,来自数据中心
|
|
|
QVector<nmDataRegionMark*> vecRegionMarkData = pDataManager->getRegionMarkDataList();
|
|
|
|
|
|
// 6.2 遍历区域标记数组的数据
|
|
|
for(int i = 0; i < vecRegionMarkData.size(); i++) {
|
|
|
nmDataRegionMark* pDataRegionMark = vecRegionMarkData[i];
|
|
|
Q_ASSERT(nullptr != pDataRegionMark);
|
|
|
|
|
|
if(pDataRegionMark == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 6.3 获取区域标记位置
|
|
|
QPointF ptRegionMark = pDataRegionMark->getPtPos();
|
|
|
QVector<QPointF> vecPtRegionMark;
|
|
|
vecPtRegionMark.append(ptRegionMark);
|
|
|
// 6.4 获取区域标记名称
|
|
|
QString sRegionMarkName = pDataRegionMark->getRegionMarkName();
|
|
|
// 6.5 转换坐标
|
|
|
QVector<QPointF> vecConvertPoints = m_pPlot->getPosForValue(vecPtRegionMark);
|
|
|
|
|
|
// 6.6 将当前区域标记对象添加到地图
|
|
|
nmObjRegionMark* pRegionMarkPlot = (nmObjRegionMark*)appendOneObj(NMOT_RegionMark, sRegionMarkName, vecConvertPoints);
|
|
|
|
|
|
if(pRegionMarkPlot == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 6.7 通过 Binder 绑定区域标记数据到图元
|
|
|
if (m_pGraphicBinder) {
|
|
|
m_pGraphicBinder->bindRegionMarkToGraphic(pRegionMarkPlot, pDataRegionMark);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::deleteAllPlotObjs()
|
|
|
{
|
|
|
emit sigMapAnalysisLeaving();
|
|
|
cancelActiveTools();
|
|
|
if (nmPlotView* view = qobject_cast<nmPlotView*>(m_pPlotView)) {
|
|
|
if (QUndoStack* history = view->mapEditHistory()) history->clear();
|
|
|
view->setMapHistoryOwner(nullptr);
|
|
|
}
|
|
|
clearMapGraphics();
|
|
|
m_pDataManager = nullptr;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::clearMapGraphics()
|
|
|
{
|
|
|
if(m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
syncMapObjectNames();
|
|
|
// 框架的历史直接引用画布图元,重建时清理。
|
|
|
m_pPlot->clearUndoStack();
|
|
|
// 这里只清理显示对象,不能调用removeData()删除DataManager中的业务数据。
|
|
|
// 先解除全部绑定,再倒序删除图元,避免重名对象残留或Binder保存悬空指针。
|
|
|
if(m_pGraphicBinder != nullptr) {
|
|
|
m_pGraphicBinder->updateDataMgr(nullptr);
|
|
|
}
|
|
|
for(int nIndex = m_pPlot->getObjCount() - 1; nIndex >= 0; --nIndex) {
|
|
|
m_pPlot->removeObjByIndex(nIndex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
nmObjBase* nmGuiPlot::appendOneObj(NM_Obj_Type o, QString& sName, QVector<QPointF>& vec)
|
|
|
{
|
|
|
nmObjBase* pObj = _createOneObj(o, sName);
|
|
|
|
|
|
if(NULL == pObj) {
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
pObj->setAllPos(vec);
|
|
|
//pObj->select(true);
|
|
|
//pObj->dealSelChanged(true);
|
|
|
pObj->update();
|
|
|
|
|
|
// 当对象创建完成之后,进行的操作,如改变按钮Check的状态
|
|
|
//emit sigObjCompleted(pObj); //通常有Plot触发,而非iGuiPlot
|
|
|
// 所以直接用 slotObjCompleted
|
|
|
slotObjCompleted(pObj);
|
|
|
|
|
|
setModified(true);
|
|
|
|
|
|
return pObj;
|
|
|
}
|
|
|
|
|
|
nmObjBase* nmGuiPlot::_createOneObj(NM_Obj_Type o, QString& sName)
|
|
|
{
|
|
|
return createMapObject(o, sName, -1, -1);
|
|
|
}
|
|
|
|
|
|
nmObjBase* nmGuiPlot::createMapObject(NM_Obj_Type o, QString& sName,
|
|
|
int objectIndex, int childIndex)
|
|
|
{
|
|
|
Q_ASSERT(NULL != m_pPlot);
|
|
|
|
|
|
const bool bOutline = o == NMOT_RectOutline ||
|
|
|
o == NMOT_PolygonOutline || o == NMOT_RoundOutline;
|
|
|
// 单一边界允许没有名称;恢复用户自定义名称时也不自动追加编号。
|
|
|
if(!bOutline) {
|
|
|
QStringList listOlds;
|
|
|
for(int i = 0; i < m_pPlot->getObjCount(); i++) {
|
|
|
listOlds << m_pPlot->getObjByIndex(i)->getName();
|
|
|
}
|
|
|
sName = ZxBaseUtil::getNextOneName(listOlds, sName);
|
|
|
}
|
|
|
|
|
|
// 创建,此处代码为了简洁,作了非规范性书写
|
|
|
nmObjBase* pObj = NULL;
|
|
|
|
|
|
if(o == NMOT_Point) {
|
|
|
pObj = new nmObjPoint(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Point_Well) {
|
|
|
pObj = new nmObjPointWell(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Line) {
|
|
|
pObj = new nmObjLine(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Polygon) {
|
|
|
pObj = new nmObjPolygon(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_PolygonOutline) {
|
|
|
pObj = new nmObjPolygonOutline(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Rect) { //矩形
|
|
|
pObj = new nmObjRect(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_RectOutline) { //矩形边界
|
|
|
pObj = new nmObjRectOutline(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Round) { //圆形
|
|
|
pObj = new nmObjRound(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_RoundOutline) { //圆形边界
|
|
|
pObj = new nmObjRoundOutline(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Line_Fracture) {
|
|
|
pObj = new nmObjLineCrack(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Line_Fault) {
|
|
|
pObj = new nmObjLineFault(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Region) {
|
|
|
pObj = new nmObjRegion(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Line_MeasuringScale) {
|
|
|
pObj = new nmObjLineMeasuringScale(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_Line_Measure) {
|
|
|
pObj = new nmObjLineMeasure(sName, NULL, NULL);
|
|
|
} else if(o == NMOT_RegionMark) {
|
|
|
pObj = new nmObjRegionMark(sName, NULL, NULL);
|
|
|
} else {
|
|
|
qDebug() << tr("Type '%1' not supported.").arg((int)o);
|
|
|
nmDataLogFile::getInstance()->writeLog(tr("Type '%1' not supported.").arg((int)o));
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
Q_ASSERT(NULL != pObj);
|
|
|
if(bOutline) {
|
|
|
// 几何基类构造时会加载样式模板;以本次传入名称覆盖模板中的旧名称。
|
|
|
// 新建边界传入空名,加载成果则传入已保存的用户名称。
|
|
|
pObj->setName(sName);
|
|
|
}
|
|
|
bindObjSignals(pObj);
|
|
|
|
|
|
// 对象列表中的目标索引,注册后用于同步鼠标命中顺序;默认追加到末尾。
|
|
|
int nInsertObjIndex = m_pPlot->getObjCount();
|
|
|
if (objectIndex >= 0 && childIndex >= 0) {
|
|
|
nInsertObjIndex = qMin(objectIndex, nInsertObjIndex);
|
|
|
if (childIndex < m_pPlot->size()) m_pPlot->insert(childIndex, pObj);
|
|
|
} else if(bOutline || o == NMOT_Region) {
|
|
|
// 框架的层级接口只调整对象和工具顺序,未同步实际绘制用的子节点顺序。
|
|
|
// 边界在所有业务图元之下;区域在已有区域标记之下。
|
|
|
// 绘制子节点包含坐标轴等非业务对象,此索引不能与对象列表索引混用。
|
|
|
int nInsertIndex = m_pPlot->size();
|
|
|
for(int i = 0; i < m_pPlot->getObjCount(); i++) {
|
|
|
ZxObjBase* pExistingObj = m_pPlot->getObjByIndex(i);
|
|
|
if(!bOutline && dynamic_cast<nmObjRegionMark*>(pExistingObj) == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
nInsertObjIndex = qMin(nInsertObjIndex, i);
|
|
|
const int nChildIndex = m_pPlot->indexOf(pExistingObj);
|
|
|
if(nChildIndex >= 0 && nChildIndex < nInsertIndex) {
|
|
|
nInsertIndex = nChildIndex;
|
|
|
}
|
|
|
}
|
|
|
if(nInsertIndex < m_pPlot->size()) {
|
|
|
// 在注册前确定绘制位置,避免移除已有图元时触发解绑或工具清理。
|
|
|
m_pPlot->insert(nInsertIndex, pObj);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// addOneObj 复用已设置的父节点,继续完成坐标轴、对象列表和编辑工具的注册。
|
|
|
m_pPlot->addOneObj(pObj);
|
|
|
|
|
|
if(objectIndex >= 0 || bOutline || o == NMOT_Region) {
|
|
|
// 逐层后移:边界位于所有业务图元之下,区域位于已有区域标记之下。
|
|
|
// sendBackward 只交换相邻业务对象及其编辑工具,保留内部图元优先响应。
|
|
|
// 不能使用 sendToBack:它会将编辑工具移到通用选择工具之后,
|
|
|
// 导致按下边界内部时先取消选中,出现小手光标却无法整体拖动。
|
|
|
for(int i = m_pPlot->getObjCount() - 1; i > nInsertObjIndex; --i) {
|
|
|
m_pPlot->sendBackward(pObj);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return pObj;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::bindObjSignals(ZxObjBase* pObj)
|
|
|
{
|
|
|
Q_ASSERT(NULL != pObj);
|
|
|
|
|
|
disconnect(pObj, SIGNAL(sigObjSelectionChanged(bool)), \
|
|
|
this, SLOT(slotObjSelChanged(bool)));
|
|
|
disconnect(pObj, SIGNAL(sigPtsChanged()), \
|
|
|
this, SLOT(slotObjPtsChanged()));
|
|
|
connect(pObj, SIGNAL(sigObjSelectionChanged(bool)), \
|
|
|
this, SLOT(slotObjSelChanged(bool)));
|
|
|
connect(pObj, SIGNAL(sigPtsChanged()), \
|
|
|
this, SLOT(slotObjPtsChanged()));
|
|
|
}
|
|
|
|
|
|
// Obj选择状态改变
|
|
|
void nmGuiPlot::slotObjSelChanged(bool b)
|
|
|
{
|
|
|
ZxObjBase* p = dynamic_cast<ZxObjBase*>(sender());
|
|
|
|
|
|
if(NULL != p) {
|
|
|
emit sigObjSelChanged(p, b);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Obj数据发生了改变
|
|
|
void nmGuiPlot::slotObjPtsChanged()
|
|
|
{
|
|
|
ZxObjBase* p = dynamic_cast<ZxObjBase*>(sender());
|
|
|
|
|
|
if(NULL != p) {
|
|
|
emit sigObjPtsChanged(p);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::slotDeleteWell(QString wellID)
|
|
|
{
|
|
|
nmDataLogFile::getInstance()->writeLog(wellID + " ========");
|
|
|
// 找到要删除的图片
|
|
|
nmObjPointWell* obj = (nmObjPointWell*)this->getWellObjById(wellID);
|
|
|
|
|
|
if(obj == nullptr || m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 创建分析时绑定的主井是流动段及数值输入基准,不能从数值 Map 单独删除。
|
|
|
if(m_pGraphicBinder && m_pGraphicBinder->isPrimaryWellGraphic(obj)) {
|
|
|
QMessageBox::information(this,
|
|
|
tr("Cannot Delete Well"),
|
|
|
tr("The primary analysis well cannot be deleted."));
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// // 创建一个QTimer对象
|
|
|
// QTimer* timer = new QTimer();
|
|
|
// // 创建一个要执行的单次任务
|
|
|
// QObject::connect(timer, &QTimer::timeout, []() {
|
|
|
// // 这里是你想要延迟执行的代码
|
|
|
// qDebug() << "任务执行了!";
|
|
|
// });
|
|
|
// // 设置延迟时间(单位毫秒)
|
|
|
// int delay = 2000; // 例如2000毫秒(2秒)
|
|
|
// timer->setSingleShot(true); // 设置为单次触发
|
|
|
// timer->start(delay); // 开始计时,时间到后执行timeout信号关联的任务
|
|
|
// 删除结构树里的对象
|
|
|
if(zxCurProject != nullptr && obj->getWellData() != nullptr) {
|
|
|
zxCurProject->removeChild(obj->getWellData());
|
|
|
}
|
|
|
|
|
|
// 删除图元
|
|
|
m_pPlot->removeObjByName(obj->getName());
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::onSerialize(ZxSerializer* ser)
|
|
|
{
|
|
|
iGuiPlot::onSerialize(ser);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::onDeserialize(ZxSerializer* ser)
|
|
|
{
|
|
|
iGuiPlot::onDeserialize(ser);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::resetAfterDeserialized()
|
|
|
{
|
|
|
iGuiPlot::resetAfterDeserialized();
|
|
|
|
|
|
if (QUndoStack* history = mapEditHistory()) history->clear();
|
|
|
if(NULL == m_pPlot) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
connectSignals();
|
|
|
slotChangeSizeWithChangedXY();
|
|
|
setModified(false);
|
|
|
|
|
|
for(int i = 0; i < m_pPlot->getObjCount(); i++) {
|
|
|
nmObjBase* pObj = (nmObjBase*)m_pPlot->getObjByIndex(i);
|
|
|
|
|
|
if(NULL != pObj) {
|
|
|
// 建立信号
|
|
|
bindObjSignals(pObj);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
QVector<ZxObjBase*> nmGuiPlot::getObjsByTag(QString objTag)
|
|
|
{
|
|
|
QVector<ZxObjBase*> pObjVec;
|
|
|
|
|
|
if(m_pPlot == nullptr) {
|
|
|
return pObjVec;
|
|
|
}
|
|
|
|
|
|
int objCount = m_pPlot->getObjCount();
|
|
|
|
|
|
for(int i = 0; i < objCount; i++) {
|
|
|
ZxObjBase* obj = m_pPlot->getObjByIndex(i);
|
|
|
|
|
|
if(obj != nullptr && _isSame(objTag, obj->getTagName())) {
|
|
|
pObjVec.append(obj);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return pObjVec;
|
|
|
}
|
|
|
|
|
|
ZxObjBase* nmGuiPlot::getWellObjById(QString id)
|
|
|
{
|
|
|
int objCount = m_pPlot->getObjCount();
|
|
|
|
|
|
for(int i = 0; i < objCount; i++) {
|
|
|
ZxObjBase* obj = m_pPlot->getObjByIndex(i);
|
|
|
nmDataLogFile::getInstance()->writeLog(QString::fromStdString(obj->getTagName()) + " ======");
|
|
|
|
|
|
if(_isSame("nObjPointWell", obj->getTagName())) {
|
|
|
nmObjPointWell* pWellPlot = dynamic_cast<nmObjPointWell*>(obj);
|
|
|
|
|
|
if(pWellPlot == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if(_isSame(id, pWellPlot->getWellID())) {
|
|
|
return pWellPlot;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
QVector<QPointF> nmGuiPlot::getOutlinePoints()
|
|
|
{
|
|
|
QVector<QPointF> pointList;
|
|
|
// 获取边界的所有点
|
|
|
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjPolygonOutline");
|
|
|
|
|
|
// 如果是多边形边界
|
|
|
if(objList.count() > 0) {
|
|
|
ZxObjBase* outlineObj = objList[0];
|
|
|
return outlineObj->getValueOf(outlineObj->getAllPos());
|
|
|
}
|
|
|
|
|
|
// 获取边界的所有点
|
|
|
objList = this->getObjsByTag("nObjRectOutline");
|
|
|
|
|
|
// 如果是多边形边界
|
|
|
if(objList.count() > 0) {
|
|
|
ZxObjBase* outlineObj = objList[0];
|
|
|
return outlineObj->getValueOf(outlineObj->getAllPos());
|
|
|
}
|
|
|
|
|
|
// TODO,需要支持圆形边界
|
|
|
|
|
|
return pointList;
|
|
|
}
|
|
|
|
|
|
QVector<QVector<double >> nmGuiPlot::getWellsInformation()
|
|
|
{
|
|
|
QVector<QVector<double >> wellsList;
|
|
|
// 获取边界的所有点
|
|
|
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjPointWell");
|
|
|
|
|
|
if(objList.count() > 0) {
|
|
|
for(int i = 0; i < objList.count() ; i++) {
|
|
|
nmObjPointWell* pWell = (nmObjPointWell*)objList[i];
|
|
|
QVector<double> wellInfo = pWell->getWellInformation();
|
|
|
|
|
|
if(wellInfo.count() == 3) {
|
|
|
wellsList.append(wellInfo);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return wellsList;
|
|
|
}
|
|
|
|
|
|
QVector<QVector<QPointF> > nmGuiPlot::getCracksInformation()
|
|
|
{
|
|
|
QVector<QVector<QPointF >> vCracks;
|
|
|
// 获取裂缝的所有点
|
|
|
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjLineFracture");
|
|
|
|
|
|
if(objList.count() > 0) {
|
|
|
for(int i = 0; i < objList.count() ; i++) {
|
|
|
nmObjLineCrack* pCrack = (nmObjLineCrack*)objList[i];
|
|
|
vCracks.append(pCrack->getValueOf(pCrack->getAllPos()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return vCracks;
|
|
|
}
|
|
|
|
|
|
QVector<QVector<QPointF> > nmGuiPlot::getFaultsInformation()
|
|
|
{
|
|
|
QVector<QVector<QPointF >> vFaults;
|
|
|
// 获取裂缝的所有点
|
|
|
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjLineFault");
|
|
|
|
|
|
if(objList.count() > 0) {
|
|
|
for(int i = 0; i < objList.count() ; i++) {
|
|
|
nmObjLineFault* pFault = (nmObjLineFault*)objList[i];
|
|
|
vFaults.append(pFault->getValueOf(pFault->getAllPos()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return vFaults;
|
|
|
}
|
|
|
|
|
|
QVector<QVector<QPointF>> nmGuiPlot::getRegionsInformation()
|
|
|
{
|
|
|
QVector<QVector<QPointF >> vRegions;
|
|
|
// 获取裂缝的所有点
|
|
|
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjRegion");
|
|
|
|
|
|
if(objList.count() > 0) {
|
|
|
for(int i = 0; i < objList.count() ; i++) {
|
|
|
nmObjRegion* pRegion = (nmObjRegion*)objList[i];
|
|
|
QVector<QPointF> vPos = pRegion->getAllPos();
|
|
|
|
|
|
for(size_t j = 0; j < vPos.size(); j++) {
|
|
|
QPointF& p = vPos[j];
|
|
|
qDebug() << QString("%1,%2").arg(p.x()).arg(p.y());
|
|
|
}
|
|
|
|
|
|
vRegions.append(pRegion->getValueOf(pRegion->getAllPos()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return vRegions;
|
|
|
}
|
|
|
|
|
|
QVector<nmObjPointWell*> nmGuiPlot::getWellPlots()
|
|
|
{
|
|
|
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjPointWell");
|
|
|
QVector<nmObjPointWell*> wellPlots;
|
|
|
|
|
|
if(objList.count() > 0) {
|
|
|
for(int i = 0; i < objList.count() ; i++) {
|
|
|
wellPlots.append((nmObjPointWell*) objList[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return wellPlots;
|
|
|
}
|
|
|
|
|
|
QVector<ZxDataWell*> nmGuiPlot::getWellDatas()
|
|
|
{
|
|
|
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjPointWell");
|
|
|
QVector<ZxDataWell*> wellDatas;
|
|
|
|
|
|
if(objList.count() > 0) {
|
|
|
for(int i = 0; i < objList.count() ; i++) {
|
|
|
wellDatas.append(((nmObjPointWell*) objList[i])->getWellData());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return wellDatas;
|
|
|
}
|
|
|
|
|
|
QStringList nmGuiPlot::getWellNames()
|
|
|
{
|
|
|
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjPointWell");
|
|
|
QStringList wellNames;
|
|
|
|
|
|
if(objList.count() > 0) {
|
|
|
for(int i = 0; i < objList.count() ; i++) {
|
|
|
wellNames.append(((nmObjPointWell*) objList[i])->getWellData()->getName());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return wellNames;
|
|
|
}
|
|
|
|
|
|
QVector<nmObjBase*> nmGuiPlot::getAllPlots()
|
|
|
{
|
|
|
QVector<nmObjBase*> vecObjects;
|
|
|
if(m_pPlot == NULL) return vecObjects;
|
|
|
const int nCount = m_pPlot->getObjCount();
|
|
|
for(int nIndex = 0; nIndex < nCount; ++nIndex) {
|
|
|
// 底层绘图还可能包含文本等框架图元,不可强制当作数值模型图元。
|
|
|
nmObjBase* pObject = qobject_cast<nmObjBase*>(m_pPlot->getObjByIndex(nIndex));
|
|
|
if(pObject != NULL) vecObjects.append(pObject);
|
|
|
}
|
|
|
return vecObjects;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::paintEvent(QPaintEvent* e)
|
|
|
{
|
|
|
iGuiPlot::paintEvent(e);
|
|
|
}
|
|
|
|
|
|
#ifdef QT_DEBUG
|
|
|
|
|
|
ZxObjBase* nmGuiPlot::updatePlotObjBy(QString sName, \
|
|
|
VecDouble& vecX, VecDouble& vecY, \
|
|
|
bool bPressureLike /*= true*/, \
|
|
|
bool bUseY2 /*= false*/, \
|
|
|
bool bClearAll /*= false*/)
|
|
|
{
|
|
|
if(vecX.count() < 2 || vecX.count() != vecY.count()) {
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
ZxPlot* pPlot = m_pPlot;
|
|
|
Q_ASSERT(NULL != pPlot);
|
|
|
|
|
|
// 移除先前图上已经有的曲线
|
|
|
int n = pPlot->getObjCount();
|
|
|
|
|
|
for(int i = n - 1; i >= 0; i--) {
|
|
|
ZxObjBase* pObj = pPlot->getObjByIndex(i);
|
|
|
|
|
|
if(NULL == pObj) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if(bClearAll) {
|
|
|
pPlot->removeObjByIndex(i);
|
|
|
} else if(_isSame(sName, pObj->getName())) {
|
|
|
pPlot->removeObjByIndex(i);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ZxObjCurve* pObj = NULL;
|
|
|
|
|
|
if(bPressureLike) {
|
|
|
pObj = appendSeriesP(vecX, vecY, sName, bUseY2);
|
|
|
} else {
|
|
|
pObj = appendSeriesF(vecX, vecY, sName, bUseY2);
|
|
|
}
|
|
|
|
|
|
if(NULL != pObj) {
|
|
|
setPenAndDot(pObj, !bPressureLike, !bPressureLike);
|
|
|
|
|
|
bindObjSignals(pObj);
|
|
|
}
|
|
|
|
|
|
return pObj;
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
void nmGuiPlot::slotMeasuringScale(QPointF pStart, QPointF pEnd, void* obj)
|
|
|
{
|
|
|
if(m_pPlot == nullptr || obj == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 全局信号会通知所有 Map,只允许持有该线段的窗口处理。
|
|
|
// 先从本窗口的有效对象中查找,不能直接解引用 obj:前一个接收者可能已删除它。
|
|
|
QPointer<nmObjLineMeasuringScale> pScaleObj;
|
|
|
for(int nIndex = 0; nIndex < m_pPlot->getObjCount(); ++nIndex) {
|
|
|
nmObjLineMeasuringScale* pCandidate = dynamic_cast<nmObjLineMeasuringScale*>(
|
|
|
m_pPlot->getObjByIndex(nIndex));
|
|
|
if(pCandidate != nullptr && static_cast<void*>(pCandidate) == obj) {
|
|
|
pScaleObj = pCandidate;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if(pScaleObj.isNull()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
QPointer<ZxPlot> pOwnerPlot = m_pPlot;
|
|
|
applyMeasuringScale(pStart, pEnd);
|
|
|
|
|
|
// 成功、取消及无效选点均清理本窗口的临时线段;弹窗期间对象销毁也可安全退出。
|
|
|
if(!pOwnerPlot.isNull() && !pScaleObj.isNull() &&
|
|
|
pOwnerPlot->getObjByName(pScaleObj->getName()) == pScaleObj.data()) {
|
|
|
pOwnerPlot->removeObjByName(pScaleObj->getName());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::applyMeasuringScale(const QPointF& pStart, const QPointF& pEnd)
|
|
|
{
|
|
|
// 重合端点无法定义比例尺,直接结束本次操作,不弹出输入框或校验提示。
|
|
|
if(!qIsFinite(pStart.x()) || !qIsFinite(pStart.y()) ||
|
|
|
!qIsFinite(pEnd.x()) || !qIsFinite(pEnd.y())) {
|
|
|
return;
|
|
|
}
|
|
|
const double dOriLength = QLineF(pStart, pEnd).length();
|
|
|
if(!qIsFinite(dOriLength) || dOriLength <= 0.0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
QPointer<nmGuiPlot> pOwner = this;
|
|
|
QPointer<ZxPlot> pPlot = m_pPlot;
|
|
|
// 比例尺属于本 Map;未绑定数据管理器时不能退回到全局当前分析。
|
|
|
QPointer<nmDataAnalyzeManager> pDataManager = m_pDataManager;
|
|
|
nmPlotDialogContextProvider* pDialogProvider = nmPlotDialogContext::provider();
|
|
|
if(pPlot.isNull() || pDataManager.isNull() || pDialogProvider == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
QPointer<ZxSubAxisX> pAxisX = pPlot->getMainAxisX();
|
|
|
QPointer<ZxSubAxisY> pAxisY = pPlot->getMainAxisY();
|
|
|
if(pAxisX.isNull() || pAxisY.isNull()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const double dXMin = pAxisX->getRangeMin();
|
|
|
const double dXMax = pAxisX->getRangeMax();
|
|
|
const double dYMin = pAxisY->getRangeMin();
|
|
|
const double dYMax = pAxisY->getRangeMax();
|
|
|
const double dXRange = dXMax - dXMin;
|
|
|
const double dYRange = dYMax - dYMin;
|
|
|
if(!qIsFinite(dXMin) || !qIsFinite(dXMax) ||
|
|
|
!qIsFinite(dYMin) || !qIsFinite(dYMax) ||
|
|
|
!qIsFinite(dXRange) || !qIsFinite(dYRange) ||
|
|
|
dXRange <= 0.0 || dYRange <= 0.0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 对话框只返回米制长度;取消或后续计算失败时不修改坐标轴及比例尺数据。
|
|
|
double dLength = 0.0;
|
|
|
if(!pDialogProvider->execMeasuringScaleDialog(pStart, pEnd, &dLength)) {
|
|
|
return;
|
|
|
}
|
|
|
// 模态窗口会处理事件,提交前确认原窗口、坐标轴及其数据管理器仍然有效。
|
|
|
if(pOwner.isNull() || pPlot.isNull() || pDataManager.isNull() ||
|
|
|
pAxisX.isNull() || pAxisY.isNull() ||
|
|
|
m_pPlot != pPlot.data() || m_pDataManager != pDataManager.data() ||
|
|
|
pPlot->getMainAxisX() != pAxisX.data() || pPlot->getMainAxisY() != pAxisY.data()) {
|
|
|
return;
|
|
|
}
|
|
|
if(!qIsFinite(dLength) || dLength <= 0.0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 保持轴最小值不变,最大值应为“最小值 + 缩放后的跨度”。
|
|
|
// 比例为 1 时完整保留原范围,正负坐标均适用。
|
|
|
const double dScale = dLength / dOriLength;
|
|
|
if(!qIsFinite(dScale) || dScale <= 0.0) {
|
|
|
return;
|
|
|
}
|
|
|
const double dXMaxScaled = dScale == 1.0 ? dXMax : dXMin + dXRange * dScale;
|
|
|
const double dYMaxScaled = dScale == 1.0 ? dYMax : dYMin + dYRange * dScale;
|
|
|
if(!qIsFinite(dXMaxScaled) || !qIsFinite(dYMaxScaled) ||
|
|
|
dXMaxScaled <= dXMin || dYMaxScaled <= dYMin) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 沿用对话框的字段译名;数据只交给本 Map 的管理器,不访问全局当前分析。
|
|
|
nmDataMeasuringScale oScaleData;
|
|
|
oScaleData.getStartPoint().setName(
|
|
|
QCoreApplication::translate("nmWxMeasuringScaleDlg", "Start coordinates"));
|
|
|
oScaleData.getStartPoint().setValue(QString("(%1, %2)").arg(pStart.x()).arg(pStart.y()));
|
|
|
oScaleData.getEndPoint().setName(
|
|
|
QCoreApplication::translate("nmWxMeasuringScaleDlg", "End coordinates"));
|
|
|
oScaleData.getEndPoint().setValue(QString("(%1, %2)").arg(pEnd.x()).arg(pEnd.y()));
|
|
|
oScaleData.getLength().setName(
|
|
|
QCoreApplication::translate("nmWxMeasuringScaleDlg", "Actual length"));
|
|
|
oScaleData.getLength().setUnit("m");
|
|
|
oScaleData.getLength().setValue(dLength);
|
|
|
|
|
|
applyAxisRange(dXMin, dXMaxScaled, dYMin, dYMaxScaled);
|
|
|
pDataManager->setMeasuringScaleData(new nmDataMeasuringScale(oScaleData));
|
|
|
nmDataAxis* pAxisData = pDataManager->getAxisData();
|
|
|
if(pAxisData != nullptr) {
|
|
|
// 用户已完成手工标定,后续窗口尺寸变化不应再触发首次自动适配。
|
|
|
pAxisData->setInitialViewFitted(true);
|
|
|
}
|
|
|
setModified(true);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::deleteMeasureObjects()
|
|
|
{
|
|
|
if(m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
removeMeasureGraphics();
|
|
|
|
|
|
// 先解除本 Map 的图元绑定,再删除所属分析的测量数据。
|
|
|
// 非模态对话框关闭时,当前页签可能已切换,不能使用全局当前分析。
|
|
|
if(m_pDataManager != nullptr) {
|
|
|
m_pDataManager->removeMeasureData();
|
|
|
}
|
|
|
|
|
|
setMeasureEditingLocked(false);
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::removeMeasureGraphics(const ZxObjBase* keptGraphic)
|
|
|
{
|
|
|
if(m_pPlot == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
for (int i = m_pPlot->getObjCount() - 1; i >= 0; --i) {
|
|
|
nmObjLineMeasure* measure = dynamic_cast<nmObjLineMeasure*>(m_pPlot->getObjByIndex(i));
|
|
|
if (measure != nullptr && measure != keptGraphic) {
|
|
|
measure->removeData();
|
|
|
m_pPlot->removeObjByIndex(i);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::setMeasureEditingLocked(bool locked)
|
|
|
{
|
|
|
if (locked == m_bMeasureEditingLocked) return;
|
|
|
m_bMeasureEditingLocked = locked;
|
|
|
refreshEditingLocks();
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::setMapEditingLocked(bool locked)
|
|
|
{
|
|
|
if (locked == m_bMapEditingLocked) return;
|
|
|
if (locked) cancelActiveTools();
|
|
|
m_bMapEditingLocked = locked;
|
|
|
refreshEditingLocks();
|
|
|
if (nmPlotView* view = qobject_cast<nmPlotView*>(m_pPlotView)) {
|
|
|
view->setMapHistoryLocked(locked);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::refreshEditingLocks()
|
|
|
{
|
|
|
if (m_bMapEditingLocked || m_bMeasureEditingLocked) {
|
|
|
if (m_pPlot == nullptr) return;
|
|
|
QSet<ZxObjBase*> lockedObjects;
|
|
|
for (int i = m_editStates.size() - 1; i >= 0; --i) {
|
|
|
if (ZxObjBase* object = m_editStates.at(i).object.data()) {
|
|
|
lockedObjects.insert(object);
|
|
|
} else {
|
|
|
m_editStates.remove(i);
|
|
|
}
|
|
|
}
|
|
|
const int count = m_pPlot->getObjCount();
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
ZxObjBase* object = m_pPlot->getObjByIndex(i);
|
|
|
if (object == nullptr || lockedObjects.contains(object)) continue;
|
|
|
|
|
|
ObjectEditState state;
|
|
|
state.object = object;
|
|
|
state.readOnly = object->isReadOnly();
|
|
|
state.positionLocked = object->isLockPos();
|
|
|
m_editStates.append(state);
|
|
|
object->setReadOnly(true);
|
|
|
object->setLockPos(true);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const QVector<ObjectEditState> states = m_editStates;
|
|
|
m_editStates.clear();
|
|
|
foreach (const ObjectEditState& state, states) {
|
|
|
if (ZxObjBase* object = state.object.data()) {
|
|
|
object->setReadOnly(state.readOnly);
|
|
|
object->setLockPos(state.positionLocked);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::bindPointerPosDialog(QWidget* pointerPosDlg)
|
|
|
{
|
|
|
if(pointerPosDlg == nullptr || m_pPlotView == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
disconnect(m_pPlotView, SIGNAL(sigPointerPos(double, double)), pointerPosDlg, SLOT(setPointerPos(double, double)));
|
|
|
connect(m_pPlotView, SIGNAL(sigPointerPos(double, double)), pointerPosDlg, SLOT(setPointerPos(double, double)));
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::syncMapObjectNames()
|
|
|
{
|
|
|
if (m_pPlot == nullptr || m_pGraphicBinder == nullptr || m_pDataManager == nullptr) return;
|
|
|
for (int i = 0; i < m_pPlot->getObjCount(); ++i) {
|
|
|
m_pGraphicBinder->syncMapObjectName(qobject_cast<nmObjBase*>(m_pPlot->getObjByIndex(i)));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
QSharedPointer<nmMapObjectState> nmGuiPlot::captureMapObject(nmObjBase* object)
|
|
|
{
|
|
|
QSharedPointer<nmMapObjectState> state;
|
|
|
if (object == nullptr || m_pPlot == nullptr ||
|
|
|
m_pGraphicBinder == nullptr || m_pDataManager == nullptr) return state;
|
|
|
|
|
|
m_pGraphicBinder->syncMapObjectName(object);
|
|
|
state = QSharedPointer<nmMapObjectState>(new nmMapObjectState());
|
|
|
state->id = object->historyId();
|
|
|
state->name = object->getName();
|
|
|
state->points = object->getAllValues();
|
|
|
state->dataIndex = -1;
|
|
|
state->includedWellIndex = -1;
|
|
|
state->childIndex = m_pPlot->indexOf(object);
|
|
|
state->objectIndex = -1;
|
|
|
for (int i = 0; i < m_pPlot->getObjCount(); ++i) {
|
|
|
if (m_pPlot->getObjByIndex(i) == object) {
|
|
|
state->objectIndex = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
state->lockedPosition = object->isLockPos();
|
|
|
state->lockedSize = object->isLockSize();
|
|
|
state->readOnly = object->isReadOnly();
|
|
|
state->visible = object->isVisible();
|
|
|
if (nmObjLineFault* fault = qobject_cast<nmObjLineFault*>(object)) {
|
|
|
state->type = NMOT_Line_Fault;
|
|
|
if (nmDataFault* data = m_pGraphicBinder->getFaultDataFor(fault)) {
|
|
|
state->data = QSharedPointer<nmDataBase>(new nmDataFault(*data));
|
|
|
state->dataIndex = m_pDataManager->getFaultDataList().indexOf(data);
|
|
|
}
|
|
|
} else if (nmObjLineCrack* crack = qobject_cast<nmObjLineCrack*>(object)) {
|
|
|
state->type = NMOT_Line_Fracture;
|
|
|
if (nmDataFracture* data = m_pGraphicBinder->getCrackDataFor(crack)) {
|
|
|
state->data = QSharedPointer<nmDataBase>(new nmDataFracture(*data));
|
|
|
state->dataIndex = m_pDataManager->getFractureDataList().indexOf(data);
|
|
|
}
|
|
|
} else if (nmObjRegion* region = qobject_cast<nmObjRegion*>(object)) {
|
|
|
state->type = NMOT_Region;
|
|
|
if (nmDataRegion* data = m_pGraphicBinder->getRegionDataFor(region)) {
|
|
|
state->pen = region->getPen();
|
|
|
nmDataRegion* copy = new nmDataRegion(*data);
|
|
|
copy->setPenWidth(state->pen.widthF());
|
|
|
// 区域归属由现存标记的位置与顺序推导,历史副本不保留数据指针。
|
|
|
copy->setRegionMarkData(nullptr);
|
|
|
state->data = QSharedPointer<nmDataBase>(copy);
|
|
|
state->dataIndex = m_pDataManager->getRegionDataList().indexOf(data);
|
|
|
}
|
|
|
} else if (nmObjRegionMark* mark = qobject_cast<nmObjRegionMark*>(object)) {
|
|
|
state->type = NMOT_RegionMark;
|
|
|
if (nmDataRegionMark* data = m_pGraphicBinder->getRegionMarkDataFor(mark)) {
|
|
|
state->data = QSharedPointer<nmDataBase>(new nmDataRegionMark(*data));
|
|
|
state->dataIndex = m_pDataManager->getRegionMarkDataList().indexOf(data);
|
|
|
}
|
|
|
} else if (nmObjPointWell* well = qobject_cast<nmObjPointWell*>(object)) {
|
|
|
state->type = NMOT_Point_Well;
|
|
|
if (nmDataWellBase* data = m_pGraphicBinder->getWellDataFor(well)) {
|
|
|
state->data = QSharedPointer<nmDataBase>(data->clone());
|
|
|
state->dataIndex = m_pDataManager->getWellDataList().indexOf(data);
|
|
|
state->currentWell = m_pDataManager->getCurWellData() == data;
|
|
|
const QVector<nmCalculationWellRef> includedWells = m_pDataManager->getIncludedCalculationWells();
|
|
|
for (int i = 0; i < includedWells.size(); ++i) {
|
|
|
if (includedWells.at(i).m_sWellCode == data->getWellCode()) {
|
|
|
state->includedWell = includedWells.at(i);
|
|
|
state->includedWellIndex = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else if (nmDataOutline* data = m_pGraphicBinder->getOutlineDataFor(object)) {
|
|
|
state->type = qobject_cast<nmObjRoundOutline*>(object) ? NMOT_RoundOutline
|
|
|
: (qobject_cast<nmObjRectOutline*>(object) ? NMOT_RectOutline : NMOT_PolygonOutline);
|
|
|
nmDataOutline* copy = new nmDataOutline(*data);
|
|
|
copy->setPen(object->getPen());
|
|
|
state->data = QSharedPointer<nmDataBase>(copy);
|
|
|
}
|
|
|
if (state->data.isNull()) state.clear();
|
|
|
return state;
|
|
|
}
|
|
|
|
|
|
QUndoStack* nmGuiPlot::mapEditHistory() const
|
|
|
{
|
|
|
nmPlotView* view = qobject_cast<nmPlotView*>(m_pPlotView);
|
|
|
return view != nullptr ? view->mapEditHistory() : nullptr;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::recordMapCreation(nmObjBase* object, const QSharedPointer<nmMapObjectState>& previous)
|
|
|
{
|
|
|
QUndoStack* stack = mapEditHistory();
|
|
|
const QSharedPointer<nmMapObjectState> current = captureMapObject(object);
|
|
|
if (stack != nullptr && current) stack->push(new nmMapObjectCommand(this, previous, current));
|
|
|
}
|
|
|
|
|
|
QStringList nmGuiPlot::applyWellSelection(const QList<ZxDataWell*>& wells)
|
|
|
{
|
|
|
QStringList failedWells;
|
|
|
if (m_bMapEditingLocked || m_pPlot == nullptr || m_pGraphicBinder == nullptr || m_pDataManager == nullptr) {
|
|
|
return failedWells;
|
|
|
}
|
|
|
|
|
|
QUndoStack* stack = mapEditHistory();
|
|
|
QScopedPointer<QUndoCommand> group(new QUndoCommand);
|
|
|
QSet<QString> selected;
|
|
|
foreach (ZxDataWell* well, wells) {
|
|
|
if (well != nullptr && !well->getCode().isEmpty()) selected.insert(well->getCode());
|
|
|
}
|
|
|
QSet<QString> existing;
|
|
|
const bool repaintEnabled = updatesEnabled();
|
|
|
setUpdatesEnabled(false);
|
|
|
|
|
|
// 逐个记录删除前的顺序和井参数,撤销时按相反顺序还原。
|
|
|
foreach (nmObjPointWell* well, getWellPlots()) {
|
|
|
nmDataWellBase* data = m_pGraphicBinder->getWellDataFor(well);
|
|
|
const QString code = data != nullptr ? data->getWellCode() : well->getWellID();
|
|
|
existing.insert(code);
|
|
|
// 工区当前缺失的井不在选择列表中,保留其已有的数值数据。
|
|
|
if (selected.contains(code) || well->getWellData() == nullptr ||
|
|
|
m_pGraphicBinder->isPrimaryWellGraphic(well)) continue;
|
|
|
|
|
|
const QSharedPointer<nmMapObjectState> before = captureMapObject(well);
|
|
|
if (removeMapObject(well) && before) {
|
|
|
new nmMapObjectCommand(this, before, QSharedPointer<nmMapObjectState>(), group.data());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
foreach (ZxDataWell* projectWell, wells) {
|
|
|
if (projectWell == nullptr) continue;
|
|
|
const QString code = projectWell->getCode();
|
|
|
if (code.isEmpty() || existing.contains(code)) continue;
|
|
|
|
|
|
const QString wellName = projectWell->getName();
|
|
|
QString objectName = wellName;
|
|
|
const bool wasModified = isModified();
|
|
|
nmObjPointWell* well = static_cast<nmObjPointWell*>(
|
|
|
createMapObject(NMOT_Point_Well, objectName, -1, -1));
|
|
|
if (well == nullptr) {
|
|
|
failedWells.append(wellName);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
const QPointF position(projectWell->getLocationX(), projectWell->getLocationY());
|
|
|
well->setAllValues(QVector<QPointF>(1, position));
|
|
|
well->setGraphicBinder(m_pGraphicBinder);
|
|
|
well->setWellData(projectWell);
|
|
|
well->afterCreated();
|
|
|
if (!m_pGraphicBinder->hasWellDataFor(well)) {
|
|
|
// 初始化失败时撤掉临时图元,恢复本次尝试前的修改状态。
|
|
|
if (removeMapObject(well)) setModified(wasModified);
|
|
|
failedWells.append(wellName);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
const QSharedPointer<nmMapObjectState> after = captureMapObject(well);
|
|
|
if (after) {
|
|
|
new nmMapObjectCommand(this, QSharedPointer<nmMapObjectState>(), after, group.data());
|
|
|
}
|
|
|
existing.insert(code);
|
|
|
setModified(true);
|
|
|
}
|
|
|
|
|
|
// 只有成功增删才入栈,空操作和全失败操作保留原有恢复记录。
|
|
|
if (stack != nullptr && group->childCount() > 0) stack->push(group.take());
|
|
|
refreshEditingLocks();
|
|
|
setUpdatesEnabled(repaintEnabled);
|
|
|
if (repaintEnabled) update();
|
|
|
return failedWells;
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::restoreMapObject(const nmMapObjectState& state)
|
|
|
{
|
|
|
if (m_pDataManager == nullptr || m_pGraphicBinder == nullptr || m_pPlot == nullptr ||
|
|
|
nmObjBase::findHistoryObject(m_pPlot, state.id) != nullptr) return false;
|
|
|
QString name = state.name;
|
|
|
nmObjBase* object = createMapObject(state.type, name, state.objectIndex, state.childIndex);
|
|
|
if (object == nullptr) return false;
|
|
|
object->setHistoryId(state.id);
|
|
|
object->setName(state.name);
|
|
|
object->setAllValues(state.points);
|
|
|
|
|
|
// 创建并绑定同类业务对象后,再统一恢复图元状态和刷新模型列表。
|
|
|
switch (state.type) {
|
|
|
case NMOT_Line_Fault: {
|
|
|
nmDataFault* data = m_pDataManager->createFault();
|
|
|
*data = *static_cast<nmDataFault*>(state.data.data());
|
|
|
m_pDataManager->restoreMapGeometryOrder(data, state.dataIndex);
|
|
|
m_pGraphicBinder->bindFaultToGraphic(static_cast<nmObjLineFault*>(object), data);
|
|
|
break;
|
|
|
}
|
|
|
case NMOT_Line_Fracture: {
|
|
|
nmDataFracture* data = m_pDataManager->createFracture();
|
|
|
*data = *static_cast<nmDataFracture*>(state.data.data());
|
|
|
m_pDataManager->restoreMapGeometryOrder(data, state.dataIndex);
|
|
|
m_pGraphicBinder->bindCrackToGraphic(static_cast<nmObjLineCrack*>(object), data);
|
|
|
break;
|
|
|
}
|
|
|
case NMOT_Region: {
|
|
|
nmDataRegion* data = m_pDataManager->createRegion();
|
|
|
*data = *static_cast<nmDataRegion*>(state.data.data());
|
|
|
m_pDataManager->restoreMapGeometryOrder(data, state.dataIndex);
|
|
|
nmObjRegion* region = static_cast<nmObjRegion*>(object);
|
|
|
region->setPen(state.pen);
|
|
|
m_pGraphicBinder->bindRegionToGraphic(region, data);
|
|
|
m_pGraphicBinder->refreshRegionMarkAssignments();
|
|
|
break;
|
|
|
}
|
|
|
case NMOT_RegionMark: {
|
|
|
nmDataRegionMark* data = m_pDataManager->createRegionMark();
|
|
|
*data = *static_cast<nmDataRegionMark*>(state.data.data());
|
|
|
m_pDataManager->restoreMapGeometryOrder(data, state.dataIndex);
|
|
|
nmObjRegionMark* mark = static_cast<nmObjRegionMark*>(object);
|
|
|
m_pGraphicBinder->bindRegionMarkToGraphic(mark, data);
|
|
|
m_pGraphicBinder->refreshRegionMarkAssignments();
|
|
|
break;
|
|
|
}
|
|
|
case NMOT_Point_Well: {
|
|
|
nmDataWellBase* data = m_pDataManager->restoreMapWell(
|
|
|
*static_cast<nmDataWellBase*>(state.data.data()), state.dataIndex);
|
|
|
if (data == nullptr) {
|
|
|
removeMapObject(object);
|
|
|
return false;
|
|
|
}
|
|
|
nmObjPointWell* well = static_cast<nmObjPointWell*>(object);
|
|
|
m_pGraphicBinder->bindWellToGraphic(well, data);
|
|
|
// 已绑定数值井时,即使缺少工区井也能恢复标签。
|
|
|
well->afterCreated();
|
|
|
well->setName(state.name);
|
|
|
if (state.currentWell) m_pDataManager->setCurWellData(data);
|
|
|
if (state.includedWellIndex >= 0) {
|
|
|
// 只把恢复的井并回当前列表,保留其他井之后修改的参与状态。
|
|
|
QVector<nmCalculationWellRef> includedWells = m_pDataManager->getIncludedCalculationWells();
|
|
|
int index = 0;
|
|
|
while (index < includedWells.size() &&
|
|
|
includedWells.at(index).m_sWellCode != state.includedWell.m_sWellCode) {
|
|
|
++index;
|
|
|
}
|
|
|
if (index == includedWells.size()) {
|
|
|
includedWells.insert(qMin(state.includedWellIndex, includedWells.size()), state.includedWell);
|
|
|
m_pDataManager->setIncludedCalculationWells(includedWells);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case NMOT_RoundOutline:
|
|
|
case NMOT_RectOutline:
|
|
|
case NMOT_PolygonOutline: {
|
|
|
nmDataOutline* data = m_pDataManager->createOutline();
|
|
|
*data = *static_cast<nmDataOutline*>(state.data.data());
|
|
|
m_pGraphicBinder->bindOutlineToGraphic(object, data);
|
|
|
break;
|
|
|
}
|
|
|
default:
|
|
|
removeMapObject(object);
|
|
|
return false;
|
|
|
}
|
|
|
object->setLockPos(state.lockedPosition);
|
|
|
object->setLockSize(state.lockedSize);
|
|
|
object->setReadOnly(state.readOnly);
|
|
|
object->setVisible(state.visible);
|
|
|
m_pDataManager->notifyGeometryListChanged();
|
|
|
setModified(true);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::removeMapObject(nmObjBase* object)
|
|
|
{
|
|
|
if (m_pPlot == nullptr || object == nullptr || m_pGraphicBinder == nullptr) return false;
|
|
|
for (int i = 0; i < m_pPlot->getObjCount(); ++i) {
|
|
|
if (m_pPlot->getObjByIndex(i) != object) continue;
|
|
|
if (nmObjLineFault* fault = qobject_cast<nmObjLineFault*>(object)) {
|
|
|
m_pGraphicBinder->removeFaultBinding(fault);
|
|
|
} else if (nmObjLineCrack* crack = qobject_cast<nmObjLineCrack*>(object)) {
|
|
|
m_pGraphicBinder->removeCrackBinding(crack);
|
|
|
} else if (nmObjRegion* region = qobject_cast<nmObjRegion*>(object)) {
|
|
|
m_pGraphicBinder->removeRegionBinding(region);
|
|
|
} else if (nmObjRegionMark* mark = qobject_cast<nmObjRegionMark*>(object)) {
|
|
|
m_pGraphicBinder->removeRegionMarkBinding(mark);
|
|
|
} else if (nmObjPointWell* well = qobject_cast<nmObjPointWell*>(object)) {
|
|
|
if (!m_pGraphicBinder->removeWellBinding(well)) return false;
|
|
|
} else if (nmObjLineMeasure* measure = qobject_cast<nmObjLineMeasure*>(object)) {
|
|
|
m_pGraphicBinder->removeMeasureBinding(measure);
|
|
|
} else if (m_pGraphicBinder->getOutlineDataFor(object) != nullptr) {
|
|
|
m_pGraphicBinder->removeOutlineBinding(object);
|
|
|
} else {
|
|
|
object->removeData();
|
|
|
}
|
|
|
m_pPlot->removeObjByIndex(i);
|
|
|
setModified(true);
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::confirmDeleteMapObject(ZxObjBase* target)
|
|
|
{
|
|
|
QPointer<nmObjBase> object = qobject_cast<nmObjBase*>(target);
|
|
|
if (m_bMapEditingLocked || object.isNull() || m_pPlot == nullptr || object->getPlot() != m_pPlot) return;
|
|
|
|
|
|
if (nmObjPointWell* well = qobject_cast<nmObjPointWell*>(object.data())) {
|
|
|
if (m_pGraphicBinder && m_pGraphicBinder->isPrimaryWellGraphic(well)) {
|
|
|
QMessageBox::information(this, tr("Cannot Delete Well"),
|
|
|
tr("The primary analysis well cannot be deleted."));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
nmPlotDialogContextProvider* provider = nmPlotDialogContext::provider();
|
|
|
QPointer<nmGuiPlot> owner = this;
|
|
|
QPointer<nmDataAnalyzeManager> manager = m_pDataManager;
|
|
|
if (provider == nullptr || !provider->confirmDeleteObject(
|
|
|
this, object->getName(), object->getTagName())) return;
|
|
|
// 确认窗口可能处理页签切换等事件,提交前重新核对地图、数据归属和对象是否有效。
|
|
|
if (owner.isNull() || object.isNull() || manager.isNull() ||
|
|
|
manager.data() != m_pDataManager || m_bMapEditingLocked || object->getPlot() != m_pPlot) return;
|
|
|
|
|
|
QUndoStack* stack = mapEditHistory();
|
|
|
const QSharedPointer<nmMapObjectState> previous = captureMapObject(object.data());
|
|
|
if (removeMapObject(object.data()) && stack != nullptr && previous) {
|
|
|
stack->push(new nmMapObjectCommand(this, previous, QSharedPointer<nmMapObjectState>()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::clearPlotsSelectStates()
|
|
|
{
|
|
|
// 获取所有图元
|
|
|
QVector<nmObjBase*> vecObjs = this->getAllPlots();
|
|
|
|
|
|
// 遍历所有图元对象,如果为选中状态,则恢复为未选中
|
|
|
foreach(nmObjBase* obj, vecObjs) {
|
|
|
if(obj->isSelected()) {
|
|
|
obj->setSelected(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::clearDFNPlotObjects()
|
|
|
{
|
|
|
if (!m_pPlot || !m_pGraphicBinder) return;
|
|
|
// 按对象索引删除,兼容旧工程中多个 DFN 使用同一名称的情况。
|
|
|
for (int i = m_pPlot->getObjCount() - 1; i >= 0; --i) {
|
|
|
nmObjLineCrack* pCrack = dynamic_cast<nmObjLineCrack*>(m_pPlot->getObjByIndex(i));
|
|
|
if (!pCrack) continue;
|
|
|
nmDataFracture* pData = m_pGraphicBinder->getCrackDataFor(pCrack);
|
|
|
if (!pData || pData->getFractureType().getValue().toString() != "DFN") continue;
|
|
|
m_pGraphicBinder->detachCrackBinding(pCrack);
|
|
|
m_pPlot->removeObjByIndex(i);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::deleteAllDFNPlots()
|
|
|
{
|
|
|
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjLineFracture");
|
|
|
|
|
|
if(objList.count() > 0) {
|
|
|
for(int i = 0; i < objList.count() ; i++) {
|
|
|
nmObjLineCrack* pCrack = (nmObjLineCrack*)objList[i];
|
|
|
|
|
|
if(pCrack == nullptr || m_pGraphicBinder == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
nmDataFracture* pData = m_pGraphicBinder->getCrackDataFor(pCrack);
|
|
|
if(pData == nullptr) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if(pData->getFractureType().getValue() == tr("DFN")) {
|
|
|
// 通过 Binder 清理数据绑定
|
|
|
m_pGraphicBinder->removeCrackBinding(pCrack);
|
|
|
// 删除DFN图元
|
|
|
m_pPlot->removeObjByName(pCrack->getName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
nmDataAnalyzeManager* nmGuiPlot::boundDataManager() const
|
|
|
{
|
|
|
return m_pDataManager;
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::isScaleBarVisible() const
|
|
|
{
|
|
|
const nmDataAxis* axis = m_pDataManager != nullptr ? m_pDataManager->getAxisData() : nullptr;
|
|
|
return axis == nullptr || axis->isScaleBarVisible();
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::setScaleBarVisible(bool visible)
|
|
|
{
|
|
|
nmDataAxis* axis = m_pDataManager != nullptr ? m_pDataManager->getAxisData() : nullptr;
|
|
|
if (axis == nullptr) return;
|
|
|
axis->setScaleBarVisible(visible);
|
|
|
if (nmPlotView* view = qobject_cast<nmPlotView*>(m_pPlotView)) {
|
|
|
view->setScaleBarVisible(visible);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
nmDataAnalyzeManager* nmGuiPlot::dataManager() const
|
|
|
{
|
|
|
return m_pDataManager != nullptr
|
|
|
? m_pDataManager
|
|
|
: nmDataAnalyzeManager::getCurrentInstance();
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::calculateVisibleContentBounds(QRectF& oBounds) const
|
|
|
{
|
|
|
nmDataAnalyzeManager* pDataManager = dataManager();
|
|
|
if(pDataManager == nullptr) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
bool bHasBounds = false;
|
|
|
double dMinX = 0.0;
|
|
|
double dMaxX = 0.0;
|
|
|
double dMinY = 0.0;
|
|
|
double dMaxY = 0.0;
|
|
|
|
|
|
nmDataOutline* pOutlineData = pDataManager->getOutlineData();
|
|
|
if(pOutlineData != nullptr && pOutlineData->getPlotVisible()) {
|
|
|
if(pOutlineData->getOutlineType() == NM_Round_Outline_Type) {
|
|
|
const QPointF oCenter = pOutlineData->getCenter();
|
|
|
const double dRadius = qAbs(pOutlineData->getRadius());
|
|
|
includeMapPoint(QPointF(oCenter.x() - dRadius,
|
|
|
oCenter.y() - dRadius),
|
|
|
bHasBounds, dMinX, dMaxX, dMinY, dMaxY);
|
|
|
includeMapPoint(QPointF(oCenter.x() + dRadius,
|
|
|
oCenter.y() + dRadius),
|
|
|
bHasBounds, dMinX, dMaxX, dMinY, dMaxY);
|
|
|
} else {
|
|
|
includeMapPoints(pOutlineData->getOutlinePoints(),
|
|
|
bHasBounds, dMinX, dMaxX, dMinY, dMaxY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const QVector<nmDataWellBase*> vecWells = pDataManager->getWellDataList();
|
|
|
foreach(nmDataWellBase* pWellData, vecWells) {
|
|
|
if(pWellData != nullptr && pWellData->getPlotVisible()) {
|
|
|
includeMapPoint(QPointF(
|
|
|
pWellData->getX().getValue().toDouble(),
|
|
|
pWellData->getY().getValue().toDouble()),
|
|
|
bHasBounds, dMinX, dMaxX, dMinY, dMaxY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const QVector<nmDataFault*> vecFaults = pDataManager->getFaultDataList();
|
|
|
foreach(nmDataFault* pFaultData, vecFaults) {
|
|
|
if(pFaultData != nullptr && pFaultData->getPlotVisible()) {
|
|
|
includeMapPoints(pFaultData->getFaultPoints(),
|
|
|
bHasBounds, dMinX, dMaxX, dMinY, dMaxY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const QVector<nmDataFracture*> vecFractures =
|
|
|
pDataManager->getFractureDataList();
|
|
|
foreach(nmDataFracture* pFractureData, vecFractures) {
|
|
|
if(pFractureData != nullptr && pFractureData->getPlotVisible()) {
|
|
|
includeMapPoints(pFractureData->getFracturePoints(),
|
|
|
bHasBounds, dMinX, dMaxX, dMinY, dMaxY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const QVector<nmDataRegion*> vecRegions = pDataManager->getRegionDataList();
|
|
|
foreach(nmDataRegion* pRegionData, vecRegions) {
|
|
|
if(pRegionData != nullptr && pRegionData->getPlotVisible()) {
|
|
|
includeMapPoints(pRegionData->getVecPts(),
|
|
|
bHasBounds, dMinX, dMaxX, dMinY, dMaxY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const QVector<nmDataRegionMark*> vecRegionMarks =
|
|
|
pDataManager->getRegionMarkDataList();
|
|
|
foreach(nmDataRegionMark* pRegionMarkData, vecRegionMarks) {
|
|
|
if(pRegionMarkData != nullptr && pRegionMarkData->getPlotVisible()) {
|
|
|
includeMapPoint(pRegionMarkData->getPtPos(),
|
|
|
bHasBounds, dMinX, dMaxX, dMinY, dMaxY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(!bHasBounds) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
oBounds = QRectF(QPointF(dMinX, dMinY),
|
|
|
QPointF(dMaxX, dMaxY)).normalized();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::applyAxisRange(double dXMin, double dXMax,
|
|
|
double dYMin, double dYMax)
|
|
|
{
|
|
|
if(m_pPlot == nullptr ||
|
|
|
!qIsFinite(dXMin) || !qIsFinite(dXMax) ||
|
|
|
!qIsFinite(dYMin) || !qIsFinite(dYMax) ||
|
|
|
dXMax <= dXMin || dYMax <= dYMin) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const bool bOldApplying = m_bApplyingAxisRange;
|
|
|
m_bApplyingAxisRange = true;
|
|
|
m_pPlot->getMainAxisX()->setRangeMinMax(dXMin, dXMax, true, false);
|
|
|
m_pPlot->getMainAxisY()->setRangeMinMax(dYMin, dYMax, true, false);
|
|
|
|
|
|
nmDataAnalyzeManager* pDataManager = dataManager();
|
|
|
nmDataAxis* pAxisData = pDataManager != nullptr
|
|
|
? pDataManager->getAxisData() : nullptr;
|
|
|
if(pAxisData != nullptr) {
|
|
|
pAxisData->getXMin().setValue(dXMin);
|
|
|
pAxisData->getXMax().setValue(dXMax);
|
|
|
pAxisData->getYMin().setValue(dYMin);
|
|
|
pAxisData->getYMax().setValue(dYMax);
|
|
|
}
|
|
|
m_bApplyingAxisRange = bOldApplying;
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::fitInitialAxisToContent()
|
|
|
{
|
|
|
if(m_pPlot == nullptr) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
QRectF oBounds;
|
|
|
if(!calculateVisibleContentBounds(oBounds)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
QRectF oPlotRect = m_pPlot->getInnerRectF();
|
|
|
if(oPlotRect.width() <= 0.0 || oPlotRect.height() <= 0.0) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
double dCenterX = (oBounds.left() + oBounds.right()) * 0.5;
|
|
|
double dCenterY = (oBounds.top() + oBounds.bottom()) * 0.5;
|
|
|
double dRangeX = oBounds.width();
|
|
|
double dRangeY = oBounds.height();
|
|
|
|
|
|
// 退化为点或直线时补足基础跨度,避免产生零范围坐标轴。
|
|
|
if(dRangeX <= 0.0) {
|
|
|
dRangeX = 1500.0;
|
|
|
}
|
|
|
if(dRangeY <= 0.0) {
|
|
|
dRangeY = 1500.0;
|
|
|
}
|
|
|
|
|
|
// 内容四周各增加最大边长的 5%,边界本身不因此发生变化。
|
|
|
const double dPadding = qMax(dRangeX, dRangeY) * 0.05;
|
|
|
dRangeX += dPadding * 2.0;
|
|
|
dRangeY += dPadding * 2.0;
|
|
|
|
|
|
const double dViewRatio = oPlotRect.width() / oPlotRect.height();
|
|
|
const double dContentRatio = dRangeX / dRangeY;
|
|
|
if(dContentRatio < dViewRatio) {
|
|
|
dRangeX = dRangeY * dViewRatio;
|
|
|
} else {
|
|
|
dRangeY = dRangeX / dViewRatio;
|
|
|
}
|
|
|
|
|
|
applyAxisRange(dCenterX - dRangeX * 0.5,
|
|
|
dCenterX + dRangeX * 0.5,
|
|
|
dCenterY - dRangeY * 0.5,
|
|
|
dCenterY + dRangeY * 0.5);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::scheduleInitialAxisView()
|
|
|
{
|
|
|
if(m_bAxisInitializationPending) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_bAxisInitializationPending = true;
|
|
|
QTimer::singleShot(0, this, SLOT(initializeAxisView()));
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::initializeAxisView()
|
|
|
{
|
|
|
m_bAxisInitializationPending = false;
|
|
|
nmDataAnalyzeManager* pDataManager = dataManager();
|
|
|
nmDataAxis* pAxisData = pDataManager != nullptr
|
|
|
? pDataManager->getAxisData() : nullptr;
|
|
|
if(pAxisData == nullptr || pAxisData->isInitialViewFitted()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 只有真实绘图区和图元均准备好后才封闭初始化,失败时等待下一次显示尺寸变化。
|
|
|
if(fitInitialAxisToContent()) {
|
|
|
pAxisData->setInitialViewFitted(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::resizeEvent(QResizeEvent* pEvent)
|
|
|
{
|
|
|
nmDataAnalyzeManager* pDataManager = dataManager();
|
|
|
nmDataAxis* pAxisData = pDataManager != nullptr
|
|
|
? pDataManager->getAxisData() : nullptr;
|
|
|
const bool bWaitingForInitialView =
|
|
|
pAxisData != nullptr && !pAxisData->isInitialViewFitted();
|
|
|
const bool bOldApplying = m_bApplyingAxisRange;
|
|
|
if(bWaitingForInitialView) {
|
|
|
// 布局阶段可能触发轴信号,不能把它误认为用户已经设置了范围。
|
|
|
m_bApplyingAxisRange = true;
|
|
|
}
|
|
|
iGuiPlot::resizeEvent(pEvent);
|
|
|
m_bApplyingAxisRange = bOldApplying;
|
|
|
if(bWaitingForInitialView) {
|
|
|
scheduleInitialAxisView();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::onRangeXChanged(double dMin, double dMax, bool bRecalTicks, bool bAdjustRectZoomRatio)
|
|
|
{
|
|
|
nmDataAnalyzeManager* pDataManager = dataManager();
|
|
|
nmDataAxis* pAxisData = pDataManager != nullptr
|
|
|
? pDataManager->getAxisData() : nullptr;
|
|
|
|
|
|
if(pAxisData == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 获取 X 最大值
|
|
|
pAxisData->getXMax().setValue(dMax);
|
|
|
|
|
|
// 获取 X 最小值
|
|
|
pAxisData->getXMin().setValue(dMin);
|
|
|
|
|
|
if(!m_bApplyingAxisRange) {
|
|
|
// 任一用户轴操作都终止首次初始化,后续范围完全由用户控制。
|
|
|
pAxisData->setInitialViewFitted(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::onRangeYChanged(double dMin, double dMax, bool bRecalTicks, bool bAdjustRectZoomRatio)
|
|
|
{
|
|
|
nmDataAnalyzeManager* pDataManager = dataManager();
|
|
|
nmDataAxis* pAxisData = pDataManager != nullptr
|
|
|
? pDataManager->getAxisData() : nullptr;
|
|
|
|
|
|
if(pAxisData == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 获取 Y 最大值
|
|
|
pAxisData->getYMax().setValue(dMax);
|
|
|
|
|
|
// 获取 Y 最小值
|
|
|
pAxisData->getYMin().setValue(dMin);
|
|
|
|
|
|
if(!m_bApplyingAxisRange) {
|
|
|
pAxisData->setInitialViewFitted(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// ============================== 可见性设置方法实现 ==============================
|
|
|
|
|
|
void nmGuiPlot::setContourVisibility(bool bIsVisible)
|
|
|
{
|
|
|
|
|
|
// 边界图元对象
|
|
|
QVector<ZxObjBase*> vecPlotObjs;
|
|
|
|
|
|
// 1、从数据中心获取当前边界类型
|
|
|
nmDataAnalyzeManager* pManager = boundDataManager();
|
|
|
|
|
|
if(pManager == nullptr || pManager->getOutlineData() == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
NM_Data_Outline_Type eOutlineType = pManager->getOutlineData()->getOutlineType();
|
|
|
|
|
|
// 2、根据边界类型设置是否可见
|
|
|
if(eOutlineType == NM_Data_Outline_Type::NM_Rect_Outline_Type) {
|
|
|
vecPlotObjs = this->getObjsByTag("nObjRectOutline");
|
|
|
|
|
|
if(vecPlotObjs.count() > 0) {
|
|
|
for(int i = 0; i < vecPlotObjs.count() ; i++) {
|
|
|
nmObjRectOutline* pOutline = (nmObjRectOutline*)vecPlotObjs[i];
|
|
|
|
|
|
if(pOutline != nullptr) {
|
|
|
pOutline->setVisible(bIsVisible);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else if(eOutlineType == NM_Data_Outline_Type::NM_Polygon_Outline_Type) {
|
|
|
vecPlotObjs = this->getObjsByTag("nObjPolygonOutline");
|
|
|
|
|
|
if(vecPlotObjs.count() > 0) {
|
|
|
for(int i = 0; i < vecPlotObjs.count() ; i++) {
|
|
|
nmObjPolygonOutline* pOutline = (nmObjPolygonOutline*)vecPlotObjs[i];
|
|
|
|
|
|
if(pOutline != nullptr) {
|
|
|
pOutline->setVisible(bIsVisible);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else if(eOutlineType == NM_Data_Outline_Type::NM_Round_Outline_Type) {
|
|
|
vecPlotObjs = this->getObjsByTag("nObjRoundOutline");
|
|
|
|
|
|
if(vecPlotObjs.count() > 0) {
|
|
|
for(int i = 0; i < vecPlotObjs.count() ; i++) {
|
|
|
nmObjRoundOutline* pOutline = (nmObjRoundOutline*)vecPlotObjs[i];
|
|
|
|
|
|
if(pOutline != nullptr) {
|
|
|
pOutline->setVisible(bIsVisible);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::chooseBackgroundImage(QWidget* pParent, BackgroundImageInfo& oImage)
|
|
|
{
|
|
|
QString sInitialDir = QFileInfo(oImage.sFilePath).absolutePath();
|
|
|
if(oImage.sFilePath.isEmpty() || !QDir(sInitialDir).exists()) {
|
|
|
sInitialDir = ZxBaseUtil::getLastDir();
|
|
|
}
|
|
|
const QString sFile = QFileDialog::getOpenFileName(pParent,
|
|
|
tr("Import reservoir map"), sInitialDir,
|
|
|
tr("Image files (*.png *.jpg *.jpeg *.bmp)"));
|
|
|
if(sFile.isEmpty()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
QImageReader oReader(sFile);
|
|
|
const QImage oLoadedImage = oReader.read();
|
|
|
if(oLoadedImage.isNull()) {
|
|
|
QMessageBox::warning(pParent, tr("Reservoir map"),
|
|
|
tr("Cannot read image: %1").arg(oReader.errorString()));
|
|
|
return false;
|
|
|
}
|
|
|
ZxBaseUtil::setLastDir(QFileInfo(sFile).absolutePath());
|
|
|
oImage.sFilePath = QFileInfo(sFile).absoluteFilePath();
|
|
|
oImage.objImage = oLoadedImage;
|
|
|
oImage.bIsVisible = true;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::importBackgroundImage()
|
|
|
{
|
|
|
QPointer<nmGuiPlot> pOwner(this);
|
|
|
QPointer<nmDataAnalyzeManager> pManager(boundDataManager());
|
|
|
if(pManager.isNull() || m_pPlot == NULL) {
|
|
|
return;
|
|
|
}
|
|
|
BackgroundImageInfo oImage = pManager->getBackgroundImageInfo();
|
|
|
if(!chooseBackgroundImage(this, oImage) || pOwner.isNull() ||
|
|
|
pManager.isNull() || pOwner->boundDataManager() != pManager.data()) {
|
|
|
return;
|
|
|
}
|
|
|
QString sError;
|
|
|
if(!pOwner->applyBackgroundImage(oImage, sError)) {
|
|
|
QMessageBox::warning(pOwner, tr("Reservoir map"), sError);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::renderBackgroundImage(const BackgroundImageInfo& oImage, QString& sError)
|
|
|
{
|
|
|
sError.clear();
|
|
|
if(m_pPlot == NULL || m_pPlot->getMainAxisX() == NULL ||
|
|
|
m_pPlot->getMainAxisY() == NULL) {
|
|
|
sError = tr("The map is no longer available.");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
QTemporaryFile* pNewCache = NULL;
|
|
|
QString sDisplayPath;
|
|
|
if(oImage.bIsVisible && !oImage.objImage.isNull()) {
|
|
|
// 底层框架只有路径接口。缓存跟随 Map 生命周期,不覆盖用户原图,也不进入工程数据。
|
|
|
if(m_pBackgroundImageCache == NULL ||
|
|
|
m_nBackgroundImageCacheKey != oImage.objImage.cacheKey() ||
|
|
|
!QFileInfo(m_pBackgroundImageCache->fileName()).exists()) {
|
|
|
pNewCache = new QTemporaryFile(
|
|
|
QDir::tempPath() + "/nm-reservoir-map-XXXXXX.png", this);
|
|
|
if(!pNewCache->open() || !oImage.objImage.save(pNewCache, "PNG")) {
|
|
|
delete pNewCache;
|
|
|
sError = tr("Cannot prepare the reservoir map image.");
|
|
|
return false;
|
|
|
}
|
|
|
pNewCache->close();
|
|
|
}
|
|
|
sDisplayPath = pNewCache != NULL ? pNewCache->fileName()
|
|
|
: m_pBackgroundImageCache->fileName();
|
|
|
}
|
|
|
|
|
|
const double dXMin = m_pPlot->getMainAxisX()->getRangeMin();
|
|
|
const double dXMax = m_pPlot->getMainAxisX()->getRangeMax();
|
|
|
const double dYMin = m_pPlot->getMainAxisY()->getRangeMin();
|
|
|
const double dYMax = m_pPlot->getMainAxisY()->getRangeMax();
|
|
|
const bool bOldApplying = m_bApplyingAxisRange;
|
|
|
m_bApplyingAxisRange = true;
|
|
|
m_pPlot->setBkImgFile(sDisplayPath);
|
|
|
const bool bLoaded = sDisplayPath.isEmpty() ||
|
|
|
(m_pPlot->getBkImg() != NULL && !m_pPlot->getBkImg()->isNull());
|
|
|
if(!bLoaded) {
|
|
|
m_pPlot->setBkImgFile(m_sDisplayedBackgroundImagePath);
|
|
|
}
|
|
|
// 导入、替换、显隐都不改变坐标和已有井/裂缝;标定仍由现有比例尺工具完成。
|
|
|
applyAxisRange(dXMin, dXMax, dYMin, dYMax);
|
|
|
m_bApplyingAxisRange = bOldApplying;
|
|
|
if(!bLoaded) {
|
|
|
delete pNewCache;
|
|
|
sError = tr("Cannot display the reservoir map image.");
|
|
|
return false;
|
|
|
}
|
|
|
if(pNewCache != NULL || oImage.objImage.isNull()) {
|
|
|
delete m_pBackgroundImageCache;
|
|
|
m_pBackgroundImageCache = pNewCache;
|
|
|
m_nBackgroundImageCacheKey = oImage.objImage.cacheKey();
|
|
|
}
|
|
|
m_sDisplayedBackgroundImagePath = sDisplayPath;
|
|
|
update();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::applyBackgroundImage(const BackgroundImageInfo& oImage, QString& sError)
|
|
|
{
|
|
|
nmDataAnalyzeManager* pManager = boundDataManager();
|
|
|
if(pManager == NULL) {
|
|
|
sError = tr("The map is no longer available.");
|
|
|
return false;
|
|
|
}
|
|
|
BackgroundImageInfo oNormalized = oImage;
|
|
|
if(oNormalized.objImage.isNull()) {
|
|
|
oNormalized = BackgroundImageInfo();
|
|
|
}
|
|
|
if(!renderBackgroundImage(oNormalized, sError)) {
|
|
|
return false;
|
|
|
}
|
|
|
pManager->setBackgroundImageInfo(oNormalized);
|
|
|
// 仅标记视图修改,不发送模型输入变更通知,避免使已有网格和计算结果失效。
|
|
|
setModified(true);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::setImagesVisibility(bool bIsVisible)
|
|
|
{
|
|
|
nmDataAnalyzeManager* pManager = boundDataManager();
|
|
|
if(pManager == NULL) {
|
|
|
return;
|
|
|
}
|
|
|
BackgroundImageInfo oImage = pManager->getBackgroundImageInfo();
|
|
|
oImage.bIsVisible = bIsVisible;
|
|
|
QString sError;
|
|
|
if(!applyBackgroundImage(oImage, sError)) {
|
|
|
QMessageBox::warning(this, tr("Reservoir map"), sError);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置所有井的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setAllWellsVisible(bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjPointWell");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjPointWell* pWell = static_cast<nmObjPointWell*>(vecPlotObjs.at(i));
|
|
|
pWell->setVisible(bIsVisible);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置单个井的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setWellVisible(QString sObjName, bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjPointWell");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjPointWell* pWell = static_cast<nmObjPointWell*>(vecPlotObjs.at(i));
|
|
|
|
|
|
if(pWell->getName() == sObjName) {
|
|
|
pWell->setVisible(bIsVisible);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置所有断层的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setAllFaultsVisible(bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjLineFault");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjLineFault* pFault = static_cast<nmObjLineFault*>(vecPlotObjs.at(i));
|
|
|
pFault->setVisible(bIsVisible);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置单个断层的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setFaultVisible(QString sObjName, bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjLineFault");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjLineFault* pFault = static_cast<nmObjLineFault*>(vecPlotObjs.at(i));
|
|
|
|
|
|
if(pFault->getName() == sObjName) {
|
|
|
pFault->setVisible(bIsVisible);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置所有裂缝的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setAllFracturesVisible(bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjLineFracture");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjLineCrack* pFracture = static_cast<nmObjLineCrack*>(vecPlotObjs.at(i));
|
|
|
pFracture->setVisible(bIsVisible);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置单个裂缝的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setFractureVisible(QString sObjName, bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjLineFracture");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjLineCrack* pFracture = static_cast<nmObjLineCrack*>(vecPlotObjs.at(i));
|
|
|
|
|
|
if(pFracture->getName() == sObjName) {
|
|
|
pFracture->setVisible(bIsVisible);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置所有区域的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setAllRegionsVisible(bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjRegion");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjRegion* pRegion = static_cast<nmObjRegion*>(vecPlotObjs.at(i));
|
|
|
pRegion->setVisible(bIsVisible);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置单个区域的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setRegionVisible(QString sObjName, bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjRegion");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjRegion* pRegion = static_cast<nmObjRegion*>(vecPlotObjs.at(i));
|
|
|
|
|
|
if(pRegion->getName() == sObjName) {
|
|
|
pRegion->setVisible(bIsVisible);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置所有区域标记的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setAllRegionMarksVisible(bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjRegionMark");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjRegionMark* pRegionMark = static_cast<nmObjRegionMark*>(vecPlotObjs.at(i));
|
|
|
pRegionMark->setVisible(bIsVisible);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief 设置单个区域标记的可见性
|
|
|
*/
|
|
|
void nmGuiPlot::setRegionMarkVisible(QString sObjName, bool bIsVisible)
|
|
|
{
|
|
|
QVector<ZxObjBase*> vecPlotObjs = this->getObjsByTag("nObjRegionMark");
|
|
|
|
|
|
for(int i = 0; i < vecPlotObjs.count(); ++i) {
|
|
|
nmObjRegionMark* pRegionMark = static_cast<nmObjRegionMark*>(vecPlotObjs.at(i));
|
|
|
|
|
|
if(pRegionMark->getName() == sObjName) {
|
|
|
pRegionMark->setVisible(bIsVisible);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::finishMeasure()
|
|
|
{
|
|
|
nmGuiPlotCmdHelper* helper = dynamic_cast<nmGuiPlotCmdHelper*>(m_pCmdHelper);
|
|
|
|
|
|
if(helper != nullptr) {
|
|
|
helper->finishMeasure();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool nmGuiPlot::setPlotsByDataManger(nmDataAnalyzeManager* pDataManager)
|
|
|
{
|
|
|
if(pDataManager == nullptr || m_pPlot == nullptr) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
emit sigMapAnalysisLeaving();
|
|
|
cancelActiveTools();
|
|
|
nmPlotView* view = qobject_cast<nmPlotView*>(m_pPlotView);
|
|
|
if (view != nullptr) {
|
|
|
// 先保留旧分析的图元标识,再暂停历史,直到新图元绑定完成。
|
|
|
if (view->mapEditHistory() != nullptr && m_pGraphicBinder != nullptr) {
|
|
|
m_pGraphicBinder->syncMapHistoryIds(false);
|
|
|
}
|
|
|
view->setMapHistoryOwner(nullptr);
|
|
|
}
|
|
|
clearMapGraphics();
|
|
|
if(m_pGraphicBinder != nullptr) {
|
|
|
m_pGraphicBinder->updateDataMgr(pDataManager);
|
|
|
}
|
|
|
m_pDataManager = pDataManager;
|
|
|
nmDataAxis* pAxisData = pDataManager->getAxisData();
|
|
|
const bool bWaitingForInitialView =
|
|
|
pAxisData != nullptr && !pAxisData->isInitialViewFitted();
|
|
|
const bool bOldApplying = m_bApplyingAxisRange;
|
|
|
if(bWaitingForInitialView) {
|
|
|
// 图元创建过程可能发出轴范围信号,首次适配完成前统一按内部更新处理。
|
|
|
m_bApplyingAxisRange = true;
|
|
|
}
|
|
|
// 0.坐标轴
|
|
|
this->initAxisFromData(pDataManager);
|
|
|
// 工程恢复或切换分析时,以所属 Manager 的图片为准;空图片也必须清除旧背景。
|
|
|
QString sImageError;
|
|
|
if(!renderBackgroundImage(pDataManager->getBackgroundImageInfo(), sImageError)) {
|
|
|
m_pPlot->setBkImgFile(QString());
|
|
|
m_sDisplayedBackgroundImagePath.clear();
|
|
|
qWarning() << sImageError;
|
|
|
}
|
|
|
// 1.边界
|
|
|
this->initBoundaryObjFromData(pDataManager);
|
|
|
// 2.井
|
|
|
this->initWellObjsFromData(pDataManager);
|
|
|
// 3.断层
|
|
|
this->initFaultObjsFromData(pDataManager);
|
|
|
// 4.裂缝
|
|
|
this->initFractureObjsFromData(pDataManager);
|
|
|
// 5.区域
|
|
|
this->initRegionObjsFromData(pDataManager);
|
|
|
// 6.区域标记
|
|
|
this->initRegionMarkObjsFromData(pDataManager);
|
|
|
refreshEditingLocks();
|
|
|
if (m_pGraphicBinder != nullptr) {
|
|
|
m_pGraphicBinder->syncMapHistoryIds(true);
|
|
|
m_pGraphicBinder->refreshRegionMarkAssignments();
|
|
|
}
|
|
|
if (view != nullptr) view->setMapHistoryOwner(pDataManager);
|
|
|
m_bApplyingAxisRange = bOldApplying;
|
|
|
|
|
|
if(pAxisData != nullptr && !pAxisData->isInitialViewFitted()) {
|
|
|
// 等本轮布局和坐标轴内边距稳定后只初始化一次。
|
|
|
scheduleInitialAxisView();
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void nmGuiPlot::removeWellPlotByData(nmDataWellBase* pData)
|
|
|
{
|
|
|
if(pData != nullptr) {
|
|
|
// 移除井图元
|
|
|
int objCount = m_pPlot->getObjCount();
|
|
|
|
|
|
for(int i = 0; i < objCount; i++) {
|
|
|
ZxObjBase* obj = m_pPlot->getObjByIndex(i);
|
|
|
|
|
|
if(_isSame(obj->getName(), pData->getWellName())) {
|
|
|
// 删除图元
|
|
|
m_pPlot->removeObjByName(obj->getName());
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|