Commit 2c30e243 authored by Flavien BRIDAULT-LOUCHEZ's avatar Flavien BRIDAULT-LOUCHEZ
Browse files

merge(dev): release 12.1.0

parents 7af05629 56aa9ee9
......@@ -15,7 +15,6 @@
<object uid="${AS_UID}" type="::fwMedData::ActivitySeries" src="ref" />
<object uid="${backgroundImageUid}" type="::fwData::Image" src="ref" />
<object uid="${frontImageUid}" type="::fwData::Image" src="ref" />
<object uid="myBlendSelectionComposite" type="::fwData::Composite" />
<object uid="TFComposite" type="::fwData::Composite" />
<service uid="mainView" type="::gui::view::SDefaultView">
......@@ -54,10 +53,6 @@
<inout key="series" uid="${AS_UID}" />
</service>
<service uid="myManagerLockDump" type="::ctrlMemory::manager::LockDumpManagerSrv" autoConnect="yes">
<in key="composite" uid="myBlendSelectionComposite" />
</service>
<service uid="medicalImageFrontSrv" type="::ctrlSelection::MedicalImageSrv">
<inout key="image" uid="${frontImageUid}" />
</service>
......@@ -68,7 +63,6 @@
<service uid="action_blendView" type="::gui::action::SConfigLauncher">
<state active="true" />
<inout key="myBlendSelectionComposite" uid="myBlendSelectionComposite" />
<inout key="TF_COMPOSITE_ID" uid="TFComposite" />
<inout key="backgroundImageUid" uid="${backgroundImageUid}" />
<inout key="frontImageUid" uid="${frontImageUid}" />
......@@ -96,7 +90,6 @@
<!-- START AND STOP SERVICES -->
<start uid="mainView" />
<start uid="myManagerLockDump" />
<start uid="medicalImageFrontSrv" />
<start uid="medicalImageBgSrv" />
<start uid="action_blendView" />
......
......@@ -3,7 +3,6 @@
<parameters>
<param name="WID_PARENT" />
<param name="GENERIC_UID" />
<param name="myBlendSelectionComposite" />
<param name="TF_COMPOSITE_ID" />
<param name="SELECTED_TF_KEYA" />
<param name="SELECTED_TF_KEYB" />
......@@ -13,7 +12,6 @@
</parameters>
<config>
<object uid="${TF_COMPOSITE_ID}" type="::fwData::Composite" src="ref" />
<object uid="${myBlendSelectionComposite}" type="::fwData::Composite" src="ref" />
<object uid="${backgroundImageUid}" type="::fwData::Image" src="ref" />
<object uid="${frontImageUid}" type="::fwData::Image" src="ref" />
<service uid="mainView" type="::gui::view::SDefaultView" autoConnect="no">
......@@ -100,9 +98,7 @@
</registry>
</service>
<service uid="snapshot" type="::uiVisuQt::SnapshotEditor" autoConnect="no">
<in key="object" uid="${myBlendSelectionComposite}" />
</service>
<service uid="snapshot" type="::uiVisuQt::SnapshotEditor" autoConnect="no" />
<service type="::ctrlMemory::LockDumpSrv" autoConnect="no">
<in key="image" uid="${backgroundImageUid}" />
......
......@@ -20,8 +20,6 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/mat4x4.hpp>
#include <QHBoxLayout>
......@@ -223,9 +221,10 @@ void STransformEditor::onSliderChanged(int value)
const double ty = m_sliders[POSITION_Y].m_slider->value();
const double tz = m_sliders[POSITION_Z].m_slider->value();
::glm::dmat4x4 mat;
mat = ::glm::translate(mat, ::glm::dvec3(tx, ty, tz));
mat = ::glm::yawPitchRoll(ry, rx, rz) * mat;
::glm::dquat quat = ::glm::dquat(::glm::dvec3(rx, ry, rz));
::glm::dmat4x4 mat = ::glm::mat4_cast(quat);
mat[3] = ::glm::dvec4(tx, ty, tz, 1.);
::fwDataTools::TransformationMatrix3D::setTF3DFromMatrix(matrix, mat);
......
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2017.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#ifndef __VISUVTKADAPTOR_S2DWHEEL_HPP__
#define __VISUVTKADAPTOR_S2DWHEEL_HPP__
#include "visuVTKAdaptor/config.hpp"
#include <fwCom/Signal.hpp>
#include <fwRenderVTK/IAdaptor.hpp>
#include <fwRenderVTK/vtk/fwVtkWheelWidget.hpp>
#include <fwVtkIO/helper/vtkLambdaCommand.hpp>
#include <vtkSmartPointer.h>
namespace visuVTKAdaptor
{
/**
* @brief Render a rotatable 2D wheel in screen-space.
*
* @section Slots Slots
* -\b updateVisibility(bool): sets the wheel visibility.
*
* @section Signals Signals
* -\b wheelUpdated(double, double, double): sends wheel position and angle when it is modified by the user.
*
* @section XML XML Configuration
*
* @code{.xml}
<service type="::visuVTKAdaptor::S2DWheel">
<config renderer="default" visible="true" />
</service>
@endcode
* @subsection Configuration Configuration
* - \b renderer(mandatory) : defines the renderer to show the wheel.
* - \b visible (optional, default: true) : makes the widget visible at start.
*/
class VISUVTKADAPTOR_CLASS_API S2DWheel : public ::fwRenderVTK::IAdaptor
{
public:
fwCoreServiceClassDefinitionsMacro( (S2DWheel)(::fwRenderVTK::IAdaptor) );
typedef ::fwCom::Signal<void (double, double, double)> WheelUpdatedSignalType;
/// Constructor. Does nothing.
VISUVTKADAPTOR_API S2DWheel() noexcept;
/// Destructor. Does nothing.
VISUVTKADAPTOR_API virtual ~S2DWheel() noexcept;
protected:
VISUVTKADAPTOR_API virtual void configuring() override;
/// Instantiates the widget and puts it in the scene.
VISUVTKADAPTOR_API virtual void starting() override;
/// Does nothing.
VISUVTKADAPTOR_API virtual void updating() override;
/// Disables the widget.
VISUVTKADAPTOR_API virtual void stopping() override;
private:
/// Slot: update wheel visibility (true = visible)
VISUVTKADAPTOR_API void updateVisibility ( bool isVisible );
/// Wheel widget.
vtkSmartPointer< fwVtkWheelWidget > m_wheelWidget;
/// Called when the VTK viewport is resized. Scales the widget accordingly.
vtkSmartPointer< ::fwVtkIO::helper::vtkLambdaCommand > m_resizeCallback;
/// Signal sending the wheel position and angle.
WheelUpdatedSignalType::sptr m_wheelUpdatedSignal;
/// Widget visibility.
bool m_visible;
};
} // namespace visuVTKAdaptor
#endif // __VISUVTKADAPTOR_S2DWHEEL_HPP__
......@@ -41,7 +41,7 @@ namespace visuVTKAdaptor
* @section XML XML Configuration
*
* @code{.xml}
<service type="::visuVTKAdaptor::SNegatoOneSlice" autoConnect="yes">
<service type="::visuVTKAdaptor::SImageSlice" autoConnect="yes">
<inout key="image" uid="..." />
<config renderer="default" picker="negatodefault" sliceIndex="axial"
transform="trf" ctrlimage="imageKey" interpolation="off" vtkimagesource="imgSource"
......
......@@ -158,6 +158,9 @@ private:
/// Number of division in checkerboard mode
int m_checkerboardDivision;
/// Number of Z divisions for checkerboard (=1 if it is a 2D image)
int m_zDivision;
};
} //namespace visuVTKAdaptor
......
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2017.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#ifndef __VISUVTKADAPTOR_STRANSFORMFROMWHEEL_HPP__
#define __VISUVTKADAPTOR_STRANSFORMFROMWHEEL_HPP__
#include "visuVTKAdaptor/config.hpp"
#include <fwDataTools/helper/MedicalImageAdaptor.hpp>
#include <fwRenderVTK/IAdaptor.hpp>
namespace visuVTKAdaptor
{
/**
* @brief Computes a volume space transform matrix from a viewport coordinate and a rotation angle.
*
* @section Slots Slots
*
* -\b updateTransform(double, double, double) : computes the transform
* -\b updateSliceOrientation(int, int): updates slice orientation
*
* @section XML XML Configuration
*
* @code{.xml}
<service type="::visuVTKAdaptor::STransformFromWheel" >
<inout key="image" uid="..." />
<inout key="transform" uid="..." />
<config renderer="default" picker="myPicker" mode="2d" />
</service>
*
* @subsection In-Out In-Out
* - \b image [::fwData::Image]: defines the space in which the transform takes place.
* - \b transform [::fwData::TransformationMatrix3D]: outputed image space transform.
*
* @subsection Configuration Configuration
* - \b renderer (mandatory): renderer in which the image is displayed.
* - \b picker (mandatory): used to find image voxel positions from a viewport pixel position.
* - \b mode (optional, defaults to 2d) : determines how the position of the coordinates are computed.
* In 2d, the coordinates are permutated to match the correct, whereas in 3d,
* we do not change the picked position.
*
*/
class VISUVTKADAPTOR_CLASS_API STransformFromWheel : public ::fwRenderVTK::IAdaptor,
public ::fwDataTools::helper::MedicalImageAdaptor
{
public:
fwCoreServiceClassDefinitionsMacro( (STransformFromWheel)(::fwRenderVTK::IAdaptor) );
/// Constructor.
VISUVTKADAPTOR_API STransformFromWheel();
/// Destructor.
VISUVTKADAPTOR_API virtual ~STransformFromWheel();
protected:
VISUVTKADAPTOR_API virtual void configuring() override;
VISUVTKADAPTOR_API virtual void starting() override;
VISUVTKADAPTOR_API virtual void updating() override;
VISUVTKADAPTOR_API virtual void stopping() override;
/**
* @brief Returns proposals to connect service slots to object signals.
*
* Connect image::s_SLICE_TYPE_MODIFIED_SIG to this::s_UPDATE_SLICE_TYPE_SLOT.
*/
VISUVTKADAPTOR_API virtual KeyConnectionsMap getAutoConnections() const override;
private:
/// Computes the transform based on the (cx, cy) wheel center and the wheel angle.
void updateTransform(double cx, double cy, double wheelAngle);
/// Slot: set the correct orientation to compute the right transform.
void updateSliceOrientation(int from, int to);
/// Interaction mode: determines how the picked point is handled (default to 2d)
unsigned char m_interactionMode;
/// Initial wheel position. Updated each time updateTransform() is called.
double m_initAngle;
};
} // namespace visuVTKAdaptor
#endif // __VISUVTKADAPTOR_STRANSFORMFROMWHEEL_HPP__
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2017.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#include "visuVTKAdaptor/S2DWheel.hpp"
#include <fwCom/Signal.hxx>
#include <fwCom/Slot.hxx>
#include <fwCom/Slots.hxx>
#include <fwServices/macros.hpp>
#include <fwVtkIO/helper/vtkLambdaCommand.hpp>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
fwServicesRegisterMacro( ::fwRenderVTK::IAdaptor, ::visuVTKAdaptor::S2DWheel);
namespace visuVTKAdaptor
{
static const ::fwCom::Signals::SignalKeyType s_WHEEL_UPDATED_SIG = "wheelUpdated";
static const ::fwCom::Slots::SlotKeyType s_UPDATE_VISIBILITY_SLOT = "updateVisibility";
//------------------------------------------------------------------------------
S2DWheel::S2DWheel() noexcept :
m_wheelWidget(vtkSmartPointer<fwVtkWheelWidget>::New()),
m_visible(true)
{
m_wheelUpdatedSignal = newSignal<WheelUpdatedSignalType>(s_WHEEL_UPDATED_SIG);
newSlot(s_UPDATE_VISIBILITY_SLOT, &S2DWheel::updateVisibility, this);
}
//------------------------------------------------------------------------------
S2DWheel::~S2DWheel() noexcept
{
}
//------------------------------------------------------------------------------
void S2DWheel::configuring()
{
this->configureParams();
const ConfigType& config = this->getConfigTree();
m_visible = config.get<bool>("config.<xmlattr>.visible", true);
}
//------------------------------------------------------------------------------
void S2DWheel::starting()
{
this->initialize();
fwVtkWheelRepresentation* wheelRepresentation = fwVtkWheelRepresentation::New();
wheelRepresentation->SetVisibility(m_visible);
m_wheelWidget->SetInteractor(this->getRenderer()->GetRenderWindow()->GetInteractor());
m_wheelWidget->SetPriority(1.f); // Set a priority higher than that of the ::visuVTKAdaptor::SProbeCursor
m_wheelWidget->SetRepresentation(wheelRepresentation);
m_wheelWidget->On();
m_wheelWidget->SetWheelUpdateCallback([this](double cx, double cy, double o)
{
OSLM_DEBUG("Center : " << "(" << cx << ", " << cy << "), Orientation : " << o);
this->m_wheelUpdatedSignal->asyncEmit(cx, cy, o);
});
m_resizeCallback = vtkSmartPointer< ::fwVtkIO::helper::vtkLambdaCommand >::New();
m_resizeCallback->SetCallback(
[this](vtkObject*, long unsigned int, void* )
{
const int viewportWidth = this->getRenderer()->GetRenderWindow()->GetSize()[0];
const int viewportHeight = this->getRenderer()->GetRenderWindow()->GetSize()[1];
if(viewportHeight != 0 && viewportWidth != 0)
{
this->m_wheelWidget->GetRepresentation()->UpdateRepresentation();
}
this->requestRender();
});
this->getRenderer()->GetRenderWindow()->AddObserver(vtkCommand::ModifiedEvent, m_resizeCallback);
this->setVtkPipelineModified();
this->requestRender();
}
//------------------------------------------------------------------------------
void S2DWheel::stopping()
{
m_wheelWidget->Off();
this->getRenderer()->GetRenderWindow()->RemoveObserver(m_resizeCallback);
this->removeAllPropFromRenderer();
this->requestRender();
}
//------------------------------------------------------------------------------
void S2DWheel::updating()
{
}
//------------------------------------------------------------------------------
void S2DWheel::updateVisibility(bool _isVisible)
{
m_visible = _isVisible;
this->m_wheelWidget->GetRepresentation()->SetVisibility(static_cast<int>(_isVisible));
this->setVtkPipelineModified();
this->requestRender();
}
//------------------------------------------------------------------------------
} // namespace visuVTKAdaptor
......@@ -55,7 +55,8 @@ static const ::fwServices::IService::KeyType s_TF_SELECTION_GROUP = "tfSelection
SImagesBlend::SImagesBlend() noexcept :
m_imageAlgorithm(nullptr),
m_checkerboardDivision(10)
m_checkerboardDivision(10),
m_zDivision(m_checkerboardDivision)
{
newSlot(s_CHANGE_MODE_SLOT, &SImagesBlend::changeMode, this);
newSlot(s_CHANGE_CHECKERBOARD_DIVISION_SLOT, &SImagesBlend::changeCheckerboardDivision, this);
......@@ -82,18 +83,7 @@ void SImagesBlend::starting()
if(nullptr == m_imageAlgorithm)
{
// If we have no vtkImageBlend, try to downcast as an vtkImageCheckerboard
vtkImageCheckerboard* imageCheckerboard =
vtkImageCheckerboard::SafeDownCast(this->getVtkObject(m_imageRegisterId));
if(nullptr != imageCheckerboard)
{
// Set the number of subdivision
imageCheckerboard->SetNumberOfDivisions(m_checkerboardDivision, m_checkerboardDivision,
m_checkerboardDivision);
// Assign as an vtkThreadedImageAlgorithm
m_imageAlgorithm = imageCheckerboard;
}
m_imageAlgorithm = vtkImageCheckerboard::SafeDownCast(this->getVtkObject(m_imageRegisterId));
}
// If we have a null m_imageAlgorithm, then we have a problem Houston
......@@ -101,6 +91,9 @@ void SImagesBlend::starting()
nullptr != m_imageAlgorithm);
this->addImageAdaptors();
// Set the divisions once all image info has been gathered.
this->changeCheckerboardDivision(m_checkerboardDivision);
}
//------------------------------------------------------------------------------
......@@ -195,6 +188,10 @@ bool SImagesBlend::checkImageInformations()
size = img->getSize();
spacing = img->getSpacing();
origin = img->getOrigin();
if(size[2] <= 1)
{
m_zDivision = 1;
}
}
else
{
......@@ -317,7 +314,7 @@ void SImagesBlend::changeMode(std::string _value, std::string _key)
{
// Set the number of subdivision
imageCheckerboard->SetNumberOfDivisions(m_checkerboardDivision, m_checkerboardDivision,
m_checkerboardDivision);
m_zDivision);
// Assign as an vtkThreadedImageAlgorithm
m_imageAlgorithm = imageCheckerboard;
......@@ -370,7 +367,7 @@ void SImagesBlend::changeCheckerboardDivision(const int division)
{
// Set the number of subdivision
imageCheckerboard->SetNumberOfDivisions(m_checkerboardDivision, m_checkerboardDivision,
m_checkerboardDivision);
m_zDivision);
// Assign as an vtkThreadedImageAlgorithm
m_imageAlgorithm = imageCheckerboard;
......
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2017.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#include "visuVTKAdaptor/STransformFromWheel.hpp"
#include <fwCom/Slot.hxx>
#include <fwCom/Slots.hxx>
#include <fwData/Image.hpp>
#include <fwData/TransformationMatrix3D.hpp>
#include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp>
#include <fwDataTools/TransformationMatrix3D.hpp>
#include <fwRenderVTK/vtk/Helpers.hpp>
#include <fwServices/macros.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
#include <vtkAbstractPropPicker.h>
namespace visuVTKAdaptor
{
fwServicesRegisterMacro( ::fwRenderVTK::IAdaptor, ::visuVTKAdaptor::STransformFromWheel);
static const ::fwCom::Slots::SlotKeyType s_UPDATE_TRANSFORM_SLOT = "updateTransform";
static const ::fwCom::Slots::SlotKeyType s_UPDATE_SLICE_TYPE_SLOT = "updateSliceType";
static const ::fwServices::IService::KeyType s_IMAGE_INOUT = "image";
static const ::fwServices::IService::KeyType s_TRANSFORM_INOUT = "transform";
//------------------------------------------------------------------------------
STransformFromWheel::STransformFromWheel() :
m_interactionMode(2),
m_initAngle(0.)
{
newSlot(s_UPDATE_TRANSFORM_SLOT, &STransformFromWheel::updateTransform, this);
newSlot(s_UPDATE_SLICE_TYPE_SLOT, &STransformFromWheel::updateSliceOrientation, this);
}
//------------------------------------------------------------------------------
STransformFromWheel::~STransformFromWheel()
{
}
//------------------------------------------------------------------------------
void STransformFromWheel::configuring()
{
this->configureParams();
const ConfigType config = this->getConfigTree().get_child("config.<xmlattr>");
const std::string interactionMode = config.get<std::string>("mode", "2D");
if(interactionMode == "2d" || interactionMode == "2D")
{
m_interactionMode = 2;
}
else if(interactionMode == "3d" || interactionMode == "3D")
{
m_interactionMode = 3;
}
else
{
SLM_WARN("Wrong interaction mode specified. Set to 2D.")
}
}
//------------------------------------------------------------------------------
void STransformFromWheel::starting()
{
this->initialize();
}
//------------------------------------------------------------------------------
void STransformFromWheel::updating()
{
}
//------------------------------------------------------------------------------
void STransformFromWheel::stopping()
{
}
//------------------------------------------------------------------------------
::fwServices::IService::KeyConnectionsMap STransformFromWheel::getAutoConnections() const
{
KeyConnectionsMap connections;