diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index c8e19917..11c0ca96 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -2045,16 +2045,66 @@ void MainWindow::on_treePlotColumns_itemChanged(QTreeWidgetItem *changeitem, int } else if(column == PlotColumnY) { if(changeitem->checkState(column) == Qt::Checked) { - // get a default color - QColor curbkcolor = changeitem->backgroundColor(column); - QColor color = !curbkcolor.isValid() ? (Qt::GlobalColor)(qrand() % 13 + 5) : curbkcolor; + // Getget a default colour + QColor colour = changeitem->backgroundColor(column); + if(!colour.isValid()) + { + static int last_colour_index = 0; + switch(last_colour_index++) + { + case 0: + colour = QColor(0, 69, 134); + break; + case 1: + colour = QColor(255, 66, 14); + break; + case 2: + colour = QColor(255, 211, 32); + break; + case 3: + colour = QColor(87, 157, 28); + break; + case 4: + colour = QColor(126, 0, 33); + break; + case 5: + colour = QColor(131, 202, 255); + break; + case 6: + colour = QColor(49, 64, 4); + break; + case 7: + colour = QColor(174, 207, 0); + break; + case 8: + colour = QColor(75, 31, 111); + break; + case 9: + colour = QColor(255, 149, 14); + break; + case 10: + colour = QColor(197, 00, 11); + break; + case 11: + colour = QColor(0, 132, 209); + + // Since this is the last colour in our table, reset the counter back + // to the first colour + last_colour_index = 0; + break; + default: + // NOTE: This shouldn't happen! + colour = QColor(0, 0, 0); + break; + } + } // Set colour - changeitem->setBackgroundColor(column, color); + changeitem->setBackgroundColor(column, colour); // Save settings for this table PlotSettings& plot_settings = browseTableSettings[current_table].plotYAxes[changeitem->text(PlotColumnField)]; - plot_settings.colour = color; + plot_settings.colour = colour; plot_settings.lineStyle = ui->comboLineType->currentIndex(); plot_settings.pointShape = (ui->comboPointShape->currentIndex() > 0 ? (ui->comboPointShape->currentIndex()+1) : ui->comboPointShape->currentIndex()); }