FFSM++  1.1.0
French Forest Sector Model ++
MapBox.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3  * http://ffsm-project.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version, given the compliance with the *
9  * exceptions listed in the file COPYING that is distribued together *
10  * with this file. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 #ifndef MAPBOX_H
23 #define MAPBOX_H
24 
25 #include <QColor> //TO.DO del
26 #include <QImage> //TO.DO del
27 
28 #include <QWidget>
29 #include <QPixmap>
30 
31 
32 using namespace std;
33 
34 /// Widget to display the maps of various spacial aspects of the model.
35 
36 /**
37 This class is based on QImage. It pick-ups from layersVector the choosed layer and display it.
38 <br>It has methods to change the individual pixels or the whole image of a layer.
39 */
40 
41 class MapBox : public QWidget {
42  Q_OBJECT
43 
44 public:
45  MapBox(QWidget *parent = 0);
46  int getLayerIndex(QString layerName_h=""); ///< Return the index of the specified layer (null to ask for the current one)
47 
48 public slots:
49  void updatePixel(QString layerName_h, int x_h, int y_h, QColor color_h);
50  void updateImage(QString layerName_h, const QImage& image_h);
51  void switchToLayer(QString layerName_h); ///< Change the layer that currentLayer and currentLayerName points
52  void addLayer(QString layerName_h);
53  void fitInWindow();
54  void zoom(double zoomFactor);
55  void scroll(int deltaX, int deltaY);
56 
57 signals:
58  void queryRequestOnPx(int px_ID, int currentLayerIndex, bool newRequest);
59 
60 private:
61  void updatePixmap(const QImage &image, bool reFit=false);
62  void paintEvent(QPaintEvent *event); ///< Reimplementation of the standard paintEvent method.
63  void prepareQueryEvent(QPoint click);
64  void keyPressEvent(QKeyEvent *event);
65  void wheelEvent(QWheelEvent *event);
66  void mousePressEvent(QMouseEvent *event);
67  void mouseMoveEvent(QMouseEvent *event);
68  vector <QImage> layersVector; ///< Vector of QImages
69  vector <QString> layersNameVector; ///< Vector of layer names
70  QImage currentLayer;
72  QPoint lastDragPos;
73  double sx1, sy1, sx2, sy2; ///< coordinates of corner pixels of source - pixmap - rectangle
74  double dx1, dy1, dx2, dy2; ///< coordinates of corner pixels of destination - widget - rectangle
75 
76 };
77 
78 #endif
QString currentLayerName
Definition: MapBox.h:71
STL namespace.
vector< QImage > layersVector
Vector of QImages.
Definition: MapBox.h:68
QImage currentLayer
Definition: MapBox.h:70
double dy2
coordinates of corner pixels of destination - widget - rectangle
Definition: MapBox.h:74
double sy2
coordinates of corner pixels of source - pixmap - rectangle
Definition: MapBox.h:73
Widget to display the maps of various spacial aspects of the model.
Definition: MapBox.h:41
vector< QString > layersNameVector
Vector of layer names.
Definition: MapBox.h:69
QPoint lastDragPos
Definition: MapBox.h:72