7 #include "uiVisuQt/SnapshotEditor.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> 18 #include <fwGui/dialog/LocationDialog.hpp> 19 #include <fwGui/dialog/MessageDialog.hpp> 21 #include <fwGuiQt/container/QtContainer.hpp> 23 #include <fwRuntime/operations.hpp> 25 #include <fwServices/macros.hpp> 27 #include <boost/filesystem.hpp> 28 #include <boost/filesystem/convenience.hpp> 30 #include <QHBoxLayout> 32 #include <QPushButton> 41 const ::fwCom::Signals::SignalKeyType SnapshotEditor::s_SNAPPED_SIG =
"snapped";
49 m_sigSnapped = newSignal< SnappedSignalType >(s_SNAPPED_SIG);
64 ::fwGuiQt::container::QtContainer::sptr qtContainer
65 = ::fwGuiQt::container::QtContainer::dynamicCast(this->getContainer() );
67 ::boost::filesystem::path path = ::fwRuntime::getBundleResourceFilePath(
"uiVisuQt",
"camera-photo.png");
68 QIcon icon(QString::fromStdString(path.string()));
69 m_snapButton =
new QPushButton(icon,
"");
70 m_snapButton->setToolTip(QObject::tr(
"Snapshot"));
72 QHBoxLayout* hlayout =
new QHBoxLayout();
73 hlayout->addWidget(m_snapButton);
74 hlayout->setContentsMargins(0, 0, 0, 0);
76 qtContainer->setLayout(hlayout);
78 QObject::connect(m_snapButton, SIGNAL(clicked()),
this, SLOT(
onSnapButton()));
120 ::fwGuiQt::container::QtContainer::sptr qtContainer = ::fwGuiQt::container::QtContainer::dynamicCast(
121 this->getContainer() );
122 QWidget* container = qtContainer->getQtContainer();
123 SLM_ASSERT(
"container not instanced", container);
124 if( container->isVisible() )
126 std::string filename = this->requestFileName();
128 if(!filename.empty())
130 m_sigSnapped->asyncEmit(filename);
135 std::string msgInfo(
"It is not possible to snapshot the negato view. This view is not shown on screen.");
137 messageBox.
setTitle(
"Negato view snapshot");
139 messageBox.
setIcon(::fwGui::dialog::IMessageDialog::WARNING);
140 messageBox.
addButton(::fwGui::dialog::IMessageDialog::OK);
147 std::string SnapshotEditor::requestFileName()
149 std::string fileName =
"";
152 dialogFile.
setTitle(
"Save snapshot as");
153 dialogFile.
addFilter(
"Image file",
"*.jpg *.jpeg *.bmp *.png *.tiff");
154 dialogFile.
addFilter(
"jpeg",
"*.jpg *.jpeg");
159 dialogFile.
setOption(::fwGui::dialog::ILocationDialog::WRITE);
161 ::fwData::location::SingleFile::sptr result;
162 result = ::fwData::location::SingleFile::dynamicCast( dialogFile.
show() );
165 fileName = result->getPath().string();
166 dialogFile.
saveDefaultLocation( ::fwData::location::Folder::New(result->getPath().parent_path()) );
void onSnapButton()
Show a file dialog and notify the scene must be printed.
virtual void starting() override
Install the layout.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
virtual UIVISUQT_API ~SnapshotEditor() noexcept
Destructor. Do nothing.
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
Defines the service interface managing the editor service for object.
Defines the generic message box for IHM. Use the Delegate design pattern.
FWGUI_API void destroy()
Stops sub-views and toobar services. Destroys view, sub-views and toolbar containers.
The namespace uiVisuQt supplies user interface editors done with Qt.
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.
FWGUI_API void addFilter(const std::string &filterName, const std::string &wildcardList) override
specify some filtering when browsing files:
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 void configuring() override
Configure the editor.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
virtual void info(std::ostream &_sstream) override
Overrides.
virtual void stopping() override
Destroy the layout.
FWGUI_API void create()
Creates view, sub-views and toolbar containers. Manages sub-views and toobar services.
virtual FWGUI_API void setIcon(IMessageDialog::Icons icon) override
Set the icon (CRITICAL, WARNING, INFO or QUESTION)
FWGUI_API void setTitle(const std::string &title) override
Set the title for the dialog.
Defines the generic file/folder selector dialog for IHM.
virtual void swapping() override
Do nothing.
SnapshotEditor service is represented by a button. It allows to snap shot a generic scene...
UIVISUQT_API SnapshotEditor() noexcept
Constructor. Do nothing.
FWGUI_API void saveDefaultLocation(::fwData::location::ILocation::sptr loc) override
Save the specified default location for the dialog in preferences (if available)
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the message box.
virtual void updating() override
Do nothing.
FWGUI_API void initialize()
Initialize managers.