|
|
#include <QPainter>
|
|
|
|
|
|
#include <ZxSerializer.h>
|
|
|
#include "IxPtyPano.h"
|
|
|
|
|
|
#include "ZxSubAxisX.h"
|
|
|
#include "ZxSubAxisY.h"
|
|
|
|
|
|
#include "nmObjPolygonOutlineTool.h"
|
|
|
#include "nmObjPolygonOutline.h"
|
|
|
|
|
|
#include "nmDataLogFile.h"
|
|
|
|
|
|
#include "nmDataAnalyzeManager.h"
|
|
|
|
|
|
ZX_DEFINE_DYNAMIC(nObjPolygonOutline, nmObjPolygonOutline)
|
|
|
|
|
|
nmObjPolygonOutline::nmObjPolygonOutline()
|
|
|
{
|
|
|
m_sObjTag = "nObjPolygonOutline";
|
|
|
nmObjPolygonOutline::init("", NULL, NULL);
|
|
|
}
|
|
|
|
|
|
nmObjPolygonOutline::nmObjPolygonOutline(const QString& sName, \
|
|
|
ZxSubAxisX* pAxisX, \
|
|
|
ZxSubAxisY* pAxisY)
|
|
|
{
|
|
|
m_sObjTag = "nObjPolygonOutline";
|
|
|
nmObjPolygonOutline::init(sName, pAxisX, pAxisY);
|
|
|
}
|
|
|
|
|
|
nmObjPolygonOutline::~nmObjPolygonOutline()
|
|
|
{
|
|
|
// 边界数据由DataManager统一释放,图元只保存引用。
|
|
|
m_outlineData = nullptr;
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::init(const QString& sName, \
|
|
|
ZxSubAxisX* pAxisX, \
|
|
|
ZxSubAxisY* pAxisY)
|
|
|
{
|
|
|
nmObjPolygon::init(sName, pAxisX, pAxisY);
|
|
|
m_outlineData = nullptr;
|
|
|
|
|
|
// 连接图元可见性信号和槽
|
|
|
connect(this, SIGNAL(sigObjVisibleChanged(bool)),
|
|
|
this, SLOT(onObjVisibleChanged(bool)));
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::initTools()
|
|
|
{
|
|
|
m_pTool = new nmObjPolygonOutlineTool();
|
|
|
nmObjBase::initTools();
|
|
|
}
|
|
|
|
|
|
bool nmObjPolygonOutline::hitTest(const QPointF& pt)
|
|
|
{
|
|
|
return nmObjPolygon::hitTest(pt);
|
|
|
}
|
|
|
|
|
|
bool nmObjPolygonOutline::_runHitTest(const QPointF& pt, int& nOption, int& nSubIndex)
|
|
|
{
|
|
|
return nmObjPolygon::_runHitTest(pt, nOption, nSubIndex);
|
|
|
}
|
|
|
|
|
|
bool nmObjPolygonOutline::runMove(const QPointF& pt1,
|
|
|
const QPointF& pt2)
|
|
|
{
|
|
|
return nmObjPolygon::runMove(pt1, pt2);
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::fillPtyPano(IxPtyPano* sheet)
|
|
|
{
|
|
|
nmObjPolygon::fillPtyPano(sheet);
|
|
|
// TODO,设置边界类型的
|
|
|
IxPtyItem* pProp = ZX_PROP("ObjPolygonOutline.Type", getCurOutlineFlowType, setCurOutlineFlowType);
|
|
|
|
|
|
if(NULL != pProp) {
|
|
|
QStringList listTags;
|
|
|
listTags << tr("No Flow") << tr("Constant Pressure");
|
|
|
QList<QVariant> listIndexes;
|
|
|
listIndexes << 0 << 1;
|
|
|
pProp->getPtyPano();
|
|
|
pProp->setOptions(listTags, listIndexes);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::onSerialize(ZxSerializer* ser)
|
|
|
{
|
|
|
nmObjPolygon::onSerialize(ser);
|
|
|
// ser->write("BackgrdColor", m_clrBackgrd);
|
|
|
// TODO,序列化 边界类型数据
|
|
|
ser->write("FlowTypeList", m_vFlowTypeList);
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::onDeserialize(ZxSerializer* ser)
|
|
|
{
|
|
|
nmObjPolygon::onDeserialize(ser);
|
|
|
// ser->read("BackgrdColor", m_clrBackgrd);
|
|
|
// TODO,序列化 边界类型数据
|
|
|
ser->read("FlowTypeList", m_vFlowTypeList);
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::onSaveTempl(ZxSerializer* ser)
|
|
|
{
|
|
|
nmObjPolygon::onSaveTempl(ser);
|
|
|
// ser->write("BackgrdColor", m_clrBackgrd);
|
|
|
ser->write("FlowTypeList", m_vFlowTypeList);
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::setAllPos(QVector<QPointF> vecPoss, QVector<int> *pVecIndexes)
|
|
|
{
|
|
|
nmObjPolygon::setAllPos(vecPoss, pVecIndexes);
|
|
|
|
|
|
// 根据点数确定边数,以此来初始化m_vFlowTypeList
|
|
|
// TODO,会不会覆盖从数据库读取的边界类型值!
|
|
|
for(int i = 0; i < vecPoss.count(); i++) {
|
|
|
if (m_vFlowTypeList.count() > i)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
m_vFlowTypeList.append(NM_OIL_RESERVOIR_OUTLINE_TYPE::OIL_Reservoir_Outline_No_Flow);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::onLoadTempl(ZxSerializer* ser)
|
|
|
{
|
|
|
nmObjPolygon::onLoadTempl(ser);
|
|
|
// ser->read("BackgrdColor", m_clrBackgrd);
|
|
|
ser->read("FlowTypeList", m_vFlowTypeList);
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::paintBack(QPainter* painter, const ZxPaintParam& param)
|
|
|
{
|
|
|
nmObjPolygon::paintBack(painter, param);
|
|
|
QVector<QPointF> pts = getPosOf(m_vecPoints);
|
|
|
|
|
|
if (m_outlineData != nullptr)
|
|
|
{
|
|
|
// 动态更新当前边界数据
|
|
|
m_outlineData->setName(m_sName);
|
|
|
m_outlineData->setOutlinePoints(m_vecPoints);
|
|
|
m_outlineData->setFlowTypeList(m_vFlowTypeList);
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
// 如果是选中的边,则显示绿色
|
|
|
if(m_nHitIndex == i && m_oHitOption == OHO_Bound) {
|
|
|
nmDataLogFile::getInstance()->writeLog("select line " + QString::number(i));
|
|
|
QPen pen;
|
|
|
pen.setWidth(1);
|
|
|
pen.setColor(Qt::green);
|
|
|
painter->setPen(pen);
|
|
|
painter->drawLine(pts[i], pts[i == pts.count() - 1 ? 0 : i + 1]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
painter->restore();
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::setCurOutlineFlowType(int flowType)
|
|
|
{
|
|
|
if(m_oHitOption == OHO_Bound) {
|
|
|
m_vFlowTypeList[m_nHitIndex] = flowType;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
int nmObjPolygonOutline::getCurOutlineFlowType()
|
|
|
{
|
|
|
if(m_oHitOption == OHO_Bound) {
|
|
|
return m_vFlowTypeList[m_nHitIndex];
|
|
|
}
|
|
|
|
|
|
return (int)NM_OIL_RESERVOIR_OUTLINE_TYPE::OIL_Reservoir_Outline_UNKNOW;
|
|
|
}
|
|
|
|
|
|
nmDataOutline* nmObjPolygonOutline::getOutlineData() const {
|
|
|
return m_outlineData;
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::setOutlineData(nmDataOutline* newOutlineData) {
|
|
|
m_outlineData = newOutlineData;
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::afterCreated() {
|
|
|
m_outlineData = nmDataAnalyzeManager::getCurrentInstance()->createOutline();
|
|
|
m_outlineData->setName(m_sName);
|
|
|
m_outlineData->setFlowTypeList(m_vFlowTypeList);
|
|
|
m_outlineData->setOutlinePoints(m_vecPoints);
|
|
|
|
|
|
m_outlineData->setOutlineType(NM_Data_Outline_Type::NM_Polygon_Outline_Type);
|
|
|
nmDataAnalyzeManager::getCurrentInstance()->notifyDataChanged();
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::removeData() {
|
|
|
if (m_outlineData) {
|
|
|
// 从数据中心移除该数据
|
|
|
nmDataAnalyzeManager::getCurrentInstance()->removeOutlineData();
|
|
|
//delete m_outlineData;
|
|
|
m_outlineData = nullptr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmObjPolygonOutline::onObjVisibleChanged(bool bIsVisible) {
|
|
|
if (m_outlineData != nullptr) {
|
|
|
m_outlineData->setPlotVisible(bIsVisible);
|
|
|
}
|
|
|
}
|