Line |
Branch |
Exec |
Source |
1 |
|
|
/************************************************************************ |
2 |
|
|
* |
3 |
|
|
* Copyright (C) 2009-2025 IRCAD France |
4 |
|
|
* Copyright (C) 2012-2020 IHU Strasbourg |
5 |
|
|
* |
6 |
|
|
* This file is part of Sight. |
7 |
|
|
* |
8 |
|
|
* Sight is free software: you can redistribute it and/or modify it under |
9 |
|
|
* the terms of the GNU Lesser General Public License as published by |
10 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
11 |
|
|
* (at your option) any later version. |
12 |
|
|
* |
13 |
|
|
* Sight is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU Lesser General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* You should have received a copy of the GNU Lesser General Public |
19 |
|
|
* License along with Sight. If not, see <https://www.gnu.org/licenses/>. |
20 |
|
|
* |
21 |
|
|
***********************************************************************/ |
22 |
|
|
|
23 |
|
|
#include "modules/ui/qt/viz/point_editor.hpp" |
24 |
|
|
|
25 |
|
|
#include <core/base.hpp> |
26 |
|
|
#include <core/com/slot.hpp> |
27 |
|
|
#include <core/com/slot.hxx> |
28 |
|
|
#include <core/com/slots.hpp> |
29 |
|
|
#include <core/com/slots.hxx> |
30 |
|
|
|
31 |
|
|
#include <data/map.hpp> |
32 |
|
|
#include <data/string.hpp> |
33 |
|
|
|
34 |
|
|
#include <ui/qt/container/widget.hpp> |
35 |
|
|
|
36 |
|
|
#include <QDoubleValidator> |
37 |
|
|
#include <QHBoxLayout> |
38 |
|
|
#include <QLabel> |
39 |
|
|
#include <QPalette> |
40 |
|
|
#include <QSpacerItem> |
41 |
|
|
#include <QStringList> |
42 |
|
|
#include <QVBoxLayout> |
43 |
|
|
#include <QWidget> |
44 |
|
|
|
45 |
|
|
namespace sight::module::ui::qt::viz |
46 |
|
|
{ |
47 |
|
|
|
48 |
|
|
static const core::com::slots::key_t GET_INTERACTION_SLOT = "get_interaction"; |
49 |
|
|
|
50 |
|
✗ |
point_editor::point_editor() noexcept |
51 |
|
|
{ |
52 |
|
✗ |
new_slot(GET_INTERACTION_SLOT, &point_editor::get_interaction, this); |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
//------------------------------------------------------------------------------ |
56 |
|
|
|
57 |
|
✗ |
point_editor::~point_editor() noexcept = |
58 |
|
|
default; |
59 |
|
|
|
60 |
|
|
//------------------------------------------------------------------------------ |
61 |
|
|
|
62 |
|
✗ |
void point_editor::starting() |
63 |
|
|
{ |
64 |
|
✗ |
this->sight::ui::service::create(); |
65 |
|
|
|
66 |
|
✗ |
auto qt_container = std::dynamic_pointer_cast<sight::ui::qt::container::widget>( |
67 |
|
✗ |
this->get_container() |
68 |
|
✗ |
); |
69 |
|
|
|
70 |
|
✗ |
auto* h_layout = new QHBoxLayout(); |
71 |
|
|
|
72 |
|
✗ |
auto* static_text_x = new QLabel(tr("x:")); |
73 |
|
✗ |
h_layout->addWidget(static_text_x, 0, Qt::AlignVCenter); |
74 |
|
|
|
75 |
|
✗ |
m_text_ctrl_x = new QLineEdit(); |
76 |
|
✗ |
m_text_ctrl_x->setValidator(new QDoubleValidator(m_text_ctrl_x)); |
77 |
|
✗ |
h_layout->addWidget(m_text_ctrl_x, 1, Qt::AlignVCenter); |
78 |
|
|
|
79 |
|
✗ |
auto* static_text_y = new QLabel(tr("y:")); |
80 |
|
✗ |
h_layout->addWidget(static_text_y, 0, Qt::AlignVCenter); |
81 |
|
|
|
82 |
|
✗ |
m_text_ctrl_y = new QLineEdit(); |
83 |
|
✗ |
m_text_ctrl_y->setValidator(new QDoubleValidator(m_text_ctrl_y)); |
84 |
|
✗ |
h_layout->addWidget(m_text_ctrl_y, 1, Qt::AlignVCenter); |
85 |
|
|
|
86 |
|
✗ |
auto* static_text_z = new QLabel(tr("z:")); |
87 |
|
✗ |
h_layout->addWidget(static_text_z, 0, Qt::AlignVCenter); |
88 |
|
|
|
89 |
|
✗ |
m_text_ctrl_z = new QLineEdit(); |
90 |
|
✗ |
m_text_ctrl_z->setValidator(new QDoubleValidator(m_text_ctrl_z)); |
91 |
|
✗ |
h_layout->addWidget(m_text_ctrl_z, 1, Qt::AlignVCenter); |
92 |
|
|
|
93 |
|
✗ |
qt_container->set_layout(h_layout); |
94 |
|
✗ |
this->updating(); |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
//------------------------------------------------------------------------------ |
98 |
|
|
|
99 |
|
✗ |
void point_editor::stopping() |
100 |
|
|
{ |
101 |
|
✗ |
this->destroy(); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
//------------------------------------------------------------------------------ |
105 |
|
|
|
106 |
|
✗ |
void point_editor::configuring() |
107 |
|
|
{ |
108 |
|
✗ |
this->sight::ui::service::initialize(); |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
//------------------------------------------------------------------------------ |
112 |
|
|
|
113 |
|
✗ |
void point_editor::updating() |
114 |
|
|
{ |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
//------------------------------------------------------------------------------ |
118 |
|
|
|
119 |
|
✗ |
void point_editor::get_interaction(data::tools::picking_info _info) |
120 |
|
|
{ |
121 |
|
✗ |
if(_info.m_event_id == data::tools::picking_info::event::mouse_left_down) |
122 |
|
|
{ |
123 |
|
✗ |
m_text_ctrl_x->setText(QString("%1").arg(_info.m_world_pos[0], 0, 'f', 3)); |
124 |
|
✗ |
m_text_ctrl_y->setText(QString("%1").arg(_info.m_world_pos[1], 0, 'f', 3)); |
125 |
|
✗ |
m_text_ctrl_z->setText(QString("%1").arg(_info.m_world_pos[2], 0, 'f', 3)); |
126 |
|
|
} |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
//------------------------------------------------------------------------------ |
130 |
|
|
|
131 |
|
✗ |
void point_editor::info(std::ostream& _sstream) |
132 |
|
|
{ |
133 |
|
✗ |
_sstream << "Point Editor"; |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
//------------------------------------------------------------------------------ |
137 |
|
|
|
138 |
|
|
} // namespace sight::module::ui::qt::viz |
139 |
|
|
|