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

279 lines
8.1 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();
}
bool nmObjPointWell::runMove(const QPointF &pt1, const QPointF &pt2)
{
nmObjPoint::runMove(pt1, pt2);
// 更新井的位置信息
if (m_pWellData) {
m_pWellData->setLocationX(pt2.x());
m_pWellData->setLocationY(pt2.y());
}
return true;
}
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);
if (m_pWellData) {
// 设置图元的位置信息将井的坐标设置为plot对象的坐标
m_vecPoints.clear();
m_vecPoints << QPointF(m_pWellData->getLocationX(), m_pWellData->getLocationY());
return;
}
// TODO如果井数据不存在则其实就是新建井了
}
void nmObjPointWell::onSaveTempl(ZxSerializer* ser)
{
nmObjBase::onSaveTempl(ser);
ser->write("NMWellID", 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);
if (m_pWellData) {
// 设置图元的位置信息将井的坐标设置为plot对象的坐标
m_vecPoints.clear();
m_vecPoints << QPointF(m_pWellData->getLocationX(), m_pWellData->getLocationY());
return;
}
// TODO如果井数据不存在则其实就是新建井了
}
void nmObjPointWell::afterCreated()
{
// 如果是选择的井则不弹出创建的dialog
if (m_bSelectWell) {
return;
}
this->createWell();
}
void nmObjPointWell::setWellData(ZxDataWell *wellObj)
{
if (wellObj) {
m_bSelectWell = true;
m_pWellData = wellObj;
m_sWellID = m_pWellData->getCode();
}
}
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如果是 选择的井,则直接删除画布上的图元
// TODO如果是 新建的井,删除图元 + 井数据!
nmSingalCenter::getInstance()->emitSigDeleteWell(sCode);
} else {
// 将数据做转换,然后移动到指定的位置
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(this->getPosOf(this->getAllPos()));
}
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) {
// 根据新坐标进行移动
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(this->getPosOf(this->getAllPos()));
}
delete pWellDialog;
}
QVector<double> nmObjPointWell::getWellInformation()
{
QVector<double> wellInformation;
if (m_pWellData) {
wellInformation.append(m_pWellData->getLocationX());
wellInformation.append(m_pWellData->getLocationY());
wellInformation.append(m_pWellData->getWellRadius());
}
return wellInformation;
}
ZxDataWell *nmObjPointWell::getWellData() const
{
return m_pWellData;
}
const QString &nmObjPointWell::getWellID() const
{
return m_sWellID;
}