7 #include "ioVtkGdcm/SSeriesDBLazyReader.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 12 #include <fwCore/base.hpp> 14 #include <fwGui/Cursor.hpp> 15 #include <fwGui/dialog/LocationDialog.hpp> 16 #include <fwGui/dialog/MessageDialog.hpp> 18 #include <fwIO/IReader.hpp> 20 #include <fwJobs/IJob.hpp> 21 #include <fwJobs/Job.hpp> 23 #include <fwMedData/Series.hpp> 24 #include <fwMedData/SeriesDB.hpp> 26 #include <fwServices/macros.hpp> 28 #include <fwTools/ProgressToLogger.hpp> 30 #include <vtkGdcmIO/SeriesDBLazyReader.hpp> 36 static const ::fwCom::Signals::SignalKeyType JOB_CREATED_SIGNAL =
"jobCreated";
42 m_sigJobCreated = newSignal< JobCreatedSignalType >( JOB_CREATED_SIGNAL );
55 static ::boost::filesystem::path _sDefaultPath;
60 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
61 dialogFile.
setType(::fwGui::dialog::LocationDialog::FOLDER);
63 ::fwData::location::Folder::sptr result;
64 result = ::fwData::location::Folder::dynamicCast( dialogFile.
show() );
67 _sDefaultPath = result->getFolder();
98 _sstream <<
"SSeriesDBLazyReader::info";
105 ExtensionsType extensions;
113 return "Choose a directory with DICOM images";
118 ::fwMedData::SeriesDB::sptr SSeriesDBLazyReader::createSeriesDB(const ::boost::filesystem::path& dicomDir)
121 ::vtkGdcmIO::SeriesDBLazyReader::sptr myLoader = ::vtkGdcmIO::SeriesDBLazyReader::New();
122 ::fwMedData::SeriesDB::sptr dummy = ::fwMedData::SeriesDB::New();
123 myLoader->setObject(dummy);
124 myLoader->setFolder(dicomDir);
126 m_sigJobCreated->emit(myLoader->getJob());
132 catch (
const std::exception& e)
134 std::stringstream ss;
135 ss <<
"Warning during loading : " << e.what();
137 "Warning", ss.str(), ::fwGui::dialog::IMessageDialog::WARNING);
142 "Warning",
"Warning during loading", ::fwGui::dialog::IMessageDialog::WARNING);
145 return myLoader->getConcreteObject();
154 ::fwMedData::SeriesDB::sptr seriesDB = createSeriesDB( this->
getFolder() );
156 if( seriesDB->size() > 0 )
159 ::fwMedData::SeriesDB::sptr associatedSeriesDB =
160 this->getInOut< ::fwMedData::SeriesDB >(::fwIO::s_DATA_KEY);
161 if (!associatedSeriesDB)
164 associatedSeriesDB = this->getObject< ::fwMedData::SeriesDB >();
167 SLM_ASSERT(
"associated SeriesDB not instanced", associatedSeriesDB);
168 associatedSeriesDB->shallowCopy( seriesDB );
171 cursor.
setCursor(::fwGui::ICursor::BUSY);
172 this->notificationOfDBUpdate();
178 "Image Reader",
"This file can not be read. Retry with another file reader.",
179 ::fwGui::dialog::IMessageDialog::WARNING);
186 void SSeriesDBLazyReader::notificationOfDBUpdate()
188 ::fwMedData::SeriesDB::sptr seriesDB = this->getInOut< ::fwMedData::SeriesDB >(::fwIO::s_DATA_KEY);
192 seriesDB = this->getObject< ::fwMedData::SeriesDB >();
194 SLM_ASSERT(
"Unable to get seriesDB", seriesDB);
196 ::fwMedData::SeriesDB::ContainerType addedSeries;
197 for( ::fwMedData::Series::sptr s : seriesDB->getContainer() )
199 addedSeries.push_back(s);
204 sig->asyncEmit(addedSeries);
211 return ::fwIO::FOLDER;
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
IOVTKGDCM_API void info(std::ostream &_sstream) override
Override.
virtual FWGUI_API void setCursor(::fwGui::ICursor::CursorType cursor) override
Set the cursor.
virtual IOVTKGDCM_API ExtensionsType getSupportedExtensions() override
Override.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.
#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 void configureWithIHM() override
Override.
virtual IOVTKGDCM_API void configuring() override
Override.
virtual FWGUI_API void setDefaultLocation(::fwData::location::ILocation::sptr loc) override
Set the initial location for the dialog.
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 void starting() override
Override.
IOVTKGDCM_API SSeriesDBLazyReader() noexcept
constructor
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_SERIES_SIG
Type of signal when series are added.
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.
virtual IOVTKGDCM_API std::string getSelectorDialogTitle() override
Override.
IOVTKGDCM_API void updating() override
Override.
IOPathType
IOPathType defines different type of paths used by service readers/writers.
FWGUI_API void setTitle(const std::string &title) override
Set the title for the dialog.
Defines the generic file/folder selector dialog for IHM.
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)
virtual IOVTKGDCM_API ~SSeriesDBLazyReader() noexcept
destructor
virtual IOVTKGDCM_API void stopping() override
Override.
This service reads a dicom dir in lazy mode, and provides a fwMedData::SeriesDB.
virtual FWGUI_API void setDefaultCursor() override
Set the default cursor.