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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
#ifndef MODULES_ARRAY_DETAIL_H
#define MODULES_ARRAY_DETAIL_H
// K-3D
// Copyright (c) 1995-2008, Timothy M. Shead
//
// Contact: tshead@k-3d.com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program 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
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <k3d-i18n-config.h>
#include <k3dsdk/data.h>
#include <k3dsdk/itransform_array_1d.h>
#include <k3dsdk/itransform_array_2d.h>
#include <k3dsdk/itransform_array_3d.h>
#include <k3dsdk/node.h>
#include <k3dsdk/node_change_signal.h>
#include <k3dsdk/signal_slots.h>
namespace module
{
namespace array
{
/////////////////////////////////////////////////////////////////////////////
// transform_array_1d
/// Boilerplate implementation of k3d::itransform_array_1d
class transform_array_1d :
public k3d::node,
public k3d::node_change_signal<transform_array_1d>,
public k3d::itransform_array_1d
{
typedef k3d::node base;
public:
transform_array_1d(k3d::iplugin_factory& Factory, k3d::idocument& Document) :
base(Factory, Document),
m_layout(init_owner(*this) + init_name("layout") + init_label(_("Layout")) + init_description(_("Layout")) + init_value<k3d::itransform_array_1d*>(0)),
m_processing(false)
{
m_layout.changed_signal().connect(this->make_node_change_slot());
}
const k3d::matrix4 get_element(unsigned long Index1, unsigned long Count1)
{
k3d::matrix4 result = on_get_element(Index1, Count1);
if(m_processing)
{
if(!Index1)
k3d::log() << warning << "breaking array_1d infinite loop" << std::endl;
return result;
}
m_processing = true;
if(k3d::itransform_array_1d* const layout = m_layout.pipeline_value())
result = result * layout->get_element(Index1, Count1);
m_processing = false;
return result;
}
private:
virtual const k3d::matrix4 on_get_element(unsigned long Index1, unsigned long Count1) = 0;
k3d_data(k3d::itransform_array_1d*, immutable_name, change_signal, with_undo, node_storage, no_constraint, node_property, node_serialization) m_layout;
bool m_processing;
};
/////////////////////////////////////////////////////////////////////////////
// transform_array_2d
/// Boilerplate implementation of k3d::itransform_array_1d
class transform_array_2d :
public k3d::node,
public k3d::node_change_signal<transform_array_2d>,
public k3d::itransform_array_2d
{
typedef k3d::node base;
public:
transform_array_2d(k3d::iplugin_factory& Factory, k3d::idocument& Document) :
base(Factory, Document),
m_layout(init_owner(*this) + init_name("layout") + init_label(_("Layout")) + init_description(_("Layout")) + init_value<k3d::itransform_array_2d*>(0)),
m_processing(false)
{
m_layout.changed_signal().connect(this->make_node_change_slot());
}
const k3d::matrix4 get_element(unsigned long Index1, unsigned long Count1, unsigned long Index2, unsigned long Count2)
{
k3d::matrix4 result = on_get_element(Index1, Count1, Index2, Count2);
if(m_processing)
{
if(!Index1 && !Index2)
k3d::log() << warning << "breaking array_2d infinite loop" << std::endl;
return result;
}
m_processing = true;
if(k3d::itransform_array_2d* const layout = m_layout.pipeline_value())
result = result * layout->get_element(Index1, Count1, Index2, Count2);
m_processing = false;
return result;
}
private:
virtual const k3d::matrix4 on_get_element(unsigned long Index1, unsigned long Count1, unsigned long Index2, unsigned long Count2) = 0;
k3d_data(k3d::itransform_array_2d*, immutable_name, change_signal, with_undo, node_storage, no_constraint, node_property, node_serialization) m_layout;
bool m_processing;
};
/////////////////////////////////////////////////////////////////////////////
// transform_array_3d
/// Boilerplate implementation of k3d::itransform_array_1d
class transform_array_3d :
public k3d::node,
public k3d::node_change_signal<transform_array_3d>,
public k3d::itransform_array_3d
{
typedef k3d::node base;
public:
transform_array_3d(k3d::iplugin_factory& Factory, k3d::idocument& Document) :
base(Factory, Document),
m_layout(init_owner(*this) + init_name("layout") + init_label(_("Layout")) + init_description(_("Layout")) + init_value<k3d::itransform_array_3d*>(0)),
m_processing(false)
{
m_layout.changed_signal().connect(this->make_node_change_slot());
}
const k3d::matrix4 get_element(unsigned long Index1, unsigned long Count1, unsigned long Index2, unsigned long Count2, unsigned long Index3, unsigned long Count3)
{
k3d::matrix4 result = on_get_element(Index1, Count1, Index2, Count2, Index3, Count3);
if(m_processing)
{
if(!Index1 && !Index2 && !Index3)
k3d::log() << warning << "breaking array_3d infinite loop" << std::endl;
return k3d::identity3();
}
m_processing = true;
if(k3d::itransform_array_3d* const layout = m_layout.pipeline_value())
result = result * layout->get_element(Index1, Count1, Index2, Count2, Index3, Count3);
m_processing = false;
return result;
}
private:
virtual const k3d::matrix4 on_get_element(unsigned long Index1, unsigned long Count1, unsigned long Index2, unsigned long Count2, unsigned long Index3, unsigned long Count3) = 0;
k3d_data(k3d::itransform_array_3d*, immutable_name, change_signal, with_undo, node_storage, no_constraint, node_property, node_serialization) m_layout;
bool m_processing;
};
} // namespace namespace array
} // namespace module
#endif // !MODULES_ARRAY_DETAIL_H
|