Rev | Line | |
---|
[2795] | 1 |
|
---|
| 2 | #ifndef BNCMAPVIEW_H
|
---|
| 3 | #define BNCMAPVIEW_H
|
---|
| 4 |
|
---|
| 5 | #include <QGraphicsView>
|
---|
| 6 | #include <QGraphicsRectItem>
|
---|
[3291] | 7 | #include <iostream>
|
---|
[2795] | 8 |
|
---|
| 9 | class BncMapView : public QGraphicsView
|
---|
| 10 | {
|
---|
| 11 | Q_OBJECT;
|
---|
| 12 |
|
---|
| 13 | public:
|
---|
| 14 | BncMapView(QWidget* parent = NULL);
|
---|
[3291] | 15 |
|
---|
| 16 | virtual void resetScale();
|
---|
| 17 | virtual void zoom(qreal scale);
|
---|
| 18 |
|
---|
| 19 | double scale(){ return _scale; }
|
---|
| 20 | double scale_curr(){ return _scCur; }
|
---|
| 21 | double scale_rate(){ return _scale/_scCur; }
|
---|
| 22 |
|
---|
[2795] | 23 |
|
---|
| 24 | protected:
|
---|
| 25 | QPointF _currentCenterPoint; // centerpoint for for panning and zooming
|
---|
| 26 | QPoint _lastPanPoint; // from panning the view
|
---|
| 27 | void SetCenter(const QPointF& centerPoint); // set the current centerpoint in the
|
---|
| 28 |
|
---|
| 29 | QPointF GetCenter(){ return _currentCenterPoint; }
|
---|
| 30 |
|
---|
| 31 | virtual void mousePressEvent(QMouseEvent* event);
|
---|
| 32 | virtual void mouseReleaseEvent(QMouseEvent* event);
|
---|
| 33 | virtual void mouseMoveEvent(QMouseEvent* event);
|
---|
| 34 | virtual void wheelEvent(QWheelEvent* event);
|
---|
| 35 | virtual void resizeEvent(QResizeEvent* event);
|
---|
[3291] | 36 |
|
---|
| 37 | private:
|
---|
| 38 | double _scale; // scale
|
---|
| 39 | double _scCur; // current relative scale
|
---|
[2795] | 40 | };
|
---|
| 41 |
|
---|
[2803] | 42 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.