Rebuild autotool system
[construo.git] / selection.hxx
blob7a3a32cb5e3461514d34321dbadaeb79d6c3e042
1 // $Id: selection.hxx,v 1.6 2003/07/28 22:46:48 grumbel Exp $
2 //
3 // Construo - A wire-frame construction gamee
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
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
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_CONSTRUO_SELECTION_HXX
21 #define HEADER_CONSTRUO_SELECTION_HXX
23 #include <list>
24 #include "vector2d.hxx"
26 class Particle;
27 class World;
29 /** A class to keep track of a group of selected particles */
30 class Selection
32 private:
33 typedef std::list<Particle*> SelectionLst;
34 /** Collection of particles */
35 SelectionLst selection;
37 /** Pointer to the world that contains the particle this selection
38 is pointing to. Used to check if the world has changed, so that
39 the selection needs to get cleared. */
40 World* world;
42 public:
43 Selection ();
45 /** @return Center point of the selection, aka the center of its
46 bounding box, result is undefined if called on a empty
47 selection */
48 Vector2d get_center ();
50 /** Select the particles between p1 (upper/left) and p2
51 (bottom/right) */
52 void select_particles (Vector2d p1, Vector2d p2);
54 /** scales the selection by the given factor */
55 void scale (float factor, Vector2d center);
57 void flip();
59 /** sets the velocity of all particles to the given one */
60 void set_velocity (const Vector2d vel);
62 /** duplicates all selected objects */
63 void duplicate ();
65 /** clears the selection */
66 void clear ();
68 /** @return true if no particle is in the selection */
69 bool empty() const;
71 /** Check if the world has changed, if so clear selection FIXME: add
72 a bit more docu here */
73 void validate();
75 void rotate(float rot_angle, Vector2d rotate_center);
77 /** Join particles that are on nearly the same position
79 * @param toleranz minimum distance of to particles below which they
80 * get joined (in world coordinates)
82 void join_doubles(float toleranz);
84 SelectionLst::size_type size() { return selection.size(); }
85 SelectionLst::iterator begin() { return selection.begin(); };
86 SelectionLst::iterator end() { return selection.end(); };
88 typedef SelectionLst::iterator iterator;
89 private:
90 Selection (const Selection&);
91 Selection& operator= (const Selection&);
94 #endif
96 /* EOF */