@@ -347,7 +347,7 @@ void MainWindow::setupGUI()
347
347
ui->comboBoxSerialReadMode ->addItem (" bytesAvailable | readAll" );
348
348
ui->comboBoxSerialReadMode ->setCurrentIndex (0 );
349
349
350
- updateDeviceList ();
350
+ updateSerialDeviceList ();
351
351
352
352
emit on_checkBoxShowLegend_toggled (ui->checkBoxShowLegend ->isChecked ());
353
353
@@ -416,7 +416,7 @@ void MainWindow::createTimers()
416
416
this ->serialStringProcessingTimer = new QTimer (this );
417
417
this ->udpStringProcessingTimer = new QTimer (this );
418
418
419
- connect (serialDeviceCheckTimer, SIGNAL (timeout ()), this , SLOT (updateDeviceList ()));
419
+ connect (serialDeviceCheckTimer, SIGNAL (timeout ()), this , SLOT (updateSerialDeviceList ()));
420
420
connect (radioButtonTimer, &QTimer::timeout, this , [=]() { ui->radioButtonDeviceUpdate ->setChecked (false ); });
421
421
}
422
422
@@ -480,7 +480,7 @@ void MainWindow::createChart()
480
480
if (ui->checkBoxEnableTracer ->isChecked ())
481
481
{
482
482
createChartTracer ();
483
- connect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (showPointValue (QMouseEvent *)));
483
+ connect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (tracerShowPointValue (QMouseEvent *)));
484
484
}
485
485
}
486
486
@@ -497,7 +497,7 @@ void MainWindow::chartBeforeReplotSlot()
497
497
498
498
if (ui->checkBoxAutoRescaleY ->isChecked ())
499
499
{
500
- bool atLeastOneGraphVisible = false , atLeastOneNotFlat = false ;
500
+ bool atLeastOneGraphVisible = false , atLeastOneGraphIsNotFlat = false ;
501
501
502
502
for (auto i = 0 ; i < ui->widgetChart ->graphCount (); ++i)
503
503
{
@@ -508,26 +508,25 @@ void MainWindow::chartBeforeReplotSlot()
508
508
bool foundRange = false ;
509
509
QCPRange valueRange = ui->widgetChart ->graph (i)->data ().data ()->valueRange (foundRange);
510
510
511
- if (foundRange && abs (valueRange.upper - valueRange.lower ) >= 0.1 )
512
- atLeastOneNotFlat = true ;
511
+ if (foundRange == true && abs (valueRange.upper - valueRange.lower ) >= 0.1 )
512
+ atLeastOneGraphIsNotFlat = true ;
513
513
}
514
514
}
515
515
516
- if (atLeastOneGraphVisible && atLeastOneNotFlat )
516
+ if (atLeastOneGraphVisible && atLeastOneGraphIsNotFlat )
517
517
{
518
518
ui->widgetChart ->yAxis ->rescale (true );
519
- ui->widgetChart ->yAxis ->scaleRange (1.20 );
519
+ ui->widgetChart ->yAxis ->scaleRange (1.20 ); // leave some space at the top and buttom of the chart.
520
520
}
521
521
}
522
522
}
523
523
else
524
524
{
525
- // if (ui->widgetChart->graph()->visible() == false)
526
- // ui->widgetChart->rescaleAxes();
525
+ // do nothing ?
527
526
}
528
527
}
529
528
530
- void MainWindow::chartContextMenuRequest (QPoint pos)
529
+ void MainWindow::chartContextMenuRequest (QPoint pos) // right click on chart
531
530
{
532
531
QMenu *menu = new QMenu (this );
533
532
menu->setAttribute (Qt::WA_DeleteOnClose);
@@ -579,6 +578,7 @@ void MainWindow::chartContextMenuRequest(QPoint pos)
579
578
void MainWindow::showSelectedGraphExclusively ()
580
579
{
581
580
hideAllGraphs ();
581
+
582
582
for (auto i = 0 ; i < ui->widgetChart ->graphCount (); ++i)
583
583
{
584
584
if (ui->widgetChart ->graph (i)->selected () || ui->widgetChart ->legend ->item (i)->selected ())
@@ -687,7 +687,7 @@ void MainWindow::chartSelectionChanged()
687
687
}
688
688
}
689
689
690
- void MainWindow::showPointValue (QMouseEvent *event)
690
+ void MainWindow::tracerShowPointValue (QMouseEvent *event)
691
691
{
692
692
if (ui->widgetChart ->graphCount () < 1 )
693
693
return ;
@@ -740,14 +740,12 @@ void MainWindow::chartMousePressHandler(QMouseEvent *event)
740
740
ui->widgetChart ->replot ();
741
741
}
742
742
743
- void MainWindow::updateDeviceList ()
743
+ void MainWindow::updateSerialDeviceList ()
744
744
{
745
- QList<QSerialPortInfo> devices;
745
+ QList<QSerialPortInfo> devices = QSerialPortInfo::availablePorts () ;
746
746
QList<QString> portNames;
747
747
static QList<QString> portNamesOld;
748
748
749
- devices = QSerialPortInfo::availablePorts ();
750
-
751
749
foreach (auto item, devices)
752
750
{
753
751
portNames.append (item.portName ());
@@ -777,9 +775,9 @@ void MainWindow::updateDeviceList()
777
775
778
776
void MainWindow::on_pushButtonRefresh_clicked ()
779
777
{
780
- qDebug () << " Szukam urządzeń COM ..." ;
781
- this ->addLog (" >>\t Searching for COM ports..." );
782
- this ->updateDeviceList ();
778
+ qDebug () << " Refreshing serial device list ..." ;
779
+ this ->addLog (" App >>\t Searching for COM ports..." );
780
+ this ->updateSerialDeviceList ();
783
781
}
784
782
785
783
void MainWindow::addLog (QString text)
@@ -822,6 +820,7 @@ void MainWindow::processSerial()
822
820
}
823
821
}
824
822
823
+ // TODO
825
824
void MainWindow::writeLogToFile (QString rawLine, QStringList labelList, QList<double > dataList, QList<long > timeList)
826
825
{
827
826
if (ui->pushButtonLogging ->isChecked ()) // Write log into file
@@ -908,15 +907,15 @@ void MainWindow::processChart(QStringList labelList, QList<double> numericDataLi
908
907
{
909
908
if (labelList[j] == ui->widgetChart ->graph (i)->name ()) // If label matches the graphs name - we can start add points to it
910
909
{
911
- if (timeStampsList[j] > 0 ) // if == 0 then we assume taht no external clock was parsed propely
910
+ if (timeStampsList[j] > 0 ) // if == 0 then we assume that no external clock was parsed propely
912
911
ui->widgetChart ->graph (i)->addData (timeStampsList[j] / 1000.0 , numericDataList[j]);
913
912
914
- // break; // we keep checking for duplicates so we can add multiple points at once
913
+ // break; // no break - slower but if we keep checking for duplicates, we can add multiple points at once
915
914
}
916
915
}
917
916
918
917
if (ui->spinBoxMaxTimeRange ->value () > 0 )
919
- ui->widgetChart ->graph (i)->data ().data ()->removeBefore ((timeStampsList.last () / 1000.0 ) - ui->spinBoxMaxTimeRange ->value ()); // Remove old samples
918
+ ui->widgetChart ->graph (i)->data ().data ()->removeBefore ((timeStampsList.last () / 1000.0 ) - ui->spinBoxMaxTimeRange ->value ()); // Remove old points
920
919
921
920
if (ui->spinBoxRemoveOldLabels ->value () > 0 )
922
921
{
@@ -928,7 +927,7 @@ void MainWindow::processChart(QStringList labelList, QList<double> numericDataLi
928
927
if (missingCount[i] > ui->spinBoxRemoveOldLabels ->value ())
929
928
{
930
929
ui->widgetChart ->removeGraph (i);
931
- missingCount.removeAt (i);
930
+ missingCount.removeAt (i); // Remove entry for this label
932
931
}
933
932
}
934
933
}
@@ -1023,7 +1022,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
1023
1022
}
1024
1023
}
1025
1024
1026
- if (event->key () == Qt::Key_F1)
1025
+ if (event->key () == Qt::Key:: Key_F1)
1027
1026
{
1028
1027
QWhatsThis::enterWhatsThisMode ();
1029
1028
}
@@ -1114,11 +1113,11 @@ void MainWindow::on_checkBoxEnableTracer_toggled(bool checked)
1114
1113
if (checked)
1115
1114
{
1116
1115
createChartTracer ();
1117
- connect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (showPointValue (QMouseEvent *)));
1116
+ connect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (tracerShowPointValue (QMouseEvent *)));
1118
1117
}
1119
1118
else
1120
1119
{
1121
- disconnect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (showPointValue (QMouseEvent *)));
1120
+ disconnect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (tracerShowPointValue (QMouseEvent *)));
1122
1121
delete phaseTracer;
1123
1122
phaseTracer = nullptr ;
1124
1123
}
@@ -1286,13 +1285,13 @@ void MainWindow::on_comboBoxTracerStyle_currentIndexChanged(const QString &arg1)
1286
1285
{
1287
1286
if (phaseTracer != nullptr )
1288
1287
{
1289
- disconnect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (showPointValue (QMouseEvent *)));
1288
+ disconnect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (tracerShowPointValue (QMouseEvent *)));
1290
1289
delete phaseTracer;
1291
1290
phaseTracer = nullptr ;
1292
1291
}
1293
1292
1294
1293
createChartTracer ();
1295
- connect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (showPointValue (QMouseEvent *)));
1294
+ connect (ui->widgetChart , SIGNAL (mouseMove (QMouseEvent *)), this , SLOT (tracerShowPointValue (QMouseEvent *)));
1296
1295
1297
1296
ui->widgetChart ->replot ();
1298
1297
}
@@ -1304,8 +1303,8 @@ void MainWindow::on_pushButtonSerialConnect_toggled(bool checked)
1304
1303
{
1305
1304
if (serial.getAvailiblePortsCount () < 1 )
1306
1305
{
1307
- addLog (" >>\t No devices available" );
1308
- addLog (" >>\t Unable to open serial port!" );
1306
+ addLog (" App >>\t No devices available" );
1307
+ addLog (" App >>\t Unable to open serial port!" );
1309
1308
ui->pushButtonSerialConnect ->setChecked (false );
1310
1309
return ;
1311
1310
}
@@ -1329,13 +1328,13 @@ void MainWindow::on_pushButtonSerialConnect_toggled(bool checked)
1329
1328
1330
1329
connect (serialStringProcessingTimer, SIGNAL (timeout ()), this , SLOT (processSerial ()));
1331
1330
1332
- addLog (" >>\t Serial port opened. " + serial.getSerialInfo () + " DTR: " + QString::number (ui->checkBoxDTR ->isChecked ()));
1331
+ addLog (" App >>\t Serial port opened. " + serial.getSerialInfo () + " DTR: " + QString::number (ui->checkBoxDTR ->isChecked ()));
1333
1332
ui->pushButtonSerialConnect ->setText (" Disconnect" );
1334
1333
}
1335
1334
else
1336
1335
{
1337
1336
ui->pushButtonSerialConnect ->setChecked (false );
1338
- addLog (" >>\t Unable to open serial port!" );
1337
+ addLog (" App >>\t Unable to open serial port!" );
1339
1338
}
1340
1339
}
1341
1340
else
@@ -1346,13 +1345,13 @@ void MainWindow::on_pushButtonSerialConnect_toggled(bool checked)
1346
1345
1347
1346
if (serial.end ())
1348
1347
{
1349
- addLog (" >>\t Connection closed." );
1348
+ addLog (" App >>\t Connection closed." );
1350
1349
ui->pushButtonSerialConnect ->setText (" Connect" );
1351
1350
}
1352
1351
else
1353
1352
{
1354
1353
ui->pushButtonSerialConnect ->setChecked (true );
1355
- addLog (" >>\t ERROR: Unable to close cennection !" );
1354
+ addLog (" App >>\t ERROR: Unable to close cennection !" );
1356
1355
}
1357
1356
1358
1357
if (!ui->pushButtonSerialConnect ->isChecked () && !ui->pushButtonUDPConnect ->isChecked ())
@@ -1367,6 +1366,7 @@ void MainWindow::on_actionSave_As_triggered()
1367
1366
1368
1367
if (fileName.isEmpty ())
1369
1368
{
1369
+ addLog (" App >>\t Saving file aborted - filename not specified." );
1370
1370
return ;
1371
1371
}
1372
1372
else
@@ -1415,7 +1415,7 @@ void MainWindow::on_actionPlotter_triggered()
1415
1415
1416
1416
void MainWindow::on_action3D_orientation_triggered ()
1417
1417
{
1418
- // ui->stackedWidget->setCurrentIndex(1);
1418
+ // ui->stackedWidget->setCurrentIndex(1); // WIP
1419
1419
}
1420
1420
1421
1421
void MainWindow::printPlot (QPrinter *printer)
@@ -1511,13 +1511,13 @@ void MainWindow::on_pushButtonUDPConnect_toggled(bool checked)
1511
1511
1512
1512
connect (udpStringProcessingTimer, SIGNAL (timeout ()), this , SLOT (processUDP ()));
1513
1513
1514
- addLog (" >>\t UDP port opened." );
1514
+ addLog (" App >>\t UDP port opened." );
1515
1515
1516
1516
ui->pushButtonUDPConnect ->setText (" Close Connection" );
1517
1517
}
1518
1518
else
1519
1519
{
1520
- addLog (" >>\t UDP error. Unable to bind" );
1520
+ addLog (" App >>\t UDP error. Unable to bind" );
1521
1521
}
1522
1522
}
1523
1523
else
@@ -1526,7 +1526,7 @@ void MainWindow::on_pushButtonUDPConnect_toggled(bool checked)
1526
1526
{
1527
1527
udpStringProcessingTimer->stop ();
1528
1528
1529
- addLog (" >>\t UDP port closed." );
1529
+ addLog (" App >>\t UDP port closed." );
1530
1530
1531
1531
disconnect (udpStringProcessingTimer, SIGNAL (timeout ()), this , SLOT (processUDP ()));
1532
1532
@@ -1542,7 +1542,7 @@ void MainWindow::sendDatagram(QString message)
1542
1542
{
1543
1543
if (!networkUDP.isOpen ())
1544
1544
{
1545
- addLog (" UDP \t Unable to send. Port closed." );
1545
+ addLog (" App >> \t Unable to send - port closed." );
1546
1546
return ;
1547
1547
}
1548
1548
@@ -1559,7 +1559,7 @@ void MainWindow::sendDatagram(QString message)
1559
1559
networkUDP.write (message, QHostAddress (ui->lineEditUDPTargetIP ->text ()), ui->spinBoxUDPTargetPort ->value ());
1560
1560
}
1561
1561
1562
- addLog (" UDP >>\t " + message);
1562
+ addLog (" App >>\t " + message);
1563
1563
}
1564
1564
1565
1565
void MainWindow::on_comboBoxUDPSendMode_currentIndexChanged (const QString &arg1)
@@ -1597,7 +1597,7 @@ void MainWindow::on_pushButtonLogging_toggled(bool checked)
1597
1597
{
1598
1598
if (ui->checkBoxAutoLogging ->isChecked () == false && ui->lineEditSaveFileName ->text ().isEmpty ())
1599
1599
{
1600
- addLog (" Logger - Filename not specified !" );
1600
+ addLog (" App >> \t logger error - filename not specified !" );
1601
1601
ui->pushButtonLogging ->setChecked (false );
1602
1602
return ;
1603
1603
}
@@ -1608,7 +1608,7 @@ void MainWindow::on_pushButtonLogging_toggled(bool checked)
1608
1608
{
1609
1609
if (!fileLogger.beginLog (ui->lineEditSaveLogPath ->text (), ui->checkBoxAutoLogging ->isChecked (), ui->lineEditSaveFileName ->text ()))
1610
1610
{
1611
- addLog (" Logger - Unable to open File" );
1611
+ addLog (" App >> \t logger error - unable to open File" );
1612
1612
ui->pushButtonLogging ->setChecked (false );
1613
1613
return ;
1614
1614
}
0 commit comments