Commit 56831c0e authored by saubatn's avatar saubatn
Browse files

DONE : task 265 "Arbitrary Slice Viewer toolbar"

	NEW : arbitrary slice action to customize it (angle, slice number).
	NEW : widget to set up slice number and angles.

NEW : arbitrary slice number is initialized to the max of the 3 others axes slices number (axial, coronal, sagital).
FIXED : action families which contain only one action are displayed like others : a submenu of the family name, and an entry of the name of the action (previously the family sub-menu was not displayed, shorten the menu to the action directly). I think the family menu shows important nformation. To be debated.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@228 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 58d78a0b
......@@ -14,4 +14,5 @@ add_subdirectory(volumerendering)
add_subdirectory(multipicking)
add_subdirectory(itksegmentation)
add_subdirectory(itkfilters)
add_subdirectory(arbitraryslice)
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2012 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK 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. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2012 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK 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. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef CAMITKAPPLICATION_H
......@@ -211,7 +211,7 @@ public:
/// Get all the actions that can be applied on any components of the given list of components (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates)
static ActionList getActions(ComponentList );
/// get all the actions that of a given tag (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates)
/// get all the actions that of a given tag (note: the returned ActionList is guaranteed to be sorted by action name and to contain no duplicates)
static ActionList getActions(ComponentList , QString );
/** register all actions from the given ActionExtension
......
......@@ -279,60 +279,60 @@ QMenu* Component::getActionAndPopupMenu() {
if (actionsMenu == NULL) {
actionsMenu = new QMenu();
//-- add all actions sorted by family
ActionList allActions = Application::getActions(this);
//-- add all actions sorted by family
ActionList allActions = Application::getActions(this);
QMap<QString, ActionSet*> familyMap;
foreach (Action *action, allActions) {
ActionSet* familySet = familyMap.value(action->getFamily().toLower());
if (!familySet) {
familySet = new ActionSet;
familyMap.insert(action->getFamily().toLower(),familySet);
familySet = new ActionSet;
familyMap.insert(action->getFamily().toLower(),familySet);
}
familySet->insert(action);
}
// for family with only one action, modify family name so that sorting in the menu will appear correct
// (as the only visible item will not be the menu but the action's name itself)
foreach (ActionSet * familySet, familyMap.values()) {
if (familySet->size()==1) {
// remove the family
familyMap.remove((*familySet->begin())->getFamily().toLower());
// reinsert it but with the action's name as key
familyMap.insert((*familySet->begin())->getName().toLower(),familySet);
}
}
// foreach (ActionSet * familySet, familyMap.values()) {
// if (familySet->size()==1) {
// // remove the family => why ? It's alwalys less messy to filter action by family, no ?
// familyMap.remove((*familySet->begin())->getFamily().toLower());
// // reinsert it but with the action's name as key
// familyMap.value(0).insert((*familySet->begin())->getName().toLower(),familySet);
// }
// }
//-- create one sub menu per family (unless there is only one action)
foreach (ActionSet * familySet, familyMap.values()) {
// sort actions by name
ActionList familyList = familySet->toList();
qSort(familyList.begin(), familyList.end(), actionLessThan);
if (familyList.size()>1) {
QMenu *familyMenu = actionsMenu->addMenu(familyList.first()->getFamily());
foreach (Action* action, familyList) {
familyMenu->addAction(action->getQAction());
foreach (ActionSet * familySet, familyMap.values()) {
// sort actions by name
ActionList familyList = familySet->toList();
qSort(familyList.begin(), familyList.end(), actionLessThan);
if (familyList.size()>=1) {
QMenu *familyMenu = actionsMenu->addMenu(familyList.first()->getFamily());
foreach (Action* action, familyList) {
familyMenu->addAction(action->getQAction());
}
}
}
else
actionsMenu->addAction(familyList.first()->getQAction());
}
else
actionsMenu->addAction(familyList.first()->getQAction());
}
// add popup action
QMenu *popup = getPopupMenu();
if (popup && popup->actions().size() > 0) {
if (allActions.size() > 0)
actionsMenu->addSeparator();
foreach (QAction * action, popup->actions()) {
actionsMenu->addAction ( action );
}
}
// add popup action
QMenu *popup = getPopupMenu();
if (popup && popup->actions().size() > 0) {
if (allActions.size() > 0)
actionsMenu->addSeparator();
foreach (QAction * action, popup->actions()) {
actionsMenu->addAction ( action );
}
}
// no menu if no action
if (actionsMenu->actions().size() == 0) {
delete actionsMenu;
actionsMenu = NULL;
}
// no menu if no action
if (actionsMenu->actions().size() == 0) {
delete actionsMenu;
actionsMenu = NULL;
}
}
return actionsMenu;
}
......
......@@ -23,6 +23,9 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
// C++ stuff
#include <algorithm>
// -- Core stuff
#include "Slice.h"
#include "Log.h"
......@@ -34,6 +37,8 @@
#include <vtkProperty.h>
#include <vtkViewport.h>
using namespace std;
namespace camitk {
/* Constructor */
......@@ -386,7 +391,9 @@ int Slice::getNumberOfSlices() const {
switch (sliceOrientation) {
default:
case ARBITRARY_ORIENTATION:
//TODO
// Set manually the slice to the max of the 3 "normal" slices
// Vtk correclty handles the "out of bounds" cases.
nbSlices = max ( max(extent[1] - extent[0], extent[3] - extent[2]), extent[5] - extent[4]) + 1;
break;
case AXIAL_ORIENTATION:
nbSlices = extent[5] - extent[4] + 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment