Commit 02011557 authored by Emmanuel Promayon's avatar Emmanuel Promayon

NEW renamed tutorial action now that MainWindow behaviour is specified

The action does not switch to/from the bitmap viewer, it just shows
it in the central viewer
parent 9b054e66
......@@ -32,7 +32,7 @@
#include <QToolBar>
#include <vtkCamera.h>
#include <vtkCamera.h> // to change the camera projection to parallel
using namespace camitk;
......@@ -60,31 +60,13 @@ BitmapViewer::BitmapViewer() : InteractiveViewer(BitmapViewerName, InteractiveVi
// parallel projection
getRendererWidget()->getActiveCamera()->ParallelProjectionOn();
isVisible = false;
switchToolbar = nullptr;
myToolbar = nullptr;
}
// -------------------- Destructor --------------------
BitmapViewer::~BitmapViewer() {
}
// -------------------- switchCentralViewer --------------------
void BitmapViewer::switchCentralViewer() {
// if the central viewer is the medical image viewer switch to my2DBitmapViewer (if it is not switch back to the medical image viewer)
if (isVisible) {
// switch back to the default MedicalImageViewer
Application::getMainWindow()->setCentralViewer(MedicalImageViewer::getInstance());
}
else {
// switch to the custom viewer
Application::getMainWindow()->setCentralViewer(BitmapViewer::getInstance());
// force refresh
refresh(this);
}
isVisible = !isVisible;
}
// -------------------- refresh --------------------
void BitmapViewer::refresh(Viewer* whoIsAsking) {
updateVisibility();
......@@ -102,28 +84,27 @@ QWidget* BitmapViewer::getWidget(QWidget* parent) {
// -------------------- getToolBar --------------------
QToolBar* BitmapViewer::getToolBar() {
if (switchToolbar == nullptr) {
if (myToolbar == nullptr) {
// create the toolbar and add the action to it
switchToolbar = new QToolBar(objectName() + " Toolbar");
myToolbar = new QToolBar(objectName() + " Toolbar");
// ensure object name is set for saving the state
switchToolbar->setObjectName(objectName() + " Toolbar");
switchToolbar->addAction(screenshotAction);
// create the action to switch between the default and this viewer
QAction* switchViewerAction = new QAction(tr("Hide Bitmap Viewer"), this);
switchViewerAction->setCheckable(true);
switchViewerAction->setChecked(true); // first time getToolBar is called -> BitmapViewer is being displayed
switchViewerAction->setStatusTip(tr("Switch The Central Viewer"));
switchViewerAction->setWhatsThis(tr("Switch The Central Viewer between the BitmapViewer and MedicalImageViewer"));
connect(switchViewerAction, SIGNAL(toggled(bool)), this, SLOT(switchCentralViewer()));
switchToolbar->addAction(switchViewerAction);
myToolbar->setObjectName(objectName() + " Toolbar");
myToolbar->addAction(screenshotAction);
// create the action to switch back to the medical image viewer
QAction* hideViewerAction = myToolbar->addAction(tr("Hide Bitmap Viewer"));
hideViewerAction->setIcon(QPixmap(":/fileClose"));
hideViewerAction->setStatusTip(tr("Switch back to the medical image viewer"));
hideViewerAction->setWhatsThis(tr("Switch back the ventral viewer to normal (i.e., show the Medical Image Viewer)"));
connect(hideViewerAction, &QAction::triggered, [=](bool) {
Application::getMainWindow()->setCentralViewer(MedicalImageViewer::getInstance());
});
}
return switchToolbar;
return myToolbar;
}
// -------------------- updateVisibility --------------------
void BitmapViewer::updateVisibility() {
// as the default component does not know anything about my2DBitmapViewer,
......
......@@ -50,10 +50,6 @@ public:
QToolBar* getToolBar() override;
public slots:
void switchCentralViewer();
protected:
BitmapViewer();
......@@ -64,9 +60,7 @@ private:
static QString BitmapViewerName;
bool isVisible;
QToolBar* switchToolbar;
QToolBar* myToolbar;
// set visibility of all possible component (that is component that can be displayed in 2D)
void updateVisibility();
......
......@@ -23,37 +23,42 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "SwitchViewer.h"
#include <BitmapViewer.h>
#include "ShowBitmapViewer.h"
#include "BitmapViewer.h"
#include <Application.h>
#include <MainWindow.h>
#include <QColor>
#include <QMessageBox>
using namespace camitk;
// -------------------- SwitchViewer --------------------
SwitchViewer::SwitchViewer(ActionExtension* extension) : Action(extension) {
setName("Switch Central Viewer");
// -------------------- ShowBitmapViewer --------------------
ShowBitmapViewer::ShowBitmapViewer(ActionExtension* extension) : Action(extension) {
setName("Show Bitmap Viewer");
setEmbedded(false); // not embedded (and as the
setDescription("Tutorial action that switch the central viewer in/out. Trigger this action when no component is selected");
setDescription("Tutorial action that set the bitmap viewer as the central viewer. Trigger this action when no component is selected");
setComponent("");
setFamily("Tutorial");
addTag("Viewer");
addTag("BitmapViewer");
addTag("MainWindow");
firstCall = true;
}
// --------------- getWidget -------------------
QWidget* SwitchViewer::getWidget() {
QWidget* ShowBitmapViewer::getWidget() {
return nullptr;
}
// --------------- apply -------------------
Action::ApplyStatus SwitchViewer::apply() {
// just ask the BitMap viewer to switch the central viewer
BitmapViewer::getInstance()->switchCentralViewer();
Action::ApplyStatus ShowBitmapViewer::apply() {
// just add the BitMap viewer in the central viewer
Application::getMainWindow()->setCentralViewer(BitmapViewer::getInstance());
Application::refresh();
if (firstCall) {
QMessageBox::information(nullptr,"Switch Viewer From the Menu", "The next time you can also use the \"View Menu\" item \"Toggle Central Viewers\" to switch the central viewer from/to the Medical Image Viewer");
firstCall = false;
......
......@@ -36,14 +36,14 @@ class Viewer;
/**
* Demonstrates how to switch the central image viewer.
*/
class SwitchViewer : public camitk::Action {
class ShowBitmapViewer : public camitk::Action {
public:
/// the constructor
SwitchViewer(camitk::ActionExtension*);
ShowBitmapViewer(camitk::ActionExtension*);
/// the destructor
virtual ~SwitchViewer() = default;
virtual ~ShowBitmapViewer() = default;
/// method called when the action when the action is triggered (i.e. started)
virtual QWidget* getWidget();
......
......@@ -22,11 +22,11 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "SwitchViewerExtension.h"
#include "SwitchViewer.h"
#include "ShowBitmapViewerExtension.h"
#include "ShowBitmapViewer.h"
// -------------------- init --------------------
void SwitchViewerExtension::init() {
registerNewAction(SwitchViewer);
void ShowBitmapViewerExtension::init() {
registerNewAction(ShowBitmapViewer);
}
......@@ -24,39 +24,39 @@
****************************************************************************/
#ifndef SWITCH_VIEWER_EXTENSION_H
#define SWITCH_VIEWER_EXTENSION_H
#ifndef SHOW_BITMAP_VIEWER_EXTENSION_H
#define SHOW_BITMAP_VIEWER_EXTENSION_H
#include <QObject>
#include <Action.h>
#include <ActionExtension.h>
/// shows how to switch the central viewer in and out
class SwitchViewerExtension : public camitk::ActionExtension {
/// shows the bitmap viewer in the central viewer
class ShowBitmapViewerExtension : public camitk::ActionExtension {
Q_OBJECT
Q_INTERFACES(camitk::ActionExtension)
Q_PLUGIN_METADATA(IID "fr.imag.camitk.tutorials.action.switchviewer")
Q_PLUGIN_METADATA(IID "fr.imag.camitk.tutorials.action.showbitmapviewer")
public:
/// the constructor
SwitchViewerExtension() : ActionExtension() {};
ShowBitmapViewerExtension() : ActionExtension() {};
/// the destructor
virtual ~SwitchViewerExtension() = default;
virtual ~ShowBitmapViewerExtension() = default;
/// initialize all the actions
virtual void init();
/// Method that return the action extension name
virtual QString getName() {
return "Switch Viewer";
return "Show Bitmap Viewer";
};
/// Method that return the action extension descrption
virtual QString getDescription() {
return "This extension contains a simple medical image viewer (axial slice) and a simple action to switch the central viewer (by default, the medical image viewer) to and from the simple medical image viewer.";
return "This extension contains a simple 2D bitmap viewer and a simple action to show this bitmap viewer in the central viewer.";
};
};
#endif // BASIC_PICKING_EXTENSION_H
#endif // SHOW_BITMAP_VIEWER_EXTENSION_H
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