Skip to content

Commit

Permalink
Merge pull request MRtrix3#852 from MRtrix3/mrview_gotovolume
Browse files Browse the repository at this point in the history
mrview: go to volume slot MRtrix3#848
  • Loading branch information
maxpietsch authored Dec 6, 2016
2 parents b1f0e31 + f500cc0 commit 5460274
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
44 changes: 41 additions & 3 deletions src/gui/mrview/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ namespace MR
prev_image_volume_action->setShortcut (tr ("Left"));
addAction (prev_image_volume_action);

goto_image_volume_action = image_menu->addAction (tr ("Go to volume..."), this, SLOT (image_goto_volume_slot()));
goto_image_volume_action->setShortcut (tr ("g"));
addAction (goto_image_volume_action);

next_image_volume_group_action = image_menu->addAction (tr ("Next volume group"), this, SLOT (image_next_volume_group_slot()));
next_image_volume_group_action->setShortcut (tr ("Shift+Right"));
addAction (next_image_volume_group_action);
Expand All @@ -362,6 +366,10 @@ namespace MR
prev_image_volume_group_action->setShortcut (tr ("Shift+Left"));
addAction (prev_image_volume_group_action);

goto_image_volume_group_action = image_menu->addAction (tr ("Go to volume group..."), this, SLOT (image_goto_volume_group_slot()));
goto_image_volume_group_action->setShortcut (tr ("Shift+g"));
addAction (goto_image_volume_group_action);

image_menu->addSeparator();

next_image_action = image_menu->addAction (tr ("Next image"), this, SLOT (image_next_slot()));
Expand Down Expand Up @@ -527,7 +535,6 @@ namespace MR
menu->addSeparator();

action = menu->addAction (tr ("Background colour..."), this, SLOT (background_colour_slot()));
action->setShortcut (tr ("G"));
action->setCheckable (false);
addAction (action);

Expand Down Expand Up @@ -1125,6 +1132,31 @@ namespace MR
}


void Window::image_goto_volume_slot ()
{
size_t maxvol = image()->image.size(3) - 1;
auto label = std::string ("volume (0...") + str(maxvol) + std::string (")");
bool ok;
size_t vol = QInputDialog::getInt (this, tr("Go to..."),
label.c_str(), image()->image.index(3), 0, maxvol, 1, &ok);
if (ok) {
set_image_volume (3, vol);
emit volumeChanged(vol);
}
}

void Window::image_goto_volume_group_slot ()
{
size_t maxvolgroup = image()->image.size(4) - 1;
auto label = std::string ("volume group (0...") + str(maxvolgroup) + std::string (")");
bool ok;
size_t grp = QInputDialog::getInt (this, tr("Go to..."),
label.c_str(), image()->image.index(4), 0, maxvolgroup, 1, &ok);
if (ok) {
set_image_volume (4, grp);
emit volumeGroupChanged(grp);
}
}


void Window::image_next_volume_group_slot ()
Expand Down Expand Up @@ -1279,17 +1311,21 @@ namespace MR

void Window::set_image_navigation_menu ()
{
bool show_next_volume (false), show_prev_volume (false);
bool show_next_volume_group (false), show_prev_volume_group (false);
bool show_next_volume (false), show_goto_volume (false), show_prev_volume (false);
bool show_next_volume_group (false), show_goto_volume_group (false), show_prev_volume_group (false);
Image* imagep = image();
if (imagep) {
if (imagep->image.ndim() > 3) {
if (imagep->image.size(3) > 1)
show_goto_volume = true;
if (imagep->image.index(3) > 0)
show_prev_volume = true;
if (imagep->image.index(3) < imagep->image.size(3)-1)
show_next_volume = true;

if (imagep->image.ndim() > 4) {
if (imagep->image.size(4) > 1)
show_goto_volume_group = true;
if (imagep->image.index(4) > 0)
show_prev_volume_group = true;
if (imagep->image.index(4) < imagep->image.size(4)-1)
Expand All @@ -1299,8 +1335,10 @@ namespace MR
}
prev_image_volume_action->setEnabled (show_prev_volume);
next_image_volume_action->setEnabled (show_next_volume);
goto_image_volume_action->setEnabled (show_goto_volume);
prev_image_volume_group_action->setEnabled (show_prev_volume_group);
next_image_volume_group_action->setEnabled (show_next_volume_group);
goto_image_volume_group_action->setEnabled (show_goto_volume_group);
}


Expand Down
14 changes: 9 additions & 5 deletions src/gui/mrview/window.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
* Copyright (c) 2008-2016 the MRtrix3 contributors
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/
*
*
* MRtrix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*
* For more details, see www.mrtrix.org
*
*
*/
#ifndef __gui_mrview_window_h__
#define __gui_mrview_window_h__
Expand Down Expand Up @@ -200,7 +200,9 @@ namespace MR
void image_previous_slot ();
void image_next_volume_slot ();
void image_previous_volume_slot ();
void image_goto_volume_slot ();
void image_next_volume_group_slot ();
void image_goto_volume_group_slot ();
void image_previous_volume_group_slot ();
void image_reset_slot ();
void image_interpolate_slot ();
Expand Down Expand Up @@ -271,11 +273,13 @@ namespace MR
*prev_image_action,
*next_image_volume_action,
*prev_image_volume_action,
*goto_image_volume_action,
*next_slice_action,
*prev_slice_action,
*reset_view_action,
*next_image_volume_group_action,
*prev_image_volume_group_action,
*goto_image_volume_group_action,
*image_list_area,

*reset_windowing_action,
Expand Down Expand Up @@ -342,7 +346,7 @@ namespace MR

#ifndef NDEBUG
# define ASSERT_GL_MRVIEW_CONTEXT_IS_CURRENT ASSERT_GL_CONTEXT_IS_CURRENT (::MR::GUI::MRView::Window::main->glwidget())
#else
#else
# define ASSERT_GL_MRVIEW_CONTEXT_IS_CURRENT
#endif

Expand Down

0 comments on commit 5460274

Please sign in to comment.