优化路径剖面,支持从"岩性符号库.lib"加载图形符号

This commit is contained in:
jiayulong 2025-12-17 17:01:05 +08:00
parent 157008bfc0
commit 6d1f4bd4db
8 changed files with 1611 additions and 21 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
#ifndef GEOINDICATORGENERATOR_H
#define GEOINDICATORGENERATOR_H
#include <qgraphicsscene.h>
#include <QXmlStreamReader>
#include <QPainter>
class GeoIndicatorGenerator
{
public:
explicit GeoIndicatorGenerator();
~GeoIndicatorGenerator();
/*Give scene items
attr:
Geo name
scene
*/
/*
*QPainter
qrectf
*/
float seleGeo(QString, QString, QPainter*, QRectF rect, bool, bool, bool, float, QColor);
private:
bool initGeoInf(QString, int);
float * getWH(QXmlStreamReader*);
void calcLNum(float*, QRectF, int* p, bool);
bool FindGeoName(QString, QXmlStreamReader*);
std::map<QString, int> libMap; //符号库映射
std::map<QString, int> nameMap; //符号名称映射
std::map<QString, int> lineType; //分隔线映射
std::map<QString, int> SymbolType; //纵向拉伸映射
std::map<QString, int> reverseType; //反向绘制映射
std::map<QString, int> fillType; //填充绘制映射
std::map<QString, int> ifGeoHeight; //是否使用标准符号高度
void PolylinePainter( QXmlStreamReader*, QPainter*, int*, float*, bool, bool, bool);
void LinePainter( QXmlStreamReader*, QPainter*, int*, float*, bool, bool, bool);
void CirclePainter( QXmlStreamReader*, QPainter*, int*, float*, bool, bool, bool);
void TextPainter( QXmlStreamReader*, QPainter*, int*, float*, bool, bool, bool);
void ArcPainter( QXmlStreamReader*, QPainter*, int*, float*, bool, bool, bool);
void PolygonPainter( QXmlStreamReader*, QPainter*, int*, float*, bool, bool, bool);
private:
QString lines[3]; //xml文本信息
QString tempLine; //缓存近期xml信息
QRectF m_Rect;
float mm; //毫米对应像素量
QStringList libStr;
float h_strechRate; //纵向拉伸比例
//QXmlStreamReader *reader;
};
#endif

View File

@ -7,9 +7,13 @@
#include <QMenu>
#include "geometryutils.h"
#include <QSvgRenderer>
#include "GeoIndicatorGenerator.h"
#pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8
extern double g_dPixelPerCm;//每厘米像素数
//static GeoIndicatorGenerator m_drawGeo;
class TransparentDraggableGeoLith : public QObject
{
Q_OBJECT
@ -93,21 +97,51 @@ public:
//设置解释结论
void setLith(QString filePath, QString colorPath){
m_Lith = filePath;
}
void drawLith(double left_Low, double right_Hight, double lY1, double lY2)
{
if(m_Lith=="")
{
return;
}
double x1 = mPlot->xAxis->coordToPixel(left_Low);
double x2 = mPlot->xAxis->coordToPixel(right_Hight);
double y1 = mPlot->yAxis->coordToPixel(lY1+(lY2-lY1)/4);
double y2 = mPlot->yAxis->coordToPixel(lY2);
double newWidth = y2-y1;
double newHeight = x1-x2;
//
QString filePath = m_Lith;
QString strLast = filePath.right(4);
if(strLast.toLower()==".svg")
{
QString path,filename;
GetWellNameAndPath(filePath, filename, path);
QString basename = filename.left(filename.size()-4);
QString basename = filename;
QString val=filePath;
QImage image(320,160,QImage::Format_RGB32);
QImage image(newWidth, newHeight, QImage::Format_RGB32);
QPainter painter(&image);
QRectF fillRect(0,0,320,160);
QRectF fillRect(0,0,newWidth, newHeight);
painter.fillRect(fillRect,Qt::white);
//
painter.setBrush(QBrush(QPixmap(colorPath)));
//painter.setBrush(QBrush(QPixmap(colorPath)));
// bool isStrech=false;
// QSvgRenderer m_SvgRenderer;
// m_SvgRenderer.load(filePath);
// if(!isStrech){
// float oil_h = fillRect.width();
// oil_h = (oil_h / 2 >= fillRect.height() / 2) ? fillRect.height() : oil_h;
// float rect_y = fillRect.y() + fillRect.height() / 2 - oil_h / 2;
// fillRect.setY(rect_y);
// fillRect.setHeight(oil_h);
// }
// fillRect.setX(fillRect.x() + 1);
// m_SvgRenderer.render(&painter, fillRect);
//拉伸
DrawSVGSteched(&painter,filePath,fillRect,0);
@ -153,11 +187,46 @@ public:
// pixmap->fill(Qt::transparent);//设置背景透明
// mPixmap_Lith->setPixmap(*pixmap); // 设置图片
mPixmap_Lith->setPixmap(QPixmap(filePath)); // 设置图片
//mPixmap_Lith->setPixmap(QPixmap(filePath)); // 设置图片
QString path,filename;
GetWellNameAndPath(filePath, filename, path);
QString basename = filename;
QString val=filePath;
QImage image(newWidth, newHeight, QImage::Format_RGB32);
QPainter painter(&image);
QRectF fillRect(0,0,newWidth, newHeight);
painter.fillRect(fillRect,Qt::white);
//
bool isOne=true;
bool isStech=true;
bool isHorizon=false;
float cm = g_dPixelPerCm;//一厘米对应的像素个数
QColor bkColor = QColor(255,255,255,255);
float GeoResult = m_drawGeo.seleGeo("岩性符号库", basename, &painter, fillRect, isOne, isStech, isHorizon, cm, bkColor);
val=GetImagePath()+"TempNew";
QDir ss;
if(!ss.exists(val)) {
ss.mkdir(val);
}
val+=QDir::separator();
val+=basename+".png";
image.save(val);
//
mPixmap_Lith->setPixmap(QPixmap(val)); // 设置图片
}
mPixmap_Lith->topLeft->setCoords(mPlot->xAxis->pixelToCoord(x2+1), mPlot->yAxis->pixelToCoord(y1+1));//right_Hight
mPixmap_Lith->bottomRight->setCoords(mPlot->xAxis->pixelToCoord(x1-1), mPlot->yAxis->pixelToCoord(y2-1));//left_Low
mPlot->replot();
// mPixmap_Lith->topLeft->setCoords(right_Hight, lY1+(lY2-lY1)/4);
// mPixmap_Lith->bottomRight->setCoords(left_Low, lY2);
//mPlot->replot();
}
//设置m_Oil
@ -175,7 +244,7 @@ public:
double x1 = mPlot->xAxis->coordToPixel(left_Low);
double x2 = mPlot->xAxis->coordToPixel(right_Hight);
double y1 = mPlot->yAxis->coordToPixel(lY1);
double y2 = mPlot->yAxis->coordToPixel(lY2);
double y2 = mPlot->yAxis->coordToPixel(lY1+(lY2-lY1)/4);
bool bWidthBig = false;
double newWidth = y2-y1;
@ -188,10 +257,10 @@ public:
}
float rect_xRight = x2 + newHeight/ 2 - newWidth/ 2;
double xNewRight = mPlot->xAxis->pixelToCoord(rect_xRight);
double xNewRight = mPlot->xAxis->pixelToCoord(rect_xRight+1);
//
float rect_xLeft = rect_xRight + newWidth;
double xNewLeft = mPlot->xAxis->pixelToCoord(rect_xLeft);
double xNewLeft = mPlot->xAxis->pixelToCoord(rect_xLeft-1);
//
QString filePath = m_Oil;
@ -201,7 +270,7 @@ public:
{
QString path,filename;
GetWellNameAndPath(filePath, filename, path);
QString basename = filename.left(filename.size()-4);
QString basename = filename;
QString val=filePath;
QImage image(newWidth, newWidth,QImage::Format_RGB32);
@ -233,9 +302,9 @@ public:
}
mPixmap_Oil->topLeft->setCoords(xNewRight, mPlot->yAxis->pixelToCoord(y1+1)); //right_Hight, lY1
mPixmap_Oil->bottomRight->setCoords(xNewLeft, lY2); //left_Low
mPixmap_Oil->bottomRight->setCoords(xNewLeft, mPlot->yAxis->pixelToCoord(y2-1)); //left_Low
mPlot->replot();
//mPlot->replot();
}
//设置Color
@ -247,7 +316,7 @@ public:
{
QString path,filename;
GetWellNameAndPath(filePath, filename, path);
QString basename = filename.left(filename.size()-4);
QString basename = filename;
QString val=filePath;
QImage image(320,160,QImage::Format_RGB32);
@ -287,6 +356,7 @@ public:
double lY1 = mPlot->yAxis->range().lower;//+10
double lY2 = mPlot->yAxis->range().upper;
mRect->topLeft->setCoords(left_Low, lY1);
mRect->bottomRight->setCoords(right_Hight, lY2);
@ -294,13 +364,14 @@ public:
mPixmap_Color->topLeft->setCoords(right_Hight, lY1+(lY2-lY1)/4);
mPixmap_Color->bottomRight->setCoords(left_Low, lY2);
//
mPixmap_Lith->topLeft->setCoords(right_Hight, lY1+(lY2-lY1)/4);
mPixmap_Lith->bottomRight->setCoords(left_Low, lY2);
//mPixmap_Lith->topLeft->setCoords(right_Hight, lY1+(lY2-lY1)/4);
//mPixmap_Lith->bottomRight->setCoords(left_Low, lY2);
drawLith(left_Low, right_Hight, lY1, lY2);
//位置与rect不一样否则图像反转
//mPixmap_Oil->topLeft->setCoords(right_Hight, lY1);
//mPixmap_Oil->bottomRight->setCoords(left_Low, lY1+(lY2-lY1)/4);
drawOil(left_Low, right_Hight, lY1, lY1+(lY2-lY1)/4);
drawOil(left_Low, right_Hight, lY1, lY2);
//mItemTitle->position->setCoords(0.5, 0.5);
// 设置父锚点,定位点
@ -719,6 +790,8 @@ private:
QString m_Oil;
QString m_Color;
GeoIndicatorGenerator m_drawGeo;
enum DragMode { DragNone, DragLeft, DragRight, DragRect };
DragMode mDragMode = DragNone;
//double mDragStartX = 0;

View File

@ -123,7 +123,7 @@ public:
{
QString path,filename;
GetWellNameAndPath(filePath, filename, path);
QString basename = filename.left(filename.size()-4);
QString basename = filename;
QString val=filePath;
QImage image(y2-y1, x1-x2,QImage::Format_RGB32);

View File

@ -215,7 +215,7 @@ void FormInfo::paintEvent(QPaintEvent* event)
painter.drawText(rect.left(), rect.top()+rect.height()/3, rect.width(), rect.height()/3, Qt::AlignCenter, m_strUnit);
}
if(m_strType=="tableObject" && (m_strLineName=="WORDS_RELUST" || m_strLineName == "RESULT"))
if(m_strType=="tableObject" && (m_strLineName=="WORDS_RELUST" || m_strLineName == "RESULT" || m_strLineName == "GEO_LITH"))
{
//文字结论,不绘制左右范围
}

View File

@ -193,7 +193,7 @@ void FormTrack::s_addWave(QString strSlfName, QString strWellName, QString strTr
void FormTrack::s_AddTableLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType)
{
if(strLineName == "FRAC_HOLE.TABLE" || strLineName == "WORDS_RELUST" || strLineName == "RESULT")
if(strLineName == "FRAC_HOLE.TABLE" || strLineName == "WORDS_RELUST" || strLineName == "RESULT" || strLineName == "GEO_LITH")
{
}

View File

@ -30,6 +30,7 @@ SOURCES += \
../CallManage/CallManage.cpp \
../common/geometryutils.cpp \
ConsoleOutputWidget.cpp \
GeoIndicatorGenerator.cpp \
InDefTableDlg.cpp \
InterfaceWidget.cpp \
PropertyWidget.cpp \
@ -65,6 +66,7 @@ HEADERS += \
../common/geometryutils.h \
ConsoleOutputWidget.h \
DraggablePixmap.h \
GeoIndicatorGenerator.h \
InDefTableDlg.h \
InterfaceWidget.h \
PropertyWidget.h \

View File

@ -303,6 +303,7 @@ void QMyCustomPlot::addGeoLithToPlot(double left_Low, double right_Hight, const
TransparentDraggableGeoLith *dragRect = new TransparentDraggableGeoLith(this, strUuid);
//图片提前设值后面setRange改变
dragRect->setOil(myOil);
dragRect->setLith(myLith, myColor);
// 设置初始范围
dragRect->setRange(left_Low, right_Hight);
@ -311,9 +312,11 @@ void QMyCustomPlot::addGeoLithToPlot(double left_Low, double right_Hight, const
//最小宽度
dragRect->setMinWidth(0.1);
//dragRect->setColor(myColor);
dragRect->setLith(myLith,myColor);
m_mapDraggable_GeoLith[strUuid] = dragRect;
//刷新
this->replot();
}
void QMyCustomPlot::onResetZoom()