MapBox.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006-2008 by Antonello Lobianco                         *
00003  *   http://regmas.org                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 3 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef MAPBOX_H
00021 #define MAPBOX_H
00022 
00023 #include <QColor> //TODO del
00024 #include <QImage> //TODO del
00025 
00026 #include <QWidget>
00027 #include <QPixmap>
00028 
00029 
00030 using namespace std;
00031 
00033 
00039 class MapBox : public QWidget {
00040     Q_OBJECT
00041 
00042 public:
00043                         MapBox(QWidget *parent = 0);
00044     int                 getLayerIndex(QString layerName_h=""); 
00045 
00046 public slots:
00047     void                updatePixel(QString layerName_h, int x_h, int y_h, QColor color_h);
00048     void                updateImage(QString layerName_h, const QImage& image_h);
00049     void                switchToLayer(QString layerName_h); 
00050     void                addLayer(QString layerName_h);
00051     void                fitInWindow();
00052     void                zoom(double zoomFactor);
00053     void                scroll(int deltaX, int deltaY);
00054 
00055 signals:
00056     void                queryRequestOnPx(int px_ID, int currentLayerIndex, bool newRequest);
00057 
00058 private:
00059     void                updatePixmap(const QImage &image, bool reFit=false);
00060     void                paintEvent(QPaintEvent *event); 
00061     void                prepareQueryEvent(QPoint click);
00062     void                keyPressEvent(QKeyEvent *event);
00063     void                wheelEvent(QWheelEvent *event);
00064     void                mousePressEvent(QMouseEvent *event);
00065     void                mouseMoveEvent(QMouseEvent *event);
00066     vector <QImage>                 layersVector; 
00067     vector <QString>            layersNameVector; 
00068     QImage                          currentLayer;
00069     QString                     currentLayerName;
00070     QPoint lastDragPos;
00071     double sx1, sy1, sx2, sy2; 
00072     double dx1, dy1, dx2, dy2; 
00073 
00074 };
00075 
00076 #endif