7 #include "ioVTK/SMeshReader.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 11 #include <fwCom/Signals.hpp> 13 #include <fwCore/base.hpp> 15 #include <fwData/location/Folder.hpp> 16 #include <fwData/location/SingleFile.hpp> 17 #include <fwData/mt/ObjectWriteLock.hpp> 19 #include <fwGui/Cursor.hpp> 20 #include <fwGui/dialog/LocationDialog.hpp> 21 #include <fwGui/dialog/MessageDialog.hpp> 23 #include <fwJobs/IJob.hpp> 25 #include <fwServices/macros.hpp> 27 #include <fwVtkIO/MeshReader.hpp> 29 #include <boost/filesystem/operations.hpp> 36 static const ::fwCom::Signals::SignalKeyType JOB_CREATED_SIGNAL =
"jobCreated";
49 m_sigJobCreated = newSignal< JobCreatedSignalType >(JOB_CREATED_SIGNAL);
58 static ::boost::filesystem::path _sDefaultPath(
"");
64 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::READ);
65 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::FILE_MUST_EXIST);
67 ::fwData::location::SingleFile::sptr result;
68 result = ::fwData::location::SingleFile::dynamicCast( dialogFile.
show() );
71 _sDefaultPath = result->getPath().parent_path();
73 this->
setFile(result->getPath());
107 _sstream <<
"SMeshReader::info";
112 void SMeshReader::loadMesh( const ::boost::filesystem::path vtkFile, ::fwData::Mesh::sptr _pMesh )
116 ::fwVtkIO::MeshReader::sptr reader = ::fwVtkIO::MeshReader::New();
118 m_sigJobCreated->emit(reader->getJob());
120 reader->setObject(_pMesh);
121 reader->setFile(vtkFile);
129 catch (
const std::exception& e)
131 std::stringstream ss;
132 ss <<
"Warning during loading : " << e.what();
137 ::fwGui::dialog::IMessageDialog::WARNING);
141 std::stringstream ss;
142 ss <<
"Warning during loading. ";
145 "Warning during loading.",
146 ::fwGui::dialog::IMessageDialog::WARNING);
157 ::fwData::Mesh::sptr pMesh = this->getInOut< ::fwData::Mesh >(::fwIO::s_DATA_KEY);
161 pMesh = this->getObject< ::fwData::Mesh >();
166 cursor.
setCursor(::fwGui::ICursor::BUSY);
168 this->loadMesh(this->
getFile(), pMesh);
169 this->notificationOfUpdate();
177 void SMeshReader::notificationOfUpdate()
179 ::fwData::Mesh::sptr pMesh = this->getInOut< ::fwData::Mesh >(::fwIO::s_DATA_KEY);
183 pMesh = this->getObject< ::fwData::Mesh >();
187 ::fwData::Object::ModifiedSignalType::sptr sig;
#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.
virtual IOVTK_API void configureWithIHM() override
Configure the image path.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.
IOVTK_API SMeshReader() noexcept
Constructor.
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)
IOVTK_API void info(std::ostream &_sstream) override
Info method.
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.
virtual IOVTK_API void starting() override
Starting method.
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:
FWIO_APIconst::boost::filesystem::path & getFile() const
Returns the file path set by the user or set during service configuration.
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.
virtual IOVTK_API void stopping() override
Stopping method.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
IOVTK_API void updating() override
Updating method.
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.
Data holding a geometric structure composed of points, lines, triangles, quads or polygons...
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)
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...
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.