void Engine::handle(GeoPainterContext* context,QList<QVector<QPointF> >& fills, QVector<QPointF>& lines,int trace, int top, int bottom, bool flag)
{
if(top >= bottom)
return;
#define SHOT(x) SHOTS[x]
#define DATA(x) SHOT(0).TraceData[trace-1].data[x]
//flag = true points is positive, else points is negative
bool start(false),end(false);
float data_1,data_2;
double maxValue = SHOT(0).TraceData[trace-1].maxTraceData;
QVector<QPointF> points;
int sampleN = bottom-top;
for(int i=0;i<sampleN;i++)
{
data_1 = DATA(i)/maxValue;
data_2 = DATA(i+1)/maxValue;
lines = context->paintFromSeismic(QPointF(trace+data_1,top+i));
if(flag)
{
//第一种情况:
/*------------------------------------
| | |
. | . | . |
| . . . |
------------------------------------*/
if(data_1<0)
{
if(data_2>0)
{
start = true;
points.push_back(context->paintFromSeismic(QPointF(trace,top+i+fabs(data_1)/(fabs(data_1)+fabs(data_2)))));
//若是最后一个采样点时,需多记录平衡位置上的一个点
if(i==bottom-1)
{
points.push_back(context->paintFromSeismic(QPointF(trace+data_2,top+i+1)));
points.push_back(context->paintFromSeismic(QPointF(trace,bottom)));
end = true;
}
}
}
//第二种情况:
/*------------------------------------
| | |
| . | . | .
| . . . |
------------------------------------*/
else if(data_1>0)
{
//若是第一个采样点时,需多记录平衡位置上的一个点
if(i==top)
{
start = true;
points.push_back(context->paintFromSeismic(QPointF(trace,top)));
}
if(data_2<0)
{
points.push_back(context->paintFromSeismic(QPointF(trace+data_1,top+i)));
points.push_back(context->paintFromSeismic(QPointF(trace,top+i+fabs(data_1)/(fabs(data_1)+fabs(data_2)))));
end = true;
}
else if(data_2==0)
{
points.push_back(context->paintFromSeismic(QPointF(trace+data_1,top+i)));
end = true;
}
else
{
points.push_back(context->paintFromSeismic(QPointF(trace+data_1,top+i)));
if(i==bottom-1)
{
points.push_back(context->paintFromSeismic(QPointF(trace+data_2,top+i+1)));
points.push_back(context->paintFromSeismic(QPointF(trace,bottom)));
end = true;
}
}
}
//第三种情况
/*------------------------------------
| | |
. . .
| . . | .
------------------------------------*/
else
{
if(data_2>0)
{
start = true;
points.push_back(context->paintFromSeismic(QPointF(trace,top)));
points.push_back(context->paintFromSeismic(QPointF(trace+data_2,top+i+1)));
if(i==bottom-1)
{
points.push_back(context->paintFromSeismic(QPointF(trace,bottom)));
end = true;
}
}
}
//只要同时有开始标识和结束标识时,才构成一个多边形点集合。
if(start && end)
{
fills.push_back(points);
points.clear();
start = false;
end = false;
}
}
}
经调试,在此语句中fills.push_back(points);出现的结果有误。
谢谢