This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/mapview/2D/MapView2D.h
2018-10-25 12:23:40 +02:00

105 lines
1.8 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* © Copyright 2014 Urheberrechtshinweis
* Alle Rechte vorbehalten / All Rights Reserved
*
* Programmcode ist urheberrechtlich geschuetzt.
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
* Keine Verwendung ohne explizite Genehmigung.
* (vgl. § 106 ff UrhG / § 97 UrhG)
*/
#ifndef MAP2D_H
#define MAP2D_H
#include <QWidget>
#include <QOpenGLWidget>
#include "../../fixC11.h"
#include "Scaler.h"
class MapModel;
class MV2DElement;
class QGestureEvent;
class QPinchGesture;
class QSwipeGesture;
#include "tools/Tools.h"
/**
* view to render (and edit) MapElements
*/
class MapView2D : public QOpenGLWidget {
Q_OBJECT
private:
/** scaling within the map */
Scaler s;
/** the currently active tool (if any) */
Tools tools;
/** the underlying data-model */
MapModel* model = nullptr;
public:
/** ctor */
MapView2D(QWidget* parent = nullptr);
void layerChange() {
update();
tools.layerChange(this);
}
public:
virtual void paintGL() override;
virtual void initializeGL() override;
virtual void resizeGL(int w, int h) override;
Tools& getTools() {return tools;}
/** get the underlying data-model */
MapModel* getModel() {return model;}
/** set the underlying data-model */
void setModel(MapModel* mdl) {
this->model = mdl;
update();
}
/** get the underlying scaling device */
Scaler& getScaler() {return s;}
signals:
void onElementChange(MV2DElement*e);
protected:
void mousePressEvent(QMouseEvent* e);
void mouseMoveEvent(QMouseEvent* e);
void mouseReleaseEvent(QMouseEvent* e);
void wheelEvent(QWheelEvent* e);
void keyPressEvent(QKeyEvent* e);
// android
bool event(QEvent *e) override;
bool gestureEvent(QGestureEvent* event);
void pinchTriggered(QPinchGesture* gesture);
void panTriggered(QPanGesture* gesture);
};
#endif // MAP2D_H