fw4spl
ui/uiMeasurementQt/include/uiMeasurementQt/editor/SLandmarks.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2017-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 #pragma once
8 
9 #include "uiMeasurementQt/config.hpp"
10 
11 #include <fwData/Landmarks.hpp>
12 
13 #include <fwDataTools/PickingInfo.hpp>
14 
15 #include <fwGui/editor/IEditor.hpp>
16 
17 #include <QCheckBox>
18 #include <QComboBox>
19 #include <QObject>
20 #include <QPointer>
21 #include <QPushButton>
22 #include <QSlider>
23 #include <QTreeWidget>
24 
25 namespace uiMeasurementQt
26 {
27 namespace editor
28 {
29 
64 class UIMEASUREMENTQT_CLASS_API SLandmarks : public QObject,
66 {
67 
68 Q_OBJECT
69 
70 public:
71 
73 
75  UIMEASUREMENTQT_API SLandmarks() noexcept;
76 
78  UIMEASUREMENTQT_API virtual ~SLandmarks() noexcept;
79 
80  UIMEASUREMENTQT_API virtual KeyConnectionsMap getAutoConnections() const override;
81 
82 protected:
83 
84  typedef ::fwRuntime::ConfigurationElement::sptr Configuration;
85 
91  virtual void starting() override;
92 
98  virtual void stopping() override;
99 
101  virtual void updating() override;
102 
103  virtual void configuring() override;
104 
105 private:
106 
108  void onColorButton();
109 
111  void onGroupNameEdited(QTreeWidgetItem* item, int column);
112 
114  void onSelectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
115 
117  void onSizeChanged(int newSize);
118 
120  void onOpacityChanged(int newOpacity);
121 
123  void onVisibilityChanged(int visibility);
124 
126  void onShapeChanged(const QString& shape);
127 
129  void onAddNewGroup();
130 
132  void onRemoveSelection();
133 
135  void addPickedPoint(::fwDataTools::PickingInfo pickingInfo);
136 
138  void addPoint(std::string groupName);
139 
141  void modifyPoint(std::string groupName, size_t index);
142 
144  void selectPoint(std::string groupName, size_t index);
145 
147  void deselectPoint(std::string groupName, size_t index);
148 
150  void addGroup(std::string name);
151 
153  void removeGroup(std::string name);
154 
156  void removePoint(std::string groupName, size_t index);
157 
159  void renameGroup(std::string oldName, std::string newName);
160 
162  void modifyGroup(std::string name);
163 
165  bool currentSelection(std::string& selection) const;
166 
168  QTreeWidgetItem* getGroupItem(const std::string& groupName) const;
169 
171  std::string generateNewGroupName() const;
172 
174  std::array<float, 4> generateNewColor();
175 
177  static QColor convertToQColor(const ::fwData::Landmarks::ColorType& color);
178 
180  static void setColorButtonIcon(QPushButton* button, const QColor& color);
181 
182  QPointer<QTreeWidget> m_treeWidget;
183 
184  QPointer<QWidget> m_groupEditorWidget;
185 
186  QPointer<QSlider> m_sizeSlider;
187 
188  QPointer<QSlider> m_opacitySlider;
189 
190  QPointer<QCheckBox> m_visibilityCheckbox;
191 
192  QPointer<QComboBox> m_shapeSelector;
193 
194  QPointer<QPushButton> m_newGroupButton;
195 
196  QPointer<QPushButton> m_removeButton;
197 
199  bool m_advancedMode;
200 
202  float m_defaultLandmarkSize;
203 
205  float m_defaultLandmarkOpacity;
206 
207 };
208 } // namespace editor
209 } // uiMeasurementQt
This class is a helper to define the connections of a service and its data.
Definition: IService.hpp:454
Defines the service interface managing the editor service for object.
Definition: IEditor.hpp:25
The namespace fwDataTools contains classes which provide helpers to manipulate fwData::Object. *.
STL namespace.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
Contains the representation of the data objects used in the framework.
This service defines a graphical editor to edit landmarks.