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
|
/************************************************************************
*
* Copyright (C) 2018-2024 IRCAD France
* Copyright (C) 2018-2019 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/filter/image/flip.hpp"
#include <core/com/signal.hxx>
#include <core/com/slots.hxx>
#include <filter/image/flipper.hpp>
namespace sight::module::filter::image
{
const core::com::slots::key_t flip::FLIP_AXIS_X_SLOT = "flip_axis_x";
const core::com::slots::key_t flip::FLIP_AXIS_Y_SLOT = "flip_axis_y";
const core::com::slots::key_t flip::FLIP_AXIS_Z_SLOT = "flip_axis_z";
//------------------------------------------------------------------------------
flip::flip() :
filter(m_signals)
{
// Initialize the slots
new_slot(FLIP_AXIS_X_SLOT, &flip::flip_axis_x, this);
new_slot(FLIP_AXIS_Y_SLOT, &flip::flip_axis_y, this);
new_slot(FLIP_AXIS_Z_SLOT, &flip::flip_axis_z, this);
}
//------------------------------------------------------------------------------
void flip::configuring()
{
}
//------------------------------------------------------------------------------
void flip::starting()
{
}
//------------------------------------------------------------------------------
void flip::updating()
{
const auto in_img = m_source.lock();
SIGHT_ASSERT("No 'imageIn' found !", in_img);
if(in_img)
{
data::image::sptr out_img = std::make_shared<data::image>();
sight::filter::image::flipper::flip(in_img.get_shared(), out_img, m_flip_axes);
m_target = out_img;
this->signal<signals::computed_t>(signals::COMPUTED)->async_emit();
}
else
{
SIGHT_ERROR("An update was triggered with an empty image as input. No output image was created.");
}
}
//------------------------------------------------------------------------------
void flip::stopping()
{
m_target.reset();
}
//------------------------------------------------------------------------------
void flip::flip_axis_x()
{
m_flip_axes[0] = !(m_flip_axes[0]);
this->updating();
}
//------------------------------------------------------------------------------
void flip::flip_axis_y()
{
m_flip_axes[1] = !(m_flip_axes[1]);
this->updating();
}
//------------------------------------------------------------------------------
void flip::flip_axis_z()
{
m_flip_axes[2] = !(m_flip_axes[2]);
this->updating();
}
//------------------------------------------------------------------------------
service::connections_t flip::auto_connections() const
{
return {
{IMAGE_IN, data::image::MODIFIED_SIG, service::slots::UPDATE},
{IMAGE_IN, data::image::BUFFER_MODIFIED_SIG, service::slots::UPDATE}
};
}
} // namespace sight::module::filter::image
|