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.
nmWATI/Src/nmNum/nmPlot/nmObjPointWell.cpp

228 lines
6.3 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <QPainter>
//#include <QDialog.h>
#include <ZxSerializer.h>
#include "IxPtyPano.h"
#include "ZxSubAxisX.h"
#include "ZxSubAxisY.h"
#include "ZxPlot.h"
#include "ZxObjText.h"
#include "nmObjPointWellTool.h"
#include "nmObjPointWell.h"
#include "nmDataLogFile.h"
#include "iWxWellNew.h"
#include "ZxBaseUtil.h"
#include "ZxDataProject.h"
#include "TreeWxMain.h"
#include "Defines.h"
#include "zxSysUtils.h"
#include "iDataTypes.h"
#include "nmSingalCenter.h"
ZX_DEFINE_DYNAMIC(nObjPointWell, nmObjPointWell)
nmObjPointWell::nmObjPointWell()
{
m_bSelectWell = false;
init("", NULL, NULL);
}
nmObjPointWell::nmObjPointWell(const QString& sName, \
ZxSubAxisX* pAxisX, \
ZxSubAxisY* pAxisY)
: nmObjPoint(sName, pAxisX, pAxisY)
{
m_bSelectWell = false;
init(sName, pAxisX, pAxisY);
}
//nmObjPointWell::nmObjPointWell(const QString& sName, \
// ZxSubAxisX* pAxisX, \
// ZxSubAxisY* pAxisY, \
// bool selectWell)
// : nmObjPoint(sName, pAxisX, pAxisY)
//{
// m_bSelectWell = selectWell;
// init(sName, pAxisX, pAxisY);
//}
nmObjPointWell::~nmObjPointWell()
{
}
void nmObjPointWell::init(const QString& sName, \
ZxSubAxisX* pAxisX, \
ZxSubAxisY* pAxisY)
{
m_sObjTag = "nObjPointWell";
nmObjBase::init(sName, pAxisX, pAxisY);
initFlags();
m_oDot = ZxDot(DTS_DownTriangle, QColor(255, 0, 0, 125), 1.f, true);
m_sDesc = "";
m_bShowSubObjs = true;
m_oDot = ZxDot(DTS_Circle, QColor(0, 255, 0), 1.5f, true);
m_clrFillUnvalid = QColor(0, 255, 255);
m_clrOuter = QColor(255, 0, 0);
m_vecPoints << QPointF(0.f, 0.f);
loadTempl();
}
void nmObjPointWell::initTools()
{
m_pTool = new nmObjPointWellTool();
nmObjBase::initTools();
}
void nmObjPointWell::initFlags()
{
// TODO如果是选择的井则位置和大小都不能动设置为true
setLockPos(false);
setLockSize(false);
setReadOnly(false);
}
void nmObjPointWell::initSubObjs()
{
// nmObjPoint::initSubObjs();
ZxPlot* pPlot = dynamic_cast<ZxPlot*>(this->getParent());
if (NULL != pPlot) {
QString sName = "";
ZxObjBase* p = pPlot->addOneObj(POT_Text, sName, false, \
m_pAxisX, m_pAxisY);
appendSubObjs(p);
ZxObjText* pBoundText = dynamic_cast<ZxObjText*>(p);
Q_ASSERT (NULL != pBoundText);
pBoundText->setFrameVisible(false);
QColor clr = QColor(255, 255, 255, 64);
pBoundText->setBackgroundColor(clr);
pBoundText->setReadOnly(true);
int n = Qt::AlignHCenter | Qt::AlignVCenter;
pBoundText->setAlignFlag(n);
pBoundText->setFont(QFont("Times", 8));
pBoundText->deselect(true);
pBoundText->deselectOthers();
pBoundText->setText(tr("PointWell"));
}
}
void nmObjPointWell::setPointTag(QString s)
{
nmObjPoint::setPointTag(s);
}
void nmObjPointWell::update()
{
nmObjBase::update();
}
void nmObjPointWell::onSerialize(ZxSerializer* ser)
{
nmObjBase::onSerialize(ser);
ser->write("NMWellID", m_sWellID);
}
void nmObjPointWell::onDeserialize(ZxSerializer* ser)
{
nmObjBase::onDeserialize(ser);
ser->read("NMWellID", m_sWellID);
// 根据wellID获取井的信息
m_pWellData = (ZxDataWell*)zxCurProject->getChild(iDataModelType::sTypeWell, m_sWellID);
// 设置图元的位置信息将井的坐标设置为plot对象的坐标
m_vecPoints.clear();
m_vecPoints << QPointF(m_pWellData->getLocationX(), m_pWellData->getLocationY());
}
void nmObjPointWell::onSaveTempl(ZxSerializer* ser)
{
nmObjBase::onSaveTempl(ser);
ser->write("NMWellID", m_sWellID);
}
void nmObjPointWell::afterCreated()
{
this->createWell();
}
void nmObjPointWell::createWell()
{
// 弹出井属性的设置dialog
iWxWellNew* pWellDialog = new iWxWellNew();
ZxDataWell* pWellData = new ZxDataWell();
// 设置图元的坐标
pWellData->setLocationX(m_vecPoints[0].x());
pWellData->setLocationY(m_vecPoints[0].y());
// 生成code
QString sCode = pWellData->getDefaultCode(zxCurProject);
pWellData->setCode(sCode);
// 添加到整体结构树上
zxCurProject->appendChild(pWellData);
Q_ASSERT (NULL != pWellDialog);
// dialog框展示井数据并支持编辑
pWellDialog->setDataWell(dynamic_cast<ZxDataWell*>(pWellData));
pWellDialog->setActionMode(iWxWellNew::AM_Edit);
// 初始化UI
pWellDialog->initUI();
// 图元保存井数据
m_sWellID = pWellData->getCode();
m_pWellData = pWellData;
// 模态展示
if (pWellDialog->exec() == QDialog::Rejected) {
// TODO将该井从画布上抹掉
nmSingalCenter::getInstance()->emitSigDeleteWell(sCode);
}
delete pWellDialog;
}
void nmObjPointWell::editWell()
{
ZxDataWell* pWellData = m_pWellData;
// 弹出井属性的设置dialog
iWxWellNew* pWellDialog = new iWxWellNew();
Q_ASSERT (NULL != pWellDialog);
// dialog框展示井数据并支持编辑
pWellDialog->setDataWell(dynamic_cast<ZxDataWell*>(pWellData));
pWellDialog->setActionMode(iWxWellNew::AM_Edit);
// 初始化UI
pWellDialog->initUI();
// 模态展示
if (pWellDialog->exec() == QDialog::Accepted) {
m_sWellID = pWellData->getCode();
}
delete pWellDialog;
// TODO根据新坐标进行移动
QVector<QPointF> vecPoss;
vecPoss << QPointF(m_pWellData->getLocationX(), m_pWellData->getLocationY());
nmDataLogFile::getInstance()->writeLog(" =========== " + QString::number(vecPoss[0].x()) + " " + QString::number(vecPoss[0].y()) );
this->setAllPos(vecPoss);
moveToPos(vecPoss);
}
ZxDataWell *nmObjPointWell::getWellData() const
{
return m_pWellData;
}
const QString &nmObjPointWell::getWellID() const
{
return m_sWellID;
}
void nmObjPointWell::onLoadTempl(ZxSerializer* ser)
{
nmObjBase::onLoadTempl(ser);
ser->read("NMWellID", m_sWellID);
// 根据wellID获取井的信息
m_pWellData = (ZxDataWell*)zxCurProject->getChild(iDataModelType::sTypeWell, m_sWellID);
// 设置图元的位置信息将井的坐标设置为plot对象的坐标
m_vecPoints.clear();
m_vecPoints << QPointF(m_pWellData->getLocationX(), m_pWellData->getLocationY());
}