Commit f5c0c40f authored by Emmanuel Promayon's avatar Emmanuel Promayon

NEW renamed arbitrary action + better GUI

parent 95f490bd
......@@ -22,7 +22,7 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "SetAnglesAction.h"
#include "AnglesAndTranslationAction.h"
// includes from CamiTK
#include <Application.h>
......@@ -32,15 +32,15 @@
#include <ImageComponent.h>
#include <Log.h>
#include "AnglesSetterWidget.h"
#include "AnglesAndTranslationWidget.h"
using namespace camitk;
// --------------- Constructor -------------------
SetAnglesAction::SetAnglesAction(ActionExtension* extension) : Action(extension) {
AnglesAndTranslationAction::AnglesAndTranslationAction(ActionExtension* extension) : Action(extension) {
// Setting name, description and input component
setName("Adjust Angles");
setDescription(tr("This action allows user to adjust the angle of the slice of the arbitrary viewer."));
setName("Modify Angles And Translation");
setDescription(tr("This action allows user to manually modify the orientation and translation of the arbitrary slice."));
setComponent("ImageComponent");
// Setting classification family and tags
......@@ -53,7 +53,7 @@ SetAnglesAction::SetAnglesAction(ActionExtension* extension) : Action(extension)
currentImageComp = nullptr;
blockEvent = true;
// the AnglesSetterWidget is going to modify these parameters using the GUI
// the AnglesAndTranslationWidget is going to modify these parameters using the GUI
// but defining them as the action parameters also allows to set them programmatically
// (for instance using another GUI or in a pipeline)
// Setting parameters default values by using properties
......@@ -79,22 +79,24 @@ SetAnglesAction::SetAnglesAction(ActionExtension* extension) : Action(extension)
}
// --------------- destructor -------------------
SetAnglesAction::~SetAnglesAction() {
AnglesAndTranslationAction::~AnglesAndTranslationAction() {
delete actionWidget;
}
// --------------- getWidget -------------------
QWidget* SetAnglesAction::getWidget() {
QWidget* AnglesAndTranslationAction::getWidget() {
if (!actionWidget) {
// TODO integrates https://github.com/aaronsnoswell/QMLVirtualJoystick
actionWidget = new AnglesSetterWidget(this);
actionWidget = new AnglesAndTranslationWidget(this);
// first call : force visibility of the arbitrary viewer
showArbitraryViewer(true);
setViewer(camitk::MedicalImageViewer::VIEWER_ARBITRARY);
}
// update the pointer
currentImageComp = dynamic_cast<ImageComponent*>(getTargets().last())->getArbitrarySlices();
// make sure the arbitrary slice is visible in 3D
currentImageComp->setViewSliceIn3D(true);
// update the properties
updateParameters();
......@@ -102,7 +104,7 @@ QWidget* SetAnglesAction::getWidget() {
}
// ---------------------- updateParameters ----------------------------
void SetAnglesAction::updateParameters() {
void AnglesAndTranslationAction::updateParameters() {
// update current action properties safely (i.e. without event(..) to be doing anything on the component)
blockEvent = true;
......@@ -110,28 +112,19 @@ void SetAnglesAction::updateParameters() {
setProperty("Translation", currentImageComp->getTranslationInVolume()*100.0);
// update widget
dynamic_cast<AnglesSetterWidget*>(actionWidget)->updateGUI();
dynamic_cast<AnglesAndTranslationWidget*>(actionWidget)->updateGUI();
// keep property up-to-date when the GUI will change
blockEvent = false;
}
// ---------------------- showArbitraryViewer ----------------------------
void SetAnglesAction::showArbitraryViewer(bool visible) {
if (visible) {
// keep the current value
visibleViewer = MedicalImageViewer::getInstance()->getVisibleViewer();
// force visibility of the arbitrary viewer
MedicalImageViewer::getInstance()->setVisibleViewer(MedicalImageViewer::VIEWER_ARBITRARY);
}
else {
// hide the arbitrary viewer
MedicalImageViewer::getInstance()->setVisibleViewer(visibleViewer);
}
// ---------------------- setViewer ----------------------------
void AnglesAndTranslationAction::setViewer(camitk::MedicalImageViewer::LayoutVisibility visibleViewer) {
MedicalImageViewer::getInstance()->setVisibleViewer(visibleViewer);
}
// ---------------------- resetTransform ----------------------------
void SetAnglesAction::resetTransform() {
void AnglesAndTranslationAction::resetTransform() {
currentImageComp->resetTransform();
// Reset the angle to zero
......@@ -146,7 +139,7 @@ void SetAnglesAction::resetTransform() {
}
// ---------------------- event ----------------------------
bool SetAnglesAction::event(QEvent* e) {
bool AnglesAndTranslationAction::event(QEvent* e) {
if (currentImageComp == nullptr || blockEvent)
return QObject::event(e);
......
......@@ -22,8 +22,8 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef SETANGLESACTION_H
#define SETANGLESACTION_H
#ifndef ANGLESANDTRANSLATIONACTION_H
#define ANGLESANDTRANSLATIONACTION_H
// CamiTK stuff
#include <QObject>
......@@ -39,17 +39,17 @@
* @brief
* This action simply display the widget allowing the user to select an angle to orientate the arbitrary slice.
*/
class ARBITRARY_SLICE_API SetAnglesAction : public camitk::Action {
class ARBITRARY_SLICE_API AnglesAndTranslationAction : public camitk::Action {
Q_OBJECT
public:
/// Default Constructor
SetAnglesAction(camitk::ActionExtension*);
AnglesAndTranslationAction(camitk::ActionExtension*);
/// Default Destructor
virtual ~SetAnglesAction();
virtual ~AnglesAndTranslationAction();
/// Return the arbitrary slice angles setter widget
virtual QWidget* getWidget();
......@@ -57,8 +57,8 @@ public:
/// manage change in the action parameters (angles and slice number)
virtual bool event(QEvent* e);
/// show or hide the arbitrary viewer
void showArbitraryViewer(bool);
/// show or hide the arbitrary viewer, 3D or all viewer
void setViewer(camitk::MedicalImageViewer::LayoutVisibility);
// reset transform to identity
void resetTransform();
......@@ -80,10 +80,7 @@ private:
/// block property changed event (temporarily)
bool blockEvent;
/// current visibility state of the medical image viewer
camitk::MedicalImageViewer::LayoutVisibility visibleViewer;
};
#endif // SETANGLESACTION_H
#endif // ANGLESANDTRANSLATIONACTION_H
......@@ -23,16 +23,16 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "AnglesSetterWidget.h"
#include "AnglesAndTranslationWidget.h"
// CamiTK stuff
#include <Property.h>
#include <SetAnglesAction.h>
#include <AnglesAndTranslationAction.h>
using namespace camitk;
// -------------------- constructor --------------------
AnglesSetterWidget::AnglesSetterWidget(SetAnglesAction* a, QWidget* parent): QWidget(parent) {
AnglesAndTranslationWidget::AnglesAndTranslationWidget(AnglesAndTranslationAction* a, QWidget* parent): QWidget(parent) {
myAction = a;
ui.setupUi(this);
......@@ -46,16 +46,18 @@ AnglesSetterWidget::AnglesSetterWidget(SetAnglesAction* a, QWidget* parent): QWi
connect(ui.yAngleDial, SIGNAL(valueChanged(int)), this, SLOT(yAngleDialValueChanged(int)));
connect(ui.zAngleDial, SIGNAL(valueChanged(int)), this, SLOT(zAngleDialValueChanged(int)));
connect(ui.showArbitraryViewer, SIGNAL(clicked(bool)), this, SLOT(showArbitraryViewer(bool)));
connect(ui.showArbitraryRadio, SIGNAL(clicked(bool)), this, SLOT(showArbitraryViewer(bool)));
connect(ui.show3DRadio, SIGNAL(clicked(bool)), this, SLOT(show3DViewer(bool)));
connect(ui.showAllRadio, SIGNAL(clicked(bool)), this, SLOT(showAllViewer(bool)));
connect(ui.resetButton, SIGNAL(clicked()), this, SLOT(resetTransform()));
}
// -------------------- destructor --------------------
AnglesSetterWidget::~AnglesSetterWidget() {
AnglesAndTranslationWidget::~AnglesAndTranslationWidget() {
}
// -------------------- updateGUI --------------------
void AnglesSetterWidget::updateGUI() {
void AnglesAndTranslationWidget::updateGUI() {
ui.translationSpinBox->blockSignals(true);
ui.translationSlider->blockSignals(true);
ui.translationSpinBox->setValue(myAction->property("Translation").toDouble());
......@@ -80,46 +82,66 @@ void AnglesSetterWidget::updateGUI() {
}
// -------------------- showArbitraryViewer --------------------
void AnglesSetterWidget::showArbitraryViewer(bool buttonState) {
myAction->showArbitraryViewer(buttonState);
void AnglesAndTranslationWidget::showArbitraryViewer(bool buttonState) {
if (buttonState) {
myAction->setViewer(camitk::MedicalImageViewer::VIEWER_ARBITRARY);
}
}
// -------------------- show3DViewer --------------------
void AnglesAndTranslationWidget::show3DViewer(bool buttonState) {
if (buttonState) {
myAction->setViewer(camitk::MedicalImageViewer::VIEWER_3D);
}
}
// -------------------- showAllViewer --------------------
void AnglesAndTranslationWidget::showAllViewer(bool buttonState) {
if (buttonState) {
myAction->setViewer(camitk::MedicalImageViewer::VIEWER_ALL);
}
}
// -------------------- updateAngleSliderLabel --------------------
void AnglesSetterWidget::resetTransform() {
void AnglesAndTranslationWidget::resetTransform() {
myAction->resetTransform();
}
// -------------------- translationSpinBoxChanged --------------------
void AnglesSetterWidget::translationSpinBoxChanged(double value) {
void AnglesAndTranslationWidget::translationSpinBoxChanged(double value) {
myAction->setProperty("Translation", value);
}
// -------------------- translationSliderChanged --------------------
void AnglesSetterWidget::translationSliderChanged(int value) {
void AnglesAndTranslationWidget::translationSliderChanged(int value) {
// the slide is from 0 to 1000
myAction->setProperty("Translation", value/10);
}
// -------------------- xAngleDialValueChanged --------------------
void AnglesSetterWidget::xAngleDialValueChanged(int value) {
void AnglesAndTranslationWidget::xAngleDialValueChanged(int value) {
myAction->setProperty("X Angle", value);
updateAngleSliderLabel(ui.xAngleDial);
}
// -------------------- yAngleDialValueChanged --------------------
void AnglesSetterWidget::yAngleDialValueChanged(int value) {
void AnglesAndTranslationWidget::yAngleDialValueChanged(int value) {
myAction->setProperty("Y Angle", value);
updateAngleSliderLabel(ui.yAngleDial);
}
// -------------------- zAngleDialValueChanged --------------------
void AnglesSetterWidget::zAngleDialValueChanged(int value) {
void AnglesAndTranslationWidget::zAngleDialValueChanged(int value) {
myAction->setProperty("Z Angle", value);
updateAngleSliderLabel(ui.zAngleDial);
}
// -------------------- updateAngleSliderLabel --------------------
void AnglesSetterWidget::updateAngleSliderLabel(QDial* dial) {
void AnglesAndTranslationWidget::updateAngleSliderLabel(QDial* dial) {
QString angleLetter;
QLabel *label;
......
......@@ -23,13 +23,13 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef AnglesSetterWidget_h
#define AnglesSetterWidget_h
#ifndef ANGLESANDTRANSLATIONWIDGET_H
#define ANGLESANDTRANSLATIONWIDGET_H
#include "ui_AnglesSetterWidget.h"
#include "ui_AnglesAndTranslationWidget.h"
#include <QWidget>
class SetAnglesAction;
class AnglesAndTranslationAction;
/**
* @ingroup group_sdk_actions_image_arbitraryslice
......@@ -43,15 +43,15 @@ class SetAnglesAction;
*
* Use corresponding .ui file created with Qt Designer.
*/
class AnglesSetterWidget : public QWidget {
class AnglesAndTranslationWidget : public QWidget {
Q_OBJECT
public:
/// Default construtor
AnglesSetterWidget(SetAnglesAction *, QWidget* parent = 0);
AnglesAndTranslationWidget(AnglesAndTranslationAction *, QWidget* parent = 0);
/// Destructor
virtual ~AnglesSetterWidget();
virtual ~AnglesAndTranslationWidget();
/// update the UI depending on the action
void updateGUI();
......@@ -67,8 +67,10 @@ private slots:
void yAngleDialValueChanged(int);
void zAngleDialValueChanged(int);
/// change the visibility of the axial viewer
/// switch to a specific viewer
void showArbitraryViewer(bool);
void show3DViewer(bool);
void showAllViewer(bool);
void resetTransform();
......@@ -77,10 +79,10 @@ private:
void updateAngleSliderLabel(QDial*);
// the GUI class itself
Ui::AnglesSetterWidget ui;
Ui::AnglesAndTranslationWidget ui;
/// the action to refer to
SetAnglesAction* myAction;
AnglesAndTranslationAction* myAction;
};
#endif // AnglesSetterWidget_h
#endif // ANGLESANDTRANSLATIONWIDGET_H
This diff is collapsed.
This diff is collapsed.
......@@ -25,11 +25,11 @@
#include "ArbitrarySliceExtension.h"
// include generated actions headers
#include "SetAnglesAction.h"
#include "AnglesAndTranslationAction.h"
// --------------- getActions -------------------
void ArbitrarySliceExtension::init() {
// Creating and registering the instance of AdjustArbiratrySliceAnglesAction
registerNewAction(SetAnglesAction);
registerNewAction(AnglesAndTranslationAction);
}
......@@ -52,7 +52,7 @@ public:
/// Method returning the action extension descrption
virtual QString getDescription() {
return "This extension gathers actions for manipulating 2D images arbitrary slice.";
return "This extension gathers actions for manipulating the arbitrary slice in a 3D image.";
};
/// initialize all the actions
......
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