Subversion Repositories Projects

Rev

Rev 395 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
395 KeyOz 1
/*
2
*
3
* This file is part of QMapControl,
4
* an open-source cross-platform map widget
5
*
6
* Copyright (C) 2007 - 2009 Kai Winter
7
*
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
* GNU Lesser General Public License for more details.
17
*
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with QMapControl. If not, see <http://www.gnu.org/licenses/>.
20
*
21
* Contact e-mail: kaiwinter@gmx.de
22
* Program URL   : http://qmapcontrol.sourceforge.net/
23
*
24
*/
25
 
26
#include "fixedimageoverlay.h"
27
namespace qmapcontrol
28
{
29
    FixedImageOverlay::FixedImageOverlay(qreal x_upperleft, qreal y_upperleft, qreal x_lowerright, qreal y_lowerright, QString filename, QString name)
30
        : ImagePoint(x_upperleft, y_upperleft, filename, name, TopLeft),
31
                     x_lowerright(x_lowerright), y_lowerright(y_lowerright)
32
    {
33
        //qDebug() << "loading image: " << filename;
34
        mypixmap = new QPixmap(filename);
35
        size = mypixmap->size();
36
        //qDebug() << "image size: " << size;
37
    }
38
 
39
    FixedImageOverlay::FixedImageOverlay(qreal x_upperleft, qreal y_upperleft, qreal x_lowerright, qreal y_lowerright, QPixmap* pixmap, QString name)
40
        : ImagePoint(x_upperleft, y_upperleft, pixmap, name, TopLeft),
41
                     x_lowerright(x_lowerright), y_lowerright(y_lowerright)
42
    {
43
        mypixmap = pixmap;
44
        size = mypixmap->size();
45
    }
46
 
47
    void FixedImageOverlay::draw(QPainter* painter, const MapAdapter* mapadapter, const QRect &viewport, const QPoint offset)
48
    {
49
        if (!visible)
50
            return;
51
 
52
        if (mypixmap !=0)
53
        {
54
            const QPointF c = QPointF(X, Y);
55
            QPoint topleft = mapadapter->coordinateToDisplay(c);
56
 
57
            const QPointF c2 = QPointF(x_lowerright, y_lowerright);
58
            QPoint lowerright = mapadapter->coordinateToDisplay(c2);
59
 
60
            painter->drawPixmap(topleft.x(), topleft.y(), lowerright.x()-topleft.x(), lowerright.y()-topleft.y(), *mypixmap);
61
        }
62
 
63
 
64
    }
65
 
66
    FixedImageOverlay::~FixedImageOverlay()
67
    {
68
    }
69
}