12
12
* (at your option) any later version. *
13
13
* *
14
14
***************************************************************************/
15
- /* qgsprojectio.cpp,v 1.12 2003/12/26 15:56:30 stevehalasz Exp */
15
+ /* qgsprojectio.cpp,v 1.13 2004/01/13 15:15:31 timlinux Exp */
16
16
#include < iostream>
17
17
#include < fstream>
18
18
#include < qfiledialog.h>
21
21
#include < qmessagebox.h>
22
22
#include < qcolor.h>
23
23
#include " qgsmaplayer.h"
24
+ #include " qvariant.h"
24
25
#ifdef POSTGRESQL
25
26
#include " qgsdatabaselayer.h"
26
27
#endif
@@ -176,10 +177,51 @@ bool QgsProjectIo::read(){
176
177
shpl->setSymbol (sym);
177
178
shpl->setVisible (visible == " 1" );
178
179
} else if ( type == " raster" ) {
179
- QgsRasterLayer *rastl = new QgsRasterLayer (dataSource, layerName);
180
+ QgsRasterLayer *myRasterLayer = new QgsRasterLayer (dataSource, layerName);
180
181
181
- map->addLayer (rastl);
182
- rastl->setVisible (visible == " 1" );
182
+ map->addLayer (myRasterLayer);
183
+
184
+ myRasterLayer->setVisible (visible == " 1" );
185
+
186
+ mnl = node.namedItem (" rasterproperties" );
187
+
188
+ QDomNode snode = mnl.namedItem (" showDebugOverlayFlag" );
189
+ QDomElement myElement = snode.toElement ();
190
+ QVariant myQVariant = (QVariant) myElement.attribute (" boolean" );
191
+ myRasterLayer->setShowDebugOverlayFlag (myQVariant.toBool ());
192
+
193
+ snode = mnl.namedItem (" showGrayAsColorFlag" );
194
+ myElement = snode.toElement ();
195
+ myQVariant = (QVariant) myElement.attribute (" boolean" );
196
+ myRasterLayer->setShowGrayAsColorFlag (myQVariant.toBool ());
197
+ snode = mnl.namedItem (" invertHistogramFlag" );
198
+ myElement = snode.toElement ();
199
+ myQVariant = (QVariant) myElement.attribute (" boolean" );
200
+ myRasterLayer->setInvertHistogramFlag (myQVariant.toBool ());
201
+
202
+ snode = mnl.namedItem (" stdDevsToPlotDouble" );
203
+ myElement = snode.toElement ();
204
+ myRasterLayer->setStdDevsToPlot (myElement.text ().toDouble ());
205
+
206
+ snode = mnl.namedItem (" transparencyLevelInt" );
207
+ myElement = snode.toElement ();
208
+ myRasterLayer->slot_setTransparency (myElement.text ().toInt ());
209
+
210
+ snode = mnl.namedItem (" redBandNameQString" );
211
+ myElement = snode.toElement ();
212
+ myRasterLayer->setRedBandName (myElement.text ());
213
+ snode = mnl.namedItem (" greenBandNameQString" );
214
+ myElement = snode.toElement ();
215
+ myRasterLayer->setGreenBandName (myElement.text ());
216
+
217
+ snode = mnl.namedItem (" blueBandNameQString" );
218
+ myElement = snode.toElement ();
219
+ myRasterLayer->setBlueBandName (myElement.text ());
220
+
221
+ snode = mnl.namedItem (" grayBandNameQString" );
222
+ myElement = snode.toElement ();
223
+ myRasterLayer->setGrayBandName (myElement.text ());
224
+
183
225
}
184
226
map->setExtent (savedExtent);
185
227
}
@@ -204,12 +246,17 @@ switch(action){
204
246
}
205
247
return fullPath;
206
248
}
249
+
207
250
void QgsProjectIo::setFileName (QString fn){
208
251
fullPath = fn;
209
252
}
253
+
210
254
QString QgsProjectIo::fullPathName (){
211
255
return fullPath;
212
256
}
257
+
258
+
259
+
213
260
void QgsProjectIo::writeXML (){
214
261
std::ofstream xml (fullPath);
215
262
if (!xml.fail ()){
@@ -278,6 +325,55 @@ void QgsProjectIo::writeXML(){
278
325
279
326
xml << " \t\t </symbol>\n " ;
280
327
}
328
+ else // raster layer properties
329
+ {
330
+ // cast the maplayer to rasterlayer
331
+ QgsRasterLayer *myRasterLayer = (QgsRasterLayer *) lyr;
332
+ // Raster flag to indicate whether debug infor overlay should be rendered onto the raster
333
+ xml << " \t\t <rasterproperties>\n " ;
334
+ xml << " \t\t\t <showDebugOverlayFlag boolean=\" " ;
335
+ if (myRasterLayer->getShowDebugOverlayFlag ())
336
+ {
337
+ xml << " true\" />\n " ;
338
+ }
339
+ else
340
+ {
341
+ xml << " true\" />\n " ;
342
+ }
343
+ // Raster flag indicating whether grayscale images should be rendered as pseudocolor
344
+ xml << " \t\t\t <showGrayAsColorFlag boolean=\" " ;
345
+ if (myRasterLayer->getShowGrayAsColorFlag ())
346
+ {
347
+ xml << " true\" />\n " ;
348
+ }
349
+ else
350
+ {
351
+ xml << " true\" />\n " ;
352
+ }
353
+ // Raster : flag indicating whether the histogram should be inverted or not
354
+ xml << " \t\t\t <invertHistogramFlag boolean=\" " ;
355
+ if (myRasterLayer->getInvertHistogramFlag ())
356
+ {
357
+ xml << " true\" />\n " ;
358
+ }
359
+ else
360
+ {
361
+ xml << " true\" />\n " ;
362
+ }
363
+ // Raster : Number of stddev to plot (0) to ignore -->
364
+ xml << " \t\t\t <stdDevsToPlotDouble>" << myRasterLayer->getStdDevsToPlot () << " </stdDevsToPlotDouble>\n " ;
365
+ // Raster transparency for this layer should be 0-255 -->
366
+ xml << " \t\t\t <transparencyLevelInt>" << myRasterLayer->getTransparency () << " </transparencyLevelInt>\n " ;
367
+ // Raster : the band to be associated with the color red - usually red -->
368
+ xml << " \t\t\t <redBandNameQString>" << myRasterLayer->getRedBandName () << " </redBandNameQString>\n " ;
369
+ // Raster : the band to be associated with the color green - usually green -->
370
+ xml << " \t\t\t <greenBandNameQString>" << myRasterLayer->getGreenBandName () << " </greenBandNameQString>\n " ;
371
+ // Raster : the band to be associated with the color blue - usually blue -->
372
+ xml << " \t\t\t <blueBandNameQString>" << myRasterLayer->getBlueBandName () << " </blueBandNameQString>\n " ;
373
+ // Raster : the band to be associated with the grayscale only ouput - usually gray -->
374
+ xml << " \t\t\t <grayBandNameQString>" << myRasterLayer->getGrayBandName () << " </grayBandNameQString>\n " ;
375
+ xml << " \t\t </rasterproperties>\n " ;
376
+ }
281
377
xml << " \t </maplayer>\n " ;
282
378
}
283
379
xml << " </projectlayers>\n " ;
0 commit comments