Commit 858c36cc authored by promayon's avatar promayon
Browse files

NEW CamiTK main window accept drag and drop for opening files!

NEW MedicalImageViewer is a singletons, use getInstance()
NEW 6 application actions with global shortcuts (from Ctrl+0 to Ctrl+5: show All, Axial, Coronal, Sagittal, 3D, and Arbitrary
FIXED application shortcuts are now active for any windows in the application (global shortcuts)



git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@136 ec899d31-69d1-42ba-9299-647d76f65fb3
parent a51fbe15
......@@ -38,6 +38,12 @@ $CAMITK_LICENCE_END$
#include "ShowConsoleAction.h"
#include "AboutAction.h"
#include "RemoveLastInstanciatedAction.h"
#include "ShowAxialViewer.h"
#include "ShowCoronalViewer.h"
#include "ShowSagittalViewer.h"
#include "Show3DViewer.h"
#include "ShowAllViewers.h"
#include "ShowArbitraryViewer.h"
// --------------- declare the extension -------------------
Q_EXPORT_PLUGIN2(applicationaction, ApplicationActionExtension);
......@@ -61,5 +67,12 @@ void ApplicationActionExtension::init() {
registerNewAction(QuitAction);
registerNewAction(ShowConsoleAction);
registerNewAction(AboutAction);
registerNewAction(RemoveLastInstanciatedAction);
registerNewAction(RemoveLastInstanciatedAction);
// -- medical image viewer manipulation
registerNewAction(ShowAxialViewer);
registerNewAction(ShowCoronalViewer);
registerNewAction(ShowSagittalViewer);
registerNewAction(Show3DViewer);
registerNewAction(ShowAllViewers);
registerNewAction(ShowArbitraryViewer);
}
\ No newline at end of file
......@@ -43,6 +43,7 @@ ClearSelectionAction::ClearSelectionAction(ActionExtension * extension) : Action
addTag("Clear Selection");
getQAction()->setShortcut(Qt::Key_Escape);
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
}
// --------------- destructor -------------------
......
......@@ -43,6 +43,7 @@ CloseAction::CloseAction(ActionExtension * extension) : Action(extension) {
// add shortcut
getQAction()->setShortcut(QKeySequence::Close);
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
}
// --------------- destructor -------------------
......
......@@ -48,7 +48,8 @@ OpenAction::OpenAction (ActionExtension * extension) : Action (extension) {
addTag ("Open");
// add a shortcut
getQAction()->setShortcut ( QKeySequence::Open );
getQAction()->setShortcut( QKeySequence::Open );
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
}
// --------------- destructor -------------------
......@@ -75,8 +76,6 @@ Action::ApplyStatus OpenAction::apply() {
foreach(ComponentExtension * ext, ExtensionManager::getComponentExtensions().values().toSet()) {
filter += ext->getName() + " (*." + ext->getFileExtensions().join(" *.") + ");;";
}
cout << filter.toStdString() << endl;
// Open more than one file
QStringList files = QFileDialog::getOpenFileNames (NULL, "Select One or More Files to Open", Application::getLastUsedDirectory().absolutePath(), filter);
......
......@@ -47,6 +47,7 @@ QuitAction::QuitAction(ActionExtension * extension) : Action(extension) {
// add a shortcut
getQAction()->setShortcut ( QKeySequence::Quit );
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
}
// --------------- destructor -------------------
......
......@@ -44,6 +44,7 @@ SaveAction::SaveAction(ActionExtension * extension) : Action(extension) {
// add a shortcut
getQAction()->setShortcut ( QKeySequence::Save );
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
}
// --------------- destructor -------------------
......
......@@ -50,7 +50,8 @@ SaveAsAction::SaveAsAction(ActionExtension * extension) : Action(extension) {
addTag("Save As");
// add shortcuts
Action::getQAction()->setShortcut ( QKeySequence::SaveAs );
getQAction()->setShortcut ( QKeySequence::SaveAs );
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
}
// --------------- destructor -------------------
......
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#include "Show3DViewer.h"
#include <MedicalImageViewer.h>
using namespace camitk;
// --------------- constructor -------------------
Show3DViewer::Show3DViewer(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Show 3D Viewer");
setEmbedded(false);
setDescription("Show the 3D Viewer Only");
setComponent("");
// Setting classification family and tags
setFamily("Application");
addTag("3D Viewer");
addTag("Geometry");
// add a shortcut
getQAction()->setShortcut ( tr("Ctrl+1") );
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
// can be checked or not (on/off), useful when group in a QActionGroup (radio buttons)
getQAction()->setCheckable(true);
}
// --------------- destructor -------------------
Show3DViewer::~Show3DViewer() {
// 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 * Show3DViewer::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus Show3DViewer::apply() {
MedicalImageViewer::getInstance()->setVisibleViewer(MedicalImageViewer::VIEWER_3D);
return SUCCESS;
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#ifndef SHOW3DVIEWER_H
#define SHOW3DVIEWER_H
#include <Action.h>
using namespace camitk;
/// set the visibility of the MedicalImageViewer in order to only show the 3D viewer
class Show3DViewer : public Action {
public:
/// Default Constructor
Show3DViewer(ActionExtension * extension);
/// Default Destructor
virtual ~Show3DViewer();
/// Returns NULL: no widget for this action.
virtual QWidget * getWidget();
public slots:
/** this method is automatically called when the action is triggered.
* it calls setVisibility on the MedicalImageViewer instance
*/
virtual ApplyStatus apply();
};
#endif // SHOW3DVIEWER_H
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#include "ShowAllViewers.h"
#include <MedicalImageViewer.h>
using namespace camitk;
// --------------- constructor -------------------
ShowAllViewers::ShowAllViewers(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Show All Viewers");
setEmbedded(false);
setDescription("Show Classical Medical Image Viewer (Axial, Coronal, Sagittal and 3D in a 4 panels)");
setComponent("");
// Setting classification family and tags
setFamily("Application");
addTag("All Viewers");
addTag("Medical Image Viewer");
// add a shortcut
getQAction()->setShortcut ( tr("Ctrl+0") );
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
// can be checked or not (on/off), useful when group in a QActionGroup (radio buttons)
getQAction()->setCheckable(true);
}
// --------------- destructor -------------------
ShowAllViewers::~ShowAllViewers() {
// 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 * ShowAllViewers::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus ShowAllViewers::apply() {
MedicalImageViewer::getInstance()->setVisibleViewer(MedicalImageViewer::VIEWER_ALL);
return SUCCESS;
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#ifndef SHOWALLVIEWERS_H
#define SHOWALLVIEWERS_H
#include <Action.h>
using namespace camitk;
/// set the visibility of the MedicalImageViewer in order to show all viewers
class ShowAllViewers : public Action {
public:
/// Default Constructor
ShowAllViewers(ActionExtension * extension);
/// Default Destructor
virtual ~ShowAllViewers();
/// Returns NULL: no widget for this action.
virtual QWidget * getWidget();
public slots:
/** this method is automatically called when the action is triggered.
* it calls setVisibility on the MedicalImageViewer instance
*/
virtual ApplyStatus apply();
};
#endif // SHOWALLVIEWERS_H
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#include "ShowArbitraryViewer.h"
#include <MedicalImageViewer.h>
using namespace camitk;
// --------------- constructor -------------------
ShowArbitraryViewer::ShowArbitraryViewer(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Show Arbitrary Viewer");
setEmbedded(false);
setDescription("Show the Arbitrary Slice Viewer Only");
setComponent("");
// Setting classification family and tags
setFamily("Application");
addTag("Arbitrary Slice Viewer");
addTag("Slice");
// add a shortcut
getQAction()->setShortcut ( tr("Ctrl+5") );
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
// can be checked or not (on/off), useful when group in a QActionGroup (radio buttons)
getQAction()->setCheckable(true);
}
// --------------- destructor -------------------
ShowArbitraryViewer::~ShowArbitraryViewer() {
// 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 * ShowArbitraryViewer::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus ShowArbitraryViewer::apply() {
MedicalImageViewer::getInstance()->setVisibleViewer(MedicalImageViewer::VIEWER_ARBITRARY);
return SUCCESS;
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#ifndef SHOWARBITRARYVIEWER_H
#define SHOWARBITRARYVIEWER_H
#include <Action.h>
using namespace camitk;
/// set the visibility of the MedicalImageViewer in order to only show the arbitrary viewer
class ShowArbitraryViewer : public Action {
public:
/// Default Constructor
ShowArbitraryViewer(ActionExtension * extension);
/// Default Destructor
virtual ~ShowArbitraryViewer();
/// Returns NULL: no widget for this action.
virtual QWidget * getWidget();
public slots:
/** this method is automatically called when the action is triggered.
* it calls setVisibility on the MedicalImageViewer instance
*/
virtual ApplyStatus apply();
};
#endif // SHOWARBITRARYVIEWER_H
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#include "ShowAxialViewer.h"
#include <MedicalImageViewer.h>
using namespace camitk;
// --------------- constructor -------------------
ShowAxialViewer::ShowAxialViewer(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Show Axial Viewer");
setEmbedded(false);
setDescription("Show the Axial Viewer Only");
setComponent("");
// Setting classification family and tags
setFamily("Application");
addTag("Axial Viewer");
addTag("Slice");
// add a shortcut
getQAction()->setShortcut ( tr("Ctrl+2") );
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
// can be checked or not (on/off), useful when group in a QActionGroup (radio buttons)
getQAction()->setCheckable(true);
}
// --------------- destructor -------------------
ShowAxialViewer::~ShowAxialViewer() {
// 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 * ShowAxialViewer::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus ShowAxialViewer::apply() {
MedicalImageViewer::getInstance()->setVisibleViewer(MedicalImageViewer::VIEWER_AXIAL);
return SUCCESS;
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#ifndef SHOWAXIALVIEWER_H
#define SHOWAXIALVIEWER_H
#include <Action.h>
using namespace camitk;
/// set the visibility of the MedicalImageViewer in order to only show the axial viewer
class ShowAxialViewer : public Action {
public:
/// Default Constructor
ShowAxialViewer(ActionExtension * extension);
/// Default Destructor
virtual ~ShowAxialViewer();
/// Returns NULL: no widget for this action.
virtual QWidget * getWidget();
public slots:
/** this method is automatically called when the action is triggered.
* it calls setVisibility on the MedicalImageViewer instance
*/
virtual ApplyStatus apply();
};
#endif // SHOWAXIALVIEWER_H
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#include "ShowCoronalViewer.h"
#include <MedicalImageViewer.h>
using namespace camitk;
// --------------- constructor -------------------
ShowCoronalViewer::ShowCoronalViewer(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Show Coronal Viewer");
setEmbedded(false);
setDescription("Show the Coronal Viewer Only");
setComponent("");
// Setting classification family and tags
setFamily("Application");
addTag("Coronal Viewer");
addTag("Slice");
// add a shortcut
getQAction()->setShortcut ( tr("Ctrl+4") );
getQAction()->setShortcutContext(Qt::ApplicationShortcut);
// can be checked or not (on/off), useful when group in a QActionGroup (radio buttons)
getQAction()->setCheckable(true);
}