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
|
/************************************************************************
*
* Copyright (C) 2020-2024 IRCAD France
* Copyright (C) 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/viz/sample/image.hpp"
#include <service/op.hpp>
#include <ui/__/registry.hpp>
#include <ui/qt/container/widget.hpp>
namespace sight::module::viz::sample
{
//------------------------------------------------------------------------------
image::image() noexcept =
default;
//------------------------------------------------------------------------------
image::~image() noexcept =
default;
//------------------------------------------------------------------------------
void image::configuring()
{
this->sight::ui::service::initialize();
}
//------------------------------------------------------------------------------
void image::starting()
{
this->sight::ui::service::create();
auto qt_container = std::dynamic_pointer_cast<sight::ui::qt::container::widget>(
this->get_container()
);
const auto generic_scene_id = this->get_id() + "-genericScene";
sight::ui::registry::register_sid_container(generic_scene_id, qt_container);
// create and register the render service
service::config_t render_config;
render_config.put("scene.background.<xmlattr>.color", "#36393E");
render_config.put("scene.layer.<xmlattr>.id", "default");
render_config.put("scene.layer.<xmlattr>.order", "1");
render_config.put("scene.layer.<xmlattr>.transparency", "");
service::config_t interactor_cfg;
interactor_cfg.put("<xmlattr>.uid", this->get_id() + "interactorAdaptor");
service::config_t negato_cfg;
negato_cfg.put("<xmlattr>.uid", this->get_id() + "negato3DAdaptor");
render_config.add_child("scene.layer.adaptor", interactor_cfg);
render_config.add_child("scene.layer.adaptor", negato_cfg);
m_render_srv = sight::service::add("sight::viz::scene3d::render");
m_render_srv->set_config(render_config);
m_render_srv->set_id(generic_scene_id);
m_render_srv->configure();
m_interactor_srv = sight::service::add("sight::module::viz::scene3d::adaptor::trackball_camera");
m_interactor_srv->set_id(this->get_id() + "interactorAdaptor");
m_interactor_srv->configure();
// Create default transfer function
m_tf = data::transfer_function::create_default_tf();
auto image = m_image.lock();
service::config_t negato_config;
negato_config.put("config.<xmlattr>.interactive", "true");
m_negato_srv = sight::service::add("sight::module::viz::scene3d::adaptor::negato3d");
m_negato_srv->set_config(negato_config);
m_negato_srv->set_input(image.get_shared(), "image", true);
m_negato_srv->set_inout(m_tf, "tf", true);
m_negato_srv->set_id(this->get_id() + "negato3DAdaptor");
m_negato_srv->configure();
m_render_srv->start().wait();
m_interactor_srv->start().wait();
m_negato_srv->start().wait();
}
//------------------------------------------------------------------------------
void image::updating()
{
}
//------------------------------------------------------------------------------
void image::stopping()
{
m_negato_srv->stop().wait();
m_interactor_srv->stop().wait();
m_render_srv->stop().wait();
sight::ui::registry::unregister_sid_container(this->get_id() + "-genericScene");
sight::service::remove(m_negato_srv);
sight::service::remove(m_interactor_srv);
sight::service::remove(m_render_srv);
m_negato_srv.reset();
m_interactor_srv.reset();
m_render_srv.reset();
m_tf.reset();
this->destroy();
}
} // namespace sight::module::viz::sample.
|