Commit 1d732a9a authored by cfouard's avatar cfouard
Browse files

MOVED Image popup menus to display axial/sagittal/arbitrary slices in 3D to proper Actions.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@363 ec899d31-69d1-42ba-9299-647d76f65fb3
parent b06a5d83
......@@ -15,4 +15,5 @@ add_subdirectory(multipicking)
add_subdirectory(itksegmentation)
add_subdirectory(itkfilters)
add_subdirectory(arbitraryslice)
add_subdirectory(showin3d)
camitk_extension(
ACTION_EXTENSION
DEFAULT
)
\ No newline at end of file
camitk_extension(
ACTION_EXTENSION
DEFAULT
DEFINES COMPILE_RECONSTRUCTION_ACTION_API)
\ No newline at end of file
/*****************************************************************************
* $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$
****************************************************************************/
#include "ShowArbitrarySliceIn3D.h"
#include <ImageComponent.h>
#include <SingleImageComponent.h>
#include <InteractiveViewer.h>
using namespace camitk;
// --------------- constructor -------------------
ShowArbitrarySliceIn3D::ShowArbitrarySliceIn3D(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("ShowArbitrarySliceIn3D");
setEmbedded(false);
setDescription("Display or not the current slice(s) in 3D");
setComponent("ImageComponent");
// setComponent("SingleImageComponent");
// Setting classification family and tags
setFamily("Display");
addTag("3D Viewer");
}
// --------------- destructor -------------------
ShowArbitrarySliceIn3D::~ShowArbitrarySliceIn3D() {
// do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
}
// --------------- getWidget --------------
QWidget * ShowArbitrarySliceIn3D::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus ShowArbitrarySliceIn3D::apply() {
foreach (Component *comp, getTargets()) {
ImageComponent * img = dynamic_cast<ImageComponent *> (comp);
if(img) {
img->getArbitrarySlices()->setViewSliceIn3D(! img->getArbitrarySlices()->getViewSliceIn3D());
}
}
return SUCCESS;
}
......@@ -22,66 +22,30 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef SHOWARBITRARYSLICEIN3D_H
#define SHOWARBITRARYSLICEIN3D_H
#ifndef IMAGEVOLUMEMANAGERComponentPOPUP_H
#define IMAGEVOLUMEMANAGERComponentPOPUP_H
#include <Action.h>
#include <Component.h>
using namespace camitk;
// -- Core stuff
#include "ComponentPopupMenu.h"
// -- VTK stuff
#include <vtkSmartPointer.h>
#include <vtkImageData.h>
namespace camitk {
// -- Core image component stuff classes
class MedicalDataOriginDialog;
class ImageComponent;
/** The popup menu of the Image Volume manager data component.
*
*/
class ImageComponentPopup : public ComponentPopupMenu {
Q_OBJECT
class ShowArbitrarySliceIn3D : public Action {
public:
ImageComponentPopup ( camitk::Component *, QWidget* );
~ImageComponentPopup();
public slots:
/// update the check box state
void updateDisplayIn3D ( bool );
/// Default Constructor
ShowArbitrarySliceIn3D(ActionExtension * extension);
void selectOrigin();
/// Default Destructor
virtual ~ShowArbitrarySliceIn3D();
/// Show/hide the volume in the 3D viewer.
void displayIn3D();
private:
MedicalDataOriginDialog * medicalDataOriginDialog;
ImageComponent * dad;
vtkSmartPointer<vtkImageData> imgData;
/// Image filter sub-menu
QMenu * imageFilterMenu;
/// The id of the displayIn3D action in the popup menu
QAction* displayIn3Did;
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget * getWidget();
public slots:
/** this method is automatically called when the action is triggered.
* It gets all the targets' top level component and close them.
*/
virtual ApplyStatus apply();
};
}
#endif
#endif // SHOWARBITRARYSLICEIN3D_H
/*****************************************************************************
* $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$
****************************************************************************/
#include "ShowAxialSliceIn3D.h"
#include <ImageComponent.h>
#include <SingleImageComponent.h>
#include <InteractiveViewer.h>
using namespace camitk;
// --------------- constructor -------------------
ShowAxialSliceIn3D::ShowAxialSliceIn3D(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("ShowAxialSliceIn3D");
setEmbedded(false);
setDescription("Display or not axial slice in 3D");
setComponent("ImageComponent");
// setComponent("SingleImageComponent");
// Setting classification family and tags
setFamily("Display");
addTag("3D Viewer");
}
// --------------- destructor -------------------
ShowAxialSliceIn3D::~ShowAxialSliceIn3D() {
// do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
}
// --------------- getWidget --------------
QWidget * ShowAxialSliceIn3D::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus ShowAxialSliceIn3D::apply() {
foreach (Component *comp, getTargets()) {
ImageComponent * img = dynamic_cast<ImageComponent *> (comp);
if(img) {
img->getAxialSlices()->setViewSliceIn3D(! img->getAxialSlices()->getViewSliceIn3D());
}
}
return SUCCESS;
}
......@@ -22,35 +22,30 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef SHOWAXIALSLICEIN3D_H
#define SHOWAXIALSLICEIN3D_H
// -- Core image component stuff
#include "SingleImageComponentPopup.h"
#include <Action.h>
#include <Component.h>
// -- Core stuff
#include "Component.h"
#include "InteractiveViewer.h"
using namespace camitk;
class ShowAxialSliceIn3D : public Action {
namespace camitk {
// ---------------------- constructor ----------------------------
SingleImageComponentPopup::SingleImageComponentPopup ( Component *dc, QWidget *parent )
: ComponentPopupMenu ( dc, parent ) {
displayIn3Did = addAction ( "Show Slice In 3D", SLOT ( displayIn3D() ), true );
displayIn3Did->setChecked ( true );
}
public:
/// Default Constructor
ShowAxialSliceIn3D(ActionExtension * extension);
/// Default Destructor
virtual ~ShowAxialSliceIn3D();
// ---------------------- displayIn3D ----------------------------
void SingleImageComponentPopup::displayIn3D() {
// if true, display in 3D, else hide.
myComponent->setVisibility ( InteractiveViewer::get3DViewer(), displayIn3Did->isChecked() );
InteractiveViewer::get3DViewer()->refresh();
}
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget * getWidget();
// ---------------------- updateDisplayIn3D ----------------------------
void SingleImageComponentPopup::updateDisplayIn3D ( bool visible ) {
displayIn3Did->blockSignals ( true );
displayIn3Did->setChecked ( visible );
displayIn3Did->blockSignals ( false );
}
}
public slots:
/** this method is automatically called when the action is triggered.
* It gets all the targets' top level component and close them.
*/
virtual ApplyStatus apply();
};
#endif // SHOWAXIALSLICEIN3D_H
/*****************************************************************************
* $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$
****************************************************************************/
#include "ShowCoronalSliceIn3D.h"
#include <ImageComponent.h>
#include <SingleImageComponent.h>
#include <InteractiveViewer.h>
using namespace camitk;
// --------------- constructor -------------------
ShowCoronalSliceIn3D::ShowCoronalSliceIn3D(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("ShowCoronalSliceIn3D");
setEmbedded(false);
setDescription("Display or not the current slice(s) in 3D");
setComponent("ImageComponent");
// setComponent("SingleImageComponent");
// Setting classification family and tags
setFamily("Display");
addTag("3D Viewer");
}
// --------------- destructor -------------------
ShowCoronalSliceIn3D::~ShowCoronalSliceIn3D() {
// do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
}
// --------------- getWidget --------------
QWidget * ShowCoronalSliceIn3D::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus ShowCoronalSliceIn3D::apply() {
foreach (Component *comp, getTargets()) {
ImageComponent * img = dynamic_cast<ImageComponent *> (comp);
if(img) {
img->getCoronalSlices()->setViewSliceIn3D(! img->getCoronalSlices()->getViewSliceIn3D());
}
}
return SUCCESS;
}
/*****************************************************************************
* $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 SHOWCORONALSLICEIN3D_H
#define SHOWCORONALSLICEIN3D_H
#include <Action.h>
#include <Component.h>
using namespace camitk;
class ShowCoronalSliceIn3D : public Action {
public:
/// Default Constructor
ShowCoronalSliceIn3D(ActionExtension * extension);
/// Default Destructor
virtual ~ShowCoronalSliceIn3D();
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget * getWidget();
public slots:
/** this method is automatically called when the action is triggered.
* It gets all the targets' top level component and close them.
*/
virtual ApplyStatus apply();
};
#endif // SHOWCORONALSLICEIN3D_H
......@@ -22,70 +22,51 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "ShowImageIn3D.h"
// -- Core image component stuff
#include "ImageComponentPopup.h"
#include "ImageComponent.h"
#include "MedicalDataOriginDialog.h"
#include <ImageComponent.h>
// -- Core stuff
#include "Application.h"
#include "MainWindow.h"
#include "Component.h"
#include "InteractiveViewer.h"
using namespace camitk;
// -- QT stuff
#include <QMessageBox>
// --------------- constructor -------------------
ShowImageIn3D::ShowImageIn3D(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("ShowImageIn3D");
setEmbedded(false);
setDescription("Shows the Image Volume in 3D viewer");
setComponent("ImageComponent");
// TODO: set a small icon with Axial/Coronal/Sagittal views in 3D
// Setting classification family and tags
setFamily("Display");
addTag("3D Viewer");
namespace camitk {
// ---------------------- constructor ----------------------------
ImageComponentPopup::ImageComponentPopup ( Component *dc, QWidget *parent ) : ComponentPopupMenu ( dc, parent ) {
medicalDataOriginDialog = NULL;
imageFilterMenu = NULL;
dad = ( ImageComponent* ) dc;
displayIn3Did = addAction ( "Show In 3D", SLOT ( displayIn3D() ), true );
// to avoid unexpected calls
updateDisplayIn3D(true);
/* 3D reconstruction */
addSeparator();
// add shortcut
getQAction()->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
}
ImageComponentPopup::~ImageComponentPopup() {
if ( medicalDataOriginDialog )
delete medicalDataOriginDialog;
// --------------- destructor -------------------
ShowImageIn3D::~ShowImageIn3D() {
// do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
}
void ImageComponentPopup::selectOrigin() {
//display the dialog window
if ( !medicalDataOriginDialog )
medicalDataOriginDialog = new MedicalDataOriginDialog ( dad, Application::getMainWindow() );
medicalDataOriginDialog->exec();
// --------------- getWidget --------------
QWidget * ShowImageIn3D::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus ShowImageIn3D::apply() {
// ---------------------- displayIn3D ----------------------------
void ImageComponentPopup::displayIn3D() {
// if true, display in 3D, else hide.
dad->setAllVisibleIn3D ( displayIn3Did->isChecked() );
camitk::InteractiveViewer::get3DViewer()->refresh();
}
// fill the toplevel component set
foreach (Component *comp, getTargets()) {
ImageComponent * img = dynamic_cast<ImageComponent *> (comp);
if(img) {
img->setViewIn3D(! img->getViewIn3D());
}
}
// ---------------------- updateDisplayIn3D ----------------------------
void ImageComponentPopup::updateDisplayIn3D ( bool in3D) {
displayIn3Did->blockSignals(true);
displayIn3Did->setChecked(in3D);
displayIn3Did->blockSignals(false);
}
return SUCCESS;
}
/*****************************************************************************
* $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 SHOWIMAGEIN3D_H
#define SHOWIMAGEIN3D_H
#include <Action.h>
using namespace camitk;
class ShowImageIn3D : public Action {
public:
/// Default Constructor
ShowImageIn3D(ActionExtension * extension);
/// Default Destructor
virtual ~ShowImageIn3D();
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget * getWidget();
public slots:
/** this method is automatically called when the action is triggered.
* It gets all the targets' top level component and close them.
*/
virtual ApplyStatus apply();
};
#endif // SHOWIMAGEIN3D_H
/*****************************************************************************
* $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$
****************************************************************************/
#include "ShowIn3DExtension.h"
// include generated actions headers
#include "ShowImageIn3D.h"
#include "ShowAxialSliceIn3D.h"
#include "ShowCoronalSliceIn3D.h"
#include "ShowSagittalSliceIn3D.h"
#include "ShowArbitrarySliceIn3D.h"
// --------------- declare the extension -------------------
Q_EXPORT_PLUGIN2(showin3d, ShowIn3DExtension)
// --------------- getActions -------------------
void ShowIn3DExtension::init() {