7 #include "ioData/MeshWriterService.hpp" 9 #include <fwData/location/Folder.hpp> 10 #include <fwData/location/SingleFile.hpp> 11 #include <fwData/Mesh.hpp> 13 #include <fwDataIO/writer/MeshWriter.hpp> 15 #include <fwGui/dialog/LocationDialog.hpp> 16 #include <fwGui/dialog/MessageDialog.hpp> 18 #include <fwServices/macros.hpp> 20 #include <boost/filesystem/operations.hpp> 36 _sstream << std::endl <<
" Mesh writer";
64 static ::boost::filesystem::path _sDefaultPath(
"");
69 dialogFile.
addFilter(
"TrianMesh",
"*.trian");
70 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::WRITE);
72 ::fwData::location::SingleFile::sptr result;
73 result = ::fwData::location::SingleFile::dynamicCast( dialogFile.
show() );
76 _sDefaultPath = result->getPath().parent_path();
78 this->
setFile(result->getPath());
94 ::fwData::Mesh::csptr mesh = this->getInput< ::fwData::Mesh >(::fwIO::s_DATA_KEY);
98 mesh = this->getObject< ::fwData::Mesh >();
103 ::fwDataIO::writer::MeshWriter::sptr writer = ::fwDataIO::writer::MeshWriter::New();
104 writer->setObject( mesh );
105 writer->setFile(this->
getFile());
111 catch (
const std::exception& e)
113 std::stringstream ss;
114 ss <<
"Warning during writing Mesh : " << e.what();
119 ::fwGui::dialog::IMessageDialog::WARNING);
IODATA_API ~MeshWriterService() noexcept
destructor
IODATA_API MeshWriterService()
Constructor : does nothing.
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
virtual IODATA_API void configuring() override
Configuring method : calls implementation from io::IWriter
static FWGUI_API IMessageDialog::Buttons showMessageDialog(const std::string &title, const std::string &message,::fwGui::dialog::IMessageDialog::Icons icon=INFO)
virtual FWGUI_API void setDefaultLocation(::fwData::location::ILocation::sptr loc) override
Set the initial location for the dialog.
IODATA_API void updating() override
Updating method. This method is called by update() from base service ( fwServices::IService ) ...
virtual IODATA_API::fwIO::IOPathType getIOPathType() const override
Return path type managed by the service, here FILE.
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 IODATA_API void info(std::ostream &_sstream) override
Info method.
FWGUI_API void addFilter(const std::string &filterName, const std::string &wildcardList) override
specify some filtering when browsing files:
FWIO_API void setFile(const ::boost::filesystem::path &file)
Sets file path.
virtual FWIO_API void configuring() override
This method proposes to parse xml configuration to retrieve file/files/folder paths.
FWIO_APIconst::boost::filesystem::path & getFile() const
Returns the file path set by the user or set during service configuration.
FWIO_API void clearLocations()
Clear any location set by the setFile/setFiles/setFolder setter.
#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.
Writer service API. It manages extension points definition and extension configuration.
FWGUI_API void setTitle(const std::string &title) override
Set the title for the dialog.
Defines the generic file/folder selector dialog for IHM.
The namespace ioData contains reader and writer services for basic fwData::Object which doesn't need ...
Data holding a geometric structure composed of points, lines, triangles, quads or polygons...
FWGUI_API void saveDefaultLocation(::fwData::location::ILocation::sptr loc) override
Save the specified default location for the dialog in preferences (if available)
FWIO_API bool hasLocationDefined() const
Returns if a location has been defined ( by the configuration process or directly by user ) ...
virtual FWSERVICES_API void info(std::ostream &_sstream)
Write information in a stream.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.
IODATA_API void configureWithIHM() override
Configure the mesh path.