~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/plugins/evis/eventbrowser/evisimagedisplaywidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
** File: evisimagedisplaywidget.h
 
3
** Author: Peter J. Ersts ( ersts at amnh.org )
 
4
** Creation Date: 2007-03-13
 
5
**
 
6
** Copyright ( c ) 2007, American Museum of Natural History. All rights reserved.
 
7
**
 
8
** This library/program is free software; you can redistribute it
 
9
** and/or modify it under the terms of the GNU Library General Public
 
10
** License as published by the Free Software Foundation; either
 
11
** version 2 of the License, or ( at your option ) any later version.
 
12
**
 
13
** This library/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 GNU
 
16
** Library General Public License for more details.
 
17
**
 
18
** This work was made possible through a grant by the the John D. and
 
19
** Catherine T. MacArthur Foundation. Additionally, this program was prepared by
 
20
** the American Museum of Natural History under award No. NA05SEC46391002
 
21
** from the National Oceanic and Atmospheric Administration, U.S. Department
 
22
** of Commerce.  The statements, findings, conclusions, and recommendations
 
23
** are those of the author( s ) and do not necessarily reflect the views of the
 
24
** National Oceanic and Atmospheric Administration or the Department of Commerce.
 
25
**
 
26
**/
 
27
/*  $Id: $ */
 
28
#ifndef EVISIMAGEDISPLAYWIDGET_H
 
29
#define EVISIMAGEDISPLAYWIDGET_H
 
30
 
 
31
#include <QLabel>
 
32
#include <QWidget>
 
33
#include <QScrollArea>
 
34
#include <QPushButton>
 
35
#include <QBuffer>
 
36
#include <QHttp>
 
37
#include <QResizeEvent>
 
38
 
 
39
/**
 
40
* \class eVisGenericEventBrowserGui
 
41
* \brief Generic viewer for browsing event
 
42
* The eVisImageDisplayWidget is a component of the eVisGenericEventBrowser. This widget provides
 
43
* the ability to display an image on the widget and basic zoom capabilities. This class was created
 
44
* so the same display features could be easily added to other widgets as needed.
 
45
*/
 
46
class eVisImageDisplayWidget : public QWidget
 
47
{
 
48
 
 
49
    Q_OBJECT
 
50
 
 
51
  public:
 
52
    /** \brief Constructor */
 
53
    eVisImageDisplayWidget( QWidget* parent = 0, Qt::WFlags fl = 0 );
 
54
 
 
55
    /** \brief Destructor */
 
56
    ~eVisImageDisplayWidget();
 
57
 
 
58
    /** \brief Load an image from disk and display */
 
59
    void displayImage( QString );
 
60
 
 
61
    /** \brief Load an image from a remote location using http and display */
 
62
    void displayUrlImage( QString );
 
63
 
 
64
    /*
 
65
     * There needs to be more logic around setting the zoom steps as you could change it mid display
 
66
     * and end up getting not being able to zoom in or out
 
67
     */
 
68
    /** \brief Accessor for ZOOM_STEPS */
 
69
    int getZoomSteps( ) { return ZOOM_STEPS; }
 
70
 
 
71
    /** \brief Mutator for ZOON_STEPS */
 
72
    void setZoomSteps( int steps ) { ZOOM_STEPS = steps; }
 
73
 
 
74
  protected:
 
75
    void resizeEvent( QResizeEvent *event );
 
76
 
 
77
  private:
 
78
 
 
79
    /** \brief Used to hold the http request to match the correct emits with the correct result */
 
80
    int mCurrentHttpImageRequestId;
 
81
 
 
82
    /** \brief CUrrent Zoom level */
 
83
    int mCurrentZoomStep;
 
84
 
 
85
    /** \brief widget to display the image in */
 
86
    QScrollArea* mDisplayArea;
 
87
 
 
88
    /** \brief Method that acually display the image in the widget */
 
89
    void displayImage( );
 
90
 
 
91
    /** \brief Pointer to the http buffer */
 
92
    QBuffer* mHttpBuffer;
 
93
 
 
94
    /** \brief Pointer to the http connection if needed */
 
95
    QHttp* mHttpConnection;
 
96
 
 
97
    /** \brief This is a point to the actual image being displayed */
 
98
    QPixmap* mImage;
 
99
 
 
100
    /** \brief Label to hold the image */
 
101
    QLabel* mImageLabel;
 
102
 
 
103
    /** \brief Flag to indicate the success of the last load request */
 
104
    bool mImageLoaded;
 
105
 
 
106
    /** \brief Ratio if height to width or width to height for the original image, which ever is smaller */
 
107
    double mImageSizeRatio;
 
108
 
 
109
    /** \brief Boolean to indicate which feature the mImageSizeRation corresponds to */
 
110
    bool mScaleByHeight;
 
111
 
 
112
    /** \brief Boolean to indicate which feature the mImageSizeRation corresponds to */
 
113
    bool mScaleByWidth;
 
114
 
 
115
    /** \brief The increment by which the image is scaled during each scaling event */
 
116
    double mScaleFactor;
 
117
 
 
118
    /** \brief The single factor by which the original image needs to be scaled to fit into current display area */
 
119
    double mScaleToFit;
 
120
 
 
121
    /** \brief Zoom in button */
 
122
    QPushButton* pbtnZoomIn;
 
123
 
 
124
    /** \brief Zoom out button */
 
125
    QPushButton* pbtnZoomOut;
 
126
 
 
127
    /** \brief Zoom to full extent button */
 
128
    QPushButton* pbtnZoomFull;
 
129
 
 
130
    /** \brief Method called to compute the various scaling parameters */
 
131
    void setScalers( );
 
132
 
 
133
    /** \brief The number of steps between the scale to fit image and full resolution */
 
134
    int ZOOM_STEPS;
 
135
 
 
136
  private slots:
 
137
    void on_pbtnZoomIn_clicked( );
 
138
 
 
139
    void on_pbtnZoomOut_clicked( );
 
140
 
 
141
    void on_pbtnZoomFull_clicked( );
 
142
 
 
143
    /** \brief Slot called when the http request is completed */
 
144
    void displayUrlImage( int, bool );
 
145
};
 
146
#endif