in the meanwhile I have solved the problem of accessing the data, and I could change my function
setMarkerOnMax( double* xData, double* yData, int dataCount, int precision, Qt::Alignment alignment )
setMarkerOnMax( double* xData, double* yData, int dataCount, int precision, Qt::Alignment alignment )
To copy to clipboard, switch view to plain text mode
to
setMarkerOnMax( int precision, Qt::Alignment alignment )
setMarkerOnMax( int precision, Qt::Alignment alignment )
To copy to clipboard, switch view to plain text mode
This work well as long as I have only one curve attached to the plot.
In the case I have several curve attached to the plot, and I don´t want to identify all maxima, but only that of one curve for example, I have to add an overloaded function
setMarkerOnMax( double* yData, int precision, Qt::Alignment alignment )
setMarkerOnMax( double* yData, int precision, Qt::Alignment alignment )
To copy to clipboard, switch view to plain text mode
yData beeing the pointer onto the data whose maximum has to be labeled.
To do so, I have the problem of identifying which curve of the list belongs to the yData (C-array)
As starting point, I have the list of all curves attached to the plot.
One solution would be to calculate an hash of the data of each curve in the list and compare them with the hash of the data yData passed as argument - see code fragment below -.
This will work but seems to me to be an overkill!
Is there a better method?
Alain
void setMarkerOnMax( double* yData, int precision, Qt::Alignment alignment )
{
QwtPlotItemIterator it;
const QwtPlotItemList& itemList = this->itemList();
QwtPlotItemList curveList;
// select the plotItem
for ( it = itemList.begin(); it != itemList.end(); ++it ) {
curveList += *it;
}
}
// calculate an hash of each curve for identification
for ( unsigned int i = 0; i < curveList.count(); ++i ) {
QwtPlotCurve* curve
= static_cast<QwtPlotCurve
*>
( curveList
[i
] );
// compute some hash data for each curve
}
// compare the hash of each curve with hash of C-array yData passed as argument
// to get the index of curveList corresponding to yData
// label the curve with the right index
}
void setMarkerOnMax( double* yData, int precision, Qt::Alignment alignment )
{
QwtPlotItemIterator it;
const QwtPlotItemList& itemList = this->itemList();
QwtPlotItemList curveList;
// select the plotItem
for ( it = itemList.begin(); it != itemList.end(); ++it ) {
if ( (*it)->rtti() == QwtPlotItem::Rtti_PlotCurve ) {
curveList += *it;
}
}
// calculate an hash of each curve for identification
for ( unsigned int i = 0; i < curveList.count(); ++i ) {
QwtPlotCurve* curve = static_cast<QwtPlotCurve *>( curveList[i] );
// compute some hash data for each curve
}
// compare the hash of each curve with hash of C-array yData passed as argument
// to get the index of curveList corresponding to yData
// label the curve with the right index
}
To copy to clipboard, switch view to plain text mode
Bookmarks