7 #include "fwRenderQt/IAdaptor.hpp" 9 #include "fwRenderQt/registry/Adaptor.hpp" 10 #include "fwRenderQt/Scene2DGraphicsView.hpp" 12 #include <fwServices/macros.hpp> 13 #include <fwServices/registry/ObjectService.hpp> 15 #include <QGraphicsItemGroup> 50 const auto&
registry = ::fwRenderQt::registry::getAdaptorRegistry();
54 ::fwRenderQt::SRender::sptr render =
56 SLM_ASSERT(
"Service SRender "+ iter->second +
" not instanced", render);
65 (
float) (
m_viewInitialSize.first / this->getScene2DRender()->getView()->width() ),
73 const ::fwRenderQt::data::Viewport::csptr& viewport = this->
getScene2DRender()->getViewport();
86 return Scene2DRatio( ratioView.first / ratioViewport.first,
87 ratioView.second / ratioViewport.second );
93 const ::fwRenderQt::data::Axis::sptr& _xAxis,
94 const ::fwRenderQt::data::Axis::sptr& _yAxis )
const 98 if (_xAxis->getScaleType() == ::fwRenderQt::data::Axis::LOG)
108 x = _xAxis->getScale() * log10( _xy.first );
114 x = _xAxis->getScale() * _xy.first;
117 if (_yAxis->getScaleType() == ::fwRenderQt::data::Axis::LOG)
120 if (_xy.second <= 0.)
127 y = _yAxis->getScale() * log10( _xy.second );
133 y = _yAxis->getScale() * _xy.second;
142 const ::fwRenderQt::data::Axis::sptr& _xAxis,
143 const ::fwRenderQt::data::Axis::sptr& _yAxis )
const 147 if (_xAxis->getScaleType() == ::fwRenderQt::data::Axis::LOG)
149 x = 10. * exp( _xy.first ) / _xAxis->getScale();
153 x = ( _xy.first ) / _xAxis->getScale();
156 if (_yAxis->getScaleType() == ::fwRenderQt::data::Axis::LOG)
158 y = 10. * ( _xy.second ) / _yAxis->getScale();
162 y = _xy.second / _yAxis->getScale();
172 const ConfigType config = this->
getConfigTree().get_child(
"config.<xmlattr>");
181 if( config.count(
"xAxis") )
188 m_xAxis = std::make_shared< ::fwRenderQt::data::Axis >();
191 if( config.count(
"yAxis") )
198 m_yAxis = std::make_shared< ::fwRenderQt::data::Axis >();
201 if( config.count(
"zValue") )
203 m_zValue = config.get<
float>(
"zValue");
206 if( config.count(
"opacity") )
208 m_opacity = config.get<
float>(
"opacity");
233 const ::fwRenderQt::data::Viewport::csptr& viewport = this->
getScene2DRender()->getViewport();
virtual FWRENDERQT_API ~IAdaptor() noexcept
Basic destructor, do nothing.
::fwRenderQt::data::Axis::sptr m_xAxis
The x Axis.
Contains fwAtomsFilter::registry details.
std::pair< float, float > Scene2DRatio
<width, height>
FWRENDERQT_API void initializeViewSize()
Initialize the source values used for computing view's size ratio.
FWRENDERQT_API IAdaptor() noexcept
Constructor, set the zValue to 0.
ViewSizeRatio m_viewInitialSize
FWRENDERQT_API Point2DType mapAdaptorToScene(const Point2DType &_xy, const ::fwRenderQt::data::Axis::sptr &_xAxis, const ::fwRenderQt::data::Axis::sptr &_yAxis) const
FWRENDERQT_API std::shared_ptr< ::fwRenderQt::SRender > getScene2DRender() const
Get the render that manages the IAdaptor.
std::pair< float, float > ViewSizeRatio
<width, height>
std::pair< double, double > Point2DType
Point2D coordinate <X, Y>
ViewportSizeRatio m_viewportInitialSize
std::pair< float, float > ViewportSizeRatio
<width, height>
FWRENDERQT_API Point2DType mapSceneToAdaptor(const Point2DType &_xy, const ::fwRenderQt::data::Axis::sptr &_xAxis, const ::fwRenderQt::data::Axis::sptr &_yAxis) const
FWRENDERQT_API float getZValue() const
Get the zValue.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWRENDERQT_API void initializeViewportSize()
Initialize the source values used for computing viewport's size ratio.
::fwRenderQt::data::Axis::sptr m_yAxis
The y Axis.
float m_opacity
Opacity of the adaptor. Default value set to 1 (opaque).
FWRENDERQT_API ViewportSizeRatio getViewportSizeRatio() const
Return the ratio between viewport's initial size and its current size.
FWRENDERQT_API void configureParams()
Parse the xml configuration for Axis, z value and opacity.
virtual FWRENDERQT_API void processInteraction(::fwRenderQt::data::Event &_event)
FWRENDERQT_API ViewSizeRatio getViewSizeRatio() const
Return the ratio between view's initial size and its current size.
The namespace fwRenderQt contains classes for rendering with Qt.
FWRENDERQT_API void setZValue(float _zValue)
Set the zValue.
This class manage events on the scene 2D (mouse event, keyboard event , ...).
FWSERVICES_API ConfigType getConfigTree() const
Return the configuration, in an boost property tree.