Пример #1
0
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
0
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;
}
Пример #3
0
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();
}
Пример #4
0
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();

}