7 #include "ioPacs/SSeriesPuller.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 11 #include <fwCom/Slots.hpp> 12 #include <fwCom/Slots.hxx> 14 #include <fwGui/dialog/MessageDialog.hpp> 15 #include <fwGui/dialog/ProgressDialog.hpp> 17 #include <fwGuiQt/container/QtContainer.hpp> 19 #include <fwMedData/DicomSeries.hpp> 21 #include <fwMedDataTools/helper/SeriesDB.hpp> 23 #include <fwPacsIO/exceptions/Base.hpp> 24 #include <fwPacsIO/helper/Series.hpp> 26 #include <fwServices/macros.hpp> 27 #include <fwServices/registry/ActiveWorkers.hpp> 28 #include <fwServices/registry/ObjectService.hpp> 29 #include <fwServices/registry/ServiceConfig.hpp> 31 #include <fwTools/System.hpp> 33 #include <boost/filesystem/operations.hpp> 34 #include <boost/foreach.hpp> 45 const ::fwCom::Slots::SlotKeyType SSeriesPuller::s_READ_SLOT =
"readDicom";
46 const ::fwCom::Slots::SlotKeyType SSeriesPuller::s_DISPLAY_SLOT =
"displayMessage";
49 const ::fwCom::Signals::SignalKeyType SSeriesPuller::s_STARTED_PROGRESS_SIG =
"startedProgress";
50 const ::fwCom::Signals::SignalKeyType SSeriesPuller::s_STOPPED_PROGRESS_SIG =
"stoppedProgress";
54 m_progressbarId("pullDicomProgressBar"),
82 _sstream <<
"SSeriesPuller::info";
89 ::fwRuntime::ConfigurationElement::sptr config =
m_configuration->findConfigurationElement(
"config");
90 SLM_ASSERT(
"The service ::ioPacs::SSeriesPuller must have a \"config\" element.", config);
95 ::boost::tie(success,
m_dicomReaderType) = config->getSafeAttributeValue(
"dicomReader");
96 SLM_ASSERT(
"It should be a \"dicomReader\" in the ::ioPacs::SSeriesPuller config element.", success);
122 ::fwServices::OSR::registerService(
m_tempSeriesDB, ::fwIO::s_DATA_KEY,
127 ::fwRuntime::ConfigurationElement::csptr readerConfig =
131 SLM_ASSERT(
"Sorry, there is no service configuration " 133 <<
" for ::fwIO::IReader", readerConfig);
135 m_dicomReader->setConfiguration( ::fwRuntime::ConfigurationElement::constCast(readerConfig) );
166 ::fwData::Vector::csptr selectedSeries = this->getInput< ::fwData::Vector >(
"selectedSeries");
172 messageBox.
setTitle(
"Pulling Series");
173 messageBox.
setMessage(
"The service is already pulling data. Please wait until the pulling is done " 174 "before sending a new pull request." );
175 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::INFO);
176 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
179 else if(selectedSeries->empty())
183 messageBox.
setTitle(
"Pulling Series");
184 messageBox.
setMessage(
"Unable to pull series, there is no series selected." );
185 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::INFO);
186 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
212 ::fwData::Vector::csptr selectedSeries = this->getInput< ::fwData::Vector >(
"selectedSeries");
215 DicomSeriesContainerType pullSeriesVector;
216 DicomSeriesContainerType selectedSeriesVector;
218 ::fwData::Vector::ConstIteratorType it = selectedSeries->begin();
219 for(; it != selectedSeries->end(); ++it)
221 ::fwMedData::DicomSeries::sptr series = ::fwMedData::DicomSeries::dynamicCast(*it);
230 pullSeriesVector.push_back(series);
233 selectedSeriesVector.push_back(series);
245 if(!pullSeriesVector.empty())
256 if(
m_pacsConfiguration->getRetrieveMethod() == ::fwPacsIO::data::PacsConfiguration::GET_RETRIEVE_METHOD)
267 ::fwPacsIO::SeriesRetriever::sptr seriesRetriever = ::fwPacsIO::SeriesRetriever::New();
268 seriesRetriever->initialize(
275 ::fwThread::Worker::sptr worker = ::fwThread::Worker::New();
303 ::std::stringstream ss;
304 ss <<
"Unable to connect to the pacs. Please check your configuration: \n" 321 InstanceUIDContainerType alreadyLoadedSeries =
327 for(const ::fwMedData::Series::sptr& series: selectedSeries)
329 const std::string selectedSeriesUID = series->getInstanceUID();
338 if(std::find(alreadyLoadedSeries.begin(), alreadyLoadedSeries.end(),
339 selectedSeriesUID) == alreadyLoadedSeries.end())
342 tempSDBhelper.clear();
345 m_dicomReader->setFolder(path.string() + selectedSeriesUID +
"/");
359 const ::std::string& filePath)
365 series->addDicomPath(instanceNumber, filePath);
369 SLM_WARN(
"The Dicom Series " + seriesInstanceUID +
" has expired.");
373 ::std::stringstream ss;
375 float percentage =
static_cast<float>(instanceNumber)/static_cast<float>(m_instanceCount);
387 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::CRITICAL);
388 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
std::string m_dicomReaderSrvConfig
Reader Config.
::fwMedData::SeriesDB::sptr m_tempSeriesDB
Temporary SeriesDB.
::fwMedData::SeriesDB::sptr m_destinationSeriesDB
Destination SeriesDB.
DisplayMessageSlotType::sptr m_slotDisplayMessage
Slot to call displayErrorMessage method;.
DicomSeriesMapType m_pullingDicomSeriesMap
Map of Dicom series being pulled.
virtual IOPACS_API void starting() override
Override.
This service is used to pull series from a PACS.
ioPacs contains services use to deal with PACS using DCMTK library.
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
::fwPacsIO::SeriesEnquirer::sptr m_seriesEnquirer
Series enquirer.
IOPACS_API void readLocalSeries(DicomSeriesContainerType selectedSeries)
Read local series.
Defines the generic message box for IHM. Use the Delegate design pattern.
::fwPacsIO::data::PacsConfiguration::csptr m_pacsConfiguration
Pacs Configuration object.
IOPACS_API void displayErrorMessage(const std::string &message) const
Display an error message.
::fwPacsIO::SeriesEnquirer::ProgressCallbackSlotType::sptr m_slotStoreInstanceCallbackUsingGetRequests
Slot to call storeInstanceCallback method using C-GET Requests.
StoppedProgressSignalType::sptr m_sigStoppedProgress
Signal emitted when the bar is stopping.
#define SLM_WARN(message)
IOPACS_API void updating() override
Override.
static FWPACSIO_API InstanceUIDContainer toSeriesInstanceUIDContainer(OFList< QRResponse * > responses)
Convert DCMTK series to instance uid vector.
IOPACS_API SSeriesPuller() noexcept
Constructor.
This class defines a vector of objects.
Base class of fwPacsIO Exceptions.
::fwIO::IReader::sptr m_dicomReader
Reader.
virtual FWGUI_API void addButton(IMessageDialog::Buttons button) override
Add a button (OK, YES_NO, YES, NO, CANCEL)
virtual IOPACS_API ~SSeriesPuller() noexcept
Destructor.
bool m_isPulling
Is pulling is set to true when we are pulling series.
virtual FWGUI_API IMessageDialog::Buttons show() override
Show the message box and return the clicked button.
This interface defines control service API. Does nothing particularly, can be considered as a default...
long unsigned int m_seriesCount
Total number of downloaded series.
IOPACS_API void pullSeries()
Pull Series.
ReadDicomSlotType::sptr m_slotReadLocalSeries
Slot to call readLocalSeries method.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWPACSIO_API bool start()
Start the server.
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
IOPACS_API void storeInstanceCallback(const std::string &seriesInstanceUID, unsigned int instanceNumber, const std::string &filePath)
Store instance callback.
virtual FWGUI_API void setIcon(IMessageDialog::Icons icon) override
Set the icon (CRITICAL, WARNING, INFO or QUESTION)
std::string m_dicomReaderType
IOPACS Reader.
::fwThread::Worker::sptr m_pullSeriesWorker
Pull Worker.
static const ::fwCom::Signals::SignalKeyType s_PROGRESSED_SIG
Key in m_signals map of signal m_sigProgressed.
InstanceUIDContainerType m_localSeries
Local Series.
std::size_t m_instanceCount
Total number of instances that must be downloaded.
static FWSERVICES_API ServiceFactory::sptr getDefault()
Return the unique Instance, create it if required at first access.
ProgressedSignalType::sptr m_sigProgressed
Signal emitted when the bar is progressing.
static FWSERVICES_API ServiceConfig::sptr getDefault()
Return the default global instance of ServiceConfig.
virtual IOPACS_API void stopping() override
Override.
virtual IOPACS_API void configuring() override
Configuring method. This method is used to configure the service.
::fwPacsIO::SeriesRetriever::ProgressCallbackSlotType::sptr m_slotStoreInstanceCallbackUsingMoveRequests
Slot to call storeInstanceCallback method using C-MOVE Requests.
StartedProgressSignalType::sptr m_sigStartedProgress
Signal emitted when the bar is starting.
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the message box.
unsigned int m_seriesIndex
Index of the series being downloaded.
IOPACS_API void info(std::ostream &_sstream) override
Override.
std::string m_progressbarId
Progress Bar ID.