fw4spl
PointEditor.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "uiVisuQt/PointEditor.hpp"
8 
9 #include <fwCom/Slot.hpp>
10 #include <fwCom/Slot.hxx>
11 #include <fwCom/Slots.hpp>
12 #include <fwCom/Slots.hxx>
13 
14 #include <fwCore/base.hpp>
15 
16 #include <fwData/Composite.hpp>
17 #include <fwData/String.hpp>
18 
19 #include <fwGuiQt/container/QtContainer.hpp>
20 
21 #include <fwMath/IntrasecTypes.hpp>
22 
23 #include <fwServices/IService.hpp>
24 #include <fwServices/macros.hpp>
25 
26 #include <QDoubleValidator>
27 #include <QHBoxLayout>
28 #include <QLabel>
29 #include <QPalette>
30 #include <QSpacerItem>
31 #include <QStringList>
32 #include <QVBoxLayout>
33 #include <QWidget>
34 
35 namespace uiVisuQt
36 {
37 
38 fwServicesRegisterMacro( ::fwGui::editor::IEditor, ::uiVisuQt::PointEditor, ::fwData::Composite );
39 
40 static const ::fwCom::Slots::SlotKeyType s_GET_INTERACTION_SLOT = "getInteraction";
41 
43 {
44  newSlot(s_GET_INTERACTION_SLOT, &PointEditor::getInteraction, this);
45 }
46 
47 //------------------------------------------------------------------------------
48 
50 {
51 }
52 
53 //------------------------------------------------------------------------------
54 
56 {
59 
60  ::fwGuiQt::container::QtContainer::sptr qtContainer = ::fwGuiQt::container::QtContainer::dynamicCast(
61  this->getContainer() );
62 
63  QHBoxLayout* hLayout = new QHBoxLayout();
64 
65  QLabel* staticText_x = new QLabel( tr("x:"));
66  hLayout->addWidget( staticText_x, 0, Qt::AlignVCenter );
67 
68  m_textCtrl_x = new QLineEdit();
69  m_textCtrl_x->setValidator( new QDoubleValidator(m_textCtrl_x) );
70  hLayout->addWidget( m_textCtrl_x, 1, Qt::AlignVCenter );
71 
72  QLabel* staticText_y = new QLabel( tr("y:") );
73  hLayout->addWidget( staticText_y, 0, Qt::AlignVCenter );
74 
75  m_textCtrl_y = new QLineEdit();
76  m_textCtrl_y->setValidator( new QDoubleValidator(m_textCtrl_y) );
77  hLayout->addWidget( m_textCtrl_y, 1, Qt::AlignVCenter );
78 
79  QLabel* staticText_z = new QLabel( tr("z:"));
80  hLayout->addWidget( staticText_z, 0, Qt::AlignVCenter );
81 
82  m_textCtrl_z = new QLineEdit();
83  m_textCtrl_z->setValidator( new QDoubleValidator(m_textCtrl_z) );
84  hLayout->addWidget( m_textCtrl_z, 1, Qt::AlignVCenter );
85 
86  qtContainer->setLayout( hLayout );
87  this->updating();
88 }
89 
90 //------------------------------------------------------------------------------
91 
93 {
95 
96  this->destroy();
97 }
98 
99 //------------------------------------------------------------------------------
100 
102 {
103  SLM_TRACE_FUNC();
105 }
106 
107 //------------------------------------------------------------------------------
108 
110 {
111 }
112 
113 //------------------------------------------------------------------------------
114 
116 {
117  this->updating();
118 }
119 
120 //------------------------------------------------------------------------------
121 
122 void PointEditor::getInteraction(::fwDataTools::PickingInfo info)
123 {
124  if ( info.m_eventId == ::fwDataTools::PickingInfo::Event::MOUSE_MOVE )
125  {
126  m_textCtrl_x->setText(QString("%1").arg(info.m_worldPos[0], 0, 'f', 3));
127  m_textCtrl_y->setText(QString("%1").arg(info.m_worldPos[1], 0, 'f', 3));
128  m_textCtrl_z->setText(QString("%1").arg(info.m_worldPos[2], 0, 'f', 3));
129  }
130 }
131 
132 //------------------------------------------------------------------------------
133 
134 void PointEditor::info( std::ostream& _sstream )
135 {
136  _sstream << "Point Editor";
137 }
138 
139 //------------------------------------------------------------------------------
140 
141 } // namespace uiVisuQt
PointEditor service allows to display point information.
Definition: PointEditor.hpp:29
virtual void info(std::ostream &_sstream) override
Overrides.
double m_worldPos[3]
Position clicked in world coordinates.
Definition: PickingInfo.hpp:44
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
void configuring() override
Configure the service before starting. Apply the configuration to service.
Defines the service interface managing the editor service for object.
Definition: IEditor.hpp:25
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.
void swapping() override
Swap the service from associated object to another object.
virtual UIVISUQT_API ~PointEditor() noexcept
Destructor. Do nothing.
Definition: PointEditor.cpp:49
virtual void stopping() override
This method launches the IEditor::stopping method.
Definition: PointEditor.cpp:92
Structure to store picking information.
Definition: PickingInfo.hpp:20
FWGUI_API void create()
Creates view, sub-views and toolbar containers. Manages sub-views and toobar services.
virtual void starting() override
This method launches the IEditor::starting method.
Definition: PointEditor.cpp:55
This class defines a composite object.
FWGUI_API void initialize()
Initialize managers.
Event m_eventId
Mouse event.
Definition: PickingInfo.hpp:50
UIVISUQT_API PointEditor() noexcept
Constructor. Do nothing.
Definition: PointEditor.cpp:42