Commit 89a90ce5 authored by Flavien BRIDAULT-LOUCHEZ's avatar Flavien BRIDAULT-LOUCHEZ
Browse files

merge(dev): release 11.0.6

parents d8b05b2f 072d164a
set( NAME ctrlHistory )
set( VERSION 0.1 )
set( TYPE BUNDLE )
set( DEPENDENCIES
fwCom
fwCore
fwData
fwDataTools
fwRuntime
fwServices
fwTools
fwCommand
)
set( REQUIREMENTS )
/* ***** 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 __CTRLHISTORY_PLUGIN_HPP__
#define __CTRLHISTORY_PLUGIN_HPP__
#include "ctrlHistory/config.hpp"
#include <fwRuntime/Plugin.hpp>
namespace ctrlHistory
{
/**
* @brief This class starts when the bundle is loaded.
*/
struct CTRLHISTORY_CLASS_API Plugin : public ::fwRuntime::Plugin
{
/// Destructor. Do nothing.
CTRLHISTORY_API ~Plugin() throw();
/// Overrides start method. Does nothing.
CTRLHISTORY_API void start() throw( ::fwRuntime::RuntimeException );
/// Overrides stop method. Does nothing.
CTRLHISTORY_API void stop() throw();
};
} // namespace ctrlHistory
#endif //__CTRLHISTORY_PLUGIN_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 ****** */
#ifndef __CTRLHISTORY_SCOMMANDHISTORY_HPP__
#define __CTRLHISTORY_SCOMMANDHISTORY_HPP__
#include "ctrlHistory/config.hpp"
#include <fwCommand/ICommand.hpp>
#include <fwCommand/UndoRedoManager.hpp>
#include <fwCore/base.hpp>
#include <fwServices/IService.hpp>
#include <fwServices/macros.hpp>
namespace ctrlHistory
{
/**
* @brief This service manages a command history.
* The history is modified when receiving "undo", "redo", "enqueue" or "clear" signal.
*
* @section Signals Signals
* - \b canUndo(bool) : sent when the history is modified, notifies if an undo is still possible.
* - \b canRedo(bool) : sent when the history is modified, notifies if an redo is still possible.
*
* @section Slots Slots
* - \b enqueue(::fwCommand::ICommand::sptr) : add a command to the history.
* - \b undo() : undo the last command.
* - \b redo() : redo the next command.
* - \b clear() : clear the history (delete all commands).
*
* @section XML XML Configuration
*
* @code{.xml}
<service uid="..." type="::ctrlHistory::SControlHistory" >
<maxCommands>10</maxCommands>
<maxMemory>100000000</maxMemory>
</service>
@endcode
*
* @subsection Configuration Configuration
* - \b maxCommands (optional) : The maximum number of commands stored in the history. Unlimited by default.
* - \b maxMemory (optional) : The maximum amount of memory (in bytes) used available to store commands.
* Unlimited by default.
*/
class CTRLHISTORY_CLASS_API SCommandHistory : public ::fwServices::IService
{
public:
fwCoreServiceClassDefinitionsMacro( (SCommandHistory)(::fwServices::IService) );
/// Constructor.
CTRLHISTORY_API SCommandHistory();
/// Destructor.
CTRLHISTORY_API virtual ~SCommandHistory();
protected:
/// Set memory and command boundaries.
CTRLHISTORY_API virtual void configuring() throw( ::fwTools::Failed );
/// Notify if undo or redo are possible.
CTRLHISTORY_API virtual void starting() throw( ::fwTools::Failed );
/// Notify if undo or redo are possible.
CTRLHISTORY_API virtual void updating() throw( ::fwTools::Failed );
/// Clears the history.
CTRLHISTORY_API virtual void stopping() throw( ::fwTools::Failed );
private:
typedef ::fwCom::Signal<void (bool)> CanDoSignalType;
/// SLOT: add a command to the history.
void enqueue(::fwCommand::ICommand::sptr command);
/// SLOT: undo the last command.
void undo();
/// SLOT: redo the next command.
void redo();
/// SLOT: delete all commands from the history.
void clear();
/// Send 'canUndo' and 'canRedo' signals.
void emitModifSig() const;
CanDoSignalType::sptr m_canUndoSig;
CanDoSignalType::sptr m_canRedoSig;
::fwCommand::UndoRedoManager m_undoRedoManager;
};
} // namespace ctrlHistory
#endif /* __CTRLHISTORY_SCOMMANDHISTORY_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 ****** */
#ifndef __CTRLHISTORY_NAMESPACE_HPP__
#define __CTRLHISTORY_NAMESPACE_HPP__
/**
* @brief The namespace ctrlHistory contains services handling command histories.
*/
namespace ctrlHistory
{
} // namespace ctrlHistory
#endif /* __CTRLHISTORY_NAMESPACE_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 "ctrlHistory/Plugin.hpp"
#include <fwRuntime/utils/GenericExecutableFactoryRegistrar.hpp>
namespace ctrlHistory
{
static ::fwRuntime::utils::GenericExecutableFactoryRegistrar<Plugin> registrar("::ctrlHistory::Plugin");
Plugin::~Plugin() throw()
{
}
//------------------------------------------------------------------------------
void Plugin::start() throw(::fwRuntime::RuntimeException)
{
}
//------------------------------------------------------------------------------
void Plugin::stop() throw()
{
}
} // namespace ctrlHistory
/* ***** 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 "ctrlHistory/SCommandHistory.hpp"
#include <fwCom/Signal.hpp>
#include <fwCom/Signal.hxx>
#include <fwCom/Signals.hpp>
#include <fwCom/Slot.hpp>
#include <fwCom/Slot.hxx>
#include <fwCom/Slots.hpp>
#include <fwCom/Slots.hxx>
#include <fwData/mt/ObjectWriteLock.hpp>
#include <fwDataCamp/exception/ObjectNotFound.hpp>
#include <fwDataCamp/getObject.hpp>
#include <numeric>
namespace ctrlHistory
{
fwServicesRegisterMacro(::fwServices::IService, ::ctrlHistory::SCommandHistory, ::fwData::Object);
static const ::fwCom::Signals::SignalKeyType s_CANUNDO_SIGNAL = "canUndo";
static const ::fwCom::Signals::SignalKeyType s_CANREDO_SIGNAL = "canRedo";
static const ::fwCom::Slots::SlotKeyType s_ENQUEUE_SLOT = "enqueue";
static const ::fwCom::Slots::SlotKeyType s_UNDO_SLOT = "undo";
static const ::fwCom::Slots::SlotKeyType s_REDO_SLOT = "redo";
static const ::fwCom::Slots::SlotKeyType s_CLEAR_SLOT = "clear";
//-----------------------------------------------------------------------------
SCommandHistory::SCommandHistory()
{
newSlot(s_ENQUEUE_SLOT, &SCommandHistory::enqueue, this);
newSlot(s_UNDO_SLOT, &SCommandHistory::undo, this);
newSlot(s_REDO_SLOT, &SCommandHistory::redo, this);
newSlot(s_CLEAR_SLOT, &SCommandHistory::clear, this);
m_canUndoSig = newSignal< CanDoSignalType >( s_CANUNDO_SIGNAL );
m_canRedoSig = newSignal< CanDoSignalType >( s_CANREDO_SIGNAL );
}
//-----------------------------------------------------------------------------
SCommandHistory::~SCommandHistory()
{
}
//-----------------------------------------------------------------------------
void SCommandHistory::configuring() throw( ::fwTools::Failed )
{
::fwServices::IService::ConfigType config = this->getConfigTree();
auto maxCommands = config.get_optional< size_t >("service.maxCommands");
auto maxMemory = config.get_optional< size_t >("service.maxMemory");
if(maxCommands.is_initialized())
{
m_undoRedoManager.setCommandCount(maxCommands.value());
}
if(maxMemory.is_initialized())
{
m_undoRedoManager.setHistorySize(maxMemory.value());
}
}
//-----------------------------------------------------------------------------
void SCommandHistory::starting() throw( ::fwTools::Failed )
{
this->emitModifSig();
}
//-----------------------------------------------------------------------------
void SCommandHistory::updating() throw( ::fwTools::Failed )
{
this->emitModifSig();
}
//-----------------------------------------------------------------------------
void SCommandHistory::stopping() throw( ::fwTools::Failed )
{
m_undoRedoManager.clear();
}
//-----------------------------------------------------------------------------
void SCommandHistory::enqueue(fwCommand::ICommand::sptr command)
{
m_undoRedoManager.enqueue(command);
this->emitModifSig();
}
//-----------------------------------------------------------------------------
void SCommandHistory::undo()
{
m_undoRedoManager.undo();
this->emitModifSig();
}
//-----------------------------------------------------------------------------
void SCommandHistory::redo()
{
m_undoRedoManager.redo();
this->emitModifSig();
}
//-----------------------------------------------------------------------------
void SCommandHistory::clear()
{
m_undoRedoManager.clear();
this->emitModifSig();
}
//-----------------------------------------------------------------------------
void SCommandHistory::emitModifSig() const
{
m_canUndoSig->asyncEmit(m_undoRedoManager.canUndo());
m_canRedoSig->asyncEmit(m_undoRedoManager.canRedo());
}
//-----------------------------------------------------------------------------
} // namespace ctrlHistory
/* ***** 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 __CTRLSELECTION_SADDFIELD_HPP__
#define __CTRLSELECTION_SADDFIELD_HPP__
#include "ctrlSelection/config.hpp"
#include <fwServices/IController.hpp>
namespace ctrlSelection
{
/**
* @brief Add one or several fields to an object.
* @section XML XML Configuration
*
* @code{.xml}
<service type="::ctrlSelection::SAddField">
<inout group="source">
<key uid="..." field="name1" />
<key uid="..." field="name2" />
</inout>
<inout key="target" uid="..." />
</service>
@endcode
* @subsection Input Input:
* - \b source [::fwData::Object]: object that will be put as field of the target object.
* @subsection In-Out In-Out:
* - \b target [::fwData::Object]: object receiving the source object as field.
* @subsection Configuration Configuration:
* - \b field Name of the field in the field map of the target object.
*/
class CTRLSELECTION_CLASS_API SAddField : public ::fwServices::IController
{
public:
fwCoreServiceClassDefinitionsMacro((SAddField)(::fwServices::IController));
/// Constructor.
CTRLSELECTION_API SAddField() throw ();
/// Destructor.
virtual ~SAddField() throw ();
protected:
/// Configure the service.
CTRLSELECTION_API void configuring() throw (fwTools::Failed);
/// Do nothing.
CTRLSELECTION_API void starting() throw (fwTools::Failed);
/// Do nothing.
CTRLSELECTION_API void stopping() throw (fwTools::Failed);
/// Add the source object as fields of the target object.
CTRLSELECTION_API void updating() throw (fwTools::Failed);
private:
/// Contain all fields names
std::vector<std::string> m_fields;
};
} //namespace ctrlSelection
#endif // __CTRLSELECTION_SADDFIELD_HPP__
<plugin id="ctrlSelection" class="::ctrlSelection::Plugin" version="@DASH_VERSION@" >
<library name="ctrlSelection" />
<requirement id="dataReg" />
<requirement id="servicesReg" />
<extension implements="::fwServices::registry::ServiceFactory">
<type>::ctrlSelection::IUpdaterSrv</type>
<service>::ctrlSelection::updater::ObjFromMsgUpdaterSrv</service>
<object>::fwData::Composite</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::ctrlSelection::IUpdaterSrv</type>
<service>::ctrlSelection::updater::STranslate</service>
<object>::fwData::Composite</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::ctrlSelection::IManagerSrv</type>
<service>::ctrlSelection::manager::SwapperSrv</service>
<object>::fwData::Composite</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::ctrlSelection::IManagerSrv</type>
<service>::ctrlSelection::manager::SField</service>
<object>::fwData::Object</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::ctrlSelection::IManagerSrv</type>
<service>::ctrlSelection::manager::MedicalImageManagerSrv</service>
<object>::fwData::Composite</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::fwServices::IController</type>
<service>::ctrlSelection::MedicalImageSrv</service>
<object>::fwData::Image</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::fwServices::IController</type>
<service>::ctrlSelection::ImageUpdateAxis</service>
<object>::fwData::Image</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::fwServices::IController</type>
<service>::ctrlSelection::BookmarkSrv</service>
<object>::fwData::Object</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::ctrlSelection::IWrapperSrv</type>
<service>::ctrlSelection::wrapper::SImageSignalForwarder</service>
<object>::fwData::Image</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::ctrlSelection::IUpdaterSrv</type>
<service>::ctrlSelection::updater::SDrop</service>
<object>::fwData::Composite</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::ctrlSelection::IUpdaterSrv</type>
<service>::ctrlSelection::updater::SObjFromSlot</service>
<object>::fwData::Composite</object>
</extension>
<extension implements="::fwServices::registry::ServiceFactory">
<type>::fwServices::IController</type>
<service>::ctrlSelection::SManage</service>
<object>::fwData::Composite</object>
</extension>
</plugin>
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2016.
* FW4SPL - Copyright (C) IRCAD, 2009-2017.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
......@@ -16,7 +16,6 @@
#include <fwServices/macros.hpp>
namespace ctrlSelection
{
......@@ -52,15 +51,19 @@ void MedicalImageSrv::convertImage()
}
if(::fwDataTools::fieldHelper::MedicalImageHelpers::checkImageValidity(pImg))
{
::fwDataTools::helper::Image helper ( pImg );
helper.createLandmarks();
helper.createTransferFunctionPool();
helper.createImageSliceIndex();
auto sig = pImg->signal< ::fwData::Object::ModifiedSignalType >( ::fwData::Object::s_MODIFIED_SIG );
::fwCom::Connection::Blocker block(sig->getConnection(m_slotUpdate));
helper.notify();
::fwDataTools::helper::Image helper( pImg );
bool isModified = false;
isModified |= helper.createLandmarks();
isModified |= helper.createTransferFunctionPool();
isModified |= helper.createImageSliceIndex();
if (isModified)
{
auto sig = pImg->signal< ::fwData::Object::ModifiedSignalType >( ::fwData::Object::s_MODIFIED_SIG );
::fwCom::Connection::Blocker block(sig->getConnection(m_slotUpdate));
helper.notify();
}
}
}
......
/* ***** 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 "ctrlSelection/SAddField.hpp"
#include <fwDataTools/helper/Field.hpp>
#include <fwServices/macros.hpp>
#include <boost/foreach.hpp>
fwServicesRegisterMacro(::fwServices::IController, ::ctrlSelection::SAddField);
namespace ctrlSelection
{
// ----------------------------------------------------------------------------
SAddField::SAddField() throw()
{
}
// ----------------------------------------------------------------------------
SAddField::~SAddField() throw()
{
}
// ----------------------------------------------------------------------------
void SAddField::configuring() throw (::fwTools::Failed)
{
auto srvConfig = this->getConfigTree().get_child("service");
BOOST_FOREACH(const ::fwServices::IService::ConfigType::value_type &v, srvConfig.equal_range("inout"))
{
const ::fwServices::IService::ConfigType& inout = v.second;
const ::fwServices::IService::ConfigType& attrInOut = inout.get_child("<xmlattr>");