玫瑰图属性

This commit is contained in:
crqiqi77 2026-04-09 16:17:38 +08:00
parent 84c52e0ae7
commit 458e342d93
2 changed files with 352 additions and 50 deletions

View File

@ -10035,8 +10035,7 @@ void QMyCustomPlot::s_changePlObjectProperty(QVariantMap variantMap)
void QMyCustomPlot::drawFgrq (bool bTableData, QString csCurveDDIR, QString csCurveDANG,
QString csCurveGrad, double LeftVal3, double RightVal3,
int nArc,
QString csCurveGrad, double LeftVal3, double RightVal3, int nArc,
double nR, QColor crArc, int nArcLineWidth, bool bFill, QColor crFill,
int lineNumber, double lineHeight, int lineThickness, QColor lineColor, bool drawAnnotation, bool drawHistogram,
int baselineWidth, QColor baselineColor, int nstep, double LeftVal, double RightVal)
@ -10064,14 +10063,11 @@ void QMyCustomPlot::drawFgrq (bool bTableData, QString csCurveDDIR, QString csCu
return;
}
}
// double nR = 50;
QPen wPen(crArc, nArcLineWidth);
double centerX = this->m_iX2/2;
float flVal = 0.0f;
float x,y,x1,y1,x2,y2;
float ifdir[360];
float mind=min(RightVal , LeftVal);
float maxd=max(RightVal , LeftVal);
float dirmax,dipmax,dr;
@ -10079,21 +10075,17 @@ void QMyCustomPlot::drawFgrq (bool bTableData, QString csCurveDDIR, QString csCu
float ftmpSdep = m_SDep;
float ftmpEdep = m_EDep;
if (m_bTableData)
{
// ReadFracDef();
for (int i = 0 ; i < iFracType ; i++)
{
m_bTypeDraw[i] = true;
}
ftmpSdep = -m_iY2;
ftmpEdep = -m_iY1;
}
int nPointNum = m_FracTabList.count();
int n = m_FracDefList.count();
int tmp = ftmpSdep / nstep;
@ -10225,7 +10217,7 @@ void QMyCustomPlot::drawFgrq (bool bTableData, QString csCurveDDIR, QString csCu
}
}
int iIndex;
int iIndex;
flVal = 3.1415926535 *2./ nArc ;
dirmax=0; dipmax=0;
for(i=0;i<=nArc;i++)
@ -10235,7 +10227,6 @@ void QMyCustomPlot::drawFgrq (bool bTableData, QString csCurveDDIR, QString csCu
dirmax=ifdir[i];
}
if (dirmax == 0 )
dirmax=1;
for(i=0;i<=nArc;i++)
@ -10243,10 +10234,8 @@ void QMyCustomPlot::drawFgrq (bool bTableData, QString csCurveDDIR, QString csCu
// ifdir[i]=ifdir[i]*(nRadius-GetLineWidth(pDC,m_nArcLineWidth/2.))/dirmax;//-m_nArcLineWidth/2.whp add 2016.10.21 for线粗时扇叶超界
ifdir[nArc+1]=ifdir[1];
//方位频率
float x0,y0;
x = centerY;
y = centerX;
for(int i=0;i<=nArc;i++)
@ -10276,24 +10265,16 @@ void QMyCustomPlot::drawFgrq (bool bTableData, QString csCurveDDIR, QString csCu
myPolygon << QPointF(0, 0);
pol->setPoints(myPolygon);
}
// QCPItemRect* prt = new QCPItemRect(this);
// prt->topLeft->setCoords(x, y);
// prt->bottomRight->setCoords(x, y);
}
//float ifdir[360], int iIndex, float dirmax
if(drawAnnotation)
{
this->drawDipAngle(centerX, centerY, ifdir, dirmax, lineNumber, lineHeight, lineThickness, lineColor,
drawHistogram, baselineWidth, baselineColor, LeftVal, RightVal);
}
flDep += nstep;
}
this->replot();
}
@ -10550,7 +10531,7 @@ void QMyCustomPlot::s_changeRoseProperty(QVariantMap variantMap)
bool bTableData = false;
if(dataType == 1)
{
dataType = true;
bTableData = true;
}
QString azimuthCurve = variantMap["m_pl_azimuthCurve"].toString();
QString inclinationCurve = variantMap["m_pl_inclinationCurve"].toString();
@ -10585,14 +10566,20 @@ void QMyCustomPlot::s_changeRoseProperty(QVariantMap variantMap)
// int nstep, double LeftVal, double RightVal
this->drawRose(bTableData, azimuthCurve, inclinationCurve,
m_rose_depth_field, m_rose_azimuth_field, m_rose_dip_field, m_rose_attribute_field,
csCurveGrad, LeftVal3, RightVal3, m_pl_fontScale,
m_rose_sector_enabled, m_rose_circle_radius_cm, m_rose_radiation_circle_enabled, m_rose_azimuth_print_interval, m_rose_circle_line_color,
m_rose_circle_line_width, m_rose_stress_line_color, m_rose_collapse_line_color, m_rose_draw_radiation_line, m_rose_draw_wellbore_collapse,
m_rose_fill_enabled, m_rose_draw_annotation,
m_pl_statInterval, m_pl_minInclination, m_pl_maxInclination);
this->drawRose(bTableData, azimuthCurve, inclinationCurve,
m_rose_depth_field, m_rose_azimuth_field, m_rose_dip_field, m_rose_attribute_field,
csCurveGrad, LeftVal3, RightVal3, m_pl_fontScale,
m_rose_sector_enabled, m_rose_circle_radius_cm, m_rose_radiation_circle_enabled, m_rose_azimuth_print_interval, m_rose_circle_line_color,
m_rose_circle_line_width, m_rose_stress_line_color, m_rose_collapse_line_color, m_rose_draw_radiation_line, m_rose_draw_wellbore_collapse,
m_rose_fill_enabled, m_rose_draw_annotation,
m_pl_statInterval, m_pl_minInclination, m_pl_maxInclination);
}
void QMyCustomPlot::drawRose(bool bTableData, QString csCurveDDIR, QString csCurveDANG,
QString qsDepth, QString qsDIR, QString qsDIP, QString qsID,
QString csCurveGrad, double m_LeftVal3, double m_RightVal3, QFont m_pl_fontScale,
@ -10612,16 +10599,10 @@ void QMyCustomPlot::drawRose(bool bTableData, QString csCurveDDIR, QString csCur
m_csCurveDDIR = csCurveDDIR; // 方位曲线
m_csCurveDANG = csCurveDANG; //倾角曲线
m_csCurveGrad = csCurveGrad;
// m_qsDepth="DEPT"; // 深度字段
// m_qsDIR="DDIR"; // 方位字段
// m_qsDIP="DANG";// 倾角字段
// m_qsID = "ID";
m_qsDepth= qsDepth; // 深度字段
m_qsDIR= qsDIR; // 方位字段
m_qsDIP= qsDIP;// 倾角字段
m_qsID = qsID;
m_qsTable="FRAC_HOLE.TABLE";
flag = Refurbish();
@ -10635,12 +10616,6 @@ void QMyCustomPlot::drawRose(bool bTableData, QString csCurveDDIR, QString csCur
float flVal = 0.0f;
float x,y,x1,y1,x2,y2;
float ifdir[360];
// int nstep = 5;
// float m_LeftVal3 = 0;
// float m_RightVal3 = 100.0;
float mind=min(m_RightVal , m_LeftVal);
float maxd=max(m_RightVal , m_LeftVal);
float dirmax,dipmax,dr;
@ -10658,6 +10633,9 @@ void QMyCustomPlot::drawRose(bool bTableData, QString csCurveDDIR, QString csCur
ftmpSdep = -m_iY2;
ftmpEdep = -m_iY1;
m_rose_fill_enabled = false;
m_bJykt = false;
}
int nPointNum = m_FracTabList.count();
@ -10666,13 +10644,6 @@ void QMyCustomPlot::drawRose(bool bTableData, QString csCurveDDIR, QString csCur
float flDep = tmp * nstep;
double pi = 3.1415926535;
// 射线
// bool m_bGrid = true;
// 井眼垮塌
// bool m_bJykt = true;
// 标注
// bool m_bHint = true;
m_Curve.DepLevel = 0.5;
while ( 1)
{
@ -10927,8 +10898,6 @@ void QMyCustomPlot::drawRose(bool bTableData, QString csCurveDDIR, QString csCur
pol->setBrushColor(QColor(m_rose_stress_line_color));
}
if ( m_bJykt && iIndex >=0 )
{
// 绘制垮塌方向
@ -10959,9 +10928,314 @@ void QMyCustomPlot::drawRose(bool bTableData, QString csCurveDDIR, QString csCur
this->addQCPItemLine(this, centerY,centerX, QPointF(x1, y1), QPointF(x3, y3), collapsePen);
this->addQCPItemLine(this, centerY,centerX, QPointF(x3, y3), QPointF(x2, y2), collapsePen);
}
flDep += nstep;
}
this->replot();
}
void QMyCustomPlot::drawTabRose(
bool bTableData,
QString csCurveDDIR,
QString csCurveDANG,
QString qsDepth,
QString qsDIR,
QString qsDIP,
QString qsID,
QString csCurveGrad,
double m_LeftVal3,
double m_RightVal3,
QFont m_pl_fontScale,
int m_nArc,
int nR,
int m_nCircle,
int m_nAzimStep,
QColor m_rose_circle_line_color,
int m_rose_circle_line_width,
QColor m_rose_stress_line_color,
QColor m_rose_collapse_line_color,
bool m_bGrid,
bool m_bJykt,
bool m_rose_fill_enabled,
bool m_bHint,
int nstep,
float m_LeftVal,
float m_RightVal
)
{
bool flag = true;
this->clearGraphs();
this->clearItems();
m_bTableData = bTableData;
m_csCurveDDIR = csCurveDDIR;
m_csCurveDANG = csCurveDANG;
m_csCurveGrad = csCurveGrad;
m_qsDepth = qsDepth;
m_qsDIR = qsDIR;
m_qsDIP = qsDIP;
m_qsID = qsID;
m_qsTable = "FRAC_HOLE.TABLE";
flag = Refurbish();
if (!flag) return;
// 必须读取裂缝表 + 裂缝定义
ReadFracDef();
int nPointNum = m_FracTabList.count();
int nFracType = m_FracDefList.count();
if (nPointNum < 1) return;
// 初始化裂缝类型默认全部绘制
for (int i = 0; i < nFracType; i++) {
m_bTypeDraw[i] = true;
}
QPen wPen(m_rose_circle_line_color, m_rose_circle_line_width);
double centerX = this->m_iX2 / 2;
float flVal = 0.0f;
float x, y, x1, y1, x2, y2;
float ifdir[360] = {0};
float mind = qMin(m_RightVal, m_LeftVal);
float maxd = qMax(m_RightVal, m_LeftVal);
float dirmax, dr;
float deps;
// 深度范围(表格数据使用屏幕坐标)
float ftmpSdep = -m_iY2;
float ftmpEdep = -m_iY1;
int tmp = ftmpSdep / nstep;
float flDep = tmp * nstep;
double pi = 3.1415926535;
while (1) {
if ((flDep >= ftmpEdep + nstep) || flDep >= ftmpEdep) break;
double tempf = flDep + nstep / 2.0;
double centerY = tempf * -1.0;
// ====================== 1. 画最外层圆 ======================
QCPItemEllipse* pEse = new QCPItemEllipse(this);
wPen.setWidth(m_rose_circle_line_width);
pEse->setPen(wPen);
pEse->m_bCustom = true;
pEse->m_nRadius = nR;
pEse->topLeft->setCoords(centerY, centerX);
pEse->bottomRight->setCoords(centerY, centerX);
// ====================== 2. 画十字线 ======================
for (int k = 0; k < 4; k++) {
QCPItemLine* pLine1 = new QCPItemLine(this);
pLine1->m_bCustom = true;
pLine1->m_dr = qDegreesToRadians(k * 90.0);
pLine1->m_nRadius = 0;
pLine1->m_nTailLen = nR;
pLine1->setPen(wPen);
pLine1->start->setCoords(centerY, centerX);
pLine1->end->setCoords(centerY, centerX);
}
// ====================== 3. 方位标注 ======================
if (m_bHint) {
int psize = 15;
flVal = m_nAzimStep * 360.0 / m_nArc;
for (int i = 0; i < 360; i += (int)flVal) {
QCPItemText* mItemTitle = new QCPItemText(this);
mItemTitle->position->setCoords(centerY, centerX);
mItemTitle->setText(QString::number(i));
mItemTitle->setFont(m_pl_fontScale);
mItemTitle->setColor(m_rose_circle_line_color);
dr = i * 2 * pi / 360.0;
mItemTitle->m_fx = (nR + psize * 0.85) * sin(dr);
mItemTitle->m_fy = (nR + psize * 0.85) * cos(dr);
mItemTitle->m_bCustom = true;
}
}
// ====================== 4. 辐射线 ======================
if (m_bGrid) {
wPen.setWidth(1);
double st = 360.0 / m_nArc;
for (int i = 0; i < m_nArc; i++) {
int ntmp = i % 9;
if (ntmp != 0) {
QCPItemLine* pLine = new QCPItemLine(this);
pLine->m_bCustom = true;
pLine->m_dr = qDegreesToRadians(i * st);
pLine->m_nRadius = 0;
pLine->m_nTailLen = nR;
pLine->setPen(wPen);
pLine->start->setCoords(centerY, centerX);
pLine->end->setCoords(centerY, centerX);
}
}
}
// ====================== 5. 辐射圈(同心圆) ======================
if (m_bGrid) {
qreal currentRadius = 0;
for (int i = 0; i < m_nCircle; i++) {
QCPItemEllipse* pEseInner = new QCPItemEllipse(this);
pEseInner->setPen(wPen);
pEseInner->m_bCustom = true;
currentRadius -= nR * 1.0 / m_nCircle;
pEseInner->m_nRadius = currentRadius;
pEseInner->topLeft->setCoords(centerY, centerX);
pEseInner->bottomRight->setCoords(centerY, centerX);
}
}
// ====================== 6. 表格数据统计方位 ======================
memset(ifdir, 0, sizeof(ifdir));
float x1Step = 360.0 / m_nArc;
// 遍历所有裂缝点
for (int i = 0; i < nPointNum; i++) {
FRAC_TABLE frac = m_FracTabList.at(i);
bool bDraw = false;
// 匹配裂缝类型
for (int j = 0; j < nFracType; j++) {
FRAC_DEF fd = m_FracDefList.at(j);
if ((int)frac.ID == fd.iCode) {
bDraw = m_bTypeDraw[j];
break;
}
}
if (!bDraw) continue;
deps = frac.DEP;
// 判断是否在当前统计深度段内
if (deps >= flDep && deps < flDep + nstep) {
float dipVal = frac.DIPorS;
if (dipVal > maxd || dipVal < mind) continue;
float dirVal = frac.DIR;
int j = dirVal / x1Step;
if (j >= 0 && j < m_nArc + 1) {
ifdir[j]++;
}
}
}
// ====================== 7. 找最大值 ======================
dirmax = 0;
int iIndex = -1;
for (int i = 0; i <= m_nArc; i++) {
if (dirmax < ifdir[i]) {
iIndex = i;
dirmax = ifdir[i];
}
}
if (dirmax == 0) dirmax = 1;
// ====================== 8. 绘制玫瑰瓣 ======================
flVal = 2 * pi / m_nArc;
QPolygonF myPolygon;
float oldx = 9999, oldy = 9999;
for (int i = 0; i <= m_nArc; i++) {
dr = i * flVal;
float px = ifdir[i] * nR * sin(dr) / dirmax;
float py = ifdir[i] * nR * cos(dr) / dirmax;
if (oldx != px || oldy != py) {
myPolygon << QPointF(px, py);
oldx = px; oldy = py;
}
dr = (i + 1) * flVal;
px = ifdir[i] * nR * sin(dr) / dirmax;
py = ifdir[i] * nR * cos(dr) / dirmax;
if (oldx != px || oldy != py) {
myPolygon << QPointF(px, py);
oldx = px; oldy = py;
}
}
// 绘制第一个玫瑰瓣
if (iIndex >= 0) {
QCPItemPolygon* pol = new QCPItemPolygon(this);
pol->topLeft->setCoords(centerY, centerX);
pol->bottomRight->setCoords(centerY, centerX);
pol->setPoints(myPolygon);
if (m_rose_fill_enabled)
m_rose_stress_line_color.setAlpha(255);
else
m_rose_stress_line_color.setAlpha(0);
pol->setBrushColor(m_rose_stress_line_color);
}
// ====================== 9. 绘制反向玫瑰瓣 ======================
myPolygon.clear();
float tempfArc = m_nArc / 2.0;
for (int i = 0; i <= m_nArc; i++) {
dr = i * flVal - tempfArc * flVal;
float px = ifdir[i] * nR * sin(dr) / dirmax;
float py = ifdir[i] * nR * cos(dr) / dirmax;
if (oldx != px || oldy != py) {
myPolygon << QPointF(px, py);
oldx = px; oldy = py;
}
dr = (i + 1) * flVal - tempfArc * flVal;
px = ifdir[i] * nR * sin(dr) / dirmax;
py = ifdir[i] * nR * cos(dr) / dirmax;
if (oldx != px || oldy != py) {
myPolygon << QPointF(px, py);
oldx = px; oldy = py;
}
}
if (iIndex >= 0) {
QCPItemPolygon* pol2 = new QCPItemPolygon(this);
pol2->topLeft->setCoords(centerY, centerX);
pol2->bottomRight->setCoords(centerY, centerX);
pol2->setPoints(myPolygon);
pol2->setBrushColor(m_rose_stress_line_color);
}
// ====================== 10. 绘制垮塌方向线 ======================
if (m_bJykt && iIndex >= 0) {
QPen collapsePen(m_rose_collapse_line_color, 2);
dr = iIndex * flVal - pi / 2;
x1 = ifdir[iIndex] * nR * sin(dr) / dirmax;
y1 = ifdir[iIndex] * nR * cos(dr) / dirmax;
dr = iIndex * flVal + pi / 2;
x2 = ifdir[iIndex] * nR * sin(dr) / dirmax;
y2 = ifdir[iIndex] * nR * cos(dr) / dirmax;
this->addQCPItemLine(this, centerY, centerX, QPointF(x1, y1), QPointF(x2, y2), collapsePen);
// 小箭头
dr = iIndex * flVal;
float x3 = 0.1 * ifdir[iIndex] * nR * sin(dr) / dirmax;
float y3 = 0.1 * ifdir[iIndex] * nR * cos(dr) / dirmax;
this->addQCPItemLine(this, centerY, centerX, QPointF(x1, y1), QPointF(x3, y3), collapsePen);
this->addQCPItemLine(this, centerY, centerX, QPointF(x3, y3), QPointF(x2, y2), collapsePen);
dr = iIndex * flVal - pi;
x3 = 0.1 * ifdir[iIndex] * nR * sin(dr) / dirmax;
y3 = 0.1 * ifdir[iIndex] * nR * cos(dr) / dirmax;
this->addQCPItemLine(this, centerY, centerX, QPointF(x1, y1), QPointF(x3, y3), collapsePen);
this->addQCPItemLine(this, centerY, centerX, QPointF(x3, y3), QPointF(x2, y2), collapsePen);
}
flDep += nstep;
}
this->replot();
}

View File

@ -663,6 +663,34 @@ public:
int m_nArc, int m_rose_circle_radius_cm, int m_rose_radiation_circle_enabled, int m_rose_azimuth_print_interval, QColor m_rose_circle_line_color,
int m_rose_circle_line_width, QColor m_rose_stress_line_color, QColor m_rose_collapse_line_color, bool m_rose_draw_radiation_line, bool m_rose_draw_wellbore_collapse,
bool m_rose_fill_enabled, bool m_rose_draw_annotation, int nstep, float m_LeftVal, float m_RightVal);
void drawTabRose(
bool bTableData,
QString csCurveDDIR,
QString csCurveDANG,
QString qsDepth,
QString qsDIR,
QString qsDIP,
QString qsID,
QString csCurveGrad,
double m_LeftVal3,
double m_RightVal3,
QFont m_pl_fontScale,
int m_nArc,
int nR,
int m_nCircle,
int m_nAzimStep,
QColor m_rose_circle_line_color,
int m_rose_circle_line_width,
QColor m_rose_stress_line_color,
QColor m_rose_collapse_line_color,
bool m_bGrid,
bool m_bJykt,
bool m_rose_fill_enabled,
bool m_bHint,
int nstep,
float m_LeftVal,
float m_RightVal
);
void addQCPItemLine(QMyCustomPlot *widget, float cx, float cy, const QPointF& p1, const QPointF& p2, const QPen& wPen);
private: