1 /***************************************************************************
2                           imagemap.h  -  description
3                              -------------------
4     begin                : Wed Apr 4 2001
5     copyright            : (C) 2001 by Jan Schäfer
6     email                : janschaefer@users.sourceforge.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef IMAGEMAP_H
19 #define IMAGEMAP_H
20 
21 #include <QImage>
22 #include <QMouseEvent>
23 #include <QPixmap>
24 #include <QPoint>
25 #include <QRect>
26 #include <QResizeEvent>
27 #include <QScrollArea>
28 
29 /**
30   *@author Jan Schäfer
31   */
32 class KImageMapEditor;
33 class Area;
34 
35 class ImageMap : public QScrollArea  {
36 public:
37 	enum DrawAction { None, DrawCircle, DrawRectangle, DrawPolygon, MoveSelectionPoint, MoveArea };
38 private:
39 	QRect imageRect;
40 	QPoint drawStart;
41 	QPoint drawCurrent;
42 	QPoint drawEnd;
43 	bool eraseOldArea;
44 	Area *oldArea;
45 	// Holds the original image
46 	QImage image;
47 	// Holds the zoomed image for efficiency reasons
48 	QPixmap zoomedImage;
49 	Area *currentArea;
50 	DrawAction currentAction;
51 	QRect *currentSelectionPoint;
52 	KImageMapEditor *imageMapEditor;
53 	double _zoom;
54 public:
55 	ImageMap(QWidget *parent,KImageMapEditor* _imageMapEditor);
56 	~ImageMap();
57 	void setZoom(double z);
58 	void setPicture(const QImage &_image);
59 	void repaintArea(const Area & a);
60 	QImage picture() const;
61 	QPoint translateFromZoom(const QPoint & p) const;
62 	QPoint translateToZoom(const QPoint & p) const;
63 	QRect translateToZoom(const QRect & p) const;
64 protected:
65 	virtual void mousePressEvent(QMouseEvent* e);
66 	virtual void mouseDoubleClickEvent(QMouseEvent* e);
67 	virtual void mouseReleaseEvent(QMouseEvent *e);
68 	virtual void mouseMoveEvent(QMouseEvent *e);
69 	virtual void resizeEvent(QResizeEvent* e);
70 	virtual void drawContents(QPainter* p,int clipx,int clipy,int clipw,int cliph);
71 };
72 
picture()73 inline QImage ImageMap::picture() const {
74 	return image;
75 }
76 
77 
78 #endif
79