~ubuntu-branches/ubuntu/edgy/k3d/edgy-proposed

« back to all changes in this revision

Viewing changes to modules/mesh/select_point_by_number.cpp

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2005-04-28 18:38:10 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050428183810-kvc6nz46z6gheo0k
Tags: 0.4.5.0-5
* AAAAAAAARGH, *patching* configure.ac broke again the build process! Fixed
  (I hope).
* Removed more cruft of shaderpreprocessor/ from configure.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// K-3D
 
2
// Copyright (c) 1995-2004, Timothy M. Shead
 
3
//
 
4
// Contact: tshead@k-3d.com
 
5
//
 
6
// This program is free software; you can redistribute it and/or
 
7
// modify it under the terms of the GNU General Public
 
8
// License as published by the Free Software Foundation; either
 
9
// version 2 of the License, or (at your option) any later version.
 
10
//
 
11
// This program is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
// General Public License for more details.
 
15
//
 
16
// You should have received a copy of the GNU General Public
 
17
// License along with this program; if not, write to the Free Software
 
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 
 
20
/** \file
 
21
                \author Timothy M. Shead (tshead@k-3d.com)
 
22
                \author Romain Behar (romainbehar@yahoo.com)
 
23
*/
 
24
 
 
25
#include <k3dsdk/classes.h>
 
26
#include <k3dsdk/measurement.h>
 
27
#include <k3dsdk/object.h>
 
28
#include <k3dsdk/persistence.h>
 
29
#include <k3dsdk/mesh.h>
 
30
#include <k3dsdk/mesh_filter.h>
 
31
#include <k3dsdk/module.h>
 
32
#include <k3dsdk/plugins.h>
 
33
 
 
34
namespace libk3dmesh
 
35
{
 
36
 
 
37
/////////////////////////////////////////////////////////////////////////////
 
38
// select_point_by_number_implementation
 
39
 
 
40
class select_point_by_number_implementation :
 
41
        public k3d::mesh_filter<k3d::persistent<k3d::object> >
 
42
{
 
43
        typedef k3d::mesh_filter<k3d::persistent<k3d::object> > base;
 
44
 
 
45
public:
 
46
        select_point_by_number_implementation(k3d::idocument& Document) :
 
47
                base(Document),
 
48
                m_index(k3d::init_name("index") + k3d::init_description("Point index [number]") + k3d::init_value(0UL) + k3d::init_precision(0) + k3d::init_step_increment(1) + k3d::init_units(typeid(k3d::measurement::scalar)) + k3d::init_document(Document))
 
49
        {
 
50
                register_property(m_index);
 
51
 
 
52
                m_input_mesh.changed_signal().connect(SigC::slot(*this, &select_point_by_number_implementation::on_reset_geometry));
 
53
                m_index.changed_signal().connect(SigC::slot(*this, &select_point_by_number_implementation::on_reset_geometry));
 
54
                m_output_mesh.need_data_signal().connect(SigC::slot(*this, &select_point_by_number_implementation::on_create_geometry));
 
55
        }
 
56
 
 
57
        void on_reset_geometry()
 
58
        {
 
59
                m_output_mesh.reset();
 
60
        }
 
61
 
 
62
        k3d::mesh* on_create_geometry()
 
63
        {
 
64
                // Get the input geometry ...
 
65
                k3d::mesh* const input = m_input_mesh.property_value();
 
66
                if(!input)
 
67
                        return 0;
 
68
 
 
69
                // Create output geometry ...
 
70
                k3d::mesh* const output = new k3d::mesh();
 
71
                k3d::deep_copy(*input, *output);
 
72
 
 
73
                const unsigned long index = m_index.property_value();
 
74
 
 
75
                for(k3d::mesh::points_t::const_iterator point = output->points.begin(); point != output->points.end(); ++point)
 
76
                        k3d::deselect(document(), k3d::deep_selection(document().dag(), k3d::make_selection(**point)));
 
77
 
 
78
                if(index < output->points.size())
 
79
                        k3d::select(document(), k3d::deep_selection(document().dag(), k3d::make_selection(*(output->points[index]))));
 
80
 
 
81
                return output;
 
82
        }
 
83
 
 
84
        k3d::iplugin_factory& factory()
 
85
        {
 
86
                return get_factory();
 
87
        }
 
88
 
 
89
        static k3d::iplugin_factory& get_factory()
 
90
        {
 
91
                static k3d::plugin_factory<
 
92
                        k3d::document_plugin<select_point_by_number_implementation>,
 
93
                        k3d::interface_list<k3d::imesh_source,
 
94
                        k3d::interface_list<k3d::imesh_sink > > > factory(
 
95
                                k3d::uuid(0xded6d3a7, 0x65fc4d6d, 0x8b7afff7, 0xdd0785ad),
 
96
                                "SelectPointByNumber",
 
97
                                "Selects a point from the input mesh by its index number",
 
98
                                "Objects",
 
99
                                k3d::iplugin_factory::EXPERIMENTAL);
 
100
 
 
101
                return factory;
 
102
        }
 
103
 
 
104
private:
 
105
        k3d_measurement_property(unsigned long, k3d::immutable_name, k3d::change_signal, k3d::with_undo, k3d::local_storage, k3d::no_constraint) m_index;
 
106
};
 
107
 
 
108
/////////////////////////////////////////////////////////////////////////////
 
109
// select_point_by_number_factory
 
110
 
 
111
k3d::iplugin_factory& select_point_by_number_factory()
 
112
{
 
113
        return select_point_by_number_implementation::get_factory();
 
114
}
 
115
 
 
116
} // namespace libk3dmesh
 
117
 
 
118