source: subversion/applications/editors/merkaartor/GeoImageDock.h @ 13989

Last change on this file since 13989 was 13962, checked in by schluessler, 11 years ago

FIX : image markers for TrackPoints? are now always drawn without using styles
FIX : there was a small bug when zooming in: the position under the mouse was not hold correctly
ADD : next/previous image can be selected through pressing page-up page-down or through the GeoImageDock? context menu

File size: 2.5 KB
Line 
1
2#include "MapView.h"
3#include "MainWindow.h"
4#include "Map/MapDocument.h"
5
6#include <QtGui/QPainter>
7#include <QtGui/QDockWidget>
8#include <QtGui/QMouseEvent>
9#include <QtGui/QShortcut>
10#include <exiv2/image.hpp>
11#include <exiv2/exif.hpp>
12
13
14#define WARNING(title, message) { \
15        if (QMessageBox::warning(this, title, message.arg(file), \
16         QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Ignore) == QMessageBox::Ignore) \
17                continue; \
18        else { \
19                theView->invalidate(true, false); \
20                return; \
21        } \
22}
23
24#define QUESTION(title, message, always) { \
25        if (always == 0) { \
26                int replyButton = QMessageBox::question(this, title, message, \
27                 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Abort, QMessageBox::Yes ); \
28                if (replyButton == QMessageBox::No) \
29                        continue; \
30                else if (replyButton == QMessageBox::Abort) { \
31                        theView->invalidate(true, false); \
32                        return; \
33                } \
34                else if (replyButton != QMessageBox::Yes) \
35                        always = replyButton; \
36        } \
37        if (always == QMessageBox::NoToAll) \
38                continue; \
39}
40       
41class ImageView;
42
43class GeoImageDock : public QDockWidget
44{
45        Q_OBJECT
46
47public:
48        GeoImageDock(MainWindow *aMain);
49        ~GeoImageDock(void);
50
51        void loadImages(QStringList fileNames);
52        void setImage(TrackPoint *Pt);
53        void setImage(int ImageId);
54
55        void addGeoDataToImage(Coord pos, const QString & file);
56
57private slots:
58        void removeImages(void);
59        void toClipboard(void);
60        void selectNext(void);
61        void selectPrevious(void);
62
63private:
64
65        QStringList Images;
66        int curImage;
67        bool updateByMe;
68
69        ImageView *Image;
70
71        struct TrackPointData {
72                TrackPointData(const QString & mId, const QString & mFilename, const QDateTime & mTimestamp, bool mInserted)
73                 : id(mId), filename(mFilename), inserted(mInserted), timestamp(mTimestamp) { }
74                bool operator<(const TrackPointData & other) const { return timestamp < other.timestamp; }
75                QString id;
76                QString filename;
77                bool inserted;
78                QDateTime timestamp;
79        };
80        QList<TrackPointData> usedTrackPoints;
81
82        MainWindow *Main;
83
84};
85
86class ImageView : public QWidget
87{
88public:
89        ImageView(QWidget *parent);
90        ~ImageView();
91
92        void setImage(QString filename);
93
94protected:
95        void paintEvent(QPaintEvent *e);
96        void mousePressEvent(QMouseEvent *e);
97        void mouseMoveEvent(QMouseEvent *e);
98        void wheelEvent(QWheelEvent *e);
99        void mouseDoubleClickEvent(QMouseEvent *e);
100        void resizeEvent(QResizeEvent *e);
101
102private:
103        QImage image;
104        QString name;
105        QPoint mousePos;
106        QRect rect;
107        QRectF area;
108
109        double zoomLevel; // zoom in percent
110
111        void zoom(double levelStep); // zoom levelStep steps
112
113};
Note: See TracBrowser for help on using the repository browser.