initial commit
This commit is contained in:
59
mapview/tools/Tools.h
Normal file
59
mapview/tools/Tools.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef TOOLS_H
|
||||
#define TOOLS_H
|
||||
|
||||
#include <vector>
|
||||
#include "Tool.h"
|
||||
|
||||
/**
|
||||
* combine several tools under the interface for one tool
|
||||
*/
|
||||
class Tools : public Tool {
|
||||
|
||||
private:
|
||||
|
||||
std::vector<Tool*> tools;
|
||||
|
||||
public:
|
||||
|
||||
/** add this tool */
|
||||
void enable(Tool* t) {tools.push_back(t);}
|
||||
|
||||
/** remove this tool */
|
||||
void disable(Tool* t) {tools.erase(std::remove(tools.begin(), tools.end(), t));}
|
||||
|
||||
|
||||
virtual void mousePressEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
for (Tool* t : tools) {t->mousePressEvent(m, e);}
|
||||
}
|
||||
|
||||
virtual void mouseMoveEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
for (Tool* t : tools) {t->mouseMoveEvent(m, e);}
|
||||
}
|
||||
|
||||
virtual void mouseReleaseEvent(MapView2D* m, QMouseEvent* e) override {
|
||||
for (Tool* t : tools) {t->mouseReleaseEvent(m, e);}
|
||||
}
|
||||
|
||||
virtual void wheelEvent(MapView2D* m, QWheelEvent* e) override {
|
||||
for (Tool* t : tools) {t->wheelEvent(m, e);}
|
||||
}
|
||||
|
||||
virtual void keyPressEvent(MapView2D* m, QKeyEvent* e) override {
|
||||
for (Tool* t : tools) {t->keyPressEvent(m, e);}
|
||||
}
|
||||
|
||||
virtual void paintBefore(MapView2D* m, Painter& p) override {
|
||||
for (Tool* t : tools) {t->paintBefore(m, p);}
|
||||
}
|
||||
|
||||
virtual void paintAfter(MapView2D* m, Painter& p) override {
|
||||
for (Tool* t : tools) {t->paintAfter(m, p);}
|
||||
}
|
||||
|
||||
virtual void layerChange(MapView2D* m) override {
|
||||
for (Tool* t : tools) {t->layerChange(m);}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // TOOLS_H
|
||||
Reference in New Issue
Block a user