9 #include "ioVTK/SModelSeriesObjWriter.hpp" 11 #include "ioVTK/SMeshWriter.hpp" 13 #include <fwCore/base.hpp> 15 #include <fwData/location/Folder.hpp> 16 #include <fwData/Mesh.hpp> 17 #include <fwData/Reconstruction.hpp> 19 #include <fwGui/Cursor.hpp> 20 #include <fwGui/dialog/ILocationDialog.hpp> 21 #include <fwGui/dialog/LocationDialog.hpp> 22 #include <fwGui/dialog/MessageDialog.hpp> 23 #include <fwGui/dialog/ProgressDialog.hpp> 25 #include <fwMedData/ModelSeries.hpp> 27 #include <fwServices/macros.hpp> 29 #include <fwTools/UUID.hpp> 31 #include <fwVtkIO/ModelSeriesObjWriter.hpp> 33 #include <boost/filesystem/operations.hpp> 40 static const ::fwCom::Signals::SignalKeyType JOB_CREATED_SIGNAL =
"jobCreated";
46 m_sigJobCreated = newSignal< JobCreatedSignalType >( JOB_CREATED_SIGNAL );
53 return ::fwIO::FOLDER;
61 static ::boost::filesystem::path _sDefaultPath(
"");
66 dialog.
setOption(::fwGui::dialog::ILocationDialog::WRITE);
67 dialog.
setType(::fwGui::dialog::ILocationDialog::FOLDER);
69 ::fwData::location::Folder::sptr result;
71 while (result = ::fwData::location::Folder::dynamicCast( dialog.
show() ))
73 if( ::boost::filesystem::is_empty(result->getFolder()) )
79 messageBox.
setTitle(
"Overwrite confirmation");
80 messageBox.
setMessage(
"The selected directory is not empty. Write anyway ?");
81 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::QUESTION);
82 messageBox.
addButton(::fwGui::dialog::IMessageDialog::YES);
83 messageBox.
addButton(::fwGui::dialog::IMessageDialog::CANCEL);
84 if( messageBox.
show() == ::fwGui::dialog::IMessageDialog::YES)
92 _sDefaultPath = result->getFolder().parent_path();
127 _sstream <<
"SModelSeriesObjWriter::info";
139 ::fwMedData::ModelSeries::csptr modelSeries = this->getInput< ::fwMedData::ModelSeries >(::fwIO::s_DATA_KEY);
143 modelSeries = this->getObject< ::fwMedData::ModelSeries >();
145 SLM_ASSERT(
"ModelSeries is not instanced", modelSeries);
147 ::fwVtkIO::ModelSeriesObjWriter::sptr writer = ::fwVtkIO::ModelSeriesObjWriter::New();
148 writer->setObject(modelSeries);
152 cursor.
setCursor(::fwGui::ICursor::BUSY);
156 m_sigJobCreated->emit(writer->getJob());
159 catch (
const std::exception& e)
161 std::stringstream ss;
162 ss <<
"Warning during saving : " << e.what();
167 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::WARNING);
168 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
173 std::stringstream ss;
174 ss <<
"Warning during saving.";
179 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::WARNING);
180 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
#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 starting() override
Starting method.
virtual IOVTK_API void stopping() override
Stopping method.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
Defines the generic message box for IHM. Use the Delegate design pattern.
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.
IOVTK_API void info(std::ostream &_sstream) override
Info method.
virtual FWGUI_API void addButton(IMessageDialog::Buttons button) override
Add a button (OK, YES_NO, YES, NO, CANCEL)
virtual FWGUI_API IMessageDialog::Buttons show() override
Show the message box and return the clicked button.
virtual FWIO_API void configuring() override
This method proposes to parse xml configuration to retrieve file/files/folder paths.
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) ...
FWIO_APIconst::boost::filesystem::path & getFolder() const
Returns folder path set by the user or set during service configuration.
virtual FWGUI_API void setIcon(IMessageDialog::Icons icon) override
Set the icon (CRITICAL, WARNING, INFO or QUESTION)
IOVTK_API void updating() override
Updating method.
IOPathType
IOPathType defines different type of paths used by service readers/writers.
virtual IOVTK_API void configureWithIHM() override
Configure the mesh path.
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.
Defines the generic cursor for IHM. Use the Delegate design pattern.
virtual IOVTK_API void configuring() override
Configuring method.
FWIO_API void setFolder(const ::boost::filesystem::path &folder)
Sets folder path.
IOVTK_API SModelSeriesObjWriter() noexcept
Constructor. Do nothing.
FWGUI_API void setType(::fwGui::dialog::ILocationDialog::Types type) override
Set the type of location for the dialog (SINGLE_FILE, FORLDER, MULTI_FILES)
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 setTitle(const std::string &title) override
Set the title of the message box.
FWIO_API bool hasLocationDefined() const
Returns if a location has been defined ( by the configuration process or directly by user ) ...
virtual IOVTK_API::fwIO::IOPathType getIOPathType() const override
This method must be implemented by concrete service writers that use path file system to write data...
virtual FWGUI_API void setDefaultCursor() override
Set the default cursor.
std::string m_windowTitle
Title of the window that will open when the configureWithIHM slot is called.