Commit 5bde59a7 authored by Emmanuel Promayon's avatar Emmanuel Promayon

Merge branch 'feature/viewer-extension-instance-extension' into 'develop'

Feature/viewer extension

Closes #32, #93, #92, and #91

See merge request !141
parents 4f37ebc3 965608c3
......@@ -170,11 +170,11 @@ void MMLComponent::connectPml() {
delete pmlComponent;
pmlComponent = nullptr;
deleteChildren();
refreshInterfaceNode();
// this gives the ownership of pml pointer to the PML Component, use takePml() not getPml()
pmlComponent = new PMLComponent(mmlGUI->getMonitoringManager()->takePml(), mmlGUI->getMonitoringManager()->getPmlFileName().c_str());
addChild(pmlComponent);
refreshInterfaceNode();
refresh();
// This is forced refresh (bad, breaking rules)
// TODO: refresh should be called in the MMLDisplay connectPml() method instead)
......
......@@ -36,11 +36,11 @@
#include "MMLMonitorDisplay.h"
#include <PMLComponent.h>
#include <InteractiveViewer.h>
#include <QtGui>
#include <QTableWidget>
#include <QRadioButton>
#include <QComboBox>
#include "MMLMonitorDisplayFactory.h"
#include <MonitoringDriver.h>
......
......@@ -7,6 +7,7 @@ camitk_extension(COMPONENT_EXTENSION
DEFINES COMPILE_PML_COMPONENT_API
ENABLE_AUTO_TEST
TEST_FILES diaphragm.pml truthcube.pml
NEEDS_VIEWER_EXTENSION interactivegeometryviewer
)
# Additional test for SDK actions: this will add auto test for the given actions using the pmlcomponent
......
......@@ -24,7 +24,6 @@
****************************************************************************/
// CamiTK stuff
#include <Action.h>
#include <InteractiveViewer.h>
#include <Log.h>
#include <Geometry.h>
#include <Property.h>
......@@ -224,7 +223,7 @@ void PMLComponent::create3DStructure() {
initRepresentation(mainGrid);
// Tell this component is visible in the 3D viewer, otherwise we won't see it!
setVisibility(InteractiveViewer::get3DViewer(), true);
setVisibility("3D Viewer", true);
}
//-------------------- parseMultiComponent -------------------
......@@ -343,7 +342,7 @@ void PMLComponent::refreshDisplay() {
// for instance in a MML monitor) in order to obtain a real refresh
getPointSet()->Modified();
// This is a forced/active refresh (breaking CamiTK programming guidelines)
InteractiveViewer::get3DViewer()->refresh();
refresh();
// shade the current selected component in order to see the selected item (SC, MC, Atoms or Cells)
myGeometry->setEnhancedModes(InterfaceGeometry::Shaded);
}
......
......@@ -85,7 +85,6 @@ MonitoringDialog::MonitoringDialog(MonitoringGuiManager* guiManager, QWidget* pa
MonitoringDialog::~MonitoringDialog() {
// unselect and clear the monitor tab's content.
// this allow not to encounter crash when closing the image
// see bug 116 : https://forge.imag.fr/tracker/index.php?func=detail&aid=116&group_id=184&atid=792
this->ui->monitorsTable->clearContents();
QWidget* simulatorWidget = ui->monitoringTabs->widget(3);
if (simulatorWidget != nullptr) {
......
......@@ -109,8 +109,8 @@ camitk_parse_test_init()
camitk_add_subdirectory(libraries)
camitk_add_subdirectory(testapplications)
camitk_add_subdirectory(components)
camitk_add_subdirectory(actions)
camitk_add_subdirectory(viewers)
camitk_add_subdirectory(actions)
camitk_add_subdirectory(applications)
camitk_add_subdirectory(cmake) # for cmake module installation
......
......@@ -25,7 +25,6 @@
#include "ApplicationActionExtension.h"
#include <Action.h>
#include "OpenAction.h"
#include "OpenFile.h"
#include "SelectLastInstantiatedAction.h"
......@@ -40,18 +39,9 @@
#include "ToggleConsoleAction.h"
#include "AboutAction.h"
#include "RemoveLastInstantiatedAction.h"
#include "ShowAxialViewer.h"
#include "ShowCoronalViewer.h"
#include "ShowSagittalViewer.h"
#include "Show3DViewer.h"
#include "ShowAllViewers.h"
#include "ShowArbitraryViewer.h"
#include "ChangeLanguage.h"
#include "LoggerParameters.h"
// --------------- constructor -------------------
ApplicationActionExtension::ApplicationActionExtension() : ActionExtension() {};
// --------------- init -------------------
void ApplicationActionExtension::init() {
registerNewAction(OpenAction);
......@@ -69,12 +59,5 @@ void ApplicationActionExtension::init() {
registerNewAction(AboutAction);
registerNewAction(RemoveLastInstantiatedAction);
registerNewAction(ChangeLanguage);
// -- medical image viewer manipulation
registerNewAction(ShowAxialViewer);
registerNewAction(ShowCoronalViewer);
registerNewAction(ShowSagittalViewer);
registerNewAction(Show3DViewer);
registerNewAction(ShowAllViewers);
registerNewAction(ShowArbitraryViewer);
registerNewAction(LoggerParameters);
}
......@@ -23,15 +23,10 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef APPLICATION_ACTION_EXTENSION_H
#define APPLICATION_ACTION_EXTENSION_H
#include <ActionExtension.h>
#include <QPushButton>
#include <QDialogButtonBox>
/**
* @ingroup group_sdk_actions_application
......@@ -47,7 +42,7 @@ class ApplicationActionExtension : public camitk::ActionExtension {
public:
/// the constructor (needed to initialize the icon resources)
ApplicationActionExtension();
ApplicationActionExtension() = default;
/// the destructor
virtual ~ApplicationActionExtension() = default;
......
camitk_extension(ACTION_EXTENSION
DEFINES COMPILE_APPLICATION_ACTION_API
CEP_NAME SDK
DESCRIPTION "Features actions used at aplication level (these actions are mandatory for any CamiTK appliction to work)"
DESCRIPTION "Features actions used at aplication level (these actions are mandatory and required for CamiTK applications to work)"
)
if(NOT ACTION_APPLICATION)
......
......@@ -3,5 +3,5 @@ camitk_extension(ACTION_EXTENSION
DESCRIPTION "Manipulating Frames."
ENABLE_AUTO_TEST
TEST_FILES brain.mha structured.vtk
NEEDS_VIEWER_EXTENSION interactivegeometryviewer
)
......@@ -27,7 +27,6 @@
#include "FrameEditor.h"
// CamiTK
#include <InteractiveViewer.h>
#include <Log.h>
using namespace camitk;
......@@ -160,7 +159,7 @@ QWidget* FrameEditor::getWidget() {
void FrameEditor::initializeDialogWithCurrentComponent() {
// update checkbox
ui.displayFrameCheckBox->blockSignals(true);
bool isFrameDisplayed = currentComponent->getFrameVisibility(InteractiveViewer::get3DViewer());
bool isFrameDisplayed = currentComponent->getFrameVisibility("3D Viewer");
ui.displayFrameCheckBox->setChecked(isFrameDisplayed);
ui.displayFrameCheckBox->blockSignals(false);
......@@ -218,19 +217,18 @@ void FrameEditor::initializeDialogWithCurrentComponent() {
void FrameEditor::displayFrameToggled(bool display) {
int frameSize = ui.frameSizeSpinBox->value();
currentComponent->getFrameAxisActor()->SetTotalLength(frameSize, frameSize, frameSize);
currentComponent->setFrameVisibility(InteractiveViewer::get3DViewer(), display);
InteractiveViewer::get3DViewer()->refresh();
currentComponent->setFrameVisibility("3D Viewer", display);
Application::refresh();
}
// --------------- frameSizeChanged -------------------
void FrameEditor::frameSizeChanged(int val) {
bool display = ui.displayFrameCheckBox->isChecked();
currentComponent->getFrameAxisActor()->SetTotalLength(val, val, val);
currentComponent->setFrameVisibility(InteractiveViewer::get3DViewer(), display);
currentComponent->setFrameVisibility("3D Viewer", display);
InteractiveViewer::get3DViewer()->refresh();
Application::refresh();
}
// --------------- setParentFrame -------------------
......@@ -251,7 +249,7 @@ void FrameEditor::setParentFrame() {
}
currentComponent->setParentFrame(parentFrame, keepTransform);
InteractiveViewer::get3DViewer()->refresh();
Application::refresh();
initializeDialogWithCurrentComponent();
}
......@@ -300,7 +298,7 @@ void FrameEditor::setTransformation() {
matrixTransform->SetMatrix(matrix);
currentComponent->setTransform(matrixTransform);
InteractiveViewer::get3DViewer()->refresh();
Application::refresh();
initializeDialogWithCurrentComponent();
}
......@@ -315,7 +313,7 @@ void FrameEditor::translate() {
ui.yTranslationLineEdit->text().toDouble(),
ui.zTranslationLineEdit->text().toDouble());
InteractiveViewer::get3DViewer()->refresh();
Application::refresh();
initializeDialogWithCurrentComponent();
}
......@@ -325,7 +323,7 @@ void FrameEditor::setTranslation() {
ui.yTranslationLineEdit->text().toDouble(),
ui.zTranslationLineEdit->text().toDouble());
InteractiveViewer::get3DViewer()->refresh();
Application::refresh();
initializeDialogWithCurrentComponent();
}
......@@ -348,7 +346,7 @@ void FrameEditor::rotate() {
ui.zRotationLineEdit->text().toDouble());
}
InteractiveViewer::get3DViewer()->refresh();
Application::refresh();
initializeDialogWithCurrentComponent();
}
......@@ -365,7 +363,7 @@ void FrameEditor::setRotation() {
ui.zRotationLineEdit->text().toDouble());
}
InteractiveViewer::get3DViewer()->refresh();
Application::refresh();
initializeDialogWithCurrentComponent();
}
......
......@@ -26,8 +26,7 @@
#ifndef FRAMEEDITOR_H
#define FRAMEEDITOR_H
#include "Action.h"
#include "Component.h"
#include <Action.h>
#include <QVector>
#include <QLineEdit>
......
......@@ -28,9 +28,7 @@
#include <Application.h>
#include <Property.h>
#include <MedicalImageViewer.h>
#include <InteractiveViewer.h>
#include <ImageComponent.h>
#include <Log.h>
// to get the enum as a string
#include <QMetaEnum>
......@@ -123,7 +121,11 @@ void AnglesAndTranslationAction::update() {
// update central viewer
MedicalImageViewer::LayoutVisibility visibleViewer = static_cast<MedicalImageViewer::LayoutVisibility>(property("Visible Viewer").toInt());
MedicalImageViewer::getInstance()->setVisibleViewer(visibleViewer);
MedicalImageViewer* medicalImageViewer = dynamic_cast<MedicalImageViewer*>(Application::getViewer("Medical Image Viewer"));
if (medicalImageViewer != nullptr) {
medicalImageViewer->setVisibleViewer(visibleViewer);
}
// keep property up-to-date when the GUI will change
blockEvent = false;
......
......@@ -57,7 +57,7 @@ public:
/// manage change in the action parameters (angles and slice number)
virtual bool event(QEvent* e);
// reset transform to identity
/// reset transform to identity
void resetTransform();
public slots:
......
......@@ -84,21 +84,21 @@ void AnglesAndTranslationWidget::updateGUI() {
// -------------------- showArbitraryViewer --------------------
void AnglesAndTranslationWidget::showArbitraryViewer(bool buttonState) {
if (buttonState) {
myAction->setProperty("Visible Viewer", camitk::MedicalImageViewer::VIEWER_ARBITRARY);
myAction->setProperty("Visible Viewer", MedicalImageViewer::VIEWER_ARBITRARY);
}
}
// -------------------- show3DViewer --------------------
void AnglesAndTranslationWidget::show3DViewer(bool buttonState) {
if (buttonState) {
myAction->setProperty("Visible Viewer", camitk::MedicalImageViewer::VIEWER_3D);
myAction->setProperty("Visible Viewer", MedicalImageViewer::VIEWER_3D);
}
}
// -------------------- showAllViewer --------------------
void AnglesAndTranslationWidget::showAllViewer(bool buttonState) {
if (buttonState) {
myAction->setProperty("Visible Viewer", camitk::MedicalImageViewer::VIEWER_ALL);
myAction->setProperty("Visible Viewer", MedicalImageViewer::VIEWER_ALL);
}
}
......
......@@ -2,6 +2,7 @@ camitk_extension(ACTION_EXTENSION
DEFINES COMPILE_ARBITRARY_SLICE_API
CEP_NAME SDK
DESCRIPTION "Control of the arbitrary slice on image component"
NEEDS_VIEWER_EXTENSION medicalimageviewer
ENABLE_AUTO_TEST
TEST_FILES Mesh.off brain.mha sinus.mhd
)
......
......@@ -2,6 +2,7 @@
camitk_extension(ACTION_EXTENSION
DEFINES COMPILE_PIXELCOLORCHANGER_ACTION_API
CEP_NAME SDK
NEEDS_VIEWER_EXTENSION interactivesliceviewer
DESCRIPTION "Allows changing the color of the image pixels"
ENABLE_AUTO_TEST
TEST_FILES mixed_3D_beam.msh brain.mha sinus.mhd
......
......@@ -25,7 +25,7 @@
// CamiTK includes
#include "PixelColorChanger.h"
#include <Application.h>
#include <InteractiveViewer.h>
#include <InteractiveSliceViewer.h>
#include <Property.h>
......@@ -75,22 +75,25 @@ PixelColorChanger::PixelColorChanger(ActionExtension* extension) : Action(extens
isConnected = false;
}
QWidget* PixelColorChanger::getWidget() {
if (!isConnected) {
//-- run the action every time a picking is done in the axial/sagittal or coronal planes
QObject::connect(InteractiveViewer::getAxialViewer(), SIGNAL(selectionChanged()), this, SLOT(apply()));
QObject::connect(InteractiveViewer::getCoronalViewer(), SIGNAL(selectionChanged()), this, SLOT(apply()));
QObject::connect(InteractiveViewer::getSagittalViewer(), SIGNAL(selectionChanged()), this, SLOT(apply()));
isConnected = true;
}
return Action::getWidget();
}
// --------------- destructor -------------------
PixelColorChanger::~PixelColorChanger() {
// 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)
}
// --------------- destructor -------------------
QWidget* PixelColorChanger::getWidget() {
if (!isConnected) {
if (Application::getViewer("Axial Viewer") != nullptr) {
//-- run the action every time a picking is done in the axial/sagittal or coronal planes
QObject::connect(Application::getViewer("Axial Viewer"), SIGNAL(selectionChanged()), this, SLOT(apply()));
QObject::connect(Application::getViewer("Coronal Viewer"), SIGNAL(selectionChanged()), this, SLOT(apply()));
QObject::connect(Application::getViewer("Sagittal Viewer"), SIGNAL(selectionChanged()), this, SLOT(apply()));
isConnected = true;
}
}
return Action::getWidget();
}
// --------------- apply -------------------
Action::ApplyStatus PixelColorChanger::apply() {
// check if widget is still visible, otherwise disconnect action
......@@ -218,11 +221,14 @@ Action::ApplyStatus PixelColorChanger::apply() {
QApplication::restoreOverrideCursor();
}
else {
// disconnect
QObject::disconnect(InteractiveViewer::getAxialViewer(), SIGNAL(selectionChanged()), this, SLOT(apply()));
QObject::disconnect(InteractiveViewer::getCoronalViewer(), SIGNAL(selectionChanged()), this, SLOT(apply()));
QObject::disconnect(InteractiveViewer::getSagittalViewer(), SIGNAL(selectionChanged()), this, SLOT(apply()));
isConnected = false;
if (Application::getViewer("Axial Viewer") != nullptr) {
// disconnect
QObject::disconnect(Application::getViewer("Axial Viewer"), SIGNAL(selectionChanged()), this, SLOT(apply()));
QObject::disconnect(Application::getViewer("Coronal Viewer"), SIGNAL(selectionChanged()), this, SLOT(apply()));
QObject::disconnect(Application::getViewer("Sagittal Viewer"), SIGNAL(selectionChanged()), this, SLOT(apply()));
isConnected = false;
}
}
return SUCCESS;
}
......@@ -23,18 +23,13 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
// -- Core image component stuff classes
#include "ImageReconstructionAction.h"
#include "ImageComponent.h"
#include "MeshComponent.h"
// -- Core stuff classes
#include <Application.h>
#include <Property.h>
#include <ImageComponent.h>
// -- stl stuff
#include <sstream>
#include <MeshComponent.h>
// -- vtk filters stuff
#include <vtkImageResample.h>
......
# Call CamiTK CMake Macro to define the action
camitk_extension(ACTION_EXTENSION
NEEDS_COMPONENT_EXTENSION vtkmesh
NEEDS_VIEWER_EXTENSION interactivegeometryviewer
CEP_NAME SDK
DESCRIPTION "Allows one to reorient a volumic image."
ENABLE_AUTO_TEST
......
......@@ -28,7 +28,7 @@
// CamiTK
#include <Core.h>
#include <InteractiveViewer.h>
#include <InteractiveGeometryViewer.h>
#include <Log.h>
#include <ImageComponent.h>
#include <ImageOrientationHelper.h>
......@@ -87,24 +87,24 @@ ReorientImage::ReorientImage(ActionExtension* extension) : Action(extension) {
lettersMeaning.insert('S', SMeaning);
// see initDialog
dialog = NULL;
dialog = nullptr;
// see buildAxes
axes = NULL;
axes = nullptr;
// see buildCube
annotatedCube = NULL;
annotatedCube = nullptr;
orientationTransform = NULL;
axesTransform = NULL;
orientationCubeTransform = NULL;
cubeTransform = NULL;
orientationTransform = nullptr;
axesTransform = nullptr;
orientationCubeTransform = nullptr;
cubeTransform = nullptr;
// see buildGeometries for the 3D representation
internalViewer = NULL;
modelBoundingBox = NULL;
maleModel = NULL;
femaleModel = NULL;
internalViewer = nullptr;
modelBoundingBox = nullptr;
maleModel = nullptr;
femaleModel = nullptr;
// these properties are for pipeline users to set parameters
Property* useMaleModel = new Property("Use Male Model", QVariant(true), tr("Use male or female model for image orientation illustration"), "");
......@@ -117,28 +117,26 @@ ReorientImage::ReorientImage(ActionExtension* extension) : Action(extension) {
// --------------- destructor -------------------
ReorientImage::~ReorientImage() {
axes = NULL;
annotatedCube = NULL;
axes = nullptr;
annotatedCube = nullptr;
delete modelBoundingBox;
modelBoundingBox = NULL;
modelBoundingBox = nullptr;
delete femaleModel;
femaleModel = NULL;
femaleModel = nullptr;
delete maleModel;
maleModel = NULL;
delete dialog;
dialog = NULL;
maleModel = nullptr;
}
// --------------- initDialog -------------------
void ReorientImage::initDialog() {
dialog = new QDialog();
dialog = new QFrame();
//-- init user interface
ui.setupUi(dialog);
//-- add the internal viewer
initInternalViewer();
ui.illustrationLayout->addWidget(internalViewer->getWidget(dialog));
internalViewer->setEmbedder(ui.illustrationLayout);
ui.xDirection->setTextFormat(Qt::RichText);
ui.yDirection->setTextFormat(Qt::RichText);
......@@ -192,8 +190,9 @@ void ReorientImage::initInternalViewer() {
buildGeometries();
// Set up the 3D viewer to visualize actual origin/orientation locations
internalViewer = InteractiveViewer::getNewViewer("Image Orientation Viewer", InteractiveViewer::GEOMETRY_VIEWER);
internalViewer->setHighlightMode(InteractiveViewer::OFF);
internalViewer = dynamic_cast<InteractiveGeometryViewer*>(Application::getNewViewer("Image Orientation Viewer", "InteractiveGeometryViewer"));
internalViewer->setProperty("Highlight Mode",InteractiveViewer::OFF);
internalViewer->setHighlightMode();
internalViewer->toggleCopyright(false);
internalViewer->getRendererWidget()->setCameraOrientation(RendererWidget::RIGHT_DOWN);
......@@ -220,7 +219,7 @@ void ReorientImage::rcsChanged(const QString index) {
// --------------- modelChanged -------------------
void ReorientImage::modelChanged(bool displayMaleModel) {
if (femaleModel == NULL || maleModel == NULL) {
if (femaleModel == nullptr || maleModel == nullptr) {
return;
}
......@@ -333,7 +332,7 @@ Action::ApplyStatus ReorientImage::process(ImageComponent* image) {
updatedTransform->SetMatrix(updatedMatrix);
image->setTransform(updatedTransform);
image->setFrameVisibility(InteractiveViewer::get3DViewer(), true);
image->setFrameVisibility("3D Viewer", true);
}
else {
......@@ -357,9 +356,8 @@ Action::ApplyStatus ReorientImage::process(ImageComponent* image) {
updatedTransform->SetMatrix(updatedMatrix);
result->setTransform(updatedTransform);
result->setFrameVisibility(InteractiveViewer::get3DViewer(), true);
result->setFrameVisibility("3D Viewer", true);
}
InteractiveViewer::get3DViewer()->refresh();
Application::refresh();
......
......@@ -31,12 +31,13 @@
// Include ui_ReorientImage.h to be able to declare an instance of Ui::ReorientImage
#include "ui_ReorientImage.h"
#include <InteractiveGeometryViewer.h>
class vtkTransform;
class vtkAnnotatedCubeActor;
namespace camitk {
class Geometry;
class ImageComponent;
class InteractiveViewer;
}
class ReorientImage : public camitk::Action {
......@@ -77,7 +78,7 @@ private:
void setAxesOrientation(const QString orientation);