You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
4.8 KiB
C++
121 lines
4.8 KiB
C++
#include "nmSubWxsPlotDialogController.h"
|
|
|
|
#include "nmDeleteConfirmationDlg.h"
|
|
#include "nmPlotDialogContext.h"
|
|
#include "nmSwitchOutlineConfirmationDlg.h"
|
|
#include "nmWxMeasureDlg.h"
|
|
#include "nmWxMeasuringScaleDlg.h"
|
|
#include "nmWxPointerPosDlg.h"
|
|
#include "nmWxWellEditor.h"
|
|
|
|
#include <QCoreApplication>
|
|
#include <QMessageBox>
|
|
|
|
namespace
|
|
{
|
|
// nmSubWxs模块加载时注册绘图弹窗上下文提供者
|
|
struct nmSubWxsPlotDialogControllerRegister
|
|
{
|
|
nmSubWxsPlotDialogControllerRegister()
|
|
{
|
|
nmPlotDialogContext::setProvider(nmSubWxsPlotDialogController::instance());
|
|
}
|
|
};
|
|
|
|
nmSubWxsPlotDialogControllerRegister s_register;
|
|
}
|
|
|
|
// 获取绘图弹窗上下文控制器单例
|
|
nmSubWxsPlotDialogController* nmSubWxsPlotDialogController::instance()
|
|
{
|
|
static nmSubWxsPlotDialogController s_controller;
|
|
return &s_controller;
|
|
}
|
|
|
|
// 打开测量比例尺弹窗
|
|
bool nmSubWxsPlotDialogController::execMeasuringScaleDialog(const QPointF& pStart, const QPointF& pEnd, double* pLength)
|
|
{
|
|
nmWxMeasuringScaleDlg dlg(pStart, pEnd, pLength);
|
|
return dlg.exec() == QDialog::Accepted;
|
|
}
|
|
|
|
// 创建测量工具弹窗
|
|
QWidget* nmSubWxsPlotDialogController::createMeasureDialog(QWidget* pParent)
|
|
{
|
|
return new nmWxMeasureDlg(pParent);
|
|
}
|
|
|
|
// 创建坐标显示弹窗
|
|
QWidget* nmSubWxsPlotDialogController::createPointerPosDialog(QWidget* pParent)
|
|
{
|
|
return new nmWxPointerPosDlg(pParent);
|
|
}
|
|
|
|
QString nmSubWxsPlotDialogController::objectTypeText(const QString& sObjectTag)
|
|
{
|
|
// 类型标识只在界面适配层解释,绘图层不依赖具体对话框或已翻译的文本。
|
|
const char* const arrTypeTexts[][2] = {
|
|
{ "nObjPointWell", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Well") },
|
|
{ "nObjLineFault", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Fault") },
|
|
{ "nObjLineFracture", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Fracture") },
|
|
{ "nObjRectOutline", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Rectangular boundary") },
|
|
{ "nObjPolygonOutline", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Polygonal boundary") },
|
|
{ "nObjRoundOutline", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Circular boundary") },
|
|
{ "nObjLineMeasure", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Measurement line") },
|
|
{ "nObjLineMeasuringScale", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Measuring scale") },
|
|
{ "nObjRegion", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Composite region") },
|
|
{ "nObjRegionMark", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Region marker") },
|
|
{ "nObjPoint", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Point") },
|
|
{ "nObjLine", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Line") },
|
|
{ "nObjPolygon", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Polygon") },
|
|
{ "nObjRect", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Rectangle") },
|
|
{ "nObjRound", QT_TRANSLATE_NOOP("nmSubWxsPlotDialogController", "Circle") }
|
|
};
|
|
const int nTypeCount = sizeof(arrTypeTexts) / sizeof(arrTypeTexts[0]);
|
|
for(int nType = 0; nType < nTypeCount; ++nType) {
|
|
if(sObjectTag.compare(QLatin1String(arrTypeTexts[nType][0]), Qt::CaseInsensitive) == 0) {
|
|
return QCoreApplication::translate("nmSubWxsPlotDialogController", arrTypeTexts[nType][1]);
|
|
}
|
|
}
|
|
return QCoreApplication::translate("nmSubWxsPlotDialogController", "Object");
|
|
}
|
|
|
|
bool nmSubWxsPlotDialogController::confirmDeleteObject(
|
|
QWidget* pParent, const QString& sObjectName, const QString& sObjectTag)
|
|
{
|
|
nmDeleteConfirmationDlg oDialog(sObjectName, objectTypeText(sObjectTag), pParent);
|
|
return oDialog.exec() == QDialog::Accepted;
|
|
}
|
|
|
|
bool nmSubWxsPlotDialogController::confirmSwitchOutline(
|
|
QWidget* pParent, const QString& sCurrentTag, const QString& sTargetTag)
|
|
{
|
|
nmSwitchOutlineConfirmationDlg oDialog(
|
|
objectTypeText(sCurrentTag), objectTypeText(sTargetTag), pParent);
|
|
return oDialog.exec() == QDialog::Accepted;
|
|
}
|
|
|
|
bool nmSubWxsPlotDialogController::editWell(QWidget* pParent,
|
|
const nmWellEditContext& oContext,
|
|
nmDataWellBase*& pModifiedWell)
|
|
{
|
|
pModifiedWell = nullptr;
|
|
|
|
// 第一步:编辑器初始化失败属于配置或数据错误,由界面层统一提示。
|
|
nmWxWellEditor oEditor(oContext, pParent);
|
|
QString sError;
|
|
if (!oEditor.initialize(sError))
|
|
{
|
|
QMessageBox::warning(pParent, oEditor.windowTitle(), sError);
|
|
return false;
|
|
}
|
|
// 第二步:只有确认关闭才转移工作副本,取消时由会话自动销毁。
|
|
if (oEditor.exec() != QDialog::Accepted)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
pModifiedWell = oEditor.takeModifiedWell();
|
|
return pModifiedWell != nullptr;
|
|
}
|