Skip to content

Commit 45c13f1

Browse files
authored
Stage (#124)
* Feature/default directory (#119) * Add count label * Use single default directory * Add count label (#121) * Add check for done status when ovewriting (#122) * Feature/feedback enhancements (#123) * Work on updating feedback types * Implement basic comment interface * Display comment in 2D view * Fix bug with setting done from region table * Add verified column, auto stretch comment column * Use delegate for line edit in feedback table * Finish feedback table updates * Add verified color, working on logic for done and verified * Finish logic for done and verified * Add done/verified logic to region table * Add search box * Disable changing done status via shortcut if verified, set verified color when loading * Remove console on windows
1 parent cf89866 commit 45c13f1

24 files changed

+504
-311
lines changed

CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if(POLICY CMP0020)
44
cmake_policy(SET CMP0020 NEW)
55
endif()
66

7-
set(SEGMENTOR_VERSION 0.4.1)
7+
set(SEGMENTOR_VERSION 0.4.2)
88

99
project(Segmentor VERSION ${SEGMENTOR_VERSION})
1010

@@ -67,8 +67,8 @@ set(UI_RESOURCES
6767
# Create executable
6868
qt5_wrap_ui(UISrcs ${UI_FILES} )
6969
# CMAKE_AUTOMOC is ON so the MOC headers will be automatically wrapped.
70-
#add_executable(Segmentor MACOSX_BUNDLE WIN32 ${CXX_FILES} ${UISrcs} ${QT_WRAP} ${UI_RESOURCES})
71-
add_executable(Segmentor MACOSX_BUNDLE ${CXX_FILES} ${UISrcs} ${QT_WRAP} ${UI_RESOURCES})
70+
add_executable(Segmentor MACOSX_BUNDLE WIN32 ${CXX_FILES} ${UISrcs} ${QT_WRAP} ${UI_RESOURCES})
71+
#add_executable(Segmentor MACOSX_BUNDLE ${CXX_FILES} ${UISrcs} ${QT_WRAP} ${UI_RESOURCES})
7272
qt5_use_modules(Segmentor Core Gui)
7373
target_link_libraries(Segmentor ${VTK_LIBRARIES})
7474
install(TARGETS Segmentor

qt/FeedbackDialog.cxx

+74-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,47 @@
11
#include "FeedbackDialog.h"
22

3-
#include "Feedback.h"
43
#include "FeedbackTable.h"
4+
#include "Region.h"
5+
#include "RegionCollection.h"
56
#include "VisualizationContainer.h"
67

8+
#include <QCompleter>
9+
#include <QDialogButtonBox>
10+
#include <QPushButton>
11+
#include <QShortcut>
12+
#include <QStandardItemModel>
13+
714
// Constructor
815
FeedbackDialog::FeedbackDialog(QWidget* parent, VisualizationContainer* visualizationContainer)
916
: QDialog(parent), visualizationContainer(visualizationContainer) {
1017
// Create the GUI from the Qt Designer file
1118
setupUi(this);
1219

20+
buttonBox->button(QDialogButtonBox::Close)->setAutoDefault(false);
21+
1322
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
1423

24+
// Search autocomplete
25+
labelModel = new QStandardItemModel(this);
26+
QCompleter* completer = new QCompleter(labelModel, this);
27+
searchLineEdit->setCompleter(completer);
28+
1529
// Create table
1630
table = new FeedbackTable(this);
1731
table->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
1832
table->update(visualizationContainer->GetRegions());
1933
tableContainer->layout()->addWidget(table);
2034

21-
QObject::connect(table, &FeedbackTable::regionFeedback, this, &FeedbackDialog::on_regionFeedback);
35+
QObject::connect(table, &FeedbackTable::regionComment, this, &FeedbackDialog::on_regionComment);
36+
QObject::connect(table, &FeedbackTable::regionDone, this, &FeedbackDialog::on_regionDone);
37+
QObject::connect(table, &FeedbackTable::regionVerified, this, &FeedbackDialog::on_regionVerified);
38+
QObject::connect(table, &FeedbackTable::selectRegion, this, &FeedbackDialog::on_selectRegion);
2239
QObject::connect(table, &FeedbackTable::highlightRegion, this, &FeedbackDialog::on_highlightRegion);
40+
QObject::connect(table, &FeedbackTable::countChanged, this, &FeedbackDialog::on_countChanged);
41+
42+
// Shortcut
43+
QShortcut* shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_V), this);
44+
QObject::connect(shortcut, &QShortcut::activated, this, &FeedbackDialog::on_verifiedShortcut);
2345

2446
updateRegions();
2547
}
@@ -29,19 +51,64 @@ FeedbackDialog::~FeedbackDialog() {
2951
}
3052

3153
void FeedbackDialog::updateRegions() {
32-
table->update(visualizationContainer->GetRegions());
54+
RegionCollection* regions = visualizationContainer->GetRegions();
55+
56+
// Update table
57+
table->update(regions);
58+
59+
// Update autocomplete
60+
labelModel->clear();
61+
for (RegionCollection::Iterator it = regions->Begin(); it != regions->End(); it++) {
62+
Region* region = regions->Get(it);
63+
64+
QStandardItem* item = new QStandardItem(QString::number(region->GetLabel()));
65+
66+
labelModel->appendRow(item);
67+
}
3368
}
3469

35-
void FeedbackDialog::on_filterCheckBox_stateChanged(int state) {
36-
printf("%d\n", state);
70+
void FeedbackDialog::updateRegion(Region* region) {
71+
table->update(region);
72+
}
73+
74+
void FeedbackDialog::selectRegionLabel(unsigned short label) {
75+
table->selectRegionLabel(label);
76+
}
77+
78+
void FeedbackDialog::on_searchLineEdit_editingFinished() {
79+
unsigned short label = searchLineEdit->text().toInt();
3780

81+
visualizationContainer->SelectRegion(label);
82+
}
83+
84+
void FeedbackDialog::on_filterCheckBox_stateChanged(int state) {
3885
table->setFilter(state != 0);
3986
}
4087

41-
void FeedbackDialog::on_regionFeedback(int label, Feedback::FeedbackType type, bool value) {
42-
visualizationContainer->SetRegionFeedback(label, type, value);
88+
void FeedbackDialog::on_regionComment(int label, QString comment) {
89+
visualizationContainer->SetRegionComment(label, comment.toStdString());
90+
}
91+
92+
void FeedbackDialog::on_regionDone(int label, bool done) {
93+
visualizationContainer->SetRegionDone(label, done);
94+
}
95+
96+
void FeedbackDialog::on_regionVerified(int label, bool verified) {
97+
visualizationContainer->SetRegionVerified(label, verified);
98+
}
99+
100+
void FeedbackDialog::on_selectRegion(int label) {
101+
visualizationContainer->SelectRegion((unsigned short)label);
43102
}
44103

45104
void FeedbackDialog::on_highlightRegion(int label) {
46105
visualizationContainer->HighlightRegion((unsigned short)label);
106+
}
107+
108+
void FeedbackDialog::on_countChanged(int count) {
109+
countLabel->setText("Count: " + QString::number(count));
110+
}
111+
112+
void FeedbackDialog::on_verifiedShortcut() {
113+
//printf("DLKJF");
47114
}

qt/FeedbackDialog.h

+13-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
#include "ui_FeedbackDialog.h"
55

6-
#include "Feedback.h"
6+
class QStandardItemModel;
77

88
class FeedbackTable;
99
class VisualizationContainer;
10+
class Region;
1011

1112
class FeedbackDialog : public QDialog, private Ui::FeedbackDialog {
1213
Q_OBJECT
@@ -15,20 +16,30 @@ class FeedbackDialog : public QDialog, private Ui::FeedbackDialog {
1516
virtual ~FeedbackDialog();
1617

1718
void updateRegions();
19+
void updateRegion(Region* region);
20+
void selectRegionLabel(unsigned short label);
1821

1922
public slots:
2023
// Use Qt's auto-connect magic to tie GUI widgets to slots,
2124
// removing the need to call connect() explicitly.
2225
// Names of the methods must follow the naming convention
2326
// on_<widget name>_<signal name>(<signal parameters>).
27+
void on_searchLineEdit_editingFinished();
2428
void on_filterCheckBox_stateChanged(int state);
2529

26-
void on_regionFeedback(int label, Feedback::FeedbackType type, bool value);
30+
void on_regionComment(int label, QString comment);
31+
void on_regionDone(int label, bool done);
32+
void on_regionVerified(int label, bool verified);
33+
void on_selectRegion(int label);
2734
void on_highlightRegion(int label);
35+
void on_countChanged(int count);
36+
void on_verifiedShortcut();
2837

2938
protected:
3039
FeedbackTable* table;
3140
VisualizationContainer* visualizationContainer;
41+
42+
QStandardItemModel* labelModel;
3243
};
3344

3445
#endif

qt/FeedbackDialog.ui

+42-8
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,48 @@
2121
</property>
2222
<layout class="QVBoxLayout" name="verticalLayout_3">
2323
<item>
24-
<widget class="QCheckBox" name="filterCheckBox">
25-
<property name="text">
26-
<string>Filter by correction needed</string>
27-
</property>
28-
</widget>
29-
</item>
30-
<item>
31-
<layout class="QVBoxLayout" name="verticalLayout_2"/>
24+
<layout class="QHBoxLayout" name="horizontalLayout_2">
25+
<item>
26+
<widget class="QLineEdit" name="searchLineEdit">
27+
<property name="placeholderText">
28+
<string>Search</string>
29+
</property>
30+
</widget>
31+
</item>
32+
<item>
33+
<widget class="QCheckBox" name="filterCheckBox">
34+
<property name="text">
35+
<string>Filter by correction needed</string>
36+
</property>
37+
</widget>
38+
</item>
39+
<item>
40+
<widget class="QLabel" name="countLabel">
41+
<property name="styleSheet">
42+
<string notr="true">margin-bottom: .1em;</string>
43+
</property>
44+
<property name="text">
45+
<string>Count: </string>
46+
</property>
47+
<property name="alignment">
48+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
49+
</property>
50+
</widget>
51+
</item>
52+
<item>
53+
<spacer name="horizontalSpacer">
54+
<property name="orientation">
55+
<enum>Qt::Horizontal</enum>
56+
</property>
57+
<property name="sizeHint" stdset="0">
58+
<size>
59+
<width>40</width>
60+
<height>20</height>
61+
</size>
62+
</property>
63+
</spacer>
64+
</item>
65+
</layout>
3266
</item>
3367
</layout>
3468
</widget>

0 commit comments

Comments
 (0)