完善 频率统计图,表格,曲线绘制
This commit is contained in:
parent
a4a1ac579a
commit
8470531a3a
|
|
@ -31412,6 +31412,69 @@ QPen QCPItemBracket::mainPen() const
|
|||
/* end of 'src/items/item-bracket.cpp' */
|
||||
|
||||
|
||||
QCPItemPolygon::QCPItemPolygon(QCustomPlot *parentPlot) :
|
||||
QCPAbstractItem(parentPlot),
|
||||
topLeft(createPosition("topLeft")),
|
||||
topRight(createPosition("topRight")),
|
||||
bottomLeft(createPosition("bottomLeft")),
|
||||
bottomRight(createPosition("bottomRight"))
|
||||
{
|
||||
topLeft->setCoords(0, 1);
|
||||
topRight->setCoords(1, 1);
|
||||
bottomLeft->setCoords(0, 0);
|
||||
bottomRight->setCoords(1, 0);
|
||||
|
||||
// 此处填写真实的坐标!
|
||||
// vertices << QPointF(-71.8, 5.2) << QPointF(-68.2, -5.2) << QPointF(6.7, 4.9) << QPointF(3.1, 15.3);
|
||||
}
|
||||
|
||||
void QCPItemPolygon::draw(QCPPainter *painter)
|
||||
{
|
||||
if (ni < 0)
|
||||
return;
|
||||
|
||||
QPointF center(topLeft->pixelPosition());
|
||||
|
||||
float x = center.x();
|
||||
float y = center.y();
|
||||
|
||||
float dr=ni*flVal;
|
||||
float x1 = x + ifdir*sin(dr);
|
||||
float y1 = y - ifdir*cos(dr);
|
||||
dr=(ni+1)*flVal;
|
||||
float x2 = x + ifdir*sin(dr);
|
||||
float y2 = y - ifdir*cos(dr);
|
||||
|
||||
QPolygonF myPolygon;
|
||||
myPolygon << QPointF(x, y);
|
||||
myPolygon << QPointF(x1, y1);
|
||||
myPolygon << QPointF(x2, y2);
|
||||
myPolygon << QPointF(x, y);
|
||||
|
||||
painter->setPen(Qt::black); // Set the pen color as needed
|
||||
painter->setBrush(QBrush(Qt::black)); // Set the brush if needed
|
||||
painter->drawPolygon(myPolygon);
|
||||
}
|
||||
|
||||
QPointF QCPItemPolygon::anchorPixelPosition(int anchorId) const
|
||||
{
|
||||
Q_UNUSED(anchorId)
|
||||
return QPointF();
|
||||
}
|
||||
|
||||
void QCPItemPolygon::setPoints(const QVector<QPointF> &vecPoint)
|
||||
{
|
||||
vertices.clear();
|
||||
vertices = vecPoint;
|
||||
}
|
||||
|
||||
void QCPItemPolygon::setPloyVal(int i, float fv, float dir)
|
||||
{
|
||||
ni = i;
|
||||
flVal = fv;
|
||||
ifdir = dir;
|
||||
}
|
||||
|
||||
/* including file 'src/polar/radialaxis.cpp' */
|
||||
/* modified 2021-03-29T02:30:44, size 49415 */
|
||||
|
||||
|
|
|
|||
|
|
@ -7838,6 +7838,39 @@ Q_DECLARE_METATYPE(QCPItemBracket::BracketStyle)
|
|||
|
||||
/* end of 'src/items/item-bracket.h' */
|
||||
|
||||
class QCPItemPolygon : public QCPAbstractItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QCPItemPolygon(QCustomPlot *parentPlot);
|
||||
double selectTest(const QPointF&, bool, QVariant*) const override { return 0; }
|
||||
virtual ~QCPItemPolygon() {}
|
||||
|
||||
// 设置真实的点信息
|
||||
void setPoints(const QVector<QPointF>& vecPoint);
|
||||
|
||||
void setPloyVal(int i, float fv, float dir);
|
||||
|
||||
// Define position types
|
||||
QCPItemPosition * const topLeft;
|
||||
QCPItemPosition * const topRight;
|
||||
QCPItemPosition * const bottomLeft;
|
||||
QCPItemPosition * const bottomRight;
|
||||
|
||||
// Define the polygon vertices
|
||||
QVector<QPointF> vertices;
|
||||
|
||||
int ni = -1;
|
||||
float flVal;
|
||||
float ifdir;
|
||||
float dr;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void draw(QCPPainter *painter) override;
|
||||
virtual QPointF anchorPixelPosition(int anchorId) const override;
|
||||
};
|
||||
|
||||
|
||||
/* including file 'src/polar/radialaxis.h' */
|
||||
/* modified 2021-03-29T02:30:44, size 12227 */
|
||||
|
|
|
|||
|
|
@ -1815,11 +1815,11 @@ void FormDraw::initTableLine(QMyCustomPlot *widget, QString strSlfName, QString
|
|||
m_qsProperty=("ID");
|
||||
m_iPrecision = 3;
|
||||
//
|
||||
// ReadFracDef();
|
||||
// for (int i = 0 ; i < iFracType ; i++)
|
||||
// {
|
||||
// m_bTypeDraw[i] = false;
|
||||
// }
|
||||
// ReadFracDef();
|
||||
// for (int i = 0 ; i < iFracType ; i++)
|
||||
// {
|
||||
// m_bTypeDraw[i] = true;
|
||||
// }
|
||||
|
||||
if (m_bTableData)
|
||||
{
|
||||
|
|
@ -2864,8 +2864,20 @@ void FormDraw::initFgrq(QMyCustomPlot *widget)
|
|||
widget->xAxis = yAxis;
|
||||
widget->yAxis = xAxis;
|
||||
|
||||
if(m_Value == NULL)
|
||||
|
||||
// if(m_Value == NULL)
|
||||
{
|
||||
m_bTableData = true; // 表格 曲线
|
||||
m_csCurveDDIR = "DDIR"; // 方位 曲线名
|
||||
m_csCurveDANG = "DANG";//倾角
|
||||
m_csCurveGrad = "GRAD";
|
||||
|
||||
m_qsTable="FRAC_HOLE.TABLE";
|
||||
m_qsDIR=("DDIR"); // 方位 曲线名
|
||||
m_qsDIP=("DANG");//倾角
|
||||
m_qsDepth="DEPT";
|
||||
m_qsID = "ID";
|
||||
|
||||
Refurbish();
|
||||
}
|
||||
|
||||
|
|
@ -2874,12 +2886,44 @@ void FormDraw::initFgrq(QMyCustomPlot *widget)
|
|||
QPen wPen(Qt::black, 2);
|
||||
double centerX = widget->m_iX2/2;
|
||||
|
||||
int nstep = 10;
|
||||
int tmp = m_SDep / nstep;
|
||||
float flVal = 0.0f;
|
||||
float x,y,x1,y1,x2,y2;
|
||||
float ifdir[360];
|
||||
int m_nArc = 36;
|
||||
float m_LeftVal3 = 0;
|
||||
float m_RightVal3 = 100.0;
|
||||
m_LeftVal = 0.0f;
|
||||
m_RightVal = 90.0f;
|
||||
float mind=min(m_RightVal , m_LeftVal);
|
||||
float maxd=max(m_RightVal , m_LeftVal);
|
||||
float dirmax,dipmax,dr;
|
||||
|
||||
float deps;
|
||||
|
||||
float ftmpSdep = m_SDep;
|
||||
float ftmpEdep = m_EDep;
|
||||
if (m_bTableData)
|
||||
{
|
||||
ReadFracDef();
|
||||
for (int i = 0 ; i < iFracType ; i++)
|
||||
{
|
||||
m_bTypeDraw[i] = true;
|
||||
}
|
||||
|
||||
ftmpSdep = -g_iY2;
|
||||
ftmpEdep = -g_iY1;
|
||||
}
|
||||
|
||||
int nPointNum = m_FracTabList.count();
|
||||
int n = m_FracDefList.count();
|
||||
int nstep = 5;
|
||||
int tmp = ftmpSdep / nstep;
|
||||
float flDep = tmp * nstep;
|
||||
|
||||
m_Curve.DepLevel = 0.5;
|
||||
while ( 1)
|
||||
{
|
||||
if((flDep>=m_EDep+nstep)||flDep>=m_EDep)break;
|
||||
if((flDep>=ftmpEdep+nstep)||flDep>=ftmpEdep)break;
|
||||
|
||||
double tempf = flDep+(float)(nstep)/2.;
|
||||
double centerY = tempf * -1.0;
|
||||
|
|
@ -2903,6 +2947,149 @@ void FormDraw::initFgrq(QMyCustomPlot *widget)
|
|||
pLine1->end->setCoords(centerY,centerX);
|
||||
}
|
||||
|
||||
for(int i=0;i<=m_nArc;i++) ifdir[i]=0.;
|
||||
x1 = 360./m_nArc;
|
||||
|
||||
int i = 0;
|
||||
if (m_bTableData)
|
||||
{
|
||||
int m_nLine = 9;
|
||||
y1 = (maxd-mind)/m_nLine;//线数
|
||||
for (i=0; i<nPointNum; i++)
|
||||
{
|
||||
const FRAC_TABLE& frac = m_FracTabList.at(i);
|
||||
if ( frac.DEP < 0 ) continue;
|
||||
bool bDraw = false;
|
||||
for (int j=0; j<n; j++)
|
||||
{
|
||||
const FRAC_DEF& fd = m_FracDefList.at(j);
|
||||
if ( (int)(frac.ID) == fd.iCode )
|
||||
{
|
||||
bDraw = m_bTypeDraw[j];//fd.bDraw;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !bDraw ) continue;
|
||||
|
||||
deps =frac.DEP;
|
||||
|
||||
if ( deps >= flDep &&deps < (flDep+ nstep) )
|
||||
{
|
||||
flVal = frac.DIR;//方位
|
||||
int j = flVal/x1;
|
||||
if ( j >= 0 && j< m_nArc+1 )
|
||||
ifdir[j] ++;
|
||||
|
||||
flVal = frac.DIPorS;//倾角
|
||||
//按倾角范围统计
|
||||
if(flVal> maxd || flVal < mind)
|
||||
{
|
||||
//i++;
|
||||
continue;
|
||||
}
|
||||
// j = (flVal-mind)/y1;//j = flVal/y1+1;
|
||||
// if ( j >= 0 && j< m_nLine+1 )
|
||||
// ifdir[j] ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while ( 1 )
|
||||
{
|
||||
deps = flDep + i * m_Curve.DepLevel;
|
||||
|
||||
tempf = (deps-m_Curve.StartDepth)/m_Curve.DepLevel+0.5;
|
||||
if (deps >= ftmpEdep||
|
||||
deps > m_Curve.EndDepth||
|
||||
deps >=( flDep + nstep))
|
||||
break;
|
||||
if(tempf<0)
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_Value3 !=NULL )// for 控制曲线
|
||||
{
|
||||
float tempf3 = (deps-m_Curve3.StartDepth)/m_Curve3.DepLevel+0.5;
|
||||
if(tempf3<0)
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
double grad = GetData(m_Curve3.RepCode,(char *)&m_Value3[(int)(tempf3)*m_Curve3.CodeLen]);
|
||||
if(grad<m_LeftVal3||grad>m_RightVal3){i++;continue;}
|
||||
}
|
||||
|
||||
flVal = GetData(m_Curve.RepCode,(char *)&m_Value[(int)(tempf)*m_Curve.CodeLen]);
|
||||
flVal=fmod(flVal,360.f);
|
||||
int j = flVal/x1;
|
||||
if ( j >= 0 && j< m_nArc+1 )
|
||||
ifdir[j] ++;
|
||||
|
||||
tempf = (deps-m_Curve2.StartDepth)/m_Curve2.DepLevel+0.5;
|
||||
if(tempf<0 )
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
//按倾角范围统计
|
||||
if(flVal> maxd || flVal < mind)
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
|
||||
flVal = 3.1415926535 *2./ m_nArc ;
|
||||
dirmax=0; dipmax=0;
|
||||
for(i=0;i<=m_nArc;i++)
|
||||
if (dirmax<ifdir[i]) dirmax=ifdir[i];
|
||||
|
||||
if (dirmax == 0 )
|
||||
dirmax=1;
|
||||
for(i=0;i<=m_nArc;i++)
|
||||
ifdir[i]=ifdir[i]*(nR)/dirmax;//-m_nArcLineWidth/2.whp add 2016.10.21 for线粗时扇叶超界
|
||||
// ifdir[i]=ifdir[i]*(nRadius-GetLineWidth(pDC,m_nArcLineWidth/2.))/dirmax;//-m_nArcLineWidth/2.whp add 2016.10.21 for线粗时扇叶超界
|
||||
ifdir[m_nArc+1]=ifdir[1];
|
||||
|
||||
//方位频率
|
||||
float x0,y0;
|
||||
|
||||
x = centerY;
|
||||
y = centerX;
|
||||
for(int i=0;i<=m_nArc;i++)
|
||||
{
|
||||
if(ifdir[i] <= 0.0f)
|
||||
continue;
|
||||
QCPItemPolygon* pol = new QCPItemPolygon(widget);
|
||||
pol->topLeft->setCoords(x, y);
|
||||
pol->bottomRight->setCoords(x, y);
|
||||
pol->setPloyVal(i,flVal, ifdir[i]);
|
||||
// pol->setPoints(myPolygon);
|
||||
// pol->setPoints(myPolygon);
|
||||
|
||||
// QCPItemRect* prt = new QCPItemRect(widget);
|
||||
// prt->topLeft->setCoords(x, y);
|
||||
// prt->bottomRight->setCoords(x, y);
|
||||
|
||||
// if(m_bFill)
|
||||
// {
|
||||
// QPainterPath myPath;
|
||||
// myPath.addPolygon(myPolygon);
|
||||
// pDC->fillPath(myPath,textBrushFill);
|
||||
// }
|
||||
// if(m_nArcLineWidth>=1)
|
||||
// {
|
||||
// pDC->setPen(pPenArc);
|
||||
// // pDC->drawPolygon(myPolygon);
|
||||
// }
|
||||
}
|
||||
|
||||
flDep += nstep;
|
||||
}
|
||||
|
||||
|
|
@ -3547,7 +3734,8 @@ void FormDraw::ReadFracDef()
|
|||
QString qs;
|
||||
|
||||
//sprintf(str,"%sconf\\FRAC.CFG",path);
|
||||
QString fracFilePath = GetConfPath() + "FRAC_New.CFG";
|
||||
// QString fracFilePath = GetConfPath() + "FRAC_New.CFG";
|
||||
QString fracFilePath = GetConfPath() + "FRAC.CFG";
|
||||
fp = fopen(fracFilePath.toStdString().c_str(),"r");
|
||||
if ( fp !=NULL )
|
||||
{
|
||||
|
|
@ -3725,7 +3913,17 @@ void FormDraw::ReadData(QString strSlfName, QString strLineName)
|
|||
if ( m_qsDIR.compare(cs)==0)
|
||||
frac.DIR = val;
|
||||
if ( m_qsID.compare(cs)==0)
|
||||
frac.ID = (int)(val);
|
||||
{
|
||||
// frac.ID = (int)(val);
|
||||
if(Table_Field[j].RepCode == 6)
|
||||
{
|
||||
char buf[513];
|
||||
memset(buf,0,513);
|
||||
strncpy(buf,&buffer[len],Table_Field[j].Length);
|
||||
buf[Table_Field[j].Length]='\0';
|
||||
frac.ID = atoi(buf);
|
||||
}
|
||||
}
|
||||
|
||||
len += Table_Field[j].Length;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user