feat(cpn): make it possible to use same scale in Log Viewer graph (#6818)
This commit is contained in:
@@ -124,7 +124,13 @@ LogsDialog::LogsDialog(QWidget *parent) :
|
||||
connect(ui->customPlot, &QCustomPlot::legendDoubleClick, this, &LogsDialog::legendDoubleClick);
|
||||
connect(ui->FieldsTW, &QTableWidget::itemSelectionChanged, this, &LogsDialog::plotLogs);
|
||||
connect(ui->logTable, &QTableWidget::itemSelectionChanged, this, &LogsDialog::plotLogs);
|
||||
connect(ui->Reset_PB, &QPushButton::clicked, this, &LogsDialog::plotLogs);
|
||||
connect(ui->Reset_PB, &QPushButton::clicked, this, [this]() {
|
||||
ui->ZoomX_ChkB->setChecked(false);
|
||||
ui->ZoomY_ChkB->setChecked(false);
|
||||
ui->CommonAxes_ChkB->setChecked(false);
|
||||
plotLogs();
|
||||
});
|
||||
connect(ui->CommonAxes_ChkB, &QPushButton::clicked, this, &LogsDialog::plotLogs);
|
||||
connect(ui->SaveSession_PB, &QPushButton::clicked, this, &LogsDialog::saveSession);
|
||||
connect(ui->fileOpen_PB, &QPushButton::clicked, this, &LogsDialog::fileOpen);
|
||||
connect(ui->mapsButton, &QPushButton::clicked, this, &LogsDialog::mapsButtonClicked);
|
||||
@@ -822,6 +828,50 @@ void LogsDialog::sessionsCurrentIndexChanged(int index)
|
||||
plotLogs();
|
||||
}
|
||||
|
||||
std::pair<double, double> LogsDialog::GetMinMaxY() const
|
||||
{
|
||||
double minVal = 0.0;
|
||||
double maxVal = 0.0;
|
||||
bool found = false;
|
||||
|
||||
// determine selected rows in the log table
|
||||
QModelIndexList sel = ui->logTable->selectionModel()->selectedRows();
|
||||
bool hasSelection = !sel.isEmpty();
|
||||
QVarLengthArray<int> selectedRows;
|
||||
|
||||
if (hasSelection) {
|
||||
selectedRows.reserve(sel.size());
|
||||
for (const QModelIndex &idx : sel) selectedRows.append(idx.row());
|
||||
}
|
||||
|
||||
// iterate over selected fields and rows to compute global min/max Y
|
||||
for (QTableWidgetItem *fieldItem : ui->FieldsTW->selectedItems()) {
|
||||
const int col = fieldItem->row() + 2; // Date and Time are first two columns
|
||||
const int rows = hasSelection ? selectedRows.length() : ui->logTable->rowCount();
|
||||
|
||||
for (int r = 0; r < rows; ++r) {
|
||||
const int tableRow = hasSelection ? selectedRows.at(r) : r;
|
||||
QTableWidgetItem *cell = ui->logTable->item(tableRow, col);
|
||||
if (!cell) continue;
|
||||
|
||||
bool ok = false;
|
||||
const double v = cell->text().toDouble(&ok);
|
||||
if (!ok) continue;
|
||||
|
||||
if (!found) {
|
||||
minVal = maxVal = v;
|
||||
found = true;
|
||||
} else {
|
||||
if (v < minVal) minVal = v;
|
||||
if (v > maxVal) maxVal = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) return {0.0, 0.0};
|
||||
return {minVal, maxVal};
|
||||
}
|
||||
|
||||
void LogsDialog::plotLogs()
|
||||
{
|
||||
if (plotLock) return;
|
||||
@@ -836,6 +886,7 @@ void LogsDialog::plotLogs()
|
||||
QModelIndexList selection = ui->logTable->selectionModel()->selectedRows();
|
||||
int rowCount = selection.length();
|
||||
bool hasLogSelection;
|
||||
bool useCommonAxes = ui->CommonAxes_ChkB->isChecked();
|
||||
QVarLengthArray<int> selectedRows;
|
||||
|
||||
if (rowCount) {
|
||||
@@ -922,23 +973,25 @@ void LogsDialog::plotLogs()
|
||||
plots.coords.at(i).max_y < yAxesRanges[plots.coords.at(i).yaxis].min)
|
||||
) {
|
||||
|
||||
switch (plots.coords[i].yaxis) {
|
||||
case firstLeft:
|
||||
plots.coords[i].yaxis = firstRight;
|
||||
break;
|
||||
case firstRight:
|
||||
plots.coords[i].yaxis = secondLeft;
|
||||
break;
|
||||
case secondLeft:
|
||||
plots.coords[i].yaxis = secondRight;
|
||||
break;
|
||||
case secondRight:
|
||||
plots.tooManyRanges = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (!useCommonAxes) {
|
||||
switch (plots.coords[i].yaxis) {
|
||||
case firstLeft:
|
||||
plots.coords[i].yaxis = firstRight;
|
||||
break;
|
||||
case firstRight:
|
||||
plots.coords[i].yaxis = secondLeft;
|
||||
break;
|
||||
case secondLeft:
|
||||
plots.coords[i].yaxis = secondRight;
|
||||
break;
|
||||
case secondRight:
|
||||
plots.tooManyRanges = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (plots.tooManyRanges) break;
|
||||
}
|
||||
if (plots.tooManyRanges) break;
|
||||
|
||||
actualRange = yAxesRanges[plots.coords.at(i).yaxis].max
|
||||
- yAxesRanges[plots.coords.at(i).yaxis].min;
|
||||
@@ -986,9 +1039,12 @@ void LogsDialog::plotLogs()
|
||||
removeAllGraphs();
|
||||
|
||||
axisRect->axis(QCPAxis::atBottom)->setRange(plots.min_x, plots.max_x);
|
||||
|
||||
axisRect->axis(QCPAxis::atLeft)->setRange(yAxesRanges[firstLeft].min,
|
||||
yAxesRanges[firstLeft].max);
|
||||
if (useCommonAxes) {
|
||||
auto [min, max] = this->GetMinMaxY();
|
||||
axisRect->axis(QCPAxis::atLeft)->setRange(min, max);
|
||||
} else {
|
||||
axisRect->axis(QCPAxis::atLeft)->setRange(yAxesRanges[firstLeft].min, yAxesRanges[firstLeft].max);
|
||||
}
|
||||
|
||||
if (plots.tooManyRanges) {
|
||||
axisRect->axis(QCPAxis::atLeft)->setTickLabels(false);
|
||||
|
||||
@@ -82,6 +82,7 @@ private slots:
|
||||
void sessionsCurrentIndexChanged(int index);
|
||||
void mapsButtonClicked();
|
||||
void yAxisChangeRanges(QCPRange range);
|
||||
std::pair<double, double> GetMinMaxY() const;
|
||||
|
||||
private:
|
||||
QList<QStringList> csvlog;
|
||||
|
||||
@@ -167,7 +167,36 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item>
|
||||
<widget class="QWidget" name="spacer">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="CommonAxes_ChkB">
|
||||
<property name="text">
|
||||
<string>Use common Y axis</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="Reset_PB">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
@@ -341,6 +370,7 @@
|
||||
<tabstop>mapsButton</tabstop>
|
||||
<tabstop>ZoomX_ChkB</tabstop>
|
||||
<tabstop>ZoomY_ChkB</tabstop>
|
||||
<tabstop>CommonAxes_ChkB</tabstop>
|
||||
<tabstop>Reset_PB</tabstop>
|
||||
<tabstop>sessions_CB</tabstop>
|
||||
</tabstops>
|
||||
|
||||
@@ -6967,12 +6967,17 @@ Are you sure ?</source>
|
||||
<translation>Prohlížeč logu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Použít společnou osu Y</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>Soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>Otevřít</translation>
|
||||
</message>
|
||||
|
||||
@@ -7035,12 +7035,17 @@ Er du sikker?</translation>
|
||||
<translation>Companion log viser</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Brug fælles Y-akse</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>Filnavn</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>Åbn logfil</translation>
|
||||
</message>
|
||||
|
||||
@@ -6967,12 +6967,17 @@ Sind Sie sicher?</translation>
|
||||
<translation>Companion Log ansehen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Gemeinsame Y-Achse verwenden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>Dateiname</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>Öffne LogDatei</translation>
|
||||
</message>
|
||||
|
||||
@@ -6921,12 +6921,17 @@ Are you sure ?</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
|
||||
@@ -7032,12 +7032,17 @@ Esta función no puede ser deshabilitada en la radio.
|
||||
<translation>Visor de registros de Companion</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Usar eje Y común</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>Nombre archivo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>Abrir archivo registros</translation>
|
||||
</message>
|
||||
|
||||
@@ -7020,12 +7020,17 @@ Are you sure ?</source>
|
||||
<translation type="unfinished">Companion logit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Käytä yhteistä Y-akselia</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation type="unfinished">Tiedoston nimi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation type="unfinished">Avaa logi</translation>
|
||||
</message>
|
||||
|
||||
@@ -7025,12 +7025,17 @@ Cette fonction ne peut pas être désactivée sur la radio.
|
||||
<translation>Visualiseur de Log</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Utiliser un axe Y commun</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>Nom de fichier</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>Ouvrir fichier de Log</translation>
|
||||
</message>
|
||||
|
||||
@@ -6891,12 +6891,17 @@ Are you sure ?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>השתמש בציר Y משותף</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
||||
@@ -7015,12 +7015,17 @@ Are you sure ?</source>
|
||||
<translation type="unfinished">Visualizzatore di Log di Companion</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Usa l’asse Y comune</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation type="unfinished">Nome file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation type="unfinished">Apri file di log</translation>
|
||||
</message>
|
||||
|
||||
@@ -7046,14 +7046,19 @@ Are you sure ?</source>
|
||||
<location filename="../logsdialog.ui" line="173"/>
|
||||
<source>Reset</source>
|
||||
<translation>リセット</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>共通の Y 軸を使用する</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>ファイル名</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>ログファイルを開く</translation>
|
||||
</message>
|
||||
|
||||
@@ -7053,14 +7053,19 @@ Are you sure ?</source>
|
||||
<location filename="../logsdialog.ui" line="173"/>
|
||||
<source>Reset</source>
|
||||
<translation>초기화</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>공통 Y축 사용</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>파일 이름</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>로그 파일 열기</translation>
|
||||
</message>
|
||||
|
||||
@@ -6891,12 +6891,17 @@ Are you sure ?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Gemeenschappelijke Y-as gebruiken</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
||||
@@ -6998,12 +6998,17 @@ Are you sure ?</source>
|
||||
<translation>Companion przegląd logów</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Użyj wspólnej osi Y</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>Nazwa pliku</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>Otwórz plik logów</translation>
|
||||
</message>
|
||||
|
||||
@@ -6891,12 +6891,17 @@ Are you sure ?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Usar eixo Y comum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
||||
@@ -7092,12 +7092,17 @@ att fungera. Detta går inte att ändra från radion.
|
||||
<translation>Companion loggläsare</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>Använd gemensam Y-axel</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>Filnamn</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>Öppna loggfil</translation>
|
||||
</message>
|
||||
|
||||
@@ -7110,12 +7110,12 @@ Are you sure ?</source>
|
||||
<translation>重设</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>文件名</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>打开 Log 文件</translation>
|
||||
</message>
|
||||
|
||||
@@ -7108,14 +7108,19 @@ Are you sure ?</source>
|
||||
<location filename="../logsdialog.ui" line="173"/>
|
||||
<source>Reset</source>
|
||||
<translation>重設</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="197"/>
|
||||
<source>Use common Y axis</source>
|
||||
<translation>使用共同的 Y 軸</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="232"/>
|
||||
<location filename="../logsdialog.ui" line="243"/>
|
||||
<source>Filename</source>
|
||||
<translation>文件名</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../logsdialog.ui" line="246"/>
|
||||
<location filename="../logsdialog.ui" line="257"/>
|
||||
<source>Open LogFile</source>
|
||||
<translation>打開 Log 文件</translation>
|
||||
</message>
|
||||
|
||||
Reference in New Issue
Block a user