19 #include <QApplication> 21 #include <QTextStream> 36 layout_(new QGridLayout(this)),
41 setAutoFillBackground(
true);
43 layout_->setHorizontalSpacing(20);
44 layout_->setVerticalSpacing(20);
46 connect(
bagReader_, SIGNAL(readingStarted()),
this,
48 connect(
bagReader_, SIGNAL(readingProgressChanged(
double)),
this,
50 connect(
bagReader_, SIGNAL(readingFinished()),
this,
52 connect(
bagReader_, SIGNAL(readingFailed(
const QString&)),
this,
66 disconnect(
config_, SIGNAL(backgroundColorChanged(
const QColor&)),
68 disconnect(
config_, SIGNAL(foregroundColorChanged(
const QColor&)),
70 disconnect(
config_, SIGNAL(numPlotsChanged(
size_t,
size_t)),
this,
72 disconnect(
config_, SIGNAL(linkScaleChanged(
bool)),
this,
74 disconnect(
config_, SIGNAL(trackPointsChanged(
bool)),
this,
81 connect(config, SIGNAL(backgroundColorChanged(
const QColor&)),
83 connect(config, SIGNAL(foregroundColorChanged(
const QColor&)),
85 connect(config, SIGNAL(numPlotsChanged(
size_t,
size_t)),
this,
87 connect(config, SIGNAL(linkScaleChanged(
bool)),
this,
89 connect(config, SIGNAL(trackPointsChanged(
bool)),
this,
134 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
140 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
146 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
152 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
158 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
166 if (numRows && numColumns) {
167 double plotWidth = (pixmap.width()-20.0*(numColumns-1.0))/numColumns;
168 double plotHeight = (pixmap.height()-20.0*(numRows-1.0))/numRows;
172 ++row, y += plotHeight+20.0) {
175 for (
size_t column = 0; column <
plotWidgets_[row].count();
176 ++column, x += plotWidth+20.0)
178 QRectF(x, y, plotWidth, plotHeight));
184 formattedAxisTitles) {
185 formattedAxisTitles.clear();
187 for (
size_t row = 0; row <
plotWidgets_.count(); ++row) {
188 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++column) {
189 QStringList formattedCurveAxisTitles;
191 plotWidgets_[row][column]->writeFormattedCurveAxisTitles(
192 formattedCurveAxisTitles);
194 formattedAxisTitles.append(formattedCurveAxisTitles);
201 formattedData.clear();
203 for (
size_t row = 0; row <
plotWidgets_.count(); ++row) {
204 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++column) {
205 QList<QStringList> formattedCurveData;
210 formattedData.append(formattedCurveData);
219 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++column)
228 QPixmap pixmap(1280, 1024);
230 pixmap.fill(Qt::transparent);
233 pixmap.save(fileName,
"PNG");
237 QFile file(fileName);
239 if (file.open(QIODevice::WriteOnly)) {
240 QStringList formattedAxisTitles;
241 QList<QStringList> formattedData;
246 QTextStream stream(&file);
248 stream <<
"# " << formattedAxisTitles.join(
", ") <<
"\n";
253 QStringList dataLineParts;
254 bool finished =
true;
256 for (
size_t column = 0; column < formattedData.count(); ++column) {
257 if (row < formattedData[column].count()) {
258 dataLineParts.append(formattedData[column][row]);
262 dataLineParts.append(QString());
266 stream << dataLineParts.join(
", ") <<
"\n";
283 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++column)
284 currentBounds +=
plotWidgets_[row][column]->getCurrentScale();
297 for (
size_t row = 0; row <
plotWidgets_.count(); ++row) {
298 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++column) {
300 plotWidgets_[row][column]->setCurrentScale(validBounds);
310 QPalette currentPalette = palette();
312 currentPalette.setColor(QPalette::Window, color);
313 currentPalette.setColor(QPalette::Base, color);
315 setPalette(currentPalette);
321 QPalette currentPalette = palette();
323 currentPalette.setColor(QPalette::WindowText, color);
324 currentPalette.setColor(QPalette::Text, color);
326 setPalette(currentPalette);
332 size_t oldNumColumns = oldNumRows ?
plotWidgets_[0].count() : 0;
334 if (!numRows || !numColumns) {
339 QVector<QVector<PlotWidget* > > plotWidgets(numRows);
340 QGridLayout* layout =
new QGridLayout();
342 layout->setHorizontalSpacing(20);
343 layout->setVerticalSpacing(20);
345 for (
size_t row = 0; row < numRows; ++row) {
346 plotWidgets[row].resize(numColumns);
348 for (
size_t column = 0; column < numColumns; ++column) {
349 if ((row < oldNumRows) && (column < oldNumColumns))
352 plotWidgets[row][column] =
new PlotWidget(
this);
354 connect(plotWidgets[row][column], SIGNAL(preferredScaleChanged(
357 connect(plotWidgets[row][column], SIGNAL(currentScaleChanged(
360 connect(plotWidgets[row][column]->getCursor(), SIGNAL(
362 connect(plotWidgets[row][column]->getCursor(), SIGNAL(
363 currentPositionChanged(
const QPointF&)),
this, SLOT(
365 connect(plotWidgets[row][column], SIGNAL(pausedChanged(
bool)),
367 connect(plotWidgets[row][column], SIGNAL(stateChanged(
int)),
373 plotWidgets[row][column]->setBroker(
registry_);
376 plotWidgets[row][column]->setCurrentScale(plotWidgets[0][0]->
379 plotWidgets[row][column]->getCursor()->setTrackPoints(
382 layout->addWidget(plotWidgets[row][column], row, column);
386 if ((numRows == 1) && (numColumns == 1))
387 plotWidgets[0][0]->setCanChangeState(
false);
389 plotWidgets[0][0]->setCanChangeState(
true);
391 for (
size_t row = 0; row < oldNumRows; ++row)
392 for (
size_t column = 0; column < oldNumColumns; ++column)
393 if ((row >= numRows) || (column >= numColumns))
410 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
411 bounds +=
plotWidgets_[row][column]->getPreferredScale();
419 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
420 plotWidgets_[row][column]->getCursor()->setTrackPoints(track);
436 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++column)
447 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++column)
450 emit
jobFailed(
"Failed to read bag from [file://"+
461 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
462 bounds +=
plotWidgets_[row][column]->getPreferredScale();
467 static_cast<PlotWidget*
>(sender())->setCurrentScale(bounds);
480 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
482 plotWidgets_[row][column]->getCursor()->setActive(active);
490 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column)
492 plotWidgets_[row][column]->getCursor()->setCurrentPosition(
502 for (
size_t row = 0; row <
plotWidgets_.count(); ++row) {
503 for (
size_t column = 0; column <
plotWidgets_[row].count(); ++ column) {
void read(const QString &fileName)
bool arePointsTracked() const
const QColor & getForegroundColor() const
PlotConfig * getPlotConfig(size_t row, size_t column) const
const QColor & getBackgroundColor() const
size_t getNumColumns() const
bool isCursorLinked() const
QString getFileName() const
size_t getNumRows() const
bool isScaleLinked() const
void run(ClassLoader *loader)