|
|
|
|
|
#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
|
|
|
|
|
|
// 仅在列表不足时补充默认值,不阻止信号发射
|
|
|
|
|
|
while(m_vFlowTypeList.count() < vecPoss.count()) {
|
|
|
|
|
|
m_vFlowTypeList.append(NM_OIL_RESERVOIR_OUTLINE_TYPE::OIL_Reservoir_Outline_No_Flow);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
emit sigOutlinePointsChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmObjRectOutline::paintBack(QPainter* painter, const ZxPaintParam& param)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// 更新m_vecPoints点的顺序
|
|
|
|
|
|
this->reorderPoints(m_vecPoints);
|
|
|
|
|
|
nmObjRect::paintBack(painter, param);
|
|
|
|
|
|
QVector<QPointF> pts = getPosOf(m_vecPoints);
|
|
|
|
|
|
|
|
|
|
|
|
// 名称同步:setName 不发信号,在绘制时通过 Binder 同步到数据中心
|
|
|
|
|
|
if (m_pGraphicBinder) {
|
|
|
|
|
|
m_pGraphicBinder->syncOutlineName(this);
|
|
|
|
|
|
m_pGraphicBinder->syncOutlineVisual(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(isSelected()) { // 选中状态下
|
|
|
|
|
|
QPen pen(QBrush(Qt::black), 0.0f, Qt::DotLine);
|
|
|
|
|
|
painter->setPen(pen);
|
|
|
|
|
|
painter->drawPolygon(&pts[0], pts.count());
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < pts.count(); i++) {
|
|
|
|
|
|
float w = 2.2f;
|
|
|
|
|
|
QPointF pt = pts[i];
|
|
|
|
|
|
QRectF rect(pt.x() - w * 0.5f, pt.y() - w * 0.5f, w, w);
|
|
|
|
|
|
// 渲染节点
|
|
|
|
|
|
painter->setPen(QColor(0, 0, 128));
|
|
|
|
|
|
painter->drawRect(rect);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
painter->restore();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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::setTopOutlineFlowType(int newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_vFlowTypeList[0] = newValue;
|
|
|
|
|
|
emit sigOutlineFlowTypeChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int nmObjRectOutline::getTopOutlineFlowType()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_vFlowTypeList[0];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 右边界流动类型
|
|
|
|
|
|
void nmObjRectOutline::setRightOutlineFlowType(int newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_vFlowTypeList[1] = newValue;
|
|
|
|
|
|
emit sigOutlineFlowTypeChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int nmObjRectOutline::getRightOutlineFlowType()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_vFlowTypeList[1];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 下边界流动类型
|
|
|
|
|
|
void nmObjRectOutline::setBottomOutlineFlowType(int newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_vFlowTypeList[2] = newValue;
|
|
|
|
|
|
emit sigOutlineFlowTypeChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int nmObjRectOutline::getBottomOutlineFlowType()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_vFlowTypeList[2];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 左边界流动类型
|
|
|
|
|
|
void nmObjRectOutline::setLeftOutlineFlowType(int newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_vFlowTypeList[3] = newValue;
|
|
|
|
|
|
emit sigOutlineFlowTypeChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int nmObjRectOutline::getLeftOutlineFlowType()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_vFlowTypeList[3];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmObjRectOutline::afterCreated()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 矩形边界需要先对点排序,再交给 Binder 创建数据
|
|
|
|
|
|
reorderPoints(m_vecPoints);
|
|
|
|
|
|
if (m_pGraphicBinder) {
|
|
|
|
|
|
m_pGraphicBinder->createOutlineForGraphic(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmObjRectOutline::removeData()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pGraphicBinder) {
|
|
|
|
|
|
m_pGraphicBinder->removeOutlineBinding(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|