Skip to content

Commit

Permalink
Stage (#137)
Browse files Browse the repository at this point in the history
* 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

* Bugfix/done sort (#126)

* 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

* Set data in addCheckWidget

* Fix sorting issue with feedback table

* Fix issue with merge

* Bump version number

* Feature/dot annotation (#134)

* Stage (#127)

* 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

* Bugfix/done sort (#126)

* 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

* Set data in addCheckWidget

* Fix sorting issue with feedback table

* Fix issue with merge

* Bump version number

* Add region center sphere visualization

* Add button for dot annotation mode

* Add dot annotation mode

* Add 2D dot visualization

* Work on applying dot annotation to current full annotations

* Fix issues with center at edges, automatically show/hide dots based on mode

* Use triangle for out of plane 2D centers

* Use cone for triangle

* Enable picking 3D dot annotations

* Change dot annotation icon

* Set default verified and comment in RegionInfo

* Add shortcut to open/close feedback dialog

* Apply dot annotation in extract regions

* Only apply dot annotation to regions when saving in dot annotation mode

* Add verified shortcut to feedback table

* Feature/dot mode guard (#135)

* Use period for verified shortcut

* Add enable dot annotation checkbox to settings

* Add warning when switching to dot annotation mode

* Push history for dot mode

* Add separate action to apply dot annotation

* Use WIN32
  • Loading branch information
davidborland authored Oct 14, 2021
1 parent ff9fb43 commit 9a8cd66
Show file tree
Hide file tree
Showing 28 changed files with 543 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif()

set(SEGMENTOR_VERSION 0.4.3)
set(SEGMENTOR_VERSION 0.4.4)

project(Segmentor VERSION ${SEGMENTOR_VERSION})

Expand Down
1 change: 1 addition & 0 deletions Segmentor.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
<file>icons/icon_filter_regions.png</file>
<file>icons/icon_reset_view.png</file>
<file>icons/icon_volume_render.png</file>
<file>icons/icon_dot.png</file>
</qresource>
</RCC>
Binary file added icons/icon_dot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions icons/icon_dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions interaction/InteractionCallbacks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,21 @@ void InteractionCallbacks::Visible(vtkObject* caller, unsigned long eventId, voi
}
}

void InteractionCallbacks::Dot(vtkObject* caller, unsigned long eventId, void* clientData, void *callData) {
vtkRenderWindowInteractor* rwi = static_cast<vtkInteractorStyle*>(caller)->GetInteractor();
VisualizationContainer* vis = static_cast<VisualizationContainer*>(clientData);

// Pick at the mouse location provided by the interactor
int pick = Pick(rwi);

if (pick) {
// Get the position for the pick event
double p[3];
PickPosition(p);
vis->SetDotAnnotation(p);
}
}

void InteractionCallbacks::MouseMove(vtkObject* caller, unsigned long eventId, void* clientData, void *callData) {
vtkRenderWindowInteractor* rwi = static_cast<vtkRenderWindowInteractor*>(caller);
VisualizationContainer* vis = static_cast<VisualizationContainer*>(clientData);
Expand Down
1 change: 1 addition & 0 deletions interaction/InteractionCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class InteractionCallbacks {
static void Grow(vtkObject* caller, unsigned long eventId, void* clientData, void *callData);
static void Done(vtkObject* caller, unsigned long eventId, void* clientData, void *callData);
static void Visible(vtkObject* caller, unsigned long eventId, void* clientData, void *callData);
static void Dot(vtkObject* caller, unsigned long eventId, void* clientData, void *callData);

static void MouseMove(vtkObject* caller, unsigned long eventId, void* clientData, void *callData);

Expand Down
3 changes: 2 additions & 1 deletion interaction/InteractionEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ enum InteractionMode {
MergeMode,
SplitMode,
GrowMode,
VisibleMode
VisibleMode,
DotMode
};

enum FilterMode {
Expand Down
32 changes: 32 additions & 0 deletions interaction/vtkInteractorStyleSlice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,30 @@ void vtkInteractorStyleSlice::EndVisible()
this->StopState();
}

//----------------------------------------------------------------------------
void vtkInteractorStyleSlice::StartDot()
{
if (this->State != VTKIS_NONE)
{
return;
}
this->StartState(VTKIS_DOT_SLICE);
}

//----------------------------------------------------------------------------
void vtkInteractorStyleSlice::EndDot()
{
if (this->State != VTKIS_DOT_SLICE)
{
return;
}
if (this->HandleObservers)
{
this->InvokeEvent(DotEvent, nullptr);
}
this->StopState();
}

//----------------------------------------------------------------------------
void vtkInteractorStyleSlice::WindowLevel()
{
Expand Down Expand Up @@ -414,6 +438,10 @@ void vtkInteractorStyleSlice::OnLeftButtonDown()
{
this->StartVisible();
}
else if (this->Mode == DotMode)
{
this->StartDot();
}
else
{
// Rotate
Expand Down Expand Up @@ -474,6 +502,10 @@ void vtkInteractorStyleSlice::OnLeftButtonUp() {
case VTKIS_VISIBLE_SLICE:
this->EndVisible();
break;

case VTKIS_DOT_SLICE:
this->EndDot();
break;
}

// Call parent to handle all other states and perform additional work
Expand Down
6 changes: 5 additions & 1 deletion interaction/vtkInteractorStyleSlice.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class vtkCellPicker;
#define VTKIS_MERGE_SLICE 2053
#define VTKIS_GROW_SLICE 2054
#define VTKIS_VISIBLE_SLICE 2055
#define VTKIS_DOT_SLICE 2056

class vtkInteractorStyleSlice : public vtkInteractorStyleImage {
public:
Expand Down Expand Up @@ -56,6 +57,8 @@ class vtkInteractorStyleSlice : public vtkInteractorStyleImage {
virtual void EndGrow();
virtual void StartVisible();
virtual void EndVisible();
virtual void StartDot();
virtual void EndDot();

virtual void WindowLevel() override;
double GetWindow();
Expand All @@ -79,7 +82,8 @@ class vtkInteractorStyleSlice : public vtkInteractorStyleImage {
AddEvent,
MergeEvent,
GrowEvent,
VisibleEvent
VisibleEvent,
DotEvent
};

protected:
Expand Down
2 changes: 1 addition & 1 deletion interaction/vtkInteractorStyleVolume.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ void vtkInteractorStyleVolume::OnLeftButtonDown()
else if (this->Mode == VisibleMode)
{
this->StartVisible();
}
}
else
{
// If shift is held down, start window level
Expand Down
9 changes: 6 additions & 3 deletions qt/FeedbackDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ FeedbackDialog::FeedbackDialog(QWidget* parent, VisualizationContainer* visualiz
QObject::connect(table, &FeedbackTable::highlightRegion, this, &FeedbackDialog::on_highlightRegion);
QObject::connect(table, &FeedbackTable::countChanged, this, &FeedbackDialog::on_countChanged);

// Shortcut
QShortcut* shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_V), this);
// Shortcuts
QShortcut* shortcut = new QShortcut(QKeySequence(Qt::Key_Period), this);
QObject::connect(shortcut, &QShortcut::activated, this, &FeedbackDialog::on_verifiedShortcut);

QShortcut* closeShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this);
QObject::connect(closeShortcut, &QShortcut::activated, this, &FeedbackDialog::close);

updateRegions();
}

Expand Down Expand Up @@ -110,5 +113,5 @@ void FeedbackDialog::on_countChanged(int count) {
}

void FeedbackDialog::on_verifiedShortcut() {
//printf("DLKJF");
visualizationContainer->ToggleCurrentRegionVerified();
}
63 changes: 63 additions & 0 deletions qt/MainWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ MainWindow::MainWindow() {

// Settings dialog
settingsDialog = new SettingsDialog(this, visualizationContainer);
QObject::connect(settingsDialog, &SettingsDialog::enableDotAnnotationChanged, this, &MainWindow::on_enableDotAnnotationChanged);

// Feedback dialog
feedbackDialog = new FeedbackDialog(this, visualizationContainer);
Expand Down Expand Up @@ -588,6 +589,32 @@ void MainWindow::on_actionSegment_Volume_triggered() {
}
}

void MainWindow::on_actionApply_Dot_Annotation_triggered() {
QMessageBox message;
message.setIcon(QMessageBox::Warning);
message.setText("Apply dot annotation.");
message.setInformativeText(
"This operation will replace each region with a single voxel at the region center.\n\n"
"Do you wish to continue?"
);
message.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
message.setDefaultButton(QMessageBox::Save);
int ret = message.exec();

switch (ret) {
case QMessageBox::Yes:
visualizationContainer->ApplyDotAnnotation();
break;

case QMessageBox::No:
break;

default:
// Should never be reached
break;
}
}

void MainWindow::on_actionExit_triggered() {
close();
}
Expand Down Expand Up @@ -691,6 +718,10 @@ void MainWindow::on_actionVisible() {
visualizationContainer->SetInteractionMode(VisibleMode);
}

void MainWindow::on_actionDot() {
visualizationContainer->SetInteractionMode(DotMode);
}

void MainWindow::on_actionUpdate() {
visualizationContainer->RelabelCurrentRegion();
}
Expand Down Expand Up @@ -807,6 +838,22 @@ void MainWindow::on_brushRadiusSpinBox_valueChanged(int value) {
visualizationContainer->SetBrushRadius(value);
}

void MainWindow::on_enableDotAnnotationChanged(bool enable) {
// Enable apply dot annotation
actionApply_Dot_Annotation->setEnabled(enable);

// Enable dot mode
QList<QAction*> actions = modeBarWidget->findChild<QToolBar*>()->actions();

for (int i = 0; i < actions.length(); i++) {
QAction* action = actions[i];
if (action->objectName() == "dotModeAction") {
action->setEnabled(enable);
break;
}
}
}

void MainWindow::on_toggleView() {
if (qvtkWidgetLeft->isVisible()) {
qvtkWidgetLeft->setVisible(false);
Expand Down Expand Up @@ -1059,6 +1106,11 @@ void MainWindow::createModeBar() {
toolBar->addAction(createActionIcon(":/icons/icon_merge.png", "Merge with current region (m)", "m", interactionModeGroup, currentMode == MergeMode, &MainWindow::on_actionMerge));
toolBar->addAction(createActionIcon(":/icons/icon_grow.png", "Grow / shrink region (g)", "g", interactionModeGroup, currentMode == GrowMode, &MainWindow::on_actionGrow));
toolBar->addAction(createActionIcon(":/icons/icon_visible.png", "Toggle region visibility (v)", "v", interactionModeGroup, currentMode == VisibleMode, &MainWindow::on_actionVisible));

QAction* dotAction = createActionIcon(":/icons/icon_dot.png", "Dot annotation mode (Ctrl + d)", QKeySequence(Qt::CTRL + Qt::Key_D), interactionModeGroup, currentMode == DotMode, &MainWindow::on_actionDot);
dotAction->setObjectName("dotModeAction");
dotAction->setEnabled(false);
toolBar->addAction(dotAction);

toolBar->addSeparator();
toolBar->addWidget(createLabel("Actions", 0, 0, 5, 5));
Expand Down Expand Up @@ -1163,6 +1215,17 @@ QAction* MainWindow::createActionIcon(const QString& fileName, const QString& te
return action;
}

QAction* MainWindow::createActionIcon(const QString& fileName, const QString& text, const QKeySequence& shortcut, QActionGroup* group, bool checked, void (MainWindow::*slot)()) {
QAction* action = new QAction(QIcon(fileName), text, group);
action->setShortcut(QKeySequence(shortcut));
action->setCheckable(true);
action->setChecked(checked);

QObject::connect(action, &QAction::triggered, this, slot);

return action;
}

QLabel* MainWindow::createLabel(const QString& text, int topMargin, int bottomMargin, int leftMargin, int rightMargin) {
QString style = QStringLiteral("color:#999;margin-top:%1px;margin-bottom:%2px;margin-left:%3px;margin-right:%4px")
.arg(topMargin).arg(bottomMargin).arg(leftMargin).arg(rightMargin);
Expand Down
5 changes: 5 additions & 0 deletions qt/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public slots:
virtual void on_actionRedo_triggered();

virtual void on_actionSegment_Volume_triggered();
virtual void on_actionApply_Dot_Annotation_triggered();

virtual void on_actionExit_triggered();

Expand Down Expand Up @@ -90,6 +91,7 @@ public slots:
virtual void on_actionGrow();
virtual void on_actionDone();
virtual void on_actionVisible();
virtual void on_actionDot();

// Action events
virtual void on_actionUpdate();
Expand Down Expand Up @@ -142,6 +144,8 @@ public slots:
virtual void on_brushRadiusDown();
virtual void on_brushRadiusUp();

virtual void on_enableDotAnnotationChanged(bool enable);

signals:

void windowLevelChanged(double window, double value);
Expand Down Expand Up @@ -184,6 +188,7 @@ public slots:
QAction* createActionIcon(const QString& fileName, const QString& text, const QKeySequence& shortcut, void (MainWindow::*slot)());
QAction* createActionIcon(const QString& fileName, const QString& text, const QString& shortcut, bool checked, void (MainWindow::*slot)(bool));
QAction* createActionIcon(const QString& fileName, const QString& text, const QString& shortcut, QActionGroup* group, bool checked, void (MainWindow::*slot)());
QAction* createActionIcon(const QString& fileName, const QString& text, const QKeySequence& shortcut, QActionGroup* group, bool checked, void (MainWindow::*slot)());
QLabel* createLabel(const QString& text, int topMargin = 10, int bottomMargin = 5, int leftMargin = 0, int rightMargin = 0);

InteractionMode navEditMode;
Expand Down
12 changes: 12 additions & 0 deletions qt/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
<string>Analyze</string>
</property>
<addaction name="actionSegment_Volume"/>
<addaction name="actionApply_Dot_Annotation"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
Expand Down Expand Up @@ -611,6 +612,17 @@
<property name="text">
<string>Show Feedback</string>
</property>
<property name="shortcut">
<string>Ctrl+F</string>
</property>
</action>
<action name="actionApply_Dot_Annotation">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Apply Dot Annotation</string>
</property>
</action>
</widget>
<customwidgets>
Expand Down
5 changes: 5 additions & 0 deletions qt/SettingsDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,9 @@ void SettingsDialog::on_gradientOpacityCheckBox_stateChanged(int state) {

void SettingsDialog::on_autoAdjustSamplingCheckBox_stateChanged(int state) {
visualizationContainer->GetVolumeView()->SetVolumeRenderingAutoAdjustSampling(state != 0);
}


void SettingsDialog::on_enableDotAnnotationCheckBox_stateChanged(int state) {
emit enableDotAnnotationChanged(state != 0);
}
5 changes: 5 additions & 0 deletions qt/SettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public slots:
virtual void on_gradientOpacityCheckBox_stateChanged(int state);
virtual void on_autoAdjustSamplingCheckBox_stateChanged(int state);

virtual void on_enableDotAnnotationCheckBox_stateChanged(int state);

signals:
void enableDotAnnotationChanged(bool enable);

protected:
VisualizationContainer* visualizationContainer;
};
Expand Down
22 changes: 21 additions & 1 deletion qt/SettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>314</width>
<height>367</height>
<height>425</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -330,6 +330,26 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Dot annotation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QCheckBox" name="enableDotAnnotationCheckBox">
<property name="text">
<string>Enable dot annotation</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down
Loading

0 comments on commit 9a8cd66

Please sign in to comment.