7 #include "ioVtkGdcm/SSeriesDBReader.hpp" 9 #include <fwCom/HasSignals.hpp> 10 #include <fwCom/Signal.hpp> 11 #include <fwCom/Signal.hxx> 13 #include <fwCore/base.hpp> 15 #include <fwGui/backend.hpp> 16 #include <fwGui/Cursor.hpp> 17 #include <fwGui/dialog/LocationDialog.hpp> 18 #include <fwGui/dialog/MessageDialog.hpp> 20 #include <fwIO/IReader.hpp> 22 #include <fwJobs/IJob.hpp> 23 #include <fwJobs/Job.hpp> 25 #include <fwMedData/Series.hpp> 26 #include <fwMedData/SeriesDB.hpp> 28 #include <fwServices/macros.hpp> 30 #include <fwTools/ProgressToLogger.hpp> 32 #include <vtkGdcmIO/SeriesDBReader.hpp> 39 static const ::fwCom::Signals::SignalKeyType JOB_CREATED_SIGNAL =
"jobCreated";
45 m_sigJobCreated = newSignal< JobCreatedSignalType >( JOB_CREATED_SIGNAL );
58 static ::boost::filesystem::path _sDefaultPath;
63 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
64 dialogFile.
setType(::fwGui::dialog::LocationDialog::FOLDER);
66 ::fwData::location::Folder::sptr result;
67 result = ::fwData::location::Folder::dynamicCast( dialogFile.
show() );
70 _sDefaultPath = result->getFolder();
101 _sstream <<
"SSeriesDBReader::info";
108 ExtensionsType extensions;
116 return "Choose a directory with DICOM images";
121 ::fwMedData::SeriesDB::sptr SSeriesDBReader::createSeriesDB(const ::boost::filesystem::path& dicomDir)
124 ::vtkGdcmIO::SeriesDBReader::sptr reader = ::vtkGdcmIO::SeriesDBReader::New();
125 ::fwMedData::SeriesDB::sptr dummy = ::fwMedData::SeriesDB::New();
126 reader->setObject(dummy);
127 reader->setFolder(dicomDir);
129 m_sigJobCreated->emit(reader->getJob());
135 catch (
const std::exception& e)
137 std::stringstream ss;
138 ss <<
"Warning during loading : " << e.what();
140 "Warning", ss.str(), ::fwGui::dialog::IMessageDialog::WARNING);
145 "Warning",
"Warning during loading", ::fwGui::dialog::IMessageDialog::WARNING);
148 return reader->getConcreteObject();
158 ::fwMedData::SeriesDB::sptr seriesDB = createSeriesDB( this->
getFolder() );
159 if( seriesDB->size() > 0 )
167 ::fwMedData::SeriesDB::sptr associatedSeriesDB =
168 this->getInOut< ::fwMedData::SeriesDB >(::fwIO::s_DATA_KEY);
169 if (!associatedSeriesDB)
172 associatedSeriesDB = this->getObject< ::fwMedData::SeriesDB >();
174 SLM_ASSERT(
"associated SeriesDB not instanced", associatedSeriesDB);
175 associatedSeriesDB->shallowCopy( seriesDB );
178 cursor.
setCursor(::fwGui::ICursor::BUSY);
179 this->notificationOfDBUpdate();
185 "Image Reader",
"This file can not be read. Retry with another file reader.",
186 ::fwGui::dialog::IMessageDialog::WARNING);
193 void SSeriesDBReader::notificationOfDBUpdate()
196 ::fwMedData::SeriesDB::sptr seriesDB = this->getInOut< ::fwMedData::SeriesDB >(::fwIO::s_DATA_KEY);
200 seriesDB = this->getObject< ::fwMedData::SeriesDB >();
202 SLM_ASSERT(
"Unable to get seriesDB", seriesDB);
204 ::fwMedData::SeriesDB::ContainerType addedSeries;
205 for( ::fwMedData::Series::sptr s : seriesDB->getContainer() )
207 addedSeries.push_back(s);
212 sig->asyncEmit(addedSeries);
219 return ::fwIO::FOLDER;
virtual IOVTKGDCM_API void configuring() override
Override.
virtual IOVTKGDCM_API void stopping() override
Override.
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
virtual FWGUI_API void setCursor(::fwGui::ICursor::CursorType cursor) override
Set the cursor.
FWSERVICES_API bool isStopped() const noexcept
Test if the service is stopped or not.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.
IOVTKGDCM_API SSeriesDBReader() noexcept
constructor
#define SLM_TRACE_FUNC()
Trace contextual function signature.
FWIO_API bool hasLocationDefined() const
Returns if a location has been defined ( by the configuration process or directly by user ) ...
virtual FWIO_API void configuring() override
This method proposes to parse xml configuration to retrieve file/files/folder paths.
static FWGUI_API IMessageDialog::Buttons showMessageDialog(const std::string &title, const std::string &message,::fwGui::dialog::IMessageDialog::Icons icon=INFO)
virtual IOVTKGDCM_API ~SSeriesDBReader() noexcept
destructor
virtual FWGUI_API void setDefaultLocation(::fwData::location::ILocation::sptr loc) override
Set the initial location for the dialog.
IOVTKGDCM_API void info(std::ostream &_sstream) override
Override.
FWGUI_API::fwGui::dialog::ILocationDialog & setOption(::fwGui::dialog::ILocationDialog::Options option) override
allow to set option to the file dialog mode=READ/WRITE, check=FILE_MUST_EXIST
FWGUI_API::fwData::location::ILocation::sptr show() override
Display the dialog.
FWIO_APIconst::boost::filesystem::path & getFolder() const
Returns folder path set by the user or set during service configuration.
virtual IOVTKGDCM_API std::string getSelectorDialogTitle() override
Override.
virtual IOVTKGDCM_API void starting() override
Override.
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_SERIES_SIG
Type of signal when series are added.
virtual IOVTKGDCM_API ExtensionsType getSupportedExtensions() override
Override.
Reader service API. It manages extension points definition and extension configuration.
ioVtkGdcm contains services to read and write Series using vtk and gdcm libraries.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
IOVTKGDCM_API::fwIO::IOPathType getIOPathType() const override
Return path type managed by the service, here FOLDER.
IOPathType
IOPathType defines different type of paths used by service readers/writers.
IOVTKGDCM_API void updating() override
Override.
FWGUI_API void setTitle(const std::string &title) override
Set the title for the dialog.
Defines the generic file/folder selector dialog for IHM.
virtual IOVTKGDCM_API void configureWithIHM() override
Override.
Defines the generic cursor for IHM. Use the Delegate design pattern.
FWIO_API void setFolder(const ::boost::filesystem::path &folder)
Sets folder path.
FWGUI_API void setType(::fwGui::dialog::ILocationDialog::Types type) override
Set the type of location for the dialog (SINGLE_FILE, FORLDER, MULTI_FILES)
FWGUI_API void saveDefaultLocation(::fwData::location::ILocation::sptr loc) override
Save the specified default location for the dialog in preferences (if available)
This service reads a dicom dir, and provides a fwMedData::SeriesDB.
virtual FWGUI_API void setDefaultCursor() override
Set the default cursor.