|
16 | 16 | #include <QScrollBar>
|
17 | 17 | #include <QCursor>
|
18 | 18 | #include <QColorDialog>
|
| 19 | +#include <QWhatsThis> |
19 | 20 |
|
20 | 21 | //#include <opencv2/ximgproc.hpp>
|
21 | 22 |
|
@@ -91,6 +92,11 @@ void MainWindow::on_button_quit_clicked()
|
91 | 92 | QCoreApplication::quit();
|
92 | 93 | }
|
93 | 94 |
|
| 95 | +void MainWindow::on_button_whats_this_clicked() // What's this function |
| 96 | +{ |
| 97 | + QWhatsThis::enterWhatsThisMode(); |
| 98 | +} |
| 99 | + |
94 | 100 | void MainWindow::on_Tabs_currentChanged(int) // when a tab is clicked
|
95 | 101 | {
|
96 | 102 | if(ui->Tabs->currentIndex()==2) ui->label_segmentation->setCursor(Qt::PointingHandCursor); // labels tab ? => labels view cursor
|
@@ -544,7 +550,8 @@ void MainWindow::SavePSDorTIF(std::string type) // save image + layers to PSD or
|
544 | 550 |
|
545 | 551 | void MainWindow::on_button_image_clicked() // Load main image
|
546 | 552 | {
|
547 |
| - QString filename = QFileDialog::getOpenFileName(this, "Select picture file", QString::fromStdString(basedir), "Images (*.jpg *.JPG *.jpeg *.JPEG *.jp2 *.JP2 *.png *.PNG *.tif *.TIF *.tiff *.TIFF *.bmp *.BMP)"); // image filename |
| 553 | + QString filename = QFileDialog::getOpenFileName(this, "Select picture file", QString::fromStdString(basedir), |
| 554 | + tr("Images (*.jpg *.jpeg *.jp2 *.png *.tif *.tiff)")); // image filename |
548 | 555 | if (filename.isNull() || filename.isEmpty()) // cancel ?
|
549 | 556 | return;
|
550 | 557 |
|
@@ -630,7 +637,7 @@ void MainWindow::on_button_save_session_clicked() // save session files
|
630 | 637 | return;
|
631 | 638 | }
|
632 | 639 |
|
633 |
| - QString filename = QFileDialog::getSaveFileName(this, "Save session to XML file...", "./" + QString::fromStdString(basedir + basefile + "-segmentation-data.xml"), "*.xml *.XML"); // filename |
| 640 | + QString filename = QFileDialog::getSaveFileName(this, "Save session to XML file...", "./" + QString::fromStdString(basedir + basefile + "-segmentation-data.xml"), tr("XML (*.xml)")); // filename |
634 | 641 |
|
635 | 642 | if (filename.isNull() || filename.isEmpty()) // cancel ?
|
636 | 643 | return;
|
@@ -716,7 +723,7 @@ void MainWindow::on_button_load_session_clicked() // load previous session
|
716 | 723 | //if (image.empty()) // image mandatory
|
717 | 724 | // return;
|
718 | 725 |
|
719 |
| - QString filename = QFileDialog::getOpenFileName(this, "Load session from XML file...", QString::fromStdString(basedir), "*.xml *.XML"); |
| 726 | + QString filename = QFileDialog::getOpenFileName(this, "Load session from XML file...", QString::fromStdString(basedir), tr("XML (*.xml)")); |
720 | 727 |
|
721 | 728 | if (filename.isNull() || filename.isEmpty()) // cancel ?
|
722 | 729 | return;
|
@@ -863,7 +870,7 @@ void MainWindow::on_button_load_session_clicked() // load previous session
|
863 | 870 |
|
864 | 871 | void MainWindow::on_button_save_conf_clicked() // save configuration
|
865 | 872 | {
|
866 |
| - QString filename = QFileDialog::getSaveFileName(this, "Save configuration to XML file...", "./" + QString::fromStdString(basedir + basefile + "-segmentation-conf.xml")); |
| 873 | + QString filename = QFileDialog::getSaveFileName(this, "Save configuration to XML file...", "./" + QString::fromStdString(basedir + basefile + "-segmentation-conf.xml"), tr("XML (*.xml)")); |
867 | 874 | if (filename.isNull() || filename.isEmpty()) // cancel ?
|
868 | 875 | return;
|
869 | 876 |
|
@@ -940,7 +947,7 @@ void MainWindow::on_button_save_conf_clicked() // save configuration
|
940 | 947 |
|
941 | 948 | void MainWindow::on_button_load_conf_clicked() // load configuration
|
942 | 949 | {
|
943 |
| - QString filename = QFileDialog::getOpenFileName(this, "Select XML configuration file", QString::fromStdString(basedir + basefile + "-segmentation-conf.xml"), "XML parameters (*.xml *.XML)"); // filename |
| 950 | + QString filename = QFileDialog::getOpenFileName(this, "Select XML configuration file", QString::fromStdString(basedir + basefile + "-segmentation-conf.xml"), tr("XML (*.xml)")); // filename |
944 | 951 | if (filename.isNull()) // cancel ?
|
945 | 952 | return;
|
946 | 953 |
|
@@ -1464,23 +1471,15 @@ void MainWindow::on_pushButton_color_laurel_clicked() // Laurel
|
1464 | 1471 | ShowCurrentColor(color[2], color[1], color[0]);
|
1465 | 1472 | }
|
1466 | 1473 |
|
1467 |
| -/////////////////// Key events ////////////////////// |
| 1474 | +/////////////////// Keyboard events ////////////////////// |
1468 | 1475 |
|
1469 | 1476 | void MainWindow::keyReleaseEvent(QKeyEvent *keyEvent) // draw cell mode and move view + show holes
|
1470 | 1477 | {
|
1471 | 1478 | if (!loaded) return;// no image = get out
|
1472 | 1479 |
|
1473 | 1480 | if (keyEvent->key() == Qt::Key_Space) { // spacebar = move the view
|
1474 |
| - QPoint mouse_pos = QCursor::pos(); // current mouse position |
1475 |
| - |
1476 |
| - int decX = mouse_pos.x() - mouse_origin.x(); // distance from the first click |
1477 |
| - int decY = mouse_pos.y() - mouse_origin.y(); |
1478 |
| - |
1479 |
| - SetViewportXY(viewport.x - double(decX) / zoom, viewport.y - double(decY) / zoom); // update viewport |
1480 |
| - |
1481 |
| - ShowSegmentation(); // display result |
1482 |
| - |
1483 |
| - QApplication::restoreOverrideCursor(); // Restore cursor |
| 1481 | + if (!keyEvent->isAutoRepeat()) |
| 1482 | + QApplication::restoreOverrideCursor(); // Restore cursor |
1484 | 1483 | }
|
1485 | 1484 |
|
1486 | 1485 | if (!computed) return;// no labels = get out
|
@@ -1544,9 +1543,25 @@ void MainWindow::keyPressEvent(QKeyEvent *keyEvent) //
|
1544 | 1543 | if (!loaded) return;// no image = get out
|
1545 | 1544 |
|
1546 | 1545 | if (keyEvent->key() == Qt::Key_Space) { // spacebar = move the view
|
1547 |
| - mouse_origin = QCursor::pos(); // current mouse position |
| 1546 | + if (!keyEvent->isAutoRepeat()) { |
| 1547 | + mouse_origin = QCursor::pos(); // current mouse position |
| 1548 | + QApplication::setOverrideCursor(Qt::SizeAllCursor); // Move cursor |
| 1549 | + } |
| 1550 | + else { |
| 1551 | + QPoint mouse_pos = QCursor::pos(); // current mouse position |
| 1552 | + |
| 1553 | + int decX = mouse_pos.x() - mouse_origin.x(); // distance from the first click |
| 1554 | + int decY = mouse_pos.y() - mouse_origin.y(); |
| 1555 | + |
| 1556 | + if ((decX == 0) & (decY == 0)) |
| 1557 | + return; |
1548 | 1558 |
|
1549 |
| - QApplication::setOverrideCursor(Qt::SizeAllCursor); // Move cursor |
| 1559 | + SetViewportXY(viewport.x - double(decX) / zoom, viewport.y - double(decY) / zoom); // update viewport |
| 1560 | + |
| 1561 | + ShowSegmentation(); // display result |
| 1562 | + |
| 1563 | + mouse_origin = mouse_pos; |
| 1564 | + } |
1550 | 1565 | }
|
1551 | 1566 |
|
1552 | 1567 | if (!computed) return;// no labels = get out
|
|
0 commit comments