|
|
#include <QPainter>
|
|
|
|
|
|
#include <ZxSerializer.h>
|
|
|
#include "IxPtyPano.h"
|
|
|
|
|
|
#include "ZxSubAxisX.h"
|
|
|
#include "ZxSubAxisY.h"
|
|
|
|
|
|
#include "nmObjRectOutlineTool.h"
|
|
|
#include "nmObjRectOutline.h"
|
|
|
|
|
|
#include "nmPlotGraphicBinder.h"
|
|
|
|
|
|
ZX_DEFINE_DYNAMIC(nObjRectOutline, nmObjRectOutline)
|
|
|
|
|
|
nmObjRectOutline::nmObjRectOutline()
|
|
|
: m_eChangeOutlineType(RBP_Unknown)
|
|
|
, m_pGraphicBinder(nullptr)
|
|
|
{
|
|
|
m_sObjTag = "nObjRectOutline";
|
|
|
nmObjRectOutline::init("", NULL, NULL);
|
|
|
}
|
|
|
|
|
|
nmObjRectOutline::nmObjRectOutline(const QString& sName, \
|
|
|
ZxSubAxisX* pAxisX, \
|
|
|
ZxSubAxisY* pAxisY)
|
|
|
: m_eChangeOutlineType(RBP_Unknown)
|
|
|
, m_pGraphicBinder(nullptr)
|
|
|
{
|
|
|
m_sObjTag = "nObjRectOutline";
|
|
|
nmObjRectOutline::init(sName, pAxisX, pAxisY);
|
|
|
}
|
|
|
|
|
|
nmObjRectOutline::~nmObjRectOutline()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::init(const QString& sName, \
|
|
|
ZxSubAxisX* pAxisX, \
|
|
|
ZxSubAxisY* pAxisY)
|
|
|
{
|
|
|
nmObjRect::init(sName, pAxisX, pAxisY);
|
|
|
m_pGraphicBinder = nullptr;
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::initTools()
|
|
|
{
|
|
|
m_pTool = new nmObjRectOutlineTool();
|
|
|
nmObjBase::initTools();
|
|
|
}
|
|
|
|
|
|
bool nmObjRectOutline::hitTest(const QPointF& pt)
|
|
|
{
|
|
|
return nmObjRect::hitTest(pt);
|
|
|
}
|
|
|
|
|
|
bool nmObjRectOutline::_runHitTest(const QPointF& pt, int& nOption, int& nSubIndex)
|
|
|
{
|
|
|
return nmObjRect::_runHitTest(pt, nOption, nSubIndex);
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::fillPtyPano(IxPtyPano* sheet)
|
|
|
{
|
|
|
nmObjRect::fillPtyPano(sheet);
|
|
|
// 设置边界类型,依次为上边界、右边界、下边界、左边界
|
|
|
IxPtyItem* pPropTop = ZX_PROP("ObjRectOutline.TopOutline", getTopOutlineFlowType, setTopOutlineFlowType);
|
|
|
IxPtyItem* pPropRight = ZX_PROP("ObjRectOutline.RightOutline", getRightOutlineFlowType, setRightOutlineFlowType);
|
|
|
IxPtyItem* pPropBottom = ZX_PROP("ObjRectOutline.BottomOutline", getBottomOutlineFlowType, setBottomOutlineFlowType);
|
|
|
IxPtyItem* pPropLeft = ZX_PROP("ObjRectOutline.LeftOutline", getLeftOutlineFlowType, setLeftOutlineFlowType);
|
|
|
|
|
|
if(NULL != pPropTop) {
|
|
|
QStringList listTags;
|
|
|
listTags << tr("No Flow") << tr("Constant Pressure");
|
|
|
QList<QVariant> listIndexes;
|
|
|
listIndexes << 0 << 1;
|
|
|
pPropTop->getPtyPano();
|
|
|
pPropTop->setOptions(listTags, listIndexes);
|
|
|
}
|
|
|
|
|
|
if(NULL != pPropRight) {
|
|
|
QStringList listTags;
|
|
|
listTags << tr("No Flow") << tr("Constant Pressure");
|
|
|
QList<QVariant> listIndexes;
|
|
|
listIndexes << 0 << 1;
|
|
|
pPropRight->getPtyPano();
|
|
|
pPropRight->setOptions(listTags, listIndexes);
|
|
|
}
|
|
|
|
|
|
if(NULL != pPropBottom) {
|
|
|
QStringList listTags;
|
|
|
listTags << tr("No Flow") << tr("Constant Pressure");
|
|
|
QList<QVariant> listIndexes;
|
|
|
listIndexes << 0 << 1;
|
|
|
pPropBottom->getPtyPano();
|
|
|
pPropBottom->setOptions(listTags, listIndexes);
|
|
|
}
|
|
|
|
|
|
if(NULL != pPropLeft) {
|
|
|
QStringList listTags;
|
|
|
listTags << tr("No Flow") << tr("Constant Pressure");
|
|
|
QList<QVariant> listIndexes;
|
|
|
listIndexes << 0 << 1;
|
|
|
pPropLeft->getPtyPano();
|
|
|
pPropLeft->setOptions(listTags, listIndexes);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::onSerialize(ZxSerializer* ser)
|
|
|
{
|
|
|
nmObjRect::onSerialize(ser);
|
|
|
ser->write("FlowTypeList", m_vFlowTypeList);
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::onDeserialize(ZxSerializer* ser)
|
|
|
{
|
|
|
nmObjRect::onDeserialize(ser);
|
|
|
ser->read("FlowTypeList", m_vFlowTypeList);
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::onLoadTempl(ZxSerializer* ser)
|
|
|
{
|
|
|
nmObjRect::onLoadTempl(ser);
|
|
|
ser->read("FlowTypeList", m_vFlowTypeList);
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::onSaveTempl(ZxSerializer* ser)
|
|
|
{
|
|
|
nmObjRect::onSaveTempl(ser);
|
|
|
ser->write("FlowTypeList", m_vFlowTypeList);
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::setAllPos(QVector<QPointF> vecPoss, QVector<int> *pVecIndexes)
|
|
|
{
|
|
|
nmObjRect::setAllPos(vecPoss, pVecIndexes);
|
|
|
|
|
|
// 根据点数确定边数,以此来初始化m_vFlowTypeList
|
|
|
// 仅在列表不足时补充默认值,不阻止信号发射
|
|
|
const int pointCount = m_vecPoints.count(); // 局部坐标更新也按实际总点数处理。
|
|
|
while(m_vFlowTypeList.count() < pointCount) {
|
|
|
m_vFlowTypeList.append(NM_OIL_RESERVOIR_OUTLINE_TYPE::OIL_Reservoir_Outline_No_Flow);
|
|
|
}
|
|
|
|
|
|
emit sigOutlinePointsChanged();
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::paintBack(QPainter* painter, const ZxPaintParam& param)
|
|
|
{
|
|
|
// 点序仅在创建时规范化;重绘不能改动节点下标或边的业务对应关系。
|
|
|
// 边界超出视图时,将填充、轮廓和节点框限制在坐标轴内。
|
|
|
painter->save();
|
|
|
painter->setClipRect(getOuterRect(), Qt::IntersectClip);
|
|
|
nmObjRect::paintBack(painter, param);
|
|
|
painter->restore();
|
|
|
if (m_pGraphicBinder) {
|
|
|
m_pGraphicBinder->syncOutlineName(this);
|
|
|
m_pGraphicBinder->syncOutlineVisual(this);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::reorderPoints(QVector<QPointF>& points)
|
|
|
{
|
|
|
if(points.size() != 4) {
|
|
|
// 如果点的数量不是4个,直接返回
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 找到所有点的最小和最大坐标
|
|
|
double minX = points[0].x();
|
|
|
double maxX = points[0].x();
|
|
|
double minY = points[0].y();
|
|
|
double maxY = points[0].y();
|
|
|
|
|
|
for(int i = 1; i < 4; ++i) {
|
|
|
if(points[i].x() < minX) minX = points[i].x();
|
|
|
|
|
|
if(points[i].x() > maxX) maxX = points[i].x();
|
|
|
|
|
|
if(points[i].y() < minY) minY = points[i].y();
|
|
|
|
|
|
if(points[i].y() > maxY) maxY = points[i].y();
|
|
|
}
|
|
|
|
|
|
// 初始化四个角的点
|
|
|
QPointF leftTop, rightTop, rightBottom, leftBottom;
|
|
|
|
|
|
// 遍历点,确定每个点的位置
|
|
|
for(int i = 0; i < 4; ++i) {
|
|
|
const QPointF& pt = points[i];
|
|
|
|
|
|
if(pt.x() == minX && pt.y() == maxY) {
|
|
|
leftTop = pt; // 左上角
|
|
|
} else if(pt.x() == maxX && pt.y() == maxY) {
|
|
|
rightTop = pt; // 右上角
|
|
|
} else if(pt.x() == maxX && pt.y() == minY) {
|
|
|
rightBottom = pt; // 右下角
|
|
|
} else if(pt.x() == minX && pt.y() == minY) {
|
|
|
leftBottom = pt; // 左下角
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 按照左上角、右上角、右下角、左下角的顺序重新排列
|
|
|
points.clear();
|
|
|
points.push_back(leftTop);
|
|
|
points.push_back(rightTop);
|
|
|
points.push_back(rightBottom);
|
|
|
points.push_back(leftBottom);
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::setSideFlowType(int side, int type)
|
|
|
{
|
|
|
while (m_vFlowTypeList.size() < 4) {
|
|
|
m_vFlowTypeList.append(OIL_Reservoir_Outline_No_Flow);
|
|
|
}
|
|
|
if (m_vFlowTypeList.at(side) == type) return;
|
|
|
m_vFlowTypeList[side] = type;
|
|
|
emit sigOutlineFlowTypeChanged();
|
|
|
}
|
|
|
|
|
|
// 上边界流动类型
|
|
|
void nmObjRectOutline::setTopOutlineFlowType(int newValue)
|
|
|
{
|
|
|
setSideFlowType(0, newValue);
|
|
|
}
|
|
|
|
|
|
int nmObjRectOutline::getTopOutlineFlowType()
|
|
|
{
|
|
|
return m_vFlowTypeList.value(0, OIL_Reservoir_Outline_No_Flow);
|
|
|
}
|
|
|
|
|
|
// 右边界流动类型
|
|
|
void nmObjRectOutline::setRightOutlineFlowType(int newValue)
|
|
|
{
|
|
|
setSideFlowType(1, newValue);
|
|
|
}
|
|
|
|
|
|
int nmObjRectOutline::getRightOutlineFlowType()
|
|
|
{
|
|
|
return m_vFlowTypeList.value(1, OIL_Reservoir_Outline_No_Flow);
|
|
|
}
|
|
|
|
|
|
// 下边界流动类型
|
|
|
void nmObjRectOutline::setBottomOutlineFlowType(int newValue)
|
|
|
{
|
|
|
setSideFlowType(2, newValue);
|
|
|
}
|
|
|
|
|
|
int nmObjRectOutline::getBottomOutlineFlowType()
|
|
|
{
|
|
|
return m_vFlowTypeList.value(2, OIL_Reservoir_Outline_No_Flow);
|
|
|
}
|
|
|
|
|
|
// 左边界流动类型
|
|
|
void nmObjRectOutline::setLeftOutlineFlowType(int newValue)
|
|
|
{
|
|
|
setSideFlowType(3, newValue);
|
|
|
}
|
|
|
|
|
|
int nmObjRectOutline::getLeftOutlineFlowType()
|
|
|
{
|
|
|
return m_vFlowTypeList.value(3, OIL_Reservoir_Outline_No_Flow);
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::afterCreated()
|
|
|
{
|
|
|
// 矩形边界需要先对点排序,再交给 Binder 创建数据
|
|
|
reorderPoints(m_vecPoints);
|
|
|
if (m_pGraphicBinder) {
|
|
|
m_pGraphicBinder->createOutlineForGraphic(this);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmObjRectOutline::removeData()
|
|
|
{
|
|
|
if (m_pGraphicBinder) {
|
|
|
m_pGraphicBinder->removeOutlineBinding(this);
|
|
|
}
|
|
|
}
|