diff options
author | neoraider <devnull@localhost> | 2008-02-13 22:06:01 +0100 |
---|---|---|
committer | neoraider <devnull@localhost> | 2008-02-13 22:06:01 +0100 |
commit | c4aadd98230f3b9ab50398b715164ff874ea8a61 (patch) | |
tree | 8b6fcaf48fb0a7eb9af6fd1483659ab4d6e5c000 /Room.h | |
parent | 16397f4474fbbe5f140a5e68b3bb6934170bf2e3 (diff) | |
download | zoomedit-c4aadd98230f3b9ab50398b715164ff874ea8a61.tar zoomedit-c4aadd98230f3b9ab50398b715164ff874ea8a61.zip |
zoomedit: Vertices are selectable now.
Diffstat (limited to 'Room.h')
-rw-r--r-- | Room.h | 40 |
1 files changed, 38 insertions, 2 deletions
@@ -3,10 +3,12 @@ #include "Polygon.h" #include "LevelObject.h" +#include "VertexProvider.h" +#include "LevelVertex.h" #include <string> -class Room : public Polygon, public LevelObject { +class Room : public Polygon, public LevelObject, public VertexProvider { private: std::string name; float height; @@ -22,9 +24,18 @@ class Room : public Polygon, public LevelObject { float getHeight() const {return height;} void setHeight(float height) {this->height = height;} - virtual bool hit(const Vertex &v) const {return contains(v);} + virtual bool hit(const Vertex &v, float scale) const {return contains(v);} virtual int getPriority() const {return 0;} + virtual std::vector<SharedPtr<LevelObject> > getChildren() { + std::vector<SharedPtr<LevelObject> > children; + + for(size_t i = 0; i < size(); i++) + children.push_back(SharedPtr<LevelObject>(new LevelVertex(this, i))); + + return children; + } + virtual const char* getType() const { return "Room"; } @@ -56,6 +67,31 @@ class Room : public Polygon, public LevelObject { return ret / size(); } + + virtual const Vertex* getVertex(size_t id) const { + return &at(id); + } + + virtual size_t getVertexCount() const { + return size(); + } + + virtual void moveVertex(size_t id, float x, float y) { + at(id) += Vertex(x, y); + } + + virtual void rotateVertex(size_t id, float a) { + Vertex z = at(id); + float s = sinf(a); + float c = cosf(a); + + for(iterator v = begin(); v != end(); v++) { + *v -= z; + v->setLocation(c*v->getX() - s*v->getY(), c*v->getY() + s*v->getX()); + *v += z; + } + } + }; #endif /*ROOM_H_*/ |