FFSM++ 1.1.0
French Forest Sector Model ++
Loading...
Searching...
No Matches
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
32using namespace std;
33
34/// Widget to display the maps of various spacial aspects of the model.
35
36/**
37This 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
41class MapBox : public QWidget {
42 Q_OBJECT
43
44public:
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
48public 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
57signals:
58 void queryRequestOnPx(int px_ID, int currentLayerIndex, bool newRequest);
59
60private:
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
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
Widget to display the maps of various spacial aspects of the model.
Definition MapBox.h:41
double dy2
coordinates of corner pixels of destination - widget - rectangle
Definition MapBox.h:74
QPoint lastDragPos
Definition MapBox.h:72
vector< QImage > layersVector
Vector of QImages.
Definition MapBox.h:68
vector< QString > layersNameVector
Vector of layer names.
Definition MapBox.h:69
void queryRequestOnPx(int px_ID, int currentLayerIndex, bool newRequest)
double sx1
Definition MapBox.h:73
double sy2
coordinates of corner pixels of source - pixmap - rectangle
Definition MapBox.h:73
double dx2
Definition MapBox.h:74
QImage currentLayer
Definition MapBox.h:70
double dy1
Definition MapBox.h:74
void scroll(int deltaX, int deltaY)
Definition MapBox.cpp:255
void addLayer(QString layerName_h)
Definition MapBox.cpp:135
double sy1
Definition MapBox.h:73
void updatePixmap(const QImage &image, bool reFit=false)
double sx2
Definition MapBox.h:73
int getLayerIndex(QString layerName_h="")
Return the index of the specified layer (null to ask for the current one)
Definition MapBox.cpp:123
void fitInWindow()
Definition MapBox.cpp:217
void zoom(double zoomFactor)
Definition MapBox.cpp:241
double dx1
Definition MapBox.h:74
void prepareQueryEvent(QPoint click)
Definition MapBox.cpp:192
void updateImage(QString layerName_h, const QImage &image_h)
Definition MapBox.cpp:87
void wheelEvent(QWheelEvent *event)
Definition MapBox.cpp:175
void paintEvent(QPaintEvent *event)
Reimplementation of the standard paintEvent method.
Definition MapBox.cpp:55
void mousePressEvent(QMouseEvent *event)
Definition MapBox.cpp:182
void switchToLayer(QString layerName_h)
Change the layer that currentLayer and currentLayerName points.
Definition MapBox.cpp:108
void updatePixel(QString layerName_h, int x_h, int y_h, QColor color_h)
Definition MapBox.cpp:73
void keyPressEvent(QKeyEvent *event)
Definition MapBox.cpp:149
void mouseMoveEvent(QMouseEvent *event)
Definition MapBox.cpp:209
QString currentLayerName
Definition MapBox.h:71