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/nmObjLineFault.cpp

193 lines
5.0 KiB
C++

#include <QPainter>
#include <ZxSerializer.h>
#include "IxPtyPano.h"
#include "ZxBaseUtil.h"
#include "ZxSubAxisX.h"
#include "ZxSubAxisY.h"
#include "nmObjLineFaultTool.h"
#include "ZxPlot.h"
#include "ZxObjText.h"
#include "nmObjLineFault.h"
ZX_DEFINE_DYNAMIC(nObjLineFault, nmObjLineFault)
nmObjLineFault::nmObjLineFault()
{
nmObjLineFault("", NULL, NULL);
}
nmObjLineFault::nmObjLineFault(const QString& sName, \
ZxSubAxisX* pAxisX, \
ZxSubAxisY* pAxisY)
: nmObjLine(sName, pAxisX, pAxisY)
{
// 裂缝名称
m_sFaultName = "Fault";
// 裂缝流动类型
m_eFaultFlowModel = NM_OIL_RESERVOIR_FAULT_FLOW_MODEL::OIL_Reservoir_Fault_Flow_Leaky;
// 裂缝渗透率
m_dFaultLeakage = 1.0;
m_sObjTag = "nObjLineFault";
initFlags();
m_oDot = ZxDot(DTS_Circle, QColor(255, 165, 0), 0.5f, true);
m_oPen = QPen(QBrush(QColor(0, 255, 164)), \
0.5f, Qt::SolidLine);
m_vecPoints.clear();
m_vecPoints << QPointF(0.f, 0.f) << QPointF(0.f, 0.f);
loadTempl();
}
nmObjLineFault::~nmObjLineFault()
{
}
void nmObjLineFault::initTools()
{
m_pTool = new nmObjLineFaultTool();
ZxObjBase::initTools();
}
void nmObjLineFault::initSubObjs()
{
nmObjPoint::initSubObjs();
setPointTag(tr("LineFault"));
}
void nmObjLineFault::paintBack(QPainter* painter, const ZxPaintParam& param)
{
Q_ASSERT (m_vecPoints.count() >= 2);
QPointF pt1 = getPosOf(m_vecPoints[0]);
QPointF pt2 = getPosOf(m_vecPoints[1]);
QLineF oLine = QLineF(pt1, pt2);
if (!this->drawLine(painter, oLine)) {
return;
}
drawSelStates(painter, oLine);
QPointF pt = oLine.pointAt(0.5f);
drawWellPos(painter, pt);
}
bool nmObjLineFault::drawSelStates(QPainter* painter,
QLineF& oLine)
{
if (!isSelected()) {
return true;
}
Q_ASSERT (NULL != m_pAxisX);
Q_ASSERT (NULL != m_pAxisY);
if (m_pAxisX->getRangeMin() == m_pAxisX->getRangeMax() || \
m_pAxisY->getRangeMin() == m_pAxisY->getRangeMax()) {
return false;
}
painter->save();
QRectF rt = getOuterRect();
painter->setClipRect(rt);
QPointF pt1 = oLine.p1();
QPointF pt2 = oLine.p2();
QVector<QPointF> pts;
pts << pt1 << pt2;
for (int i = 0; i < pts.count(); i++) {
float w = 1.2f;
QPointF pt = pts[i];
QRectF rect(pt.x() - w * 0.5f, pt.y() - w * 0.5f, w, w);
if (m_nHitIndex == i && m_oHitOption == OHO_Point) {
QBrush br(Qt::red);
painter->fillRect(rect, br);
} else {
painter->setPen(QColor(0, 0, 128));
painter->drawRect(rect);
}
}
painter->restore();
return true;
}
double nmObjLineFault::getFaultLeakage()
{
return m_dFaultLeakage;
}
void nmObjLineFault::setFaultLeakage(double newFaultLeakage)
{
m_dFaultLeakage = newFaultLeakage;
}
int nmObjLineFault::getFaultFlowModel()
{
return m_eFaultFlowModel;
}
void nmObjLineFault::setFaultFlowModel(int newFaultFlowModel)
{
m_eFaultFlowModel = (NM_OIL_RESERVOIR_FAULT_FLOW_MODEL)newFaultFlowModel;
}
QString nmObjLineFault::getFaultName()
{
return m_sFaultName;
}
void nmObjLineFault::setFaultName( QString newFaultName)
{
m_sFaultName = newFaultName;
}
void nmObjLineFault::onSerialize(ZxSerializer* ser)
{
nmObjLine::onSerialize(ser);
ser->write("Name", m_sFaultName);
int flowModel = (int)m_eFaultFlowModel;
ser->write("FlowModel", flowModel);
ser->write("Leakage", m_dFaultLeakage);
}
void nmObjLineFault::onDeserialize(ZxSerializer* ser)
{
nmObjLine::onDeserialize(ser);
ser->read("Name", m_sFaultName);
int flowModel = 0;
ser->read("FlowModel", flowModel);
m_eFaultFlowModel = (NM_OIL_RESERVOIR_FAULT_FLOW_MODEL)flowModel;
ser->read("Leakage", m_dFaultLeakage);
}
void nmObjLineFault::onSaveTempl(ZxSerializer* ser)
{
nmObjLine::onSaveTempl(ser);
ser->write("Name", m_sFaultName);
int flowModel = (int)m_eFaultFlowModel;
ser->write("FlowModel", flowModel);
ser->write("Leakage", m_dFaultLeakage);
}
void nmObjLineFault::onLoadTempl(ZxSerializer* ser)
{
nmObjLine::onLoadTempl(ser);
ser->read("Name", m_sFaultName);
int flowModel = 0;
ser->read("FlowModel", flowModel);
m_eFaultFlowModel = (NM_OIL_RESERVOIR_FAULT_FLOW_MODEL)flowModel;
ser->read("Leakage", m_dFaultLeakage);
}
void nmObjLineFault::fillPtyPano(IxPtyPano* sheet)
{
nmObjLine::fillPtyPano(sheet);
ZX_PROP("ObjLineFault.Name", getFaultName, setFaultName);
IxPtyItem* pProp = ZX_PROP("ObjLineFault.FlowModel", getFaultFlowModel, setFaultFlowModel);
if (NULL != pProp) {
QStringList listTags;
listTags << tr("Leaky") << tr("Composite Limit") << tr("Unknow");
QList<QVariant> listIndexes;
listIndexes << 0 << 1 << 2;
pProp->getPtyPano();
pProp->setOptions(listTags, listIndexes);
}
ZX_PROP("ObjLineFault.Leakage", getFaultLeakage, setFaultLeakage);
}