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

211 lines
5.6 KiB
C++

#include <QPainter>
#include <ZxSerializer.h>
#include "IxPtyPano.h"
#include "ZxBaseUtil.h"
#include "ZxSubAxisX.h"
#include "ZxSubAxisY.h"
#include "nmObjLineCrackTool.h"
#include "ZxPlot.h"
#include "ZxObjText.h"
#include "nmObjLineCrack.h"
ZX_DEFINE_DYNAMIC(nObjLineCrack, nmObjLineCrack)
nmObjLineCrack::nmObjLineCrack()
{
nmObjLineCrack("", NULL, NULL);
}
nmObjLineCrack::nmObjLineCrack(const QString& sName, \
ZxSubAxisX* pAxisX, \
ZxSubAxisY* pAxisY)
: nmObjLine(sName, pAxisX, pAxisY)
{
// 裂缝名称
m_sCrackName = "crack";
// 裂缝流动类型
m_eCrackFlowModel = NM_OIL_RESERVOIR_CRACK_FLOW_MODEL::OIL_Reservoir_Crack_Flow_Infinite_Conductivity;
// 裂缝宽度
m_dCrackThickness = 1.0;
// 裂缝传导率
m_dCrackConductivity = 5000.0;
m_sObjTag = "nObjLineCrack";
initFlags();
m_oDot = ZxDot(DTS_Circle, QColor(0, 255, 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();
}
nmObjLineCrack::~nmObjLineCrack()
{
}
void nmObjLineCrack::initTools()
{
m_pTool = new nmObjLineCrackTool();
ZxObjBase::initTools();
}
void nmObjLineCrack::initSubObjs()
{
nmObjPoint::initSubObjs();
setPointTag(tr("LineCrack"));
}
void nmObjLineCrack::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 nmObjLineCrack::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;
}
QString nmObjLineCrack::getCrackName()
{
return m_sCrackName;
}
void nmObjLineCrack::setCrackName( QString newSCrackName)
{
m_sCrackName = newSCrackName;
}
int nmObjLineCrack::getCrackFlowModel()
{
return m_eCrackFlowModel;
}
void nmObjLineCrack::setCrackFlowModel(int newCrackFlowModel)
{
m_eCrackFlowModel = (NM_OIL_RESERVOIR_CRACK_FLOW_MODEL)newCrackFlowModel;
}
double nmObjLineCrack::getCrackThickness()
{
return m_dCrackThickness;
}
void nmObjLineCrack::setCrackThickness(double newCrackThickness)
{
m_dCrackThickness = newCrackThickness;
}
double nmObjLineCrack::getCrackConductivity()
{
return m_dCrackConductivity;
}
void nmObjLineCrack::setCrackConductivity(double newCrackConductivity)
{
m_dCrackConductivity = newCrackConductivity;
}
void nmObjLineCrack::onSerialize(ZxSerializer* ser)
{
nmObjLine::onSerialize(ser);
ser->write("Name", m_sCrackName);
int flowModel = (int)m_eCrackFlowModel;
ser->write("FlowModel", flowModel);
ser->write("Thickness", m_dCrackThickness);
ser->write("Conductivity", m_dCrackConductivity);
}
void nmObjLineCrack::onDeserialize(ZxSerializer* ser)
{
nmObjLine::onDeserialize(ser);
ser->read("Name", m_sCrackName);
int flowModel = 0;
ser->read("FlowModel", flowModel);
m_eCrackFlowModel = (NM_OIL_RESERVOIR_CRACK_FLOW_MODEL)flowModel;
ser->read("Thickness", m_dCrackThickness);
ser->read("Conductivity", m_dCrackConductivity);
}
void nmObjLineCrack::onSaveTempl(ZxSerializer* ser)
{
nmObjLine::onSaveTempl(ser);
ser->write("Name", m_sCrackName);
int flowModel = (int)m_eCrackFlowModel;
ser->write("FlowModel", flowModel);
ser->write("Thickness", m_dCrackThickness);
ser->write("Conductivity", m_dCrackConductivity);
}
void nmObjLineCrack::onLoadTempl(ZxSerializer* ser)
{
nmObjLine::onLoadTempl(ser);
ser->read("Name", m_sCrackName);
int flowModel = 0;
ser->read("FlowModel", flowModel);
m_eCrackFlowModel = (NM_OIL_RESERVOIR_CRACK_FLOW_MODEL)flowModel;
ser->read("Thickness", m_dCrackThickness);
ser->read("Conductivity", m_dCrackConductivity);
}
void nmObjLineCrack::fillPtyPano(IxPtyPano* sheet)
{
nmObjLine::fillPtyPano(sheet);
ZX_PROP("ObjLineCrack.Name", getCrackName, setCrackName);
IxPtyItem* pProp = ZX_PROP("ObjLineCrack.FlowModel", getCrackFlowModel, setCrackFlowModel);
if (NULL != pProp) {
QStringList listTags;
listTags << tr("Infinite Conductivity") << tr("Finite Conductivity") << tr("Unknow");
QList<QVariant> listIndexes;
listIndexes << 0 << 1 << 2;
pProp->getPtyPano();
pProp->setOptions(listTags, listIndexes);
}
ZX_PROP("ObjLineCrack.Thickness", getCrackThickness, setCrackThickness);
ZX_PROP("ObjLineCrack.Conductivity", getCrackConductivity, setCrackConductivity);
}