7 #include "ioVTK/SSeriesDBReader.hpp" 9 #include <fwCom/HasSignals.hpp> 10 #include <fwCom/Signal.hpp> 11 #include <fwCom/Signal.hxx> 13 #include <fwData/location/Folder.hpp> 14 #include <fwData/mt/ObjectWriteLock.hpp> 16 #include <fwGui/Cursor.hpp> 17 #include <fwGui/dialog/LocationDialog.hpp> 18 #include <fwGui/dialog/MessageDialog.hpp> 19 #include <fwGui/dialog/ProgressDialog.hpp> 21 #include <fwJobs/IJob.hpp> 22 #include <fwJobs/Job.hpp> 24 #include <fwMedData/SeriesDB.hpp> 26 #include <fwMedDataTools/helper/SeriesDB.hpp> 28 #include <fwServices/macros.hpp> 30 #include <fwVtkIO/SeriesDBReader.hpp> 32 #include <boost/filesystem/operations.hpp> 39 static const ::fwCom::Signals::SignalKeyType JOB_CREATED_SIGNAL =
"jobCreated";
45 m_sigJobCreated = newSignal< JobCreatedSignalType >( JOB_CREATED_SIGNAL );
59 static ::boost::filesystem::path _sDefaultPath(
"");
63 dialogFile.
setType(::fwGui::dialog::ILocationDialog::MULTI_FILES);
65 dialogFile.
addFilter(
"Vtk",
"*.vtk *.vti *.mhd *.vtu");
66 dialogFile.
addFilter(
"Vtk files",
"*.vtk");
67 dialogFile.
addFilter(
"Vti files",
"*.vti");
68 dialogFile.
addFilter(
"Vtu files",
"*.vtu");
69 dialogFile.
addFilter(
"MetaImage files",
"*.mhd");
70 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
71 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::FILE_MUST_EXIST);
73 ::fwData::location::MultiFiles::sptr result;
74 result = ::fwData::location::MultiFiles::dynamicCast( dialogFile.
show() );
77 const ::fwData::location::ILocation::VectPathType paths = result->getPaths();
80 _sDefaultPath = paths[0].parent_path();
116 _sstream <<
"SSeriesDBReader::info";
121 void SSeriesDBReader::loadSeriesDB( const ::fwData::location::ILocation::VectPathType& vtkFiles,
122 const ::fwMedData::SeriesDB::sptr& seriesDB )
124 ::fwVtkIO::SeriesDBReader::sptr reader = ::fwVtkIO::SeriesDBReader::New();
125 reader->setObject(seriesDB);
126 reader->setFiles(vtkFiles);
128 m_sigJobCreated->emit(reader->getJob());
134 catch (
const std::exception& e)
136 std::stringstream ss;
137 ss <<
"Warning during loading : " << e.what();
142 ::fwGui::dialog::IMessageDialog::WARNING);
146 std::stringstream ss;
147 ss <<
"Warning during loading. ";
150 "Warning during loading.",
151 ::fwGui::dialog::IMessageDialog::WARNING);
162 ::fwMedData::SeriesDB::sptr seriesDB = this->getInOut< ::fwMedData::SeriesDB >(::fwIO::s_DATA_KEY);
166 seriesDB = this->getObject< ::fwMedData::SeriesDB >();
168 SLM_ASSERT(
"SeriesDB not instanced", seriesDB);
170 ::fwMedData::SeriesDB::sptr localSeriesDB = ::fwMedData::SeriesDB::New();
173 cursor.
setCursor(::fwGui::ICursor::BUSY);
175 this->loadSeriesDB(this->
getFiles(), localSeriesDB);
184 seriesDB->shallowCopy(localSeriesDB);
187 ::fwMedData::SeriesDB::ContainerType addedSeries = seriesDB->getContainer();
191 sig->asyncEmit(addedSeries);
#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.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.
IOVTK_API SSeriesDBReader() noexcept
Constructor. Do nothing.
virtual IOVTK_API::fwIO::IOPathType getIOPathType() const override
This method must be implemented by concrete service readers that use path file system to read data...
#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 IOVTK_API void starting() override
Starting method.
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)
FWIO_API void setFiles(const ::fwIO::LocationsType &files)
Sets file paths.
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.
A helper to lock object on exclusive mode.
FWGUI_API void addFilter(const std::string &filterName, const std::string &wildcardList) override
specify some filtering when browsing files:
virtual IOVTK_API void configureWithIHM() override
Configure the vtk file path.
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_SERIES_SIG
Type of signal when series are added.
IOVTK_API void updating() override
Updating method.
Reader service API. It manages extension points definition and extension configuration.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWIO_APIconst::fwIO::LocationsType & getFiles() const
Returns file paths set by the user or set during service configuration.
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.
virtual IOVTK_API void stopping() override
Stopping method.
Defines the generic file/folder selector dialog for IHM.
Defines the generic cursor for IHM. Use the Delegate design pattern.
virtual IOVTK_API void configuring() override
Configuring method.
IOVTK_API void info(std::ostream &_sstream) override
Info method.
FWGUI_API void setType(::fwGui::dialog::ILocationDialog::Types type) override
Set the type of location for the dialog (SINGLE_FILE, FORLDER, MULTI_FILES)
FWIO_API void clearLocations()
Clear any location set by the setFile/setFiles/setFolder setter.
FWGUI_API void saveDefaultLocation(::fwData::location::ILocation::sptr loc) override
Save the specified default location for the dialog in preferences (if available)
The namespace ioVTK contains reader, writer and helper using the fwVtkIO lib for output and input act...
virtual FWGUI_API void setDefaultCursor() override
Set the default cursor.