sldpatch_18_08_09.patch

Patch with python bindings updated - Redmine Admin, 2009-08-17 06:43 PM

Download (75.5 KB)

View differences:

python/core/qgsrasterdataprovider.sip (working copy)
1

  
2
/** Base class for raster data providers
3
 *
4
 *  \note  This class has been copied and pasted from
5
 *         QgsVectorDataProvider, and does not yet make
6
 *         sense for Raster layers.
7
 */
8
 
9
class QgsRasterDataProvider : QgsDataProvider
10
{
11
%TypeHeaderCode
12
#include <qgsrasterdataprovider.h>
13
%End
14

  
15
public:
16

  
17
    //! If you add to this, please also add to capabilitiesString()
18
    enum Capability
19
    {
20
      NoCapabilities =              0,
21
      Identify =                    1
22
//      Capability2 =           1 <<  1, etc
23
    };
24

  
25

  
26
    QgsRasterDataProvider();
27

  
28
    QgsRasterDataProvider( const QString & uri );
29

  
30
    virtual ~QgsRasterDataProvider();
31

  
32
    /**
33
     * Add the list of WMS layer names to be rendered by this server
34
     */
35
    virtual void addLayers(const QStringList & layers,
36
                           const QStringList & styles = QStringList()) = 0;
37

  
38
    //! get raster image encodings supported by (e.g.) the WMS Server, expressed as MIME types
39
    virtual QStringList supportedImageEncodings() = 0;
40

  
41
    /**
42
     * Get the image encoding (as a MIME type) used in the transfer from (e.g.) the WMS server
43
     */
44
    virtual QString imageEncoding() const = 0;
45

  
46
    /**
47
     * Set the image encoding (as a MIME type) used in the transfer from (e.g.) the WMS server
48
     */
49
    virtual void setImageEncoding(const QString & mimeType) = 0;
50
 
51
    /**
52
     * Set the image projection (in WMS CRS format) used in the transfer from (e.g.) the WMS server
53
     */
54
    virtual void setImageCrs(const QString & crs) = 0;
55

  
56

  
57
    // TODO: Document this better.
58
    /** \brief   Renders the layer as an image
59
     */
60
    virtual QImage* draw(const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight) = 0;
61

  
62
    /** Returns a bitmask containing the supported capabilities
63
        Note, some capabilities may change depending on whether
64
        a spatial filter is active on this provider, so it may
65
        be prudent to check this value per intended operation.
66
      */
67
    virtual int capabilities() const;
68

  
69
    /**
70
     *  Returns the above in friendly format.
71
     */
72
    QString capabilitiesString() const;
73

  
74

  
75
    // TODO: Get the supported formats by this provider
76
    
77
    // TODO: Get the file masks supported by this provider, suitable for feeding into the file open dialog box
78
    
79

  
80
    /**
81
     * Get metadata in a format suitable for feeding directly
82
     * into a subset of the GUI raster properties "Metadata" tab.
83
     */
84
    virtual QString metadata() = 0;
85

  
86
    /**
87
     * \brief Identify details from a server (e.g. WMS) from the last screen update
88
     *
89
     * \param point[in]  The pixel coordinate (as it was displayed locally on screen)
90
     *
91
     * \return  A text document containing the return from the WMS server
92
     *
93
     * \note WMS Servers prefer to receive coordinates in image space, therefore
94
     *       this function expects coordinates in that format.
95
     *
96
     * \note  The arbitraryness of the returned document is enforced by WMS standards
97
     *        up to at least v1.3.0
98
     */
99
    virtual QString identifyAsText(const QgsPoint& point) = 0;
100

  
101
    /**
102
     * \brief   Returns the caption error text for the last error in this provider
103
     *
104
     * If an operation returns 0 (e.g. draw()), this function
105
     * returns the text of the error associated with the failure.
106
     * Interactive users of this provider can then, for example,
107
     * call a QMessageBox to display the contents.
108
     *
109
     */
110
    virtual QString lastErrorTitle() = 0;
111

  
112
    /**
113
     * \brief   Returns the verbose error text for the last error in this provider
114
     *
115
     * If an operation returns 0 (e.g. draw()), this function
116
     * returns the text of the error associated with the failure.
117
     * Interactive users of this provider can then, for example,
118
     * call a QMessageBox to display the contents.
119
     *
120
     */
121
    virtual QString lastError() = 0;
122

  
123
      /**Returns the dpi of the output device.
124
      @note: this method was added in version 1.2*/
125
    int dpi();
126

  
127
    /**Sets the output device resolution.
128
      @note: this method was added in version 1.2*/
129
    void setDpi(int dpi);
130

  
131

  
132
protected:
133

  
134
};
135

  
1

  
2
/** Base class for raster data providers
3
 *
4
 *  \note  This class has been copied and pasted from
5
 *         QgsVectorDataProvider, and does not yet make
6
 *         sense for Raster layers.
7
 */
8
 
9
class QgsRasterDataProvider : QgsDataProvider
10
{
11
%TypeHeaderCode
12
#include <qgsrasterdataprovider.h>
13
%End
14

  
15
public:
16

  
17
    //! If you add to this, please also add to capabilitiesString()
18
    enum Capability
19
    {
20
      NoCapabilities =              0,
21
      Identify =                    1
22
//      Capability2 =           1 <<  1, etc
23
    };
24

  
25

  
26
    QgsRasterDataProvider();
27

  
28
    QgsRasterDataProvider( const QString & uri );
29

  
30
    virtual ~QgsRasterDataProvider();
31

  
32
    /**
33
     * Add the list of WMS layer names to be rendered by this server
34
     */
35
    virtual void addLayers(const QStringList & layers,
36
                           const QStringList & styles = QStringList()) = 0;
37

  
38
    //! get raster image encodings supported by (e.g.) the WMS Server, expressed as MIME types
39
    virtual QStringList supportedImageEncodings() = 0;
40

  
41
    /**
42
     * Get the image encoding (as a MIME type) used in the transfer from (e.g.) the WMS server
43
     */
44
    virtual QString imageEncoding() const = 0;
45

  
46
    /**
47
     * Set the image encoding (as a MIME type) used in the transfer from (e.g.) the WMS server
48
     */
49
    virtual void setImageEncoding(const QString & mimeType) = 0;
50
 
51
    /**
52
     * Set the image projection (in WMS CRS format) used in the transfer from (e.g.) the WMS server
53
     */
54
    virtual void setImageCrs(const QString & crs) = 0;
55

  
56
    
57
    /**
58
     * Set the url of sld document
59
     * Added in qgis version 1.2
60
     */
61
    virtual void setSLDURL( const QString & sldURL ) = 0;
62
    /**
63
     * Retrieves the url of sld document
64
     * Added in qgis version 1.2
65
     */
66
    virtual QString sldURL()=0;
67
    /**
68
     * Set the sld document body
69
     * Added in qgis version 1.2
70
     */
71
    virtual void setSLDBody( const QString & sldBody ) = 0;
72

  
73
    /**
74
     * Retrieves the sld document body
75
     * Added in qgis version 1.2
76
     */
77
    virtual QString sldBody() = 0;
78

  
79
    // TODO: Document this better.
80
    /** \brief   Renders the layer as an image
81
     */
82

  
83
    // TODO: Document this better.
84
    /** \brief   Renders the layer as an image
85
     */
86
    virtual QImage* draw(const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight) = 0;
87

  
88
    /** Returns a bitmask containing the supported capabilities
89
        Note, some capabilities may change depending on whether
90
        a spatial filter is active on this provider, so it may
91
        be prudent to check this value per intended operation.
92
      */
93
    virtual int capabilities() const;
94

  
95
    /**
96
     *  Returns the above in friendly format.
97
     */
98
    QString capabilitiesString() const;
99

  
100

  
101
    // TODO: Get the supported formats by this provider
102
    
103
    // TODO: Get the file masks supported by this provider, suitable for feeding into the file open dialog box
104
    
105

  
106
    /**
107
     * Get metadata in a format suitable for feeding directly
108
     * into a subset of the GUI raster properties "Metadata" tab.
109
     */
110
    virtual QString metadata() = 0;
111

  
112
    /**
113
     * \brief Identify details from a server (e.g. WMS) from the last screen update
114
     *
115
     * \param point[in]  The pixel coordinate (as it was displayed locally on screen)
116
     *
117
     * \return  A text document containing the return from the WMS server
118
     *
119
     * \note WMS Servers prefer to receive coordinates in image space, therefore
120
     *       this function expects coordinates in that format.
121
     *
122
     * \note  The arbitraryness of the returned document is enforced by WMS standards
123
     *        up to at least v1.3.0
124
     */
125
    virtual QString identifyAsText(const QgsPoint& point) = 0;
126

  
127
    /**
128
     * \brief   Returns the caption error text for the last error in this provider
129
     *
130
     * If an operation returns 0 (e.g. draw()), this function
131
     * returns the text of the error associated with the failure.
132
     * Interactive users of this provider can then, for example,
133
     * call a QMessageBox to display the contents.
134
     *
135
     */
136
    virtual QString lastErrorTitle() = 0;
137

  
138
    /**
139
     * \brief   Returns the verbose error text for the last error in this provider
140
     *
141
     * If an operation returns 0 (e.g. draw()), this function
142
     * returns the text of the error associated with the failure.
143
     * Interactive users of this provider can then, for example,
144
     * call a QMessageBox to display the contents.
145
     *
146
     */
147
    virtual QString lastError() = 0;
148

  
149
      /**Returns the dpi of the output device.
150
      @note: this method was added in version 1.2*/
151
    int dpi();
152

  
153
    /**Sets the output device resolution.
154
      @note: this method was added in version 1.2*/
155
    void setDpi(int dpi);
156

  
157

  
158
protected:
159

  
160
};
161

  
python/core/qgsrasterlayer.sip (working copy)
1
/*! \class QgsRasterLayer
2
 *  \brief This class provides qgis with the ability to render raster datasets
3
 *  onto the mapcanvas..
4
 */
5

  
6
class QgsRasterLayer : QgsMapLayer
7
{
8
%TypeHeaderCode
9
#include <qgsrasterpyramid.h>
10
#include <qgsrasterlayer.h>
11
#include <qgscontrastenhancement.h>
12
#include <qgsrastertransparency.h>
13
#include <qgsrastershader.h>
14
%End
15

  
16
public:
17
    /** \brief This is the constructor for the RasterLayer class.
18
     *
19
     * The main tasks carried out by the constructor are:
20
     *
21
     * -Load the rasters default style (.qml) file if it exists
22
     *
23
     * -Populate the RasterStatsVector with initial values for each band.
24
     *
25
     * -Calculate the layer extents
26
     *
27
     * -Determine whether the layer is gray, paletted or multiband.
28
     *
29
     * -Assign sensible defaults for the red, green, blue and gray bands.
30
     *
31
     * -
32
     * */
33
    QgsRasterLayer( const QString & path = QString::null,
34
                    const QString &  baseName = QString::null,
35
                    bool loadDefaultStyleFlag = true );
36

  
37
    /**  \brief [ data provider interface ] Constructor in provider mode */
38
    QgsRasterLayer( int dummy,
39
                    const QString & baseName = QString(),
40
                    const QString & path = QString(),
41
                    const QString & providerLib = QString(),
42
                    const QStringList & layers = QStringList(),
43
                    const QStringList & styles = QStringList(),
44
                    const QString & format = QString(),
45
                    const QString & crs = QString());
46

  
47

  
48
    /** \brief The destructor */
49
    ~QgsRasterLayer();
50

  
51

  
52
    //
53
    // Enums, structs and typedefs
54
    //
55
    /** \brief This enumerator describes the types of shading that can be used */
56
    enum ColorShadingAlgorithm
57
    {
58
      UndefinedShader,
59
      PseudoColorShader,
60
      FreakOutShader,
61
      ColorRampShader,
62
      UserDefinedShader
63
    };
64

  
65
    /** \brief This enumerator describes the different kinds of drawing we can do */
66
    enum DrawingStyle
67
    {
68
      UndefinedDrawingStyle,
69
      SingleBandGray,                 // a single band image drawn as a range of gray colors
70
      SingleBandPseudoColor,          // a single band image drawn using a pseudocolor algorithm
71
      PalettedColor,                  //a "Palette" image drawn using color table
72
      PalettedSingleBandGray,        // a "Palette" layer drawn in gray scale
73
      PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
74
      PalettedMultiBandColor,         // currently not supported
75
      MultiBandSingleGandGray,        // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
76
      MultiBandSingleBandPseudoColor, //a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
77
      MultiBandColor                  //a layer containing 2 or more bands, mapped to RGB color space.
78
                                      //In the case of a multiband with only two bands, one band will be mapped to more than one color.
79
    };
80

  
81
    /** \brief This enumerator describes the type of raster layer */
82
    enum LayerType
83
    {
84
      GrayOrUndefined,
85
      Palette,
86
      Multiband
87
    } ;
88

  
89
    /** \brief A list containing on ContrastEnhancement object per raster band in this raster layer */
90
    typedef QList<QgsContrastEnhancement> ContrastEnhancementList;
91

  
92
    /** \brief  A list containing one RasterPyramid struct per raster band in this raster layer.
93
     * POTENTIAL pyramid layer. This works by dividing the height
94
     * and width of the raster by an incrementing number. As soon as the result
95
     * of the division is <=256 we stop allowing RasterPyramid structs
96
     * to be added to the list. Each time a RasterPyramid is created
97
     * we will check to see if a pyramid matching these dimensions already exists
98
     * in the raster layer, and if so mark the exists flag as true */
99
    typedef QList<QgsRasterPyramid> RasterPyramidList;
100

  
101
    /** \brief  A list containing one RasterBandStats struct per raster band in this raster layer.
102
     * Note that while every RasterBandStats element will have the name and number of its associated
103
     * band populated, any additional stats are calculated on a need to know basis.*/
104
    typedef QList<QgsRasterBandStats> RasterStatsList;
105

  
106

  
107

  
108

  
109

  
110
    //
111
    // Static methods:
112
    //
113
    static void buildSupportedRasterFileFilter( QString & fileFilters );
114

  
115
    /** This helper checks to see whether the file name appears to be a valid
116
     *  raster file name.  If the file name looks like it could be valid,
117
     *  but some sort of error occurs in processing the file, the error is
118
     *  returned in retError.
119
     */
120
    static bool isValidRasterFileName( const QString & theFileNameQString, QString &retError );
121

  
122
    static bool isValidRasterFileName( const QString & theFileNameQString );
123

  
124
    /** Return time stamp for given file name */
125
    static QDateTime lastModified( const QString &  name );
126

  
127
    /** \brief ensures that GDAL drivers are registered, but only once */
128
    static void registerGdalDrivers();
129

  
130

  
131

  
132

  
133
    //
134
    // Non Static inline methods
135
    //
136

  
137
    /** \brief  Accessor for blue band name mapping */
138
    QString blueBandName() const;
139

  
140
    /** \brief Accessor for color shader algorithm */
141
    QgsRasterLayer::ColorShadingAlgorithm colorShadingAlgorithm() const;
142

  
143
    /** \brief Accessor for contrast enhancement algorithm */
144
    QgsContrastEnhancement::ContrastEnhancementAlgorithm contrastEnhancementAlgorithm();
145

  
146
    /** \brief Returns contrast enhancement algorithm as a string */
147
    QString contrastEnhancementAlgorithmAsString() const;
148

  
149
    /** \brief Accessor for drawing style */
150
    DrawingStyle drawingStyle();
151

  
152
    /** \brief Accessor for gray band name mapping */
153
    QString grayBandName() const;
154

  
155
    /** \brief Accessor for green band name mapping */
156
    QString greenBandName() const;
157

  
158
    /** \brief Accessor for mHasPyramids (READ ONLY) */
159
    bool hasPyramids();
160

  
161
    /** \brief Accessor for mUserDefinedGrayMinimumMaximum */
162
    bool hasUserDefinedGrayMinimumMaximum() const;
163

  
164
    /** \brief Accessor for mUserDefinedRGBMinimumMaximum */
165
    bool hasUserDefinedRGBMinimumMaximum() const;
166

  
167
    /** \brief Accessor that returns the height of the (unclipped) raster */
168
    int height();
169

  
170
    /** \brief Accessor to find out whether the histogram should be inverted  */
171
    bool invertHistogram() const;
172

  
173
    /** \brief Is the NoDataValue Valid */
174
    bool isNoDataValueValid() const;
175

  
176
    /** \brief Accessor for mGrayMinimumMaximumEstimated */
177
    bool isGrayMinimumMaximumEstimated() const;
178

  
179
    /** \brief Accessor for mRGBMinimumMaximumEstimated */
180
    bool isRGBMinimumMaximumEstimated() const;
181

  
182
    /** \brief Accessor that returns the NO_DATA entry for this raster */
183
    double noDataValue( bool* isValid = 0 );
184

  
185
    /** \brief Returns a pointer to the transparency object */
186
    QgsRasterTransparency* rasterTransparency();
187

  
188
    /** \brief Accessor for raster shader */
189
    QgsRasterShader* rasterShader();
190

  
191
    /** \brief  Accessor for raster layer type (which is a read only property) */
192
    LayerType rasterType();
193

  
194
    /** \brief Accessor for red band name (allows alternate mappings e.g. map blue as red color) */
195
    QString redBandName();
196

  
197
    /**  [ data provider interface ] Set the data provider */
198
    void setDataProvider( const QString & provider,
199
                          const QStringList & layers,
200
                          const QStringList & styles,
201
                          const QString & format,
202
                          const QString & crs );
203

  
204
    /** \brief Mutator for drawing style */
205
    void setDrawingStyle( const DrawingStyle &  theDrawingStyle );
206

  
207
    /** \brief Mutator for mGrayMinimumMaximumEstimated */
208
    void setGrayMinimumMaximumEstimated( bool theBool );
209

  
210
    /** \brief Mutator to alter the state of the invert histogram flag  */
211
    void setInvertHistogram( bool theFlag );
212

  
213
    /** \brief Mutator for mRGBMinimumMaximumEstimated */
214
    void setRGBMinimumMaximumEstimated( bool theBool );
215

  
216
    /** \brief Mutator to alter the number of standard deviations that should be plotted */
217
    void setStandardDeviations( double theStdDevsToPlot );
218

  
219
    /** \brief Mutator for mUserDefinedGrayMinimumMaximum */
220
    void setUserDefinedGrayMinimumMaximum( bool theBool );
221

  
222
    /** \brief Mutator for mUserDefinedRGBMinimumMaximum */
223
    void setUserDefinedRGBMinimumMaximum( bool theBool );
224

  
225
    /** \brief Accessor to find out how many standard deviations are being plotted */
226
    double standardDeviations() const;
227

  
228
    /** \brief  Accessor for transparent band name mapping */
229
    QString transparentBandName() const;
230

  
231
    /**  \brief [ data provider interface ] Does this layer use a provider for setting/retrieving data? */
232
    bool usesProvider();
233

  
234
    /** \brief Accessor that returns the width of the (unclipped) raster  */
235
    int width();
236

  
237

  
238

  
239

  
240

  
241
    //
242
    // Non Static methods
243
    //
244
    /** \brief Get the number of bands in this layer  */
245
    unsigned int bandCount();
246

  
247
    /** \brief Get the name of a band given its number  */
248
    const  QString bandName( int theBandNoInt );
249

  
250
    /** \brief Get the number of a band given its name. The name is the rewritten name set
251
    *   up in the constructor, and will not necessarily be the same as the name retrieved directly from gdal!
252
    *   If no matching band is found zero will be returned! */
253
    int bandNumber( const QString & theBandName );
254

  
255
    /** \brief Get RasterBandStats for a band given its number (read only)  */
256
    const  QgsRasterBandStats bandStatistics( int );
257

  
258
    /** \brief Get RasterBandStats for a band given its name (read only)  */
259
    const  QgsRasterBandStats bandStatistics( const QString & );
260

  
261
    /** \brief Accessor for ths raster layers pyramid list. A pyramid list defines the
262
     * POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers
263
     * ACTUALLY exists you need to look at the existsFlag member in each struct stored in the
264
     * list.
265
     */
266
    RasterPyramidList buildPyramidList();
267

  
268
    /** \brief Accessor for color shader algorithm */
269
    QString colorShadingAlgorithmAsString() const;
270

  
271
    /** \brief Wrapper for GDALComputeRasterMinMax with the estimate option */
272
    void computeMinimumMaximumEstimates( int theBand, double* theMinMax );
273

  
274
    /** \brief Wrapper for GDALComputeRasterMinMax with the estimate option */
275
    void computeMinimumMaximumEstimates( QString theBand, double* theMinMax );
276

  
277
    /** \brief Get a pointer to the contrast enhancement for the selected band */
278
    QgsContrastEnhancement* contrastEnhancement( unsigned int theBand );
279

  
280
    /**Copies the symbology settings from another layer. Returns true in case of success*/
281
    bool copySymbologySettings( const QgsMapLayer& theOther );
282

  
283
    /** \brief Get a pointer to the color table */
284
//QList<QgsColorRampShader::ColorRampItem>* colorTable( int theBandNoInt );
285

  
286
    /** Returns the data provider */
287
    QgsRasterDataProvider* dataProvider();
288

  
289
    /** Returns the data provider in a const-correct manner */
290
    //const QgsRasterDataProvider* dataProvider() const;
291

  
292
    /** \brief This is called when the view on the raster layer needs to be redrawn */
293
    bool draw( QgsRenderContext& rendererContext );
294

  
295
    /** \brief This is an overloaded version of the draw() function that is called by both draw() and thumbnailAsPixmap */
296
    void draw( QPainter * theQPainter,
297
               QgsRasterViewPort * myRasterViewPort,
298
               const QgsMapToPixel* theQgsMapToPixel = 0 );
299

  
300
    /** \brief Returns a string representation of drawing style
301
     *
302
     * Implementaed mainly for serialisation / deserialisation of settings to xml.
303
     * NOTE: May be deprecated in the future!. DrawingStyle drawingStyle() instead.
304
     * */
305
    QString drawingStyleAsString() const;
306

  
307
    /** \brief Checks if symbology is the same as another layers */
308
    bool hasCompatibleSymbology( const QgsMapLayer& theOther ) const;
309

  
310
    /** \brief  Check whether a given band number has stats associated with it */
311
    bool hasStatistics( int theBandNoInt );
312

  
313
    /** \brief Identify raster value(s) found on the point position */
314
    bool identify( const QgsPoint & point, QMap<QString, QString>& results /Out/ );
315

  
316
    /** \brief Identify arbitrary details from the WMS server found on the point position */
317
    QString identifyAsText( const QgsPoint & point );
318

  
319
    /** \brief Currently returns always false */
320
    bool isEditable() const;
321

  
322
    /** \brief [ data provider interface ] If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure  */
323
    QString lastError();
324

  
325
    /** \brief [ data provider interface ] If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure */
326
    QString lastErrorTitle();
327

  
328
    /** \brief Get a legend image for this layer */
329
    QPixmap legendAsPixmap();
330

  
331
    /** \brief  Overloaded version of above function that can print layer name onto legend */
332
//QPixmap legendAsPixmap( bool );
333

  
334
    /** \brief Use this method when you want an annotated legend suitable for print output etc */
335
//QPixmap legendAsPixmap( int theLabelCount );
336

  
337
    /** \brief Accessor for maximum value user for contrast enhancement */
338
    double maximumValue( unsigned int theBand );
339

  
340
    /** \brief Accessor for maximum value user for contrast enhancement */
341
    double maximumValue( QString theBand );
342

  
343
    /** \brief Obtain GDAL Metadata for this layer */
344
    QString metadata();
345

  
346
    /** \brief Accessor for minimum value user for contrast enhancement */
347
    double minimumValue( unsigned int theBand );
348

  
349
    /** \brief Accessor for minimum value user for contrast enhancement */
350
    double minimumValue( QString theBand );
351

  
352
    /** \brief Get an 100x100 pixmap of the color palette. If the layer has no palette a white pixmap will be returned */
353
    QPixmap paletteAsPixmap( int theBand = 1 );
354

  
355
    /**  \brief [ data provider interface ] Which provider is being used for this Raster Layer? */
356
    QString providerKey();
357

  
358
    /** \brief Returns the number of raster units per each raster pixel. In a world file, this is normally the first row (without the sign) */
359
    double rasterUnitsPerPixel();
360

  
361
    /** \brief Read color table from GDAL raster band */
362
//bool readColorTable( int theBandNumber, QList<QgsColorRampShader::ColorRampItem>* theList );
363

  
364
    /** \brief Simple reset function that set the noDataValue back to the value stored in the first raster band */
365
    void resetNoDataValue();
366

  
367
    /** \brief Mutator for blue band name mapping */
368
    void setBlueBandName( const QString & theBandName );
369

  
370
    /** \brief Mutator for color shader algorithm */
371
    void setColorShadingAlgorithm( QgsRasterLayer::ColorShadingAlgorithm theShaderAlgorithm );
372

  
373
    /** \brief Mutator for color shader algorithm */
374
    void setColorShadingAlgorithm( QString theShaderAlgorithm );
375

  
376
    /** \brief Mutator for contrast enhancement algorithm */
377
    void setContrastEnhancementAlgorithm( QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm,
378
                                          bool theGenerateLookupTableFlag = true );
379

  
380
    /** \brief Mutator for contrast enhancement algorithm */
381
    void setContrastEnhancementAlgorithm( QString theAlgorithm, bool theGenerateLookupTableFlag = true );
382

  
383
    /** \brief Mutator for contrast enhancement function */
384
    void setContrastEnhancementFunction( QgsContrastEnhancementFunction* theFunction );
385

  
386
    /** \brief Overloaded version of the above function for convenience when restoring from xml */
387
    void setDrawingStyle( const QString & theDrawingStyleQString );
388

  
389
    /** \brief Mutator for gray band name mapping  */
390
    void setGrayBandName( const QString & theBandName );
391

  
392
    /** \brief Mutator for green band name mapping  */
393
    void setGreenBandName( const QString & theBandName );
394

  
395
    /** \brief Mutator for setting the maximum value for contrast enhancement */
396
    void setMaximumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );
397

  
398
    /** \brief Mutator for setting the maximum value for contrast enhancement */
399
    void setMaximumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );
400

  
401
    /** \brief Mutator for setting the minimum value for contrast enhancement */
402
    void setMinimumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );
403

  
404
    /** \brief Mutator for setting the minimum value for contrast enhancement */
405
    void setMinimumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );
406

  
407
    /** \brief Mutator that allows the  NO_DATA entry for this raster to be overridden */
408
    void setNoDataValue( double theNoData );
409

  
410
    /** \brief Set the raster shader function to a user defined function */
411
    void setRasterShaderFunction( QgsRasterShaderFunction* theFunction );
412

  
413
    /** \brief Mutator for red band name (allows alternate mappings e.g. map blue as red color) */
414
    void setRedBandName( const QString & theBandName );
415

  
416
    /** \brief Mutator for transparent band name mapping  */
417
    void setTransparentBandName( const QString & theBandName );
418

  
419
    /**  \brief [ data provider interface ] A wrapper function to emit a progress update signal */
420
    void showProgress( int theValue );
421

  
422
    /** \brief Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS */
423
    QStringList subLayers() const;
424

  
425
    /** \brief Draws a thumbnail of the rasterlayer into the supplied pixmap pointer */
426
    void thumbnailAsPixmap( QPixmap * theQPixmap );
427

  
428
    /** \brief Emit a signal asking for a repaint. (inherited from maplayer) */
429
    void triggerRepaint();
430

  
431

  
432

  
433

  
434

  
435
    //
436
    // Virtural methods
437
    //
438
    /**
439
     * Reorders the *previously selected* sublayers of this layer from bottom to top
440
     *
441
     * (Useful for providers that manage their own layers, such as WMS)
442
     *
443
     */
444
    virtual void setLayerOrder( const QStringList & layers );
445

  
446
    /**
447
     * Set the visibility of the given sublayer name
448
     */
449
    virtual void setSubLayerVisibility( const QString & name, bool vis );
450

  
451

  
452

  
453

  
454

  
455
  public slots:
456
    /** \brief Create GDAL pyramid overviews */
457
    QString buildPyramids( const RasterPyramidList &,
458
                           const QString &  theResamplingMethod = "NEAREST",
459
                           bool theTryInternalFlag = false );
460

  
461
    /** \brief Populate the histogram vector for a given band */
462
    void populateHistogram( int theBandNoInt,
463
                            int theBinCountInt = 256,
464
                            bool theIgnoreOutOfRangeFlag = true,
465
                            bool theThoroughBandScanFlag = false );
466

  
467
    void showStatusMessage( const QString & theMessage );
468

  
469
    /** \brief Propagate progress updates from GDAL up to the parent app */
470
    void updateProgress( int, int );
471

  
472

  
473

  
474

  
475

  
476
  signals:
477
    /** \brief Signal for notifying listeners of long running processes */
478
    void progressUpdate( int theValue );
479

  
480

  
481

  
482

  
483
  protected:
484

  
485
    /** \brief Read the symbology for the current layer from the Dom node supplied */
486
    bool readSymbology( const QDomNode& node, QString& errorMessage );
487

  
488
    /** \brief Reads layer specific state from project file Dom node */
489
    bool readXml( QDomNode & layer_node );
490

  
491
    /** \brief Write the symbology for the layer into the docment provided */
492
    bool writeSymbology( QDomNode&, QDomDocument& doc, QString& errorMessage ) const;
493

  
494
    /** \brief Write layer specific state to project file Dom node */
495
    bool writeXml( QDomNode & layer_node, QDomDocument & doc );
496

  
497
};
498

  
1
/*! \class QgsRasterLayer
2
 *  \brief This class provides qgis with the ability to render raster datasets
3
 *  onto the mapcanvas..
4
 */
5

  
6
class QgsRasterLayer : QgsMapLayer
7
{
8
%TypeHeaderCode
9
#include <qgsrasterpyramid.h>
10
#include <qgsrasterlayer.h>
11
#include <qgscontrastenhancement.h>
12
#include <qgsrastertransparency.h>
13
#include <qgsrastershader.h>
14
%End
15

  
16
public:
17
    /** \brief This is the constructor for the RasterLayer class.
18
     *
19
     * The main tasks carried out by the constructor are:
20
     *
21
     * -Load the rasters default style (.qml) file if it exists
22
     *
23
     * -Populate the RasterStatsVector with initial values for each band.
24
     *
25
     * -Calculate the layer extents
26
     *
27
     * -Determine whether the layer is gray, paletted or multiband.
28
     *
29
     * -Assign sensible defaults for the red, green, blue and gray bands.
30
     *
31
     * -
32
     * */
33
    QgsRasterLayer( const QString & path = QString::null,
34
                    const QString &  baseName = QString::null,
35
                    bool loadDefaultStyleFlag = true );
36

  
37
    /**  \brief [ data provider interface ] Constructor in provider mode */
38
    QgsRasterLayer( int dummy,
39
                    const QString & baseName = QString(),
40
                    const QString & path = QString(),
41
                    const QString & providerLib = QString(),
42
                    const QStringList & layers = QStringList(),
43
                    const QStringList & styles = QStringList(),
44
                    const QString & format = QString(),
45
                    const QString & crs = QString());
46
                    
47
    /**  \brief [ data provider interface ] Constructor in provider mode to pass the parameters as a map */                
48
    QgsRasterLayer( QString const & rasterLayerPath,
49
                    QString const & baseName,
50
                    QMap<QString,QString> theWmsProperties);
51
                
52

  
53

  
54
    /** \brief The destructor */
55
    ~QgsRasterLayer();
56

  
57

  
58
    //
59
    // Enums, structs and typedefs
60
    //
61
    /** \brief This enumerator describes the types of shading that can be used */
62
    enum ColorShadingAlgorithm
63
    {
64
      UndefinedShader,
65
      PseudoColorShader,
66
      FreakOutShader,
67
      ColorRampShader,
68
      UserDefinedShader
69
    };
70

  
71
    /** \brief This enumerator describes the different kinds of drawing we can do */
72
    enum DrawingStyle
73
    {
74
      UndefinedDrawingStyle,
75
      SingleBandGray,                 // a single band image drawn as a range of gray colors
76
      SingleBandPseudoColor,          // a single band image drawn using a pseudocolor algorithm
77
      PalettedColor,                  //a "Palette" image drawn using color table
78
      PalettedSingleBandGray,        // a "Palette" layer drawn in gray scale
79
      PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
80
      PalettedMultiBandColor,         // currently not supported
81
      MultiBandSingleGandGray,        // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
82
      MultiBandSingleBandPseudoColor, //a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
83
      MultiBandColor                  //a layer containing 2 or more bands, mapped to RGB color space.
84
                                      //In the case of a multiband with only two bands, one band will be mapped to more than one color.
85
    };
86

  
87
    /** \brief This enumerator describes the type of raster layer */
88
    enum LayerType
89
    {
90
      GrayOrUndefined,
91
      Palette,
92
      Multiband
93
    } ;
94

  
95
    /** \brief A list containing on ContrastEnhancement object per raster band in this raster layer */
96
    typedef QList<QgsContrastEnhancement> ContrastEnhancementList;
97

  
98
    /** \brief  A list containing one RasterPyramid struct per raster band in this raster layer.
99
     * POTENTIAL pyramid layer. This works by dividing the height
100
     * and width of the raster by an incrementing number. As soon as the result
101
     * of the division is <=256 we stop allowing RasterPyramid structs
102
     * to be added to the list. Each time a RasterPyramid is created
103
     * we will check to see if a pyramid matching these dimensions already exists
104
     * in the raster layer, and if so mark the exists flag as true */
105
    typedef QList<QgsRasterPyramid> RasterPyramidList;
106

  
107
    /** \brief  A list containing one RasterBandStats struct per raster band in this raster layer.
108
     * Note that while every RasterBandStats element will have the name and number of its associated
109
     * band populated, any additional stats are calculated on a need to know basis.*/
110
    typedef QList<QgsRasterBandStats> RasterStatsList;
111

  
112

  
113

  
114

  
115

  
116
    //
117
    // Static methods:
118
    //
119
    static void buildSupportedRasterFileFilter( QString & fileFilters );
120

  
121
    /** This helper checks to see whether the file name appears to be a valid
122
     *  raster file name.  If the file name looks like it could be valid,
123
     *  but some sort of error occurs in processing the file, the error is
124
     *  returned in retError.
125
     */
126
    static bool isValidRasterFileName( const QString & theFileNameQString, QString &retError );
127

  
128
    static bool isValidRasterFileName( const QString & theFileNameQString );
129

  
130
    /** Return time stamp for given file name */
131
    static QDateTime lastModified( const QString &  name );
132

  
133
    /** \brief ensures that GDAL drivers are registered, but only once */
134
    static void registerGdalDrivers();
135

  
136

  
137

  
138

  
139
    //
140
    // Non Static inline methods
141
    //
142

  
143
    /** \brief  Accessor for blue band name mapping */
144
    QString blueBandName() const;
145

  
146
    /** \brief Accessor for color shader algorithm */
147
    QgsRasterLayer::ColorShadingAlgorithm colorShadingAlgorithm() const;
148

  
149
    /** \brief Accessor for contrast enhancement algorithm */
150
    QgsContrastEnhancement::ContrastEnhancementAlgorithm contrastEnhancementAlgorithm();
151

  
152
    /** \brief Returns contrast enhancement algorithm as a string */
153
    QString contrastEnhancementAlgorithmAsString() const;
154

  
155
    /** \brief Accessor for drawing style */
156
    DrawingStyle drawingStyle();
157

  
158
    /** \brief Accessor for gray band name mapping */
159
    QString grayBandName() const;
160

  
161
    /** \brief Accessor for green band name mapping */
162
    QString greenBandName() const;
163

  
164
    /** \brief Accessor for mHasPyramids (READ ONLY) */
165
    bool hasPyramids();
166

  
167
    /** \brief Accessor for mUserDefinedGrayMinimumMaximum */
168
    bool hasUserDefinedGrayMinimumMaximum() const;
169

  
170
    /** \brief Accessor for mUserDefinedRGBMinimumMaximum */
171
    bool hasUserDefinedRGBMinimumMaximum() const;
172

  
173
    /** \brief Accessor that returns the height of the (unclipped) raster */
174
    int height();
175

  
176
    /** \brief Accessor to find out whether the histogram should be inverted  */
177
    bool invertHistogram() const;
178

  
179
    /** \brief Is the NoDataValue Valid */
180
    bool isNoDataValueValid() const;
181

  
182
    /** \brief Accessor for mGrayMinimumMaximumEstimated */
183
    bool isGrayMinimumMaximumEstimated() const;
184

  
185
    /** \brief Accessor for mRGBMinimumMaximumEstimated */
186
    bool isRGBMinimumMaximumEstimated() const;
187

  
188
    /** \brief Accessor that returns the NO_DATA entry for this raster */
189
    double noDataValue( bool* isValid = 0 );
190

  
191
    /** \brief Returns a pointer to the transparency object */
192
    QgsRasterTransparency* rasterTransparency();
193

  
194
    /** \brief Accessor for raster shader */
195
    QgsRasterShader* rasterShader();
196

  
197
    /** \brief  Accessor for raster layer type (which is a read only property) */
198
    LayerType rasterType();
199

  
200
    /** \brief Accessor for red band name (allows alternate mappings e.g. map blue as red color) */
201
    QString redBandName();
202

  
203
    /**  [ data provider interface ] Set the data provider */
204
    void setDataProvider( const QString & provider,
205
                          const QStringList & layers,
206
                          const QStringList & styles,
207
                          const QString & format,
208
                          const QString & crs,
209
                          const QString &sldurl=QString(),
210
						  const QString &sldbody=QString());
211

  
212
    /** \brief Mutator for drawing style */
213
    void setDrawingStyle( const DrawingStyle &  theDrawingStyle );
214

  
215
    /** \brief Mutator for mGrayMinimumMaximumEstimated */
216
    void setGrayMinimumMaximumEstimated( bool theBool );
217

  
218
    /** \brief Mutator to alter the state of the invert histogram flag  */
219
    void setInvertHistogram( bool theFlag );
220

  
221
    /** \brief Mutator for mRGBMinimumMaximumEstimated */
222
    void setRGBMinimumMaximumEstimated( bool theBool );
223

  
224
    /** \brief Mutator to alter the number of standard deviations that should be plotted */
225
    void setStandardDeviations( double theStdDevsToPlot );
226

  
227
    /** \brief Mutator for mUserDefinedGrayMinimumMaximum */
228
    void setUserDefinedGrayMinimumMaximum( bool theBool );
229

  
230
    /** \brief Mutator for mUserDefinedRGBMinimumMaximum */
231
    void setUserDefinedRGBMinimumMaximum( bool theBool );
232

  
233
    /** \brief Accessor to find out how many standard deviations are being plotted */
234
    double standardDeviations() const;
235

  
236
    /** \brief  Accessor for transparent band name mapping */
237
    QString transparentBandName() const;
238

  
239
    /**  \brief [ data provider interface ] Does this layer use a provider for setting/retrieving data? */
240
    bool usesProvider();
241

  
242
    /** \brief Accessor that returns the width of the (unclipped) raster  */
243
    int width();
244

  
245

  
246

  
247

  
248

  
249
    //
250
    // Non Static methods
251
    //
252
    /** \brief Get the number of bands in this layer  */
253
    unsigned int bandCount();
254

  
255
    /** \brief Get the name of a band given its number  */
256
    const  QString bandName( int theBandNoInt );
257

  
258
    /** \brief Get the number of a band given its name. The name is the rewritten name set
259
    *   up in the constructor, and will not necessarily be the same as the name retrieved directly from gdal!
260
    *   If no matching band is found zero will be returned! */
261
    int bandNumber( const QString & theBandName );
262

  
263
    /** \brief Get RasterBandStats for a band given its number (read only)  */
264
    const  QgsRasterBandStats bandStatistics( int );
265

  
266
    /** \brief Get RasterBandStats for a band given its name (read only)  */
267
    const  QgsRasterBandStats bandStatistics( const QString & );
268

  
269
    /** \brief Accessor for ths raster layers pyramid list. A pyramid list defines the
270
     * POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers
271
     * ACTUALLY exists you need to look at the existsFlag member in each struct stored in the
272
     * list.
273
     */
274
    RasterPyramidList buildPyramidList();
275

  
276
    /** \brief Accessor for color shader algorithm */
277
    QString colorShadingAlgorithmAsString() const;
278

  
279
    /** \brief Wrapper for GDALComputeRasterMinMax with the estimate option */
280
    void computeMinimumMaximumEstimates( int theBand, double* theMinMax );
281

  
282
    /** \brief Wrapper for GDALComputeRasterMinMax with the estimate option */
283
    void computeMinimumMaximumEstimates( QString theBand, double* theMinMax );
284

  
285
    /** \brief Get a pointer to the contrast enhancement for the selected band */
286
    QgsContrastEnhancement* contrastEnhancement( unsigned int theBand );
287

  
288
    /**Copies the symbology settings from another layer. Returns true in case of success*/
289
    bool copySymbologySettings( const QgsMapLayer& theOther );
290

  
291
    /** \brief Get a pointer to the color table */
292
//QList<QgsColorRampShader::ColorRampItem>* colorTable( int theBandNoInt );
293

  
294
    /** Returns the data provider */
295
    QgsRasterDataProvider* dataProvider();
296

  
297
    /** Returns the data provider in a const-correct manner */
298
    //const QgsRasterDataProvider* dataProvider() const;
299

  
300
    /** \brief This is called when the view on the raster layer needs to be redrawn */
301
    bool draw( QgsRenderContext& rendererContext );
302

  
303
    /** \brief This is an overloaded version of the draw() function that is called by both draw() and thumbnailAsPixmap */
304
    void draw( QPainter * theQPainter,
305
               QgsRasterViewPort * myRasterViewPort,
306
               const QgsMapToPixel* theQgsMapToPixel = 0 );
307

  
308
    /** \brief Returns a string representation of drawing style
309
     *
310
     * Implementaed mainly for serialisation / deserialisation of settings to xml.
311
     * NOTE: May be deprecated in the future!. DrawingStyle drawingStyle() instead.
312
     * */
313
    QString drawingStyleAsString() const;
314

  
315
    /** \brief Checks if symbology is the same as another layers */
316
    bool hasCompatibleSymbology( const QgsMapLayer& theOther ) const;
317

  
318
    /** \brief  Check whether a given band number has stats associated with it */
319
    bool hasStatistics( int theBandNoInt );
320

  
321
    /** \brief Identify raster value(s) found on the point position */
322
    bool identify( const QgsPoint & point, QMap<QString, QString>& results /Out/ );
323

  
324
    /** \brief Identify arbitrary details from the WMS server found on the point position */
325
    QString identifyAsText( const QgsPoint & point );
326

  
327
    /** \brief Currently returns always false */
328
    bool isEditable() const;
329

  
330
    /** \brief [ data provider interface ] If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure  */
331
    QString lastError();
332

  
333
    /** \brief [ data provider interface ] If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure */
334
    QString lastErrorTitle();
335

  
336
    /** \brief Get a legend image for this layer */
337
    QPixmap legendAsPixmap();
338

  
339
    /** \brief  Overloaded version of above function that can print layer name onto legend */
340
//QPixmap legendAsPixmap( bool );
341

  
342
    /** \brief Use this method when you want an annotated legend suitable for print output etc */
343
//QPixmap legendAsPixmap( int theLabelCount );
344

  
345
    /** \brief Accessor for maximum value user for contrast enhancement */
346
    double maximumValue( unsigned int theBand );
347

  
348
    /** \brief Accessor for maximum value user for contrast enhancement */
349
    double maximumValue( QString theBand );
350

  
351
    /** \brief Obtain GDAL Metadata for this layer */
352
    QString metadata();
353

  
354
    /** \brief Accessor for minimum value user for contrast enhancement */
355
    double minimumValue( unsigned int theBand );
356

  
357
    /** \brief Accessor for minimum value user for contrast enhancement */
358
    double minimumValue( QString theBand );
359

  
360
    /** \brief Get an 100x100 pixmap of the color palette. If the layer has no palette a white pixmap will be returned */
361
    QPixmap paletteAsPixmap( int theBand = 1 );
362

  
363
    /**  \brief [ data provider interface ] Which provider is being used for this Raster Layer? */
364
    QString providerKey();
365

  
366
    /** \brief Returns the number of raster units per each raster pixel. In a world file, this is normally the first row (without the sign) */
367
    double rasterUnitsPerPixel();
368

  
369
    /** \brief Read color table from GDAL raster band */
370
//bool readColorTable( int theBandNumber, QList<QgsColorRampShader::ColorRampItem>* theList );
371

  
372
    /** \brief Simple reset function that set the noDataValue back to the value stored in the first raster band */
373
    void resetNoDataValue();
374

  
375
    /** \brief Mutator for blue band name mapping */
376
    void setBlueBandName( const QString & theBandName );
377

  
378
    /** \brief Mutator for color shader algorithm */
379
    void setColorShadingAlgorithm( QgsRasterLayer::ColorShadingAlgorithm theShaderAlgorithm );
380

  
381
    /** \brief Mutator for color shader algorithm */
382
    void setColorShadingAlgorithm( QString theShaderAlgorithm );
383

  
384
    /** \brief Mutator for contrast enhancement algorithm */
385
    void setContrastEnhancementAlgorithm( QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm,
386
                                          bool theGenerateLookupTableFlag = true );
387

  
388
    /** \brief Mutator for contrast enhancement algorithm */
389
    void setContrastEnhancementAlgorithm( QString theAlgorithm, bool theGenerateLookupTableFlag = true );
390

  
391
    /** \brief Mutator for contrast enhancement function */
392
    void setContrastEnhancementFunction( QgsContrastEnhancementFunction* theFunction );
393

  
394
    /** \brief Overloaded version of the above function for convenience when restoring from xml */
395
    void setDrawingStyle( const QString & theDrawingStyleQString );
396

  
397
    /** \brief Mutator for gray band name mapping  */
398
    void setGrayBandName( const QString & theBandName );
399

  
400
    /** \brief Mutator for green band name mapping  */
401
    void setGreenBandName( const QString & theBandName );
402

  
403
    /** \brief Mutator for setting the maximum value for contrast enhancement */
404
    void setMaximumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );
405

  
406
    /** \brief Mutator for setting the maximum value for contrast enhancement */
407
    void setMaximumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );
408

  
409
    /** \brief Mutator for setting the minimum value for contrast enhancement */
410
    void setMinimumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );
411

  
412
    /** \brief Mutator for setting the minimum value for contrast enhancement */
413
    void setMinimumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );
414

  
415
    /** \brief Mutator that allows the  NO_DATA entry for this raster to be overridden */
416
    void setNoDataValue( double theNoData );
417

  
418
    /** \brief Set the raster shader function to a user defined function */
419
    void setRasterShaderFunction( QgsRasterShaderFunction* theFunction );
420

  
421
    /** \brief Mutator for red band name (allows alternate mappings e.g. map blue as red color) */
422
    void setRedBandName( const QString & theBandName );
423

  
424
    /** \brief Mutator for transparent band name mapping  */
425
    void setTransparentBandName( const QString & theBandName );
426

  
427
    /**  \brief [ data provider interface ] A wrapper function to emit a progress update signal */
428
    void showProgress( int theValue );
429

  
430
    /** \brief Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS */
431
    QStringList subLayers() const;
432

  
433
    /** \brief Draws a thumbnail of the rasterlayer into the supplied pixmap pointer */
434
    void thumbnailAsPixmap( QPixmap * theQPixmap );
435

  
436
    /** \brief Emit a signal asking for a repaint. (inherited from maplayer) */
437
    void triggerRepaint();
438

  
439

  
440

  
441

  
442

  
443
    //
444
    // Virtural methods
445
    //
446
    /**
447
     * Reorders the *previously selected* sublayers of this layer from bottom to top
448
     *
449
     * (Useful for providers that manage their own layers, such as WMS)
450
     *
451
     */
452
    virtual void setLayerOrder( const QStringList & layers );
453

  
454
    /**
455
     * Set the visibility of the given sublayer name
456
     */
457
    virtual void setSubLayerVisibility( const QString & name, bool vis );
458

  
459

  
460

  
461

  
462

  
463
  public slots:
464
    /** \brief Create GDAL pyramid overviews */
465
    QString buildPyramids( const RasterPyramidList &,
466
                           const QString &  theResamplingMethod = "NEAREST",
467
                           bool theTryInternalFlag = false );
468

  
469
    /** \brief Populate the histogram vector for a given band */
470
    void populateHistogram( int theBandNoInt,
471
                            int theBinCountInt = 256,
472
                            bool theIgnoreOutOfRangeFlag = true,
473
                            bool theThoroughBandScanFlag = false );
474

  
475
    void showStatusMessage( const QString & theMessage );
476

  
477
    /** \brief Propagate progress updates from GDAL up to the parent app */
478
    void updateProgress( int, int );
479

  
480

  
481

  
482

  
483

  
484
  signals:
485
    /** \brief Signal for notifying listeners of long running processes */
486
    void progressUpdate( int theValue );
487

  
488

  
489

  
490

  
491
  protected:
492

  
493
    /** \brief Read the symbology for the current layer from the Dom node supplied */
494
    bool readSymbology( const QDomNode& node, QString& errorMessage );
495

  
496
    /** \brief Reads layer specific state from project file Dom node */
497
    bool readXml( QDomNode & layer_node );
498

  
499
    /** \brief Write the symbology for the layer into the docment provided */
500
    bool writeSymbology( QDomNode&, QDomDocument& doc, QString& errorMessage ) const;
501

  
502
    /** \brief Write layer specific state to project file Dom node */
503
    bool writeXml( QDomNode & layer_node, QDomDocument & doc );
504

  
505
};
506

  
src/app/qgisapp.cpp (working copy)
2751 2751

  
2752 2752
  if ( wmss->exec() )
2753 2753
  {
2754
    QMap<QString,QString> parameters;
2754 2755

  
2756
	parameters.clear();
2757
	parameters.insert("connection",wmss->connectionInfo());
2758
    parameters.insert("basename",(wmss->selectedLayers().join( "/" )));
2759
	parameters.insert("provider","wms");
2760
	parameters.insert("layers",wmss->selectedLayers().join("/"));
2761
	parameters.insert("styles",wmss->selectedStylesForSelectedLayers().join("/"));
2762
	parameters.insert("format",wmss->selectedImageEncoding());
2763
	parameters.insert("crs",wmss->selectedCrs());
2764
	parameters.insert("sld",wmss->sldURL());
2765
	parameters.insert("sld_body",wmss->sldBody());
2766
    addRasterLayer(parameters);
2767

  
2768
	/*QgsRasterLayer* QgisApp::addRasterLayer( QString const & rasterLayerPath,
2769
    QString const & baseName,
2770
    QString const & providerKey,
2771
    QStringList const & layers,
2772
    QStringList const & styles,
2773
    QString const & format,
2774
    QString const & crs )
2755 2775
    addRasterLayer( wmss->connectionInfo(),
2756
                    /*wmss->connName()*/wmss->selectedLayers().join( "/" ),
2776
		            wmss->selectedLayers().join( "/" ),
2757 2777
                    "wms",
2758 2778
                    wmss->selectedLayers(),
2759 2779
                    wmss->selectedStylesForSelectedLayers(),
2760 2780
                    wmss->selectedImageEncoding(),
2761
                    wmss->selectedCrs() );
2781
                    wmss->selectedCrs() );*/
2762 2782
  }
2763 2783
}
2764 2784

  
......
5907 5927

  
5908 5928
} // QgisApp::addRasterLayer
5909 5929

  
5930
/*fred*/
5931
QgsRasterLayer* QgisApp::addRasterLayer( QMap<QString,QString> theWmsLayerProperties)
5932
{
5933
  if ( mMapCanvas && mMapCanvas->isDrawing() )
5934
  {
5935
    return 0;
5936
  }
5937
  mMapCanvas->freeze();
5938
  
5939
  // create the layer
5940
  QgsRasterLayer *layer;
5941
  
5942
  /*QgsDebugMsg( "Creating new raster layer using " + rasterLayerPath
5943
               + " with baseName of " + baseName
5944
               + " and layer list of " + layers.join( ", " )
5945
               + " and style list of " + styles.join( ", " )
5946
               + " and format of " + format
5947
               + " and providerKey of " + providerKey
5948
               + " and CRS of " + crs );*/
5949
  QString rasterLayerPath=theWmsLayerProperties.value("connection");
5950
  QString baseName=theWmsLayerProperties.value("basename");
5951
  layer = new QgsRasterLayer(rasterLayerPath,baseName,theWmsLayerProperties);
5952
  //layer = new QgsRasterLayer( 0, rasterLayerPath, baseName, providerKey, layers, styles, format, crs );
5910 5953

  
5954
  QgsDebugMsg( "Constructed new layer." );
5911 5955

  
5956
  if ( layer && layer->isValid() )
5957
  {
5958
    addRasterLayer( layer );
5959

  
5960
    statusBar()->showMessage( mMapCanvas->extent().toString( 2 ) );
5961

  
5962
  }
5963
  else
5964
  {
5965
    QMessageBox::critical( this, tr( "Layer is not valid" ),
5966
                           tr( "The layer is not a valid layer and can not be added to the map" ) );
5967
  }
5968

  
5969
  // update UI
5970
  qApp->processEvents();
5971
  // draw the map
5972
  mMapCanvas->freeze( false );
5973
  mMapCanvas->refresh();
5974
  return layer;
5975
}
5976
/*fred*/
5912 5977
/** Add a raster layer directly without prompting user for location
5913 5978
  The caller must provide information compatible with the provider plugin
5914 5979
  using the rasterLayerPath and baseName. The provider can use these
src/app/qgisapp.h (working copy)
99 99
      */
100 100
    bool addRasterLayers( QStringList const & theLayerQStringList, bool guiWarning = true );
101 101

  
102
	/** Open a raster layer using the Raster Data Provider.
103
     *  This method use a map to pass all the neccesary wms properties
104
     */
105
	QgsRasterLayer* addRasterLayer( QMap<QString,QString> theWmsLayerProperties);
106

  
102 107
    /** Open a raster layer using the Raster Data Provider.
103 108
     *  Note this is included to support WMS layers only at this stage,
104 109
     *  GDAL layer support via a Provider is not yet implemented.
src/app/qgsrasterlayerproperties.cpp (working copy)
57 57
    mRasterLayer( dynamic_cast<QgsRasterLayer*>( lyr ) )
58 58
{
59 59

  
60
  
61

  
60 62
  ignoreSpinBoxEvent = false; //Short circuit signal loop between min max field and stdDev spin box
61 63
  mGrayMinimumMaximumEstimated = true;
62 64
  mRGBMinimumMaximumEstimated = true;
......
75 77
  }
76 78

  
77 79
  setupUi( this );
80
   // disable SLD tab
81
  tabBar->setTabEnabled( tabBar->indexOf( tabSLD ), FALSE );
82

  
78 83
  connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
79 84
  connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
80 85
  connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
......
163 168
  int myBandCountInt = mRasterLayer->bandCount();
164 169

  
165 170
  QgsDebugMsg( QString( "Looping though %1 image layers to get their names " ).arg( myBandCountInt ) );
166

  
171
  
167 172
  for ( int myIteratorInt = 1;
168 173
        myIteratorInt <= myBandCountInt;
169 174
        ++myIteratorInt )
170 175
  {
176
    QString num;	
171 177
    //find out the name of this band
172 178
    QString myRasterBandNameQString = mRasterLayer->bandName( myIteratorInt ) ;
173 179

  
......
269 275
  // Only do pyramids if dealing directly with GDAL.
270 276
  if ( mRasterLayerIsGdal )
271 277
  {
278
    
272 279
    QgsRasterLayer::RasterPyramidList myPyramidList = mRasterLayer->buildPyramidList();
273 280
    QgsRasterLayer::RasterPyramidList::iterator myRasterPyramidIterator;
274 281

  
......
297 304

  
298 305
    // disable Histogram tab completely
299 306
    tabBar->setTabEnabled( tabBar->indexOf( tabPageHistogram ), FALSE );
307
	// enable SLD tab
308
	tabBar->setTabEnabled( tabBar->indexOf( tabSLD ), TRUE );
300 309
  }
301 310

  
302 311
  leSpatialRefSys->setText( mRasterLayer->srs().toProj4() );
......
315 324
                                 .arg( pyramidSentence4 ).arg( pyramidSentence5 ) );
316 325

  
317 326
  // update based on lyr's current state
327
  
318 328
  sync();
319 329
} // QgsRasterLayerProperties ctor
320 330

  
......
837 847
  txtbMetadata->document()->setDefaultStyleSheet( myStyle );
838 848
  txtbMetadata->setHtml( mRasterLayer->metadata() );
839 849

  
850

  
851
  QgsDebugMsg( "populate sld tab" );
852
  /*
853
   * SLD Tab
854
   */
855
  if ( mRasterLayerIsWms ){
856
     sldURLEdit->setText(mRasterLayer->dataProvider()->sldURL()); 
857
     sldBodyText->clear();
858
	 sldBodyText->appendPlainText(mRasterLayer->dataProvider()->sldBody());
859
  }
860

  
840 861
} // QgsRasterLayerProperties::sync()
841 862

  
842 863
void QgsRasterLayerProperties::syncColormapTab()
... This diff was truncated because it exceeds the maximum size that can be displayed.