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