7 #include "ioVTK/SImageSeriesReader.hpp" 9 #include "ioVTK/SImageReader.hpp" 11 #include <fwCom/Signal.hxx> 13 #include <fwData/Image.hpp> 14 #include <fwData/location/Folder.hpp> 15 #include <fwData/location/SingleFile.hpp> 17 #include <fwGui/Cursor.hpp> 18 #include <fwGui/dialog/LocationDialog.hpp> 19 #include <fwGui/dialog/MessageDialog.hpp> 20 #include <fwGui/dialog/ProgressDialog.hpp> 22 #include <fwIO/ioTypes.hpp> 23 #include <fwIO/IReader.hpp> 25 #include <fwJobs/IJob.hpp> 26 #include <fwJobs/Job.hpp> 28 #include <fwMedData/Equipment.hpp> 29 #include <fwMedData/ImageSeries.hpp> 30 #include <fwMedData/Patient.hpp> 31 #include <fwMedData/Study.hpp> 33 #include <fwServices/macros.hpp> 35 #include <fwTools/dateAndTime.hpp> 36 #include <fwTools/Failed.hpp> 37 #include <fwTools/Os.hpp> 38 #include <fwTools/UUID.hpp> 40 #include <fwVtkIO/BitmapImageReader.hpp> 42 #include <boost/date_time/posix_time/posix_time.hpp> 43 #include <boost/filesystem/operations.hpp> 50 static const ::fwCom::Signals::SignalKeyType JOB_CREATED_SIGNAL =
"jobCreated";
56 m_sigJobCreated = newSignal< JobCreatedSignalType >( JOB_CREATED_SIGNAL );
70 static ::boost::filesystem::path _sDefaultPath;
73 std::vector<std::string> ext;
75 std::string availableExtensions =
"";
79 availableExtensions =
"*" + ext.at(0);
80 for(
size_t i = 1; i < ext.size(); i++)
82 availableExtensions = availableExtensions +
" *" + ext.at(i);
91 dialogFile.
addFilter(
"MetaImage",
"*.mhd");
92 dialogFile.
addFilter(
"Bitmap image", availableExtensions);
93 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
94 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::FILE_MUST_EXIST);
96 ::fwData::location::SingleFile::sptr result;
97 result = ::fwData::location::SingleFile::dynamicCast( dialogFile.
show() );
100 _sDefaultPath = result->getPath().parent_path();
102 this->
setFile(result->getPath());
133 _sstream <<
"SImageSeriesReader::info";
138 void initSeries(::fwMedData::Series::sptr series)
141 const std::string unknown =
"unknown";
142 const ::boost::posix_time::ptime now = ::boost::posix_time::second_clock::local_time();
143 const std::string date = ::fwTools::getDate(now);
144 const std::string time = ::fwTools::getTime(now);
146 series->setModality(
"OT");
147 series->setDate(date);
148 series->setTime(time);
149 series->setDescription(
"Image imported with VTK");
150 ::fwMedData::DicomValuesType physicians = series->getPerformingPhysiciansName();
151 if(physicians.empty())
153 const std::string username = ::fwTools::os::getEnv(
"USERNAME", ::
fwTools::os::getEnv(
"LOGNAME",
"Unknown"));
154 physicians.push_back(username);
156 series->setPerformingPhysiciansName(physicians);
157 series->getEquipment()->setInstitutionName(unknown);
159 series->getPatient()->setName(unknown);
160 series->getPatient()->setPatientId(unknown);
161 series->getPatient()->setBirthdate(unknown);
162 series->getPatient()->setSex(unknown);
164 series->getStudy()->setInstanceUID(instanceUID);
165 series->getStudy()->setDate(date);
166 series->getStudy()->setTime(time);
167 series->getStudy()->setReferringPhysicianName(unknown);
168 series->getStudy()->setDescription(unknown);
169 series->getStudy()->setPatientAge(unknown);
179 ::fwMedData::ImageSeries::sptr imageSeries = this->getInOut< ::fwMedData::ImageSeries >(::fwIO::s_DATA_KEY);
180 SLM_ASSERT(
"ImageSeries is not instanced", imageSeries);
183 cursor.
setCursor(::fwGui::ICursor::BUSY);
187 ::fwData::Image::sptr image = ::fwData::Image::New();
191 imageSeries->setImage(image);
192 initSeries(imageSeries);
193 this->notificationOfDBUpdate();
199 FW_RAISE_EXCEPTION(e);
207 void SImageSeriesReader::notificationOfDBUpdate()
209 ::fwMedData::ImageSeries::sptr imageSeries = this->getInOut< ::fwMedData::ImageSeries >(::fwIO::s_DATA_KEY);
210 SLM_ASSERT(
"imageSeries not instanced", imageSeries);
virtual FWGUI_API void setCursor(::fwGui::ICursor::CursorType cursor) override
Set the cursor.
static FWVTKIO_API void getAvailableExtensions(std::vector< std::string > &ext)
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.
Class allowing to block a Connection.
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.
virtual IOVTK_API void stopping() override
Stopping method.
IOVTK_API SImageSeriesReader() noexcept
Constructor. Do nothing.
static IOVTK_API bool loadImage(const ::boost::filesystem::path &vtkFile, const std::shared_ptr< ::fwData::Image > &image, const std::shared_ptr< JobCreatedSignalType > &sigJobCreated)
This method is used to load an vtk image using a file path.
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.
#define OSLM_TRACE(message)
FWGUI_API void addFilter(const std::string &filterName, const std::string &wildcardList) override
specify some filtering when browsing files:
FWIO_APIconst::boost::filesystem::path & getFile() const
Returns the file path set by the user or set during service configuration.
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...
UpdateSlotType::sptr m_slotUpdate
Slot to call update method.
FWIO_API void setFile(const ::boost::filesystem::path &file)
Sets file path.
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) ...
IOPathType
IOPathType defines different type of paths used by service readers/writers.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
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.
virtual IOVTK_API void configuring() override
Configuring method.
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)
IOVTK_API void info(std::ostream &_sstream) override
Info method.
virtual IOVTK_API void configureWithIHM() override
Configure the image path.
The namespace ioVTK contains reader, writer and helper using the fwVtkIO lib for output and input act...
virtual IOVTK_API void starting() override
Starting method.
IOVTK_API void updating() override
Updating method.
virtual FWGUI_API void setDefaultCursor() override
Set the default cursor.