本文整理汇总了C++中CCurve类的典型用法代码示例。如果您正苦于以下问题:C++ CCurve类的具体用法?C++ CCurve怎么用?C++ CCurve使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCurve类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SelectPoint
bool Graph::SelectPoint(QString const &CurveName, int sel)
{
QString str;
CCurve *pCurve = NULL;
if(sel<0)
{
// pCurve->SetSelected(-1);
return false;
}
for(int i=0; i<m_oaCurves.size(); i++)
{
pCurve = (CCurve*)m_oaCurves.at(i);
pCurve->GetTitle(str);
if(str == CurveName)
{
if(sel>pCurve->GetCount())
{
pCurve->SetSelected(-1);
return false;
}
else
{
pCurve->SetSelected(sel);
return true;
}
}
}
// pCurve->SetSelected(-1);
return false;
}
示例2: ClientTox
CCurve* Graph::GetCurvePoint(const int &xClt, const int &yClt,int &nSel)
{
static int i, n, xc, yc;
static double dist, x1, y1, x,y;
CCurve *pOldCurve;
x= ClientTox(xClt);
y= ClientToy(yClt);
for(i=0; i<m_oaCurves.size(); i++)
{
pOldCurve = (CCurve*)m_oaCurves.at(i);
pOldCurve->GetClosestPoint(x, y, x1, y1, dist, n);
xc = xToClient(x1);
yc = yToClient(y1);
if((xClt-xc)*(xClt-xc) + (yClt-yc)*(yClt-yc) <16)//sqrt(16) pixels distance
{
nSel = n;
return pOldCurve;
}
}
nSel = -1;
return NULL;
}
示例3: DeselectPoint
void Graph::DeselectPoint()
{
CCurve *pCurve;
for(int i=0; i<m_oaCurves.size(); i++)
{
pCurve = (CCurve*)m_oaCurves.at(i);
pCurve->SetSelected(-1);
}
}
示例4: ResetCurves
void Graph::ResetCurves()
{
CCurve *pCurve;
for(int i=0; i<m_oaCurves.size(); i++)
{
pCurve = (CCurve*)m_oaCurves.at(i);
pCurve->ResetCurve();
}
}
示例5: ComputeLoop
// --[ Method ]---------------------------------------------------------------
//
// - Class : CFuncRandom
// - Prototype : float Evaluate(float fTime)
//
// - Purpose : Returns a float value as a result of evaluating the function
// given a time value.
//
// -----------------------------------------------------------------------------
float CFuncRandom::Evaluate(float fTime)
{
ComputeLoop(0.0f, LOOPLENGTH - (1.0f / m_fFrequency), &fTime);
CVector3 v3Val;
CCurve* pCurve;
if(m_bSmooth) pCurve = &m_crvFunctionSmooth; else pCurve = &m_crvFunctionLinear;
pCurve->Evaluate(fTime, &v3Val);
return v3Val.X();
}
示例6: CCurve
CCurve* Graph::AddCurve()
{
CCurve *pCurve = new CCurve();
if(pCurve)
{
int nIndex = m_oaCurves.size();
pCurve->SetColor(m_CurveColors[nIndex%10]);
pCurve->SetStyle(0);
pCurve->m_pParentGraph = this;
m_oaCurves.append(pCurve);
}
return pCurve;
}
示例7: GetCurve
CCurve* Graph::GetCurve(QString CurveTitle)
{
QString strong;
CCurve * pCurve;
for(int i=0; i<m_oaCurves.size(); i++)
{
pCurve = (CCurve*)m_oaCurves.at(i);
if(pCurve)
{
pCurve->GetTitle(strong);
if(strong==CurveTitle) return pCurve;
}
}
return NULL;
}
示例8: nearest_point_to_curve
static boost::python::tuple nearest_point_to_curve(CCurve& c1, const CCurve& c2)
{
double dist;
Point p = c1.NearestPoint(c2, &dist);
return bp::make_tuple(p, dist);
}
示例9: ExportToFile
void QGraph::ExportToFile(QFile &XFile, int FileType)
{
int i,j, maxpoints;
CCurve *pCurve;
QString strong;
QTextStream out(&XFile);
maxpoints = 0;
for(i=0; i<m_oaCurves.size(); i++)
{
pCurve = GetCurve(i);
if(pCurve)
{
maxpoints = qMax(maxpoints,pCurve->n);
pCurve->GetTitle(strong);
if(FileType==1) out << " "<<m_XTitle<<" "<< strong <<" ";
else out << m_XTitle<<","<< strong << ", , ";
}
}
out<<"\n"; //end of title line
for(j=0; j<maxpoints; j++)
{
for(i=0; i<m_oaCurves.size(); i++)
{
pCurve = GetCurve(i);
if(pCurve && j<pCurve->n)
{
if(FileType==1) strong= QString("%1 %2 ")
.arg(pCurve->x[j],13,'g',7).arg(pCurve->y[j],13,'g',7);
else strong= QString("%1, %2, , ")
.arg(pCurve->x[j],13,'g',7).arg(pCurve->y[j],13,'g',7);
}
else
{
if(FileType==1) strong= " ";
else strong= ", , , ";
}
out << strong;
}
out<<"\n"; //end of data line
}
out<<"\n"; //end of file
XFile.close();
}
示例10: CurveIntersections
void CArea::InsideCurves(const CCurve& curve, std::list<CCurve> &curves_inside)const
{
//1. find the intersectionpoints between these two curves.
std::list<Point> pts;
CurveIntersections(curve, pts);
//2.seperate curve2 in multiple curves between these intersections.
std::list<CCurve> separate_curves;
curve.ExtractSeparateCurves(pts, separate_curves);
//3. if the midpoint of a seperate curve lies in a1, then we return it.
for(std::list<CCurve>::iterator It = separate_curves.begin(); It != separate_curves.end(); It++)
{
CCurve &curve = *It;
double length = curve.Perim();
Point mid_point = curve.PerimToPoint(length * 0.5);
if(IsInside(mid_point, *this))curves_inside.push_back(curve);
}
}
示例11: make_obround
static CArea make_obround(const Point& p0, const Point& p1, double radius)
{
Point dir = p1 - p0;
double d = dir.length();
dir.normalize();
Point right(dir.y, -dir.x);
CArea obround;
CCurve c;
if(fabs(radius) < 0.0000001)radius = (radius > 0.0) ? 0.002 : (-0.002);
Point vt0 = p0 + right * radius;
Point vt1 = p1 + right * radius;
Point vt2 = p1 - right * radius;
Point vt3 = p0 - right * radius;
c.append(vt0);
c.append(vt1);
c.append(CVertex(1, vt2, p1));
c.append(vt3);
c.append(CVertex(1, vt0, p0));
obround.append(c);
return obround;
}
示例12: SetFromResult
static void SetFromResult( CCurve& curve, const TPolygon& p, bool reverse = true )
{
for(unsigned int j = 0; j < p.size(); j++)
{
const IntPoint &pt = p[j];
DoubleAreaPoint dp(pt);
CVertex vertex(0, Point(dp.X / CArea::m_units, dp.Y / CArea::m_units), Point(0.0, 0.0));
if(reverse)curve.m_vertices.push_front(vertex);
else curve.m_vertices.push_back(vertex);
}
// make a copy of the first point at the end
if(reverse)curve.m_vertices.push_front(curve.m_vertices.back());
else curve.m_vertices.push_back(curve.m_vertices.front());
if(CArea::m_fit_arcs)curve.FitArcs();
}
示例13: TextPen
void QGraph::DrawLegend(QPainter &painter, QPoint &Place, QFont &LegendFont, QColor &LegendColor)
{
painter.save();
int LegendSize, ypos;
QString strong;
LegendSize = 30;
ypos = 12;
painter.setFont(LegendFont);
CCurve* pCurve;
QPen TextPen(LegendColor);
QPen LegendPen(Qt::gray);
int npos = 0;
for (int nc=0; nc< m_oaCurves.size(); nc++)
{
pCurve = (CCurve*) m_oaCurves[nc];
if(pCurve->IsVisible())
{
pCurve->GetTitle(strong);
if(pCurve->n>0 && strong.length())//is there anything to draw ?
{
LegendPen.setColor(pCurve->GetColor());
LegendPen.setStyle(GetStyle(pCurve->GetStyle()));
LegendPen.setWidth(pCurve->GetWidth());
painter.setPen(LegendPen);
painter.drawLine(Place.x(), Place.y() + ypos*npos,
Place.x() + (int)(LegendSize), Place.y() + ypos*npos);
painter.setPen(TextPen);
painter.drawText(Place.x() + (int)(1.5*LegendSize), Place.y() + ypos*npos+(int)(ypos/2),
strong);
npos++;
}
}
}
painter.restore();
}
示例14: GetCurve
void QGraph::DrawCurve(int nIndex, QPainter &painter)
{
painter.save();
static double scaley;
static int i, ptside;
static QPoint From, To, Min, Max;
static QRect rViewRect;
ptside = 2;
CCurve* pCurve = GetCurve(nIndex);
scaley = m_scaley;
QBrush FillBrush(m_BkColor);
painter.setBrush(FillBrush);
QPen CurvePen(pCurve->GetColor());
CurvePen.setStyle(GetStyle(pCurve->GetStyle()));
CurvePen.setWidth((int)pCurve->GetWidth());
painter.setPen(CurvePen);
Min.setX(int(xmin/m_scalex) +m_ptoffset.x());
Min.setY(int(ymin/scaley) +m_ptoffset.y());
Max.setX(int(xmax/m_scalex) +m_ptoffset.x());
Max.setY(int(ymax/scaley) +m_ptoffset.y());
rViewRect.setTopLeft(Min);
rViewRect.setBottomRight(Max);
if(pCurve->n>=1)
{
From.setX(int(pCurve->x[0]/m_scalex+m_ptoffset.x()));
From.setY(int(pCurve->y[0]/scaley +m_ptoffset.y()));
if(pCurve->IsVisible())
{
for (i=1; i<pCurve->n;i++)
{
To.setX(int(pCurve->x[i]/m_scalex+m_ptoffset.x()));
To.setY(int(pCurve->y[i]/scaley +m_ptoffset.y()));
painter.drawLine(From, To);
From = To;
}
}
if(pCurve->PointsVisible())
{
for (i=0; i<pCurve->n;i++)
{
if(pCurve->GetSelected() !=i)
painter.drawRect(int(pCurve->x[i]/m_scalex+m_ptoffset.x())-ptside,
int(pCurve->y[i]/ scaley+m_ptoffset.y())-ptside,
2*ptside,2*ptside);
}
}
}
if(m_bHighlightPoint)
{
int point = pCurve->GetSelected();
if(point>=0)
{
//highlight
QColor HighColor(0,40, 150);
CurvePen.setWidth((int)pCurve->GetWidth());
CurvePen.setColor(HighColor);
painter.setPen(CurvePen);
To.setX(int(pCurve->x[point]/m_scalex+m_ptoffset.x()));
To.setY(int(pCurve->y[point]/scaley +m_ptoffset.y()));
painter.drawRect(To.x()-ptside-1,To.y()-ptside-1, 2*(ptside+1),2*(ptside+1));
}
}
painter.restore();
}
示例15: qMin
bool Graph::SetXScale()
{
CCurve *pCurve;
int nc;
if(m_bAutoX)
{
bool bCurve = false;
if (m_oaCurves.size())
{
//init only if we have a curve
for (nc=0; nc < m_oaCurves.size(); nc++)
{
pCurve = (CCurve*)m_oaCurves[nc];
if ((pCurve->IsVisible() ||pCurve->PointsVisible()) && pCurve->n>1)
{
bCurve = true;
break;//there is something to draw
}
}
}
if (bCurve)
{
Cxmin = 9999999.0;
Cxmax = -9999999.0;
for (nc=0; nc < m_oaCurves.size(); nc++)
{
pCurve = (CCurve*)m_oaCurves[nc];
if ((pCurve->IsVisible() ||pCurve->PointsVisible()) && pCurve->n>0)
{
Cxmin = qMin(Cxmin, pCurve->GetxMin());
Cxmax = qMax(Cxmax, pCurve->GetxMax());
}
}
if(Cxmax<=Cxmin)
Cxmax = (Cxmin+1.0)*2.0;
if(m_Type == 1)
{
xmin = qMin(xmin, Cxmin);
xmax = qMax(xmax, Cxmax);
}
else
{
xmin = Cxmin;
xmax = Cxmax;
}
if(Cxmin>=0.0) xmin = 0.0;
if(Cxmax<=0.0) xmax = 0.0;
}
else
{
// until things are made clear
for (nc=0; nc < m_oaCurves.size(); nc++)
{
pCurve = (CCurve*)m_oaCurves[nc];
if ((pCurve->IsVisible() ||pCurve->PointsVisible()) && pCurve->n>0)
{
xmin = qMin(xmin, pCurve->x[0]);
xmax = qMax(xmax, pCurve->x[0]);
}
}
}
xo=0.0;
if(fabs((xmin-xmax)/xmin)<0.001)
{
if(fabs(xmin)<0.00001) xmax = 1.0;
else
{
xmax = 2.0 * xmin;
if(xmax < xmin)
{
double tmp = xmax;
xmax = xmin;
xmin = tmp;
}
}
}
if(m_w<=0.0) return false;
m_scalex = (xmax-xmin)/m_w;
//try to set an automatic scale for X Axis
SetAutoXUnit();
}
else
{
//scales are set manually
if(m_w<=0.0) return false;
// m_scalex = (xmax-xmin)/m_w;
if (xunit<1.0)
{
//.........这里部分代码省略.........