GraphingWindow: don't use size_t as indexes for Qt containers
This commit is contained in:
+21
-25
@@ -779,12 +779,12 @@ void GraphingWindow::saveSpreadsheet()
|
|||||||
QList<GraphParams>::iterator iter;
|
QList<GraphParams>::iterator iter;
|
||||||
double xMin = std::numeric_limits<double>::max(),
|
double xMin = std::numeric_limits<double>::max(),
|
||||||
xMax = std::numeric_limits<double>::min();
|
xMax = std::numeric_limits<double>::min();
|
||||||
size_t maxCount = 0;
|
int maxCount = 0;
|
||||||
size_t numGraphs = graphParams.length();
|
int numGraphs = graphParams.length();
|
||||||
for (auto && graph : graphParams) {
|
for (auto && graph : graphParams) {
|
||||||
xMin = std::min(xMin, graph.x[0]);
|
xMin = std::min(xMin, graph.x[0]);
|
||||||
xMax = std::max(xMax, graph.x[graph.x.count() - 1]);
|
xMax = std::max(xMax, graph.x[graph.x.count() - 1]);
|
||||||
maxCount = std::max(maxCount, static_cast<size_t>(graph.x.count()));
|
maxCount = std::max(maxCount, graph.x.count());
|
||||||
}
|
}
|
||||||
qDebug() << "xMin: " << xMin;
|
qDebug() << "xMin: " << xMin;
|
||||||
qDebug() << "xMax: " << xMax;
|
qDebug() << "xMax: " << xMax;
|
||||||
@@ -795,8 +795,6 @@ void GraphingWindow::saveSpreadsheet()
|
|||||||
double xSize = xMax - xMin;
|
double xSize = xMax - xMin;
|
||||||
double sliceSize = xSize / ((double)maxCount);
|
double sliceSize = xSize / ((double)maxCount);
|
||||||
double equivValue = sliceSize / 100.0;
|
double equivValue = sliceSize / 100.0;
|
||||||
double currentX;
|
|
||||||
double value;
|
|
||||||
QList<int> indices;
|
QList<int> indices;
|
||||||
indices.reserve(numGraphs);
|
indices.reserve(numGraphs);
|
||||||
|
|
||||||
@@ -808,14 +806,14 @@ void GraphingWindow::saveSpreadsheet()
|
|||||||
}
|
}
|
||||||
outFile->write("\n");
|
outFile->write("\n");
|
||||||
|
|
||||||
for (size_t j = 1; j < (maxCount - 1); j++)
|
for (int j = 1; j < (maxCount - 1); j++)
|
||||||
{
|
{
|
||||||
currentX = xMin + (j * sliceSize);
|
double currentX = xMin + (j * sliceSize);
|
||||||
qDebug() << "X: " << currentX;
|
qDebug() << "X: " << currentX;
|
||||||
outFile->write(QString::number(currentX, 'f').toUtf8());
|
outFile->write(QString::number(currentX, 'f').toUtf8());
|
||||||
for (size_t k = 0; k < numGraphs; k++)
|
for (int k = 0; k < numGraphs; k++)
|
||||||
{
|
{
|
||||||
value = 0.0;
|
double value = 0.0;
|
||||||
|
|
||||||
// move cursor to last sample before currentX
|
// move cursor to last sample before currentX
|
||||||
while (graphParams[k].x[indices[k]+1] < currentX)
|
while (graphParams[k].x[indices[k]+1] < currentX)
|
||||||
@@ -849,7 +847,7 @@ void GraphingWindow::saveSpreadsheet()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// find index, where x >= currentX
|
// find index, where x >= currentX
|
||||||
size_t cursor = indices[k];
|
int cursor = indices[k];
|
||||||
double span = graphParams[k].x[cursor+1] - graphParams[k].x[cursor];
|
double span = graphParams[k].x[cursor+1] - graphParams[k].x[cursor];
|
||||||
double progress = (currentX - graphParams[k].x[cursor]) / span;
|
double progress = (currentX - graphParams[k].x[cursor]) / span;
|
||||||
Q_ASSERT(progress >= 0.0 && progress <= 1.0);
|
Q_ASSERT(progress >= 0.0 && progress <= 1.0);
|
||||||
@@ -1325,10 +1323,8 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
|||||||
double yminval=10000000.0, ymaxval = -1000000.0;
|
double yminval=10000000.0, ymaxval = -1000000.0;
|
||||||
double xminval=10000000000.0, xmaxval = -10000000000.0;
|
double xminval=10000000000.0, xmaxval = -10000000000.0;
|
||||||
GraphParams *refParam = ¶ms;
|
GraphParams *refParam = ¶ms;
|
||||||
int sBit, bits;
|
|
||||||
bool intelFormat, isSigned;
|
|
||||||
QString tempStr;
|
QString tempStr;
|
||||||
double x,y;
|
double x{}, y{};
|
||||||
|
|
||||||
qDebug() << "New Graph ID: " << params.ID;
|
qDebug() << "New Graph ID: " << params.ID;
|
||||||
qDebug() << "Start bit: " << params.startBit;
|
qDebug() << "Start bit: " << params.startBit;
|
||||||
@@ -1365,10 +1361,10 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
|||||||
//params.x.fill(0, numEntries);
|
//params.x.fill(0, numEntries);
|
||||||
//params.y.fill(0, numEntries);
|
//params.y.fill(0, numEntries);
|
||||||
|
|
||||||
sBit = params.startBit;
|
int sBit = params.startBit;
|
||||||
bits = params.numBits;
|
int bits = params.numBits;
|
||||||
intelFormat = params.intelFormat;
|
bool intelFormat = params.intelFormat;
|
||||||
isSigned = params.isSigned;
|
bool isSigned = params.isSigned;
|
||||||
|
|
||||||
for (int j = 0; j < numEntries; j++)
|
for (int j = 0; j < numEntries; j++)
|
||||||
{
|
{
|
||||||
@@ -1558,16 +1554,16 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
|||||||
void GraphingWindow::moveLegend()
|
void GraphingWindow::moveLegend()
|
||||||
{
|
{
|
||||||
qDebug() << "moveLegend";
|
qDebug() << "moveLegend";
|
||||||
if (QAction* contextAction = qobject_cast<QAction*>(sender())) // make sure this slot is really called by a context menu action, so it carries the data we need
|
if (QAction* contextAction = qobject_cast<QAction*>(sender())) // make sure this slot is really called by a context menu action, so it carries the data we need
|
||||||
{
|
|
||||||
bool ok;
|
|
||||||
int dataInt = contextAction->data().toInt(&ok);
|
|
||||||
if (ok)
|
|
||||||
{
|
{
|
||||||
ui->graphingView->axisRect()->insetLayout()->setInsetAlignment(0, (Qt::Alignment)dataInt);
|
bool ok;
|
||||||
ui->graphingView->replot();
|
int dataInt = contextAction->data().toInt(&ok);
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
ui->graphingView->axisRect()->insetLayout()->setInsetAlignment(0, (Qt::Alignment)dataInt);
|
||||||
|
ui->graphingView->replot();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphParams::GraphParams()
|
GraphParams::GraphParams()
|
||||||
|
|||||||
Reference in New Issue
Block a user