TEAmerc
26th October 2015, 19:41
I have a server that I'm reading different signal data off of and I want to plot the data using a qwtPlotCurve as it comes in. My problem is that some of the data comes in as an unsigned type (Uint64_t, ulongong, ushort, etc) but setRawSamples only supports arrays of double, so my data gets misinterpreted and comes out as really funny numbers except for the signals that are of signed types.
I had a similar problem with displaying my data in a table, but since the data is stored as a QVariant all I had to do was make a large switch block and cast the data as I updated it, and make a custom delegate for displaying it.
However, since setRawSamples only supports signed types I can't do this and was wondering if there was another way around it so that i could have curves being plotted of both signed and unsigned types.
My code for updating the plot as it is now is below for reference:
void TableViewWindow::UpdateTrendViewDocks(uint64_t **storedData)
{
//If this ViewWindow has been closed do nothing
if (this->isHidden())
return;
QList<QDockWidget *> allDockWidgets = findChildren<QDockWidget *>();
for (QDockWidget * eachDock : allDockWidgets)
{
//Only update docks that are visible
if (!eachDock->isHidden())
{
TableDock *thisTableDock = static_cast<TableDock *>(eachDock);
// Check if the dock contains a trendview before attempting to update
if (thisTableDock->GetViewType() == TableDock::TrendView)
{
QwtPlot *theTrendView = static_cast<QwtPlot *>(thisTableDock->widget());
for (TableDock::CurvePair *curvePair : thisTableDock->curveHolder)
{
curvePair->curve->setRawSamples(xAxisCounter
, (double *)storedData[curvePair->sigNumber]
, historyCount);
double ** demoContainer= (double **)storedData;
std::cerr << std::dec << "SignNum " << curvePair->sigNumber
<< " Should = " << *((uint64_t * )&demoContainer[curvePair->sigNumber][2999])
<< " double Value = " << *((double * )&demoContainer[curvePair->sigNumber][2999])
<< std::endl;
}
theTrendView->replot();
}
}
}
}
With a sample output line from this using a signal where the only difference is whether it's interpreted as signed or unsigned being:
SignNum 0 Should = 6693 double Value = 3.30678e-320
Note that storedData is of type uint64_t **
Also note the letsPretend variable and cerr print statement was for proof of concept and isn't actually going to be in the final run as it does nothing but show the error I'm getting
I had a similar problem with displaying my data in a table, but since the data is stored as a QVariant all I had to do was make a large switch block and cast the data as I updated it, and make a custom delegate for displaying it.
However, since setRawSamples only supports signed types I can't do this and was wondering if there was another way around it so that i could have curves being plotted of both signed and unsigned types.
My code for updating the plot as it is now is below for reference:
void TableViewWindow::UpdateTrendViewDocks(uint64_t **storedData)
{
//If this ViewWindow has been closed do nothing
if (this->isHidden())
return;
QList<QDockWidget *> allDockWidgets = findChildren<QDockWidget *>();
for (QDockWidget * eachDock : allDockWidgets)
{
//Only update docks that are visible
if (!eachDock->isHidden())
{
TableDock *thisTableDock = static_cast<TableDock *>(eachDock);
// Check if the dock contains a trendview before attempting to update
if (thisTableDock->GetViewType() == TableDock::TrendView)
{
QwtPlot *theTrendView = static_cast<QwtPlot *>(thisTableDock->widget());
for (TableDock::CurvePair *curvePair : thisTableDock->curveHolder)
{
curvePair->curve->setRawSamples(xAxisCounter
, (double *)storedData[curvePair->sigNumber]
, historyCount);
double ** demoContainer= (double **)storedData;
std::cerr << std::dec << "SignNum " << curvePair->sigNumber
<< " Should = " << *((uint64_t * )&demoContainer[curvePair->sigNumber][2999])
<< " double Value = " << *((double * )&demoContainer[curvePair->sigNumber][2999])
<< std::endl;
}
theTrendView->replot();
}
}
}
}
With a sample output line from this using a signal where the only difference is whether it's interpreted as signed or unsigned being:
SignNum 0 Should = 6693 double Value = 3.30678e-320
Note that storedData is of type uint64_t **
Also note the letsPretend variable and cerr print statement was for proof of concept and isn't actually going to be in the final run as it does nothing but show the error I'm getting