7 #include "ioVTK/SModelSeriesReader.hpp" 9 #include "ioVTK/SMeshWriter.hpp" 11 #include <fwCom/Signal.hpp> 12 #include <fwCom/Signal.hxx> 13 #include <fwCom/Signals.hpp> 15 #include <fwCore/base.hpp> 17 #include <fwData/location/Folder.hpp> 18 #include <fwData/location/ILocation.hpp> 19 #include <fwData/location/MultiFiles.hpp> 20 #include <fwData/Mesh.hpp> 21 #include <fwData/mt/ObjectWriteLock.hpp> 22 #include <fwData/Reconstruction.hpp> 24 #include <fwGui/Cursor.hpp> 25 #include <fwGui/dialog/ILocationDialog.hpp> 26 #include <fwGui/dialog/LocationDialog.hpp> 27 #include <fwGui/dialog/MessageDialog.hpp> 28 #include <fwGui/dialog/ProgressDialog.hpp> 30 #include <fwJobs/IJob.hpp> 31 #include <fwJobs/Job.hpp> 33 #include <fwMedData/ModelSeries.hpp> 35 #include <fwServices/macros.hpp> 37 #include <fwTools/UUID.hpp> 39 #include <fwVtkIO/MeshReader.hpp> 41 #include <boost/filesystem/operations.hpp> 48 static const ::fwCom::Signals::SignalKeyType JOB_CREATED_SIGNAL =
"jobCreated";
54 m_sigJobCreated = newSignal< JobCreatedSignalType >( JOB_CREATED_SIGNAL );
68 static ::boost::filesystem::path _sDefaultPath(
"");
72 dialogFile.
setType(::fwGui::dialog::ILocationDialog::MULTI_FILES);
74 dialogFile.
addFilter(
"Vtk files",
"*.vtk");
75 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
76 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::FILE_MUST_EXIST);
78 ::fwData::location::MultiFiles::sptr result;
79 result = ::fwData::location::MultiFiles::dynamicCast( dialogFile.
show() );
82 const ::fwData::location::ILocation::VectPathType paths = result->getPaths();
85 _sDefaultPath = paths[0].parent_path();
121 _sstream <<
"SModelSeriesReader::info";
131 ::fwMedData::ModelSeries::sptr modelSeries = this->getInOut< ::fwMedData::ModelSeries >(::fwIO::s_DATA_KEY);
135 modelSeries = this->getObject< ::fwMedData::ModelSeries >();
139 cursor.
setCursor(::fwGui::ICursor::BUSY);
141 ::fwMedData::ModelSeries::ReconstructionVectorType recDB = modelSeries->getReconstructionDB();
142 ::fwMedData::ModelSeries::ReconstructionVectorType addedRecs;
143 for(const ::fwData::location::ILocation::PathType& file : this->
getFiles())
145 ::fwData::Mesh::sptr mesh = ::fwData::Mesh::New();
146 this->loadMesh(file, mesh);
148 ::fwData::Reconstruction::sptr rec = ::fwData::Reconstruction::New();
150 rec->setIsVisible(
true);
151 rec->setOrganName(file.stem().string());
152 recDB.push_back(rec);
153 addedRecs.push_back(rec);
155 cursor.setDefaultCursor();
156 modelSeries->setReconstructionDB(recDB);
162 sig->asyncEmit(addedRecs);
169 void SModelSeriesReader::loadMesh( const ::boost::filesystem::path file, ::fwData::Mesh::sptr mesh )
171 ::fwVtkIO::MeshReader::sptr reader = ::fwVtkIO::MeshReader::New();
173 reader->setObject(mesh);
174 reader->setFile(file);
176 m_sigJobCreated->emit(reader->getJob());
183 catch (
const std::exception& e)
185 std::stringstream stream;
186 stream <<
"Warning during loading : " << e.what();
190 ::fwGui::dialog::IMessageDialog::WARNING);
196 "Warning during loading.",
197 ::fwGui::dialog::IMessageDialog::WARNING);
#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.
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...
Class allowing to block a Connection.
#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)
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.
virtual IOVTK_API void stopping() override
Stopping method.
virtual IOVTK_API void configureWithIHM() override
Configure the mesh path.
FWGUI_API void addFilter(const std::string &filterName, const std::string &wildcardList) override
specify some filtering when browsing files:
UpdateSlotType::sptr m_slotUpdate
Slot to call update method.
Reader service API. It manages extension points definition and extension configuration.
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_RECONSTRUCTIONS_ADDED_SIG
Key in m_signals map of signal m_sigReconstructionsAdded.
IOVTK_API void updating() override
Updating method.
IOVTK_API void info(std::ostream &_sstream) override
Info method.
FWIO_APIconst::fwIO::LocationsType & getFiles() const
Returns file paths set by the user or set during service configuration.
virtual IOVTK_API void starting() override
Starting method.
virtual IOVTK_API void configuring() override
Configuring method.
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.
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)
IOVTK_API SModelSeriesReader() noexcept
Constructor. Do nothing.
The namespace ioVTK contains reader, writer and helper using the fwVtkIO lib for output and input act...