Skip to content

Commit e177668

Browse files
Replaced help bubbles with "What's this?" button
1 parent 7e9025d commit e177668

File tree

4 files changed

+794
-326
lines changed

4 files changed

+794
-326
lines changed

mainwindow.cpp

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <QScrollBar>
1717
#include <QCursor>
1818
#include <QColorDialog>
19+
#include <QWhatsThis>
1920

2021
//#include <opencv2/ximgproc.hpp>
2122

@@ -91,6 +92,11 @@ void MainWindow::on_button_quit_clicked()
9192
QCoreApplication::quit();
9293
}
9394

95+
void MainWindow::on_button_whats_this_clicked() // What's this function
96+
{
97+
QWhatsThis::enterWhatsThisMode();
98+
}
99+
94100
void MainWindow::on_Tabs_currentChanged(int) // when a tab is clicked
95101
{
96102
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
544550

545551
void MainWindow::on_button_image_clicked() // Load main image
546552
{
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
548555
if (filename.isNull() || filename.isEmpty()) // cancel ?
549556
return;
550557

@@ -630,7 +637,7 @@ void MainWindow::on_button_save_session_clicked() // save session files
630637
return;
631638
}
632639

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
634641

635642
if (filename.isNull() || filename.isEmpty()) // cancel ?
636643
return;
@@ -716,7 +723,7 @@ void MainWindow::on_button_load_session_clicked() // load previous session
716723
//if (image.empty()) // image mandatory
717724
// return;
718725

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)"));
720727

721728
if (filename.isNull() || filename.isEmpty()) // cancel ?
722729
return;
@@ -863,7 +870,7 @@ void MainWindow::on_button_load_session_clicked() // load previous session
863870

864871
void MainWindow::on_button_save_conf_clicked() // save configuration
865872
{
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)"));
867874
if (filename.isNull() || filename.isEmpty()) // cancel ?
868875
return;
869876

@@ -940,7 +947,7 @@ void MainWindow::on_button_save_conf_clicked() // save configuration
940947

941948
void MainWindow::on_button_load_conf_clicked() // load configuration
942949
{
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
944951
if (filename.isNull()) // cancel ?
945952
return;
946953

@@ -1464,23 +1471,15 @@ void MainWindow::on_pushButton_color_laurel_clicked() // Laurel
14641471
ShowCurrentColor(color[2], color[1], color[0]);
14651472
}
14661473

1467-
/////////////////// Key events //////////////////////
1474+
/////////////////// Keyboard events //////////////////////
14681475

14691476
void MainWindow::keyReleaseEvent(QKeyEvent *keyEvent) // draw cell mode and move view + show holes
14701477
{
14711478
if (!loaded) return;// no image = get out
14721479

14731480
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
14841483
}
14851484

14861485
if (!computed) return;// no labels = get out
@@ -1544,9 +1543,25 @@ void MainWindow::keyPressEvent(QKeyEvent *keyEvent) //
15441543
if (!loaded) return;// no image = get out
15451544

15461545
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;
15481558

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+
}
15501565
}
15511566

15521567
if (!computed) return;// no labels = get out

mainwindow.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ public slots:
4040

4141
private slots:
4242

43-
//// UI
43+
//// GUI
4444
void InitializeValues(); // well named !
45+
void on_button_whats_this_clicked(); // What's this function
4546

4647
//// quit
4748
void on_button_quit_clicked();
@@ -59,11 +60,12 @@ private slots:
5960
void on_listWidget_labels_itemChanged(QListWidgetItem *currentItem); // show current label name used
6061
void on_pushButton_label_add_clicked(); // add one default label
6162
void on_pushButton_label_hide_clicked(); // set label color to 0 => transparent
62-
void on_pushButton_label_create_clicked(); // special mode where a new cell can be drawn
63+
void on_pushButton_label_draw_clicked(); // special mode where a new cell can be drawn
6364
void on_pushButton_label_join_clicked(); // join two or more labels
64-
void on_pushButton_draw_clear_clicked();
65-
void on_pushButton_draw_grabcut_clicked();
66-
cv::Vec3b DrawColor();
65+
void on_pushButton_draw_clear_clicked(); // clear the cell drawing mask
66+
void on_pushButton_draw_grabcut_clicked(); // use GrabCut in cell drawing mode
67+
void on_pushButton_draw_grabcut_iteration_clicked(); // repeat GrabCut in cell drawing mode
68+
cv::Vec3b DrawColor(); // return drawing color in cell drawing mode
6769

6870
//// image export
6971
void on_pushButton_psd_clicked(); // export to PSD Photoshop image
@@ -88,6 +90,7 @@ private slots:
8890
void on_checkBox_mask_clicked(); // toggle mask view
8991
void on_checkBox_image_clicked(); // toggle image view
9092
void on_checkBox_grid_clicked(); // toggle grid view
93+
void on_checkBox_selection_clicked(); // toggle selection view
9194
void on_checkBox_holes_clicked(); // toggle holes view
9295

9396
void on_horizontalSlider_blend_image_valueChanged(); // image transparency
@@ -179,7 +182,8 @@ private slots:
179182
mask, undo_mask, // painted cells
180183
grid, // grid mask
181184
selection, // selection mask
182-
/*create_cell_labels_save,*/ create_cell_mask_save, mask_line_save; // used by cell paint
185+
draw_cell_mask_save, draw_cell_labels_mask_save, draw_cell_labels_save, draw_cell_grid_save, mask_line_save, // used by cell paint
186+
grabcut_mask, grabcut_background, grabcut_foreground; // for GrabCut
183187

184188
cv::Mat disp_color; // Processed image display with mask and grid
185189
cv::Rect viewport; // part of the segmentation image to display

0 commit comments

Comments
 (0)