7 #include "ioPacs/SSeriesPusher.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 11 #include <fwCom/Slots.hpp> 12 #include <fwCom/Slots.hxx> 14 #include <fwData/Vector.hpp> 16 #include <fwGui/dialog/MessageDialog.hpp> 18 #include <fwMedData/DicomSeries.hpp> 19 #include <fwMedData/Series.hpp> 21 #include <fwPacsIO/exceptions/Base.hpp> 22 #include <fwPacsIO/helper/Series.hpp> 24 #include <fwServices/macros.hpp> 26 #include <boost/foreach.hpp> 28 #include <dcmtk/dcmdata/dcistrmb.h> 37 const ::fwCom::Slots::SlotKeyType SSeriesPusher::s_DISPLAY_SLOT =
"displayMessage";
40 const ::fwCom::Signals::SignalKeyType SSeriesPusher::s_STARTED_PROGRESS_SIG =
"startedProgress";
41 const ::fwCom::Signals::SignalKeyType SSeriesPusher::s_STOPPED_PROGRESS_SIG =
"stoppedProgress";
46 m_progressbarId("pushDicomProgressBar"),
69 _sstream <<
"SSeriesPusher::info";
103 ::fwData::Vector::csptr selectedSeries = this->getInput< ::fwData::Vector >(
"selectedSeries");
109 messageBox.
setTitle(
"Pushing Series");
110 messageBox.
setMessage(
"The service is already pushing data. Please wait until the pushing is done " 111 "before sending a new push request." );
112 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::INFO);
113 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
116 else if(selectedSeries->empty())
120 messageBox.
setTitle(
"Pushing Series");
121 messageBox.
setMessage(
"Unable to push series, there is no series selected." );
122 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::INFO);
123 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
158 ::fwData::Vector::csptr seriesVector = this->getInput< ::fwData::Vector >(
"selectedSeries");
164 DicomSeriesContainerType duplicateSeriesVector;
169 ::fwData::Vector::ConstIteratorType it = seriesVector->begin();
170 for(; it != seriesVector->end(); ++it)
172 ::fwMedData::DicomSeries::csptr series = ::fwMedData::DicomSeries::dynamicCast(*it);
173 SLM_ASSERT(
"The SeriesDB should contain only DicomSeries.", series);
176 OFList< QRResponse* > responses;
180 if(responses.size() > 1)
182 duplicateSeriesVector.push_back(series);
192 if(!duplicateSeriesVector.empty())
194 ::std::stringstream ss;
195 ss <<
"Those series are already on the PACS: \n";
198 for(const ::fwMedData::Series::csptr& series: duplicateSeriesVector)
200 std::string description = series->getDescription();
201 description = (description.empty()) ?
"[No description]" : description;
202 ss <<
"- " << description << std::endl;
205 ss << std::endl <<
"Would you like to perform the operation anyway ?" << std::endl
206 <<
"(This will result in a merge operation)";
209 messageBox.
setTitle(
"Duplicate series");
211 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::INFO);
212 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
213 messageBox.
addButton(::fwGui::dialog::IMessageDialog::CANCEL);
216 result = (answer == ::fwGui::dialog::IMessageDialog::OK);
222 ::std::stringstream ss;
223 ss <<
"Unable to connect to the pacs. Please check your configuration: \n" 243 ::fwData::Vector::csptr seriesVector = this->getInput< ::fwData::Vector >(
"selectedSeries");
249 std::vector< CSPTR(DcmDataset) > dicomContainer;
252 for(
const auto& series : *seriesVector)
254 ::fwMedData::DicomSeries::csptr dicomSeries = ::fwMedData::DicomSeries::dynamicCast(series);
255 SLM_ASSERT(
"The SeriesDB should contain only DicomSeries.", dicomSeries);
257 for(
const auto& item : dicomSeries->getDicomContainer())
259 DcmFileFormat fileFormat;
260 ::fwMemory::BufferObject::sptr bufferObj = item.second;
261 const size_t buffSize = bufferObj->getSize();
263 char* buffer =
static_cast< char*
>( lock.
getBuffer() );
265 DcmInputBufferStream is;
266 is.setBuffer(buffer, offile_off_t(buffSize));
269 fileFormat.transferInit();
270 if (!fileFormat.read(is).good())
272 FW_RAISE(
"Unable to read Dicom file '"<< bufferObj->getStreamInfo().fsFile.string() <<
"'");
275 fileFormat.loadAllDataIntoMemory();
276 fileFormat.transferEnd();
278 const DcmDataset* dataset = fileFormat.getAndRemoveDataset();
279 CSPTR(DcmDataset) datasetPtr(dataset);
280 dicomContainer.push_back(datasetPtr);
299 ::std::stringstream ss;
300 ss <<
"Unable to connect to the pacs. Please check your configuration: \n" 316 const std::string& filePath)
320 float percentage =
static_cast<float>(instanceNumber)/static_cast<float>(
m_instanceCount);
335 messageBox.
setTitle((error ?
"Error" :
"Information"));
337 messageBox.
setIcon(error ? (::fwGui::dialog::IMessageDialog::CRITICAL): (::fwGui::dialog::IMessageDialog::INFO));
338 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
long unsigned int m_instanceCount
Total number of instances that must be uploaded.
This service is used to push a DICOM series to a PACS.
::fwPacsIO::SeriesEnquirer::sptr m_seriesEnquirer
Series enquirer.
ioPacs contains services use to deal with PACS using DCMTK library.
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
IOPACS_API void displayMessage(const std::string &message, bool error) const
Display a message.
Defines the generic message box for IHM. Use the Delegate design pattern.
::fwThread::Worker::sptr m_pushSeriesWorker
Push Worker.
bool m_isPushing
Is pushing is set to true when we are puishing series.
IOPACS_API void progressCallback(const std::string &seriesInstanceUID, unsigned int instanceNumber, const std::string &filePath)
Progress callback.
std::string m_progressbarId
Progress Bar ID.
StoppedProgressSignalType::sptr m_sigStoppedProgress
Signal emitted when the bar is stopping.
base class for BufferObject Lock
#define SLM_WARN(message)
IOPACS_API bool checkSeriesOnPACS()
Check whether some series are already on the PACS.
Base class of fwPacsIO Exceptions.
::fwPacsIO::SeriesEnquirer::ProgressCallbackSlotType::sptr m_slotProgressCallback
Slot to call progressCallback method.
virtual FWGUI_API void addButton(IMessageDialog::Buttons button) override
Add a button (OK, YES_NO, YES, NO, CANCEL)
StartedProgressSignalType::sptr m_sigStartedProgress
Signal emitted when the bar is starting.
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...
LockBase< T >::BufferType getBuffer() const
Returns BufferObject's buffer pointer.
DisplayMessageSlotType::sptr m_slotDisplayMessage
Slot to call displayMessage method;.
static const ::fwCom::Signals::SignalKeyType s_PROGRESSED_SIG
Key in m_signals map of signal m_sigProgressed.
IOPACS_API SSeriesPusher() noexcept
Constructor.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
virtual IOPACS_API void stopping() override
Override.
ProgressedSignalType::sptr m_sigProgressed
Signal emitted when the bar is progressing.
Base class for each data object.
virtual FWGUI_API void setIcon(IMessageDialog::Icons icon) override
Set the icon (CRITICAL, WARNING, INFO or QUESTION)
IOPACS_API void updating() override
Override.
virtual IOPACS_API void starting() override
Override.
virtual IOPACS_API void configuring() override
Does nothing.
virtual IOPACS_API ~SSeriesPusher() noexcept
Destructor.
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the message box.
::fwPacsIO::data::PacsConfiguration::csptr m_pacsConfiguration
Pacs Configuration object.
IOPACS_API void pushSeries()
Pull Series.
IOPACS_API void info(std::ostream &_sstream) override
Override.
#define SLM_WARN_IF(message, cond)
static FWPACSIO_API void releaseResponses(OFList< QRResponse * > responses)
Release the responses.