]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/object.h
8ce521ab5366df54375973e3db4715e11cc0c81e
[r2c2.git] / source / libr2c2 / object.h
1 #ifndef LIBR2C2_OBJECT_H_
2 #define LIBR2C2_OBJECT_H_
3
4 #include "geometry.h"
5 #include "objecttype.h"
6 #include "snap.h"
7
8 namespace R2C2 {
9
10 class Layout;
11
12 class Object
13 {
14 protected:
15         Layout &layout;
16         Vector position;
17         float rotation;
18
19         Object(Layout &l): layout(l) { }
20 public:
21         virtual ~Object() { }
22
23         virtual Object *clone(Layout * = 0) const = 0;
24         virtual const ObjectType &get_type() const = 0;
25         Layout &get_layout() const { return layout; }
26         virtual void set_position(const Vector &) = 0;
27         virtual void set_rotation(float) = 0;
28         const Vector &get_position() const { return position; }
29         float get_rotation() const { return rotation; }
30         virtual Object *get_parent() const { return 0; }
31
32         virtual unsigned get_n_snap_nodes() const { return 0; }
33         virtual Snap get_snap_node(unsigned) const;
34         virtual bool snap(Snap &, float, SnapType = SNAP_DEFAULT) const;
35         virtual bool snap_to(const Object &, float, SnapType = SNAP_DEFAULT);
36 protected:
37         virtual SnapType get_default_snap_type_to(const Object &) const { return NO_SNAP; }
38
39 public:
40         virtual bool collide_ray(const Vector &, const Vector &) const = 0;
41 };
42
43 } // namespace R2C2
44
45 #endif